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

map<int, int> st;

void solve() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		int u; scanf("%d", &u);
		st[u]++;
	}
	vector<int> ls;
	for (auto it : st) {
		ls.push_back(it.second);
	}
	sort(ls.begin(),ls.end());
	reverse(ls.begin(), ls.end());
	long long res = 0;
	for (int i = k; i < ls.size(); ++i) {
		res += ls[i];
	}
	cout << res;
}

int main() {
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin);
#endif

	solve();

#ifdef _LOCAL_
	cout << '\n' << 1.0 * clock() / CLOCKS_PER_SEC << '\n';
#endif
	return 0;
}

Measured memory_bytes: 10748
#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;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    int val = min(a - b, c);
    b += val;
    c -= val;
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
let n = Scanf.scanf " %d" @@ (+) 0
let ss = Array.init n @@ fun _ -> Scanf.scanf " %c" @@ fun c -> c
let _ =
  for i = 0 to n - 1 do if ss.(i) = 'Y' then (print_endline "Four"; exit 0) done;
  print_endline "Three"

Measured memory_bytes: 512
def main():
    N = int(input())
    X = input()
    t = X.count("1")
    x1, x2 = int(X, 2) % (t-1) if t != 1 else 0, int(X, 2) % (t+1)
    for i in range(N):
        ans = 0
        if X[i] == "0":
            # 反転してt += 1
            x = x2 + pow(2, N-i-1, t+1)
            x %= t+1
            ans += 1
            while x > 0:
                b = "{:0b}".format(x).count("1")
                x %= b
                ans += 1
        elif X[i] == "1" and t != 1:
            # 反転してt -= 1
            x = x1 - pow(2, N-i-1, t-1)
            x %= t-1
            ans += 1
            while x > 0:
                b = "{:0b}".format(x).count("1")
                x %= b
                ans += 1
        else:
            # X[i] == "1" and t == 1
            ans = 0
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 83440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,q,a[2005],ans=(1ll<<30);
bool chk[2005];
ll solve(ll val){
    for(ll i=1;i<=n;i++){
        if(a[i]<val)chk[i]=1;
        else chk[i]=0;
    }
    vector<ll> s,t;
    for(ll i=1;i<=n+1;i++){
        if(chk[i]||i==n+1){
            sort(t.begin(),t.end());
            if(t.size()>=k)for(ll j=0;j<t.size()-(k-1);j++)s.push_back(t[j]);
            t.clear();
        }
        else t.push_back(a[i]);
    }
    sort(s.begin(),s.end());
    if(s.size()<q)return (1ll<<30);
    return s[q-1]-s[0];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k>>q;
    for(ll i=1;i<=n;i++)cin>>a[i];
    for(ll i=1;i<=n;i++)ans=min(ans,solve(a[i]));
    cout<<ans;
}

Measured memory_bytes: 384
from heapq import heappush, heappop

def dijkstra(graph, start):
    
    INF = float("inf")

    num = len(graph)
    dist = [INF] * num
    prev = [INF] * num

    dist[start] = 0
    q = []
    heappush(q, (0, start))
    
    while len(q) != 0:
        prov_cost, src = heappop(q)

        if dist[src] < prov_cost:
            continue
        
        for edge in graph[src]:
            cost = edge[1]
            dest = edge[0]

            if dist[dest] > dist[src] + cost:
                 dist[dest] = dist[src] + cost
                 heappush(q, (dist[dest], dest))
                 prev[dest] = src
        
    return prev

def main():
    n,m = map(int, input().split())
    G = {}
    for i in range(n):
        G.update({i: []})
    for i in range(m):
        a, b = map(int, input().split())
        G[a - 1].append([b - 1, 1])
        G[b - 1].append([a - 1, 1])

    path = dijkstra(G, 0)
    
    print("Yes")
    for i in range(1, n):
        print(path[i] + 1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 78252
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		int X = scan.nextInt();
		int Y = scan.nextInt();
		int sum = 0;
		
		if(N - K > 0) {
			sum += (K * X);
			sum += ((N - K) * Y);
		} else {
			sum += (N * X);
		}
		
		System.out.println(sum);
		
		scan.close();
	}

}


Measured memory_bytes: 22996
import heapq
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort()
s=p[:x]+q[:y]
heapq.heapify(s)
for i in range(c)[::-1]:
    h=heapq.heappop(s)
    heapq.heappush(s,max(h,r[i]))
print(sum(s))

Measured memory_bytes: 110376
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = [readline().strip() for _ in range(N)]

    c = Counter(S)
    max_freq = max(c.values())
    ans = [s for s, v in c.items() if v == max_freq]
    ans.sort()

    print(*ans, sep='\n')

    return


if __name__ == '__main__':
    main()


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

