akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(N: int):
    n = N % 10
    if n in [2, 4, 5, 7, 9]:
        return 'hon'
    if n in [0, 1, 6, 8]:
        return 'pon'
    return 'bon'

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
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
    print(solve(N))

def test():
    import doctest
    doctest.testmod()

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


Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int N,M; cin >> N >> M;
  if(N==M) Yes
  else No
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class ABC
{

    public static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string S = Console.ReadLine();
        int K  = int.Parse(Console.ReadLine());

        char target = S[K - 1];
        string output = "";
        for (int i = 0; i < S.Length; i++)
        {
            if (S[i] != target)
            {
                output += "*";
            }
            else output += S[i];
        }
        Console.WriteLine(output);
    }
}

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

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;

#define show(x) cerr << #x << " = " << x << endl;
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()

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


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

  int n;
  cin >> n;


  int ans = ceil(n*1.0/1000)*1000 - n;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long int lli;
const long long int MaxN=300005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli arr[MaxN];
	void solve(){
		lli N,x,i,j,p,q,res=0,tot=0;
		cin>>N>>x;
		for(i=0;i<N;i++){
			cin>>arr[i];
			tot+=arr[i];
		}
		if(x>tot){
			cout<<N-1;
			return;
		}
		sort(arr,arr+N);
		for(i=0;i<N;i++){
			if(x>=arr[i])x-=arr[i],res+=1;
		}
		cout<<res;
		
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    ll q,h,s,d,n;
    cin>>q>>h>>s>>d>>n;
    ll min1=min({4*q,2*h,s});
    ll min2=min({2*min1,d});
    cout<<min2*(n/2)+min1*(n%2)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main() {
  double x1,y1,x2,y2,x;
  scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
  x = sqrt(pow(x2-x1,2.0) + pow(y2-y1,2.0));
  printf("%lf\n", x);
  return 0;
}



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

using namespace std;

#ifdef Lin1043
    #define DEBUG(msg, ...) printf("(%s #%d) " msg, __FUNCTION__, __LINE__, __VA_ARGS__)
    #define massert(...) assert(...)
#else
    #define DEBUG(...)
    #define massert(...)
#endif

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )

struct iopener
{
    iopener()
    {
#ifdef Lin1043
        freopen("./in" , "r" , stdin);
#endif
    }
} iop;

typedef long long LL;

template<typename T>inline bool chkmin(T &x , const T &y) { return x > y ? (x = y , 1) : 0; }
template<typename T>inline bool chkmax(T &x , const T &y) { return x < y ? (x = y , 1) : 0; }

template<typename T>inline T read(T &f)
{
    f = 0; int x = 1 ; char c = getchar();
    while(!isdigit(c)) x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}

string S;

int w , n , e , s;

