akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

const LL MAX_N = 2000 + 5;

struct Node {
    LL id;
    Node *nex;
    Node(LL id_ = 0, Node *nex_ = NULL)
        : id(id_), nex(nex_) {}
} *head[MAX_N];

void init() {
    for (LL i = 0; i < MAX_N; ++i) head[i] = new Node(-1, NULL);
}

void addEdge(LL u, LL v) {
    Node *e = new Node(v, head[u]->nex); head[u]->nex = e;
    Node *r = new Node(u, head[v]->nex); head[v]->nex = r;
}

LL n, k, A[MAX_N], B[MAX_N];

stack <LL> stk, path;
LL firPath = -1, firNode = -1;
void dfs(LL u, LL fa, LL step, bool recPath) {
    if (recPath) stk.push(u);
    bool haveSon = false;
    for (Node *it = head[u]->nex; it != NULL; it = it->nex) {
        if (it->id != fa) {
            haveSon = true;
            dfs(it->id, u, step + 1, recPath);
        }
    }
    if (step > firPath) {
        firNode = u; firPath = step;
        if (!haveSon) path = stk;
    }
    if (recPath) stk.pop();
}

LL cal(LL u, LL fa, LL step) {
    LL ret = 0;
    if (step > k / 2) ++ret;
    for (Node *it = head[u]->nex; it != NULL; it = it->nex) {
        if (it->id != fa) {
            ret += cal(it->id, u, step + 1);
        }
    }
    // printf("Call cal(u = %lld, fa = %lld, step = %lld), ", u, fa, step);
    // printf("return (ret = %lld)\n", ret);
    return ret;
}

int main() {
    scanf("%lld%lld", &n, &k);
    LL u, v;
    init();
    for (LL i = 1; i <= n - 1; ++i) {
        scanf("%lld%lld", &u, &v);
        addEdge(u, v);
        A[i] = u; B[i] = v;
    }
    LL ans = INT_MAX;
    if (k % 2 == 0) {
        for (LL i = 1; i <= n; ++i) ans = min(ans, cal(i, -1, 0));
    } else {
        for (LL i = 1; i <= n - 1; ++i) ans = min(ans, cal(A[i], B[i], 0) + cal(B[i], A[i], 0));
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 512
from collections import Counter

N = int(input())
a = list(map(int, input().split()))

L = Counter(a)
R = L.most_common()

r = []
for i in range(len(R)):
    if R[i][0] == 1:
        r.append(abs(R[i][1] - R[i][0]))
    else:
        r.append(R[i][1] % R[i][0])

print(sum(r))

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
    int n; cin >> n; vector <ll> h(n);
    for (int i=0;i<n;i++)
    {
        sll(h[i]);
    }
    vector<ll> dp(n,MAX);
    dp[0]=0;
    for (int i=0;i<n;i++)
    {
        for (int j=i+1;j<=i+2;j++)
        {
            if (j<n)
            {
                dp[j]=min(dp[j],dp[i]+abs(h[j]-h[i]));
            }
        }
    }
    cout << dp[n-1];
    return 0;
}


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

using namespace std;

typedef long long ll;

struct N
{
    double v;
    int p;
    bool operator < (N b) const
    {
        return v<b.v;
    }
};

N a[110];

int main()
{
    int n;
    double av=0,tem;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%lf",&tem);
        a[i].p=i;
        a[i].v=tem;
        av+=tem;
    }
    av=av/n;
    for(int i=0;i<n;i++)
        a[i].v=abs(a[i].v-av);
    double m=a[0].v;
    for(int i=1;i<n;i++)
        if(a[i].v<m)m=a[i].v;
    int pp=200;
    for(int i=0;i<n;i++)
        if(a[i].v==m&&a[i].p<pp)pp=a[i].p;
    printf("%d\n",pp);
    return 0;
}


Measured memory_bytes: 256
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
bool DD=0;
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
 
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int N=3e6+10;

	pii b[N];
	int cnt[N];set<int> ok;
	void main()
	{
		int n=qread();int mi0=INF,mi1=INF,mx0=0,mx1=0;
		fo(i,1,n)
		{
			int x=qread(),y=qread();b[i*2-1]={x,i},b[i*2]={y,i};
			if(x>y)swap(x,y);chmin(mi0,x),chmax(mx0,x);chmin(mi1,y),chmax(mx1,y);
		}
		ll ans=1ll*(mx0-mi0)*(mx1-mi1);
		sort(b+1,b+n+n+1);
		if(b[1].SE!=b[n+n].SE or b[1].FR==b[2].FR or b[n+n-1].FR==b[n+n].FR)//有办法同侧
		{
			if(b[1].SE==b[n+n].SE and b[1].FR==b[2].FR) swap(b[1],b[2]);
			if(b[1].SE==b[n+n].SE and b[n+n-1].FR==b[n+n].FR) swap(b[n+n-1],b[n+n]);
			for(int l=2,r=1;;l++)
			{
				while(r+1<n+n and sz(ok)<n) {++r,cnt[b[r].SE]++;if(cnt[b[r].SE]==1) ok.insert(b[r].SE); }
				debug("l=%d r=%d\n",l,r);
				if(sz(ok)<n) break;chmin(ans, 1ll*(b[n+n].FR-b[1].FR)*(b[r].FR-b[l].FR) );
				cnt[b[l].SE]--;if(!cnt[b[l].SE]) ok.erase(b[l].SE);
			}
		}write(ans);
	}
};//(ans+MOD)%MOD
signed main()
{
	//freopen("a.in","r",stdin);
	srand(time(0));
	mine::main();
}