int main(){
    long int H,W;

    while(H!=0&&W!=0){
        cin>>H>>W;
        for(int i=0; i<H; i++){
            if(i%2==1){
                for(int j=0;j<W; j++){
                    cout<<"#."[j%2==0];
                }
            }
            if(i%2==0){
                for(int j=0; j<W; j++){
                    cout<<".#"[j%2==0];
                }
            }
            cout<<endl;
        }
        if(H!=0&&W!=0){
            cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3096
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0

    if all(s.count(c) > 0 for c in '753'):
           ret = 1
    else:
           ret = 0
    
    for c in '753':
        ret += dfs(s + c)
        
    return ret

print(dfs('0'))

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main()
{
    long long a,b,x,z,c;
    cin>>a>>b>>x;
    z=b/x;
    if(a==0)
        cout<<z+1;
    else
    {
        c=(a-1)/x;
        cout<<z-c;
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	string s;
	cin >> s;
	s.insert( 4, " ");
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
import sys


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    p = list(map(int, input().split()))
    ans = 0
    for i in range(1, n - 1):
        if sorted(p[i - 1 : i + 2])[1] == p[i]:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9064
#include<bits/stdc++.h>
using namespace std;
string s;
int a,b,c,sum=0;
int main(){
    scanf("%d %d",&a,&b);
    for(int i=1;i<=a*b;i++){
        cin>>s;sum++;
        if(s=="snuke")break;
    }
    c=sum%b==0?b:sum%b;
    printf("%c%.0lf",64+c,ceil((sum+0.00)/b));
    return 0;
}

Measured memory_bytes: 256
r = [1,1,2]
3.upto(30) do |i|
	r[i] = r[i-1] + r[i-2] + r[i-3]
end

while i=gets.to_i do
	break if i == 0
	p ((r[i]+9) / 10 + 364) / 365 
end

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

string a,b="CF";
int al,bl;

int main()
{
    getline(cin,a);
    al=a.length();
    for(int i=0;i<al;i++)
        if(a[i]==b[bl]){
            bl++;
            if(bl==2)
                break;
        }
    if(bl==2) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import combinations

n = int(input())
l = list(map(int, input().split()))

ans = 0
for a, b, c in combinations(l, 3):
    if a == b or b == c or c == a:
        continue
    if a + b > c and b + c > a and a + c > b:
        ans += 1

print(ans)
    

Measured memory_bytes: 9180
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
#include <cstdlib>
using namespace std;
int main(){
    int d,n;
    int ans=1;
    cin >> d >> n;
    if(n == 100){
        for(int i=0;i<d;i++){
            ans *= 100;
        }
        ans *= 101;
        cout << ans << endl;
    }
    else{
        for(int i=0;i<d;i++){
            ans *= 100;
        }
        ans *= n;
        cout << ans << endl;
    }
    return 0;
    
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const double PI = acos(-1);
const double PI2 = PI * 2;

/* typedef */

template <typename T>
struct Pt {
  T x, y;

  Pt() {}
  Pt(T _x, T _y) : x(_x), y(_y) {}
  Pt(const Pt& pt) : x(pt.x), y(pt.y) {}

  bool operator==(const Pt pt) const { return x == pt.x && y == pt.y; }
  Pt<T> operator+(const Pt pt) const { return Pt<T>(x + pt.x, y + pt.y); }
  Pt<T> operator-() const { return Pt<T>(-x, -y); }
  Pt<T> operator-(const Pt pt) const { return Pt<T>(x - pt.x, y - pt.y); }
  Pt<T> operator*(T t) const { return Pt<T>(x * t, y * t); }
  Pt<T> operator/(T t) const { return Pt<T>(x / t, y / t); }
  T dot(Pt v) const { return x * v.x + y * v.y; }
  T cross(Pt v) const { return x * v.y - y * v.x; }
  Pt<T> mid(const Pt pt) { return Pt<T>((x + pt.x) / 2, (y + pt.y) / 2); }
  T d2() { return x * x + y * y; }
  double d() { return sqrt(d2()); }

  Pt<T> rot(double th) {
    double c = cos(th), s = sin(th);
    return Pt<T>(c * x - s * y, s * x + c * y);
  }

  bool operator<(const Pt& pt) const {
    return x < pt.x || (x == pt.x && y < pt.y);
  }

  void print(string format) {
    printf(("(" + format + ", " + format + ")\n").c_str(), x, y);
  }
  void print() { print("%.6lf"); }
};

typedef Pt<double> pt;

struct CL {
  pt p;
  double t0, t1;
  void print() {
    printf("CL:(%.6lf,%.6lf), t0=%.6lf, t1=%.6lf\n", p.x, p.y, t0, t1);
  }
};

/* global variables */

/* subroutines */

bool cross_lines(const pt& a0, const pt& da, const pt& b0, const pt& db,
                 CL& cl) {
  double op01 = da.cross(db);
  if (op01 == 0.0) return false; /* need to handle parallel?? */

  pt v = b0 - a0;
  double op0 = v.cross(da);
  double op1 = v.cross(db);

  cl.t0 = op1 / op01;
  cl.t1 = op0 / op01;
  cl.p = db * cl.t1 + b0;

  return (cl.t0 >= 0.0 && cl.t1 >= 0.0 && cl.t1 <= 1.0);
}

/* main */

int main() {
  double r = (double)1.0 / sqrt(3);
  double d30 = PI / 6;

  pt a0(0, 0);
  pt b0(r, 0), db(-cos(d30), sin(d30));
  
  for (;;) {
    int n;
    cin >> n;
    if (n == 0) break;

    if (n % 3 == 0) n /= 3;
    
    int n3 = n * 3;
    double th = PI / n3;
    
    pt da(cos(th), sin(th));
    CL cl;

    cross_lines(a0, da, b0, db, cl);
    //cl.print();
    double ar = b0.cross(cl.p) * n3;

    printf("%.6lf\n", ar);
  }

  return 0;
}

Measured memory_bytes: 1188
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
#include <array>
#include <chrono>
#include <random>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { std::cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { std::cin >> first; Scan(rest...); }
#define OUT(d) std::cout<<d;
#define FOUT(n, d) std::cout<<std::fixed<<std::setprecision(n)<<d;
#define SOUT(n, c, d) std::cout<<std::setw(n)<<std::setfill(c)<<d;
#define SP std::cout<<" ";
#define TAB std::cout<<"\t";
#define BR std::cout<<"\n";
#define ENDL std::cout<<std::endl;
#define FLUSH std::cout<<std::flush;
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define MAT(type, c, m, n) std::vector<std::vector<type>> c(m, std::vector<type>(n));for(auto& r:c)for(auto& i:r)std::cin>>i;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
#define PAIR std::pair<int, int>
#define IN(a, x, b) (a<=x && x<=b)
#define IN2(a0, y, a1, b0, x, b1) (a0<=y && y<a1 && b0<=x && x<b1)
#define SHOW(d) {std::cout << #d << "\t:" << d << "\n";}
#define SHOWVECTOR(v) {std::cout << #v << "\t:";for(const auto& i : v){std::cout << i << " ";}std::cout << "\n";}
#define SHOWVECTOR2(v) {std::cout << #v << "\t:\n";for(const auto& i : v){for(const auto& j : i){std::cout << j << " ";}std::cout << "\n";}}
#define SHOWPAIRVECTOR2(v) {std::cout << #v << "\t:\n";for(const auto& i : v){for(const auto& j : i){std::cout<<'('<<j.first<<", "<<j.second<<") ";}std::cout << "\n";}}
#define SHOWPAIRVECTOR(v) {for(const auto& i:v){std::cout<<'('<<i.first<<", "<<i.second<<") ";}std::cout<<"\n";}
#define CHECKTIME(state) {auto start=std::chrono::system_clock::now();state();auto end=std::chrono::system_clock::now();auto res=std::chrono::duration_cast<std::chrono::nanoseconds>(end-start).count();std::cerr<<"[Time:"<<res<<"ns  ("<<res/(1.0e9)<<"s)]\n";}

//#define int ll
using ll = long long;
constexpr int INFINT = 1 << 30;
constexpr ll INFLL = 1LL << 60;
constexpr double EPS = 0.0000001;
constexpr int MOD = 1000000007;

signed main() {
	INIT;
	VAR(int, n, l);
	VEC(int, a, n);
	REP(i, n - 1) {
		if (a[i] + a[i + 1] >= l) {
			OUT("Possible")BR;
			int t = 0;
			while (t < i) {
				OUT(t+1)BR;
				++t;
			}
			t = n - 2;
			while (t > i) {
				OUT(t + 1)BR;
				--t;
			}
			OUT(i + 1)BR;
			return 0;
		}
	}
	OUT("Impossible")BR;
	return 0;
}

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

int dpd(string t){

  int n = t.size();
  int ans = 0;
  rep(i,n){
    if(t.at(i) == 'D' ) ans++;
  }
  rep(i,n-1){
    if(t.substr(i,2) == "PD") ans++;
  }
  return ans;
  
  
}




int main(){

string t;
cin >> t;


int n = t.size();

rep(i,n){
  if(t.at(i) == '?') t.at(i) = 'D';
}

cout << t << endl;

}

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

using namespace std;

vector<int> color;

void dfs(vector<vector<pair<int,int>>> &g,int v,int cur = 0){
    for(int i = 0;i < g[v].size();i++){
        if(color[g[v][i].first] != -1)continue;
        if(g[v][i].second % 2 == 0){
            color[g[v][i].first] = cur;
            dfs(g,g[v][i].first,cur);
        }else{
            color[g[v][i].first] = 1-cur;
            dfs(g,g[v][i].first,1-cur);
        }
    }
}

int main(){
    int n;
    cin >> n;
    vector<vector<pair<int,int>>> graph(n);
    for(int i = 0;i < n-1;i++){
        int k;pair<int,int> p;
        cin >> k >> p.first >> p.second;
        k-=1;p.first -= 1;
        graph[k].push_back(p);
        swap(k,p.first);
        graph[k].push_back(p);
    }
    color.assign(n,-1);
    for(int v = 0;v < n;v++){
        if(color[v] != -1)continue;
        if(v == 0){
            dfs(graph,v);
            continue;
        }
        dfs(graph,v,color[v]);
    }
    for(auto a : color)cout << a << endl;
    return 0;
}

Measured memory_bytes: 8704
import math as m


N, K = map(int, input().split())
P = 0

for i in range(1, N+1):
    if i >= K:
        P += (N-i+1) / N
        break
    else:
        if m.log2(K/i).is_integer():
            P += 1 / (N*2**(m.log10(K/i)/m.log10(2)))
        else:
            P += 1 / (N*2**int(m.log10(K/i)/m.log10(2) + 1))

print(P)

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    int ans = n * n * n;
    cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d; cin>>a>>b>>c>>d;
    if (a+b>c+d){
        cout<<"Left\n";
    }else if(a+b<c+d){
        cout<<"Right\n";
    }else{
        cout<<"Balanced\n";
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
ans=0
for i in range(n):
  a=i+1
  hoge=0
  for j in range(n):
    b=j+1
    if(a%b==0):
      hoge+=1
  if(hoge==8 and a%2==1):
    ans+=1
print(ans)
    

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
using namespace std;

int main()
{
char s;
  cin>>s;
    if(s>='a'&&s<='z')
      cout<<char(s+1);
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

int main(){
  
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(k < a) cout << k << endl;
  if(a <= k && k < a+b) cout << a << endl;
  if(a+b <= k) cout << a - (k - a - b) << endl;
}


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

const int MAXN = 200001;
typedef long long ll;

int main(){
    int N,M;
    scanf("%d %d",&N,&M);
    int hi = M/N;
    for (int i=hi;i>0;i--){
        if ((M-i*(N-1))%i==0){
            printf("%d\n",i);
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace  std;
int const N= 2*10e5+5;
long long arr[N];
long long gcd(long long n1, long long  n2)
{
    if (n2 != 0)
        return gcd(n2, n1 % n2);
    else
        return n1;
}
int main() {
  long long  x,y;
  cin>>x>>y;
    cout<<(x*y)/gcd(x,y);
}


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

using namespace std;

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

inline int add(int a, int b) {
  a += b;
  if (a >= md) a -= md;
  return a;
}

inline int sub(int a, int b) {
  a -= b;
  if (a < 0) a += md;
  return a;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

void bye() {
  cout << "0\n";
  exit(0);
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1), b(m + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  for (int i = 1; i < n; i++) {
    if (a[i] == a[i + 1]) {
      bye();
    }
  }
  for (int i = 1; i < m; i++) {
    if (b[i] == b[i + 1]) {
      bye();
    }
  }

  int res = 1, choose = 0;
  for (int k = n * m, i = n + 1, j = m + 1; k > 0; k--) {
    if (a[i - 1] == k && b[j - 1] == k) {
      i--; j--;
      choose += (n - i) + (m - j);
    } else if (a[i - 1] == k) {
      i--;
      res = mul(res, m - j + 1);
      choose += (m - j);
    } else if (b[j - 1] == k) {
      j--;
      res = mul(res, n - i + 1);
      choose += (n - i);
    } else {
      if (choose == 0) bye();
      res = mul(res, choose);
      choose--;
    }
  }
  cout << res << '\n';
  return 0;
}

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

int main() {
	int n;cin>>n;
	string s;cin>>s;
	int ans=1;
	for(int i=0;i<n-1;i++){
		if(s[i]!=s[i+1])ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

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

    int x = 0;
    while (1<<x <= L) {
        x++;
    }
    x--;

    int cnt = 0;
    vector<string> path;
    for (int i = 0; i < x; i++) {
        path.push_back(to_string(i + 1) + " " + to_string(i + 2) + " 0");
        path.push_back(to_string(i + 1) + " " + to_string(i + 2) + " " + to_string(1<<i));
        cnt++;
    }

    int z = (L - (1<<x));
    int s = 1<<x;
    for (int i = x - 1; i >= 0; i--) {
        if (z & (1<<i)) {
            path.push_back(to_string(i + 1) + " " + to_string(x + 1) + " " + to_string(s));

            s += (1<<i);
        }
    }

    cout << (x + 1) << " " << path.size() << endl;
    rep(i, path.size()) {
        cout << path[i] << endl;
    }
}

Measured memory_bytes: 3708
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let n: usize = match buf.trim().to_string().parse() {
		Ok(m) => m,
		_ => panic!(""),
	};
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = String::from(buf.trim());
	if n%2 == 0 {
		let s1 = &s[..n/2];
		let s2 = &s[n/2..];
		if s1 == s2 {
			println!("Yes");
		}else{
			println!("No");
		}
	}else{
		println!("No");
	}
}

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

int main() {
  int N,Z,W,i;
  cin >> N >>Z>>W;
  int a[N];
  for(i=0;i<N;i++) cin >> a[i];
  if(N==1) {
	cout<<abs(a[0]-W)<<endl;
	return 0;
  }
  int k=abs(a[N-1]-W);
  int l=abs(a[N-2]-a[N-1]);
  k=max(k,l);
  cout << k << endl;
  return 0;
}     

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

#define INF 0x3f3f3f3f
#define MAXN 100010
#define endl "\n"
#define abs(a, b) ((a > b) ? a-b : b-a)

typedef long long int ll;

/* End */

int n;
ll a[MAXN];
ll pd[MAXN];

int main() {
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];

	pd[n-1] = 0;
	for (int i = n-2; i >= 0; i--) {
		if (i < n-2) pd[i] = min(pd[i+1] + abs(a[i], a[i+1]),
			                 pd[i+2] + abs(a[i], a[i+2]));
		else pd[i] = abs(a[i], a[i+1]);
	}

	cout << pd[0] << endl;

	return 0;
}


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

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

using namespace std;

int main() {

    string s; cin >> s;
    ll ans = 0;
    ll countB = 0;

    for(ll i = s.length()-1; i >=0; i --){
        if(s[i] == 'B'){
            ans += (s.length() -1 - i -countB);
            countB ++;
        }
    }

    cout << ans;

    return 0;
}











Measured memory_bytes: 3756
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

signed main()
{
	double R, G;
	cin >> R >> G;
	cout << (2 * G - R) << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long 
#define pi 3.1415926536
using namespace std;
const ll N=1e5+5;
void solve()
{ll n,k,l,h,r,z,w,mini,maxi=INT_MAX,prev;
  cin>>n;
  ll ans=0;k=0;
  for(ll i=1;i<=n;i++)
  {
  	if(i%3!=0&&i%5!=0)
  	{
  		ans+=i;
  		k++;
	}
  }
  cout<<ans;
}
  
int main()
{
  fast
  //for(ll i=0;i<=9;i++)
  //cal(1,3234566667,i);
  //sort(v.begin(),v.end());
  //fact();
  //chk();
ll t=1;
//cin>>t;
//SieveOfEratosthenes();
//cout<<"ok";
while(t--)
{ //cout<<"ok";

solve();
 //cout<<ma<<endl;
}
return 0;}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<iterator>
#include<string>
#include<algorithm>
using namespace std;
typedef long long int ll;
int main()
{
  ll n;
  cin>>n;
  string s;
 	cin>>s;
  vector<ll>v,u;
  ll cr=0,cw=0;
  for(ll i=0;i<n;i++)
  {
  	if(s[i]=='R')
       {
         v.push_back(i);
         cr++;
       }
       if(s[i]=='W')
       {
         u.push_back(i);
         cw++;
       }
  }
    reverse(v.begin(),v.end());
    ll cnt=0;
     ll i=0,j=0;
       for(;i<v.size()&&j<u.size();i++,j++)
       {
        	if(v[i]>u[j])
            cnt++;
       }
       cout<<min(cr,min(cw,cnt));
}

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

using namespace std;

int main(void) {
  int X, A, B; cin >> X >> A >> B;

  if (A-B >= 0) {
    cout << "delicious" << endl;
  } else if (B-A <= X) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }

  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int num_th = N / 1000;
  int num_h = (N % 1000) / 100;
  int num_t = (N % 100) / 10;
  int num_o = N % 10;
  if (num_h == num_t && (num_t == num_th || num_t == num_o)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main(void)
{
	char c[10];

	scanf("%s", c);

	if (strcmp(c, "a") == 0 || strcmp(c, "i") == 0 || strcmp(c, "u") == 0 || strcmp(c, "e") == 0 || strcmp(c, "o") == 0)
	{
		puts("vowel");
	}
	else
	{
		puts("consonant");
	}

	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;
using ll = long long int;

ll count_smaller_than(const vector<ll>& vec, ll n) {
  ll l = 0;
  ll r = vec.size() - 1;

  if (vec[r] < n) {
    return vec.size();
  } else if (vec[l] > n) {
    return 0;
  }

  // binary_search
  while (l != r) {
    ll mid = (l + r) / 2;
    if (n > vec[mid]) {
      l = mid + 1;
    } else {
      r = mid;
    }
  }
  return r;
}

int main() {
  int N;
  cin >> N;
  vector<ll> L(N);

  for (size_t i = 0; i < N; i++) {
    cin >> L[i];
  }
  sort(L.begin(), L.end());

  ll ans = 0;
  for (size_t i = 0; i < (N - 2); i++) {
    for (size_t j = i + 1; j < (N - 1); j++) {
      vector<ll> vec(L.begin() + j + 1, L.end());
      ans += count_smaller_than(vec, L[i] + L[j]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>

using namespace std;

int main(void) {

	int r;

	cin >> r;

	if (r < 1200)cout << "ABC\n";
	else if (r < 2800)cout << "ARC\n";
	else cout << "AGC\n";

	return 0;
}

Measured memory_bytes: 256
from itertools import permutations
# use faster method than input()
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, C = map(int, input().split())

D = []
for _ in range(C):
    D.append(list(map(int, input().split())))


# それぞれのグループで、color_iが何個あるかをカウント
mod_0 = [0]*C
mod_1 = [0]*C
mod_2 = [0]*C

for i in range(N):
    l = list(map(int, input().split()))
    for j in range(N):
        m = i+j
        color = l[j]-1
        if m % 3 == 0:
            mod_0[color] += 1
        elif m % 3 == 1:
            mod_1[color] += 1
        else:
            mod_2[color] += 1


# もしかしたら、貪欲かも
# 書き換え方を全通ためして、min
def brute_force():
    ans = float('inf')
    per = permutations(range(C), 3)

    for c1, c2, c3 in per:
        cost = 0
        for i in range(C):
            cost += D[i][c1]*mod_0[i]
        for i in range(C):
            cost += D[i][c2]*mod_1[i]
        for i in range(C):
            cost += D[i][c3]*mod_2[i]
        ans = min(ans, cost)

    return ans


print(brute_force())


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(void){
    long long n,k;
    long long MOD=1000000007;
    long long x=0,y=0,z=0;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(a[i]>a[j]) x++;
        }
    }
    for(int i=n-1;i>=1;i--){
        for(int j=i-1;j>=0;j--){
            if(a[i]>a[j]) y++;
        }
    }
    if(k==1) cout<<x;
    else cout<<(((k*(k+1))/2%MOD)*x+((k*(k-1))/2%MOD)*y)%MOD;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <stdio.h>
#include <stdlib.h>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    string s;
    ll k;
    cin >> s >> k;

    vector<int> vec;

    for(int i=0;i<s.size();i++){
        vec.pb(s[i]-'0');
    }

    int j=0;

    while(true){
        if(j>=vec.size()){
            cout << 1 << endl;
            return 0;
        }
        if(vec[j] != 1){
            break;
        }
        j++;
    }

    if(k==1){
        cout << vec[0] << endl;
    }
    else if((j+1)>k){
        cout << 1 << endl;
    }
    else{
        cout << vec[j] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline LL ri() {LL x; scanf("%lld", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/


//const int maxn = 200010;
int c[1 << 26];
//vector<bool> t(1 << 26);

int n;
int main() {
  string s;
  ios::sync_with_stdio(false);
  cin >> s; 
  n = s.length();
  rep(i, 1<<26) c[i] = n;
  c[0] = 0;
  int mask = 0;
  rep(i, n - 1) {
    mask ^= 1 << (s[i] - 'a'); 
    rep(j, 26) {
      int tmask = mask ^ (1 << j);
      if (c[tmask] < n) {
        smin(c[mask], c[tmask] + 1);
      }
    }
  }
  mask ^= 1 << (s[n - 1] - 'a');


  int res = n;
  res = c[mask] + 1;
  rep(j, 26) {
    int tmask = mask ^ (1 << j);
    smin(res, c[tmask] + 1);
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 262804
#include <stdio.h>

void search(char *data,int pos,int a,int b,int ta,int tb) {
	if(a==ta && b==tb) {
		data[pos]='\0';
		puts(data);
	} else if ((a==5 && b<4) || (a<4 && b==5) || a+b==10) {
		/* nothing */
	} else {
		data[pos]='A';
		search(data,pos+1,a+1,b,ta,tb);
		data[pos]='B';
		search(data,pos+1,a,b+1,ta,tb);
	}
}

int main(void) {
	char keiro[64];
	int j,y;
	if(scanf("%d%d",&j,&y)!=2)return 1;
	search(keiro,0,0,0,j,y);
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    ll x, y, ans;
    cin >> x >> y;
    if(0<x && x<y) ans=y-x;
    else if(0<y && y<x) ans=x-y+2;
    else if(x<0 && 0<y){
        if(-x<=y) ans=y+x+1;
        else ans=-y-x+1;
    }else if(y<0 && 0<x){
        if(y<=-x) ans=-y-x+1;
        else ans=y+x+1;
    }else if(x<y && y<0) ans=y-x;
    else if(y<x && x<0) ans=x-y+2;
    else if(x==0){
        if(y>0) ans=y;
        else ans=-y+1;
    }else if(y==0){
        if(x>0) ans=x+1;
        else ans=-x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 1000000009
using P = pair<int,int>;


int main(){
  #define int long long
  int n,x,y;
  cin >> n >> x >> y;
  n;
  x--;
  y--;
  vint ans(n);
  for(int i = 0;i < n;i++){
    for(int j = i + 1;j < n;j++){
      int ANS = min(j-i,abs(x-i) + abs(y-j) + 1);
      ans[ANS]++;
      //cout << i << " " << j << " " << ANS << endl;
    }
  }
  rep1(i,n){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

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


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;

int n; int a, b, c;
int l[10];
int dfs(int now, int sa, int sb, int sc) {
	if (now == n) {
		if (min({ sa,sb,sc }) > 0)return abs(a - sa) + abs(b - sb) + abs(c - sc) - 30;
		else return INF;
	}
	return min({ dfs(now+1,sa,sb,sc),dfs(now + 1, sa + l[now], sb, sc) + 10, dfs(now + 1, sa, sb + l[now], sc) + 10, dfs(now + 1, sa, sb, sc + l[now]) + 10 });
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> a >> b >> c;
	rep(i, n)cin >> l[i];
	cout << dfs(0, 0, 0, 0) << endl;
	return 0;
}

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

int main()
{
    int x[2];
    cin>>x[0]>>x[1];
    int ans=0;
    for (int i = 0; i < 2; i++)
    {
        if(x[i]==1){
            ans+= 300000;
        }else if(x[i]==2){
            ans+= 200000;
        }else if(x[i]==3){
            ans+= 100000;
        }
    }
    if(x[0]==1 && x[1]==1){
        ans+=400000;
    }

    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<bitset>

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

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;

int main() {
	string s;
	int i, j, k, n, l, m;

	cin >> s;

	k = s.length();
	m = 0;
	rep(i, k) {
		for (j = k - 1; j >= i; j--) {
			for(l=i;l<=j;l++){
				if (s[l] != 'A' && s[l] != 'T' && s[l] != 'C' && s[l] != 'G')
					break;
			}
			if (l == j + 1)m = max(m, j - i + 1);
		}
	}

	cout << m;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<set>
#include<map>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int n, a[345678], ans;
signed main() {
	cin >> n; for1(i, 3*n)cin >> a[i]; sort(a + 1, a + 3 * n + 1, greater<int>());
	for1(i, n)ans += a[i * 2];
	cout << ans << endl;
}

Measured memory_bytes: 2560
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	m := nextInt()
	k, s := nextIntMatFlex(m)
	p := make([]int, m)
	for i := 0; i < m; i++ {
		p[i] = nextInt()
	}

	cnt := 0

	for bit := 0; bit < (1 << n); bit++ {

		var setlist []int
		for j := 0; j < n; j++ {
			if bit&(1<<j) != 0 { // 今回ヒットした場合
				setlist = append(setlist, j)
			}
		}

		// allok
		allok := true
		for i := 0; i < m; i++ { // 全電球
			// onになっているスイッチをカウント
			ons := 0
			for j := 0; j < k[i]; j++ { // 該当スイッチ
				f, _ := hasX(s[i][j]-1, setlist)
				if f == true {
					ons++
				}
			}
			if ons%2 != p[i] {
				allok = false
			}
		}

		if allok == true {
			cnt++
		}

	}

	fmt.Println(cnt)

}
func hasX(x int, plist []int) (bool, int) {
	for i, p := range plist {
		if x == p {
			return true, i
		}
	}
	return false, -1
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

// nextIntMatFlex   行ごとに列数が違う2次元配列
// ヘッダ数列と可変長配列を返す。
// 3 1 1 1
// 4 1 1 1 1
// header=[3,4]  mat=[[1 1 1][1 1 1 1]]
func nextIntMatFlex(h int) ([]int, [][]int) {
	header := make([]int, h)
	mat := make([][]int, h)
	for i := 0; i < h; i++ {
		header[i] = nextInt()
		mat[i] = make([]int, header[i])
		for j := 0; j < header[i]; j++ {
			mat[i][j] = nextInt()
		}
	}
	return header, mat
}


Measured memory_bytes: 1888
#include<bits/stdc++.h>
#define Forend return puts("-1"),0
using namespace std;
int n,m,a[11],vis[11];
int qpow(int a,int b){
    int re=1;
    while(b){
        if(b&1) re=re*a;
        b>>=1;a=a*a;
    }return re;
}
int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
    return x*f;
}
signed main(){
    n=read(),m=read();bool flag=0;
    int val=qpow(10,n-1)-1,v=0;
    for(int i=1;i<=m;i++){
        int x=read(),y=read();
        if(vis[x]&&a[x]!=y) flag=1;
        a[x]=y;vis[x]=1;
    }
    if(flag) Forend;
    if(n==1&&!a[1]) return puts("0"),0;
    if(vis[1]&&!a[1]) Forend;
    if(!a[1]) a[1]=1;
    for(int i=1;i<=n;i++) v=v*10+a[i];
    if(v<=val) puts("-1");
    else printf("%d\n",v);
    return 0;
}


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

int main(){
  int E,Y;
  cin>>E>>Y;
  switch(E){
    case 0:
    if(1868<=Y && Y<=1911){
      cout<<"M"<<Y-1867<<endl;
    }
    else if(1912<=Y && Y<=1925){
      cout<<"T"<<Y-1911<<endl;
    }
    else if(1926<=Y && Y<=1988){
      cout<<"S"<<Y-1925<<endl;
    }
    else if(1989<=Y && Y<=2016){
      cout<<"H"<<Y-1988<<endl;
    }
    break;
    case 1:
      cout<<Y+1867<<endl;
      break;
    case 2:
      cout<<Y+1911<<endl;
      break;
    case 3:
      cout<<Y+1925<<endl;
      break;
    case 4:
      cout<<Y+1988<<endl;
      break;
    }
}



Measured memory_bytes: 3084
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias Train = Tuple!(long, "c", long, "s", long, "f");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto t = new Train[](n - 1);
    foreach (i; iota(n - 1))
    {
        long c, s, f;
        scan(c, s, f);
        t[i] = Train(c, s, f);
    }
    foreach (i; iota(n))
    {
        long elapsed;
        foreach (e; t[i .. $])
        {
            if (elapsed % e.f)
                elapsed += e.f - (elapsed % e.f);

            if (elapsed < e.s)
                elapsed = e.s;

            elapsed += e.c;
        }
        elapsed.writeln();
    }
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int t,x;cin>>t>>x;
  double ans=(double)t/(double)x;
  cout << ans << endl;
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define input() ios::sync_with_stdio(false);cin.tie(0);
void solve(){
	
}
int power(int x,int y){
	int res=1;
	while(y){
		if(y&1)
		res=res*x;
		x=x*x;
		y=y/2;
	}
	return res;
}
int main(){
    input()
    int n,m,sum=0;
    cin>>n>>m;
    vector<int>a(n);
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	sum+=a[i];
    }
    int l=0;
    bool ok=false;
    for(int i=0;i<n;i++){
    	if((a[i]*4*m)>=sum){
    		l++;
    	}
    	if(l==m){
    		ok=true;
    		break;
    	}
    }
    if(ok)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}

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

signed main() {
  int N;
  cin >> N;
  string A, B, C;
  cin >> A >> B >> C;
  
  vector<int> diff(N); //i文字目が何個違うか
  int ans = 0;
  for( int i = 0; i < N; i++ ){
    if( A.at(i) == B.at(i) && B.at(i) == C.at(i) ){
      diff.at(i) = 0;
      continue;
    }
    if( A.at(i) != B.at(i) ) diff.at(i)++;
    if( B.at(i) != C.at(i) ) diff.at(i)++;
    if( C.at(i) != A.at(i) ) diff.at(i)++;
  }
  
  for( int i = 0; i < N; i++ ){
    if( diff.at(i) > 0 ) ans += diff.at(i)-1;
  }
  cout << ans << endl;
    
    
  
}


Measured memory_bytes: 256
def main():
    n = int(input())
    A = list(map(int, input().split()))
    A += A
    ans = [0] * n
    s1 = sum(A[:n - 1:2])
    s2 = sum(A[1:n:2])
    for i in range(n):
        if i % 2 == 0:
            s1 += A[i + n - 1]
            ans[i] = s1 - s2
            s1 -= A[i]
        else:
            s2 += A[i + n - 1]
            ans[i] = s2 - s1
            s2 -= A[i]
    print(' '.join(list(map(str, ans))))

if __name__ == '__main__':
    main()


Measured memory_bytes: 19816
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
    double a ;
    cin >> a ;
    if(int(a)%2==1){
        cout << fixed << setprecision(10) << ceil(a/2)/a << endl;
    } else{
        cout << fixed << setprecision(10) << (a/2)/a << endl;
    }




    // int a,b;
    // cin >> a >> b;
    // if(a-b*2<=0){
    //     cout << 0 << endl;
    // } else { 
    //     cout << a-b*2 << endl;
    // }
}



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

using namespace std;

int main(void) {
    string s;
    cin >> s;
    for (auto& c : s) {
        if (c == ',') cout << " ";
        else cout << c;
    }
    puts("");

    return 0;
}

Measured memory_bytes: 256