akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

std::vector<bool> sieve;
std::vector<int> primes;

void eratosthenes(int maximum){
	sieve = std::vector<bool>(maximum+1);
	sieve[0]=sieve[1]=false;
	for(int i=2; i<sieve.size(); i++) sieve[i]=true;
	for(int j=4; j<sieve.size(); j+=2) sieve[j]=false;
	for(int i=3; 2*i<sieve.size(); i++){
		if(!sieve[i]) continue;
		for(int j=2*i; j<sieve.size(); j+=i) sieve[j] = false;
	}
}

void get_primes(int maximum){
	if(sieve.size() < maximum) eratosthenes(maximum);
	for(int i=2; i<sieve.size(); i++){
		if(sieve[i]) primes.push_back(i);
	}
}

std::map<ll, int> get_factors(ll x){
	std::map<ll, int> factors;
	for(int p: primes){
		if(p*p>x) break;
		while(x%p==0){
			factors[p]++;
			x /= p;
		}
	}
	if(x>1) factors[x]++;
	return factors;
}

ll gcd(ll x, ll y){
	if(y==0) return x;
	else return gcd(y, x%y);
}

int main(){
	get_primes(10000000);
	ll A, B; cin >> A >> B;
	ll d = gcd(A, B);
	debug(d);
	auto fact = get_factors(d);

	if(d == 1) cout << 1 << endl;
	else cout << fact.size() + 1 << endl;

	return 0;
}


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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka
vector<vector<int>> g;
vector<int> l;
vector<int> r;
vector<int> c;
string s;

void dfs(int x, int p) {
    c[x] = (s[x] == '1');
    r[x] = 0;
    l[x] = 0;
    int max = -1;
    for (int i = 0; i < g[x].size(); i++) {
        int y = g[x][i];
        if (y != p) {
            dfs(y, x);
            c[x] += c[y];
            r[x] += (r[y] + c[y]);
            if (max == -1 || l[y] + c[y] > l[max] + c[max]) max = y;
        }
    }
    if (max == -1) {
        l[x] = r[x];
    } else {
        int ll = 0;
        int rr = 0;
        int xx = l[max] + c[max];
        for (int i = 0; i < g[x].size(); i++) {
            int y = g[x][i];
            if (y != p && y != max) {
                ll += l[y] + c[y];
                rr += r[y] + c[y];
            }
        }
        if (ll <= xx && rr >= xx) {
            l[x] = (ll + xx) % 2;
        } else if (ll > xx) {
            l[x] = (ll + xx) % 2;
        } else { // rr < l[max]
            l[x] = xx - rr;
        }
    }
//    if (l[x] % 2 != r[x] % 2) {
//        cout << "!!!";
//    }
}

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    cin >> s;
    g.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    l.resize(n);
    r.resize(n);
    c.resize(n);
    int res = MAX_INT;
    for (int i = 0; i < n; i++) {
        dfs(i, -1);
//        cout << l[i] << " " << r[i] << "\n";
        if (l[i] == 0) {
            res = min(res, r[i]);
        }
    }
    cout << (res == MAX_INT ? -1 : res / 2);

    return 0;
}

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

int main(){

	int n;
	float ax,ay,bx,by,cx,cy,dx,dy;
	float Labx, Laby, Lcdx, Lcdy;
	float cross;

	cin >> n;

	for( int i=0;i<n;i++ ){
		cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;

		Labx = bx - ax;
		Laby = by - ay;
		Lcdx = dx - cx;
		Lcdy = dy - cy;

		cross = Labx * Lcdy - Laby * Lcdx;

		if( cross == 0.0 )
			cout << "YES" << endl;
		else
			cout << "NO" << endl;

	}
	return 0;
}

Measured memory_bytes: 1224
#include <cassert>
#include <cstdio>
#include <vector>
#include <unordered_map>

using namespace std;

using p_t = uint32_t;
using g_t = std::unordered_map<long long, std::unordered_map<long long, long long> >;

std::vector<long long> get_path(g_t &g, long long p1, long long p2, long long fr) {
    assert(p1 != p2);
    for (auto &mp_e : g[p1]) {
       long long e = mp_e.second;
       if (e == fr) continue;
       long long mp = mp_e.first;
       if (mp == p2) {
           return std::vector<long long>{e};
       }
       std::vector<long long> pt = get_path(g, mp, p2, e);
       if (pt.size() != 0) {
           pt.push_back(e);
           return pt;
       }
    }
    return std::vector<long long>{};
}


void solve(long long N, std::vector<long long> a, std::vector<long long> b, long long M, std::vector<long long> u, std::vector<long long> v){
    g_t g;
    for (long long i = 0; i < N - 1; i++) {
        g[a[i]][b[i]] = g[b[i]][a[i]] = i;
    }
    std::vector<p_t> em(N);
    for (long long i = 0; i < M; i++) {
        for (auto &ei : get_path(g, u[i], v[i], -1)) {
            em[ei] |= (1 << i);
        }
    }

    std::unordered_map<p_t, long long> *dp = new std::unordered_map<p_t, long long>;
    (*dp)[0] = 1;
    for (long long ei = 0; ei < N - 1; ei++) {
        p_t ptn = em[ei];
        std::unordered_map<p_t, long long> *ndp = new std::unordered_map<p_t, long long>;
        for (auto &kv : *dp) {
            p_t ptn0 = kv.first;
            long long pv = kv.second;
            (*ndp)[ptn0] += pv;
            (*ndp)[ptn0 | ptn] += pv;
        }
        delete dp;
        dp = ndp;
    }
    printf("%lld\n", (*dp)[(1 << M) - 1]);
    delete dp;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N-1);
    std::vector<long long> b(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    long long M;
    scanf("%lld",&M);
    std::vector<long long> u(M);
    std::vector<long long> v(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&u[i]);
        scanf("%lld",&v[i]);
    }
    solve(N, std::move(a), std::move(b), M, std::move(u), std::move(v));
    return 0;
}


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

