akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
#define _v1 CONCAT(qyw1, __LINE__) // unique name in same line (otherwise use __COUNTER__)
#define _v2 CONCAT(qyw2, __LINE__)
#define forbits(i, m) for (int _v1 = m, i = __builtin_ctz(_v1); _v1 != 0; _v1 ^= _v1 & -_v1, i = __builtin_ctz(_v1))
#define forsubm(s, m) for (int s = m; s >= 0; s = !s ? -1 : m & (s - 1))
int __nextXZW(int v){int t=v|(v-1);int w=(t+1)|(((~t&-~t)-1)>>(__builtin_ctz(v)+1));return w;}
#define ksets(i, n, k) for (int i = (1u << k) - 1, max = i << (n - k); i <= max; i = __nextXZW(i))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  string s; cin >> s;
  ll sum = 0;
  for (char c : s) {
    int x = c - '0';
    sum += x;
  }

  if (sum % 9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int main(){
    vector<ll> vec(10001);
    vec[0] = 1;
    for(int i=1;i<=10000;i++){
        vec[i] = vec[i-1] + i;
    }
    int n;
    while(cin >> n){
        cout << vec[n] << endl;
    }
    return 0;
}
// int main(){
//      int n;
//      while(cin >> n){
//          cout << n*(n-1)/2 +1 << endl;
//      }
//      return 0;
// }

Measured memory_bytes: 1268
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int n,m,p,X,Y,Z,res,b[9][9][9];
int dx[] = {1,0,0,1,1,0,-1,-1, 0,1, 1, 1,-1};
int dy[] = {0,1,0,1,0,1, 1, 0,-1,1, 1,-1, 1};
int dz[] = {0,0,1,0,1,1, 0, 1, 1,1,-1, 1, 1};

inline int check(int col){
  rep(i,n)rep(j,n)rep(k,n){
    if(b[i][j][k]==col){
      rep(t,13){
	int c=0,tx=i,ty=j,tz=k;
	while(c<m && 0<=tx && tx<n && 0<=ty && ty<n && 0<=tz && tz<n){
	  if(b[tx][ty][tz] == b[i][j][k])c++;
	  else break;
	  tx += dx[t]; ty += dy[t]; tz += dz[t];
	}
	if(c==m)return b[i][j][k];
      }
    }
  }
  return -1;
}

int main(){
  std::ios::sync_with_stdio(false);
  while(cin >> n >> m >> p,n+m+p){
    rep(i,n)rep(j,n)rep(k,n)b[i][j][k] = -1;

    bool f = true;
    rep(i,p){
      cin >> X >> Y;
      if(f){
	X--; Y--;Z=0;
	while(b[X][Y][Z]>=0)Z++;
	b[X][Y][Z] = i&1;
	
	if(i>=2*(m-1)){
	  res = check(i&1);
	  if(res==0){
	    cout << "Black " << i+1 << endl;
	    f = false;
	  }else if(res==1){
	    cout << "White " << i+1 << endl;
	    f = false;
	  }
	}
      }
    }
    if(f)cout << "Draw\n";
  }
}

Measured memory_bytes: 1204
def main():
    n = int(input())
    
    ans = 0
    i = 2
    while i * i <= n:
        count = 0
        while n % i == 0:
            count += 1
            n //= i
        times = 1
        while count > 0:
            count -= times
            times += 1
            ans += 1
        if count < 0:
            ans -= 1
        i += 1
    
    if n > 1:
        ans += 1
    
    print(ans)

main()

Measured memory_bytes: 62796
#include<bits/stdc++.h>
#define N 100100
using namespace std;
typedef long long LL;
inline void read(int &a){
	a=0;char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch<='9'&&ch>='0') a=a*10+ch-'0',ch=getchar();
}
int a[N],n,m;
LL add[N],del[N],ans=1e18;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) read(a[i]);
	for(int i=0;i<n-1;i++) {
		int x=a[i],y=a[i+1];
		if(x<y){
			add[1]+=(y-x);
			add[x+1]-=(y-x);
			del[x+1]--;
			add[y+1]+=(y-x);
			add[x+1]+=y+1;
			del[y+1]++;
			add[y+1]-=y+1;
		}
		else if(x>y){
			add[1]+=y+1;
			del[1]--;
			add[y+1]-=y+1;
			add[y+1]+=m-x+y;
			del[y+1]++;
			add[x+1]-=m-x+y;
			add[x+1]+=y+1+m;
			del[x+1]--;
		}
	}
	for(int i=1;i<=m;i++){
		add[i]+=add[i-1];
		del[i]+=del[i-1];
		ans=min(ans,add[i]+LL(i)*del[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2176
program main;
var a, b, c, d : integer;
begin
    readln(a, b, c, d);

    while(a > 0) and (c > 0) do begin
    c := c - b;
    if c > 0 then 
    a:= a - d;
end;

if c <= 0 then 
    writeln('Yes')
else
    writeln('No');
end.

Measured memory_bytes: 1376
package main

import "fmt"

func main() {
  var D int
  fmt.Scan(&D)
  
  switch D {
  case 22: {
    fmt.Println("Christmas Eve Eve Eve")
    }
  case 23: {
    fmt.Println("Christmas Eve Eve")
    }
  case 24: {
    fmt.Println("Christmas Eve")
    }
  case 25: {
    fmt.Println("Christmas")
    }
  }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
     ios_base ::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int d,t,s;
cin>>d>>t>>s;
if(s*t>=d) cout <<"Yes\n";
else cout <<"No\n";
}

Measured memory_bytes: 3660
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static void solve() throws Exception {
        int a = scanInt();
        out.print(a+ a*a + a*a*a);
    }

    static int scanInt() throws IOException {
        return parseInt(scanString());
    }

    static long scanLong() throws IOException {
        return parseLong(scanString());
    }

    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        }
        catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

Measured memory_bytes: 32840
#include <stdio.h>
#include <stdlib.h>

int main () {
    int N;
    scanf("%d", &N);
    int *A = malloc((1 + N) * sizeof(int));
    double total_mul = 1;
    for (int i = 1; i <= N; i++) {
        scanf("%d", &A[i]);
        total_mul *= A[i];
    }
    double total_plus = 0;
    for (int i = 1; i <= N; i++) {
        total_plus += total_mul / A[i];
    }
    printf("%.9f\n", total_mul / total_plus);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int w[maxn],sum[maxn],minv=inf;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>w[i];
		sum[i]+=w[i];
		sum[i]+=sum[i-1];
	}
	for(int i=1;i<=n;i++)
		minv=min(minv,abs(sum[i]-(sum[n]-sum[i])));
	cout<<minv<<endl;
	return 0;
}




Measured memory_bytes: 256
N = int(input())
Alist = list(map(int,input().split()))
Answer = 0
Amax = Alist[0]
for i in range(1,N):
    Ast = Alist[i]
    if Amax > Ast:
        Answer += Amax - Ast
    else:
        Amax = Ast
print(Answer)


Measured memory_bytes: 32228
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    ll n;
    cin >> n;
    ll ans = infl;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ll j = n / i;
            ans = min(ans, i - 1 + j - 1);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int a, b;
	long c;
	std::cin >> a >> b;
	string ans;
	c = a * b;
	if (c % 2==1) {
		ans = "Odd";
	}
	else {
		ans = "Even";
	}
	for (auto&& x : ans)cout << x; cout << endl;
    return 0;
}



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

