akhauriyash/Code-Regression huggingface dataset:
<?php

[$N ] = fscanf(STDIN, "%d");
$keta = 0;
$keta_value = 26;
while($N > 0){
    $keta++;
    if($N > 26**$keta){
        $N -= 26**$keta;
    }else{
        break;
    }


}
$ans = "";
for($i=0;$i<$keta;$i++){
    if($N === 0){
        $ans = "a".$ans;
    }else {
        $ts = $N % 26;
        if($ans === "") {
            if ($ts === 0) {
                $ts = 26;
            }
            $ans = chr(96 + $ts) . $ans;
        }else{
            $ans = chr(97 + $ts) . $ans;
        }
        $N = intdiv($N - $ts, 26);
    }
}
echo $ans;


Measured memory_bytes: 16056
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if(A == B) {
        cout << C << endl;
        return 0;
    }
    if(B == C) {
        cout << A << endl;
        return 0;
    }
    if(A == C) {
        cout << B << endl;
        return 0;
    }
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = (ll)(1e9 + 7);

struct UnionFind {
  vector<int> data; // 根の場合は集合の大きさ*-1、子の場合は親の番号が入る
  UnionFind(int size) : data(size, -1) { }
  bool link(int x, int y) { //新たな併合を行うとtrue
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  int root(int x) { // 代表元を返す
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  bool same(int x, int y) { // 同じ集合ならtrue
    return root(x) == root(y);
  }
};

struct Edge {
  int u, v;
  ll w;
};

const int MAX_N = 1024;
const int MAX_M = 2024;
ll two[MAX_M];


int N, M;
vector<Edge> g[MAX_N];
vector<Edge> es;

bool dfs(int cur, int prev, int goal, vector<ll>&path) {
  if (cur == goal) {
    return true;
  }
  for (Edge e : g[cur]) if (e.v != prev) {
    path.push_back(e.w);
    bool found = dfs(e.v, cur, goal, path);
    if (found) {
      return true;
    } else {
      path.pop_back();
    }
  }
  return false;
}

// 「重さがX以下の全ての全域木は単色である」 ような辺の塗り方の総数。
// ⇔
// 「カラフルな全域木が存在するならばその重さは X+1 以上である」ような辺の塗り方の総数。
ll f(ll X) {

  REP(i, MAX_N) g[i].clear();

  sort(ALL(es), [](const Edge& a, const Edge& b){
    return a.w < b.w;
  });

  UnionFind uf(N);
  ll S = 0;
  vector<int> inS(M);
  REP(j, M) {
    const int u = es[j].u;
    const int v = es[j].v;
    if (!uf.same(u, v)) {
      uf.link(u, v);
      S += es[j].w;
      inS[j] = 1;
      g[u].push_back({u, v, es[j].w});
      g[v].push_back({v, u, es[j].w});
    }
  }

  int c = 0;
  REP(j, M) {
    if (inS[j]) {
      if (S <= X) { /* */ } else { c++; }
    } else {
      const int u = es[j].u;
      const int v = es[j].v;
      vector<ll> path;
      dfs(u, -1, v, path);
      ll d = *max_element(ALL(path));
      if (S - d + es[j].w <= X) { /* */ } else { c++; }
    }
  }
  if (c == M)
    return two[c-1];
  else
    return two[c];
}

int main2() {
  N = nextInt();
  M = nextInt();
  ll X = nextLong();
  es.clear();
  REP(i, M) {
    int u = nextInt() - 1;
    int v = nextInt() - 1;
    ll w = nextLong();
    es.push_back((Edge){u, v, w});
  }

  ll ans = f(X-1) - f(X) + MOD;
  ans = (ans * 2) % MOD;
  cout << ans << endl;
  return 0;
}

int main() {

  two[0] = 1;
  for (int i = 1; i < MAX_M; i++) two[i] = (two[i-1] * 2) % MOD;

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
const int maxn = 123567;
vector<int> g[maxn];
int dfs(int cur, int pr){
    int ans = 0;
    for(int v : g[cur])
        if(v != pr)
            ans ^= dfs(v, cur) + 1;
    return ans;
}
int main(){
    int n;
    scanf("%d", &n);
    for(int e = 0; e < n - 1; e ++){
        int x, y; scanf("%d %d", &x, &y); x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    if(dfs(0, -1)) printf("Alice\n");
    else printf("Bob\n");
    return 0;
}


Measured memory_bytes: 11008
#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b;
	cin >> a >> b;
	cout << 6-a-b;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())

    def enum_divisors(n):
        # 約数列挙

        divisors = []

        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n // i)

        return divisors

    divs = enum_divisors(N)

    ans = INF
    for div1 in divs:
        div2 = N // div1
        score = (div1 + div2 - 2)
        ans = min(score, ans)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65220
#include <iostream>
#include <iomanip>
#include <algorithm>

using namespace std;

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

    int Arr[N] = {0};
    for (int i = 0; i < N; i++){
        cin >> Arr[i];
    }

    for (int i = 0; i < N; i++){
        cout << Arr[i];
        if (i != N-1) cout << " ";
    }
    cout << endl;

    int Tmp = 0, j = 0;
    for (int i = 1; i < N; i++){
        Tmp = Arr[i];
        j = i-1;
        while (j >= 0 && Arr[j] > Tmp){
            Arr[j+1] = Arr[j];
            j--;
        }
        Arr[j+1] = Tmp;
        for (int i = 0; i < N; i++){
            cout << Arr[i];
            if (i != N-1) cout << " ";
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3104
package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

func StrStdin() string {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	return strings.TrimSpace(scanner.Text())
}

func Uint64Stdin() uint64 {
	stringInput := StrStdin()
	num, _ := strconv.ParseUint(strings.TrimSpace(stringInput), 10, 64)
	return num
}

func IsPrime(n uint64) bool {
	if n == 1 { return false }
	if n == 2 { return true }
	if n % 2 == 0 { return false }

	for ni := 3; uint64(ni) * uint64(ni) <= n; ni += 2 {
		if n % uint64(ni) == 0 { return false }
	}

	return true 
}

func Solve() {
	X := Uint64Stdin()
	start := X

	if IsPrime(X) { 
		fmt.Println(X)
		return
	}

	if X % uint64(2) == 0 { 
		start += 1
	}

	for {
		if IsPrime(start) { break }
		start += 2
	}

	fmt.Println(start)
}

func main() {
	Solve()
}

Measured memory_bytes: 640
N, Y = map(int, input().split())
for i in range(N + 1):
    for j in range (N - i +1):
        if i * 10000 + j * 5000 + (N - i - j) * 1000 == Y:
            print(i, j, N - i - j)
            exit()
print('-1 -1 -1')

Measured memory_bytes: 2940
def solve():
    n,t = map(int,input().split())
    mn = 10**9
    ans = False
    for _ in range(n):
        a,b = map(int,input().split())
        if b<=t:
            mn = min(mn,a)
            ans = True
    if ans:
        print(mn)
    else:
        print('TLE')
if __name__=='__main__':
    solve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int r,g,b;
  cin>>r>>g>>b;
  if((10*g+b)%4==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
int l[2005];
int cnt[2005][2005];
int main(){
	int n,i,j,ans=0,low,high;

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

	for(i=0;i<n;i++){//[i,n-1]
        for(j=i;j<n;j++){
            cnt[i][l[j]]++;
        }
        for(j=1;j<2005;j++){
            cnt[i][j]+=cnt[i][j-1];
            //printf("cnt[%d][%d]=%d",i,j,cnt[i][j]);
        }
	}

	for(i=0;i+2<n;i++){
        for(j=i+1;j+1<n;j++){

            high=l[i]+l[j];
            if(l[i]>l[j]) low=l[i]-l[j];
            else low=l[j]-l[i];
            //printf("%d %d:%d<x<%d %d\n",l[i],l[j],low,high,cnt[j+1][high-1]-cnt[j+1][low]);
            if(cnt[j+1][high-1]-cnt[j+1][low]>0) ans+=cnt[j+1][high-1]-cnt[j+1][low];
        }
	}
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 17384
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, v, w, t int
	fmt.Scan(&a, &v, &b, &w, &t)

	if w >= v {
		fmt.Println("NO")
		return
	}

	if (v-w)*t >= int(math.Abs(float64(b)-float64(a))) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1820
def baisuaru(l,r,m):
  if l//m < r//m:
    return True
  elif l%m==0:
    return True
  else:
    return False
    

l,r = map(int, input().split())


if baisuaru(l,r,2019):
  print(0)
else:
  if baisuaru(l,r,3) and baisuaru(l,r,673):
    print(0)
  else:
    a=l%2019
    b=r%2019
    ans=99999999
    for i in range(a,b+1):
      for j in range(i+1,b+1):
        tmpans=(i*j)%2019
        if ans>tmpans:
          ans=tmpans
    print(ans)
    


Measured memory_bytes: 38768
import bisect
a,b,q=map(int,input().split())
S,T=[],[]
for i in range(a):
  S.append(int(input()))
for i in range(b):
  T.append(int(input()))
def f(list,n):
  if n<list[0]:
    return [-float("inf"),list[0]]
  elif list[-1]<n:
    return [list[-1],float("inf")]
  else:
    i=bisect.bisect_left(list,n)
    return [list[i-1],list[i]]
def g(SS,TT,x):
  a,b,c,d=x-SS[0],SS[1]-x,x-TT[0],TT[1]-x
  dis1=max(a,c)
  dis2=min(2*a+d,2*d+a)
  dis3=max(b,d)
  dis4=min(2*b+c,2*c+b)
  return min([dis1,dis2,dis3,dis4])
for i in range(q):
  x=int(input())
  print(g(f(S,x),f(T,x),x))

Measured memory_bytes: 12092
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include<iostream>
using namespace std;
typedef long long ll;
ll a[1000005];
int main()
{
    ll a,b,c;
    scanf("%lld %lld %lld",&a,&b,&c);
    if(a<=b*c)
    printf("Yes\n");
    else
         printf("No\n");

}


Measured memory_bytes: 3724
#include <iostream>
#include <stack>
#include <string>

using namespace std;

int main()
{
	stack<long> s;
	string i;

	while (cin >> i) {
		if (i == "+") {
			int a, b;
			b = s.top();
			s.pop();
			a = s.top();
			s.pop();
			s.push(a + b);
		} else if (i == "-") {
			int a, b;
			b = s.top();
			s.pop();
			a = s.top();
			s.pop();
			s.push(a - b);
		} else if (i == "*") {
			int a, b;
			b = s.top();
			s.pop();
			a = s.top();
			s.pop();
			s.push(a * b);
		} else {
			s.push(stoi(i));
		}
	}
	cout << s.top() << endl;
}

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

void Main()
{
    string s;
    cin >> s;
    int n = 0, mn=0;
    for (int i = 0; i < 3; i++)
    {
        if(s[i]=='R') n++;
        else if(s[i]=='S') n=0;
        mn = max(n, mn);
    }
    cout << mn << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef unsigned long long ull;
typedef long long ll;

#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)

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

ll mod(ll a, ll b) { return (a%b+b)%b; }
ll gcd(ll x, ll y) { return __gcd(x, y); }
ll lcm(ll x, ll y) { return x * 1ll * y / gcd(x, y); }
 
const ll MAXN = 1e18;
const ll SIZE = 100;
const ll MOD  = 1e9 + 7;

ll n, m, x, res = MAXN;
ll c[SIZE], u[SIZE], a[SIZE][SIZE];

int main() { speedhack()

	cin >> n >> m >> x;

	forn (i, n) {
		cin >> c[i];
		forn (j, m)
			cin >> a[i][j];
	}

	ll N = (1LL << n) - 1;

	for (ll i = 1; i <= N; i++) {
		ll sum = 0;
		for (ll j = 1; j <= m; j++) u[j] = 0;
		bool ok = true;
		for (ll j = 0; j < 15; j++) {
			ll bit = (i >> j) & 1;
			if (bit) {
				sum += c[j + 1];
				for (ll k = 1; k <= m; k++) 
					u[k] += a[j + 1][k];
			}
		}
		for (ll j = 1; j <= m; j++)
			if (u[j] < x) 
				ok = false;
		if (ok)
			res = min (res, sum);
	}

	if (res == MAXN) 
		res = -1;
	cout << res;
	

	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
	int n;
	cin>>n;
	vector<int>v(n);
	int s = 0;
	for(int i = 0; i < n; i++)cin>>v[i];
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++)s+=v[i]*v[j];
	}
	cout<<s;
}
signed main(){
	speed;
	int t=1;
	//cin>>t;
	while(t--)solve();
}

Measured memory_bytes: 3568
#include<iostream>

using namespace std;
int main(void){
  int N, X, num_min = 0;
  int m[100];
  cin >> N >> X;
  for(int i = 0; i < N; i++){
    cin >> m[i];
    X -= m[i];
    if(m[num_min] > m[i]){
      num_min = i;
    }
  }
  cout << N + X/m[num_min] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
 
int A;
 
 
string F(int len){
    int x=len/2;
    if(x*(x+1)/2<A)return "";
 
    string S="";
 
    int st=0;
    int op=x,en=x;
    int cost=0;
    for(int i=0;i<len;i++){
        if(op){
            int sst=st+1;
            int sop=op-1;
            int sen=en;
            int scost=cost+max(-st,0ll);
            int t=min(sen-sst,sop);
            scost+=t*(t+1)/2;
            if(scost>=A){
                S+="(";
                op--;
                cost+=max(-st,0ll);
                st++;
            }
            else{
                S+=")";
                en--;
                st--;
            }
        }
        else {S+=")";en--;st--;}
 
 
        //cout<<S<<" "<<st<<" "<<op<<" "<<en<<" "<<cost<<endl;
    }
    return S;
}
 
signed main(){
    cin>>A;
    for(int i=1;;i++){
        if(i*(i+1)/2>=A){
            cout<<F(i*2)<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3352
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <sstream>
#define maxn 200005
#define pb push_back
#define mp make_pair
#define lop(i,k,n) for(int i=(k);i<n;i++)
#define rep(i,k,n) for(int i=(k);i<=n;i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){if (b == 0) return a; return gcd(b , a&b);}
ll lcm(ll a, ll b){ return a/gcd(a,b)*b;}
map<ll,ll> s;
int a[maxn];
int main(){
    ll n,sum = 0,count = 0;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        sum += a[i];
        s[sum]++;
      // cout << sum << endl;
    }
   // cout << 1 << endl;
    map<ll,ll> ::iterator it;
    for (it = s.begin(); it != s.end(); it++) {
        ll x = it->second;
       // cout << x << endl;
        if (x > 1) {
            //cout <<x*(x-1)/2<<endl;
            count += x*(x-1)/2;
        }
        if (it->first == 0){
            //cout <<x*(x-1)/2<<endl;
            count += it->second;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=998244353;
const int maxn=3e3+5;;

int dp[maxn][maxn];
int a,b,c,d;

int f(int x,int y){
	int &ans = dp[x][y];
	if(ans != -1) return ans;
	if(x < a or y < b) return 0;
	ans = f(x-1,y)*(y);
	ans += f(x,y-1)*x;
	ans -= f(x-1,y-1)*(x-1)*(y-1);
	ans %= MOD;
	return ans;
}

int32_t main(){
    fast_io;
    for (int i = 0; i < maxn; ++i)
    {
    	for (int j = 0; j < maxn; ++j)
    	{
    		dp[i][j] = -1;
    	}
    }
    cin>>a>>b>>c>>d;
    dp[a][b] = 1;
	show((f(c,d)+MOD)%MOD);
    return 0;
}

Measured memory_bytes: 74456
#include <bits/stdc++.h>
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>
using namespace std;
constexpr char nl = '\n';
using ll = long long;
using boost::irange;
namespace rng { using namespace boost; using namespace boost::range; }
namespace adp { using namespace boost::adaptors; }

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
constexpr auto color_s_ = "\033[2m\033[33m", color_e_ = "\033[0m";
template<class T> void trace_(const T& v) { cerr << v; }
template<class T> void trace_(const vector<vector<T>>& m) { cerr << "\n"; for (const auto& v : m) { trace_(v); cerr << "\n"; } }
template<class T> void trace_(const char* s, const T& v) { cerr << color_s_ << s << "="; trace_(v); cerr << color_e_ << "\n"; cerr.flush(); }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { cerr << color_s_; for (; *s != ','; ++s) { cerr << *s; } cerr << "="; trace_(v); cerr << ","; trace_(++s, vs...); }
#define TRACE(...) trace_(#__VA_ARGS__, __VA_ARGS__)
#else
#define TRACE(...)
#endif

int main() {
    ll x;
    cin >> x;
    ll a = 100;
    int i = 0;
    while (a < x) {
        a = a * 1.01;
        i++;
    }
    cout << i << nl;
}


Measured memory_bytes: 3656
/*input
999999
*/
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<iomanip>
using namespace std;
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
typedef long double ld;
#define pii pair<ld,ld>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ld i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=50005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-8;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int main(){
    int n;
    cin>>n;
    int ans=0;
    REP1(i,n/2){
        int j=n-i;
        if(j!=i) ++ans;
    }
    cout<<ans;
}

Measured memory_bytes: 256
def main():
    t = list(input())
    pre_char = "*" #意味なし
    answer_char_lst = []
    for i in range(len(t)):
        temp_c = t[i]
        next_c = t[i+1] if i < len(t)-1 else "P"
        pre_c = t[i-1] if i > 0 else "D"

        if temp_c == "?":
            if pre_c == "P":
                temp_c = "D"
            elif pre_c == "D":
                temp_c = "P" if next_c == "D" else "D"
            else:
                temp_c = "D"
        t[i] = temp_c
        answer_char_lst.append(temp_c)

    print("".join(answer_char_lst))


if __name__ == '__main__':
    main()


Measured memory_bytes: 12484
import java.util.Scanner

object Main extends App { 
  val sc = new Scanner(System.in)
  val n, t  = sc.nextInt()
  val list = (for (i <- 0 until n) yield (sc.nextInt(), sc.nextInt())).toList

  type Move = (Int, Int) // (time, direction)

  def prep(ls:List[(Int, Int)], ac:List[Move]):List[Move] = {
    if (ls.isEmpty) ac.sortWith((a, b)=> (a._1 - b._1) match {
      case d if d > 0 => false
      case d if d < 0 => true
      case _ => a._2 < b._2  
    })
    else {
      val (l, r) = ls.head
      prep(ls.tail, (l,1)::(r,0)::ac)
    }
  }

  val moves = prep(list, Nil)

  def solver(l:List[Move], m:Int, ac:Int):Int = {
    if (l.isEmpty) m
    else {
      l.head match {
        case (_, 1) => solver(l.tail, m max ac+1, ac+1)
        case (_, _) => solver(l.tail, m, ac-1)
      }
    } 
  }

  println(solver(moves, 0, 0))
}



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

using namespace std;

typedef pair<int, int> P;

int main() {
  int N;
  cin >> N;
  int res = 0;
  for (int i = 1; i <= N; i += 2) {
    int cnt = 0;
    for (int j = 1; j * j <= i; ++j) {
      if (i % j == 0) cnt++;
    }
    if (cnt == 4) res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import sys


from inspect import currentframe


def pri(*args):
    names = {id(v): k for k, v in currentframe().f_back.f_locals.items()}
    # print(', '.join(names.get(id(arg), '???')+' = '+repr(arg) for arg in args))


def solve(n, w_count):
    pri("solve")
    right_count = [5, 7, 5, 7, 7]

    for i in range(n):
        locate = 0
        way_count = 0
        pri(i)

        for w_i in w_count[i:]:
            if right_count[locate] == w_i + way_count:
                locate += 1
                way_count = 0
            elif right_count[locate] > w_i + way_count:
                way_count += w_i
            else:
                break

            if locate == 5:
                print(i + 1)
                return


    return


if __name__ == '__main__':
    while True:
        n_input = int(input())
        if n_input == 0:
            break
        w_count_imput = [len(input()) for i in range(n_input)]

        solve(n_input, w_count_imput)




Measured memory_bytes: 7424
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
int gcd(int a,int b){if(a<b)swap(a,b);int c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int n; cin>>n;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> h(n);
  rep(i,n) cin>>x[i]>>y[i]>>h[i];

  rep(i,101){
    rep(j,101){
      ll H=-1;
      ll underh=LMAX;
      bool f=1;
      rep(k,n){
        if(k==0){
          if(h[k]==0) underh=abs(x[k]-i)+abs(y[k]-j);
          else H=h[k]+abs(x[k]-i)+abs(y[k]-j);
        }else{
          ll nh=h[k]+abs(x[k]-i)+abs(y[k]-j);
          if(h[k]==0) underh=min(underh,nh-h[k]);
          else{
            if(H==-1) H=nh;
            else if(H!=nh) f=0;
          }
          if(H>underh) f=0;
        }
      }
      if(f&&H>0){
        cout<<i<<" "<<j<<" "<<H;
        return 0;
      }
    }
  }

  return 0;
}


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

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)

const int GEN = 1e9 + 7;

int main(){
  int n, m;
  scanf("%d%d",&n,&m);
  int k = ceil(sqrt(m));
  int p = 2;
  int maxD = 0; // 最大の割り切れる回数
  queue<int> times; // 素数で何回割り切れるかを記録する

  if(m % 2 == 0){ // 2で何回割り切れるか
    int a = 0;
    while(m % 2 == 0){
      m /= 2;
      a++;
    }
    times.push(a);
    if(a > maxD){ // maxDの更新
      maxD = a;
    }
  }
  p++;

  while(p <= k && p <= m){ // √ m 以下の 奇素数で何回割り切れるか
    if(m % p == 0){ // 割り切れなくなるまで
      int a = 0;
      while(m % p == 0){
        m /= p;
        a++;
      }
      times.push(a);
      if(a > maxD){ // maxDの更新
        maxD = a;
      }
    }
    p += 2;
  }
  if(m > 1){
    times.push(1); // mはこの時素数である
  }
  // Distrubute[p][q] := p人に対して, 区別のつかない q 個のものを配る通りの 10^9 + 7での余り
  vector< vector<long long int> > Distribute(n + 1);
  for(int i = 0;i <= n;i++){
    Distribute[i].resize(maxD + 1,0);
  }
  Distribute[0][0] = 1;
  for(int i = 1;i <= n;i++){
    Distribute[i][0] = 1;
    for(int j = 1;j <= maxD;j++){
      Distribute[i][j] = (Distribute[i][j - 1] + Distribute[i - 1][j]) % GEN;
    }
  }

  int ans = 1;
  while (!times.empty()) {
    int a =  times.front(); // 先頭要素を参照する
    times.pop(); // 先頭要素を削除
    ans = (ans * Distribute[n][a]) % GEN;
  }

  //答えの出力
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 27520
N,K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
import numpy as np
s_A = sum(A)
if s_A<=K:
  print(0)

else:
  A.sort()
  F.sort(reverse=True)
  A = np.array(A)
  F = np.array(F)
  mi=0
  ma=max(F)*max(A)
  while mi+1<ma:
    mid = (mi+ma)//2
    if s_A-np.minimum(A,mid//F).sum()<=K:
      ma=mid
    else:
      mi=mid

  print(ma)

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) 2e5 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;

ll a[MAXN];

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, k;
	cin >> n >> k;
	//for(int i = 0; i < n; i++) cin >> a[i];
	if((n + 1) / 2 >= k) cout << "YES";
	else cout << "NO";
	return 0;
}


/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n,d;
  cin>>n>>d;
  vector<vector<int>>data(n,vector<int>(d));
  rep(i,n){
    rep(j,d){
      cin>>data[i][j];
    }
  }
  int ans=0;
  rep(i,n){
    rep(j,i){
      int sum=0;
      rep(k,d){
        int dif=data[i][k]-data[j][k];
        sum+=dif*dif;
      }
      int s=sqrt(sum)+0.5;
      if(s*s==sum) ans++;
    }
  }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define int ll
using namespace std;
const int inf=1e18,N=1e6;
int n,x,y,z,a[N],b[N],c[N],p[N];
ll ans,now;
multiset<int>s,s1,s2;
bool cmp(int x,int y)
{
	return a[x]-b[x]<a[y]-b[y];
}
void insx(int o)
{
	s.insert(o);now+=o;if(s.size()>x)
	{
		s1.insert(*s.begin());now-=(*s.begin());s.erase(s.begin());
	}
}
void delx(int o)
{
	if((*s.lower_bound(o))!=o)
	{
		s1.erase(s1.lower_bound(o));return;
	}//cout<<o<<" "<<(*s.lower_bound(o))<<" "<<s.size();
	//s.clear();o=2;s.insert(2);
	
	now-=o;s.erase(s.find(o));now+=(*--s1.lower_bound(inf));//cout<<s1.size()<<endl;
	s.insert(*--s1.lower_bound(inf));s1.erase(--s1.lower_bound(inf));
}
void insy(int o)
{
	s2.insert(o);now+=o;if(s2.size()>y)
	{now-=(*s2.begin());s2.erase(s2.begin());
	}
}
main()
{//s.insert(2);s.erase(s.lower_bound(2));
x=y=inf;
	//insx(1);insx(2);delx(1);return 0;delx(2);
	scanf("%lld%lld%lld",&x,&y,&z);n=x+y+z;s1.insert(inf);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);a[i]-=c[i];b[i]-=c[i];ans+=c[i];
		p[i]=i;insx(a[i]);
	}sort(p+1,p+n+1,cmp);ll kkk=-inf;//delx(2);
	//return 0;
	for(int i=1;i+x<=n;i++)
	{int e=p[i];//cout<<i<<" "<<s1.size()<<endl;cout<<e<<" "<<a[e]<<" "<<b[e]<<endl;
		insy(b[e]);
		delx(a[e]);//cout<<i<<endl;
		if(i>=y)
		kkk=max(now,kkk);
	}cout<<kkk+ans;
	return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100001
int digit(int x) {
    int sum = 0;
    int dig;
    while (x) {
        dig = x % 10;
        sum += dig;
        x /= 10;
    }
    return sum;
}
        

int main() {
    int a, n, m;

    cin >> a >> n >> m;

    int ans =0;

    ll x;

    for(int y=1; y<73; y++) {
        x = pow((y+a), n);
        if (x > m) break;
        if (digit(x) == y) {
            ans++; 
//            cout << x << endl;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 3284
using System;
using System.Collections.Generic;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            // 最初のintはcharだが楽をしている
            var map = new Dictionary<int, int>();
            for (int i = 0; i < 26; ++i)
            {
                map['a' + i] = 0;
            }

            var inputLine = Console.In.ReadToEnd(); // 読み込み終了条件がないので最後まで読む方法を試す
            var chars = inputLine.ToCharArray();

            foreach (var c in chars)
            {
                var lower = char.ToLower(c);
                if (map.ContainsKey(lower) == false)
                {
                    continue;
                }
                map[lower]++;
            }

            for (int i = 0; i < 26; ++i)
            {
                int c = 'a' + i;
                Console.Out.WriteLine("{0} : {1}", (char)c, map[c]);
            }
        }
    }
}



Measured memory_bytes: 18024
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n;
  cin>>n;
  int a[n],b[n];
  rep(i,n) cin>>a[i];
  int l=0,r=(n-1);
  int cnt=0;
  repn(i,n-1){
    if(cnt%2==0){b[l]=a[i];l++;}
    else{b[r]=a[i];r--;}
    cnt++;
  }
  rep(i,n-1) cout<<b[i]<<" ";
  cout<<b[n-1]<<endl;
  return 0;
}






Measured memory_bytes: 3712
n = int(input())
s = input()
r = s.count("R")
g = s.count("G")
b = s.count("B")
num = r*g*b
for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >=n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            num -=1
print(num)

Measured memory_bytes: 68232
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl 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>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< 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 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;
ll mypow(ll x){
    ll tmp=1;
    rep(i,0,5)
        tmp*=x;
    return tmp;
}


int main(){
    ll N,M,ans=0,f,t;
    cin>>N;
    while(1){
        f=mypow(ans);
        M=0;
        while(1){
            t=mypow(M);
            if(f+t == N){
                cout<<ans<<" "<<M*-1<<endl;
                return 0;
            }else if(f-t == N){
                cout<<ans<<" "<<M<<endl;
                return 0;
            }

            if(f>N && N+t>f){
                break;
            } else if (f<N && N-t<f){
                break;
            }
            M++;
        }
        ans++;
    }
    return 0;
}



Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    ll sum = 0;
    REP(i, 1, n + 1) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}


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

using namespace std;

template <typename T> void floyd_warshall(vector<vector<T>> &graph) {
  for (int k = 0; k < (int)graph.size(); k++) {
    for (int i = 0; i < (int)graph.size(); i++) {
      for (int j = 0; j < (int)graph.size(); j++) {
        graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W;
  cin >> H >> W;
  vector<vector<int>> C(10, vector<int>(10));
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> C[i][j];
    }
  }
  floyd_warshall(C);
  int res = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int a;
      cin >> a;
      if (a == -1) continue;
      res += C[a][1];
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

ans = 0
for i in range(N):
    ans += A[i] // 2
    A[i] = A[i] % 2
    if A[i] == 1 and i + 1 < N and A[i + 1] > 0:
        ans += 1
        A[i] -= 1
        A[i + 1] -= 1

print(ans)

Measured memory_bytes: 50008
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string>

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

typedef long long ll;

using namespace std;

const int INF = 1e9;
const double PI=3.14159265358979323846;

int main(){
  int h,w;
  cin >> h >> w;
  int a[h][w], b[w];

  rep(i,h){
    rep(j,w){
      cin >> a[i][j];
    }
  }
  rep(i,w) cin >> b[i];
  rep(i,h){
    int res = 0;
    rep(j,w){
      res += a[i][j] * b[j];
    }
    cout << res << endl;
  }
}



Measured memory_bytes: 3148
def main():
    n, t, *a = map(int, open(0).read().split())
    b = 0
    c = float("Inf")
    d = 0
    for i in range(n):
        x = a[i]
        if x - c > b:
            b = x - c
            d = 1
        elif x - c == b:
            d += 1
        c = min(c, x)

    print(d)


if __name__ == '__main__':
    main()


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

vector<int> sieve_of_eratosthenes() {
	int n = 1000000;
	vector<int> primes(n);
	for (int i = 2; i < n; i++)primes[i] = i;
	for (int i = 2; i*i < n; i++) {
		if (primes[i]) {
			for (int j = i * i; j < n; j += i) primes[j] = 0;
		}
	}

	return primes;
}

int main() {
	ll n, i = 0; cin >> n;
	auto p = sieve_of_eratosthenes();

	while (n) {
		if (p[i] && i % 10 == 1) {
			cout << i << endl;
			n--;
		}
		i++;
	}

	return 0;
}

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

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

    int n;
    string s;
    cin >> n >> s;

    int maxi = 0;
    for(int i = 1; i < n; i++){
        map<char, int> mp1, mp2;
        for(int j = 0; j < i; j++){
            mp1[s[j]]++;
        }
        for(int j = i; j < n; j++){
            mp2[s[j]]++;
        }
        int cnt = 0;
        for(auto x : mp1){
            if(mp2[x.first]) cnt++;
        }
        maxi = max(maxi, cnt);
    }
    cout << maxi << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int x[10001];
  int count = 10001;
  for (int i=1; i <= 10000; i++) {
    cin >> x[i];
    if (x[i] == 0) {
      count = i;
      break;
    }
  }
  for (int i=1; i < count; i++) 
    cout << "Case " << i << ": " << x[i] << endl;
  return 0;
}



Measured memory_bytes: 3108
#include <stdio.h>
#include <string.h>

#define MDATA 200001

typedef struct
{
    char arr[MDATA];
    int top;    //末尾のデータのある配列の要素番号
} stack;

int push(stack *stk, char input)
{
    if (stk->top <= MDATA)
    {
        stk->top++;
        stk->arr[stk->top] = input;
        return 0;
    }else{
        return -1;
    }
}

int pop2(stack *stk)
{
    if (stk->top != 0)
    {
        stk->top--;
    }
    return 0;
}

int main(void)
{
    stack stk;
    char x[MDATA];
    stk.top=0;
    scanf("%s",x);
    for(int i=0;i<strlen(x);i++)
    {
        if(x[i]=='S')
        {
            push(&stk,x[i]);
        }else{
            if(stk.arr[stk.top]=='S')
            {
                pop2(&stk);
            }else{
                push(&stk,x[i]);
            }
        }
    }
    printf("%d\n",stk.top);
    return 0;
}


Measured memory_bytes: 1992
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 22:01:05 2020

@author: H_Hoshigi
"""

import math

K = int(input())
answer = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        gcd_a_b = math.gcd(a, b)
        for c in range(1, K+1):
            answer += math.gcd(gcd_a_b, c)
print(answer)



Measured memory_bytes: 9184
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

int check (vector<pair<int, int>> &list, vector<bool> &kouho)
{
    vecrep(itr, kouho) *itr = false;
    int topd  = list[0].first;
    int ret = 0; 
    vecrep(itr, list)
    {
        if( itr->first != topd ) return ret;
        kouho[itr->second] = true;
        ret++;
    }
    return ret;
}

int main()
{
    _LL h, w, m;
    cin >> h >> w >> m;
    vector<pair<int, int>> bomb(m);
    vector<int> hlist(h);   
    vector<int> wlist(w);
    rep(i, h) hlist[i] = 0;   
    rep(j, w) wlist[j] = 0;   
    rep(i, m)
    {
        cin >> bomb[i].first >> bomb[i].second;
        bomb[i].first--;  bomb[i].second--;
        hlist[bomb[i].first]++;
        wlist[bomb[i].second]++;
    }

    vector<pair<int, int>> hsort(h);
    rep(i, h) { hsort[i].first = -hlist[i]; hsort[i].second = i; }
    vector<pair<int, int>> wsort(w);
    rep(j, w) { wsort[j].first = -wlist[j]; wsort[j].second = j; }

    sort( hsort.begin(), hsort.end() );
    sort( wsort.begin(), wsort.end() );

    vector<bool> hkouho(h);   
    vector<bool> wkouho(w);

    _LL hnum = check(hsort, hkouho);
    _LL wnum = check(wsort, wkouho);

    _LL count = 0;
    vecrep(itr, bomb)
    {
        if( hkouho[itr->first] && wkouho[itr->second] ) count++;
    }

    int ans = -hsort[0].first - wsort[0].first;
    if( count >= hnum * wnum ) ans -= 1;
    cout << ans; 

    return 0;    
}

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

using namespace std;

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

bool isPrime(int n){
    if(n == 2)return true;
    else if(n < 2)return false;
    REP(i,2,sqrt(n)+1)if(!(n % i))return false;
    return true;
}

int main(){
    int n,cnt = 0;
    cin >> n;
    rep(i,n){
        int k;
        cin >> k;
        if(isPrime(k))cnt++;
    }

    cout << cnt << endl;

    return 0;
}


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

long long int N, A;
unordered_set<long long> s;

int main(){
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i){
        scanf("%lld", &A);
        if(s.count(A))s.erase(A);
        else s.insert(A);
    }
    cout << s.size() << endl;
    return 0;
}

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

const int MOD = (int)1e9+7;

int main(){
	int N;
	cin >> N;
	vector<double> A(N);
	for(int i=0;i<N;i++)	cin >> A.at(i);

	double ans=0;
	for(int i=0;i<N;i++){
		ans+=1.0/A.at(i);
	}
	ans=1.0/ans;
	printf("%9f\n",ans);

	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vadim Semenov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        PopularVote solver = new PopularVote();
        solver.solve(1, in, out);
        out.close();
    }

    static final class PopularVote {
        public void solve(int __, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] a = in.nextIntArray(n);
            int total = 0;
            for (int i : a) {
                total += i;
            }
            int qty = 0;
            for (int i : a) {
                if (i * 4 * m >= total) {
                    qty++;
                }
            }
            out.println(qty >= m ? "Yes" : "No");
        }

    }

    static class InputReader {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public int[] nextIntArray(int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; ++i) {
                array[i] = nextInt();
            }
            return array;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(readLine());
            }
            return tokenizer.nextToken();
        }

        public String readLine() {
            String line;
            try {
                line = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }

    }
}



Measured memory_bytes: 21460
#include<iostream>
#include<string>
using namespace std;
char map[8][8],cop[8][8];
int main(){
	for(int i=0;i<8;i++)
		for(int j=0;j<8;j++)
			cin>>cop[i][j];
	for(int u=1;u<=3;u++){
		cout<<u*90<<endl;
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				map[i][j]=cop[7-j][i];
				cout<<map[i][j];
			}
			cout<<endl;
		}
		for(int i=0;i<8;i++)
			for(int j=0;j<8;j++)
				cop[i][j]=map[i][j];
	}
	return 0;
}

Measured memory_bytes: 1140