Measured memory_bytes: 16512
N=int(input())
m=list(map(int,str(N)))[::-1]
p=0
n=len(str(N))
if n==1:
    print(N)
    exit()
for i in range(2**(n-1)):
    s=(["0"]*8+list(bin(i)[2:]))[::-1]
    s=s[:n-1]
    p+=m[0]
    q=0
    for i in range(n-1):
        if s[i]=="0":
            q+=1
            p+=(10**q)*(m[i+1])
        else:
            q=0
            p+=m[i+1]
print(p)            
        
        

Measured memory_bytes: 3064
import scala.collection.mutable

object Main {

  val amari = 1000000007

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val S = sc.next()
    val stack = new mutable.Stack[Char]
    var cnt = 0
    for {
      i <- 0 until S.length
    } {
      val s = S.charAt(i)
      if (stack.isEmpty || s == stack.top) {
        stack.push(s)
      } else  {
        stack.pop()
        cnt = cnt+2
      }
    }
    println(cnt)
  }
}


Measured memory_bytes: 31592
#include <stdio.h>
#include <math.h>
#include <string.h>
#define rep(i,n) for(i=0;i<n;i++)
int in(void){
	int i;
	scanf("%d",&i);
	return i;
}
int main(void){
	int a,b;
	a=in();
	b=in();
	printf("%d\n",(a+b)%24);
	return 0;
}

Measured memory_bytes: 128
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;

int main()
{
	ll N;
	cin >> N;
	cout << (N - 1)*N / 2 << endl;
	return 0;
}


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

dp = [1e+09]*N
dp[0] = 0
for i in range(1,N):
  for j in range(1,K+1):
    if i >= j: dp[i] = min(dp[i],dp[i-j]+abs(h[i] - h[i-j]))
print(int(dp[-1]))


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

int main(){
    int X, A; cin >> X >> A;
    if(X<A){
        cout << 0 << endl;
    }
    else{
        cout << 10 << endl;
    }
}

Measured memory_bytes: 256
<?php
$s = strrev(trim(fgets(STDIN)));
$divide = ['dream', 'dreamer', 'erase', 'eraser'];
foreach ($divide as $k => $v) {
    $divide[$k] = strrev($v);
}
$can = true;
for ($i = 0; $i < strlen($s);) {
    $can2 = false;
    foreach ($divide as $v) {
        if (strpos($s, $v, $i) === $i) {
            $can2 = true;
            $i += strlen($v);
        }
    }
    if (! $can2) {
        $can = false;
        break;
    }
}
echo $can ? 'YES' : 'NO';
?>

Measured memory_bytes: 3852
/*
 * ----------------------------------------------------------------------------
 (: Bismillahir Rahmanir Rahim :) 
 * File: /home/grimfirefly/Programming/Atcoder/B_Easy_Linear_Programming.c
 * Project: /home/grimfirefly/Programming/Atcoder
 * Created Date: Thursday, May 14th 2020, 8:13:18 pm
 * Author: Grim Firefly :)
 * Author Mail : GrimFirefly1@gmail.com
 * -----
 * Last Modified: Thu May 14 2020
 * Modified By: Grim Firefly :)
 * -----
 * ----------------------------------------------------------------------------
 */
int min(int x, int y)
{
    if (x < y)
        return x;
    else
        return y;
}
#include <stdio.h>
int main()
{
    int a, b, c, k;
    scanf("%d %d %d %d", &a, &b, &c, &k);
    int ans = 0;
    ans += min(a, k)*1;
    k -= min(a, k);
    ans += min(b, k)*0;
    k -= min(b, k);
    ans -= min(c, k);
    k -= min(c, k);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <ostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using ll = long long;
using ld = long double;
//typedef long long ll;

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

#define INF ((1LL << 31) - 1)
#define INFLL ((1LL << 62) - 1)
#define MOD (ll)(1e9+7)
#define EPS 1e-10
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define P "Yes"
#define NP "No"

template <typename T>
std::ostream& operator << (std::ostream& os, std::vector<T> v) {
  os << "[";
  for (int i = 0; i < int(v.size()); ++i) {
    cout << v[i] << (i == v.size() - 1 ? "]" : ", ");
  }
  return os;
}

int vx[4] = { -1, 0, 1, 0 }, vy[4] = { 0, -1, 0, 1 };
//int vx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, vy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

// [sx, se), [sy, ey)であることに注意
inline bool check(int sx, int ex, int sy, int ey, int x, int y) {
  return (sx <= x and x < ex and sy <= y and y < ey);
}

inline bool check(int ex, int ey, int x, int y) {
  return check(0, ex, 0, ey, x, y);
}

inline void init() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
}

struct T {
  int x, y, cost;
  T() = default;
  T(int x, int y, int cost) : x(x), y(y), cost(cost) {}
};