int check()
{
    if(w && e  && n && s )return 1;
    if(w  && e && n == 0 && s == 0)return 1;
    if(w == 0 && e == 0 && n && s)return 1;
    if(w == 0 && e == 0 && n == 0 && s == 0)return 1;
    return 0;
}
int main()
{
    getline(cin , S);
    for(size_t i = 0; i < S.length() ; ++i)
        if(S[i] == 'W')w++;
        else if(S[i] == 'N')n++;
        else if(S[i] == 'E')e++;
        else if(S[i] == 'S')s++;
    puts(check() ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
//Cancel in interactive questions
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
#define got(container,num) get<num-1>(container)
using namespace std;
const int INF=LLONG_MAX/2;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,t,a[maxn],b[maxn],ans;

main()
{
    IOS
    cin>>n;
    string k="";//0 1 1 702 27
    while(n>0)
    {
        n--;
        k+=(char)((n%26+26)%26+'a');
//        if(n-1<26)break;
        n/=26;
    }
    reverse(all(k));
    out(k)
    return 0;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <typename T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

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

    vector<int> E = enum_div(M);

    RSORT(E);
    REP(i, E.size()) {
        if (E[i] <= M / N) {
            cout << E[i] << endl;
            return 0;
        }
    }

    cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> words = new ArrayList<>();
            words.add(br.readLine());
            words.add(br.readLine());
            words.add(br.readLine());

            StringBuilder result = new StringBuilder();
            for (int i = 0; i < words.size(); i++) {
                result.append(words.get(i).substring(i, i + 1));
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 20948
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
int n,ac=0,tle=0,wa=0,re=0;
cin >> n;
string s[n];
for (int i = 0; i < n; ++i) {
    cin >> s[i];
    if(s[i]=="AC") {ac++;}
    if (s[i]=="TLE") {tle++;}
    if (s[i]=="WA") {wa++;}
    if (s[i]=="RE") {re++;}
}
cout << "AC x " << ac << endl;
cout << "WA x " << wa << endl;
cout << "TLE x " << tle << endl;
cout << "RE x " << re << endl;
return 0;
}


Measured memory_bytes: 6772
# nの逆元のリスト
def inv_mod(n:int, mod:int) -> list:
    inv = [0,1]
    for i in range(2,n+1):
        inv.append(mod - ((mod//i)*inv[mod%i]) % mod)
    return inv
       
# nの階乗のリスト
def fact(n:int, mod:int) -> list:
    fac = [1,1]
    res = 1
    for i in range(2,n+1):
        res = res*i%mod
        fac.append(res)
    return fac

# nの階乗の逆元のリスト
def fact_inv(n:int, inv:list, mod:int) -> list:
    facInv = [1,1]
    for i in range(2,n+1):
        facInv.append(facInv[i-1]*inv[i] % mod)
    return facInv
        
# 二項係数
def nCr(n:int, r:int, mod:int, fac:list, facInv:list) -> int:
    if n==0 and r==0:
        return 1

    elif not (0<=r and r<=n):
        return 0
    
    return ((fac[n]*facInv[r]) % mod) * facInv[n-r] % mod


H,W,A,B = map(int, input().split())
mod = 10**9+7

inv = inv_mod(H+W, mod)
fac = fact(H+W, mod)
facInv = fact_inv(H+W,inv,mod)

checkPoint = []
for i in range(H-A):
    checkPoint.append((i,B-1))
    
ans = 0
for h,w in checkPoint:
    ans = (ans + nCr(h+w,h,mod,fac,facInv) \
                * nCr(H+W-h-w-3, H-h-1, mod, fac, facInv)) % mod
    
print(ans)

Measured memory_bytes: 39000
H, N = map(int, input().split())
G = [0 for i in range(N)]
for i in range(N):
    A, B = map(int, input().split())
    koritu = A / B
    G[i] = (koritu, A, B)
G.sort(reverse = True)
#print(G)
dp = [[0 for i in range(H+1)] for j in range(N)]
k, a, b = G[0]
for i in range(1, H + 1):
    dp[0][i] = ((i - 1) // a + 1) * b
for j in range(1, N):
    k, a, b = G[j]
    for i in range(1, H+1):
        if i >= a:
            dp[j][i] = min(dp[j-1][i], dp[j][i-a] + b)
        else:
            dp[j][i] = min(dp[j-1][i],b)
print(dp[N-1][H])



Measured memory_bytes: 125916
n=int(input())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
ans=0
for i in range(n-1,-1,-1): #勇者を後ろから順にみていく
 if arr1[i+1]>=arr2[i]: #i番目の勇者がi+1番目の町のモンスターしか倒せないとき
   ans+=arr2[i]
   continue
 else: #i番目の勇者がi番目の町のモンスターも倒す余裕があるとき
   ans+=arr1[i+1]
   arr2[i]-=arr1[i+1]
   if arr1[i]>arr2[i]: #i番目の勇者がi番目の町のモンスターをすべて倒せないとき
     ans+=arr2[i]
     arr1[i]-=arr2[i] #i番目の勇者が倒せなかったモンスターの数を計算する
   else:  #i番目の勇者がi番目の町のモンスターもすべて倒せるとき
     ans+=arr1[i]
     arr1[i]=0
print(ans)

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

int main() {
  long n;
  cin >> n;
  if (n%11 == 0) {
    cout << n/11*2 << endl;
  }
  if (1 <= n%11 && n%11 <= 6) {
    cout << n/11*2 +1 << endl;
  }
  if (7 <= n%11) {
    cout << n/11*2 +2 << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    String output = "";
    for(int i = x - n + 1; i <= x + n -1; i++){
      output += "" + i + " ";
    }
    System.out.println(output);
  }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	string s, t, u;
	int a, b;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	if (s == u) {
		a--;
	} else {
		b--;
	}
	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 256
X = int(input())
if 400<= X <= 599:
    print("8")
elif 600<= X <= 799:
    print("7")
elif 800<= X <= 999:
    print("6")
elif 1000<= X <= 1199:
    print("5")
elif 1200<= X <= 1399:
    print("4")
elif 1400<= X <= 1599:
    print("3")
elif 1600<= X <= 1799:
    print("2")
elif 1800<= X <= 1999:
    print("1")

Measured memory_bytes: 9056
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
          ll n,i,j,k,c=0;
          cin>>n;
          ll a[n+1];
          for(i=0;i<n;i++)
                    cin>>a[i];
         for(i=0;i<n-1;i++)
         {
                  if(a[i]>a[i+1])
                  {
                            c+=a[i]-a[i+1];
                            a[i+1]=a[i];
                  }
         }

          cout<<c;

}


Measured memory_bytes: 5212
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a[100000];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    if(n==2)cout<<n-1<<endl;
    else cout<<(n+k-3)/(k-1)<<endl;
    return 0;
}


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

using ll = long long;
const ll INF = 1e18 + 5;



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s,t;
    cin>>s>>t;
    vector<vector<int>> dp(s.length()+1,vector<int>(t.length()+1,0));
    for(int i=1;i<=s.length();i++){
		for(int j=1;j<=t.length();j++){
			if(s[i-1]==t[j-1]){
				dp[i][j] = 1 + dp[i-1][j-1];
			}	
			else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
		}
	}
    string ans = "";
    int x=s.length(),y=t.length();
    while(x&&y){
		if(s[x-1]==t[y-1]){
			x--;
			y--;
			ans += s[x];
		}
		else if(dp[x-1][y]>=dp[x][y-1]){
			x--;
		}
		else y--;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
    return 0;
}









Measured memory_bytes: 35584
from collections import deque
import sys
input = sys.stdin.readline

def solve():
  n,q = (int(i) for i in input().split())
  graph = [[] for _ in range(n)]

  for i in range(n-1):
    a,b = (int(i) for i in input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
  ans = [0]*n
  
  for i in range(q):
    p,x = (int(i) for i in input().split())
    ans[p-1] += x

  query = deque([(0,-1)])
  while query:
    nowplace,parent = query.popleft()
    nowvalue = ans[nowplace]   
    for node in graph[nowplace]:
      if node == parent:
        continue
      else:
        ans[node] += nowvalue
        query.append([node,nowplace])
      
  print(*ans)

if __name__ == '__main__':
  solve()

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

int main() {
	
	ll n; cin >> n;
	vector<ll> num(n, 0);
	for (ll i = 0; i < n; i++) {
		ll a; cin >> a;
		num[a]++;
	}
	
	const ll mod = 1000000007;
	ll ans = 1;
	bool can = true;
	if (n % 2 == 0) {
		for (ll i = 1; i <= n / 2; i++) {
			if (num[2 * i - 1] != 2) {
				can = false;
			}
		}
		if (can) {
			for (ll i = 1; i <= n / 2; i++) {
				ans *= 2;
				ans %= mod;
			}
		}
		else {
			ans = 0;
		}
	}
	else {
		if (num[0] == 1) {
			for (ll i = 1; i <= n / 2; i++) {
				if (num[2 * i] != 2) {
					can = false;
				}
			}
			if (can) {
				for (ll i = 1; i <= n / 2; i++) {
					ans *= 2;
					ans %= mod;
				}
			}
			else {
				ans = 0;
			}
		}
		else {
			ans = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define N 100005
#define ll long long
#define orta ((bas+son)>>1)
using namespace std;

int n;
int fen[3*N],a[N],pre[N],add[N];

int get(int x) {

	int res=0;

	for(int i=x;i>=1;i-=(i&-i)) res+=fen[i];

	return res;

}

void up(int x) {

	for(int i=x;i<2*N;i+=(i&-i)) fen[i]++;

}

ll find(int val) {

	for(int i=1;i<=n;i++) {

		if(a[i]<val) add[i]=1;
		else add[i]=-1;

		pre[i]=pre[i-1]+add[i];

	}

	memset(fen,0,sizeof(fen));

	up(N);

	ll res=0;

	for(int i=1;i<=n;i++) {

		res+=get(pre[i]-1+N);

		up(pre[i]+N);

	}

	return res;

}

int main() {

	//freopen("input.txt","r",stdin);

	scanf("%d",&n);

	for(int i=1;i<=n;i++) scanf("%d",&a[i]);

	int bas=1,son=1000000000;

	while(bas<=son) {

		ll smaller=find(orta);
		ll all=1ll*n*(n+1)/2;

		if(smaller>=all/2+1) son=orta-1;
		else bas=orta+1;

	}

	printf("%d",son);

}				

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a,b;
  string s,t,u;
  cin>>s>>t;
  cin>>a>>b;
  cin>>u;
  if(u.compare(s)==0)
  {
    a--;
  }
  else if(u.compare(t)==0)
  {
    b--;
  }
  cout<<a<<" "<<b;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<int,int>
#define mp make_pair
using namespace std;
int main()
{
    ll a,b;
    cin>>a>>b;
    int x = 1;
    int ans = 0;
    while(x < b)
    {
        x+=(a-1);
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    for(;;){
        cin>>x>>y;
        if(x==0&&y==0){
            break;
        }
        if(x>y){
            swap(x,y);
    }
        cout<<x<<" "<<y<<endl;
    }
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef vector<long long> vll;
typedef vector<pii> pxx;
typedef vector<int> vi;
#define pb push_back
#define mod  1000000007
#define PI 2*acos(0.0)
#define REP(i,a,b)  for(i = a; i <= b; i++)
#define f(a,b)  for(a=0 ; a<b; a++)



main()
{
    ll t=1;//cin>>t;
    while(t--)
    {
        ll n,i,sum=0,x,c=0,ec=0;
        cin >> n;
        ll ara[300000];
        map<ll,ll> v;
        f(i,n)
        {
            cin >> x;
            x=i-x+1;
            ara[i]=x;
            v[x]++;
        }
        f(i,n)
        {
            x=2*(i+1)-ara[i];
            sum+=v[x];
        }
        cout << sum << endl;


    }
}


Measured memory_bytes: 27736
#include <bits/stdc++.h>
#define BIT(x) (1ll<<(x))
#define KMAX 35

using namespace std;
typedef long long llong;
struct Coord
{
    llong x, y;
} v[1005];

int n;

int main()
{
    scanf("%d", &n);
    scanf("%lld%lld", &v[0].x, &v[0].y);
    int par = ((v[0].x + v[0].y) % 2) == 0;
    int ok = 1;
    for(int i = 1; i < n; i++)
    {
        scanf("%lld%lld", &v[i].x, &v[i].y);
        int par2 = ((v[i].x + v[i].y) % 2) == 0;
        if(par != par2)
        {
            ok = 0;
            break;
        }
    }
    if(ok == 0)
        printf("-1");
    else
    {
        if(par)
            printf("%d\n1 ", KMAX + 1);
        else printf("%d\n", KMAX);
        for(int i = KMAX - 1; i >= 0; i--)
            printf("%lld ", BIT(i));
        printf("\n");
        for(int i = 0; i < n; i++)
        {
            llong x = v[i].x;
            llong y = v[i].y;
            if(par)
            {
                x--;
                printf("R");
            }
            llong ax, ay;
            for(int i = KMAX - 1; i >= 0; i--)
            {
                ax = abs(x);
                ay = abs(y);
                if(ax > ay)
                {
                    if(x < 0)
                    {
                        x += BIT(i);
                        printf("L");
                    }
                    else
                    {
                        x -= BIT(i);
                        printf("R");
                    }
                }
                else
                {
                    if(y < 0)
                    {
                        y += BIT(i);
                        printf("D");
                    }
                    else
                    {
                        y -= BIT(i);
                        printf("U");
                    }
                }
            }
            printf("\n");
        }
    }
    return 0;
}


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

using namespace std;

const double EPS=1e-7;
bool EQ(double a,double b){
  return abs(a-b)<EPS;
}

typedef pair<int,int> pii;
int N;
double R;
set<pii> used;
double XS[1000001];
double YS[1000001];
pii ps[1000001];

int main(){
  map<pii,int> m;
  cin>>N>>R;
  double minx,miny;
  minx=(1e+10);
  miny=(1e+10);
  for(int i=0;i<N;i++){
    cin>>XS[i]>>YS[i];
    minx=min(minx,XS[i]);
    miny=min(miny,YS[i]);
  }
  for(int i=0;i<N;i++){
    XS[i]-=minx,YS[i]-=miny;
  }
  for(int i=0;i<N;i++){
    double x,y;
    x=XS[i],y=YS[i];
    int xpos=(EPS+x/(R));
    int ypos=(EPS+y/(R));
    ps[i]=pii(ypos,xpos);
    m[pii(ypos,xpos)]++;
  }
  int res=0;
  for(int i=0;i<N;i++){
    if(used.count(ps[i])!=0)continue;
    res++;
    int sy=ps[i].first;
    int sx=ps[i].second;
    queue<pii> q;
    q.push(pii(sy,sx));
    used.insert(pii(sy,sx));
    while(q.size()){
      pii p=q.front();q.pop();
      int cy=p.first;
      int cx=p.second;
      for(int i=-1;i<=1;i++){
	for(int j=-1;j<=1;j++){
	  if(i==0&&j==0)continue;
	  int ny=cy+i;
	  int nx=cx+j;
	  pii np=pii(ny,nx);
	  if(ny>=0&&nx>=0&&used.count(np)==0&&m.count(np)>0){
	    used.insert(np);
	    q.push(np);
	  }
	}
      }
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 35484
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,k; cin>>n>>k;
    string s; cin>>s;
    s[k-1] = tolower(s[k-1]);
    cout << s << '\n';
    return 0;
}

Measured memory_bytes: 256
ins = input().strip()
if not ('S' in ins and 'N' in ins) and ('S' in ins or 'N' in ins):
        print('No')
        exit()
if not ('E' in ins and 'W' in ins) and ('E' in ins or 'W' in ins):
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 3064
#include<algorithm> 
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cstdio>
#include<ctime>

using namespace std;

const int maxn=15;
int n,a[maxn];

inline int read() {
	int res=0,fh=1;
	char ch=getchar();
	while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
	if(ch=='-')fh=-1,ch=getchar();
	while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
	return fh*res;
}

inline int cnt(int a){
	int res=0;
	do{
		res++;
	}while(a/=10);
	return res;
}

int main()
{
	int ans=0;
	int n=read();
	for(int i=1;i<=n;i++){
		if(cnt(i)&1) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
// Template by [thunder_blade]
// IIIT ALLAHABAD
// includes :)

#include<bits/stdc++.h>
using namespace std;
#define TEST  int test_case; cin>>test_case; while(test_case--)
#define all(v) (v).begin(),(v).end()
#define fi  first
#define se  second
#define pb push_back
#define mp make_pair
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);  cin.tie(0);  cout.tie(0);
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define pf(x) printf("%f\n",x)
#define ps(x) printf("%s\n",x)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sf(x) scanf("%f",&x)
#define ss(x) scanf("%s",x)
#define pis(x) printf("%d ",x)
#define pls(x) printf("%lld ",x)
#define pfs(x) printf("%f ",x)
#define pss(x) printf("%s ",x)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define mod 1000000007

int main()
{
	ll a,b,c, ans= 0, a1,b1,c1;
	sl(a), sl(b), sl(c);
	while(1){
		a1 = 0, b1 = 0, c1 = 0;
		if(a%2 || b%2 ||c%2)
			break;
		ans++;
		a1 += (b/2);
		a1 += (c/2);
		b1 += (c/2);
		b1 += a/2;
		c1 += a/2;
		c1 += b/2;
		a = a1;
		b = b1;
		c = c1;
		if(ans > 1000000)
			break;
	}
	if(ans > 1000000){
		pi(-1);
	}else{
		pl(ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};


int main(){
    CIN(X);
    for(int a = 1;;a++){
        X -= a;
        if(X <= 0){
            COUT(a);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <functional>
#include <iterator>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#ifdef _MSC_VER
using ll = __int64;
using ull = unsigned __int64;
#else
using ll = long long int;
using ull = unsigned long long int;
#endif

// Range系のライブラリ
struct RangeIterator {
	ll v;
	const ll operator*() { return v; }
	RangeIterator& operator++() { ++v; return *this; }
	bool operator!=(const RangeIterator& rhs) { return v != rhs.v; }
};
template<bool INCLUSIVE> struct EndType {};
template<> struct EndType<false> {
	ll end;
	ll operator()() { return end; }
};
template<> struct EndType<true> {
	ll end;
	ll operator()() { return end + 1; }
};
template<bool INCLUSIVE>
struct Range {
	ll s; EndType<INCLUSIVE> e;
	Range(ll end) : s(0), e(EndType<INCLUSIVE>{end}) {}
	Range(ll start, ll end) : s(start), e(EndType<INCLUSIVE>{end}) {}
	RangeIterator begin() { return { s }; }
	RangeIterator end() { return { e() }; }
};
inline Range<false> range(ll start) { return Range<false>(start); }
inline Range<false> range(ll start, ll end) { return Range<false>(start, end); }
inline Range<true> irange(ll start) { return Range<true>(start); }
inline Range<true> irange(ll start, ll end) { return Range<true>(start, end); }

// 二乗を計算する。
ll sq(ll x) { return x * x; }

// 領域内にいるか。
bool within(ll x, ll min, ll max) {
	return min <= x && x <= max;
}

// container の中から key より小さい値を見つける。
// 見つからない場合は container.end() を返す。
template<typename T>
typename T::iterator less_than(T& container, typename T::key_type& key) {
	typename T::iterator prev = container.lower_bound(key);
	if (prev == container.begin()) prev = container.end();
	else prev--;
	return prev;
}

// container の中から key より大きい値を見つける。
// 見つからない場合は container.end() を返す。
template<typename T>
typename T::iterator greater_than(T & container, typename T::key_type & key) {
	return container.upper_bound(key);
}

// b^e (mod m) を求める
ll modpow(ll b, ll e, ll m) {
	ll result = 1;
	while (e > 0) {
		if ((e & 1) == 1) result = (result * b) % m;
		e >>= 1;
		b = (b * b) % m;
	}
	return result;
}


// ここから解法


int main(void) {
	std::ios_base::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	cout << (N - K + 1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N >> A;
 
  B = N % 500;
  
  if (B <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Function (on, fix)
import Data.Bool (bool)

main :: IO ()
main = do
  n <- readLn
  replicateM n (solve <$> f <*> g) >>= mapM_ print
  where
    f = map read <$> words <$> getLine
    g = map head <$> words <$> getLine

solve :: [Int] -> String -> Int
solve ns ss = bool 0 1 . all f . map (map snd) . groupBy ((==) `on` fst) . sort$ zip ss ns
  where
    f [] = True
    f xs@(x:_) = [x,x+1,x+2] `intersect` xs == [x,x+1,x+2] && f (xs \\ [x,x+1,x+2]) ||
                 [x,x,x] `isPrefixOf` xs && f (xs \\ [x,x,x])



Measured memory_bytes: 4180
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n, k;
  cin >> n >> k;
  int a[n], b[n];
  for(int i = 0; i < n; i++) cin >> a[i] >> b[i];

  vector< int > v;
  for(int i = 30; i >= 0; i--){
    if((k & (1 << i)) != 0) v.push_back(i);
  }

  ll ans = 0, sum = 0;
  for(int i: v){
    int s = k & ~(1 << i);
    s |= (1 << i) - 1;
    sum = 0;
    for(int j = 0; j < n; j++){
      if((s & a[j]) == a[j]) sum += (ll)b[j];
    }
    ans = max(ans, sum);
  }

  sum = 0;
  for(int i = 0; i < n; i++){
    if((k & a[i]) == a[i]) sum += (ll)b[i];
  }
  ans = max(ans, sum);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1152
{-# LANGUAGE FlexibleContexts #-}

import Control.Monad
import Data.List

main = sol <$> (getLine *> get) >>= print

get = map read . words <$> getLine

sol (a:as) = length . (elemIndices =<< maximum) $ f (a,a) as

f _ []        = []
f (l,r) (a:as)
  | a < l     = f (a,a) as
  | a > r     = (a-l):f (l,a) as
  | otherwise = f (l,r) as

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

#if 0
int Fibonatch(int result[], int num)
{
    int ret = result[num];

    if (ret == 0) {
        if (num > 1) {
            ret = Fibonatch(result, num - 1) + Fibonatch(result, num - 2);
        }
        else {
            ret = 1;
        }
        result[num] = ret;
    }

    return ret;
}

int main(void)
{
    int num;
    int ret[45] = {0};
    int result;

    scanf("%d", &num);
    result = Fibonatch(ret, num);

    printf("%d\n", result);

    return 0;
}
#else

int Fibonatch(int num)
{
    int i;
    int result[45];

    result[0] = result[1] = 1;
    for (i = 2; i <= num; i++) {
        result[i] = result[i - 1] + result[i - 2];
    }

    return result[num];
}

int main(void)
{
    int num;
    int result;

    scanf("%d", &num);

    result = Fibonatch(num);
    printf("%d\n", result);

    return 0;
}

#endif

Measured memory_bytes: 1188
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#include <math.h>

int main() {

	long long x;
	long long table[10000];
	int ans;
	cin >> x;

	table[0] = 100;

	for (int i = 1; i < 4000; i++) {
		table[i] = floor(table[i - 1] * 1.01);
	}

	for (int i = 1; i < 4000; i++) {
		if (x <= table[i]) {
			ans = i;
			break;
		}
	}

	cout << ans << endl;
	cin >> x;

	return 0;


}

Measured memory_bytes: 3684
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;



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

	if (N % 10 == 0) {
		cout << 10 << endl;
	}
	else {
		int ans = 0;
		N--;
		while (N > 0) {
			ans += N % 10;
			N /= 10;
		}
		cout << ans + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S = input()
    ans = 1000
    for i in range(len(S) - 2):
        ans = min(ans, abs(753 - int(S[i:i+3])))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n;
    ll a1, a2, target = 0; 
    cin >> n >> a1 >> a2;
    for (int i=2; i<n; i++) {
        ll ai; cin >> ai;
        target ^= ai;
    }
    ll sum = a1 + a2, new1 = 0;
    ll next = 0;
    cerr << target << ' ' << sum << '\n';
    vector<ll> addable;
    for (ll i=40; i>=0; i--) {
        ll x = (target >> i) & 1;
        ll s = (sum >> i) & 1;
        if (x == 0) {
            new1 += next * (1ll << i);
            next = s;
        } else {
            if (s == next) {
                cout << -1 << '\n';
                return 0;
            } else {
                addable.push_back(1ll << i);
            }
        }
    }
    for (auto &adi:addable) if (new1 + adi <= a1) new1 += adi;
    cout << (new1 <= a1 && new1 > 0 && next == 0 ? a1 - new1 : -1) << '\n';
    return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n; cin >> n;
    map<string, ll> m;
    for(int i = 0; i < n; i++){
        string s; cin >> s;
        sort(ALL(s));
        m[s]++;
    }

    ll ans = 0;
    for(auto p : m){
        if(1 < p.second){
            ans += (p.second * (p.second - 1) / 2);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11420
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string A, B; cin >> A >> B;

    int n = stoi(A + B);

    string ans = "No";
    FOR(i,1,1000) {
        if (i*i == n){
            ans = "Yes";
            break;
        }
    }
  
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = 0
for i in range(1, n + 1):
    if i < k:
        count = 1
        while (i * (2 ** count)) < k:
            count += 1
        p += (1 / n) * (0.5 ** count)
    else:
        p += 1 / n
print(p)


Measured memory_bytes: 9380
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007�
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a;
	string str;
	cin>>a>>str;
	if(a<3200)
	cout<<"red";
	else
	cout<<str;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

int main(){
    int ans = 0;
    int n,a,b;
    cin >> n >> a >> b;
    vector<int> p(n);
    for (int i = 0; i < n; ++i){
        cin >> p[i];
    }
    vector<int> pn(3,0);
    for (int i = 0; i < n; ++ i){
        if (p[i] <= a){
            pn[0]++;
        }
        if (a < p[i] && p[i] <= b){
            pn[1]++;
        }
        if (b < p[i]){
            pn[2]++;
        }
    }
    sort(pn.begin(),pn.end());
    ans = pn[0];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=[]
for i in range(n):
    s.append(input())
s2=sorted(s)
now=s2[0]
ren=1
kind=[]
for i in range(1,n):
    if now!=s2[i]:
        kind.append([ren,now])
        now=s2[i]
        ren=1
    else:
        ren+=1
kind.append([ren,now])
kind2=sorted(kind,reverse=True)
max_=kind2[0][0]
ans=[]
ans.append(kind2[0][1])
for i in range(1,len(kind2)):
    if max_==kind2[i][0]:
        ans.append(kind2[i][1])
    else:
        break
#print(kind2)
ans2=sorted(ans)
for i in range(len(ans2)):
    print(ans2[i])

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

#define Vsort(a) sort(a.begin(), a.end())
#define rep(i,n) for(int i = 0; i < (n); i++)

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  
  char a; cin >> a;
  
  if(isupper(a)){
    cout << "A" << endl;
  }else{
    cout << "a" << endl;
  }
  
  return 0;
  
}


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

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

#define x first
#define y second

const int MAXN = 50;

int n;
pii arr[MAXN+10];
int ans=100;

int main()
{
    int i, j, k, l;

    scanf("%d", &n);
    for(i=1; i<=n; i++) scanf("%d%d", &arr[i].x, &arr[i].y);

    sort(arr+1, arr+n+1);
    for(i=1; i<=n; i++) for(j=i+1; j<=n; j++)
    {
        int p=arr[j].x-arr[i].x, q=arr[j].y-arr[i].y;

        int now=0;
        for(k=1; k<=n; k++)
        {
            bool flag=true;
            for(l=1; l<=n; l++)
            {
                if(make_pair(arr[l].x+p, arr[l].y+q)==arr[k]) flag=false;
            }
            if(flag) now++;
        }
        ans=min(ans, now);
    }
    if(ans==100) ans=1;
    printf("%d", ans);
}


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

int main(){
  int n,h;
  cin >> n >> h;
  vector<int> b(n);
  int a, mx = 0, cnt = 0;
  for(int i=0;i<n;i++){
    cin >> a >> b[i];
    mx = max(a,mx);
  }
  sort(b.begin(), b.end(), greater<int>());
  for(int i=0;i<n;i++){
    if(mx < b[i]){ // 投げる
      cnt++;
      h = max(0, h - b[i]);
    }
    if(h == 0 || mx >= b[i]) break;
  }
  cout << (int)ceil(h /(double)mx) + cnt << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

template< int mod >
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
};
using mint = ModInt< 998244353 >;

signed main(){

  int a, b, c, d; cin >> a >> b >> c >> d;

  vector<vector<mint>> dp(c+3, vector<mint>(d+3, 0));
  dp[a][b] = 1;
  for(int i = a; i <= c; i++){
    for(int j = b; j <= d; j++){
      dp[i+1][j] += dp[i][j] * j;
      dp[i][j+1] += dp[i][j] * i;
      dp[i+1][j+1] -= dp[i][j] * i * j;
    }
  }
  cout << dp[c][d] << endl;

  return 0;
}

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

const int N=2e5+100;
const int mod=1e9+7;
typedef long long ll;

int p[101],prime[101];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int num=0;
    for(int i=2;i<=100;i++) {
        int f=0;
        for(int j=2;j*j<=i;j++){
            if(i%j==0) {
                f=1;break;
            }
        }
        if(!f) prime[++num]=i;
    }


    int n;cin>>n;

    for(int i=2;i<=n;i++) {
            int k=i;
       for(int j=1;prime[j]<=k && j<=num;j++) {
          while(k%prime[j]==0 ){
             p[j]++;
             k/=prime[j];
          }

       }
    }


    int num2=0,num4=0,num14=0,num24=0,num74=0;

    for(int i=1;i<=25;i++) {
        if(p[i]>=2) num2++;
        if(p[i]>=4) num4++;
        if(p[i]>=14) num14++;
        if(p[i]>=24) num24++;
        if(p[i]>=74) num74++;
    }

    ll ans=0;

    ans=num74+(num4-1)*num4/2*(num2-2)+num14*(num4-1)+num24*(num2-1);


    cout<<ans<<endl;

     return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(void) {
	int p,N,M;
	string S;
	cin >> N >> M;
	vector< pair<int,int> > data(N,{0,0});
	for (int i = 0; i < M; ++i) {
		cin >> p;
		cin >> S;
		if (data[p-1].first != 1) {
			if (S == "AC") {
				data[p-1].first = 1;
			}
			else {
				++data[p-1].second;
			}
		}
	}
	int noa,now;
	noa = now = 0;
	for (int i = 0; i < N; ++i) {
		noa += data[i].first;
		now += data[i].first*data[i].second;
	}
	cout << noa << " " << now << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dl double long
#define rep(i, m, n) for(ll i = (ll)(m); i < (ll)(n); ++i)
#define rrep(i, m, n) for(ll i = (ll)(m); i < (ll)(n); --i)
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;

struct Point{
    double x, y;
};

void print(Point p){
    printf("%8f %8f\n", p.x, p.y);
    return;
}

void koch(int d, Point p1, Point p2){
    if(d == 0) return;
    Point s, t, u;
    s.x = (2 * p1.x + p2.x) / 3;
    s.y = (2 * p1.y + p2.y) / 3;
    t.x = (p1.x + 2 * p2.x) / 3;
    t.y = (p1.y + 2 * p2.y) / 3;
    u.x = (t.x - s.x) * cos(pi/3) - (t.y - s.y) * sin(pi/3) + s.x;
    u.y = (t.y - s.y) * cos(pi/3) + (t.x - s.x) * sin(pi/3) + s.y;

    koch(d-1, p1, s);
    print(s);
    koch(d-1, s, u);
    print(u);
    koch(d-1, u, t);
    print(t);
    koch(d-1, t, p2);
    return;
}

int main(void){
    int n;
    cin >> n;
    Point start, end;
    start.x = start.y = end.y = 0;
    end.x = 100;
    print(start);
    koch(n, start, end);
    print(end);

    return 0;
}


Measured memory_bytes: 3224
def main():
    N = int(input())
    csf = []
    for _ in range(N - 1):
        C, S, F = map(int, input().split())
        csf.append((C, S, F))
    
    ans = []
    for i in range(N - 1):
        c, s, _  = csf[i]
        t = c + s
        for ii in range(i + 1, N - 1):
            nc, ns, nf = csf[ii]
            if t > ns:
                if (t - ns) % nf == 0:
                    ns += ((t - ns) // nf) * nf
                else:
                    ns += ((t - ns) // nf + 1) * nf
            t += nc + ns - t
        ans.append(t)
    ans.append(0)
    
    for t in ans:
        print(t)
    

main()


Measured memory_bytes: 3188