akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
int inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int n;
int q;
Graph G;
vector<int> add;
vector<int> ans;

//inputします
void input() {
    cin >> n;
    cin >> q;
}

//ライブラリ置き場

//グラフ生成
void build_G(Graph& GG33, int nn33, int mm33) {//GG:グラフ nn:頂点数 mm:辺の数
    GG33.resize(nn33+1);
    ff(ii33, 0, mm33) {
        int aa33, bb33;
        cin >> aa33 >> bb33;
        GG33[aa33].push_back(bb33);
        GG33[bb33].push_back(aa33);
    }
}

//深さ優先探索するなら使う
vector<bool> seen34;
vector<int> first_order34;
vector<int> last_order34;

void set_order(int nn35) {
    seen34.assign(nn35+1, 0);
    first_order34.resize(nn35+1);
    last_order34.resize(nn35+1);
}

//深さ優先探索
i64 pre = 0;
void dfs(const Graph& GG34, int vv34, int& first_ptr34, int& last_ptr34) {
    seen34[vv34] = 1;//vを訪れました（現在地：vv)
    //ここで行う操作を下に書く
    first_order34[vv34] = first_ptr34++;
    pre += add[vv34];
    ans[vv34] += pre;
    //vから行ける場所を見つけ次第潜るのでどんどん深くなっていく
    for (auto next_vv34 : GG34[vv34]) {
        if (seen34[next_vv34])continue;
        dfs(GG34, next_vv34, first_ptr34, last_ptr34);
    }

    pre -= add[vv34];
    last_order34[vv34] = last_ptr34++;
}
//main
int main() {
    input();
    build_G(G, n, n - 1);
    set_order(n);
    add.resize(n + 1);
    ans.resize(n + 1);
    ff(i, 0, q) {
        int x, y;
        cin >> x >> y;
        add[x] += y;
    }
    int a = 0, b = 0;
    dfs(G, 1, a, b);
    ff(i, 1, n+1) {
        cout << ans[i] << (i == n ? "" : " ");
    }
    cout << endl;
	return 0; 
}

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

int main() {
 ll n ;cin >> n;
 vector<ll> h(n);
 rep(i,n)cin >> h[i];
  ll  maxh=h[0]; bool flag=1;
  rep1(i,n){
    if(h[i]<maxh-1)flag=0;
    else if(h[i]>=maxh) maxh=h[i];
  }

  if(flag)cout << "Yes" << endl;
  else cout << "No" << endl;

}


Measured memory_bytes: 1024
def main():
  N,K=map(int,input().split())
  sFlag=True
  s=0
  while(sFlag):
    sk=K**s
    if(N>=sk):
      sans=s
      s=s+1
    else:
      print(sans+1)
      sFlag=False

if __name__ == '__main__':
	main()

Measured memory_bytes: 38256
#include <iostream>
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <queue>

using namespace std;

int main()
{
  queue<char> A,B,C;
  string s;
  int i,j,size;
  char a;

  s.empty(); cin >> s; size = s.length();
  for(i = 0; i < size; i++){
    a=0;
    a=s[i];
    A.push(a);
  }
  s.empty(); cin >> s; size = s.length();
  for(i = 0; i < size; i++){
    a=0;
    a=s[i];
    B.push(a);
  }
  s.empty(); cin >> s; size = s.length();
  for(i = 0; i < size; i++){
    a=0;
    a=s[i];
    C.push(a);
  }

  int flag;
  char tmp=A.front(); A.pop();
  while(1){
    if(tmp=='a'){
      if(A.empty()) {flag=1;break;}
      tmp=0;
      tmp=A.front(); A.pop();
    }
    else if(tmp=='b'){
      if(B.empty()) {flag=2;break;}
      tmp=0;
      tmp=B.front(); B.pop();
    }
    else if(tmp=='c'){
      if(C.empty()) {flag=3;break;}
      tmp=0;
      tmp=C.front(); C.pop();
    }
  }

  switch(flag){
  case 1 : cout<<'A'<<endl; break;
  case 2 : cout<<'B'<<endl; break;
  case 3 : cout<<'C'<<endl; break;
  }

  return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  a, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  b, _ := strconv.Atoi(sc.Text())

  if a == b {
    fmt.Println(a + b)
  } else if a > b {
    fmt.Println(a * 2 - 1)
  } else {
    fmt.Println(b * 2 - 1)
  }
}


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