void solve() {
  int h, w;
  std::string s[51];

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

  int white = 0, black = 0;
  char BLACK = '#', WHITE = '.';

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (i == 0 && j == 0 || i == h - 1 && j == w - 1) {
        continue;
      }
      if (s[i][j] == BLACK) black++;
      else white++;
    }
  }

  std::queue<T> que;
  bool used[51][51];
  std::memset(used, false, sizeof used);
  used[0][0] = true;
  que.push({ 0, 0, 0 });

  int sum_cost = 0;

  while (!que.empty()) {
    T t = que.front();
    que.pop();
    if (t.x == h - 1 && t.y == w - 1) {
      sum_cost = t.cost;
      break;
    }

    for (int i = 0; i < 4; ++i) {
      int nx = t.x + vx[i], ny = t.y + vy[i];

      if (check(h, w, nx, ny) && !used[nx][ny] && s[nx][ny] == WHITE) {
        que.push({ nx, ny, t.cost + 1 });
        used[nx][ny] = true;
      }
    }
  }

  if (!used[h - 1][w - 1]) {
    cout << -1 << endl;
  }
  else {
    cout << std::max(0, (w * h - black - sum_cost - 1)) << endl;
  }
  int n;
  cin >> n;
  return;
}

int main() {

  solve();

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
const int INF = 1000000000;
int dp[50010];
int find(int A[],int n,int key){
    int i;
    for(i=0;i<n;i++){
	if(A[i]==key) return 1;
    }
    return 0;
}

int main(void){
    int n,m,i,j,k;
    int c[20];

    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++){
	scanf("%d",&c[i]);
    }

    dp[0]=0;dp[1]=1;
    for(i=2;i<=n;i++) dp[i]=INF;
    
    for(i=2;i<=n;i++){
	if(find(c,m,i)) dp[i]=1;
	else{
	    for(j=0;j<m;j++){
		if(i-c[j]>0){
		    if(dp[i-c[j]]+1<dp[i]) dp[i]=dp[i-c[j]]+1;
		}
	    }
	}
    }

    printf("%d\n",dp[n]);

    return 0;
}

Measured memory_bytes: 788
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>

using namespace std;

typedef struct datum_name {
	int x;
	int y;
	int whosay;
	bool operator==(const datum_name& data) const
	{
		return (x == data.x && y == data.y);
	}
} datum;


bool cmp_who(const datum& left, const datum& right) {
	return left.whosay < right.whosay;
}


int main()
{
	int64_t A, B;
	cin >> A >> B;
	int64_t i = 1;
	int64_t tmp;
	while (true) {
		tmp = A * i;
		if (tmp % B == 0) break;
		i++;
	}
	cout << tmp << endl;
	return 0;

}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
import sys
from collections import deque
from itertools import *


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


A, B, K = LI()
l = []
for i in range(1,100+1):
    if A % i == 0 and B % i == 0:
        l.append(i)

l.reverse()
print(l[K-1])


Measured memory_bytes: 64900
n = int(input())

march = 'MARCH'
bucket = [0]*5



for _ in range(n):
    s = input()

    pos = march.find(s[0])
    if pos < 0:
        continue

    bucket[pos] += 1


ans = 0
for i in range(5):
    for j in range(1,5):
        if i >= j:
            continue
        for k in  range(2,5):
            if j >= k:
                continue
            
            # print((i,j,k))
            ans += bucket[i]*bucket[j]*bucket[k]


print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define Maxn 110

int n, m, q, A[Maxn], B[Maxn], C[Maxn], D[Maxn], Res, a[Maxn];

void dfs(int dep)
{
	if (dep > n)
	{
		int Rep = 0;
		for (int i=1; i<=q; i++) if (a[B[i]] - a[A[i]] == C[i]) Rep += D[i];
		Res = max(Res, Rep);
		return;
	}
	for (int i=a[dep-1]; i<=m; i++)
	{
		a[dep]=i;
		dfs(dep+1);
	}
}

int main()
{
	scanf("%d%d%d", &n, &m, &q);
	for (int i=1; i<=q; i++)
		scanf("%d%d%d%d", &A[i], &B[i], &C[i], &D[i]);
	a[0]=1;
	dfs(1);							
	printf("%d\n", Res);
}

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

#define ll long long

void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n,greater<>());
    ll total = a[0];
    ll x = 0;
    ll d = 1;
    for(int i=1;i<n-1;i++)
    {
        //cout<<total<<endl;
        total+=a[i];
        x++;
        if(x+2==n)break;
        total+=a[i];
        x++;
        if(x+2==n)break;
    }
    cout<<total<<endl;
}

int main()
{
    solve();
}


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

int main() {
  std::string s, t; std::cin >> s >> t;
  bool ok = true;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] != t[i]) ok = false; 
  }
  if (ok) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  
  return 0;
}

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

int main(){
	#ifndef ONLINE_JUDGE
		freopen ("input.txt", "r", stdin);
		freopen ("output.txt", "w", stdout);
	#endif

    int n; cin>>n;
    int a[n];
    // set<pair<int, pair<int, int>>> st;
    set<set<int>> st;
    int ans=0;
    for(int i=0 ; i<n ; i++) cin>>a[i];
    for(int i=0 ; i<n ; i++){
        for(int j=i+1 ; j<n ; j++){
            for(int k=j+1 ; k<n ; k++){
                if(i!=j && i!=k && j!=k){
                    if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i] && a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k]){
                        ans++;
                        // int x[] = {i, j, k};
                        // sort(x, x+3);
                        set<int> x;
                        x.insert(i);x.insert(j);x.insert(k);
                        // st.insert({x[0], {x[1], x[2]}});
                        // cout<<i<<" "<<j<<" "<<k<<endl;
                        st.insert(x);
                    }
                }
            }
        }
    }
    cout<<st.size()<<endl;
	return 0;
}

