akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class D
{
	struct P
	{
		public int i, j;
		public P(int _i, int _j) { i = _i; j = _j; }
		public bool IsInRange => 0 <= i && i < h && 0 <= j && j < w;
		public P[] Nexts() => new[] { new P(i, j - 1), new P(i, j + 1), new P(i - 1, j), new P(i + 1, j) };
	}

	static int h, w;

	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var z = Read();
		h = z[0]; w = z[1];
		var s = Read();
		var g = Read();
		var c = new int[h].Select(_ => Console.ReadLine()).ToArray();

		var sp = new P(s[0] - 1, s[1] - 1);
		var gp = new P(g[0] - 1, g[1] - 1);

		var u = new int[h, w];
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				u[i, j] = c[i][j] == '.' ? 1 << 30 : -1;
		var pq = PQ<P>.Create(p => u[p.i, p.j]);

		u[sp.i, sp.j] = 0;
		pq.Push(sp);

		// Dijkstra
		while (pq.Any())
		{
			var p = pq.Pop();

			foreach (var x in p.Nexts())
			{
				if (!x.IsInRange || u[x.i, x.j] <= u[p.i, p.j]) continue;
				u[x.i, x.j] = u[p.i, p.j];
				pq.Push(x);
			}

			for (int i = -2; i <= 2; i++)
				for (int j = -2; j <= 2; j++)
				{
					var x = new P(p.i + i, p.j + j);
					if (!x.IsInRange || u[x.i, x.j] <= u[p.i, p.j] + 1) continue;
					u[x.i, x.j] = u[p.i, p.j] + 1;
					pq.Push(x);
				}
		}
		var r = u[gp.i, gp.j];
		Console.WriteLine(r == 1 << 30 ? -1 : r);
	}
}

class PQ<T> : List<T>
{
	public static PQ<T> Create(T[] vs = null, bool desc = false)
	{
		var c = Comparer<T>.Default;
		return desc ?
			new PQ<T>(vs, (x, y) => c.Compare(y, x)) :
			new PQ<T>(vs, c.Compare);
	}

	public static PQ<T> Create<TKey>(Func<T, TKey> getKey, T[] vs = null, bool desc = false)
	{
		var c = Comparer<TKey>.Default;
		return desc ?
			new PQ<T>(vs, (x, y) => c.Compare(getKey(y), getKey(x))) :
			new PQ<T>(vs, (x, y) => c.Compare(getKey(x), getKey(y)));
	}

	Comparison<T> c;
	public T First => this[0];

	PQ(T[] vs, Comparison<T> _c)
	{
		c = _c;
		if (vs != null) foreach (var v in vs) Push(v);
	}

	void Swap(int i, int j) { var o = this[i]; this[i] = this[j]; this[j] = o; }
	void UpHeap(int i) { for (int j; i > 0 && c(this[j = (i - 1) / 2], this[i]) > 0; Swap(i, i = j)) ; }
	void DownHeap(int i)
	{
		for (int j; (j = 2 * i + 1) < Count;)
		{
			if (j + 1 < Count && c(this[j], this[j + 1]) > 0) j++;
			if (c(this[i], this[j]) > 0) Swap(i, i = j); else break;
		}
	}

	public void Push(T v)
	{
		Add(v);
		UpHeap(Count - 1);
	}
	public T Pop()
	{
		var r = this[0];
		this[0] = this[Count - 1];
		RemoveAt(Count - 1);
		DownHeap(0);
		return r;
	}
}


