akhauriyash/Code-Regression huggingface dataset:
import collections
n = int(input())
s = list(map(int, input().split()))
c = collections.Counter(s)
ans = 0
for x in c.items():
  if x[0]<x[1]:
    ans+=x[1]-x[0]
  elif x[0]>x[1]:
    ans+=x[1]
print(ans)

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
#define _GLIBCXX_DEBUG

int threemax(int a, int b, int c) {
	if (a >= b && a >= c) {
		return a;
	}
	else if (b >= a && b >= c) {
		return b;
	}
	else {
		return c;
	}
}

int threemin(int a, int b, int c) {
	if (a <= b && a <= c) {
		return a;
	}
	else if (b <= a && b <= c) {
		return b;
	}
	else {
		return c;
	}
}

void chmaxl(ll &a,ll b){
	if(a<b){
		a=b;
	}
	return;
}

void chminl(ll &a,ll b){
	if(a>b){
		a=b;
	}
	return;
}

void chmaxi(int &a,int b){
	if(a<b){
		a=b;
	}
	return;
}

void chmini(int &a,int b){
	if(a>b){
		a = b;
	}
	return;
}



int main() {
  ll N,M;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  for(ll i=0;i<M;i++){
    cin >> L.at(i) >> R.at(i);
  }
  int LL,RR;
  LL=MAX(L);
  RR=MIN(R);
  if(RR>=LL){
    cout << RR-LL+1;
  }
  else{
    cout << 0;
  }
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
EDGE=[list(map(int,input().split())) for i in range(M)]

if M%2!=0:
    print(-1)
    sys.exit()

E=[set() for i in range(N+1)]

for x,y in EDGE:
    E[x].add(y)
    E[y].add(x)

ECOUNT=[0]*(N+1)

from collections import deque


E_tree = [set() for i in range(N+1)]

Q=deque()
Q.append(1)
check=[0]*(N+1)
check[1]=1

TOP=[]
while Q:
    x=Q.pop()
    TOP.append(x)
    for to in E[x]:
        if check[to]==0:
            Q.append(to)
            E_tree[x].add(to)
            E_tree[to].add(x)
            check[to]=1

ECOUNT=[0]*(N+1)
for x,y in EDGE:
    if x in E_tree[y]:
        continue
    print(x,y)
    ECOUNT[x]+=1

#print(TOP[::-1])

for p in TOP[::-1][:-1]:
    q=list(E_tree[p])[0]

    if ECOUNT[p]%2==0:
        print(q,p)
        ECOUNT[q]+=1
    else:
        print(p,q)
    E_tree[q].remove(p)
    


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

 

#define pb push_back

#define mp make_pair

#define fs first

#define sc second

#define rep(i, from, to) for (int i = from; i < (to); ++i)

#define all(x) x.begin(), x.end()

#define sz(x) (int) (x).size()

#define FOR(i, to) for (int i = 0; i < (to); ++i)

 

using namespace std;

typedef long long ll;

typedef vector<int> vi;

typedef pair<int,int> pii;

typedef pair<double,double> pdd;

typedef vector<ll> vll;

typedef vector<pair<int,int>> vpi;

typedef pair<ll,ll> pll;

typedef vector<string> vs;

#define MOD 998244353

#define mod 998244353

#define INF 1000000000LL * 100000000LL

#define Nmax 2020200

int N, T, M, K, Q;

ll X;
vi v;
ll sum;
ll sm = 0;

int main() {

  cin.sync_with_stdio(false);

  cin >> X;
  while(X) {
    v.pb(X%10);
    X=X/10;
  }
  reverse(all(v));
  ll ret = (sz(v)-1) * 9;
  FOR(i, sz(v)) {
    sm += v[i];  
  }
  ret = max(ret, sm);
  for(int i=0;i<sz(v);++i) {
    if(v[i]) {
      ret = max(ret, sum + (v[i]-1) + (sz(v)-i-1) * 9);
    }
    sum += v[i];
  }
  cout << ret;

}

 

Measured memory_bytes: 256
from sys import stdin

N, K, Q = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(stdin.readline().rstrip()) for _ in range(Q)]

score = [0] * N

for a in A:
    score[a - 1] += 1

for s in score:
    if s > Q - K:
        print('Yes')
    else:
        print('No')


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

int main(){
  int H,W;
  cin >> H >> W;
  vector<int> h(H,0);
  vector<int> w(W,0);
  vector<string> m(H);
  for (int i=0;i<H;i++){
    cin >> m[i];
  }
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      if (m[i][j]=='#'){
        h[i]=1;
        w[j]=1;
      }
    }
  }
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      if (h[i] & w[j])
        cout << m[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  cout << "ABC" << N << endl;
}


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> B(N - 1);
  for (int i = 0; i < N - 1; i++) {
    scanf("%lld", &B[i]);
  }

  ll ans = B[0] + B[N - 2];
  rep(i, 1, N - 1) { ans += min(B[i], B[i - 1]); }
  cout << ans << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8
#


def main(n, i):
    retval = n - i + 1
    print(retval)
    