using namespace std;

int INF = INT_MAX / 6;
const int MAX_V = 1003;

// ????????¨????§??????? (???????????????????????????)
struct edge { int to, cap, rev; };
vector<edge> G[MAX_V]; // ??°???????????£??\???????????¨???
int level[MAX_V]; // s??????????????¢
int iter[MAX_V]; // ???????????§??????????????£??????
				 // from??????to??????????????????cap???????????°?????????????????????
void add_edge( int from, int to, int cap ) {
	edge a;
	a.to = to;
	a.cap = cap;
	a.rev = G[to].size();
	G[from].push_back( a );
	edge b;
	b.to = from;
	b.cap = 0;
	b.rev = G[from].size() - 1;
	G[to].push_back( b );
}
// s????????????????????¢???BFS??§?¨??????????
void bfs( int s ) {
	memset( level, -1, sizeof( level ) );
	queue<int> que;
	level[s] = 0;
	que.push( s );
	while( !que.empty() ) {
		int v = que.front(); que.pop();
		for( int i = 0; i < G[v].size(); i++ ) {
			edge &e = G[v][i];
			if( e.cap > 0 && level[e.to] < 0 ) {
				level[e.to] = level[v] + 1;
				que.push( e.to );
			}
		}
	}
}
// ?¢?????????????DFS??§??¢???
int dfs( int v, int t, int f ) {
	if( v == t ) return f;
	for( int &i = iter[v]; i < G[v].size(); i++ ) {
		edge &e = G[v][i];
		if( e.cap > 0 && level[v] < level[e.to] ) {
			int d = dfs( e.to, t, min( f, e.cap ) );
			if( d > 0 ) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
// s??????t???????????§???????±???????
int max_flow( int s, int t ) {
	int flow = 0;
	for( ;;) {
		bfs( s );
		if( level[t] < 0 ) return flow;
		memset( iter, 0, sizeof( iter ) );
		int f;
		while( ( f = dfs( s, t, INF ) ) > 0 ) {
			flow += f;
		}
	}
}

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

int main() {
	while( true ) {
		long long int N, M;
		cin >> N >> M;
		if( N == 0 && M == 0 ) {
			break;
		}
		for( size_t i = 0; i < MAX_V; i++ ) {
			G[i].clear();
		}
		vector<int>B( N ), R( M );
		for( size_t i = 0; i < N; i++ ) {
			cin >> B[i];
			add_edge( N + M + 1, i, 1 );
		}
		for( size_t j = 0; j < M; j++ ) {
			int r;
			cin >> r;
			for( size_t i = 0; i < N; i++ ) {
				if( gcd( r, B[i] ) != 1 ) {
					add_edge( i, j + N, 1 );
				}
			}
			add_edge( j + N, N + M + 2, 1 );
		}
		cout << max_flow( N + M + 1, N + M + 2 ) << endl;
	}
}

Measured memory_bytes: 9108
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 
 
void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
 
double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}
 
ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}
 
ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}
 