namespace b
{
    class Program
    {
        static long n;
        static void Main(string[] args)
        {
            long[] nx = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            n = nx[0];
            long x = nx[1];
            long[,] data = new long[n, n];
            long ans = 0;

            for (long i = 0; i < n; i++)
            {
                data[0, i] = a[i];
                ans += a[i];
            }
            for (long magic = 1; magic < n; magic++)
            {
                long tmp = magic * x;
                for (long slime = 0; slime < n; slime++)
                {
                    data[magic, slime] =
                        Math.Min(data[magic - 1, slime], 
                        data[0, fixNum(slime - magic)]);
                    tmp += data[magic, slime];
                }
                ans = Math.Min(ans, tmp);
            }
            Console.WriteLine(ans);
        }

        static long fixNum(long i)
        {
            if (i < 0) return i + n;
            return i;
        }
    }
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// 出力は.xで！！！！

int main(){
  int n,k; cin >> n >> k;
  vector<vector<int> > ki(n);
  rep(i,n-1){
    int a,b; cin >> a >> b;
    a--; b--;
    ki[a].push_back(b);
    ki[b].push_back(a);
  }
  vector<int> visit(n,0);
  vector<int> ko(n,0);
  queue<P> nord;
  nord.push(P(0,-1));
  mint ans=1;
  while(!nord.empty()){
    int now=nord.front().first;
    int par=nord.front().second;
    visit[now]++;
    nord.pop();
    if(par==-1) ans*=k;
    else{
      int num=2;
      if(par==0) num=1;
      ans*=k-(num+ko[par]);
      ko[par]++;
    }
    rep(i,ki[now].size()){
      if(ki[now][i]==par) continue;
      nord.push(P(ki[now][i],now));
    }
    //cout << ans.x << endl;
  }
  cout << ans.x << endl;
return 0;
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
          
            string[] input = Console.ReadLine().Split(' ');


            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int ans = a * b;

            if(a >= 10 || b >= 10)
            {
                Console.WriteLine(-1);

            }
            else
            {
                  Console.WriteLine(ans);
            }



        }
    }
}



Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main()
{int k;
 cin>>k;
 string s;
  cin>>s;

  int length=s.length();
 // cout<<length<<"\n";

 if(length<=k)
   cout<<s;
 else
 {
   s.resize(k);
   s=s+"...";
   cout<<s;

 }




  return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string.h>
    using namespace std;
    int main()
    {
      char s[3];
      char t[3];
      cin >> s;
      cin >> t;

      int count =0;

      for (size_t i = 0; i < 3; i++) {
        if (s[i] == t[i]) {
          count++;
        }
      }

        cout << count << '\n';
        return 0;
      }


Measured memory_bytes: 256
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($K,$X) =  explode(" ",trim(fgets(STDIN)));
//$H =  explode(" ",trim(fgets(STDIN)));

$S=array();
for($i=0;$i<$N;$i++) {
  $wks = trim(fgets(STDIN));
  $sa = str_split($wks);
  sort($sa);
  $S[] = implode($sa);
}
$ac = array_count_values($S);
$res=0;
foreach($ac as $v) {
  if ($v > 1) {
    $res += intdiv($v * ($v -1),2);
  }
}

printf("%d\n",$res);

Measured memory_bytes: 19188
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int m[100];

int main()
{
	int n,x;
	int ans=0;
	int s=0;
	
	cin>>n>>x;
	for(int i=0;i<n;i++)
	{
		cin>>m[i];
		s+=m[i];
	}
	sort(m,m+n);
	x-=s;
	ans+=n;
	ans+=x/m[0];
	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<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  ll K,N;
  cin >> K >> N;
  vector<ll> A(N);
  cin >> A.at(0);
  ll m = 0;
  rep(i,N-1){
    cin >> A.at(i+1);
    m = max(A.at(i+1) - A.at(i),m);
  }
  m = max(K + A.at(0) - A.at(N-1),m);
  cout << K - m <<endl;
  return 0;
}



Measured memory_bytes: 1792
dict = {}
N = int(raw_input())
for i in range(N):
    blue = raw_input()
    if blue in dict: dict[blue] += 1
    else: dict[blue] = 1

M = int(raw_input())
for i in range(M):
    red = raw_input()
    if red in dict: dict[red] -= 1
    else: dict[red] = -1

if 0 < max(dict.values()): print max(dict.values())
else: print(0)


Measured memory_bytes: 2568
N = int(input())
S = list(input())

lstE = [0] * (N+2)
lstW = [0] * (N+2)

for i in range(1,N+1):
    if S[i-1] == 'W':
        lstE[i] = lstE[i-1] +1
    else:
        lstE[i] = lstE[i-1]

for j in range(N,0,-1):
    if S[j-1] == 'E':
        lstW[j] = lstW[j+1] + 1
    else:
        lstW[j] = lstW[j+1]

ans = N
for k in range(1,N+1):
    ans = min(ans, lstE[k-1]+lstW[k+1])

print (ans)

Measured memory_bytes: 20044
# coding: utf-8
A, B, M = list(map(int,input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
m = [list(map(int, input().split())) for _ in range(M)]

# no discount
min_val = min(a) + min(b)
# with discount
for ai, bi, ci in m:
    val = a[ai-1] +b[bi-1] -ci
    if min_val > val:
        min_val = val
print(min_val)

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

# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "<stdin>"

using namespace std;

# 1 "../Algo/NumberTheory/modulo.h" 1
class ModuloOps {
public:
    ModuloOps(long long mod): MOD(mod) {
    }

    long long binPow(long long a, long long b) {
        if (b < 0) {
            throw "invalid op";
        }
        if (b == 0) {
            return 1;
        }
        auto prev = binPow(a, b/2);
        return mul(mul(prev, prev), b % 2 == 1 ? normalize(a) : 1);
    }

    long long inv(long long a) {
        return binPow(a, MOD - 2);
    }

    inline long long add(long long a, long long b) {
        return normalize(a + b);
    }

    inline long long sub(long long a, long long b) {
        return normalize(a - b);
    }

    inline void inc(long long &a, long long b) {
        a = add(a, b);
    }

    inline long long mul(long long a, long long b) {
        return normalize(normalize(a) * normalize(b));
    }

    inline long long div(long long a, long long b) {
        return mul(a, inv(b));
    }

private:
    long long MOD;

    inline long long normalize(long long a) {
        return (a%MOD + MOD) % MOD;
    }
};
# 5 "<stdin>" 2

ModuloOps MOD(998244353);

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    vector<long long> fact(n+1, 1);
    for (int i = 1; i <= n; i++) {
        fact[i] = MOD.mul(fact[i-1], i);
    }

    auto C = [&] (int n, int k) {
        return MOD.div(fact[n], MOD.mul(fact[k], fact[n-k]));
    };
    long long ans = 0;
    for (int r = 0; r <= k; r++) {
        MOD.inc(ans, MOD.mul(MOD.mul(m, C(n-1, r)), MOD.binPow(m-1, n-1-r)));
    }
    cout << ans << endl;
}


Measured memory_bytes: 4736
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
 int key;
 struct node *left, *right, *parent;
}node;

node *root, *NIL;


void insert(int k) {
 node* y = NIL, * x = root, * z;
 z = (node*)malloc(sizeof(node));
 z->key = k; z->left = NIL; z->right = NIL;

 while (x != NIL) {
  y = x;
  if (k < x->key) {
   x = x->left;
  }
  else {
   x = x->right;
  }
 }
 z->parent = y;

 if (y == NIL) root = z;
 else {
  if (k < y->key) {
   y->left = z;
  }
  else {
   y->right = z;
  }
 }
}

void search(int key) {
  node* copy = root;

 while (copy!= NIL) {
  if (copy->key == key)
{   printf("yes");
   return;
  }
  
    if (key < copy->key) copy = copy->left;
  else copy= copy->right;
  
 }
   printf("no");
 

}

void inOrder(node* input_node) {
 if (input_node == NIL)return;
 inOrder(input_node->left);
 printf(" %d", input_node->key); //from note put space before number
 inOrder(input_node->right);
}
void preOrder(node* input_node) {
 if (input_node == NIL)return;
 printf(" %d", input_node->key);
 preOrder(input_node->left);
 preOrder(input_node->right);
}

int main() {
 int i;
 int n;
 int A[500000];
 scanf("%d", &n);
 char function[258];
 char str1[]="insert";
  char str2[]="print";
  char str3[]="find";
 

 for (i = 0; i<n; i++)
  {
      scanf("%s", function);
    if (strcmp(function, str1) == 0)
     {
        scanf("%d", &A[i]);
        insert(A[i]);
  }
  if (strcmp(str3, function) == 0)
   {
       scanf("%d", &A[i]);
       search(A[i]);
       printf("\n");
  }
  if (strcmp(str2, function) == 0) 
  {
      inOrder(root);
      printf("\n");
      preOrder(root);
      printf("\n");
  }
 }

 return 0;
}



Measured memory_bytes: 27156
#include<bits/stdc++.h>
using namespace std;
using ll = unsigned long long;

int main(){
    int n, m;
    while( cin >> n >> m ){
        bool arr[n+1];
        int sub[n+1];
        memset( arr, false, sizeof arr );
        memset( sub, 0, sizeof sub );
        int ac = 0, pan = 0;
        for( int i = 0; i < m; i++ ){
            int a;
            string v;
            cin >> a >> v;
            if( v == "WA" && arr[a] == false ){
                sub[a]++;
            }else if( v == "AC" ){
                arr[a] = true;
            }
        }
        for( int i = 0; i <= n; i++ ){
            if( arr[i] == true ){
                ac++;
                pan+=sub[i];
            }
        }
        cout << ac << " " << pan << endl;
    }
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ld=long double;
typedef pair<int,int> P;
ld dp[605],EPS=1e-15,ans=1e9;
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}

signed main(){
  int n,m;cin>>n>>m;
  vector<int> edge[n];
  while(m--){
    int s,t;cin>>s>>t;
    edge[--s].push_back(--t);
  }
  ld ans=1e9;
  for(int i=0;i<=n;i++){
    if(edge[i].size()==1)continue;
    memset(dp,0,sizeof(dp));
    for(int j=n-1;j>=0;j--){
      if(i==j){
        ld tmp=0;int a;
        for(int p:edge[j])if(tmp<dp[p])tmp=dp[p],a=p;
        for(int p:edge[j])if(p!=a)dp[j]+=(dp[p]+1)/((ld)edge[j].size()-1);
      }
      else for(int p:edge[j])dp[j]+=(dp[p]+1)/(ld)edge[j].size();
    }
    if(dp[0]>EPS)chmin(ans,dp[0]);
  }
  cout<<fixed<<setprecision(12)<<ans<<endl;
}

/*
解説AC
扉閉める条件なくても期待値求められなくね？
->O(NM)で求める方法は思いついたけどこれ以上どうしろと？
->解説見る
期待値は後ろから求めて行けばよさげ？あと部屋からNにいける道しかないのが楽でよかった
別に後ろからじゃなくてもいいのかな
いやでも前からだと通路通った分の+1が出来ない気がするんだよな
後ろからだと線形になっているからなんとかなるんだけど
後ろから求める方法さえ分かれば最大のそれを削るのは割と明らかに見える
*/


Measured memory_bytes: 1408
// Shift-JIS（シフトジス）

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

int gcd(int a, int b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

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

    int nc = 0;
    for (int i = 2; i < S.size() - 1; i++)
    {
        if (S[i] == 'C') nc++;
    }

    int nu = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (isupper(S[i])) nu++;
    }

    if (S[0] == 'A' && nc == 1 && nu == 2) cout << "AC" << endl;
    else cout << "WA" << endl;
}

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

