akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main()
{
    unsigned short *A, *B;

    int C[VMAX + 1];
    int n, i, j;
    scanf("%d", &n);

    A = malloc(sizeof(short) * n + 1);
    B = malloc(sizeof(short) * n + 1);

    for ( i = 0; i <= VMAX; i++) C[i] = 0;

    for ( i = 0; i < n; i++)
    {
        scanf("%hu", &A[i + 1]);
        C[A[i + 1]]++;
    }
    
    for ( i = 1; i <= VMAX; i++) C[i] = C[i] + C[i - 1];

    for ( j = 1; j <= n; j++)
    {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }

    for ( i = 1; i <= n; i++)
    {
        if ( i > 1) printf(" ");
        printf("%d", B[i]);
    }
    printf("\n");

    return 0;
}



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

using namespace std;

#define int long long

#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

#ifdef DBG
#define log(item) cout << #item << " " << item << endl
#define loga(array, val) cout << #array << #val << " " << array[val] << endl
#else
#define log(item)
#define loga(array, val)
#endif

typedef vector<int> VI;
typedef pair<int, int> PII;

//-------------------

int A, B;

signed main(){
    cin >> A >> B;
    if(A >= 13){
        cout << B << endl;
    }
    else if(A >= 6){
        cout << B / 2 << endl;
    }
    else{
        cout << 0 << 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);
        int N = sc.nextInt();
        int digitNum = (int)Math.log10(N) + 1;

        int ans = 0;
        if(digitNum == 6){
            ans = 9 + 900 + 90000;
        }else if(digitNum == 5){
            ans = 9 + 900 + N - 10000 + 1;
        }else if(digitNum == 4){
            ans = 9 + 900;
        }else if(digitNum == 3){
            ans = 9 + N - 100 + 1;
        }else if(digitNum == 2){
            ans = 9;
        }else if(digitNum == 1){
            ans = N;
        }
        System.out.println("" + ans);
    }

}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> a(H, vector<char>(W + 1));

    vector<bool> ver(W, true), hor(H, true);
    for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
            cin >> a[i][j];
            if(a[i][j] == '.') {
                ver[j] = ver[j] & true;
                hor[i] = hor[i] & true;
            } else
                ver[j] = hor[i] = false;
        }
    }

    for(int i = 0; i < H; ++i) {
        if(hor[i])
            continue;
        for(int j = 0; j < W; ++j) {
            if(ver[j])
                continue;
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n,m,c = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(n):
    a = list(map(int,input().split()))
    num = 0
    for x in range(m):
        num += a[x] * b[x]
    num += c
    if num > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3064
// [[ABC134C] Exception Handling] https://www.luogu.com.cn/problem/AT4843
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  printf("%d\n", (a-b)%c);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
  fio();
  int n;
  cin >> n;
  vector<pll> xl(n);
  rep (i, n) {
    cin >> xl[i].first >> xl[i].second;
  }
  sort(all(xl));

  vector<pll> use(1, pll(-INF, 0));
  rep (i, n) {
    ll now = use.back().first + use.back().second;
    if (now <= xl[i].first - xl[i].second) {
      use.push_back(xl[i]);
    }
    else {
      if (now <= xl[i].first + xl[i].second) continue;
      use.pop_back();
      use.push_back(xl[i]);
    }
  }
  cout << use.size() - 1 << endl;
}

Measured memory_bytes: 3956
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int price = 0;
        boolean judge = false;
        
        for(int i=1; i<=1000; i++){
            price = i;
            if(Math.floor(price*0.08) == A && Math.floor(price*0.1) == B){
                judge = true;
                break;
            }
        }
        
        if(judge) System.out.println(price);
        else System.out.println(-1);
    }
}


Measured memory_bytes: 35624
N, L = map(int, input().split())

T = [L + i - 1 for i in range(1, N + 1)]

min = 1000000
value = 0

for i, t in enumerate(T):
    if abs(t) < min:
        min = abs(t)
        value = t
    else:
        continue

print(sum(T) - value)


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

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