if __name__ == '__main__':
    try:
        n, i = list(map(int,input().strip().split(" ")))
        main(n, i)
    except EOFError:
        pass


Measured memory_bytes: 2940
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 100005
const int mod=1e9+7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second

int n,m;
char s[maxn<<1];

inline int read(){
    int x=0,f=1; char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

int main(){
	n=read(); scanf("%s",s+1);
	int cnt=0; int res=1;
	for (int i=1;i<=(n<<1);i++){
		if (s[i]=='B'){if (cnt&1) res=1ll*res*cnt%mod,--cnt; else ++cnt;}
		else if (s[i]=='W'){if (cnt&1) ++cnt; else res=1ll*res*cnt%mod,--cnt;}
		if (cnt<0){puts("0"); return 0;}
	}
	if (cnt){puts("0"); return 0;}
	for (int i=1;i<=n;i++) res=1ll*res*i%mod;
	printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define DDight(N) (int)(log10((int)N) + 1)
int SumDDight(int N)
{
    int ans  = 0;
    int n = N;
    for(int i = 0;i < DDight(N);i++)
    {
        ans += n % 10;
        n /= 10;
    }
    return ans;
} 
int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    long long sum = 0;
    int tmp = 0;
    for(int i = 1;i <= n; ++i)
    {
        tmp = SumDDight(i);
        if(a <= tmp && tmp <= b)
            sum += i;
    }
    cout << sum << '\n';
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
typedef  pair<int,int> P;

//union findで実装してあげて、最大個数所属している山を探す
struct UnionFind
{
vector<int>d;
UnionFind(int n): d(n,-1){}


int find(int x)
{
if(d[x]<0)return x;
return d[x]=find(d[x]);
}

bool unite(int x,int y)
{
x=find(x),y=find(y);
if(x==y)return false;
if(d[x]>d[y])swap(x,y);
//xにyを付ける→xの絶対値が大きい必要がある。
d[x]+=d[y];
d[y]=x;
return true;

}
bool same(int x,int y){return find(x)==find(y);}
int size(int x){return -d[find(x)];}
};



int main()
{
int n,m;
cin>>n>>m;
UnionFind uf(n);
rep(i,m)
{
int a,b;
cin>>a>>b;
a--;b--;
uf.unite(a,b);
}

int ans=0;
for(int i=0;i<n;i++)
ans=max(ans,uf.size(i));
cout <<ans;
}


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

int main(){
  
  int N; cin >> N;
  vector<int> W(N);
  for (int i = 0; i < N; i++) cin >> W.at(i);
  
  int sum = 0;
  for (int i = 0; i < N; i++) sum += W.at(i);
  
  int subsum = 0;
  
  for (int i = 0; i < N; i++){
    int temp = sum - subsum * 2;
    subsum += W.at(i);
    //cout << sum << " " << subsum << endl; //test
    if (subsum == sum - subsum){
      cout << 0 << endl;
      break;
    }
    if (subsum > sum - subsum){
      //cout << temp << endl; //test
      //cout << subsum * 2 - sum << endl; //test
      cout << min(temp,subsum * 2 - sum) << endl;
      break;
    }
  }
  
}

Measured memory_bytes: 256
def solve():
    N = int(input())
    for h in range(1,3500+1):
        for n in range(1,3500+1):
            numerator = N * h * n
            denominator = 4 * h * n - N * n - N * h

            if denominator == 0:
                continue

            w = numerator // denominator
            if numerator % denominator == 0 \
            and 0 < w <= 3500:
                print(h,n,w)
                return
        
if __name__ == '__main__':
    solve()


Measured memory_bytes: 66360
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()
{
  //int A, B, C, X, Y;
//  int m[101]={};
  long long min=0;
  int A, B, C, K;
//  int sosu[20000]={};
  int i,j,k;
  int flag=0;
  int tmp=0;
  int cnt =0;
  int next_cnt = 0;
  int tmp_cnt =0;
  int tmp_next_cnt = 0;

//    int k=0;

  scanf("%d %d", &A, &B);
  //printf("%d\n", A);



 if(A==0 && B==100)   printf("%d", B +1);
 else if(A==0)   printf("%d", B);

 if(A==1 && B==100)      printf("%d", (B +1) * 100);
 else if(A==1)      printf("%d", B * 100);
 if(A==2 && B==100)      printf("%d", (B +1) * 100 *100);
 else if(A==2)      printf("%d", B * 100 * 100);

return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20191021
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);

            int i = a - b;
            int j = c - i;

            if (j < 0)
                j = 0;

            Console.WriteLine(j);
        }
    }
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> ans(4);
    vector<string> S(N);
    for (int i = 0; i < N; i++)
    {
        cin >> S.at(i);
        if (S.at(i) == "AC")
        {
            ans.at(0) ++;
        }
        if (S.at(i) == "WA")
        {
            ans.at(1) ++;
        }
        if (S.at(i) == "TLE")
        {
            ans.at(2) ++;
        }
        if (S.at(i) == "RE")
        {
            ans.at(3) ++;
        }
    }
    

    cout << "AC x " << ans.at(0) << endl;
    cout << "WA x " << ans.at(1) << endl;
    cout << "TLE x " << ans.at(2) << endl;
    cout << "RE x " << ans.at(3) << endl;
    
}