using namespace std;

int main(int argc, char *argv[])
{
    
    
    
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int n,m;
    while (cin >> n >> m, n||m) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (i == 0 || j == 0 || i == n-1 || j == m -1) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3140
import math

def dist(x1,x2):
    tmp = 0
    for i,j in zip(x1,x2):
        tmp += (i - j) * (i - j)
    return math.sqrt(tmp)

n,d = map(int,input().split()) 
x = []
for i in range(n):
    x.append(list(map(int,input().split())))

count = 0
for i in range(n):
    for j in range(i+1,n):
        tmp = dist(x[i],x[j])
        if abs(tmp - round(tmp)) < 0.0001:
            count += 1
print(count)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main()
{
    int D;
    cin>>D;
    if(D==25){
        cout<<"Christmas"<<endl;
    }else if(D==24){
        cout<<"Christmas Eve"<<endl;
    }else if(D==23){
        cout<<"Christmas Eve Eve"<<endl;
    }else if(D==22){
        cout<<"Christmas Eve Eve Eve"<<endl;
    }
}

Measured memory_bytes: 3560
#include<stdio.h>
#include<string.h>
int main()
{
	char org[1002], str[1002], *p;
	fgets(org, 1002, stdin);
	strcpy(str, org);
	for (p = org-1; p=strstr(p+1, "peach"); )
		strncpy(str+(p-org), "apple", 5);
	for (p = org-1; p=strstr(p+1, "apple"); )
		strncpy(str+(p-org), "peach", 5);
	printf("%s", str);
	return 0;
}

Measured memory_bytes: 0
n,a,b = input().split()
n = int(n)
a = int(a)
b = int(b)
P = 10**9 + 7

def inv(x):
    return pow(x,P-2,P)

A=max(a,b)
B=min(a,b)

ans =  pow(2,n,P) - 1 

bunsi = 1
bunbo = 1

for i in range(A):
    bunsi = bunsi * (n-i) % P
    bunbo = bunbo * (1+i) % P
    if 1+i==B:
        ans = ans - bunsi * inv(bunbo)
        #print([B, bunsi * inv(bunbo)])
    #print([i+1,bunsi,bunbo])
ans = ans - bunsi * inv(bunbo)
#print([A, bunsi * inv(bunbo)])
    
print( ans % P )

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

ll memo[10][10];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int n;
  cin>>n;

  for(int i=1;i<=n;i++){
    string s = to_string(i);
    int first = s[0]-'0';
    int last = s[s.size()-1]-'0';
    memo[first][last]++;
  }
  ll ans=0;
  for(int i=1;i<=9;i++){
    for(int j=i;j<=9;j++){
      // cout<<i<<':'<<j<<':'<<memo[i][j]<<endl;
      ll t = memo[i][j] * memo[j][i];
      if (i != j) t *= 2;
      ans += t;
    }
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
import sys
def main():
  input = sys.stdin.readline
  n, k = map(int , input().split())
  p_list = list(map(int, input().split()))
  c_list = list(map(int, input().split()))
  res = -float('inf')
  
  for s in range(n):
    S = []
    i = p_list[s] - 1
    S.append(c_list[i])
    while i != s:
      i = p_list[i]-1
      S.append(S[-1] + c_list[i])
    if k <= len(S):
      score = max(S[:k])
    elif S[-1] <= 0:
      score = max(S)
    else:
      score1 = S[-1] * (k//len(S) - 1)
      score1 += max(S)
      
      score2 = S[-1] * (k//len(S))
      r = k%len(S)
      if r!=0:
        score2 += max(0, max(S[:r]))
      score = max(score1, score2)
    res = max(res, score)
  print(res)
      

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

Measured memory_bytes: 81740
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    int r,g,b,n;
    scanf("%d%d%d%d",&r,&g,&b,&n);
    int cnt=0;
    int sum;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            sum=n-(i*r+g*j);
            //cout<<i<<" "<<j<<endl;cout<<sum<<endl;
            if(sum==0||(sum>0&&sum%b==0)) {
                    cnt++;
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

int main(){
	int N;
	cin >> N;
	int X[N],Y[N];
	for (int i=0; i<N; i++) {
		cin >> X[i];
		Y[i] = X[i];
	}

	sort(X, X+N);

	int small, large;
	small = X[N/2 - 1];
	large = X[N/2];

	for (int i=0; i<N; i++){
		if (Y[i] <= small){
			cout << large << endl;
		} else {
			cout << small << endl;
		}
	}
}

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

#define ll long long
ll dp[110][100010];

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

    int n,w;
    cin>>n>>w;

    int val[n+10],weight[n+10];

    memset(dp,-1,sizeof dp);

    for(int i=0;i<n;i++)
        cin>>weight[i]>>val[i];

        dp[0][0]=0;

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<100001;j++)
        {
            if(dp[i][j]!=-1)
            {
                if(j+weight[i]<=w)
                dp[i+1][j+weight[i]]=max(dp[i+1][j+weight[i]],dp[i][j]+val[i]);
                dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            }
        }
    }

ll ans=INT_MIN;


    for(int i=w;i>=0;i--)
        ans=max(ans,dp[n][i]);

        cout<<ans<<'\n';

    return 0;

}


Measured memory_bytes: 86272
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(n,a,b) (a<=(n)&&(n)<b)
#define F first
#define S second
typedef long long ll;
using namespace std;

int main(){
	ll N;
	cin>>N;
	ll mn;
	for(int i=sqrt(N);i>=1;i--){
		if(N%i==0){
			mn=N/i;
			break;
		}
	}
	int ans=0;
	while(mn>0){
		mn/=10;
		ans++;
	}
	p(ans);
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
ll MOD = 1000000007LL;
#include <set>
#include <deque>


int main() {
	ll A, B; cin >> A >> B;
	
	if (A>1 && B>1)
		cout << (A*B+1)/2 << endl;
	else
		cout << 1 << endl;
	


	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N, M; cin >> N >> M;
    priority_queue<ll> pq;
    ll sum = 0;
    for(int i = 0; i < N; i++) {
        ll A; cin >> A;
        pq.push(A);
        sum += A;
    }
    while(M > 0 ) {
        ll n = pq.top(); pq.pop();
        sum -= (n + 1) / 2;
        pq.push(n / 2);
        M--;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4320
import scala.annotation.tailrec
import scala.io.StdIn.{readInt, readLine}

object Main extends App {
  import Implicits.ListOps

  val Zero = BigInt(0)
  val VMax = BigInt(1_000_000_000_000_000_000L)

  val n  = readInt()
  val xs = readLine().split(' ').view.map { BigInt(_) }.toList

  val (s, isOver) =
    if (xs.contains(Zero)) (Zero, false)
    else {
      val (s, ys) = xs.reduceWhile { _ * _ } { _ <= VMax }
      (s, ys.nonEmpty)
    }

  println(if (isOver) -1 else s)
}

/**
  * 拡張メソッド群
  */
object Implicits {

  /**
    * List用拡張メソッド
    * @param self 自身を表すList
    * @tparam A 要素の型
    */
  implicit class ListOps[A](self: List[A]) {

    /**
      * 条件を満たし続ける限りListの要素を集約する
      * 条件を満たさなくなった時点で処理を打切る
      * @param z 初期値
      * @param op 集約演算用の関数
      * @param p 処理を続けるかどうかを判定する述語関数
      * @return 条件を満たさなくなった時点のそれまでの計算結果と残りのリストListの組
      */
    def foldWhile[B](z: B)(op: (B, A) => B)(p: B => Boolean): (B, List[A]) = {

      @tailrec
      def loop(accum: B, zs: List[A]): (B, List[A]) = zs match {
        case Nil => (accum, Nil)
        case x :: xs =>
          val s = op(accum, x)
          if (p(s)) loop(s, xs) else (accum, zs)
      }

      loop(z, self)
    }

    /**
      * foldWhileの初期値を自身の先頭要素にした関数
      */
    def reduceWhile(op: (A, A) => A)(p: A => Boolean): (A, List[A]) = self match {
      case Nil     => throw new UnsupportedOperationException("empty list")
      case x :: xs => xs.foldWhile(x)(op)(p)
    }
  }
}


Measured memory_bytes: 79776
l = input().split()
a,b,c = list(map(int,l))
if max(a,b,c) ==a:
    if b > c:
        print(c,b,a)
    else:
        print(b,c,a)
elif max(a,b,c)==b:
    if a > c:
        print(c,a,b)
    else:
        print(a,c,b)
else:
    if a > b:
        print(b,a,c)
    else:
        print(a,b,c)


Measured memory_bytes: 5592
# -*- coding: utf-8 -*-
from collections import Counter, defaultdict


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 1 << 60


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    g = defaultdict(list)
    rg = Counter()

    V = set()

    def ij2v(i, j):
        if i > j:
            i, j = j, i
        return i * 10**6 + j
    for i, a in enumerate(A, start=1):
        for j in range(len(a)-1):
            u = ij2v(i, a[j])
            v = ij2v(i, a[j+1])
            g[u].append(v)
            rg[v] += 1
            V.add(u)
            V.add(v)

    s = []
    for v in V:
        if not rg[v]:
            s.append(v)

    done = len(s)
    ans = 0
    while s:
        ans += 1
        ns = []
        for u in s:
            for v in g[u]:
                rg[v] -= 1
                if rg[v] == 0:
                    ns.append(v)
                    done += 1
        s = ns

    if done != N * (N-1) // 2:
        return -1

    return ans



def main():
    N = read_int()
    A = [read_int_n() for _ in range(N)]
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 259568
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i =0;i<n;i++){
    int l;
    cin >>l;
    a.at(i)=l;
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(a.at(i)>0){
      for(int j=i;j<n;j++){
        if(a.at(j)>0){
          a.at(j)--;
        }
        else if(a.at(j)==0){
          ans++;
          i--;
          break;
        }
        if(j==n-1){
          ans++;
          i--;
          break;
        }
      }
    }
  }
  cout << ans;
}

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

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N; cin >> N;
    int C[N], S[N], F[N]; for (int i = 0; i < N - 1; ++i) cin >> C[i] >> S[i] >> F[i];

    int res[N];
    for (int i = 0; i < N-1; ++i) {
        res[i] = C[i] + S[i];
        for (int j = i+1; j < N - 1; ++j) {
            if (res[i] <= S[j]) res[i] = C[j] + S[j];
            else {
                if ((res[i] - S[j]) % F[j] > 0) res[i] += C[j] + F[j] - ((res[i] - S[j]) % F[j]);
                else res[i] += C[j];
            }

        }
    }
    res[N-1] = 0;
    for (int i = 0; i < N; ++i) cout << res[i] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   double n,d,c=0,p,q,r,s;
   cin>>n>>d;
   while(n--)
   {
       cin>>p>>q;
       p=p*p,q=q*q;
       p=sqrt(p+q);
       if(p<=d)
        c++;
   }
   cout<<c;
    return 0;
}



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

//#define int long long
#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(c) begin(c),end(c)
const int INF = (1ll << 31) - 1;
const int NIL = -1;
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; }
struct SegmentTree {
	int n;
	vector<int>d, lazy;
	SegmentTree(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, INF);
		lazy.assign(2 * n, NIL);
	}
	void eval(int k, int l, int r) {
		if (lazy[k] != NIL) {
			d[k] = lazy[k];
			if (r - l > 1) lazy[2 * k] = lazy[2 * k + 1] = lazy[k];
			lazy[k] = NIL;
		}
	}
	void update(int a, int b, int x, int k = 1, int l = 0, int r = -1) {
		if (r == -1)r = n;
		eval(k, l, r);
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			lazy[k] = x;
			eval(k, l, r);
		}
		else {
			update(a, b, x, 2 * k, l, (l + r) / 2);
			update(a, b, x, 2 * k + 1, (l + r) / 2, r);
			d[k] = min(d[2 * k], d[2 * k + 1]);
		}
	}
	int find(int a, int b, int k = 1, int l = 0, int r = -1) {
		if (r == -1)r = n;
		eval(k, l, r);
		if (r <= a || b <= l)return INF;
		if (a <= l&&r <= b)return d[k];
		else return min(find(a, b, 2 * k, l, (l + r) / 2), find(a, b, 2 * k + 1, (l + r) / 2, r));
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	SegmentTree seg(n);
	rep(i, 0, q) {
		int com; cin >> com;
		if (com) {
			int s, t; cin >> s >> t;
			cout << seg.find(s, t + 1) << endl;
		}
		else {
			int s, t, x; cin >> s >> t >> x;
			seg.update(s, t + 1, x);
		}
	}
	return 0;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int n, a;
    cin >> n >> a;
    cout << n * n - a << endl;
    return 0;
}