const int MOD = 1000000007;

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

    int ans = 0;
    for(int i = 1; i < n; i++) {
        ans += (n - 1) / i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
from collections import defaultdict

s = input()
x, y = map(int, input().split())

arr = list(map(len, s.split('T')))
EW = [arr[ew] for ew in range(0, len(arr), 2)]
NS = [arr[ns] for ns in range(1, len(arr), 2)]

# dp[i][j] := i回目までの移動で座標jにいることができるか
dp = [defaultdict(bool) for i in range(len(EW))]
dp[0][EW[0]] = True
for i in range(1, len(EW)):
    for prev in dp[i - 1].keys():
        dp[i][prev + EW[i]] = True
        dp[i][prev - EW[i]] = True
if not dp[-1][x]:
    print('No')
    exit(0)

if len(NS) > 0:
    dp = [defaultdict(bool) for i in range(len(NS))]
    dp[0][NS[0]] = True
    dp[0][-NS[0]] = True
    for i in range(1, len(NS)):
        for prev in dp[i - 1].keys():
            dp[i][prev + NS[i]] = True
            dp[i][prev - NS[i]] = True
    if not dp[-1][y]:
        print('No')
        exit(0)

print('Yes')


Measured memory_bytes: 389768
#include <stdio.h>
long long int kaizyou(long long int x,long long int y,long long z){
    //xの階乗（mod y）
    long long int tmp=1;
    for(int i=x;i<=z;i++){
        tmp*=i;
        tmp%=y;
    }
    return tmp;
}

long long int ruizyou(long long int x,long long y,long long int z){
    //xのｙ乗(modz)
    long long int tmp=1;
    long long int s[100]={};
    int memo[100]={};
    s[0]=x;
    for(int i=0;i<100;i++){
        memo[i]=y%2;
        y/=2;
    }
    for(int i=1;i<100;i++){
        s[i]=(x*x)%z;
        x=(x*x)%z;
    }
    for(int i=0;i<100;i++){
        if(memo[i]==1){
            tmp=(tmp*s[i])%z;
        }
    }
    return tmp;
}

long long int combination(long long int x,long long int y,long long int z){
    //xCy(mod z)
    long long int tmp=1;
    tmp=(tmp*kaizyou(y+1,z,x))%z;
    tmp=(tmp*ruizyou(kaizyou(1,z,x-y),z-2,z))%z;
    return tmp;
}


int main(void){
    long long int n,m,sosu[100]={},memo=0,copy_m,max=1,result=1;
    
    scanf("%lld%lld",&n,&m);
    
    copy_m=m;
    
    for(int i=2;i<32000;i++){
        if(m%i==0)memo++;
        next:
        if(m%i==0){
            m/=i;
            sosu[memo]++;
            max*=i;
            goto next;
        }
    }
   
    if(copy_m/max>=32000){
        sosu[memo+1]++;
    }
    
    for(int i=1;i<=99;i++){
        result*=combination(n+sosu[i]-1,n-1,1000000007);
        result%=1000000007;
    }
    printf("%lld",result);
    
    
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
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;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
//グラフの隣接リスト
VI g[100010];
//頂点の入次数を管理
int h[100010];
signed main(void)
{
  //頂点数v、辺の数e
  int v, e;
  cin >> v >> e;
  REP(i, e) {
    int s, t;
    cin >> s >> t;
    s--;t--;
    //頂点sから頂点tへの有向辺
    g[s].push_back(t);
    h[t]++;
  }

  //入次数が0の頂点の集合
  stack<int> st;

  //入次数が0の頂点であればstに追加
  REP(i, v) if(h[i] == 0) st.push(i);

  //ソートされた後のグラフ
  VI ans;
  //stがなくなるまでループ
  while(st.size()) {
    //stの集合のから一つ取り出す
    int i = st.top(); st.pop();
    ans.push_back(i);
    for(auto& j: g[i]) {
      //隣接する頂点の入次数をマイナス1
      h[j]--;
      //これによって入次数が0になればstに追加
      if(h[j] == 0) st.push(j);
    }
  }
    vi dp(v);
    REP(i,ans.size()){
        REP(j,g[ans[i]].size()){
            chmax(dp[g[ans[i]][j]],dp[ans[i]]+1);
        }
    }
    cout<<*max_element(all(dp))<<endl;

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int x, cnt = 0, ans;
  cin >> x;
  for (int i = 0; i < x; ++i) {
    cnt += i + 1;
    if (cnt >= x) {
      ans = i + 1;
      break;
    }
  }

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


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
        int a, b, W;
        scanf("%d %d %d", &W, &a, &b);

        if(a<b)
        {
                printf("%d\n", b-(a+W)<0?0:b-(a+W));
        }
        else if(a>b)
        {
                printf("%d\n", a-(b+W)<0?0:a-(b+W));
        }
        else
        {
                printf("0\n");
        }

        return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

int main()
{
	int n, m, a, b;
    scanf("%d %d", &n, &m);
    vector<int> v[100000];
    for(int i=0; i<m; i++){
      scanf("%d %d", &a, &b);
      a--;
      b--;
      v[a].push_back(b);
      v[b].push_back(a);
    }
    int e=0;
    for(int i=0; i<n; i++){
      if(v[i].size()%2!=0) e=1;
    }
    if(e==0){
      printf("%s\n", "YES");
    }else{
      printf("%s\n", "NO");
    }
	return 0;
}


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

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

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

acc1 = []
s1 = 0
acc2 = []
s2 = 0
for i in range(n):
    s1+=A1[i]
    s2+=A2[i]
    acc1.append(s1)
    acc2.append(s2)

res = 0

for i in range(n):
    res = max(res,acc1[i]+acc2[-1]-acc2[i]+A2[i])

print(res)


Measured memory_bytes: 3064
# include <iostream>
# include <algorithm>
# include <cmath>
# include <tuple>
# include <vector>
# include <queue>
# include <string>
# include <map>

typedef long long ll;
using namespace std;

string s;
int n;

bool isValid(int len) {
    map<string, int> m;
    for (int i = 0; i <= n-len; i++) {
        string str = s.substr(i, len);
        if (m.find(str) != m.end() && m[str]+len <= i) return true;
        m.insert({str, i});
    }
    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cin >> s;
    if (!isValid(1)) {
        cout << 0 << endl;
        return 0;
    }
    int l = 1;
    int r = n/2+1;
    while (r - l >= 1) {
        if (r-l == 1) {
            if (isValid(r)) l = r;
            break;
        }
        int mid = (l+r)/2;
        if (isValid(mid)) {
            l = mid;
        } else {
            r = mid;
        }
    }
    cout << l << endl;
    return 0;
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;


int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string S, T; cin >> S >> T;
	ll NS = S.size();
	ll NT = T.size();

	vector<string> res;

	REP(si, NS)
	{
		if (NS - si < NT) continue;
		string tmp;
		REP(i, si)
		{
			if (S[i] == '?')
				tmp.push_back('a');
			else
				tmp.push_back(S[i]);
		}

		bool ok{true};
		REP(i, NT)
		{
			ll ss = i + si;
			ll tt = i;

			if (S[ss] == '?')
			{
				tmp.push_back(T[tt]);
			}
			else 
			{
				if (S[ss] == T[tt])
					tmp.push_back(S[ss]);
				else
					ok = false;
			}
		}
		if (!ok) continue;

		for (ll i = si + NT; i < NS; ++i)
		{
			if (S[i] == '?')
				tmp.push_back('a');
			else
				tmp.push_back(S[i]);
		}
			

		res.push_back(tmp);
	}

	if (res.size() == 0)
	{
		std::cout << "UNRESTORABLE" << std::endl;
		return 0;
	}
	sort(ALL(res));
	std::cout << res[0] << std::endl;
	
	return 0;
}


Measured memory_bytes: 3652
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int n, m;

int main() {
scanf("%d %d", &n, &m);
if (n > m) swap(n, m);
if (n == 1) {
	if (m == 1) printf("1\n"); else printf("%d\n", m - 2);
	return 0;
}
printf("%lld\n", (n - 2) * 1LL * (m - 2));
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size())cout << a[i] << " ";cout << "\n"
#define vecvec(a) vector<vector<(a)>>
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll A,B,C;
    cin >> A >> B >> C;
    if(A == B && A != C)cout << "Yes" << "\n";
    else if(A == C && A != B)cout << "Yes" << "\n";
    else if(B == C && A != C)cout << "Yes" << "\n";
    else cout << "No" << endl;
}


Measured memory_bytes: 3620
using System;

public class Hello
{
    public static void Main()
    {
        var dx = new int[] { 0, 1, 0, -1 };
        var dy = new int[] { 1, 0, -1, 0 };
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var h = int.Parse(line[0]);
            var w = int.Parse(line[1]);
            if (h == 0 && w == 0) break;
            var map = new int[h, w];
            for (int i = 0; i < h; i++)
            {
                var s = Console.ReadLine().Trim();
                for (int j = 0; j < w; j++)
                    if (s[j] == '#') map[i, j] = 1;
                    else if (s[j] == '*') map[i, j] = 2;
            }
            var count = 0;
            for (int i = 0; i < h; i++)
                for (int j = 0; j < w; j++)
                    if (map[i, j] <= 2) { count++; goDfs(map, h, w, i, j, map[i, j], dx, dy); }
            Console.WriteLine(count);
        }
    }
    public static void goDfs(int[,] map, int h, int w, int x, int y, int c, int[] dx, int[] dy)
    {
        map[x, y] = 3;
        for (int i = 0; i < 4; i++)
        {
            var nx = x + dx[i];
            var ny = y + dy[i];
            if (nx >= 0 && nx < h && ny >= 0 && ny < w && map[nx, ny] == c)
                goDfs(map, h, w, nx, ny, c, dx, dy);
        }
    }
}

Measured memory_bytes: 10384
#include<bits/stdc++.h>
using namespace std;
long long dp[101][100001];

int main()
{
    long long n,W,i,x,y,tw,j;
    cin>>n>>W;
    vector<long long> a,w;
    for(i=1;i<=n;i++)
    {
        cin>>y>>x;
        a.push_back(x);
        w.push_back(y);
    }
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=W;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else if(j>=w[i-1])
                dp[i][j]=max(dp[i-1][j],a[i-1]+dp[i-1][j-w[i-1]]);
            else
                dp[i][j]=dp[i-1][j];
           // cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    cout<<dp[n][W]<<endl;
    return 0;
}


Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
int a[1005];
int main()
{
	int i,j,k;
	int n;
	sd(n);
	for(i=0;i<n;i++)
		sd(a[i]);
	int cnt=1,ans=0;
	for(i=1;i<n;i++)
	{
		if(a[i]==a[i-1])
			cnt++;
		else
		{
			ans+=cnt/2;
			cnt=1;
		}
	}
	ans+=cnt/2;
	printf("%d\n",ans );
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli n,d,a;
	cin>>n>>d>>a;

	queue<pair<lli,lli>> boms;
	lli bomNum=0;
	lli bomCnt=0;

	vector<pair<lli,lli>> mons;
	REP(i,0,n){
		lli x,h;
		cin>>x>>h;
		mons.push_back(mp(x,h));
	}
	sort(mons.begin(),mons.end());

	REP(i,0,n){
		//bom check
		while(boms.size()>0 && boms.front().first<mons[i].first){
			bomNum -= boms.front().second;
			boms.pop();
		}
		//bom execute
		mons[i].second -= a*bomNum;

		//bom add
		if(mons[i].second>0){
			lli tmp = (mons[i].second-1)/a+1;
			bomCnt += tmp;
			bomNum += tmp;
			boms.push(mp(mons[i].first+2*d,tmp));
		}
	}
	cout<<bomCnt<<endl;

	return 0;
}

Measured memory_bytes: 6256
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
	int x;
	
	for (int i=1;;i++){
		cin >> x;
		if (x == 0){
			break;
		}
		
		cout << "Case " << i << ": " << x << endl;
	}
	return 0;
}