typedef long long ll;
typedef long double ldb;
int main()
{
	ldb n;
	cin >> n;
	
	ldb sides=(ldb)n/(ldb)3;
	//cout << sides << '\n';

	ldb sol = sides*sides*sides;
	cout << setprecision(9) << sol << '\n';
	return 0;
}


Measured memory_bytes: 256
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

x = A + V * T
y = B + W * T

z = A - V * T
w = B - W * T

if A < B:
  if x >= y:
    print('YES')
  else:
    print('NO')
else:
  if z <= w:
    print('YES')
  else:
    print('NO')


Measured memory_bytes: 9188
program prob1
    implicit none
    integer::n, i
    character(len=4)::s
    read(*,*) s
    do i = 1, 2
        read(s(i:i+2),*) n
        if(mod(n,111) == 0) then
            write(*,'(a)') "Yes"
            stop
        end if
    end do
    write(*,'(a)') "No"
    stop
end program

Measured memory_bytes: 2928
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int a,b,h,m;cin>>a>>b>>h>>m;
    double minute = 360/60.0*m;
    double hour = 360/12.0*h+m*0.50;
    double res = min(360-abs(max(hour,minute)-min(minute,hour)), max(hour,minute)-min(minute,hour));
	double rad = res*(pi/180.0);
	double ans = sqrt(b*b+a*a-2*b*a*cos(rad));
	cout << fixed << setprecision(20) << ans << "\n";
}


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

int main(){
    int h,w,i,j;
    while(true){
        cin>>h>>w;
        if(h==0&&w==0)break;
        else{
            for(i=0;i<h;i++){
                for(j=0;j<w;j++){
                    if(i%2==0){
                        if(j%2==0)cout<<"#";
                        else cout<<".";
                    }
                    else{
                        if(j%2==0)cout<<".";
                        else cout<<"#";
                    }
                }
                cout<<"\n";
            }
            cout<<"\n";
        }
    }
    return 0;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto && (i) : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int n;
  cin >> n;
  string s = "ACL";
  rep(i, 0, n) cout << s;
  cout << '\n';
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
   
int main()
{
    fastread;
    string s;
    ll i,j,k,l,n,m;
    cin>>n>>m>>k;
	ll temp=n/(m+k);
	ll res=temp*m+min(m,n%(m+k));
	cout<<res; 
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        char X = sc.next().charAt(0);
        char Y = sc.next().charAt(0);

        System.out.println(solve(X, Y));

        sc.close();
    }

    static String solve(char X, char Y) {
        if (X < Y) {
            return "<";
        } else if (X > Y) {
            return ">";
        } else {
            return "=";
        }
    }
}

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

using namespace std;

int N;
map<long long int, int> DpSum;

int main() {
	int d, maxLen;
	long long int curSum;
	
	curSum = 0;
	maxLen = 0;
	DpSum[0] = 0;
	cin >> N;
	for (int i = 1; i <= N; ++i) {
		cin >> d;
		curSum += d;
		if (DpSum.count(curSum) == 0) {
			DpSum[curSum] = i;
			continue;
		}
		maxLen = max(maxLen, i - DpSum[curSum]);
	}
	cout << maxLen << endl;
	
	return 0;
}