vec modncrlistp,modncrlistm;
 
ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}
 
ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}
 
ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}
 
ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  startupcpp();
  ll i,j,N,E,F;
  vec sal(2),wat(2);
  rep(i,2)cin>>wat[i];
  rep(i,2)cin>>sal[i];
  cin>>E>>F;
  datas ans=datas(100*wat[0],0),x;
  vec cansal(F+1,0),canwat(F+1,0);
  cansal[0]=canwat[0]=1;
  rep(i,F+1){
    rep(j,2){
      if(i>=sal[j]&&cansal[i-sal[j]])cansal[i]=1;
      if(i>=wat[j]*100&&canwat[i-wat[j]*100])canwat[i]=1;
    }
    if(canwat[i]){
      N=min(i/100*E,F-i);
      while(!cansal[N])N--;
      x.first=i+N;x.second=N;
      if(ans.second*x.first<ans.first*x.second)ans=x;
    }
  }
  cout<<ans.first<<" "<<ans.second<<endl;
  return 0;
}

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

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

    int k;
    cin >> k;
    int a, b;
    cin >> a >> b;
    for(int i = a; i <= b; i++){
        if(i % k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b,c;
  cin>>a;
  b=a;
  while(a){
    c+=a%10;
    a/=10;
  }
  if(b%c==0)cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000 //1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cout << H << " ";
  debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (ll)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// ll        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) ); 
// 大文字65-90(-32)
// 小文字97-122(+32)

int main()
{
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n,k;cin >> n >> k;
  vector<ll> p(n,0);
  rep(i,n){
    cin >> p[i];
  }
  ll res = -1;
  if(k==1){
    res = MAX(p);
  }else{
    repz(i,1,n){
      p[i]=p[i-1]+p[i];
      debug(p[i]);
    }
    if(k==n){
      res=p[n-1];
    }else{
      for(ll i=0;i+k<n;i++){
        res = max(p[i+k]-p[i], res);
      }
    }
  }

  cout << fixed << setprecision(15) << (double)(res+k)*0.5 << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define inf 10000000000000007
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

string s, t;

signed main() {
	cin >> s >> t;
	rep(i, s.size()) {
		s = s[s.size() - 1] + s.substr(0, s.size() - 1);
		if (s == t) {
			cout << "Yes" << endl;
			ggr
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int A0, A1, A2;
  scanf("%d %d %d", &A0, &A1, &A2);
  
  int res = 0;
  
  if(A0 < A1)
  {
    if(A1 < A2)		res = A2 - A0;
    else
    {
      if(A0 < A2)	res = A1 - A0;
      else			res = A1 - A2;
    }
  }
  else
  {
    if(A1 < A2)
    {
      if(A0 < A2)	res = A2 - A1;
      else			res = A0 - A1;
    }
    else			res = A0 - A2;
  }
  
  printf("%d\n", res);
  
  return 0;
}

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

int main()
{
	int a[3] = { 3,8,1 };

	std::cin >> a[0] >> a[1] >> a[2];
	std::sort(a, a + 3);

	std::cout << a[0] << " " << a[1] << " " << a[2] << std::endl;
	
    return 0;
}

Measured memory_bytes: 3120
N = int(input())
A = list(map(int, input().split()))

A = sorted(A, key=lambda x: x)
all = [True] * 1000001
ans = 0
for i in range(N):
    if all[A[i]] == False:
        continue
    if i == N - 1 or A[i+1] > A[i]:
        ans += 1
    b = A[i]
    while b < 1000001:
        all[b] = False
        b += A[i]

print(ans)

Measured memory_bytes: 109392
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    int N, K;
    cin >> N >> K;

    vector<long> hs;
    long H;
    for (int i = 0; i < N; ++i) {
        cin >> H;
        hs.push_back(H);
    }

    sort(hs.begin(), hs.end(), greater<long>());

    long cnt = 0;
    for (int i = K; i < N; ++i) {
        cnt += hs[i];
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 2420
N, A, B = map(int,input().split())
s = input()
accepted = 0
acceptedab = 0
for i in range(len(s)):
  if s[i] == 'a' and accepted < (A + B):
    print('Yes')
    accepted += 1
  elif (s[i] == 'b') and (acceptedab <B) and (accepted <(A+B)):
    print('Yes')
    accepted +=  1
    acceptedab += 1
  else:
    print('No')

Measured memory_bytes: 4372
//Create Time: 2018-04-21 20:19:58
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <functional>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <ctime>
#include <utility>
#include <complex>
#include <cassert>
#include <climits>
#include <iterator>
#include <tuple>
using namespace std;
#define snuke(i,x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,n,a) for (int i=(n)-1;i>=(a);i--)
// #define OUT(x) std::cout<<(#x)<<":"<<(x)<<std::endl
// #define TST(x) std::cout<<(#x)<<":"<<(x)<<" "
#define OUT(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("\n",_it,args);}
#define TST(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("",_it,args);}
#define SZ(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define unq(x) sort(all(x)),(x).erase(unique(all(x)),(x).end())
#define mem(f,x) memset((f), (x), sizeof(f))
#define clr(f) mem(f,0)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define DEBUG
void OUT_TST(string s,istream_iterator<string> it) {cerr<<s;}
template<typename T, typename... Args> void OUT_TST(string s,istream_iterator<string> it,T a,Args... args){cerr<<*it<<"="<<a<<" ";OUT_TST(s,++it,args...);}
template<class T> void rd(T&ret){ret=0;bool ok=0,u=0;for(;;){int c=getchar();if(c>='0'&&c<='9')ret=(ret<<3)+(ret<<1)+c-'0',ok=1;else if(c=='-')u=1;else if(ok){if(u)ret*=-1;return;}}}
long long powmod(long long p,long long n,long long mod){long long ret=1;for(;n;n>>=1){if(n&1)ret=ret*p%mod;p=p*p%mod;}return ret;}
template <class T> bool chmin(T& a, const T &b) {return b < a? a = b, 1: 0;}
template <class T> bool chmax(T& a, const T &b) {return b > a? a = b, 1: 0;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii > vii;
/****head****/
const int N=(int)1e5+9;
typedef pair<ll, ll> pll;
pll an[N];
pll bn[N];
ll calc(int n,ll c,pll *a){
    int top=0;
    ll get=0,ans=0;
    rep(i,0,n){
        get+=an[i].y-an[i].x;
        if(i) get+=an[i-1].x;
        if(top==0 || bn[top-1].y<get)bn[top++]={(ll)i,get};
        chmax(ans,get);
    }
    get=0;
    ll t;
    per(i,n,0){
        if(i==n-1)get+=an[i].y-(c-an[i].x);
        else get+=an[i].y-(an[i+1].x-an[i].x);
        if(top && bn[top-1].x>=i)--top;
        t=get;
        if(top && bn[top-1].y>c-an[i].x)t+=bn[top-1].y-(c-an[i].x);
        chmax(ans,t);
    }
    return ans;
}
        
    
int main(){
    int n;ll c;cin>>n>>c;
    rep(i,0,n)scanf("%lld%lld",&an[i].x,&an[i].y);
    ll ans=calc(n,c,an);
    reverse(an,an+n);
    rep(i,0,n)an[i].x=c-an[i].x;
    chmax(ans,calc(n,c,an));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    private struct Pair { public int x, y; }
    public static void Main()
    {
        int N = NextInt();
        int M = NextInt();
        int[] dp = new int[N + 1];
        int[] count = new int[N + 1];
        List<int>[] e = new List<int>[N + 1];
        for (int i = 1; i <= N; i++) e[i] = new List<int>();
        for (int i = 0; i < M; i++)
        {
            int x = NextInt();
            int y = NextInt();
            count[y]++;
            e[x].Add(y);
        }

        Queue<int> queue = new Queue<int>();
        for (int i = 1; i <= N; i++) if (count[i] == 0) queue.Enqueue(i);
        while (queue.Count() != 0)
        {
            int x = queue.Dequeue();
            foreach (var xx in e[x])
            {
                count[xx]--;
                dp[xx] = Math.Max(dp[xx], dp[x] + 1);
                if (count[xx] == 0) queue.Enqueue(xx);
            }
        }
        Console.WriteLine(dp.Max());
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 26292
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> v(h);
    for (auto &&i : v) cin >> i;
    int ans = INF<int>;
    auto dp = make_v(h, w, 0);
    vector<int> cnt(h);
    for (int a = 0; a < (1 << (h-1)); ++a) {
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                dp[i][j] = 0;
            }
            cnt[i] = 0;
        }
        int cur = 0;
        int ok = 1;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                dp[cur][j] += v[i][j] - '0';
            }
            if(a & (1 << i)) cur++;
        }
        int val = cur++;
        int l = 0;
        for (int j = 0; j < w; ++j) {
            int good = 1;
            for (int i = 0; i < cur; ++i) {
                cnt[i] += dp[i][j];
                if(cnt[i] > k){
                    good = 0;
                }
            }
            if(!good){
                if(j == l) {
                    ok = 0;
                    break;
                }else {
                    val++;
                    l = j;
                    for (int i = 0; i < cur; ++i) {
                        cnt[i] = dp[i][j];
                    }
                }
            }
        }
        if(ok){
            ans = min(ans, val);
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;
 
template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

string pop(vstring &v) {
  string s = v.back();
  v.pop_back();
  return s;
}

int main() {
  int n;
  while (cin >> n) {
    vstring xx, xa, bx, ba;
    REP(i,n) {
      string s; cin >> s;
      bool a = s[s.length() - 1] == 'A';
      bool b = s[0] == 'B';
      if (a && b) ba.push_back(s);
      else if (b) bx.push_back(s);
      else if (a) xa.push_back(s);
      else xx.push_back(s);
    }

    string result = "";
    REP(iter,n) {
      if (result.size() && result[result.length()-1] == 'A') {
        if (ba.size()) result += pop(ba);
        else if (bx.size()) result += pop(bx);
        else if (xa.size()) result += pop(xa);
        else result += pop(xx);
      } else {        
        if (xa.size()) result += pop(xa);
        else if (ba.size()) result += pop(ba);
        else if (bx.size()) result += pop(bx);
        else result += pop(xx);
      }
    }

    int ans = 0;
    REP(i,result.length()-1) if (result[i] == 'A' && result[i+1] == 'B') ++ans;
    cout << ans << endl;
  }
}


Measured memory_bytes: 952
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

template<typename T>
struct Monoid {
  T id;
  fn<T(T, T)> op;
  Monoid(T e, fn<T(T, T)> f)
    : id(e), op(f) {
  }
};

template<typename T>
class SegT {
private:
  vector<T> data;
  Monoid<T> monoid;
  int size = 1;

public:
  SegT(const int &n, const Monoid<T> &m = Monoid<int>(INF, [](int a, int b) { return min(a, b); }))
    : monoid(m) {
    while (size < n) size *= 2;
    data = vector<T>(2 * size, monoid.id);
  }

  void update(int i, const T &x) {
    i += size;
    data[i]                = x;
    while (i /= 2) data[i] = monoid.op(data[i * 2], data[i * 2 + 1]);
  }

  T fold(const int &a, const int &b, const int &k = 1, const int &l = 0, int r = -1) {
    if (r == -1) r = size;
    if (b <= l || r <= a) return monoid.id;
    if (a <= l && r <= b) return data[k];
    return monoid.op(fold(a, b, 2 * k, l, (l + r) / 2), fold(a, b, 2 * k + 1, (l + r) / 2, r));
  }

  const T &operator[](const int &i) const {
    return data[i + size];
  }
};

void solve() {
  int n, q;
  cin >> n >> q;
  SegT<int> t(n, Monoid<int>(0, plus<int>()));
  while (q--) {
    int com, x, y;
    cin >> com >> x >> y;
    x--;
    if (com) {
      cout << t.fold(x, y) << endl;
    } else {
      t.update(x, t[x] + y);
    }
  }
}

Measured memory_bytes: 4944
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void){
    char S[10000];
    int i,sum,len;
    scanf("%s",S);
    sum = 0;
    len = strlen(S);
    for(i=0;i<len;i++){
        sum += (S[i] - '0');
    }
    int Si;
    Si = atoi(S);
    // printf("%d %d\n",sum,Si);
    if(Si % sum == 0){
        printf("Yes\n");
    }else{
        printf("No");
    }
    return 0;  
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"

	"strings"
)

func solve(in io.Reader, out io.Writer) error {
	sc := bufio.NewScanner(in)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	s := sc.Text()

	if strings.Index(s, "a") < 0 || strings.Index(s, "b") < 0 || strings.Index(s, "c") < 0 {
		fmt.Fprintln(out, "No")
		return nil
	}

	fmt.Fprintln(out, "Yes")
	return nil
}

func main() {
	err := solve(os.Stdin, os.Stdout)
	if err != nil {
		log.Fatal(err)
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    double ans = 0.0;
    double _x = fabs(x2 - x1);
    double _y = fabs(y2 - y1);
    ans = sqrt(pow(_x, 2) + pow(_y, 2));
    cout << fixed << setprecision(6) << ans << endl;

    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;
int main(){
  int n,t;
  cin >> n;
  string ts;
  vector<pair<string,pair<int,int>>> p;
  for(int i=0;i<n;i++){
    cin >> ts >> t;
    p.push_back(make_pair(ts,make_pair(100-t,i+1)));
  }
  sort(p.begin(),p.end());
  for(int i=0;i<n;i++){
    cout << p[i].second.second<< endl;
  }
}


Measured memory_bytes: 256
package main
  
import (
    "fmt"
)

func main() {
    const mod = 1e9 + 7
    var n, m int
    fmt.Scan(&n, &m)
    s := make([]int, n)
    t := make([]int, m)
    for i := 0; i < n; i++ {
        fmt.Scan(&s[i])
    }
    for i := 0; i < m; i++ {
        fmt.Scan(&t[i])
    }
    dp := make([][]int, n+1)
    for i := 0; i < n+1; i++ {
        dp[i] = make([]int, m+1)
    }
    for i := 1; i <= n; i++ {
        for j := 1; j <= m; j++ {
            if s[i-1] == t[j-1] {
                dp[i][j] += (dp[i-1][j] + dp[i][j-1] + 1) % mod
            } else {
                dp[i][j] += (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % mod
                if dp[i][j] < 0 {
                    dp[i][j] += mod
                }
            }
        }
    }
    fmt.Println(dp[n][m] + 1)
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N * 3);
  for (int i = 0; i < N * 3; i++) cin >> A.at(i);
  sort(A.rbegin(), A.rend());
  long ans = 0;
  for (int i = 1, cnt = 0; cnt < N; i += 2, cnt++) ans += A.at(i);
  cout << ans << "\n";
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >>n ;
    bool f = true;
    int x;
    for(int i=0;i<n;i++){
        cin >> x ;
        if(x % 2 == 0 &&(x % 3 != 0 && x %5 != 0)){
            f = false;
        }
    }
    cout << (f?"APPROVED":"DENIED") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
  ll A=0,B=0,C=0,D=0,E=0,F=0,N=0,M=0,K=0,L=0,R=0,H=0,W=0;
  string S,T;
  cin >> A >> B;
  if(A+B==15){
    cout << "+" << endl;
  }
  else if(A*B==15){
    cout << "*" << endl;
  }
  else{
    cout << "x" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#define fre
#define DEBUG
using namespace std;
char s[100005];
int lat[26];
int main()
{
    bool f = false;
    memset(lat, -1, sizeof(lat));
    scanf("%s", s);
    for (int i = 0; s[i]; ++i)
    {
        if (lat[s[i] - 'a'] == -1) lat[s[i] - 'a'] = i;
        else 
        {
            if (i - lat[s[i] - 'a'] <= 2) 
            { 
                printf("%d %d\n", lat[s[i] - 'a'] + 1, i + 1);
                f = true;
                break;
            }
            lat[s[i] - 'a'] = i;
        }
    }
    if (!f) printf("-1 -1\n");
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> a(M);
  vector<int> b(M);
  
  for (int i = 0; i < M; i++) {
	cin >> a.at(i) >> b.at(i);
  }
  
  vector<int> city(N);
  
  for (int i = 0; i < N; i++) {
    city.at(i) = 0;
  }
  
  for (int i = 0; i < N; i++) {
	for (int j = 0; j < M; j++) {
      if ( a.at(j) == i+1 ) { 
        city.at(i) = city.at(i) + 1;
      }
      else if ( b.at(j) == i+1 ) { 
        city.at(i) = city.at(i) + 1;
      }
    }
  }
 
  for (int i = 0; i < N; i++) {
    cout << city.at(i) << endl;
  } 
       
}

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

void findDivisors(ll n, vector<ll>& div) 
{
	for (ll i = 1; i <= n; i += 1) {
		for (ll j = 1; j*i <= n; j += 1) {
			div[i * j]++;
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	cout.tie(NULL);
	ll n;	cin >> n;
	vector<ll> div(n+1);
	findDivisors(n, div);
	unsigned long long int ans = 1;
	for (int i = 2; i <= n; i += 1) {
		ans += i*div[i];
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 81308
#!/usr/bin/env python3
import collections

H, W, M = map(int, input().split())
tate = []
yoko = []
S = set()

for i in range(M):
    h, w = map(int, input().split())
    tate.append(h-1)
    yoko.append(w-1)
    S.add((h-1, w-1))

tate = collections.Counter(tate)
yoko = collections.Counter(yoko)
yoko_max = yoko.most_common()[0][1]
yoko_index = []
tate_max = tate.most_common()[0][1]
tate_index = []

for k, v in yoko.most_common():
    if v == yoko_max: yoko_index.append(k)
    else: break

for k, v in tate.most_common():
    if v == tate_max: tate_index.append(k)
    else: break

for i in yoko_index:
    for j in tate_index:
        if (j, i) in S:
            continue
        else:
            print(tate_max + yoko_max)
            exit()


print(tate_max + yoko_max - 1)


Measured memory_bytes: 185608
n,q = map(int,input().split())
s = list(input())
l = [0]*q
r = [0]*q
for i in range(q):
    l[i], r[i] = map(int,input().split())

lis = [0]
for i in range(1,n):
    if s[i-1] == 'A' and s[i] == 'C':
        lis.append(lis[i-1]+1)
    else:
        lis.append(lis[i-1])
# print(s)
# print(lis)
for i in range(q):
    print(lis[r[i]-1] - lis[l[i]-1])


Measured memory_bytes: 14816
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const int NMAX = 2000;
const int MOD = 1000000007;

vector<ll> fac(NMAX+1);
vector<ll> inv(NMAX+1);
vector<ll> fnv(NMAX+1);
vector<ll> power(NMAX+1);

void com_init(){
    
    fac[0]=1LL;
    fac[1]=1LL;
    inv[0]=0LL;
    inv[1]=1LL;
    fnv[0]=1LL;
    fnv[1]=1LL;
    
    for(int i=2; i<NMAX+1; i++){
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - (MOD/i) * inv[MOD%i] % MOD;
        fnv[i] = fnv[i-1] * inv[i] % MOD;
    }
    return;
}

ll combi(int n, int k){
    if(n<k)return 0LL;
    if(k<0 || n<0 )return 0LL;
    
    return fac[n] * (fnv[k]*fnv[n-k] % MOD) % MOD;
}


int main() {
    int n,k;cin>>n>>k;
    
    com_init();
    
    //i=1
    cout<< n-k+1 << endl;
    
    for(int i=2; i<=k; i++){
        if(i>n-k+1){
            cout << 0 << endl;
            continue;
        }
        
        ll ans = 0;
        
        ans += combi(n-k-1, i-2);
        ans += combi(n-k-1, i-1);
        ans += combi(n-k-1, i-1);
        ans += combi(n-k-1, i);
        
        ans %= MOD;
        
        ans *= combi(k-1, i-1);
        ans %= MOD;
        
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  int K,A,B,i,ans = 0;

  scanf("%d",&K);
  scanf("%d %d",&A,&B);

  for(i = A;i <= B;i++){
    if(i % K == 0){
      ans = 1;
      break;
    }
  }

  if(ans == 1) printf("OK\n");
  else printf("NG");
  return 0;
}


Measured memory_bytes: 1728
#include <stdio.h>
#include <math.h>
void main()
{
  int a,b,h,m;
  double c;
  scanf("%d %d %d %d", &a, &b, &h, &m);
  double r;
  r = ((h/6.0) - (11.0*m/360.0))*M_PI;
  c = sqrt(a*a + b*b - 2*a*b*cos(r));
  printf("%.15f\n", c);
}

Measured memory_bytes: 2600
N = int(input())
A = list(map(int, input().split()))

L = []
for i, v in enumerate(A):
    if (1 <= v and v <= 399):
        L.append('灰色')
    elif(400 <= v and v <= 799):
        L.append('茶色')
    elif(800 <= v and v <= 1199):
        L.append('緑色')
    elif(1200 <= v and v <= 1599):
        L.append('水色')
    elif(1600 <= v and v <= 1999):
        L.append('青色')
    elif(2000 <= v and v <= 2399):
        L.append('黄色')
    elif(2400 <= v and v <= 2799):
        L.append('橙色')
    elif(2800 <= v and v <= 3199):
        L.append('赤色')
    else:
        L.append('自由')

J = [i for i in L if i == '自由']
L = list(set(L))
if ('自由' in L):
    L.remove('自由')
if (len(L) == 0 and len(J) != 0):
    L.append('自由')
    J.pop(0)
print(len(L), len(L) + len(J))


Measured memory_bytes: 3064
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
#from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
medi = sum(A)/n
#print(medi)
medi = int(medi) if medi - int(medi) < 0.5 else int(medi) + 1
ans = 0
#print(medi)
for i in range(n):
    ans += abs(A[i] - medi)**2
print(ans)


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

int main(){
  string S;
  cin >> S;
  long long count = 0, ans = 0;
  int slen = S.size(), i=0;
  while(i<slen-1){
    if (S[i]=='A'){
      count++;
      i++;
    }
    else if (S[i]=='B'&&S[i+1]=='C'){
      ans += count;
      i += 2;
    }
    else {
      count = 0;
      i++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int maxn=5e5+5;
char s[maxn],ch;
set<int> pos[26];
int n,t,opt,x,y;
int main(){
    scanf("%d %s %d",&n,s+1,&t);
    for(int i=0;i<=25;i++){
        pos[i].insert(n+1);
    }
    for(int i=1;i<=n;i++){
        pos[s[i]-'a'].insert(i);
    }
    while(t--){
        scanf("%d",&opt);
        if(opt==1){
            scanf("%d %c",&x,&ch);
            if(s[x]!=ch){
                pos[s[x]-'a'].erase(x);
                pos[ch-'a'].insert(x);
                s[x]=ch;
            }
        }else{
            scanf("%d %d",&x,&y);
            int ans=0;
            for(int i=0;i<=25;i++){
                if(*pos[i].lower_bound(x)<=y){
                    ans++;
                }
            }
            printf("%d\n",ans);
        }
    }
    return 0;
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

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

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

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

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  VAR(int, A, B, C);
  OUTL(min(B / A, C));
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[105];
void delte(int x){
    int cnt = 0;
    for(int i=1;i<=n;i++){
        if(i==x)continue;
        a[++cnt]=a[i];
    }
    n=cnt;
}
vector<int> ans;
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++){cin>>a[i];}
    int t = 200;
    while (t--){
        for(int i=n;i>=1;i--){
            if(a[i]==i) {
                ans.push_back(a[i]);
                delte(i);
                break;
            }
        }
    }
    if(n==0){
        reverse(ans.begin(),ans.end());
        for(auto x:ans)cout<<x<<endl;
    } else
        cout<<-1;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    int r;
    cin >> r;
    cout << 3*r*r << endl;
}

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

namespace CompetitiveProgCsLib
{
	class MainProg
	{
		static string R => Console.ReadLine();
		static int RI => int.Parse(R);
		static double RD => double.Parse(R);
		static int[] RIs => R.Split(' ').Select(int.Parse).ToArray();
		static double[] RDs => R.Split(' ').Select(double.Parse).ToArray();
		static void Out(object obj) => Console.WriteLine(obj);
		static void OutLine<T>(IEnumerable<T> obj, string separateChar) => Out(String.Join(separateChar, obj));
		static void Outb(bool b) => Out(b ? "Yes" : "No");
		static void OutB(bool b) => Out(b ? "YES" : "NO");
		static bool IsIn(int y, int x, int h, int w) => 0 <= x && x < w && 0 <= y && y < h;

		static void Main(string[] args)
		{
			var nmd = RIs;
			long n = nmd[0];
			long m = nmd[1];
			long d = nmd[2];
			double ans;
			if (d == 0) ans = 1.0 / n;
			else ans = (2 * (n - 2 * d) + 2 * d) / (double)n / (double)n;
			Out(ans * (m-1));
		}
	}
}


Measured memory_bytes: 13396