Measured memory_bytes: 2976
#include <bits/stdc++.h>
using namespace std;
pair<int, int> arr[15];
int N, parr[15], fact = 1;
double result;

int main()
{
    scanf("%d", &N);
    for(int i = 0; i < N; i++)
    {
        scanf("%d %d", &arr[i].first, &arr[i].second);
        parr[i] = i;
        fact *= i + 1;
    }
    do
    {
        for(int i = 0; i < N - 1; i++)
        {
            double t1, t2;
            t1 = arr[parr[i]].first - arr[parr[i + 1]].first;
            t2 = arr[parr[i]].second - arr[parr[i + 1]].second;
            result += sqrt(t1 * t1 + t2 * t2);
        }
    }
    while(next_permutation(parr, parr + N));
    printf("%0.10lf", result / fact);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
ll n,minn;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;int now=sqrt(n);
	minn=1e18;
	for(res i=1;i<=now;++i) if(!(n%i)) chkmin(minn,n/i+i);
	cout<<minn-2<<'\n';
	cout<<flush;
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int n, m;
    cin >> n >> m;
    map<long long, long long> mp;
    for(int i = 0; i < n; ++i){
        long long a, b;
        cin >> a >> b;
        mp[a] += b;
    }
    long long res = 0;
    for(pair<long long, long long> p : mp){
        long long x;
        if(p.second < m) x = p.second;
        else x = m;
        res += p.first * x;
        if(m <= p.second){
            cout << res << endl;
            return 0;
        }
        m -= p.second;
    }
}


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