Measured memory_bytes: 3600
N = int(input())
info = [list(map(int,input().split())) for i in range(N)]

for cx in range(101):
    for cy in range(101):
        H_upper = info[0][2]+abs(info[0][0]-cx)+abs(info[0][1]-cy)
        H_lower = info[0][2]+abs(info[0][0]-cx)+abs(info[0][1]-cy) if info[0][2] != 0 else 0
        for i in range(1,N):
            H_upper = min(H_upper,info[i][2]+abs(info[i][0]-cx)+abs(info[i][1]-cy))
            H_lower = max(H_lower,info[i][2]+abs(info[i][0]-cx)+abs(info[i][1]-cy) if info[i][2] != 0 else 0)
        if H_upper == H_lower and 0 < H_lower:
            print(cx,cy,H_upper)
            break
    else:
        continue
    break


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

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

  int ans = 1e9;

  for (int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;
    if (t <= T) ans = min(ans, c);
  }

  if (ans == 1e9) cout << "TLE" << "\n";
  else cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ct = 0;
struct Node {
	vector<int>e;
	bool flag;
	Node():flag(0){}
}node[100009];
int N;
int a, b;
int search(int i, int pre) {
	if (node[i].e.size() == 1&&i!=N&&i!=1)return 1;
	int tot = 0;
	for (int j = 0; j < node[i].e.size();j++){
		if (pre != node[i].e[j]) {
			tot += search(node[i].e[j], i);
		}
	}
	return tot + 1;
}
bool dfs(int i,int pre) {
	if (node[i].e.size()==1&&i!=1)return false;
	int t;
	if (find(node[i].e.begin(), node[i].e.end(), N) != node[i].e.end()) {
		node[i].flag = true;
		return true;
	}
	for (int j = 0; j < node[i].e.size(); j++) {
		if (pre!=node[i].e[j]&&dfs(node[i].e[j],i)) {
			node[i].flag = true;
			return true;
		}
	}
	return false;
}
int main()
{
	scanf("%d", &N);
	int way = 0;
	for (int i = 1; i < N; i++) {
		scanf("%d%d", &a, &b);
		node[a].e.push_back(b);
		node[b].e.push_back(a);
	}
	node[N].flag = true;
	dfs(1, 1);
	int white, black;
	int bnow = 1,bpre = 1;
	for (int i = 1; i <= N; i++) {
		if (node[i].flag == true)way++;
	}
	for (int i = 0; i < node[1].e.size(); i++) {
		if (node[node[1].e[i]].flag == true) {
			bnow = node[1].e[i];
			break;
		}
	}
	if (way > 2) {
		for (int i = 0; i < (way - 1) / 2; i++) {
			for (int j = 0; j < node[bnow].e.size(); j++) {
				if (node[bnow].e[j] != bpre&&node[node[bnow].e[j]].flag == true) {
					bpre = bnow;
					bnow = node[bnow].e[j];
					break;
				}
			}
		}
	}
	node[bpre].e.erase(find(node[bpre].e.begin(), node[bpre].e.end(), bnow));
	node[bnow].e.erase(find(node[bnow].e.begin(), node[bnow].e.end(), bpre));
	black = search(1, 1);
	white = N - black;
	if (white < black) {
		printf("Fennec\n");
	}
	else printf("Snuke\n");
}

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

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        boolean[] abc = new boolean[3];

        for(char c : br.readLine().toCharArray()){
            abc[c-'a'] = true;
        }

        for(boolean b : abc){
            if(!b){
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}

Measured memory_bytes: 21332
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  if(N==3){
    cout<<61<<endl;
    return 0;
  }
  VVL dp(N+1,VL(64));
  ll mod=1e9+7;
  rep(i,64) if(i!=9 and i!=6 and i!=33) dp[3][i]=1;
  rep(i,N-3){
    int tmp=3+i;
    rep(j,64){
      if(j%16==1){
        rep(k,4) if(k!=2) (dp[tmp+1][4+k]+=dp[tmp][j])%=mod;
      }else if(j==8){
        rep(k,4) if(k!=1) (dp[tmp+1][32+k]+=dp[tmp][j])%=mod;
      }else if(j==10){
        rep(k,4) if(k!=1) (dp[tmp+1][40+k]+=dp[tmp][j])%=mod;
      }else if(j==2){
        rep(k,4) if(k!=1) (dp[tmp+1][8+k]+=dp[tmp][j])%=mod;
      }else if(j%16==8){
        rep(k,4) if(k!=1) (dp[tmp+1][32+k]+=dp[tmp][j])%=mod;
      }else if(j%16==2){
        rep(k,4) if(k!=1) (dp[tmp+1][8+k]+=dp[tmp][j])%=mod;
      }else if((j>>2)==2){
        rep(k,4) if(k!=1) (dp[tmp+1][j*4%64+k]+=dp[tmp][j])%=mod;
      }else if((j>>4)==0 and j%4==2){
        rep(k,4) if(k!=1) (dp[tmp+1][j*4+k]+=dp[tmp][j])%=mod;
      }else{
        rep(k,4) (dp[tmp+1][j*4%64+k]+=dp[tmp][j])%=mod;
      }
    }
  }
  ll ans=0;
  rep(i,64) (ans+=dp[N][i])%=mod;
  cout<<ans<<endl;
}

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