Measured memory_bytes: 41368
#include <cstdio>
using namespace std;
#define MOD 100000
int main(){
	int W,H;
	while(1){
		scanf("%d%d",&W,&H);
		if(W == 0 && H == 0){
			break;
		}
		int dp[20][20]={{0}};
		int stage[17][17]={{0}};
		int N;
		scanf("%d",&N);
		for(int i = 0; i < N; i++){
			int a,b;
			scanf("%d %d",&a,&b);
			stage[b][a] = 1;
		}
		dp[1][0] = 1;
		for(int i = 1; i <= H; i++){
			for(int j = 1; j <= W; j++){
				dp[i][j] = dp[i-1][j] + dp[i][j-1];
				if(stage[i][j])dp[i][j] = 0;
			}
		}


		printf("%d\n",dp[H][W]);
	}
	return 0;
}

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

int main(void){

	int a[5001];
	for(int i=0; i<5001; i++) a[i] = 0;

	int n;
	while(cin >> n){
		
		if(n==0) break;
		for(int i=0; i<n; i++){
			cin >> a[i];
		}

		int ans = -999999;
		int sum = 0;

		for(int i=0; i<n; i++){
			for(int j=0; j<(n-i); j++){
				sum = sum + a[i+j];
				if(sum>ans) ans=sum;
			}
			sum = 0;
		}

		cout << ans << endl;

		for(int i=0; i<5001; i++) a[i] = 0;
	}

	return 0;
}

Measured memory_bytes: 0
n = int(input())
h = list(map(int,input().split()))
check = [0,abs(h[0]-h[1])] + [None]*(n-2)
for i in range(n-2):
    check[i+2] = min(check[i]+abs(h[i]-h[i+2]),check[i+1]+abs(h[i+1]-h[i+2]))
print(check[-1])

Measured memory_bytes: 13980
#include <iostream>