using namespace std;

bool dp[5001][5001];
bool dp2[5001][5001];

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

	int n,k,t;
	vector <int> v;

	cin >> n >> k;
	for(int i=0;i<n;i++)
	{
		cin >> t;
		t = min(t,k);
		v.push_back(t);
	}

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

	memset(dp,false,sizeof(dp));
	dp[0][0] = true;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=k;j++)
		{
			if(dp[i][j]==false)
			{
				continue;
			}
			dp[i+1][j] = true;
			if(j + v[i] <= k)
			{
				dp[i+1][j+v[i]] = true;
			}
		}
	}


	memset(dp2,false,sizeof(dp2));
	dp2[n][0] = true;
	for(int i=n-1;i>=0;i--)
	{
		for(int j=0;j<=k;j++)
		{
			if(dp2[i+1][j]==false)
			{
				continue;
			}
			dp2[i][j] = true;
			if(j + v[i] <= k)
			{
				dp2[i][j+v[i]] = true;
			}
		}
	}

	int res = 0;
	for(int i=0;i<n;i++)
	{
		bool ok = false;
		for(int j=0;j<k;j++)
		{
			if(dp[i][j]==true || dp2[i+1][j]==true)
			{
				if(j+v[i] >= k)
				{
					ok = true;
					break;
				}
			}
		}
		for(int j=0;j<=k-v[i];j++)
		{
			if(dp[i][j]==true && dp2[i+1][k-v[i]-j]==true)
			{
				ok = true;
				break;
			}
		}
		if(!ok)
		{
			res++;
		}
	}
	cout << res << '\n';

	return 0;
}


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