#define rep(i, n)     for(int i = 0;      i < int(n); ++i)
#define rep3(i, a, b) for(int i = int(a); i < int(b); ++i)
#define all(x)        (x).begin(),(x).end()
#define sz(x)         int(x.size())

typedef long long ll;

using namespace std;

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

  for(ll d=m/n; d >= 0; d--){
    if(m % d == 0 && m >= n*d){
      cout << d << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
import math
import heapq

N, M = map(int, input().split())
A = list(map(int,input().split()))
B = []
for i in range(N):
	heapq.heappush(B, -A[i])

for _ in range(M):
	tmp = heapq.heappop(B) * (-1)
	tmp = math.floor(tmp/2)
	heapq.heappush(B, -tmp)

print(sum(B) * (-1))

Measured memory_bytes: 14380
#include <iostream>

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

  if(S.find("a") != std::string::npos &&
     S.find("b") != std::string::npos &&
     S.find("c") != std::string::npos){
    std::cout << "Yes" << std::endl;
  }else{
    std::cout << "No" << std::endl;
  }


  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const int MAX=100005;
int n;
int a[MAX];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;++i)cin>>a[i];
    ll curmin=1e18;
    int cnt;
    bool yes=false;
    for(int i=0;i<n;++i)
    {
        if(a[i]<0)
        cnt++;
        if(a[i]==0)
        {
            yes=true;
            break;
        }
    }
    ll ans = 0;
     for(int i=0;i<n;++i)
        {
            ans+=abs(a[i]);
        }
    if(cnt%2==0 || yes)
    {
        cout<<ans ;
        return 0;
    }

    for(int i=0;i<n;++i)
    {
        curmin=min(curmin,(long long)(abs(a[i])));
    }

    cout<<ans-2*curmin;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

int main() {
	int A,B,C,X,Y;
	cin >>  A >> B >> C >> X >> Y;
	long long int ans,tmp;
	int a = X,b = Y,c=0;

	ans = A*a + B*b + C*c;
	while(a>0 || b>0){
		a = max(a-1,0);
		b = max(b-1,0);
		c += 2;
		tmp = a*A + b*B + c*C;
		if(tmp < ans){
			ans = tmp;
		}
	}
	 cout << ans << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    char b;
    cin>>b;
    switch (b) {
        case 'A':
            cout<<'T';
            break;
        case 'T':
            cout<<'A';
            break;
        case 'C':
            cout<<'G';
            break;
        case 'G':
            cout<<'C';
            break;
    }
    cout<<endl;
}

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

AC = [0] * (N + 1)
WA = [0] * (N + 1)

for _ in range(M):
    pS = input().split()
    n = int(pS[0])
    
    if pS[1] == 'AC':
        AC[n] = 1
    elif (pS[1] == 'WA') & (AC[n] == 0):
        WA[n] += 1
        
# 正解数
correct = len([i for i in AC if i > 0])

# ペナルティ
penalty = sum([x * y for (x, y) in zip(AC, WA)])

print(correct, penalty)

Measured memory_bytes: 5528
local BIT={}

local update=function(a,b)
    if a==0 then
        return
    end
    while a<=#BIT do
        BIT[a]=math.max(BIT[a],b)
        a=a+(a&-a)
    end
end

local getmax=function(a)
    local sum=0
    while a>0 do
        sum=math.max(BIT[a],sum)
        a=a-(a&-a)
    end
    return sum
end

----------

local n=io.read("n")
local h,a={},{}
for i=1,n do
    h[i]=io.read("n")
end
for i=1,n do
    a[i]=io.read("n")
end

for i=1,n do
    BIT[i]=0
end
for i=1,n do
    update(h[i],getmax(h[i])+a[i])
end

print(getmax(n))

Measured memory_bytes: 14596
#include <stdio.h>

int main(int argc, const char * argv[]){
    int b, f, r, v;
    int house[5][4][11] = {0};
    int n;

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d%d%d", &b, &f, &r, &v);
        house[b][f][r] += v;
    }
    
    for (b = 1; b <= 4; b++) {
        for (f = 1; f <= 3; f++) {
            for (r = 1; r <= 10; r++) printf(" %d", house[b][f][r]);
            printf("\n");
        }
        if (b < 4) printf("####################\n");
    }
    return 0;
}