using namespace std;
int a, b, c, mn, mx, md;
int main()
{
	cin >> a >> b >> c;
	mn = min(min(a, b), c);
	mx = max(max(a, b), c);
	md = a + b + c - mn - mx;
	cout << mn + md;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n,m;cin>>n>>m;
  int ans=-1;
  vector<pair<int,char>> cond(m);
  int cnt=pow(10,n);
  rep(i,m){
    int si;cin>>si;
    char ci;cin>>ci;
    cond[i]=pair<int,char>(si-1,ci);
  }
  rep(i,cnt){
    string s=to_string(i);
    bool match=true;
    if(s.size()!=n){
      match=false;
      continue;
    }
    rep(j,m){
      if(s[cond[j].first]!=cond[j].second){
        match=false;
        break;
      }
    }
    if(match){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a,b,c;
	int x;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b)
	{
		x=a;
		a=b;
		b=x;
	}
	if(b>c)
	{
		x=b;
		b=c;
		c=x;
	}
	if(a>b)
	{
		x=a;
		a=b;
		b=x;
	}
	printf("%d %d\n",a,c);
	return 0;
}


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

typedef long long ll;
#define rep(n, i) for(int i = 1; i <= n; ++i)

void solve(void) {
  ll n; cin >> n;
  ll res = 0;

  string s = "";

  rep(n, i) {
    if((ll)(to_string(i)).size() % 2 != 0) res++;
  }
  cout << res << endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

struct TreeCut{
  struct Node{
    int p,t;
    vector<int> sib;
  };

  vector<Node> node;
  vector<bool> visited;
  vector<int> back;
  vector<bool> cut;
  int time,n;

  TreeCut(int v){
    n=v;
    node.clear();
    visited.clear();
    back.clear();
    cut.clear();

    node.resize(n);
    visited.resize(n,0);
    back.resize(n);
    cut.resize(n,0);

    time=0;
  }

  void input(int a,int b){
    node[a].sib.push_back(b);
    node[b].sib.push_back(a);
  }

  void search(int v=0,int prev=-1){
    //DFS

    int i,next,small=time;
    visited[v]=1;
    node[v].t=time;
    node[v].p=prev;
    time++;
    for(i=0;i<node[v].sib.size();i++){
      next=node[v].sib[i];
      if(next==prev)continue;
      if(visited[next]){
        small=min(small,node[next].t);
        continue;
      }

      search(next,v);
      small=min(small,back[next]);
    }
    back[v]=small;
  }

  void findCut(){
    int i,par,cnt=0;
    
    for(i=1;i<n;i++){
      par=node[i].p;
      if(back[i]>=node[par].t){
        cut[par]=1;
      }
    }
    
    for(i=0;i<node[0].sib.size();i++){
      if(node[node[0].sib[i]].p==0)cnt++;
    }
    if(cnt>1)cut[0]=1;
    else cut[0]=0;
  }
};

int main(void){
  int v,e,i,s,t;

  cin>>v>>e;
  TreeCut tree(v);

  for(i=0;i<e;i++){
    cin>>s>>t;
    tree.input(s,t);
  }

  tree.search();
  tree.findCut();

  for(i=0;i<v;i++){
    if(tree.cut[i])printf("%d\n",i);
  }

  return 0;
}


Measured memory_bytes: 4400
use std::cmp::{max, min};
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let a = it.next().unwrap();
    let b = it.next().unwrap();
    let c = it.next().unwrap();
    let equal = |c, d| c == d || c == '?' || d == '?';
    let cmp = |a: &str, b: &str| a.chars().zip(b.chars()).all(|(c, d)| equal(c, d));
    let M = 2000isize;
    let calc_a2b = |a: &str, b: &str| {
        let mut ab = vec![true; (2 * M + 1) as usize];
        for i in (-M)..(M + 1) {
            let ai = max(0, i) as usize;
            let bi = max(0, -i) as usize;
            if ai >= a.len() || bi >= b.len() {
                continue;
            }
            ab[(i + M) as usize] = cmp(&a[ai..], &b[bi..]);
        }
        ab
    };
    let ab = calc_a2b(a, b);
    let bc = calc_a2b(b, c);
    let ac = calc_a2b(a, c);
    let check = |ab: &Vec<bool>, i: isize| {
        if i < ab.len() as isize && i >= 0 {
            ab[i as usize]
        } else {
            true
        }
    };
    let M = 2000isize;
    let mut ret = (M * 3) as usize;
    for i in (-M * 2)..(M * 2 + 1) {
        for j in (-M * 2)..(M * 2 + 1) {
            if check(&ab, i + M) && check(&bc, j - i + M) && check(&ac, j + M) {
                let l = min(i, j);
                let l = min(l, 0);
                let r = max(a.len() as isize, i + b.len() as isize);
                let r = max(r, j + c.len() as isize);
                ret = min(ret, (r - l) as usize);
            }
        }
    }
    println!("{:?}", ret); // DEBUG
}


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

typedef long long int ll;

int main()
{
    ll n;
    cin >> n;
    vector<pair<ll,ll>> xy(n);
    for(ll i = 0;i < n;i++){
        cin >> xy[i].first >> xy[i].second;
    }

    ll ans = n, cnt = 0;
    for(ll i = 0;i < n;i++){
        for(ll j = 0;j < n;j++){
            if(i == j)continue;
            ll mx = 0;
            ll tp = xy[i].first - xy[j].first;
            ll tq = xy[i].second - xy[j].second;
            for(ll k = 0;k < n;k++){
                for(ll l = 0;l < n;l++){
                    if(k == l)continue;
                    if(xy[k].first - xy[l].first == tp && xy[k].second - xy[l].second == tq){
                        mx++;
                        break;
                    }
                }
            }
            cnt = max(cnt,mx);
        }
    }
    
    ans = n - cnt;

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
n=gets.chomp.to_i
array=gets.chomp.split(' ').map(&:to_i)
min = max = array[0]
kq = true
if n == 1
  kq = true
else
  array.each_with_index do |value, index|
    next if index == n -1
    kq = false if value - array[index+1] > 1
    min = value < min ? value : min
    kq = false if min - array[index+1] > 1
    max = value > max ? value : max
    kq = false if max - array[index+1] > 1
  end
end
str = kq ? "Yes" : "No"
puts str

Measured memory_bytes: 9612
#include <bits/stdc++.h>
using namespace std; 
int main() {
    string S;
    cin >> S;
    string t1 = S.substr(0, 2) , t2 = S.substr(2);
    int a = stoi(t1), b = stoi(t2);
    if (0 < a && a <= 12) {
        if (0 < b && b <= 12) {
            cout << "AMBIGUOUS" << endl;
        }
        else {
            cout << "MMYY" << endl;
        }
    }
    else {
        if (0 < b && b <= 12) {
            cout << "YYMM" << endl;
        }
        else {
            cout << "NA" << endl;
        }
    }
 
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main (){
  
  double x1,y1,x2,y2,d;
  
  cin >>x1>>y1>>x2>>y2;
  
  d=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
  
  printf("%0.8f\n",sqrt(d));
  
  return 0;
  
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define co         cout
#define ci         cin
#define sf1(n)     scanf("%lld",&n)
#define sf2(n,m)   scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define pf1(n)     printf("%lld\n",n);
#define mem(a,b)   memset(a,b,sizeof(a))
#define en         cout<<endl;
#define pb         push_back
#define gcd(n,m)   __gcd(n,m)
#define lcm(n,m)   ((n)/__gcd(n,m))*(m)
#define fi         first
#define se         second
#define coy        cout<< "YES"<<endl;
#define con        cout<< "NO"<<endl;
#define f(i,a,b)     for(ll i=a;i<b;i++)
#define all(x)     (x).begin(),(x).end()
#define allr(x)    (x).rbegin(),(x).rend()
#define pi         pair<ll,ll>
#define br         break;
#define i64        long long
#define PI         2*acos(0.0)
#define MAXN       3*100000
 
int main()
{
    ll n,m,k,g,mx,mn,res,c,x,y,z,w,p,q,r,l,s,t;
    ci>>n>>m>>k;
    if(m*k>=n) co<< "Yes";
      else co<< "No";
    return 0;
}

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

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int inf = 1000000000; // 10^9

int main(){
   int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
   if((MAX(a,b)-MIN(a,b)<=d&&MAX(b,c)-MIN(c,b)<=d)||(MAX(c,a)-MIN(c,a)<=d))printf("Yes");
   else printf("No");
}

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

int main()
{
	double MIN=(double) (1<<30), MAX=0, t;
	while (cin >> t)
	{
		MIN = min(MIN, t);
		MAX = max(MAX, t);
	}

	cout.setf(ios::fixed);
	cout.precision(3);
	cout << MAX-MIN << endl;
}

Measured memory_bytes: 0
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i32 = input();
    let b: i32 = input();

    if (a + b) % 2 == 1 {
        println!("IMPOSSIBLE");
    } else {
        println!("{}", (a + b) / 2);
    }
}


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

using namespace std;

long long n, a[312345], sum[312345];
int cnt = 0;

int main() {
                                               

	int a, b;
	cin >> a >> b;

	long long ans=0;
	if(a==1) ans += 3e5;
	if(a==2)ans+=2e5;
	if(a==3)ans+=1e5;
	if(b==1) ans += 3e5;
	if(b==2)ans+=2e5;
	if(b==3)ans+=1e5;
	if(a==1&&b==1)ans+=4e5;
	cout<<ans;
}




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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  string S; cin >> S;
  int l = S.length();
  int result = 0;
  rep(i,l) {
    if (S[i]!=S[(l-1)-i]) {
      S[(l-1)-i] = S[i];
      result++;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define bitoff(val,pos) val & ~(1<<pos)
#define biton(val,pos) val | (1<<pos)
#define bittgl(val,pos) val ^ (1<<pos)
#define bitchk(val,pos) (bool)(val & (1<<pos))
#define odevn(val,pos) (bool)(val & (1<<pos))
#define bitcnt(val) __builtin_popcount(val)
ll ar[1000000],br[1000000],vis[1000009],cm[1000009],ck,n,r,sum,k,sm;
string st;
vector<ll>vec;
vector<ll>vec2[200009];
queue<ll>qq;
stack<ll>stk;
map<string,ll>mp;map<ll,ll>mp1;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll min1=9999999999;
    ll i,j,e,d,t,s=0;
    sum=0;
    double dd,vv,gg;
    cin >> d >> t;
    for(i=1;i<=t;i++)
    {
        cin >> j;
        sum+=j;
    }
    if(sum>=d)
    {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
}



Measured memory_bytes: 6400
N, P = map(int, input().split())

def factoring(k): #kを因数分解し、素因数とその個数を辞書に入れて返す。
    import math
    dic = dict()
    n = int(math.sqrt(k))+2
    for i in range(2, n):
        count = 0
        while k%i == 0:
            count += 1
            k = k//i
        if count != 0:
            dic[i] = count
    if k != 1: #sqrt(k)までチェックしてもkが1になっていない --> kが素因数
        dic[k] = 1
    return dic

dic = factoring(P)

ans = 1
for i in dic:
    ans *= i ** (dic[i] // N)

# print (dic)
print (ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

const long long mod=1e9+7;

int main() {
  long long ans;
  int N, M;
  cin >> N >> M;
  vector<int> an(N+1);
  vector<int> dp(N+1);

  REP(m,M){
    int tmp;
    cin >> tmp;
    an.at(tmp) = 1;
  }

  dp.at(0) = 1;
  REP(n,N+1){
    for(int next=n+1;next<=min(N,n+2);++next){
      if(an.at(next) == 0){
        dp.at(next) += dp.at(n);
        dp.at(next) %=mod;
      }
    }
  }
  cout << dp.at(N) << endl;

}

Measured memory_bytes: 1024
#include <stdio.h>
#define N 25

typedef struct node {
  int id;
  int depth;
  int height;
  int degree;
  int sibling;
  struct node* parent;
  struct node* left;
  struct node* right;
} NODE;

void calcDepth(NODE*);
void calcHeight(NODE*);

int main() {
  int i, j, n;
  int id, leftid, rightid;
  int root;
  NODE node[N];

  // input the number of nodes
  scanf("%d", &n);

  for(i = 0; i < n; i++) {
    node[i].parent = NULL;
    node[i].degree = 0;
    node[i].left = NULL;
    node[i].right = NULL;
  }

  // input the information of nodes
  for(i = 0; i < n; i++) {
    scanf("%d", &id);
    node[id].id = id;
    
    scanf("%d", &leftid);
    if(leftid != -1) {
      node[id].degree++;
      node[leftid].id = leftid;
      node[id].left = &node[leftid];
      node[leftid].parent = &node[id];
    }
    
    scanf("%d", &rightid);
    if(rightid != -1){
      node[id].degree++;
      node[rightid].id = rightid;
      node[id].right = &node[rightid];
      node[rightid].parent = &node[id];
    }
    
    // sibling
    if((leftid != -1)&&(rightid == -1)) {
      node[leftid].sibling = -1;
    }
    else if((leftid == -1)&&(rightid != -1)) {
      node[rightid].sibling = -1;
    }
    else if((leftid != -1)&&(rightid != -1)) {
      node[leftid].sibling = rightid;
      node[rightid].sibling = leftid;
    }
  }

  // depth
  i = 0;
  while(1) {
    if(node[i].parent == NULL){
      root = i;
      break;
    }
    i++;
  }
  calcDepth(&node[root]);
  calcHeight(&node[root]);

  // output
  for(i = 0; i < n; i++) {
    printf("node %d: ", i);
    // parent
    if(node[i].parent == NULL) printf("parent = -1, ");
    else printf("parent = %d, ", node[i].parent->id);
    // sibling
    if(node[i].parent == NULL) printf("sibling = -1, ");
    else printf("sibling = %d, ", node[i].sibling);
    // degree
    printf("degree = %d, ", node[i].degree);
    // depth
    printf("depth = %d, ", node[i].depth);
    // height
    printf("height = %d, ", node[i].height);
    // type
    if(node[i].parent == NULL) printf("root");
    else if((node[i].left == NULL)&&(node[i].right == NULL)) {
      printf("leaf");
    }
    else printf("internal node");
    printf("\n");
  }

  return 0;
}

void calcDepth(NODE* node) {
  // Preorder walk

  if(node == NULL) return;
  if(node->parent == NULL) node->depth = 0;
  else node->depth = node->parent->depth + 1;
  calcDepth(node->left);
  calcDepth(node->right);
}

void calcHeight(NODE* node) {
  // Postorder
  if(node == NULL) return;
  calcHeight(node->left);
  calcHeight(node->right);
  if((node->left == NULL)&&(node->right == NULL)) node->height = 0;
  else if((node->left != NULL)&&(node->right == NULL)) {
    node->height = node->left->height + 1;
  }
  else if((node->left == NULL)&&(node->right != NULL)) {
    node->height = node->right->height + 1;
  }
  else if(node->left->height > node->right->height) {
    node->height = node->left->height + 1;
  }
  else {
    node->height = node->right->height + 1;
  }
}



Measured memory_bytes: 2104
program abc155a
      implicit none
      integer::a,b,c

         read *, a,b,c

         if (a/=b .and. b==c) then
            print *,'Yes'
         else if (b/=a .and. a==c) then
            print *,'Yes'
         else if (c/=a .and. a==b) then
            print *,'Yes'
         else
            print *,'No'
         end if

   end program abc155a

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi same(N,0);
  rep(i,N) {
    int a,b;
    cin >> a >> b;
    same[i]=a==b;
  }
  rep(i,N-2) {
    bool ok=true;
    ok &= same[i];
    ok &= same[i+1];
    ok &= same[i+2];
    if(ok) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<int> xs(n); cin >> xs;
    vector<int> ys(m); cin >> ys;
    bool ok = false;
    for(int i = x + 1; i <= y; i++){
        if(*max_element(xs.begin(), xs.end()) < i &&
           *min_element(ys.begin(), ys.end()) >= i){
            ok = true;
        }
    }
    cout << (ok ? "No War" : "War") << '\n';
}


Measured memory_bytes: 256
gets.to_i
array1=gets.chomp.split(" ").map(&:to_i)
gets.to_i
array2=gets.chomp.split(" ").map(&:to_i)

array = array1.uniq + array2.uniq
puts array.group_by {|e| e }.select{|k,v| v.length == 2 }.length


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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

int gcd(int a, int b);
int lcm(int a, int b);

void solve_A(){
    int h, a;
    cin >> h >> a;

    cout << (h + a - 1)/a;
}

void solve_B(){
    
}

void solve_C(){
    
}

int main(void){
    solve_A();
    solve_B();
    solve_C();
    
    return 0;
}

int gcd(int a, int b){
    if(a < b) swap(a, b);

    int r = a % b;
    while(r != 0){
        a = b;  b = r;  r = a % b;
    }
    return b;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  string n;
  cin >> n;
  if(n[0] == '1') cout << '9';
  else cout << '1';
  if(n[1] == '1') cout << '9';
  else cout << '1';
  if(n[2] == '1') cout << '9'<< endl;
  else cout << '1' << endl;

  return 0;
}

Measured memory_bytes: 256
S = input()
S ="w"+ S + "w"
m = 0
n = 0
lst = []
for i in S:
  n += 1
  if i not in "ACGT":
    lst.append(n)
for y in range(len(lst)-1):
  if (lst[y+1] - lst[y]) > m:
    m = (lst[y+1] - lst[y])
print (m-1)
  


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((int)(x).size())

using namespace std;
typedef long long ll;


void solve(long long n, std::vector<long long> p){
  int count = 0;
  for (int i = 0; i < n - 2; i++) {
    if ((p[i] < p[i+1] && p[i+1] < p[i+2]) || (p[i] > p[i+1] && p[i+1] > p[i+2])) count++;

  }
  printf("%d\n", count);
}

int main(){
  long long n;
  scanf("%lld",&n);
  std::vector<long long> p(n);
  for(int i = 0 ; i < n ; i++){
    scanf("%lld",&p[i]);
  }
  solve(n, std::move(p));
  return 0;
}


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

bool visited[100005];
vector <int> route[100005];

void dfs(int v){
    visited[v]=1;
    for(int i:route[v]){
        if (visited[i]==1) continue;
        dfs(i);
    }
}

void testcase(){
    int n,m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        route[a].push_back(b);
        route[b].push_back(a);
    }
    int c=0;
    for(int i=0;i<n;i++){
        if(visited[i]==1) continue;
        dfs(i);
        c++;
    }
    cout << c-1;

}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int q=1;
   // cin >> q;
    while(q--){
    testcase();
    }
    return 0;
}


Measured memory_bytes: 9648
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toInt() }

    val cnt = mutableMapOf<Int, Long>()
    for (i in a) {
        cnt[i] = (cnt[i] ?: 0) + 1
    }
    val s = cnt.map { entry -> entry.value * (entry.value - 1) / 2 }.sum()

    (0 until n)
            .map { s - cnt[a[it]]!! + 1 }
            .joinToString("\n")
            .let { println(it) }
}


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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;
const ll MAXN = 3e5 + 5;

vector < vector < ll > > adj(MAXN, vector < ll > ());
vector < ll > d(MAXN, LLONG_MAX);
vector < bool > used(MAXN, false);

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

  ll n, m;
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    ll u, v;
    cin >> u >> v;
    adj[u].push_back(v + n);
    adj[u + n].push_back(v + 2 * n);
    adj[u + 2 * n].push_back(v);
  }
  ll st, ed;
  cin >> st >> ed;
  d[st] = 0;
  queue < ll > q;
  q.push(st);
  used[st] = true;
  while(!q.empty()){
    ll u = q.front(); q.pop();
    for(auto to : adj[u]){
      if(!used[to]){
        d[to] = min(d[to], d[u] + 1);
        used[to] = true;
        q.push(to);
      }
    }
  }

  if(d[ed] == LLONG_MAX) cout << -1 << endl;
  else{
    cout << d[ed] / 3 << endl;
  }
}


Measured memory_bytes: 19072
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 55;
const LL MOD = 1000000007;

typedef vector<LL> vec;
typedef vector<vec> mat;

mat mul(const mat &m1, const mat &m2) {
	mat res = mat(m1.size(), vec(m2[0].size(), 0));
	for (int i = 0; i < m1.size(); i++) {
		for (int j = 0; j < m2[0].size(); j++) {
			for (int k = 0; k < m2.size(); k++) {
				(res[i][j] += m1[i][k] * m2[k][j]) %= MOD;
			}
		}
	}
	return res;
}

mat qpow(const mat &m, LL pw) {
	if (pw == 1) return m;
	mat res = qpow(m, pw >> 1);
	res = mul(res, res);
	if (pw & 1) res = mul(res, m);
	return res;
}

LL K, N;
mat adj;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> N >> K;
	adj.resize(N, vec(N));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> adj[i][j];
		}
	}
	
	LL ans = 0;
	adj = qpow(adj, K);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ans = (ans + adj[i][j]) % MOD;
		}
	}
	
	cout << ans << "\n";
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<long long, long long> P;
int main(){
    int N, M;
    cin >> N >> M;
    vector<long long> A(N), B(N);
    vector<long long> ind(N);
    set<int> s;
    for(int i = 1; i <= M; i++) s.insert(i);
    for(int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        ind[i] = i;
    }
    sort(ind.begin(), ind.end(), [&](int x, int y){
        if(B[x] != B[y]) return B[x] > B[y];
        return A[x] > A[y];
    });
    long long ans = 0;
    for(int i = 0; i < N; i++){
        auto ite = s.lower_bound(A[ind[i]]);
        if(ite != s.end()){
            ans += B[ind[i]];
            s.erase(*ite);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 10292
#include<stdio.h>
#include<stdlib.h>
int compare(const void *a,const void *b){return *(int*)b-*(int*)a;}
int main(){
    int a[3],n,i,j,r=0;
    scanf("%d%d%d%d",&a[0],&a[1],&a[2],&n);
    qsort(a,3,4,compare);
    for(i=0;i<=n/a[0];i++){
        for(j=0;j<=(n-i*a[0])/a[1];j++){
            r+=(n-i*a[0]-j*a[1])%a[2]==0;
        }
    }
    printf("%d",r);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int main(){
	int N;
	long* A;
	long* B;
	int i;
	long num_pushed = 0;
	long tmp;

	scanf("%d", &N);

	A = (long*)malloc(sizeof(long) * N);
	B = (long*)malloc(sizeof(long) * N);

	for(i = 0; i < N ; i++){
		scanf("%ld %ld", &A[i], &B[i]);
	}
	for(i =N-1; i>=0; i--){
		A[i] += num_pushed;
		if(A[i] % B[i] != 0){
			tmp = B[i] - A[i] % B[i];	// なんかいおせばよいか
		
			num_pushed += tmp;
		}
	}

	printf("%ld\n", num_pushed);

	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
const double pi = 3.14159265359;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, k;

int main()
{
	cin >> n >> k;
	int ans = k;
	for (int i = 0;i < n - 1;i++) {
		ans *= (k - 1);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
        String b = sc.next();
        int count=0;
        for(int i=0;i<a.length();i++){
          if(a.charAt(i)!=(b.charAt(i)))
          count++;
        }
		System.out.println(count);
	}
}

Measured memory_bytes: 41164
using System;

    class Program
    {
        static void Main(string[] args)
        {
            int n, f, r, total;

            while (true)
            {
                //テスト点数受け取り
                string[] str = Console.ReadLine().Split(' ');
                n = int.Parse(str[0]);
                f = int.Parse(str[1]);
                r = int.Parse(str[2]);

                //中間&期末の合計
                total = n + f;

                if (n == -1 && f == -1 && r == -1)
                {
                    break;
                }

                if (total < 30 || n == -1 || f == -1)
                {
                    Console.WriteLine("F");
                }
                else if (total >= 80)
                {
                    Console.WriteLine("A");
                }
                else if (total >= 65)
                {
                    Console.WriteLine("B");
                }
                else if (total >= 50 || r >= 50)
                {
                    Console.WriteLine("C");
                }
                else if (total >= 30)
                {
                    Console.WriteLine("D");
                }
          
            }
        }
    }



Measured memory_bytes: 8844