Measured memory_bytes: 6428
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    vector<int> cnt(1e5, 0);
    rep(i, n) {
        int a;
        cin >> a;
        ++cnt[a];
        if ( a >= 1 ) {
            ++cnt[a-1];
        }
        if ( a < 1e5-1 ) {
            ++cnt[a+1];
        }
    }
//    rep(i, 10) {
//        cout << cnt[i] << " " ;
//    }
//    cout << endl;
    int ans = 0;
    rep(i, 1e5+1) {
        ans = max(ans, cnt[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
n, m = gets.split.map(&:to_i)
s = gets.chomp

i = n
a = []
while i > 0
    x = ([i-m, 0].max).upto(i) {|j| break j if s[j] == ?0}
    
    if i == x
        a = [-1]
        break
    end

    a.unshift(i-x)
    i = x
end

puts a * " "

Measured memory_bytes: 3324
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<map>
#include<vector>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=51;
int N;
double a[maxn];
int main(){
	//freopen("in","r",stdin);
	N=read();
	for(int i=1;i<=N;i++)
		a[i]=read();
	for(int i=1;i<N;i++){
		sort(a+1,a+1+N-i+1);
		a[1]=(a[1]+a[2])/2;
		for(int j=2;j<=N-i+1;j++)
			a[j]=a[j+1];
	}
	printf("%.6lf\n",a[1]);
	return 0;
}



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

using namespace std;

int main(){
	double x1,y1,x2,y2;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	printf("%.8lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}



Measured memory_bytes: 2748
#include<bits/stdc++.h>
#define ll long long

const int N = 4010;
const int moder = 1e9 + 7;

ll dp[2][N][2], n, m, kk;

int main(){
	scanf("%d%d%d", &n, &m, &kk);
	dp[0][0][0] = 1;
	int pre = 0, now = 1;
	ll ans = 0;
	for (int i = 1; i <= (n + m - 1) / (kk - 1); ++ i){
		for (int k = 0; k <= n; ++ k){
			if (k < i * (kk - 1) - m + 1){
				continue;
			}
			dp[now][k][0] = (dp[now][k][0] + dp[pre][k][0] + dp[pre][k][1]) % moder;
		}
		for (int j = 1; j < kk; ++ j){
			for (int k = 0; k <= n; ++ k){
				int x = j + k;
				if (x < i * (kk - 1) - m + 1 || x > n){
					continue;
				}
				dp[now][x][1] = (dp[now][x][1] + dp[pre][k][0] + dp[pre][k][1]) % moder;
			}
		}
		for (int j = 0; j <= n; ++ j){
			if (j % (kk - 1) == n % (kk - 1)){
				ans = (ans + dp[now][j][1]) % moder;
			}
		}
		pre ^= 1;
		now ^= 1;
		memset(dp + now, 0, sizeof(int) * N * 2);
	}
	return printf("%d\n", ans), 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e3 + 5;
const ll inf = 1e18;


struct store {
    ll a, b;
    void read() {
	cin>>a>>b;
    }
    bool operator<(const store&o ) const {
	//return b/a < o.b/o.a;
	return (1+b)*o.a < (1+o.b)*a;
    }
};

int n;
ll T;


void relax(ll &x, ll y) {
    x = min(x, y);
}


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

    cin>>n>>T;
    vector<store> v;
    vector<ll> B;
    for (int i=0; i<n; i++) {
	store s;
	s.read();
	if (s.a==0) {
	    B.push_back(s.b);
	} else {
	    v.push_back(s);
	}
    }


    sort(v.begin(), v.end());

    const int N = 50; // > 1e9
    // a(aT+b+1)+b -> a^i -> exponential time increase

    vector<ll> dp(N+1, inf);
    dp[0] = 0;

    for (int i=0; i<(int)v.size(); i++) {
	for (int j=N; j>=0; j--) {
	    if (dp[j] < T) {
		relax(dp[j+1], dp[j] + 1 + ((dp[j]+1)*v[i].a + v[i].b));
	    }
	}
    }



    sort(B.begin(), B.end());
    vector<ll> cost;
    cost.push_back(0);
    for (int i=1; i<(int)B.size(); i++) {
	B[i] += B[i-1];
    }
    for (int i=0; i<(int)B.size(); i++) {
	cost.push_back((i+1) + B[i]);
    }


    int hi = 0;
    for (int i=0; i<=N; i++) {
	if (dp[i] <= T) {
	    ll leftover = T-dp[i];
	    auto iter = std::prev(upper_bound(cost.begin(), cost.end(), leftover));
	    int take = i + (iter-cost.begin());
	    //watch(iter-cost.begin());
	    hi = max(hi, take);
	}
    }

    cout<<hi<<endl;    
    return 0;
}


Measured memory_bytes: 7928
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
	static void Main(string[] args)
	{
		var N = int.Parse(Console.ReadLine());
		var array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
		var max = array[0];
		var count = 0;
		for (int i = 0; i < N; i++)
		{
			if (max <= array[i])
			{
				count++;
				max = array[i];
			}
		}

		Console.WriteLine(count);
	}
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};

int main(){

	string str;
	int st,ls;

	cin >> str;

	for(int i=0; i<str.size(); i++){
		if(str[i] == 'A'){
			st = i;
			break;
		}
	}


	for(int j=str.size()-1; j>=0; j--){
		if(str[j] == 'Z'){
			ls = j;
			break;
		}
	}

	cout << ls - st + 1 << endl;
}

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

#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int n;
int c[10][10];
long long res;
int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n;
    for(int i = 1; i <= 9; i ++){
        for(int j = 1; j <= 9; j ++){
            int cnt = 0;
            for(int k = 1; k <= n; k ++){
                int x = k;
                int pw = 1;
                while(x > 0){
                    x /= 10;
                    pw *= 10;
                }
                pw /= 10;
                cnt += (k / pw == i && k % 10 == j);
            }
            c[i][j] = cnt;
        }
    }
    for(int i = 1; i <= 9; i ++){
        for(int j = 1; j <= 9; j ++){
            res += c[i][j] * 1ll * c[j][i];
        }
    }
    cout << res << "\n";
}



Measured memory_bytes: 256
import itertools
import math
N=int(input())
lis=[]
for i in range(N):
	[x,y]=[int(j)+1000 for j in input().split()]
	lis+=[x+y*10000]
A=list(itertools.permutations(lis))
add=0
cnt=0
for i in range(len(A)):
	for j in range(len(A[i])-1):
		add+=(((A[i][j]//10000)-(A[i][j+1]//10000))**2+((A[i][j]%10000)-(A[i][j+1]%10000))**2)**0.5
		cnt+=1
print(add/math.factorial(N))

Measured memory_bytes: 46444
// E - Sum of gcd of Tuples (Hard)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)

#define MOD 1'000'000'007

// a^n mod m を計算する(繰り返し二乗法,二分累乗法:O(logn)) (再帰版)
ll modpow(ll a,ll n){return n?modpow(a*a%MOD,n/2)*(n%2?a:1)%MOD:1;}

ll cnt_gcd[100001]; // [gcd:[1,K]] gcd 毎の個数

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

	irp(g, K, 1-1){ // g:[K,1,-1] gcd を固定
		cnt_gcd[g] = modpow(K/g, N); // g の倍数の個数
		for(int n=2; n*g<=K; ++n) cnt_gcd[g] -= cnt_gcd[n*g]; // g*1 以外を除去
	}

	ll ans = 0;
	rp(g, 1, K+1) ans = (ans + (cnt_gcd[g] * g % MOD)) % MOD;
	cout<< ans <<endl;
}

Measured memory_bytes: 4408
#!/usr/bin/env python3
import sys
def gcd(a, b):
    while b: a, b = b, a % b
    return abs(a)

def solve(N: int, M: int, a: "List[int]"):
    a = [t//2 for t in list(set(a))]

    g = a[0]
    for t in a:
        g = gcd(g, t)

    ag = [t//g for t in a] 

    mu = 1
    for t in ag:
        if t%2==1:
            mu*= t//gcd(t,mu)
        else:
            print(0)
            return
    # print(g)
    # print(mu)
    print((M//(mu*g)+1)//2)



    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 60576
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;

void dfs(int u, vector<vector<int> > &G, vector<bool> &vis, int& count)
{
   vis[u] = 1;
   count++;
   for (auto x : G[u])
   {
      if (!vis[x])
         dfs(x, G, vis, count);
   }
}
 
int main()
{
   
   int n, m;
   cin >> n >> m;
   vector<vector<int> > G(n + 1);
   for(int i=0;i<m;i++)
   {
      int a, b;
      cin >> a >> b;
      G[a].push_back(b);
      G[b].push_back(a);
   }
   vector<bool> vis(n + 1, false);
   vector<int>  res;
   for (int i = 1; i <= n; i++)
   {
      int count = 0;
      if (!vis[i])
      {
         dfs(i, G, vis, count);
         res.push_back(count);
      }
   }
   ll ans = 0;
   int z = *max_element(res.begin(), res.end());
   cout << z << endl;
 
   return 0;
}


Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> t(n + 1);
    vector<int> x(n + 1);
    vector<int> y(n + 1);
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for(int i = 1; i < n+1; i++)
    {
        cin >> t[i] >> x[i] >> y[i];
    }

    for(int i = 0; i < n; i++)
    {
        int t1 = t[i + 1] - t[i];
        int x1 = max(x[i + 1], x[i]) - min(x[i + 1], x[i]);
        int y1 = max(y[i + 1], y[i]) - min(y[i + 1], y[i]);
        int d = x1 + y1;

        if(d <= t1 && (t1 % 2 == d % 2))
        {
            continue;
        }
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}




Measured memory_bytes: 1408
MOD = 10**9+7

def solve(C):
    N = len(C)
    C.sort()

    dp1 = 0
    dp2 = 0
    for k,c in enumerate(C):
        ndp2 = 2*pow(4,k,MOD)*c + 4*dp2
        dp1 = 4*dp1 + ndp2 - 2*dp2
        dp2 = ndp2
        dp1 %= MOD
        dp2 %= MOD

    return dp1

def naive(C):
    from itertools import product
    N = len(C)
    C.sort()
    s = 0
    for a in product(range(2),repeat=N):
        for b in product(range(2),repeat=N):
            pop = 1
            for x,y,c in zip(a,b,reversed(C)):
                if x != y:
                    s += c*pop
                    pop += 1
    return s

if __name__ == '__main__':
    N = int(input())
    C = list(map(int,input().split()))
    print(solve(C))

Measured memory_bytes: 31244
n, x = map(int, input().split())
layer = [1]
patty = [1]
for _ in range(n):
    layer.append(1 + layer[-1] + 1 + layer[-1] + 1)
    patty.append(patty[-1] + 1 + patty[-1])
res = 0
while x > 0:
    x -= 1
    if x >= layer[n-1] + 1:
        res += 1
    while x >= layer[n-1]:
        res += patty[n-1]
        x -= layer[n-1] + 1
    n -= 1
print(res)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=2*300 +117;
const int MM= +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
int e[NN][2]={};
LL dp[NN][NN]={};
int s[NN]={};
bool ok[NN][NN]={};
inline int cnt(int l,int r){
	return s[r]-s[l-1];
}
bool inside(int x,int l,int r){
	return l<=x&&x<=r;
}
LL v[NN]={};
const int mod=1e9+7;
int main(){
	//open();
	n=read()*2;
	m=read();
	v[0]=1;
	for(int i=2;i<=n;++i){
		v[i]=v[i-2]*(i-1)%mod;
	}
	for(int i=1;i<=m;++i){
		e[i][0]=read(),e[i][1]=read();
		s[e[i][0]]++;
		s[e[i][1]]++;
	}
	for(int i=1;i<=n;++i){
		s[i]+=s[i-1];
	}
	for(int i=1;i<=n;++i){
		for(int j=i+1;j<=n;++j){
			ok[i][j]=1;
			for(int k=1;k<=m;++k){
				if(inside(e[k][0],i,j)^inside(e[k][1],i,j)){
					ok[i][j]=0;
					break;
				}
			}
		}
	}
	LL op=0;
	for(int len=2;len<=n;len+=2){
		for(int i=1;i+len-1<=n;++i){
			int j=i+len-1;
			if(!ok[i][j])continue;
			LL ans=v[len-cnt(i,j)];
			for(int c=i+1;c<j;c+=2){
				ans-=dp[i][c]*v[j-c-cnt(c+1,j)]%mod;
			}
			ans%=mod;
			dp[i][j]=ans;
			ans=ans*v[n-len-2*m+cnt(i,j)]%mod;
			op+=ans;
			//if(ans)cerr<<i<<" "<<j<<": "<<ans<<endl;
			op%=mod;
		}
	}
	op=(op+mod)%mod;
	printf("%lld\n",op);
	close();
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long double pi = acos(-1.0); 
typedef long long ll;

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

	int n;
	cin >> n;
	int cnt = 0;
	int ans = 0;
	for(int i = 0; i < n; i++) {
		int d1, d2;
		cin >> d1 >> d2;
		if(d1 == d2) {
			cnt++;
			ans = max(ans, cnt);
		}else {
			cnt = 0;
		}
	}
	if(ans >= 3) {
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3648
#include <stdio.h>
int main()
{
  int n;
  scanf("%d",&n);
  int i = 0;
  int d[n][2];
  int cnt = 0;
  while (i < n)
  {
    scanf("%d",&d[i][0]);
    scanf("%d",&d[i][1]);
    if (d[i][0] == d[i][1])
      cnt++;
    else
      cnt = 0;
    if (cnt == 3)
    {
      printf("Yes");
      return (0);
    }
    i++;
  }
  printf("No");
}

Measured memory_bytes: 1732
from sys import exit
while(True):
    N = int(input())
    # print(N)
    if N == 0:
        break
    h = list(map(int, input().split()))
    for i in range(N+1):
        targ = h[:i] + h[i+1:]
        diff = targ[1] - targ[0]
        OK = True
        for j in range(1, N):
            if diff != targ[j] - targ[j-1]:
                OK = False
                break
        if not OK:
            continue
        else:
            print(h[i])
            break



Measured memory_bytes: 5620
"""
C - Pyramid
"""

import numpy as np

n = int(input())

points = []
for i in range(n):
    part = list(map(int, input().split()))
    points.append(part)

#print(points)

# 100 * 100 を走査する
for cx in range(101):
    for cy in range(101):

        #print("cx", cx, "cy", cy)
        
        # -1 未定義　-2 だめ
        need_h = -1
        for point in points:

            # 地平線に隠れていない
            if point[2] > 0:
                # 高さを仮定する
                temp = point[2] + abs(cx - point[0]) + abs(cy - point[1])
                if need_h == -1:
                    need_h = temp
                else:
                    if need_h != temp:
                        need_h = -2
                        break
                
        if need_h == -2:
            continue
        
        # 通過したつまり地平線に隠れた部分
        for point in points:
            if point[2] == 0:
                dist = abs(cx - point[0]) + abs(cy - point[1])
                if need_h > dist:
                    need_h = -2
                    break
        
        if need_h == -2:
            continue
        
        print(cx, cy, need_h)
        exit()




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

#define v vector
#define ll long long 
#define vpll vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pci pair<char,int>
 
using namespace std; 


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    double n,k;
    cin>>n>>k;
    double ans = 0.0;
    for(int i = 1 ; i <= n ; i++)
    {
        if(i < k)
        {
            int p = ceil(log2(k/i));
            ans += (1.0/n)*pow(0.5,p);
        }
        else
        {
            ans += (1.0/n);
        }
        
    }
    cout<<setprecision(12)<<ans;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

void func(set<int>& M, int v) {
    set<int> tmp;
    for(auto it=M.begin(); it != M.end(); ++it) {
        tmp.insert({*it + v, *it - v});
    }

    M = tmp;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    string s;
    cin >> s;

    int x, y;
    cin >> x >> y;

    set<int> X, Y;
    X.insert(0);
    Y.insert(0);

    int start = 0;
    int cnt = 0;
    for (; start < s.size(); ++start) {
        if (s[start] != 'T') ++cnt;
        else {
            ++start;
            break;
        }
    }

    X.insert(cnt);
    cnt = 0;

    bool v = true;
    FOR(i, start, s.size()) {
        if (s[i] == 'T') {
            if (v) {
                func(Y, cnt);
            } else {
                func(X, cnt);
            }
            cnt = 0;
            v ^= 1;
        } else {
            ++cnt;
        }
    }

    if (cnt){
        if (v) {
            func(Y, cnt);
        } else {
            func(X, cnt);
        }
    }


    if (X.count(x) && Y.count(y)) cout << "Yes" << endl;
    else cout << "No" << endl;


}


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

int main() {
  ll n,k;
  cin >> n>>k;
  if (n<=k){
    cout <<0<< endl;
    return 0;
  }
  vector<ll> v(n);
  rep(i,n){
    cin>>v.at(i);
  }
  sort(v.begin(),v.end());
  ll sum = 0;
  rep(i,n-k){
    sum += v.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    REPS(c, s) {
        cout << 'x';
    }
    cout << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    
    int menseki = a * b;
    int syu = a * 2 + b * 2;
    System.out.println(menseki + " " + syu);
  }
}

Measured memory_bytes: 26136
A, B = map(int, input().split())

rank = (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1)

if rank.index(A) > rank.index(B):
    print("Alice")
elif rank.index(A) < rank.index(B):
    print("Bob")
else:
    print("Draw")


Measured memory_bytes: 2940
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()
	sum, xor := 0, 0
	var sums, xors = make([]int, N+1), make([]int, N+1)
	for i := 1; i <= N; i++ {
		a := nextInt()
		sum += a
		xor ^= a
		sums[i] = sum
		xors[i] = xor
	}

	c, l, r := 0, 0, 0
	for l < N {
		for r < N && sums[r+1] - sums[l] == xors[r+1] ^ xors[l] {
			r++
		}

		c += r - l

		if l == r {
			r++
		}
		l++
	}

	fmt.Println(c)
}


Measured memory_bytes: 4736
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  int n;cin>>n;
  P a[101],b[101];
  int i,j,k;
  rep(i,n) cin>>a[i].first>>a[i].second;
  rep(i,n) cin>>b[i].first>>b[i].second;

  sort(a,a+n);
  sort(b,b+n);
  int cnt=0;
  rep(i,n){
      int tmp=-1;
    rep(j,n){
      if(a[j].first<b[i].first){
        if(a[j].second<b[i].second){
          tmp=max(tmp,a[j].second);
        }
      }
      else break;
    }
    rep(j,n){
      if(tmp==a[j].second){
        a[j].second=INF;
        break;
      }
    }
    if(tmp>-1){
      cnt++;
      //cout<<tmp<<endl;
    }
  }
  cout<<cnt<<endl;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : (x))
#define all(x) x.begin(), x.end() // sort(all(x))
#define sz(x) (int)(x).size()
#define mp(x, y) make_pair((x), (y))

typedef long long ll;

typedef double T;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tiii;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<T> vt;
typedef vector<vt> vvt;
typedef vector<pii> vpi;
typedef vector<pii> vpl;
typedef vector<vpi> graph;
typedef complex<T> Pt;
typedef pair<Pt, Pt> Line;

const ll MOD = 1e9 + 7; // 998244353;
const T EPS = 1e-10;
const int INF = 1e9 + 1;

/* Mod Library */

struct Mod {
    ll x;
    Mod (ll x = 0) : x(x) {}
    Mod operator+(Mod b) { return Mod((x + b.x)%MOD); }
    Mod operator-(Mod b) { return Mod((x - b.x + MOD)%MOD); }
    Mod operator*(Mod b) { return Mod((x * b.x)%MOD); }
    Mod operator/(Mod b) { return *this * inverse(b); }
    Mod operator%(Mod b) { return Mod(x % b.x); }

    static ll euclid(ll a, ll b, ll &x, ll &y) {
        if (b) {
            ll d = euclid(b, a%b, y, x);
            y -= a/b*x;
            return d;
        }
        x = 1; 
        y = 0;
        return a;
    }
    
    Mod inverse(Mod a) {
        ll x, y, g = euclid(a.x, MOD, x, y);
        assert(g == 1);
        return Mod((x + MOD)%MOD);
    }

    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this^(e/2);
        r = r*r;
        return e&1 ? *this*r : r;
    }
};

/* Input Library */
template <typename A, typename B>
istream& operator>>(istream &in, pair<A, B> &p) {
    in >> p.first >> p.second;
    return in;
}

template <typename A, typename B>
ostream& operator<<(ostream &out, pair<A, B> &p) {
    out << p.first << " " << p.second;
    return out;
}

template <typename I>
istream& operator>>(istream &in, vector<I> &a) {
    trav(i, a) in >> i;
    return in;
}

template <typename I>
ostream& operator<<(ostream &out, vector<I> &a) {
    rep(i, 0, sz(a)) {
        if (i) out << " ";
        out << a[i];
    }
    return out;
}

void fast_io() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    //cout.tie(0);
    cin.exceptions(cin.failbit);
} 

void solve_test() {
  int x; 
  cin >> x;
  cout << 360 / __gcd(x, 360) << endl;
}

void setup() {
}

int main() {
    setup();
    srand(time(0));
    fast_io();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve_test();
    }
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> gate(m, vector<int>(2));
	for (int i = 0; i < m; i++) {
		cin >> gate.at(i).at(0) >> gate.at(i).at(1);
	}
	int ans = 0;
	
	int left = -1;
	int right = 1000000;
	for (int i = 0; i < m; i++) {
		left = max(left, gate.at(i).at(0));
		right = min(right, gate.at(i).at(1));
	}
	ans = right - left + 1;
	if (ans < 0) ans = 0;
	cout << ans << endl;
}

Measured memory_bytes: 5760
import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val k = cin.nextInt()

    val mod: Long = 1000000007

    val c = Array<Array<Int>>(n+1, { Array<Int>(n+1, { 0 })})

    for (i in 0..n) {
        for (j in 0..n) {
            if (j > i) {
                continue
            } else if (j == 0) {
                c[i][j] = 1
            } else {
                val c_long: Long = c[i-1][j-1].toLong() + c[i-1][j].toLong()
                c[i][j] = (c_long % mod).toInt()
            }
        }
    }

    for (i in 1..k) {
        println((c[k-1][i-1].toLong() * c[n-k+1][i].toLong()) % mod)
    }
}

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

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double th = double(h*60+m)/720 * 2*M_PI;
    double tm = double(m)/60 * 2*M_PI;
    double ans = sqrt(a*a + b*b - 2*a*b*cos(th - tm));
    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 4192
#include <iostream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <cmath>
#include <numeric>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int x[n], y[n];
    for(int i=0; i<n; i++){
        cin >> x[i] >> y[i];
        //cout << x[i] << "," << y[i] << endl;
    }
    
    vector<int> v(n);
    double sum = 0.0;
    int ptn = 0;
    iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
    do {
        //cout << "---" << endl;
        //for(auto i : v) cout << i << " "; cout << "\n";    // v の要素を表示
        ptn++;
        double tmp = 0.0;
        for(int i=0; i<n-1; i++){
            //cout << v[i] << " -> " << v[i+1] << endl;
            //cout << x[v[i]-1] << " -> " << x[v[i+1]-1] << endl;
            //cout << y[v[i]-1] << " -> " << y[v[i+1]-1] << endl;

            int deltax = x[v[i]-1] - x[v[i+1]-1];
            int deltay = y[v[i]-1] - y[v[i+1]-1];
            //cout << deltax << "," << deltay << endl; 
            tmp += sqrt(deltax*deltax + deltay*deltay);
        }
        sum += tmp;
    } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成
    
    //cout << (double)ptn << endl; 
    printf("%.7lf\n", sum/(double)ptn);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>
#define PLL pair<ll, ll>

using namespace std;


int N, M, p, q, r;
int main() {
	while (cin >> N, N)
	{
		cin >> M >> p >> q >> r;
		vector<P> group;
		group.emplace_back(1, r);
		rep(i, M) {
			int x, y;
			cin >> x >> y;
			rep(j, group.size()) {
				int a = group[j].first, b = group[j].second;
				if (a <= x && x < b) {
					group[j].second = x;
					group.emplace_back(x + 1, b);
					continue;
				}
				if (a <= y && y < b) {
					group[j].second = y;
					group.emplace_back(y + 1, b);
				}
			}
			rep(j, group.size()) {
				int a = group[j].first;
				if (a <= x) {
					group[j].first += N - x;
					group[j].second += N - x;
				}
				else if (a <= y) {
					group[j].first += N - y - x;
					group[j].second += N - y - x;
				}
				else{
					group[j].first += -y;
					group[j].second += -y;
				}
			}
		}

		int ans = 0;
		rep(i, group.size()) {
			int a = group[i].first, b = group[i].second;
			if (p <= a && b <= q) {
				ans += b - a + 1;
			}
			else if (p <= a && a <= q) {
				ans += q - a + 1;
			}
			else if (p <= b && b <= q) {
				ans += b - p + 1;
			}
		}

		cout << ans << endl;

	}


	return 0;
}


Measured memory_bytes: 3072
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;

void outAns(vector<int> &a){
    cout << a[0];
    rep(i,n-1) cout << " " << a[i+1];
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> n >> a >> b;
    vector<int> ans(n);
    if(a == 1){
        if(n == b){
            rep(i,n) ans[i] = n-i;
            outAns(ans);
        }
        else{
            cout << -1 << endl;
        }
    }
    else if(b == 1){
        if(n == a){
            rep(i,n) ans[i] = i+1;
            outAns(ans);
        }
        else{
            cout << -1 << endl;
        }
    }
    else if(n <= a || n <= b){
        cout << -1 << endl;
    }
    else{
        if(a <= b){
            rep(i,a) ans[i] = n - a + i + 1;
            int lim = n - a + 1;
            if(b < 2 || b > lim || (n - a + b - 2) / (b - 1) > a){
                cout << -1 << endl;
            }
            else{
                int idx = a, cnt = 1;
                while(idx < n){
                    rep(i,b-1){
                        ans[idx] = min((b-1)*cnt - i, n - a - i);
                        if(++idx == n) break;
                    }
                    ++cnt;
                }
                outAns(ans);
            }
        }
        else{
            rep(i,b) ans[i] = b - i;
            int lim = n - b + 1;
            if(a < 2 || a > lim || (n - b + a - 2) / (a - 1) > b){
                cout << -1 << endl;
            }
            else{
                int idx = b, cnt = 1;
                while(idx < n){
                    rep(i,a-1){
                        ans[idx] = max(n - (a - 1)*cnt + i + 1, b + 1 + i);
                        if(++idx == n) break;
                    }
                    ++cnt;
                }
                outAns(ans);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4508
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int n,m;
vector<int> to[200005];
int parent[200005];
int color[200005];
set<int> S;
int sm[200005];

void dfs(int u){
    if(color[u]==1)return;
    color[u]=1;
    for(int v:to[u]){
        if(color[v]==0){
            parent[v]=parent[u];
            dfs(v);
        }
    }
    return;
}

int main(){
    cin >> n>>m;
    rep(i,n){
        parent[i]=i;
    }
    rep(i,m){
        int a,b;
        cin >> a>> b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i,n){
        dfs(i);
    }
    
    rep(i,n){
        sm[parent[i]]++;
        //cerr<<parent[i]<<' ';
    }
    int ans=0;
    rep(i,n){
        ans=max(ans,sm[i]);
    }
    //cerr<<endl;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 25380
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<int> > vvint;
struct node {
	int parent;
	int left;
	int right;
};
void rec(int i, int d, vector<int>& D, vector<node>& A) {
	D[i] = d;
	if (A[i].left != -1) {
		rec(A[i].left, d+1, D, A);
	}
	if (A[i].right!=-1) {
		rec(A[i].right, d, D, A);
	}
};
string children(int i, vector<node>& A) {
	string s = "[";
	int c = A[i].left;
	while (c!=-1) {
		ostringstream oss;
		oss << c;

		s += oss.str();
		
		c = A[c].right;
		if(c!=-1)s += ", ";
	}
	s += "]";
	return s;
}
int main() {
	int N;
	cin >> N;
	vector<node> A(N);
	vector<int> D(N,-1);
	for (int i = 0; i < N; i++)A[i].parent = A[i].left = A[i].right = -1;
	int prev,id,len,child,root;
	for (int i = 0; i < N; i++)
	{
		cin >> id >> len;
		for (int j = 0; j < len; j++)
		{
			cin >> child;
			A[child].parent = id;
			if (j==0) {
				A[id].left = child;
			}
			else {
				A[prev].right = child;
			}
			prev = child;
		}
	}
	for (int i = 0; i < N; i++)
	{
		if (A[i].parent == -1)root = i;
	}
	rec(root,0,D,A);
	for (int i = 0; i < N; i++)
	{
		char ans[500];
		string type;
		if (A[i].parent==-1) {
			type = "root";
		}
		else if (A[i].left==-1) {
			type = "leaf";
		}
		else {
			type = "internal node";
		}
		cout << "node "<<i<<": parent = "<<A[i].parent<<", depth = "<<D[i]<<", "<<type<<", "<< children(i, A) << endl;
	}
};


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

typedef long long ll;

const int MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0);

int main()
{
  ll n, cnt = 0 ;
  cin >> n ;
  string s ;
  cin >> s ;
  for(int i = 0; i <= n - 3; i++) {
    if(s[i] == 'A') {
      if(s[i + 1] == 'B') {
        if(s[i + 2] == 'C') {
          cnt++ ;
          i += 2 ;
        }
      }
    }
  }
  cout << cnt << endl ;
}


Measured memory_bytes: 256