Measured memory_bytes: 51068
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
  ll H,W,C;cin >> H >> W;
  char S[57][57];
  rep(i,H){
    cin>>S[i];
  }
  rep(i,H){
    rep(j,H){
      if(S[i][j]=='#'){
        C=0;
        if(i!=0){
          if(S[i-1][j]=='#'){
            C++;
          }
        }
        if(i!=H-1){
          if(S[i+1][j]=='#'){
            C++;
          }
        }
        if(j!=0){
          if(S[i][j-1]=='#'){
            C++;
          }
        }
        if(j!=W-1){
          if(S[i][j+1]=='#'){
            C++;
          }
        }
        if(C==0){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
//2019.8.24 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define unl __int128
#define eps 5.6e-8
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define ull unsigned LL
#define gc getchar
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG unl x){
//    if(x>10)write(x/10);
//    putchar(int(x%10)+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start=clock();
//inline void ck(){
//    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
const int kcz=1e9+7;
const int N=2e3+10;
namespace MAIN{
    int n,k;
    int a[N];
    int ans,sum;
    inline int mul(const res &x,const res &y){
        return int(1LL*x*y%kcz);
    }
    inline int qpow(res x,res y){
        res ret=1;
        while(y){
            if(y&1)ret=mul(ret,x);
            x=mul(x,x),y>>=1;
        }
        return ret;
    }
    inline void MAIN(){
        n=read(),k=read();
        for(res i=1;i<=n;i++)a[i]=read();
        for(res i=1;i<=n;i++)
            for(res j=i+1;j<=n;j++){
                if(a[i]>a[j])ans++;
                if(a[i]<a[j])sum++;
            }
        res Ans=0;
        Ans=mul(ans,k);
        res A=ans+sum;
        res B=1LL*k*(k-1)/2%kcz;
        A=mul(A,B);
        Ans=(Ans+A)%kcz;
        printf("%d\n",Ans);
    }
}
int main(){
//    srand(19260817);
//    freopen("signin.in","r",stdin);
//    freopen("signin.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

bool X[N][N];

void initialize()
{
  for (int i = 0; i < N; i++)
    row[i] = FREE, col[i] = FREE;
  for (int i = 0; i < 2 * N - 1; i++)
    dpos[i] = FREE, dneg[i] = FREE;
}

void printBoard()
{
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      if (X[i][j])
      {
        if (row[i] != j)
          return; // 前提としてコマが置かれているのに探索の結果ではコマが置かれていない場合．
      }
    }
  }
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      cout << ((row[i] == j) ? "Q" : ".");
    }
    cout << endl;
  }
}

void recursive(int i)
{
  if (i == N)
  { // クイーンの襲撃に成功
    printBoard();
    return;
  }

  for (int j = 0; j < N; j++)
  {
    // (i, j)が他のクイーンに襲撃されている場合は無視
    if (NOT_FREE == col[j] || NOT_FREE == dpos[i + j] || NOT_FREE == dneg[i - j + N - 1])
      continue;
    // (i, j)にクイーンを配置する
    row[i] = j;
    col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
    // 次の行を試す
    recursive(i + 1);
    // (i, j)に配置されているクイーンを取り除く
    row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
  }
  // クイーンの配置に失敗
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  initialize();

  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      X[i][j] = false;
    }
  }

  int k;
  cin >> k;
  for (int i = 0; i < k; i++)
  {
    int r, c;
    cin >> r >> c;
    X[r][c] = true;
  }

  recursive(0);

  return 0;
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;
int main(){
  int ct;
  vector<int> n;
  string ans = "NO";
  REP(c,4){
    cin >> ct;
    n.pb(ct);
    }
    sort(n.begin(),n.end());
    if(n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9) ans = "YES";

    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main(){
	var A, B, C string
	fmt.Scan(&A, &B, &C)

	if A[len(A)-1] == B[0] && B[len(B)-1] == C[0]{
		fmt.Println("YES")
	}else{
		fmt.Println("NO")
	}

}

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



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    int n;
    cin>>n;
    int ans = (n+1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    int s, w;
    cin >> s >> w;
    if (s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>

int main(){
	int n, m;
	while(std::cin>>n>>m, n, m){
		int a[10001], b[10001];
		std::vector<int> fri;
		int ans = 0;
		int flag[10001]={0};
		flag[1]=1;
		for(int i=0;i<m;++i){
			std::cin>>a[i]>>b[i];
			if(a[i]==1)flag[b[i]]=1,fri.push_back(b[i]),ans++;
			if(b[i]==1)flag[a[i]]=1,fri.push_back(a[i]), ans++;
		}
		for(int i=0;i<fri.size();++i){
			for(int j=0;j<m;++j){
				if(fri[i]==a[j] && !flag[b[j]])ans++, flag[b[j]]=1;
				if(fri[i]==b[j] && !flag[a[j]])ans++, flag[a[j]]=1;
			}
		}
		std::cout<<ans<<std::endl;
	}
}
		
		

Measured memory_bytes: 1336
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#define Mod 1000000007
#define INF 1e14
typedef long long int ll;
const ll N=1e5+5;
int main()
{
    ll n,K;
    cin>>n>>K;
    ll a[n],i,j;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll res[n];
    for(i=0;i<n;i++)
    {
        ll u=0;
        for(j=i+1;j<n;j++)
        {
            if(a[i]>a[j])
            {
               u++;
            }
        }
        res[i]=u;
    }
    ll p[n];
    for(i=0;i<n;i++)
    {
        ll y=0;
        for(j=0;j<n;j++)
        {
            if(i!=j)
            {
              if(a[i]>a[j])
              y++;
            }
        }
        p[i]=y;
    }
    ll ans=0;
    ll inv=500000004;
    for(i=0;i<n;i++)
    {
        ll e,g;
        e=((K%Mod)*(res[i]%Mod))%Mod;
        g=((K%Mod)*((K-1)%Mod))%Mod;
        g=((g%Mod)*(p[i]%Mod))%Mod;
        g=((g%Mod)*(inv%Mod))%Mod;
        ans=(ans%Mod+e%Mod+g%Mod)%Mod;
    }
    cout<<ans;

}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    for(int i=0;i<n;i++) cin>>h[i];
    int ans=0;
    while(1){
        int i=0;
        int M=0;
        while(1){
            bool f=false;
            while(h[i]!=0 && i<n){
                h[i]--;
                M=max(M,h[i]);
                i++;
                f=true;
            }
            while(h[i]==0 && i<n){
                i++;
            }
            if(f) ans++;
            if(i==n) break;
        }
        if(M==0) break;
    }
    cout<<ans<<endl;
}

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

int main() {
    int r, w, c, r1;
    while (cin >> r >> w >> c >> r1) {
        if (r + w + c + r1 == 0) break;
        int cur = r / w;
        if (cur == c) {
            cout << 0 << endl;
            continue;
        }
        for (int i = 0;; i++) {
            int nx = (r + i * r1) / w;
            if (c <= nx) {
                cout << i << endl;
                break;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3080
/*input
??2??5
 
*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

const int N = 1e5 + 1;
int dp[N][13];

string str;
int n;

int fun(int ind, int rem) {
  if (ind == n) {
    return rem == 5;
  }
  if (dp[ind][rem] != -1)
    return dp[ind][rem];
  int ans = 0;
  if (str[ind] == '?') {
    for (int i = 0; i <= 9; i++) {
      ans = add(ans, fun(ind + 1, (rem * 10 + i) % 13));
    }
  } else {
    ans = add(ans, fun(ind + 1, (rem * 10 + (str[ind] - 48)) % 13));
  }
  return dp[ind][rem] = ans;
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  cin >> str;
  n = str.size();
  memset(dp, -1, sizeof(dp));
  int ans = fun(0, 0);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 13392
#include <stdio.h>

int main(void) {
	int a, b, c;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	if (a < b){
		if (b < c)
			printf("Yes\n");
		else
		printf("No\n");
	}
	else
	printf("No\n");
	return 0;
}

Measured memory_bytes: 580
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    a = (N-2) if N >= 2 else 1
    b = (M-2) if M >= 2 else 1
    print(a*b)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
    int a,cnt;
    scanf("%d",&a);
    cnt = 0;
    cnt+=a/25;
    a = a%25;
    cnt += a/10;
    a = a%10;
    cnt += a/5;
    a = a%5;
    cnt += a;
    printf("%d\n",cnt);
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#define ll long long

using namespace std;

long long MOD = 1000000007;

vector<long long> fact(10,1);
void factorial(int N){
    for(int i=1; i<N; i++){
        fact[i+1]=(i+1)*fact[i]%MOD;
    }
}

double norm(vector<double> p1, vector<double> p2){
    double ret=(p1[0]-p2[0])*(p1[0]-p2[0])+(p1[1]-p2[1])*(p1[1]-p2[1]);
    ret=sqrt(ret);
    return ret;
}

int main(){
    int N; 
    cin >> N;
    factorial(10);
    double ans=0;
    vector<vector<double>> pos(N,vector<double>(2,0));
    for(int i=0; i<N; i++){
        cin >> pos[i][0] >> pos[i][1];
    }

    for(int i=0; i<N; i++){
        for(int j=0; j<i; j++){
            ans+=norm(pos[i],pos[j])*2/N;
        }
    }
    cout << setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    //let n = read::<u32>();
    let v = read_vec::<u64>();
    let w = v[0];
    let h = v[1];
    let x = v[2];
    let y = v[3];

    let half = (w * h) as f64 / 2.0;
    if 2 * x == w && 2 * y == h {
        println!("{} 1", half);
    } else {
        println!("{} 0", half);
    }
}


Measured memory_bytes: 4352
a=300
x,n=map(int, input().split())
if n==0:
    a=x
else:
    p= list(map(int, input().split()))
    ls=[j  for j in range(-100,200)]

    for i in range(len(p)):
        ls.remove(p[i])
    for k in range(len(ls)):
        if abs(x-ls[k])<abs(x-a):
             a=ls[k]
        elif abs(x-ls[k])==abs(x-a):
            if ls[k]<a:
                a=ls[k]
print(a)

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

int main(void)
{

    string str;
    string::size_type size;
    cin >> str;
    size = str.size();
    
    int i;
    char c;
    
    for(i=0;2*i<size;i++){
        c = str[2*i];
        cout << c;
    }
    cout << endl;

}


Measured memory_bytes: 512
#python3
from collections import Counter
from operator import itemgetter
def main():
    n = int(input())
    s = [(x, -y) for x, y in Counter([input() for i in range(n)]).items()]
    s.sort(key=itemgetter(1,0))
    MAX = s[0][1]
    for i in range(len(s)):
        if s[i][1] == MAX:
            print(s[i][0])
        else:
            break

main()

Measured memory_bytes: 47176
#include <atcoder/segtree>
#include <iostream>
#include <vector>
#define rep(i, j, n) for (int i = j; i < n; ++i)
using namespace std;

int b;
bool f(int a) { return a < b; }

int main() {
  int n, q, t, x, v;
  cin >> n >> q;
  vector<int> a(n);
  for (int& z : a) cin >> z;
  auto op = [](int a, int b) { return std::max(a, b); };
  auto e = []() { return 0; };
  atcoder::segtree<int, op, e> st(a);

  rep(i, 0, q) {
    cin >> t >> x >> v;
    --x;
    if (t == 1)
      st.set(x, v);
    else if (t == 2)
      cout << st.prod(x, v) << '\n';
    else {
      b = v;
      cout << st.max_right<f>(x) + 1 << '\n';
    }
  }

  return 0;
}

Measured memory_bytes: 5704
#!/usr/bin/env python3
import sys
import fractions
from functools import reduce

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def solve(N: int, T: "List[int]"):
    print(reduce(lcm,T))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    T = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5332
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //b
  int n;
  cin >> n;
  double ans = 0;
  for (int i = 0; i < n; i++) {
    double a;
    cin >> a;
    ans += 1 / a;
  }
  cout << setprecision(20) << fixed << 1 / ans << endl;
  return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int a,b,c,x; cin>>a>>b>>c>>x;
	int ans=0;
	for(int i=0;i<=a;++i){
		for(int j=0;j<=b;++j){
			for(int k=0;k<=c;++k){
				if(i*500+j*100+k*50==x)++ans;
			}
		}
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}


// ----------------------------------------------------------------------------
int main(){
  while(1){
    int n,x;
    cin >> n >> x;
    if(n==0 && x==0){
      break;
    }
    int ans=0;
    for(int i=1; i<=n; i++){
      for(int j=i+1; j<=n; j++){
        if(x-(i+j)<=j) continue;
        if(x-(i+j)<=n){
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3112
n,m = map(int,input().split())
ans = [[int(i) for i in input().split()] for j in range(n)]

loved = []
for i in range(m):
    loved.append(0)
for i in range(n):
    for f in range(ans[i][0]+1):
        if f==0:
            continue
        loved[ans[i][f]-1] += 1

a = 0

for f in range(m):
    if(loved[f]==n):
        a += 1
print(a)

Measured memory_bytes: 3064
//
// Created by Hideaki Imamura on 2020-04-04.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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;
}

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

ll N, K;

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

    cout << min(N % K, K - N % K) << endl;
    return 0;
}

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

array = {}
for i in range(N):
    a,b = map(int,input().split())
    if a not in array:
        array[a] = b
    else:
        array[a] += b

k = 1        
for a,b in sorted(array.items(),key=lambda x:x[0]):
    if k+b>K:
        print(a)
        break
    else:
        k += b

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

using namespace std;

int main(){
  int a,b,c;
  cin >>a>>b>>c;
  int sum=a+b+c;
  if((sum/2==max(a,max(b,c)))&&(sum%2==0))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

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

int main() {

    int N, M;
    cin >> N >> M;

    vector<vector<int>> v(100010);

    int A, B;
    for (int i = 0; i < M; ++i) {
        cin >> A >> B;
        v[A].push_back(B);
        v[B].push_back(A);
    }

    queue<int> q;
    set<int> visited;
    vector<int> ans(100010);

    q.push(1);
    visited.insert(1);

    int node;
    while(!q.empty()) {
        node = q.front();
        // cout << "node : " << node << endl;
        q.pop();
        for (int n: v[node]) {
            // cout << "n : " << n << endl;
            set<int>::iterator itr = visited.find(n);
            if (itr == visited.end()) {
                q.push(n);
                visited.insert(n);
                ans[n] = node;
            }
        }
    }

    cout << "Yes" << endl;
    for (int i = 2; i <= N; ++i) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 14772
// Problem : A - ∴ (Therefore)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<string, string> pss;
#define pb push_back
#define EPS 1e-4
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fout(S,x)            cout<<fixed<<setprecision(x)<<(S)<<endl
#define present(c,x) ((c).find(x) != (c).end())
#define T() ll tc;cin>>tc;while(tc--)
#define ff first
#define ss second
#define fread(input) freopen("input","r",stdin)
#define fwrite(b) freopen("b","w",stdout)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define FOREACH(i,c) for (__typeof ((c).begin()) i = (c).begin() ; i != (c).end() ; i++)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int main(){
    fastio;
    int n;
    cin>>n;
    string s = to_string(n);
    if(s[s.length()-1]=='3'){
    	cout<<"bon"<<endl;
    }
    else if(s[s.length()-1]=='0'||s[s.length()-1]=='6'||s[s.length()-1]=='8'||s[s.length()-1]=='1'){
    	cout<<"pon"<<endl;
    }
    else{
    	cout<<"hon\n";
    }
    return 0;
}    


Measured memory_bytes: 3740
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

int main(){
    int x,y;
    cin>>x>>y;
    if(x==1 && y==1){
        cout<<1000000<<endl;
    }
    else{
        auto f=[](int x){
            if(x==1) return 300000;
            if(x==2) return 200000;
            if(x==3) return 100000;
            return 0;
        };
        cout<<f(x)+f(y)<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if (4*h*n-N*h-N*n)>0 and (h*n)%(4*h*n-N*h-N*n)==0:
            print(h,n,h*n*N//(4*h*n-N*h-N*n))
            exit()


Measured memory_bytes: 40556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(a,j,n) for(ll i=a;i<j;i=i+n )
typedef pair<ll,ll> P;
const ll mod = 1000000007;
const ll INF = 1000000009;
ll i;


int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll d=c-b-a;

    if(d>=0){
        if(d*d-4*a*b>0)cout<<"Yes";
        else cout<<"No";
    }
    else{
        cout<<"No";
    }
    cout<<endl;
}



Measured memory_bytes: 256
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

int a,b,c,d;

int main() {
	qr(a);qr(b); qr(c);qr(d);
	while(a>0&&c>0) {
		c-=b;
		if(c<=0) {puts("Yes"); return 0;}
		a-=d;
		if(a<=0) {puts("No");return 0;}
	}
	return 0;
}



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

#define INF 100000000

int n, p[100001], dp[100001];

int rec(int idx) {
    if(idx == n) return 0;
    if(idx < 0) return INF;
    if(~dp[idx]) return dp[idx];


    int ret = INF;
    if(idx + 1 == p[idx]) {
        swap(p[idx], p[idx + 1]);
        ret = min(ret, rec(idx + 1) + 1);
        swap(p[idx], p[idx + 1]);
        swap(p[idx], p[idx - 1]);
        ret = min(ret, rec(idx - 1) + 1);
        swap(p[idx], p[idx - 1]);
    } else {
        ret = rec(idx + 1);
    }

    return dp[idx] = ret;
 }

int main() {

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

    memset(dp, -1, sizeof(dp));
    cout << rec(0) << endl;
}


Measured memory_bytes: 5760
N = int(input())
H = list(map(int, input().split()))
_max = 0
m = 0
before = H[-1]
for n in range(N - 2, -1, -1):
    now = H[n]
    _max = max(_max, m)
    if before <= now:
        m += 1
    else:
        m = 0
    before = now
_max = max(_max, m)
print(_max)


Measured memory_bytes: 14228
from math import ceil


def main():
    N = int(input())
    capacity = []
    for _ in range(5):
        capacity.append(int(input()))
    min_capacity = min(capacity)
    if N <= min_capacity:
        print(5)
    else:
        print(4 + ceil(N / min_capacity))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
/* *
 *
 * Author: Hamkor
 *
 * */
 
#include <bits/stdc++.h>

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s; cin>>s;
	int m = (s[5]-48)*10 + (s[6]-48), d = (s[8]-48)*10 + (s[9]-48);
	if (m<4) cout<<"Heisei";
	else if (m==4) if (d<= 30) cout<<"Heisei";else cout<<"TBD";
	else cout<<"TBD";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<ll,ll>
const ll mod=1000000007;
int n,a,b;
ll t[111111];


ll m[100][100];

ll C(ll n,ll r){
	if(n<r)return 0;
	if(m[n][r]!=0)return m[n][r];
	if(n==r)return m[n][r]=1;
	if(r==1)return m[n][r]=n;
	return m[n][r]=C(n-1,r)+C(n-1,r-1);
}

int main(){
	//cout<<C((ll)50,(ll)25)<<endl;
	cin>>n>>a>>b;
	rep(i,n)cin>>t[i];
	sort(t,t+n,greater<ll>());
	a--;
	b--;
	ll ma=t[0];
	ll pt=0,cnt=0;
	rep(i,a+1)cnt+=t[i];

	if(t[a]!=ma){
		ll k=t[a];
		int sta,sum=0;;
		rep(i,n){
			if(t[i]==k){sta=i;break;}
		}	
		rep(i,n)if(t[i]==k)sum++;
		pt+=C(sum,a+1-sta);

		double s=(double)cnt/(double)(a+1);
		printf("%.10lf\n",s);
		cout<<pt<<endl;
	}

	else{

		int pos=a;
		ll tmp=t[a],c=0;
		while(tmp==t[pos])pos++;


		double s=(double)cnt/(double)(a+1);
		printf("%.10lf\n",s);
		for(int i=a+1;i<=b+1;i++){pt+=C(pos,i);}
		cout<<pt<<endl;
	}
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;
const int mx=200005;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll cnt=0;
    int n=s.size();
    rep(i,n){
        cnt+=s[i]-'0';
    }
    if(cnt%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3772
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << (A + B + C > 21 ? "bust" : "win") << endl;
    
    return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

template<typename String> bool isAnagram(String s, String t) {
  std::sort(s.begin(), s.end());
  std::sort(t.begin(), t.end());
  return s == t;
}

main {
  string s;
  cin >> s;
  if (s.size() < 8) {
    cout << s << endl;
    return 0;
  }
  rep(i, s.size() - 7) {
    if (isAnagram(s.substr(i, 8), string("AIDUNYAN"))) {
      s.replace(i, 8, "AIZUNYAN");
      i += 7;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 3224
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void _main();
int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); return 0;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

void _main() {
  int N; cin >> N ;
  vl a(N),inv(N);
  rep(i,N) cin >> a[i] ;
  rep(i,N) inv[a[i]-1] = i;
  set<int> st;
  ll ans = 0LL;
  rep(i,N){
    st.insert(inv[i]);
    auto itr = st.find(inv[i]);
    int lb,ub;
    if(itr==st.begin()) lb = 0;
    else lb = *prev(itr)+1;
    if(next(itr)==st.end()) ub = N-1;
    else ub = *next(itr)-1;
    ans += ll(i+1) * ll(inv[i]-lb+1) * ll(ub-inv[i]+1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 14848
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;
const int MOD=1000000007;

int n;
ll a,b; ll d[2];
ll x[MAXN],dx[MAXN];

int nxt[2][MAXN]; // nx[i][j]=jj is first idx with x[jj]>=x[j]+d[i]
ll mnd[2][MAXN]; // mnd[i][j] is the minimum distance between two elements between j and nx[i][j]

int q[MAXN],qhead,qtail;

int dp[MAXN+1];	// dp[j] is # ways to divide [j..n)
int dpfix[2][MAXN+1]; // dpfix[i][j] is #ways to divide [j..n) given that j belongs to i and j-1 belongs to 1-i
void inc(int &a,int b) { if((a+=b)>=MOD) a-=MOD; }

void run() {
	scanf("%d%lld%lld",&n,&a,&b); REP(i,n) scanf("%lld",&x[i]); d[0]=a,d[1]=b;

	FOR(i,1,n) dx[i]=x[i]-x[i-1];
	REP(i,2) {
		qhead=qtail=0;
		for(int at=0,to=0;at<n;++at) {
			if(to<=at) to=at+1;
			while(qtail<qhead&&q[qtail]<=at+1) ++qtail;
			while(to<n&&x[to]<x[at]+d[i]) {
				if(to!=at+1) {
					int d=dx[to];
					while(qtail<qhead&&dx[q[qhead-1]]>=d) --qhead;
					q[qhead++]=to;
				}
				++to;
			}
			//printf("\t"); FOR(j,qtail,qhead) printf("%d=%d ",q[j],x[q[j]]-x[q[j]-1]); puts("");
			nxt[i][at]=to; mnd[i][at]=qtail<qhead?dx[q[qtail]]:LLONG_MAX;
		}
		//REP(j,n) printf("(%d..%d=%lld) ",j,nxt[i][j],mnd[i][j]==LLONG_MAX?-1:mnd[i][j]); puts("");
	}

	dp[n]=1;
	for(int j=n-1;j>=0;--j) {
		REP(i,2) if(j+1>=n||x[j]+d[i]<=x[j+1]) inc(dp[j],dp[j+1]); else inc(dp[j],dpfix[1-i][j+1]);
		if(j!=0) REP(i,2) if(mnd[1-i][j-1]>=d[i]) if(nxt[1-i][j-1]==n||dx[nxt[1-i][j-1]]>=d[i]) inc(dpfix[i][j],dp[nxt[1-i][j-1]]); else inc(dpfix[i][j],dpfix[1-i][nxt[1-i][j-1]]);
	}
	printf("%d\n",dp[0]);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll x,y;
  cin>>x>>y;
  ll c=1;
  while(true){
    if(x*2<=y){
      x*=2;
      c++;
    }else{
      cout<<c<<endl;
      break;
    }
  }
}

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

LL n,a,ans,sum;

int main()
{
    scanf("%lld",&n);
    mp[0]=1;
    while(n--)
    {
        scanf("%lld",&a);
        sum+=a;
        ans+=mp[sum];
        mp[sum]++;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 12800
N = int(input())
A = [0] + list(map(int, input().split())) + [0]

all = 0
for i in range(1, N + 2):
    all += abs(A[i] - A[i - 1])

for i in range(1, N + 1):
    tmp = all
    tmp -= abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i])
    tmp += abs(A[i + 1] - A[i - 1])
    print(tmp)


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

int main()
{
    int n, k;cin>>n>>k;
  string s;
  cin>> s;
  for(int i=0;i<n;++i)
    if(i==k-1) cout << (char)(s[i]+32);
  else cout << s[i];
  cout<<endl;
}

Measured memory_bytes: 256
def solve():
    S = input()
    if S == 'SUN':
        print(7)
    elif S == 'MON':
        print(6)
    elif S == 'TUE':
        print(5)
    elif S == 'WED':
        print(4)
    elif S == 'THU':
        print(3)
    elif S == 'FRI':
        print(2)
    else:
        print(1)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int n;
vector<int> G[100005];
bool used[100005];
P res[100005];
int cnt[100005];

P solve(int len){
	memset(used,false,sizeof(used));
	memset(cnt,0,sizeof(cnt));
	queue<int> que;
	for(int i=0;i<n;i++){
		if(G[i].size()==1){
			que.push(i);
		}
	}
	int prev=-1;
	while(que.size()){
		int v=que.front();
		prev=v;
		que.pop();
		used[v]=true;
		int sum=0;
		multiset<int> vi;
		for(int i=0;i<G[v].size();i++){
			int nv=G[v][i];
			if(used[nv]){
				vi.insert(res[nv].second);
				sum+=res[nv].first;
			}else{
				cnt[nv]++;
				if(cnt[nv]+1==G[nv].size())que.push(nv);
			}
		}
		if(vi.size()==0){
			res[v]=P(1,1);
			continue;
		}
		bool flag=false;
		int len_min=n+5;
		while(vi.size()){
			int v=*vi.rbegin();
			multiset<int>::iterator it2=vi.end();
			it2--;
			vi.erase(it2);
			multiset<int>::iterator it=vi.upper_bound(len-v);
			if(it!=vi.begin()){
				it--;
				vi.erase(it);
				sum--;
			}else{
				flag=true;
				len_min=min(len_min,v);
			}
		}
		if(!flag){
			sum++;
			len_min=0;
		}else if(len_min==len){
			sum++;
			len_min=0;
		}
		res[v]=P(sum,len_min+1);
		//printf("%d %d %d\n",v,res[v].first,res[v].second);
	}
	if(res[prev].second==1){
		res[prev].first--;
		res[prev].second=len;
	}
	return res[prev];
}


bool C(int num,int len){
	P rec=solve(len);
	if(rec.first>num)return false;
	return true;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int l1=0,r1=n;
	while(l1+1<r1){
		int mid=(l1+r1)/2;
		if(C(mid,n))r1=mid;
		else l1=mid;
	}
	int l2=0,r2=n;
	while(l2+1<r2){
		int mid=(l2+r2)/2;
		if(C(r1,mid))r2=mid;
		else l2=mid;
	}
	printf("%d %d\n",r1,r2);
	return 0;
}

Measured memory_bytes: 12120
// https://atcoder.jp/contests/abc165/tasks/abc165_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll A, B, N;
  cin >> A >> B >> N;

  ll x = min(N, B - 1);
  ll res = (A * x / B) - A * (x / B);

  cout << res << "\n";
}


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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

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

  i64 n, k;
  cin >> n >> k;

  vector<i64> a(n+5);
  i64 maxv = 0;

  rep(i, n) {
    cin >> a[i];
    if (a[i] == k) {
      cout << "POSSIBLE" << "\n";
      return 0;
    }
    chmax(maxv, a[i]);
  }

  i64 G = a[0];
  for (int i = 1; i < n; ++i) {
    G = gcd(G, a[i]);
  }

  cout << ((k % G == 0 && k <= maxv) ? "POSSIBLE" : "IMPOSSIBLE") << "\n";

  return 0;
}

Measured memory_bytes: 1024