signed main(){
  
  int n;
  cin>>n;
  
  int p[20];
  
  for(int i=0;i<n;i++) cin>>p[i];

  int ans = 0;
  
  for(int i=1;i<n-1;i++){
    
    if( p[i-1] < p[i] && p[i] < p[i+1] ) ans++;
    if( p[i-1] > p[i] && p[i] > p[i+1] ) ans++;
    
  }

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


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    string s;
    cin >> s;

    const string ans = (s == "ABC" ? "ARC" : "ABC");
    cout << ans << endl;
}


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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;

  int num_a = 0;
  ll ans = 0;
  for(int i = 0; i < s.size() - 1; ++i){
    if(s[i] == 'A'){
      num_a++;
    }
    else if(s[i] == 'B' && s[i+1] == 'C'){
      ans += num_a;
      ++i;
    }
    else{
      num_a = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 720
<?php
list($a, $b) = ints();
if ($a <= 0 && $b >= 0) exit('Zero');
$cntMinus = max(0, -$a) - max(0, - ($b + 1));
echo $cntMinus % 2 ? 'Negative' : 'Positive';
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 15872
import collections
n = int(input())


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


ans = 0
# print(prime_factorize(n))
a = collections.Counter(prime_factorize(n))
# print(a)
for i in a.keys():
    for j in range(1, a[i]+1):  # 1乗　2乗...
        if a[i] < j:
            break
        else:
            a[i] -= j
            ans += 1
        # print(a[i])

print(ans)


Measured memory_bytes: 9468
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

int main(void){
  int X,N;
  cin >> X >> N;
  int p[N];
  for(int i=0;i<N;i++){
    cin >> p[i];
  }
  int dist = 102;
  int dist_num = -1;
  int flag = 0;
  for(int num=0;num<102;num++){
    flag = 0;
    for(int i=0;i<N;i++){
      if(num==p[i]){
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      if(dist>abs(X-num)){
        dist = abs(X-num);
        dist_num = num;
      } else if(dist==abs(X-num)) {
        if( num < dist_num){
          dist = abs(X-num);
          dist_num = num;
        }
      }
    }
  }
  printf("%d\n",dist_num);
  return 0;
}

Measured memory_bytes: 3764
# /usr/bin/python
# -*- coding: utf-8 -*-
import math



def split1(h,w):
  # 1|2|3
  if h%3==0 or w%3==0:
    return 0
  else:
    return min(h,w)    


def split2(h,w):
  # 1|2
  # ---
  #  3
  ret = h*w
  for h2 in (h//3,h//3+1):
    s = [h2*w, (h-h2)*(w//2), (h-h2)*(w-w//2)]
    ret = min(ret, max(s)-min(s))
  return ret


def main():
  H,W = map(int, input().split())
  diffs = [split1(H,W), split2(H,W), split2(W,H)]
  return min(diffs)


if __name__ == "__main__":
  ret = main()
  print(ret)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    ll n,k;
    ll ans = 0;
    cin >> n >> k;
    for(ll i=k;i<=n+1;i++){
        ll ans1 = (n)*(n+1)/2-(n-i+1)*(n-i)/2-i*(i-1)/2 + 1;
        ans = ans + ans1;
        ans = ans % 1000000007;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

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

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int MAX_N = 110;
int dist[MAX_N][MAX_N];
int N,M;
void init(){
  for (int i = 0; i < MAX_N; i++){
    for (int j = 0; j < MAX_N; j++){
      dist[i][j] = INF;
      if (i == j){
        dist[i][j] = 0;
      }
    }
  }
}
struct node {
  int v, d;
  node(int v, int d):v(v),d(d){}
  bool operator<(const node &n) const { return d > n.d; }
};
struct edge { int to, d; };
int V;
vector<edge> G[MAX_N];
int cost[MAX_N]; // shortest distance
set<pii> tmp;
void dijkstra(int s) {
  memset(cost, -1, sizeof(cost));
  priority_queue<node> que;
  que.push(node(s, 0));
  while(!que.empty()){
    int v = que.top().v, d = que.top().d;
    que.pop();
    if(cost[v] >= 0 and cost[v] <= d) continue;
    cost[v] = d;
    for(int i = 0; i < G[v].size(); i++){
      int next = G[v][i].to;
      if (dist[next][s] == d + G[v][i].d){
        tmp.emplace(mp(min(next, v), max(next, v)));
      }
      que.push(node(G[v][i].to, d+G[v][i].d));
    }
  }
}
int main() {
  init();
  cin >> N >> M;
  for (int i = 0; i < M; i++){
    int a,b,c;
    cin >> a >> b >> c;
    a--,b--;
    dist[a][b] = c;
    dist[b][a] = c;
    G[a].push_back(edge{b, c});
    G[b].push_back(edge{a, c});
  }

  for (int k = 0; k < N; k++){
    for (int i = 0; i < N; i++){
      for (int j = 0; j < N; j++){
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  for (int i = 0; i < N; i++){
    dijkstra(i);
  }
  cout << M - tmp.size() << endl;
  return 0;
}


Measured memory_bytes: 888
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

class Union_Find
{
	std::vector<LL>per, rank, cnt;
public:
	void init(LL size)
	{
		rep(i, size)
		{
			per.push_back(i);
			rank.push_back(0);
			cnt.push_back(1);
		}
	}
	LL get_per(LL x)
	{
		if (x == per[x]) return x;
		return per[x] = get_per(per[x]);
	}
	bool is_same_per(LL x, LL y)
	{
		return get_per(x) == get_per(y);
	}
	void unite(LL x, LL y)
	{
		LL x_per = get_per(x), y_per = get_per(y);
		if (x_per == y_per) return;
		if (rank[x_per] < rank[y_per])
		{
			per[x_per] = y_per;
			cnt[y_per] += cnt[x_per];
			cnt[x_per] = 0;
		}
		else
		{
			per[y_per] = x_per;
			cnt[x_per] += cnt[y_per];
			cnt[y_per] = 0;
			if (rank[x_per] == rank[y_per]) ++rank[x_per];
		}
	}
	LL get_cnt(LL x)
	{
		return cnt[get_per(x)];
	}
};

int main()
{
	LL N;
	in >> N;
	std::vector<LL>x(N), y(N);
	rep(i, N) in >> x[i] >> y[i];

	std::set<std::pair<LL, LL>>diff;
	rep(i, N)
	{
		rep(j, N)
		{
			if (i == j) continue;
			LL dx = x[i] - x[j], dy = y[i] - y[j];
			diff.insert(std::make_pair(dx, dy));
		}
	}

	LL ans = 114514;
	for (auto d : diff)
	{
		Union_Find tree;
		tree.init(N + 1);
		rep(i, N)
		{
			for (LL j = i + 1; j < N; ++j)
			{
				if (i == j) continue;
				LL dx = x[i] - x[j], dy = y[i] - y[j];
				if ((dx == d.first && dy == d.second) || (-dx == d.first && -dy == d.second))
				{
					tree.unite(i, j);
				}
			}
		}

		std::set<LL>roots;
		rep(i, N) roots.insert(tree.get_per(i));
		ans = std::min<LL>(ans, roots.size());
	}

	if (N == 1) ans = 1;
	out << ans << std::endl;
}


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

int main(){
	int k;
  	cin >> k;
  	vector<ll> a;
  	for(int i = 1; i < 10; i++) a.push_back(i);
  
  	while(1){
      	if(k <= a.size()){
        	cout << a[k - 1] << endl;
          	break;
        }
      	
      	k -= a.size();
      
    	vector<ll> old;
      	swap(old, a);
      	for(ll x : old){
        	for(int i = -1; i <= 1; i++){
            	int d = x % 10 + i;
              	if(d < 0 || d > 9) continue;
              	ll nx = x * 10 + d;
              	a.push_back(nx);
            }
        }
    }
  
  	return 0;
}

Measured memory_bytes: 1712
#include<iostream>
using namespace std;
int apsp[9+1][9+1];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int h, w; cin >> h >> w;
	for(int d1 = 0; d1 <= 9; d1++)
		for(int d2 = 0; d2 <= 9; d2++)
			cin >> apsp[d1][d2];
	for(int k = 0; k <= 9; k++)
		for(int i = 0; i <= 9; i++)
			for(int j = 0; j <= 9; j++)
				apsp[i][j] = min(apsp[i][j],apsp[i][k]+apsp[k][j]);

	int total = 0;
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
		{
			int x; cin >> x;
			if(x!=-1)
				total += apsp[x][1];
		}
	cout<<total<<endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
pans = 0
sum_ = sum(a)%(10**9+7)
for i in range(n-1):
    sum_ -= a[i]
    ans = sum_ * a[i]
    ans = ans % (10**9+7)
    pans += ans
print(pans%(10**9+7))

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

int main () {
    

    string s;
    cin >> s;
    
    if (s == "SAT") cout << "1";
    if (s == "SUN") cout << "7";
    if (s == "MON") cout << "6";
    if (s == "TUE") cout << "5";
    if (s == "WED") cout << "4";
    if (s == "THU") cout << "3";
    if (s == "FRI") cout << "2";
    
    return 0;
}

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

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

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

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

int main()
{
    string S;
    cin >> S;
    int m = 0;
    int n = S.length();
    m = (int)(S[n - 4] - '0') + (int)(S[n - 5] - '0') * 10;
    if (m > 4)
        cout << "TBD" << endl;
    else
        cout << "Heisei" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    ll n,m; cin >> n >> m;
    ll ans = 0;
    if(2*n==m){
	ans = n;
    }else if(2*n > m){
	ans = m/2;
    }else{
	ans = n;
	m = m-(2*n);
	ans += m/4;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#python Time_Limit_Exceeded.py
"""
入力フォーマット
N T
c_1 t_1
.
.
.
c_N t_N
N:帰宅経路数, T:帰宅制限時間
c_i:i番目の経路のコスト, t_i:i番目の経路の時間
出力：時間T以内に帰宅可能な最小コストの経路(不可能なら"TLE")
"""

line1 = list(map(int, input().split(" ")))
N = line1[0]
T = line1[1]
line2 = []
for i in range(N):
	line2.append(list(map(int, input().split(" "))))

min=1001 #1<=T<=1000
for i in range(N):
	if line2[i][1]<=T and min>line2[i][0]:
		min=line2[i][0]

if min<1001:
	print(min)
else:
	print("TLE")


Measured memory_bytes: 3064
program therefore;
var
    n : string;
    x : char;
begin
    readln(n);
    x := n[length(n)];
    if (x = '2') or (x = '4') or (x = '5') or (x = '7') or (x = '9') then 
        writeln('hon')
        else if x = '3' then
            writeln('bon')
                else writeln('pon');
end.

Measured memory_bytes: 1360
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	int[] prime = new int[32769];
	int[] map = new int[32769];
	prime[0] = 1;  prime[1] = 1;
	TreeSet<Integer> tree = new TreeSet<Integer>();
	for(int i=2; i<Math.sqrt(32769); i++)
	    if(prime[i]==0)
		for(int j=i*i; j<32769; j+=i)
		    prime[j] = 1;
	int k = 0;
	for(int i=2; i<32768; i++)
	    if(prime[i]==0){
		map[k] = i;
		k++;
	    }
	try {
	    while(true){
		int count=0, n = Integer.valueOf(sc.readLine());
		if(n==0)
		    break;
		k = 0;
		while(map[k] != 0){
		    if(map[k]>n/2)
			break;
		    if(prime[n-map[k]]==0)
			count++;
		    k++;
		}
		System.out.println(count);
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

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

string S;

void solve() {
  ll res1 = 0, res2 = 0;
  for (int i = 0; i < (int)S.size(); i++) {
    if (i % 2 == 0 && S[i] != '0') {
      res1++;
    }
    else if (i % 2 == 1 && S[i] != '1') {
      res1++;
    }
  }
  for (int i = 0; i < (int)S.size(); i++) {
    if (i % 2 == 0 && S[i] != '1') {
      res2++;
    }
    else if (i % 2 == 1 && S[i] != '0') {
      res2++;
    }
  }
  cout << min(res1, res2) << "\n";
  return;
}

int main() {
  cin >> S;
  solve();
  return 0;
}


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

int main(void){
  string a,b;
  cin >> a >> b;
  a = a+b;
  int c = stoi(a);
  for (int i=0; i<1000; i++){
    if (c == i*i){
      cout << "Yes" << "\n";
      return 0;
    }
  }
  cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector <int> H(N);
  int ans   = 0;
  int steps = 0;
  for (int i = 0; i < N; i++) {
	  cin >> H[i];
	}
  for (int i = N - 1; i > 0; i--) {
	  if (H[i] <= H[i - 1]) {
		  steps++;
		  ans = max(ans, steps);
		}
	  else {
		  steps = 0;
		}
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
function reverse(s) {
  return s.split('').reverse().join('');
}
 
function r_search(input){
  const words = ['dreamer', 'dream', 'eraser', 'erase'];
  const reversed_words = words.map(x => reverse(x));
  var current_input = reverse(input);

  length_check_loop: while(current_input!=""){
    for(word of reversed_words){
      
      if(current_input.startsWith(word)){
        current_input = current_input.substring(word.length)
        continue length_check_loop;
      }
    }
    return false;
  }
  return true;
}
 
function main(input) {
  if(r_search(input.split('\n')[0])){
    console.log('YES');
  }else{
    console.log('NO');
  }
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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


int main() {
    long N;
    cin >> N;

    long n = sqrt(N);
    long a, b;

    for(long i = n; i > 0; i--){
        if(N % i == 0){
            a = i;
            b = N / i;
            break;
        }
    }

    cout << (a-1)+(b-1) << endl;
    
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
import math 

if n>=2 and m>=2:
  ans = math.factorial(n)/math.factorial(n-2)/math.factorial(2) + math.factorial(m)/math.factorial(m-2)/math.factorial(2)

elif n<2 and m>=2 :
  ans =  math.factorial(m)/math.factorial(m-2)/math.factorial(2)

elif m<2 and n>=2:
  ans = math.factorial(n)/math.factorial(n-2)/math.factorial(2)

else:
  ans = 0

print(int(ans))

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
    // Your code here!
    int n, i, ii, iii, ans = 0;
    long long int l[101], tmp, sum;

    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%lld", l + i);
    for (i = 0; i < n; i++)
        for (ii = i + 1; ii < n; ii++)
            for (iii = ii + 1; iii < n; iii++)
                if (l[i] != l[ii] && l[i] != l[iii] && l[ii] != l[iii])
                {
                    tmp = l[i];
                    if (l[ii] > tmp)
                        tmp = l[ii];
                    if (l[iii] > tmp)
                        tmp = l[iii];
                    sum = l[i] + l[ii] + l[iii];
                    if (sum - tmp * 2 > 0)
                        ans++;
                }
    printf("%d", ans);
                    
}


Measured memory_bytes: 1736
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 
using namespace std;
int main(){
  ll a,b,c,x,y;
  cin >>a>>b>>c>>x>>y;
  ll ans=1000000009;
  ll i=0;
  ll d=0;
  ll e=0;
while(i/2<=max(x,y)){
  d=0;
  e=0;
    if(x>i/2){
       d=x-i/2;
    }
    if(y>i/2){
        e=y-i/2;
    }
      ans=min(ans,i*c+d*a+e*b);
  i++;
}
  cout <<ans<<endl;
}
      
  

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;

int main()
{
	int n;
	cin>>n;
	
	if(n==1) cout<<"Hello World"<<endl;
	if(n==2){
		int a,b;
		cin>>a>>b;
		cout<<a+b<<endl;	
	}
	
	return 0;
}


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

using namespace std;

typedef long long ll;

int n, m;
int vis[16];
vector<int> g[16];

ll dfs(int u, int c) {
  if(c == n)
    return 1;

  vis[u] = 1;

  ll cnt = 0;
  for(int v : g[u])
    if(not vis[v])
      cnt += dfs(v, c+1);

  vis[u] = 0;

  return cnt;
}

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  cin >> n >> m;
  while(m--) {
    int u, v;
    cin >> u >> v;
    g[u].emplace_back(v);
    g[v].emplace_back(u);
  }
  ll cnt = dfs(1, 1);
  cout << cnt;
}

Measured memory_bytes: 256
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace __gnu_pbds;
using namespace std;

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

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

int a, b, c;

signed main() {
  init_ios();
  cin >> a >> b >> c;
  if (c-a-b >= 0 && 4*a*b < (c-a-b)*(c-a-b))
    cout<<"Yes\n";
  else
    cout<<"No\n";
}

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

if(X<0):
  X = -X
if(X>=K*D):
  print(X-K*D)
else:
  p = X % D
  q = (X-p)//D
  if((K-q) % 2 == 0):
    print(p)
  else:
    print(D - p)

Measured memory_bytes: 9176
def func_b(a):
    if a%2!=0:
        return 0
    elif a%2==0:
        if a%3==0:
            return 0
        elif a%5==0:
            return 0
        else:
            return 1

N = int(input())
A = list(map(int, input().split()))
A_=map(func_b, A)
if sum(A_)!=0:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#define rep(i,n) for(ll i=0; i<n; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	int N,M;
	cin >> N >> M;
	int ans = N*(N-1)/2 + M*(M-1)/2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main (){
	int n;
	int m;
	cin>>n>>m;
	int MATR[n][m];
	for (int i=0; i<n; i++)
		for (int j=0; j<m; j++)
			cin>>MATR[i][j];
	int vector[m];
	for(int i=0; i<m; i++)
		cin>>vector[i];
		
	for(int i=0; i<n; i++){
		int res=0;
		for (int j=0; j<m; j++){
		res+=MATR[i][j]*vector[j];
		}
	cout<<res<<endl;
	}
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n,c1=0,c2=0,c3=0,c4=0;
	cin>>n;
	string s;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s=="AC")
		c1++;
		else if(s=="WA")
		c2++;
		else if(s=="TLE")
		c3++;
		else c4++;
	}
	cout<<"AC x "<<c1<<endl;
	cout<<"WA x "<<c2<<endl;
	cout<<"TLE x "<<c3<<endl;
	cout<<"RE x "<<c4<<endl;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {

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

    vector<int>h(999);
    rep2(i,1,1000){
        h[i]=i+h[i-1];
    }

    rep2(i,1,1000){
        if(h[i+1]-h[i]==b-a){
            cout<<h[i]-a<<endl;
            return 0;
        }
    }

}


Measured memory_bytes: 256
import sys
N = int(input())
K = int(input())
coordinate = list(map(int,input().split()))
if N < 0 or N > 100 or K < 0 or K > 100:
    sys.exit()

sum_min = 0
for x in coordinate:
    if x < 0 or x >= K:
        sys.exit()
    if x * 2 <= (K - x) * 2:
        sum_min += x * 2
    else:
        sum_min += (K - x) * 2
print(sum_min)

Measured memory_bytes: 9128
#include<iostream>
using namespace std; // 575

int main() {
	char b;
	cin >> b;
	cout << (b == 'A' ? 'T' : b == 'T' ? 'A' : b == 'G' ? 'C' : 'G');
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

*/

Measured memory_bytes: 256
s=input()
t=input()
if s==t:
    print("Yes")

else:
    flag=True
    for i in range(1,len(s)):
        if s[0:i]==t[len(s)-i:len(s)] and s[i:len(s)]==t[0:len(s)-i]:
            print("Yes")
            flag=False
            exit()

    if flag:
        print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    vec a(7); readvec(a);
    int ans = (a[0] / 2) * 2 + a[1] + (a[3] / 2) * 2 + (a[4] / 2) * 2;
    if(a[0] >= 1 && a[3] >= 1 && a[4] >= 1){
        int ans2 = 3;
        a[0]--; a[3]--; a[4]--;
        ans2 += (a[0] / 2) * 2 + a[1] + (a[3] / 2) * 2 + (a[4] / 2) * 2;
        ans = max(ans, ans2);
    }
    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256