Measured memory_bytes: 2080
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


int main(){

    int N;
    cin >> N;

    int t, x, y;

    int t_pre=0;
    int x_pre=0, y_pre=0;
    int step, dis;

    for (int i=0; i<N; i++){
        cin >> t >> x >> y;

        step = t - t_pre;

        int dis = abs(x_pre - x) + abs(y_pre - y);

        if(dis > step){
            cout << "No" << endl;
            return 0;
        }

        if(dis%2 != step%2){
            cout << "No" << endl;
            return 0;
        }

        t_pre = t;
        x_pre = x;
        y_pre = y;
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
//void _(){
//    string s;
//    cin >> s;
//    int ans = 0;
//
//    rep(i,0,sz(s)-2)
//        if(s[i] != s[i+1])
//            ++ans;
//    print(ans);
//}
//
#include <iomanip>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define REP_INT(i,l,r) for(int i = l; i <= r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 void print(T x, string end = "\n"){
    cout << x << end;
}
void _(){
    string s;
    cin >> s;
    int ans = 0;
    rep(i,0,sz(s)-2)
        if(s[i] != s[i+1])
            ++ans;
    print(ans);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        _();
}


Measured memory_bytes: 512
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
//by NeighThorn
using namespace std;
int n,m,ans;
signed main(void){
	scanf("%d",&n);m=sqrt(n);ans=n;
	for(int i=2;i<=m;i++)
		if(n%i==0){
			ans=ans/i*(i-1);
			while(n%i==0)
				n/=i;
		}
	if(n>1)
		ans=ans/n*(n-1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3232
//unsolved list
//CODE FESTIVAL 2017 qual A-D
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1

using namespace std;

const double g=10.0,eps=1e-7;
const int N=500+10,maxn=60000+10,inf=0x3f3f3f;

int n,m,k;
char ans[N][N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m>>k;
    for(int i=1;i<=500;i++)
    {
        for(int j=1;j<=500;j++)
        {
            int x=(i+j+1e9)/k,y=(i-j+1e9)/k;
            if(x%2==1&&y%2==1)ans[i][j]='R';
            else if(x%2==1&&y%2==0)ans[i][j]='Y';
            else if(x%2==0&&y%2==1)ans[i][j]='G';
            else ans[i][j]='B';
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
            cout<<ans[i][j];
        cout<<endl;
    }
    return 0;
}
/********************

********************/


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 10000
#define MAXD 100

int dp[MAXN+1][MAXD+1][2];

int main(){
  string s;cin>>s;
  int n = s.size();
//  reverse(s.begin(), s.end());
  int d;cin>>d;

  dp[0][0][1]=1;

  rep(i, n)rep(j, d)rep(k, 10){
    int cd = s[i]-'0';

    int nj = (j+k)%d;

//cout<<cd<<' '<<j<<'>'<<nj<<' '<<k<<endl;

    if(k==cd){
      dp[i+1][nj][1] += dp[i][j][1];
      dp[i+1][nj][0] += dp[i][j][0];
    }else if(k<cd){
      dp[i+1][nj][0] += dp[i][j][1] + dp[i][j][0];
    }else{
      dp[i+1][nj][0] += dp[i][j][0];
    }
    dp[i+1][nj][1] %= MOD;
    dp[i+1][nj][0] %= MOD;
  }

  ll result = (dp[n][0][1]+dp[n][0][0])%MOD;
  cout << (result-1+MOD)%MOD << endl;

  return 0;

cout<<dp[n][0][1]<<' '<<dp[n][0][0]<<endl;

rep(i, n+1){
  rep(j, d+1)cout<<dp[i][j][0]+dp[i][j][1]<<' ';
  cout<<endl;
}

  return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int a[2 * N + 1];
int n;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    cin >> n;
    int index = 1;
    int res = 0;
    FOR(i, 1, n) cin >> a[i];
    FOR(i, 1, n)
        if(a[i] == index)
        {
            index++;
        }
        else res++;
    if(res >= n) cout << -1;
    else
    cout << res;
    return 0;
}


Measured memory_bytes: 1152