Measured memory_bytes: 15464
def main():
    import collections 
    import sys

    input()
    a = list(map(int, sys.stdin.readline().split()))

    b = collections.Counter(a)

    c = sum(v * (v - 1) // 2 for v in b.values())
    d = [str(c - (b[v] - 1)) for v in a]
    print('\n'.join(d))


if __name__ == '__main__':
    main()


Measured memory_bytes: 34400
a,b=map(int,input().split())
c=sorted(map(int,input().split()))
x=int(1)
dif=[]
while x<b:
    dif.append(c[x]-c[x-1])
    x=x+1
dif.append(a-max(c)+min(c))
print(a-max(dif))

Measured memory_bytes: 26444
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {
    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder();
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            int n = Integer.parseInt(br.readLine());
            String[] split = br.readLine().split("\\s+");
            Deque<Integer> q = new ArrayDeque<>(n);
            for (String s: split) {
                q.add(Integer.parseInt(s));
            }
            int k = 0;
            int i = 1;
            while (!q.isEmpty() && k < n) {
                if (i == q.removeFirst()) {
                    i++;
                } else {
                    k++;
                }
            }

            if (!q.isEmpty() || k >= n) {
                System.out.println(-1);
            } else {
                System.out.println(k);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 51600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF ll(1e18)
#define MOD (ll)1e9+7
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n,m;cin>>n>>m;
    int arr[n];
    vector<vector<int>>vec(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;a--;b--;
        vec[a].pb(b);
        vec[b].pb(a);
    }
    ll cnt=0;
    for(int i=0;i<n;i++){
        bool state=true;
        for(auto x:vec[i]){
            if(arr[x]>=arr[i]){
                state=false;break;
            }
        }
        if(state)cnt++;
    }
    cout<<cnt<<"\n";
}



Measured memory_bytes: 8744
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

using namespace std;
using ll = long long;

int main(){
    int A,B,M;
    cin>>A>>B>>M;
    vector<int> a(A),b(B);
    vector<int> x(M),y(M),c(M);
    int ans=1e9;

    for(int i=0;i<A;i++) cin>>a[i];
    for(int i=0;i<B;i++) cin>>b[i];
    for(int i=0;i<M;i++){
        cin>>x[i]>>y[i]>>c[i];
        ans = min(ans, a[x[i]-1] + b[y[i]-1] - c[i]);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    
    ans = min(ans, a[0] + b[0]);

    cout<<ans<<endl;
}

Measured memory_bytes: 2176
x, y = map(int, input().split())

g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]
g3 = [2]

if x in g1 and y in g1:
    print('Yes')
elif x in g2 and y in g2:
    print('Yes')
elif x in g3 and y in g3:
    print('Yes')
else:
    print('No')

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

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

    string S, T;
    cin >> S >> T;

    string ans = "";
    for (int i = 0; i < N; i++)
    {
        ans += S[i];
        ans += T[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  at3595
//
//  Created by horse on 2019/3/19.
//  Copyright © 2019 horse. All rights reserved.
//

#include <iostream>
using namespace std;
int main() {
    int h,w;
    cin>>h>>w;
    char a[h+2][w+2];
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(a[i][j]=='#') continue;
            else{
                int count=0;
                if(a[i-1][j-1]=='#') count++;
                if(a[i-1][j]=='#') count++;
                if(a[i-1][j+1]=='#') count++;
                if(a[i][j-1]=='#') count++;
                if(a[i][j+1]=='#') count++;
                if(a[i+1][j-1]=='#') count++;
                if(a[i+1][j]=='#') count++;
                if(a[i+1][j+1]=='#') count++;
                a[i][j]=count+48;
            }
        }
    }
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cout<<a[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 1e5 + 7;
int a[N], mx, cho, n, L;
int main() {
#ifndef ONLINE_JUDGE
#endif
	n = gi(), L = gi();
	rep(i, 1, n) a[i] = gi();
	rep(i, 1, n - 1) if(Max(mx, a[i] + a[i + 1])) cho = i;
	if(mx < L) return puts("Impossible"), 0;
	puts("Possible");
	rep(i, 1, cho - 1) printf("%d\n", i);
	for(int i = n - 1; i > cho; --i) printf("%d\n", i);
	printf("%d\n", cho);
	return 0;
}

Measured memory_bytes: 1152
// Problem : C - Attention
// Contest : AtCoder Regular Contest 098
// URL : https://atcoder.jp/contests/arc098/tasks/arc098_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define temptts template <class T, class... Ts>

const int N = 1e6 + 1, mod = 1e9 + 7, inf = 2e9;

int n, mn = inf, l[N], r[N];
bool a[N];

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		char c;
		cin >> c;
		a[i] = c == 'E';
		l[i] = l[i - 1] + a[i];
	}
	for (int i = n; i >= 1; i--) {
		r[i] = r[i + 1] + !a[i];
	}
	for (int i = 1; i <= n; i++) {
		mn = min(mn, n - (l[i - 1] + r[i + 1]) - 1);
	}
	cout << mn;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
using u64 = uint_fast64_t;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr u64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(int i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(int i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef pair<i64,i64> P;
typedef v(i64) vi;
typedef v(vi) vvi;
typedef v(vvi) vvvi;
typedef v(P) vp;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

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

  vector<vector<pair<int,int>>> A(N, vector<pair<int,int>>(N-1));
  int a;
  rep(i,N) rep(j,N-1){
    cin >> a;
    a--;
    A[i][j] = make_pair(min(i,a),max(i,a));
  }

  map<pair<int,int>,vector<pair<int,int>>> G;
  map<pair<int,int>,int> mp;
  rep(i,N) rep(j,1,N-1){
    mp[A[i][j]]++;
    G[A[i][j-1]].emplace_back(A[i][j]);
  }

  vector<pair<int,int>> S;
  rep(i,N-1) rep(j,i+1,N){
    if(mp[make_pair(i,j)]) continue;
    S.emplace_back(make_pair(i,j));
  }

  int ans = 0;
  while(!S.empty()){
    ans++;
    vector<pair<int,int>> L;
    for(auto &p:S){
      L.emplace_back(p);
    }
    S.clear();
    for(auto &p:L) {
      for(auto &q:G[p]) {
        mp[q]--;
        if(mp[q]==0){
          S.emplace_back(q);
        }
      }
    }
  }

  for(auto &p:mp){
    if(p.second != 0){
      cout << -1 << "\n";
      return;
    }
  }
  cout << ans << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

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

int main() {
    int k,a,b;
    cin >> k >> a >> b;
    bool flag = false;
    for (int i = a; i < b+1; i++) {
        if (i%k == 0) {
            flag = true;
            break;
        }
    }
    if (flag) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, const char *argv[]) {
  int N;
  int count = 0;
  string S;
  string a = "ABC";

  cin >> N;
  cin >> S;

  for (int i = 0; i < N - 2; i++) {
    if (S.compare(i, 3, a) == 0) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


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

int main() {
	int t = 0;
	
	cin >> t;
	set<string>s;

	while (t--) {
		string str;
		cin >> str;

		s.insert(str);
	}
	cout << s.size() << endl;

	return 0;
}

Measured memory_bytes: 19236
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;

int saiki(int n, int k){
    if(n/k > 0){
        return 1 + saiki(n/k, k);
    }else{
        return 1;
    }
     
}

int main(){
    int n,k;
    
    cin >> n >> k;
    cout << saiki(n,k) << endl;
   
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include<iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;
const ll mod=1000000007;
/*pi*/const double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n;cin>>n;
 ll c[n+10],s[n+10],f[n+10];
 rep(i,0,n-1)cin>>c[i]>>s[i]>>f[i];

 ll now,time,ans[n+10]={0};
 rep(i,0,n-1){
  now=i;
  time=s[i];
  while(now<n-1){
   time+=c[now];
   now++;
   if(now>=n-1)break;
   while(time%f[now]!=0||time<s[now]){
    time++;
  //  cout<<i<<" "<<now<<" "<<time<<endl;
   }
  }
  ans[i]=time;
 }
 rep(i,0,n)pr(ans[i]);
return 0;}

Measured memory_bytes: 3644
use proconio::*;
use proconio::marker::*;

#[fastout]
fn run() {
    input! {
        _n: usize,
        s: Bytes,
        q: usize,
        ask: [usize; q],
    }
    for k in ask {
        let mut d = 0u64;
        let mut m = 0;
        let mut dm = 0;
        let mut dmc = 0;
        for (i, &c) in s.iter().enumerate() {
            if i >= k {
                let c = s[i - k];
                if c == b'D' {
                    dm -= m;
                    d -= 1;
                } else if c == b'M' {
                    m -= 1;
                }
            }
            if c == b'D' {
                d += 1;
            } else if c == b'M' {
                dm += d;
                m += 1;
            } else if c == b'C' {
                dmc += dm;
            }
        }
        println!("{}", dmc);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 3996
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
  long long X, Y;
  cin >> X >> Y;

  long long ans = 1;
  long long aa = X;

  while (true) {
    aa *= 2;
    if (aa > Y) break;
    ans++;
  }

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


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

#define MAX 100100
int N,K,x[MAX];

void compute() {

}

int main() {
  cin >> N >> K;
  rep(i,N) cin >> x[i];
  int mini = INT_MAX;
  rep(i,N) {
    int j = i + K - 1;
    if( j >= N ) break;
    mini = min(mini,min(abs(x[i]),abs(x[j]))+abs(x[i]-x[j]));
  }
  cout << mini << endl;
  compute();
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int f(int x) {
  if (!x) return 0;
  return f(x/10)+x%10;
}

int main() {
  int n;
  scanf("%d",&n);
  int ans = INF;
  rrep(i,n-1) {
    mins(ans, f(i)+f(n-i));
  }
  cout<<ans<<endl;
  return 0;
}






















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

int main() {
    long long N, K;
    cin >> N >> K;
    vector <long long> h(N);
    for (long long i=0; i<N; i++) cin >> h.at(i);
    sort(h.begin(), h.end());
    long long ans=1000000000;
    for (long long i=0; i<=N-K; i++) {
        ans = min(h.at(i+K-1)-h.at(i), ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4052
N=int(input())
P=input().split()
Pn=[]
Pn.append(int(P[0]))

count=1
nowmin=Pn[0]

for i in range(1,len(P)):
    if int(P[i])<nowmin:
        count+=1
        nowmin = int(P[i])
    
print(count)


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

int main() {
  vector<char> c = {'3', '5', '7'};
  int n;
  cin >> n;
  set<string> s;
  queue<string> q;
  for (auto e : c) {
    q.push(string(1, e));
  }
  while (!q.empty()) {
    for (auto e : c) {
      string t = q.front();
      t.push_back(e);
      if (stoll(t) <= n && s.count(t) == 0) {
        set<char> ss;
        for (auto e : t) {
          ss.insert(e);
        }
        if (ss.size() == 3) {
          s.insert(t);
        }
        q.push(t);
      }
    }
    q.pop();
  }
  cout << s.size() << endl;
}


Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
int main()
{
	ll n;
	cin >> n;
	ll ans = 0;
	vector<ll> dev(n + 1);
	ll first, last, d, number;
	for (int i = 1; i <= n; ++i) {
		first = i;
		number = n / i;
		last = i * number;
		dev[i] = (first + last)*number / ll(2);
	}
	for (int i = 1; i <= n; ++i) {
		ans += dev[i];
	}
	cout << ans << endl;
	return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    string s;
    cin>>s;
    int a=0;
    REP(i,0,s.size()){
        if(a==0){
            if(s[i]=='C') a++;
        }
        else if(a==1) if(s[i]=='F') a++;
    }
    YesNo(a==2);
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _for(i, a, b) for(int i = (a);i < (b); ++i)
#define _rep(i, a, b) for(int i = (a);i <= (b); ++i)
#define b_e(a) begin(a), end(a)
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, string> pis;

int nextInt() { int x; scanf("%d", &x); return x; }
LL nextLL() { LL x; scanf("%lld", &x); return x; }
//double nextDouble() { double x; scanf("%lf", &x); return x; }
//string nextString() { string s; cin >> s; return s; }
//auto cmp = [](const int& a, const int& b) {return a > b;};
const int INF = 1e9;
const int MAXN = 10000;
const int dx[4] = { 0, 0, 1, -1 };
const int dy[4] = { 1, -1, 0, 0 };
int main() {
	int a = nextInt(), b = nextInt(), c = nextInt();
	int x = nextInt(), y = nextInt();
	int ans = x * a + y * b;
	if (a + b <= c + c) {
		printf("%d", ans);
		exit(0);
	}
	_rep(i, 0, max(x, y))
		ans = min(ans, 2 * i * c + max(0, x - i) * a + max(0, y - i) * b);
	printf("%d", ans);
	exit(0);
}

Measured memory_bytes: 256
def main():
    n = int(input())
    inlis = list(map(int, input().split()))

    ans = 10 ** 10

    for kouho1 in range(-100,101):
        tmp1 = 0
        for i in range(n):
            tmp1 += (inlis[i]- kouho1) ** 2
        if tmp1 < ans:
            ans = tmp1
    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin >> n >> m;
	map<int, int> M;
	int i, j, k;
	for(i=1; i<=n; i++){
		cin >> k;
		for(j=1; j<=k; j++){
			int x;
			cin >> x;
			M[x]++;
		}
	}
	int count = 0;
	for(auto it = M.begin(); it!=M.end(); it++){
		if(it->second == n) count++;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int INF=INT_MAX;
const ld PI=3.1415926535838797323;
const ld E=2.71828183;
const int MOD=1e9+7;
vi bfs(vector<vi>adj,int src){
    //adjacency list, not-weighted, possibly directed ,src is 1-indexed, adj[0].size()=0!!!
    //for n vertices, adj.size()=n+1. (constructed via push_back() ).

    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return dst;
}
vi bfsParents(vector<vi>adj,int src){
    vi parents=vi(adj.size(),INF);
    parents[src]=-1;
    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                parents[nbr]=c;
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return parents;
}
int powMod(int base,int exp,int mod){
    //base^exp %mod
    int ans=1;
    for(int i=0; i<exp; i++)
        ans=((ans%mod)*(base%mod))%mod;
    return ans;
}
vi divisorsOf(int n){
    //vector of divisors of n (inc. 1 , excl.n)
    vi ans;
    for(int i=1; i*i<=n; i++){
        if(n%i==0)
            ans.push_back(i);
        if(i*i!=n && i!=1)
            ans.push_back(n/i);
    }
    return ans;
}

void solve();

int main() {
    //  int t;
    //cin >> t;
    //while(t--)
    solve();
}
void solve(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int sum=0;
    sum+=min(a,k);
    k-=a;
    if(k>0)
        k-=b;
    if(k>0)
        sum-=k;
    cout << sum << "\n";

}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#include<functional>
#include<list>
#include<bitset>
#include<numeric>
#include<utility>
#define INF (int)1e9
#define DINF (double)1e9
#define MOD 1000000007
#define MAX 2100000
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> p;



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	map<int, int> mp, mp1;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			mp[a[i]]++;
		}
		else {
			mp1[a[i]]++;
		}
	}
	vector<p> v, v1;
	for (auto itr : mp) {
		v.push_back(make_pair(itr.second, itr.first));
	}
	v.push_back(make_pair(0, 0));
	for (auto itr : mp1) {
		v1.push_back(make_pair(itr.second, itr.first));
	}
	v1.push_back(make_pair(0, 0));
	sort(v.begin(), v.end(),greater<p>());
	sort(v1.begin(), v1.end(), greater<p>());
	//for (auto itr: v) {
	//	cout << itr.second << " " << itr.first << endl;
	//}
	//cout << "Ss" << endl;
	//for (auto itr : v1) {
	//	cout << itr.second << " " << itr.first << endl;
	//}
	//cout << "Ss" << endl;
	if (v[0].second != v1[0].second) {
		cout << n - v[0].first - v1[0].first;
	}
	else {
		int ans = v[0].first + v1[1].first;
		int ans2 = v[1].first + v1[0].first;
		cout << n - max(ans, ans2);
	}

	return 0;
}


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FIO freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

#define endl '\n'
#define int long long
#define double long double

const int N = 3000;
int n;
double cache[N][N], p[N];
bool visited[N][N];

double dp(int id, int heads) {
    if(id == n) 
        return (heads*2 >= n);
    double &ans = cache[id][heads];
    if(visited[id][heads])
        return ans;
    visited[id][heads] = 1;
    ans = p[id] * dp(id+1, heads+1) + (1 - p[id]) * dp(id+1, heads);
    return ans;
}

int32_t main()
{
    IOS; //FIO;

    memset(cache, -1, sizeof(cache));
    cin >> n;
    for(int i = 0; i < n; i ++) {
        cin >> p[i];
    }
    double ans = dp(0,0);
    cout << fixed << setprecision(12) << ans << endl;  
    return 0;
}

Measured memory_bytes: 150016
#include<cstdio>


using ll=long long;


int main(void)
{
	ll n, p;

	while(scanf("%lld%lld", &n, &p)==2)
	{
		ll ans=1LL;

		for(ll i=2;i*i<=p;i++)
		{
			if(p%i==0)
			{
				for(int j=0;p%i==0;j++)
				{
					p/=i;
					if(j==n-1)
					{
						ans*=i;
						j=-1;
					}
				}
			}
		}
		if(n==1) ans*=p;
		printf("%lld\n", ans);
	}

	return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES 
#include <cmath>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#define rep(i,start,n) for(int i=start;i<n;i++)
#define And &&
#define Or ||
#define Lb cout<<endl
using namespace std;

int main() {
	int n;
	cin >> n;
	rep(i,1,n+1) 	{
		int x = i;
		if (i % 3 == 0) cout << " " << i;
		else {
			while (x > 0) {
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
				x = x / 10;
			}
		}
	}
	Lb;
}

Measured memory_bytes: 1160
S = gets.chomp

str = S.split("")

wa = 0
have_c = 0
for i in 0..(str.length - 1) do
    if i == 0 then
        if str[i] != "A" then
            wa += 1
        end
        next
    end

    if str[i] == "C" then
        if 2 <= i and i <= (str.length - 2 ) then
            have_c += 1
        end
        next
    end

    if "ABCDEFGHIJKLMNOPQRSTUVWXYZ".include?(str[i]) then
        wa += 1
    end
end


if wa == 0 and have_c == 1 then
    puts "AC"
else
    puts "WA"
end


Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
int team[51],wrong[51][11],time[51],count[51];
int main(void){
    int M,T,P,R,i,o,m,t,p,j,temp;
    while(1){
        for(i=0;i<51;i++)
            team[i]=time[i]=count[i]=0;
        memset(wrong,0,sizeof(wrong));
        scanf("%d %d %d %d",&M,&T,&P,&R);
        if(!(M+T+P+R))
            break;
        for(o=T;o>=1;o--)
            team[T-o+1]=o;
        for(i=0;i<R;i++){
            scanf("%d %d %d %d",&m,&t,&p,&j);
            if(j)
                wrong[t][p]++;
            else{
                if(wrong[t][p])
                    time[t]+=wrong[t][p]*20;
                time[t]+=m;
                count[t]++;
            }
        }
        for(i=2;i<=T;i++){
            temp=team[i];
            for(o=i;o>1;o--){
                if(count[temp] > count[team[o-1]])
                    team[o]=team[o-1];
                else if(count[temp] == count[team[o-1]] && time[temp] < time[team[o-1]])
                    team[o]=team[o-1];
                else
                    break;
            }
            team[o]=temp;
        }
        for(i=1;i<=T;i++)
            printf("%d%s",team[i],i==T?"\n":(count[team[i]]==count[team[i+1]] && time[team[i]]==time[team[i+1]]?"=":","));
    }
    return 0;
}

Measured memory_bytes: 600
def wa(x):
    y=int(26*(26**x-1)/25)
    return y

n=int(input())
kake=0
count=0
ans=""
kotae=[]
al=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

while(n>kake):
        count+=1
        kake=wa(count)
#countが文字数
n-=wa(count-1)
n-=1
for x in range(count):
    kotae.append(al[n%26])
    n=n//26
for x in range(count):
    ans+=kotae[count-1-x]
print(ans)

Measured memory_bytes: 9244
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

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

int main(void){
  int n, d;
  cin >> n >> d;
  vector<vector <double> > x(n);

  rep(i, n) {
    x[i] = vector<double>(d);
    rep (j, d) {
      cin >> x[i][j];
    }
  }

  int cnt =  0;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      // cout << "I: " << i << " J: " << j << endl;
      double sum = 0;
      for (int k = 0; k < d; k++) {
        sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      // cout << sqrt(sum) << endl;
      if (ceil(sqrt(sum)) == floor(sqrt(sum))) cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const ll INF = 1000000000;
//const ll MOD = 1000000007;
const ld PI = (acos(-1));
using Graph = vector<vector<int>>;
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;}
typedef pair<int, int> pair;
double rad(double a) {return a * 180 / PI;}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//dpTable
int dp[100050];

int main(){
    int N,X,T;
    cin >> N >> X >> T;
    cout << ((N + X - 1) / X) * T << endl;
    return 0;
}

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

int main()
{
    const int NUM = 10000;
    int x;
    int num;
    int data[NUM];

    num = 0;

    while (num < NUM) {
        cin >> x;

        if (x == 0) break;

        if (x >= 1 && x <= 10000) {
            data[num] = x;
            num++;
        }
    }

    for (int i = 0; i < num; i++) {
        cout << "Case " << i+1 << ": " << data[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9) + 7;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		List<Integer[]> intervals = new ArrayList<>();
		
		// 記錄開始與結束段落
		Integer[] interval = new Integer[2];
		
        int n = sc.nextInt();
        int t = sc.nextInt();
        int[] time = new int[n];
        
        for (int i = 0; i < n; i++) {
        	time[i] = sc.nextInt();
        }
        
        for (int i = 0; i < n; i++) {
        	int startTime = time[i];
        	int endTime = startTime + t;
        	
        	if (i == 0) {
        		interval[0] = startTime;
        		interval[1] = endTime;
        	} else {
        		if (startTime <= interval[1]) {
        			interval[1] = endTime;
        		} else {
        			intervals.add(Arrays.copyOf(interval, 2));
        			interval[0] = startTime;
        			interval[1] = endTime;
        		}
        	}
        }
        intervals.add(Arrays.copyOf(interval, 2));
        long res = 0;
        for (Integer[] i: intervals) {
        	res += (i[1] - i[0]);
        }
      	System.out.println(res);
	}
	
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 45776
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back

ll gcd (ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}


signed main(){
    int t;
    cin>>t;
    while(t--){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        
        if(a<b){
            cout<<"No"<<endl;
        }else if(b>d){
            cout<<"No"<<endl;
        }else if(b<=c+1){
            cout<<"Yes"<<endl;
        }else {
            
            int G = gcd(b,d);
            
            int k1 = (a-b+G)/G;
            int k2 = (a-c-1)/G;
            
//            cout<<k2<<" "<<k1<<endl;
            
            if(k2>=k1)cout<<"No"<<endl;
            else cout<<"Yes"<<endl;
        }
    }
}


Measured memory_bytes: 256