akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
// headers {{{
using namespace std;
// using namespace rel_ops;
 
typedef long long int64;
typedef unsigned long long uint64;
const double pi=acos(-1.0);
const double eps=1e-11;
const int INF=0x7FFFFFFF;
template<class T> inline bool checkmin(T &a,T b){return b<a?a=b,1:0;}
template<class T> inline bool checkmax(T &a,T b){return b>a?a=b,1:0;}
template<class T> inline T sqr(T x){return x*x;}
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define mem(a,b) memset(a, b, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a))
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ff first
#define ss second
#ifdef LOCAL
#define dbg(args...) printf(args); //##__VA_ARGS__
#define dout cout
#define out(x) (cout<<#x<<": "<<x<<endl)
template<class T>void show(T a, int n){for(int i=0; i<n; ++i) cout<<a[i]<<' '; cout<<endl;}
template<class T>void show(T a, int r, int l){for(int i=0; i<r; ++i)show(a[i],l);cout<<endl;}
#else
#define dbg(...)
#define dout if(true);else cout
#define out(...)
#define show(...)
#endif
// }}}

int main() {
    int64 a, b, c;
    char ch;
    while (cin >> a >> b>>ch>>c) {
        int64 ans =a * b + a * c / 100;
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 2e5 + 7;
struct node{ll x, y;}q[MAXN];
int n; ll C; 
ll h[MAXN], dp[MAXN];
inline bool check(node &a, node &b, node &c) {return (c.y - b.y) * (b.x - a.x) < (b.y - a.y) * (c.x - b.x);}
inline ll cal(node &a, ll h) {return a.y - a.x * h + h * h + C;}

int main()
{
    scanf("%d%lld", &n, &C);
    for (int i = 1; i <= n; i++) scanf("%lld", &h[i]);
    int head = 0, tail = 0; q[tail++] = {h[1] * 2, dp[1] + h[1] * h[1]};
    for (int i = 2; i <= n; i++)
    {
        while (head + 1 < tail && cal(q[head + 1], h[i]) < cal(q[head], h[i])) head++;
        dp[i] = cal(q[head], h[i]);
        node now = {h[i] * 2, dp[i] + h[i] * h[i]};
        while (tail - head >= 2 && check(q[tail - 2], q[tail - 1], now)) tail--;
        q[tail++] = now;
    }
    printf("%lld\n", dp[n]);
    return 0;
}

Measured memory_bytes: 6528
a,b,c,d = map(int, input().split())
if a >=0:
    if c > 0:
        print(b * d)
    elif d < 0:
        print(a * d)
    else:
        print(b*d)

elif a < 0 and b >= 0:
    if c >= 0:
        print(b * d)
    elif d <= 0:
        print(a * c)
    else:
        ac = a * c
        bd = b * d
        if ac >= bd:
            print(ac)
        else:
            print(bd)
else:
    if c >= 0:
        print(b * c)
    elif d <= 0:
        print(a * c)
    else:
        print(a * c)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N, M;
constexpr int Nmax = 200000;
vector<int> A(Nmax);
vector<int> count_(Nmax + 1);
vector<int> dup(Nmax + 1);

int main()
{
    cin >> N >> M;
    REP(i, N)
    {
        cin >> A[i];
        if (A[i] - count_[A[i]] > 0) dup[A[i] - count_[A[i]]]++;
        count_[A[i]]++;
    }

    int invans = 0;
    REP(i, N) if (dup[i + 1]) invans++;

    REP(_, M)
    {
        int X, Y;
        cin >> X >> Y;

        int del = A[X - 1];
        count_[del]--;
        if (del - count_[del] > 0)
        {
            dup[del - count_[del]]--;
            if (dup[del - count_[del]] == 0) invans--;
        }
 
        A[X - 1] = Y;
        if (Y - count_[Y] > 0)
        {
            dup[Y - count_[Y]]++;
            if (dup[Y - count_[Y]] == 1) invans++;
        }
        count_[Y]++;

        cout << N - invans << endl;
    }
}


Measured memory_bytes: 3840
N, Y = map(int, input().split())
Y //= 1000
p = [-1, -1, -1]
for i in range(N + 1):
  s = 0
  for j in range(N - i + 1):
    if 9 * i + 4 * j == Y - N:
      p = [i, j, N - i - j]
      s += 1
      break
  if s == 1:
    break
print(p[0], p[1], p[2])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int s,w;
  cin>>s>>w;
  if(w>=s) cout<<"unsafe"<<endl;
  else cout<<"safe"<<endl;
  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<n;++i)

typedef long long ll;
using namespace std;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i, h)cin >> s[i];
    vector<string> ans(h);

    REP(i, h){
        REP(j, w){
            if(s[i][j]=='.'){
                int cnt = 0;
                for(int k=i-1;k<=i+1;++k){
                    for(int l=j-1;l<=j+1;++l){
                        if(k<0 || k>=h || l<0 || l>=w)continue;
                        if(k==i && l==j)continue;
                        if(s[k][l]=='#')++cnt;
                    }
                }
                ans[i] += to_string(cnt);
            } else {
                ans[i] += '#';
            }
        }
    }

    REP(i, h){
        cout << ans[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
template <typename T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll n, m, k;
    cin >> n >> m >> k;

    bool ok = false;
    rep(i, n + 1) {
        rep(j, m + 1) {
            if (k == j * n + i * m - 2 * i * j) ok = true;
        }
    }

    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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 inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> dp(n+1,inf);
    dp[0] = 0;
    rep(i,n) {
        chmin(dp[i+1],dp[i]+1);
        int now = 6;
        while(i+now <= n) {
            chmin(dp[i+now],dp[i]+1);
            now *= 6;
        }
        now = 9;
        while(i+now <= n) {
            chmin(dp[i+now],dp[i]+1);
            now *= 9;
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>


using namespace std;
 
int main() {
  int N, M;
  int sum = 0;

  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }

  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) {
    cin >> t.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    int count = 0;
    string cmd = s.at(i);
    for (int j = 0; j < N; j++) {
        if (s.at(j) == cmd) {
            count++;
        }
    }
    for (int j = 0; j < M; j++) {
        if (t.at(j) == cmd) {
            count--;
        }
    }
    if (count > sum) {
      sum = count;
    }
  }

  
  cout << sum;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

void solve() {
	int n, k; cin >> n >> k;
    vector<int> a(n), sum(n + 1, 0);
    rep(i, n) {
        cin >> a[i];
        sum[i + 1] = sum[i] + a[i];
    }
    vector<int> sub;
    for(int l = 0; l < n; ++l) {
        for(int r = l + 1; r <= n; ++r) {
            int t = sum[r] - sum[l];
            sub.pb(t);
        }
    }
    int ans = 0;
    for(int bit = 40; bit >= 0; --bit) {
        int cnt = 0;
        vector<int> sub1;
        for(auto& u: sub) {
            if(u & (1LL<<bit)) {
                sub1.pb(u);
                cnt ++;
            }
        }
        if(cnt < k) continue;
        else {
            swap(sub, sub1);
            ans += (1LL<<bit);
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 6512
import java.util.*;
import java.util.Map.Entry;
 
 
 
public class Main{
	
	
	
	public static long A;
	public static long answer = 0;
	public static long MOD=1000000007;
	

 
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd(long a, long b) {
		if (b == 0) {
			return a;			
		}
		return gcd(b, a % b);
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}
 
 
 
	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
 
 
	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}
 
 
	//階乗
	static long factorial (int k) {
		long sum = 1;
		for(int i=1;i<=k;i++) {
			sum = (sum*i)%MOD;
		}
		return sum;
		
	}
 
 
	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	public static int H,W;
	public static char[][] c;
	public static boolean[][] b;
	
	

    
	
	
 public static void main(String[] args) {
	 
	 Scanner sc=new Scanner(System.in);
	 int N=sc.nextInt();
	 
	 long A=0,B=0,AB=0,SAB=0;
	 
	 for(int i=0;i<N;i++) {
		 char[] c=sc.next().toCharArray();
		 if(c[0]=='B'&&c[c.length-1]=='A') {
			 SAB++;
		 }else if(c[0]=='B') {
			 B++;
		 }else if(c[c.length-1]=='A'){
			 A++;
		 }
		 
		 for(int j=0;j<c.length;j++) {
			 if(j+1<c.length&&c[j]=='A'&&c[j+1]=='B') {
				 AB++;
			 }
			 
	 }
	 }
	 
	 long result = AB;
	 
	 if(SAB==0&&A+B!=0) {
		 result+=Math.min(A, B);
	 }else if(A+B!=0&&SAB!=0) {
		 result+=(Math.min(A, B)+SAB);
	 }else if(SAB!=0&&A+B==0) {
		 result+=(SAB-1);
	 }
	 
	 System.out.println(result);
	
}
 
 
}

Measured memory_bytes: 29796
#include<iostream>
#include<ctype.h>

using namespace std;

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

Measured memory_bytes: 3620
while True:
    try:
        str = input()
        ans = ''
        # flag
        n = 1
        
        for c in str:
            if '@' == c:
                n = 0
            elif n < 1:
                n = int(c)
            else:
                ans += c * n
                n = 1
        print(ans)
    except:
        break
        


Measured memory_bytes: 5588
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
    var a = Number(inputs[0]);
    var b = Number(inputs[1]);
    var c = Number(inputs[2]);

    if (a < b && b < c) {
        console.log('Yes');
    } else {
        console.log('No');
    }

});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15536
n = int(input())
d = {}
for i in range(n-1):
    u,v,w = map(int,input().split())
    if u-1 not in d:
        d[u-1] = []
        d[u-1].append([v-1,w])
    else:
        d[u-1].append([v-1,w])
    if v-1 not in d:
        d[v-1] = []
        d[v-1].append([u-1,w])
    else:
        d[v-1].append([u-1,w])

ch = [False]*n
res = [-1]*n
q =[0]
res[0] = 0
ch[0] = True
while q != []:
     t = q.pop(0)
     for l in d[t]:
         if ch[l[0]] == True:
             continue
         else:
             ch[l[0]] = True
             res[l[0]] = res[t] + l[1]
             q.append(l[0])
for i in range(n):
    print(res[i]%2)

Measured memory_bytes: 58356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)


void solve(long long N, long long X, long long Y){
    X--; Y--;

    vector<vector<ll>> net(N);
    REP(i, N - 1){
        net.at(i).push_back(i + 1);
        net.at(i + 1).push_back(i);
    }
    net.at(X).push_back(Y);
    net.at(Y).push_back(X);

    vector<ll> count(N, 0);
    REP(s, N){
        vector<ll> dist(N, -1);
        dist.at(s) = 0;
        queue<ll> que;
        que.push(s);
        while(!que.empty()){
            ll cur = que.front(); que.pop();
            for(ll nxt : net.at(cur)){
                if(dist.at(nxt) != -1){ continue; }
                dist.at(nxt) = dist.at(cur) + 1;
                que.push(nxt);
            }
        }
        for(ll t = s + 1; t < N; ++t){
            count.at(dist.at(t))++;
        }
    }

    for(ll d = 1; d < N; ++d){
        cout << count.at(d) << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(N, X, Y);
    return 0;
}


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

using namespace std;

int main()
{
    int n;

    cin >> n;

    int a = n % 10;

    if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9)
    {
        cout << "hon\n";
    }
    else if (a == 0 || a == 1 || a == 6 || a == 8)
    {
        cout << "pon\n";
    }
    else
    {
        cout << "bon\n";
    }

        return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
int main(void)
{
	int a,b,c,d,x,y;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	x=a+b;
	y=c+d;
	if(x<y){
		printf("Right\n");
	}
	else if(x==y){
		printf("Balanced\n");
	}
	else{
		printf("Left\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define   ll          long long int
#define   sz          200010
#define   sc(a)       scanf("%lld",&a)
#define   sc2(a,b)    scanf("%lld %lld",&a,&b)
#define   py          printf("Yes\n")
#define   pn          printf("No\n")
using namespace std;


ll num[sz];



int main()
{


     ll n,i,j,k,d,p,s=0;

     cin>>n;

     d=n*(n-1);
     d/=2;

     cout<<d<<endl;




    return 0;
}



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

typedef long long ll;
const int maxn = 200005;
const ll mod = 1e9+7;
const int MAX_int = 1e9;
const double eps = 1e-9;
int vis[105];
int relation[105][105];
int match[105];
int n;
struct node
{
    int a,b;
} p[105],q[105];

bool find(int x)
{
    for (int j=1; j<=n; j++)
    {
        if (relation[x][j]==1 && vis[j]==0)
        {
            vis[j]=1;
            if (match[j]==0 || find(match[j]))
            {
                //名花无主或者能腾出个位置来，这里使用递归
                match[j]=x;
                return true;
            }
        }
    }
    return false;
}

int main()
{
    memset(match,0,sizeof(match));
    memset(relation,0,sizeof(relation));
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d%d",&p[i].a,&p[i].b);
    for(int i=1; i<=n; i++)
        scanf("%d%d",&q[i].a,&q[i].b);
    for(int i=1; i<=n; i++)
        for(int j=1; j<=n; j++)
            if(p[i].a <q[j].a && p[i].b <q[j].b)
                relation[i][j]=1;

    int cnt=0;
    for (int i=1; i<=n; i++)
    {
        memset(vis,0,sizeof(vis));    //这个在每一步中清空
        if (find(i))
            cnt++;
        }
    printf("%d\n",cnt);
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN	200005
#define INF	1e9
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
vector <int> a[MAXN];
int l[MAXN], r[MAXN], size[MAXN], n;
int mx[MAXN], home[MAXN], nx[MAXN];
char s[MAXN];
void updmin(int &x, int y) {
	x = min(x, y);
}
void updmax(int &x, int y) {
	x = max(x, y);
}
void update(int x, int y) {
	int value;
	if (home[y] == x) value = nx[y] + 1;
	else value = mx[y] + 1;
	if (value > mx[x]) {
		nx[x] = mx[x];
		mx[x] = value;
		home[x] = y;
	} else updmax(nx[x], value);
}
void dfs1(int pos, int fa) {
	size[pos] = s[pos] == '1';
	if (size[pos]) updmin(l[pos], 0);
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (a[pos][i] != fa) {
			dfs1(a[pos][i], pos);
			update(pos, a[pos][i]);
			size[pos] += size[a[pos][i]];
			if (size[a[pos][i]]) updmin(l[pos], mx[a[pos][i]] + 1);
		}
}
void dfs2(int pos, int fa) {
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (a[pos][i] != fa) {
			update(a[pos][i], pos);
			dfs2(a[pos][i], pos);
			if (size[1] - size[a[pos][i]]) {
				if (home[pos] == a[pos][i]) updmin(l[a[pos][i]], nx[pos] + 1);
				else updmin(l[a[pos][i]], mx[pos] + 1);
			}
		}
	r[pos] = min(mx[pos] - 1, nx[pos] + 1);
}
int main() {
	read(n);
	for (int i = 1; i < n; i++) {
		int x, y;
		read(x), read(y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	scanf("%s", s + 1);
	for (int i = 1; i <= n; i++)
		l[i] = INF;
	dfs1(1, 0);
	dfs2(1, 0);
	long long ans = 0;
	for (int i = 1; i <= n; i++)
		if (r[i] >= l[i]) ans += r[i] - l[i] + 1;
	cout << ans + 1 << endl;
	return 0;
}

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

#define MAX(A,B) \
  ( (B) > (A) ? (B) : (A) )

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int q;
  int i;

  scanf ( "%d", &q );
  while ( q-- )
  {
    int r;
    int c;

    scanf ( "%d", &r );
    for ( c = 0; r >= 10; ++c )
    {
      int mx = 0;

      for ( i = 10; i <= r; i *= 10 )
        mx = MAX( mx, ( r / i ) * ( r % i ) );
      r = mx;
    }
    printf ( "%d\n", c );
  }

  return ( EXIT_SUCCESS );
}

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

int main(){
  int n;
  cin >> n;
  while(n--){
    int out = 0, score = 0, runner = 0;
    while(out<3){
      string s;
      cin >> s;
      if(s == "HIT"){
	runner++;
	if(runner == 4){
	  score++; runner--;
	}
      }else if(s == "HOMERUN"){
	score += runner+1;
	runner = 0;
      }else{
	out++;
      }
    }
    cout << score << endl;
  }
}

Measured memory_bytes: 1212
import collections

S = input().strip()

valley_collections = collections.Counter()
saved_index_set = set()
last_saved_index = -1
for s in range(len(S)):
    if(S[s] == "L"):
        if(len(saved_index_set) > 0):
            for i in saved_index_set:
                valley_collections[i] = s - 1
            valley_collections[s] = s - 1
            last_saved_index = s - 1        
            saved_index_set.clear()
        else:
            valley_collections[s] = last_saved_index
    else:
        saved_index_set.add(s)

ans = [0 for i in range(len(S))]
for s in range(len(S)):
    if((valley_collections[s] - s) % 2 == 0):
        ans[valley_collections[s]] += 1
    else:
        ans[valley_collections[s] + 1] += 1
print(" ".join(map(str, ans)))

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

#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define phi 3.1415926535
 
using namespace std;
 
ll tc, cnt = 0, number, many, total = 0;
int rmove[4] = {0, 0, -1, 1};
int cmove[4] = {1, -1, 0, 0};



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt","r", stdin);
    // freopen("output.txt","w", stdout);
    // g++ -std=c++11 Default.cpp  -o test

    cin >> many;

    ll monster[many + 1];
    for(int i = 0; i < many + 1; i++)
        cin >> monster[i];

    ll hero[many];
    for(int i = 0; i < many; i++)
        cin >> hero[i];

    ll answer = 0;
    for(int i = 0; i < many; i++)
    {
        if(monster[i] > 0)
        {
            ll temp = min(monster[i], hero[i]);
            monster[i] -= temp;
            hero[i] -= temp;
            answer += temp;
        }

        if(monster[i + 1] > 0)
        {
            ll temp = min(monster[i + 1], hero[i]);
            monster[i + 1] -= temp;
            hero[i] -= temp;
            answer += temp;
        }
    }

    cout << answer << endl;
    
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
    return 0;
}

Measured memory_bytes: 1792
from collections import namedtuple

Task = namedtuple('Task', 'name time')

class Queue:
    def __init__(self, n):
        self.n = n
        self._l = [None for _ in range(self.n + 1)]
        self._head = 0
        self._tail = 0

    def enqueue(self, x):
        self._l[self._tail] = x
        self._tail += 1
        if self._tail > self.n:
            self._tail = 0

    def dequeue(self):
        if self.isEmpty():
            raise IndexError("pop from empty queue")
        else:
            e = self._l[self._head]
            self._l[self._head] = None
            self._head += 1
            if self._head > self.n:
                self._head = 0
            return e

    def isEmpty(self):
        return self._head == self._tail

    def isFull(self):
        return self._tail == self.n

if __name__ == '__main__':
    n, q = map(int, input().split())
    queue = Queue(n)
    for _ in range(n):
        name, time = input().split()
        time = int(time)
        queue.enqueue(Task(name=name, time=time))

    now = 0
    while not queue.isEmpty():
        task = queue.dequeue()
        t = task.time
        if t <= q:
            now += t
            print(task.name, now)
        else:
            now += q
            queue.enqueue(Task(task.name, t - q))



Measured memory_bytes: 13216
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y,count=0;
  cin>>x>>y;
  if(x==2&&y==2){
    cout<<"Yes"<<"\n";
    return(0);
  }
  if(x==2||y==2){
    cout<<"No"<<"\n";
    return(0);
  }
  if(x>=8){
    if(x%2==0){
      count++;
    }
  }else if(x<=7){
    if(x%2==1){
      count++;
    }
  }
  if(y>=8){
    if(y%2==0){
      count++;
    }
  }else if(y<=7){
    if(y%2==1){
      count++;
    }
  }
  if(count==0||count==2){
    cout<<"Yes"<<"\n";
  }else{
      cout<<"No"<<"\n";
  }
    return(0);
}


Measured memory_bytes: 256
N = int(input())
count = 0
loop_N = 357
while(loop_N <= N) :
    count_3 = 0
    count_5 = 0
    count_7 = 0
    count_n = 0
    
    temp = str(loop_N)
    for j in range(0,len(temp)) :
        if temp[j] == "3" :
            count_3 += 1
        elif temp[j] == "5" :
            count_5 += 1
        elif temp[j] == "7" :
            count_7 += 1
        else :
            count_n += 1
            if temp[j] == "9" :
                temp = str(int(temp[:j+1]) + 1) + temp[j+1:]
            else :
                temp = temp[:j] + str(int(temp[j])+1) + temp[j+1:]
            loop_N = int(temp)
            break
    
    if count_3 > 0 and count_5 > 0 and count_7 > 0 and count_n < 1:
        count += 1
    if count_n < 1 :
        loop_N += 1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
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; }
using namespace std;
typedef long long ll;
typedef pair<int, int> pa;

int n;
int a[1005];
int used[1005][1005];
int dp[1005][1005];
bool isDAG;
vector<pa> graph[1005][1005];

void dfs(int i, int j){
    if(used[i][j] == 1){
        isDAG = false;
        return;
    }
    if(used[i][j] == 2)return;
    used[i][j] = 1;
    for(pa p : graph[i][j])dfs(p.first, p.second);
    used[i][j] = 2;
}

int dfs2(int i, int j){
    if((int)graph[i][j].size() == 0)return 0;
    if(dp[i][j] != -1)return dp[i][j];
    int res = -1;
    for(pa p : graph[i][j])chmax(res, dfs2(p.first, p.second) + 1);
    return dp[i][j] = res;
}

// AtCoder Beginner Contest 139
int main(){

    cin >> n;
    rep(i, n){
        rep(j, n - 1)cin >> a[j];
        rep(j, n - 2){
            int t1 = i, t2 = i, t3 = a[j] - 1, t4 = a[j + 1] - 1;
            if(t1 > t3)swap(t1, t3);
            if(t2 > t4)swap(t2, t4);
            // cout << t1 << ' ' << t3 << ' ' << t2 << ' ' << t4 << endl;
            graph[t1][t3].push_back(pa(t2, t4));
        }
    }

    // rep(i, n)rep(j, i){
    //     cout << graph[j][i].size() << ' ';
    // }

    isDAG = true;
    rep(i, n)rep(j, i)dfs(j, i);
    if(!isDAG){
        cout << -1 << endl;
        return 0;
    }

    memset(dp, -1, sizeof(dp));
    int ans = -1;
    rep(i, n)rep(j, i){
        chmax(ans, dfs2(j, i));
    }

    cout << ans + 1 << endl;
    return 0;

}

Measured memory_bytes: 47488
#include<stdio.h>

int main(){
	
	int n,i,j,same,ans,tru;
	int arr[100];
	ans=0;
        scanf("%d",&n);
        for(i=0;i<n;i++)
        {
        	scanf("%d",&arr[i]);
        }
	for(i=0;i<n;i++)
	{  
		same=arr[i];
		for(j=i+1;i<j,j<n;j++)
		{
			
			if(arr[j]==same)
			{

	         ans++;
	        
	         break;
	        }  
	     
	     
		}
	 
 

	}
     tru=n-ans;
	printf("%d",tru);

}

Measured memory_bytes: 128
h,w = map(int,input().split())
a = [""]*h
for i in range(h):
  a[i] = input()

row = [False]*h
column = [False]*w

for i in range(h):
  for j in range(w):
    if a[i][j] == "#":
      row[i] = True
      column[j] = True

for i in range(h):
  if row[i]:
    for j in range(w):
      if column[j]:
        print(a[i][j],end = "")
    print()
        
    
      


Measured memory_bytes: 4468
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)

int main() {
  int N;
  int A;
  map<int,int> group;
  cin >> N;
  rep(i,N) {
    cin >> A;
    if ( group.count(A) ) {
      cout << "NO" << endl;
      return 0;
    }
    group[A] = 1;
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 9600
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N, M = MI()
    relations = [set([]) for i in range(N)]
    for i in range(M):
        a, b = MI()
        a -= 1
        b -= 1
        relations[a].add(b)
        relations[b].add(a)

    grouped = [-1] * N
    group_num = [0] * N

    group = -1

    for i in range(len(grouped)):
        if grouped[i] != -1:
            continue
        deque = cl.deque(relations[i])
        group += 1

        while len(deque) > 0:
            target = deque.popleft()
            friends = relations[target]
            for friend in friends:
                if grouped[friend] != -1:
                    continue
                grouped[friend] = group
                group_num[group] += 1
                deque.append(friend)

    ans = max(group_num)
    print(max(ans, 1))


main()


Measured memory_bytes: 148936
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <initializer_list>
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;

const int dx44[5] = { 0,-1,-1,1,1 };
const int dy44[5] = { 0,-1,1,-1,1 };

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 1e6 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes");}// exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No");}// exit(0); }
void one() { puts("-1"); exit(0); }

string s;
void solve()
{
	cin>>s;
	int len = s.length();
	string ans = s.substr(0,len-8);
	cout<<ans<<endl;
}

int main()
{


	solve();
	// system("pause");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  int n,m;
  cin >> n >> m;
  if(n % 2 == 1){
    int from = 1;
    rep(i,m){
      cout << from << " " << n - from << endl;
      from++;
    }
  }else{
    int from = 1;
    rep(i,m){
      int to = n - from;
      if((to - from) <= n/2) cout << from << " " << to - 1 << endl;
      else cout << from << " " << n - from << endl;
      from++;
    }
  }
}

Measured memory_bytes: 3636
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,m=map(int,input().split())
a=list(map(int,input().split()))

def lcm(a,b):
    g=math.gcd(a,b)
    return b*(a//g)
l=a[0]//2
for i in range(n):
    r=a[i]//2
    l=lcm(l,r)
for i in range(n):
    if (l//(a[i]//2))%2==0:
        print(0)
        exit()
res=m//l
print((res+1)//2)

Measured memory_bytes: 91084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            for(int i=1;i<10;i++)
            {
                for(int j=1;j<10;j++)
                {
                    Console.WriteLine("{0}x{1}={2}", i, j, i * j);
                }
            }
        }
    }
}

Measured memory_bytes: 5556
N = int(input())
S = input()
memo = {key:[] for key in ("R","G","B")}
ans = 0
for i in range(N):
    memo[S[i]].append(i)
    for space in range(1,N+1):
        j = space + i
        k = space + j
        if(k<N):
            if(S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]):
                ans -= 1

ans += len(memo["R"])*len(memo["G"])*len(memo["B"])
print(ans)

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

using namespace std;
using ll=long long;
int main() {
  ll n;
  cin >> n;
  set<int> cnt;
  vector<ll>a(n);
  for(int i=0;i<n;i++) {
    cin >> a[i];
    
  }
  for(int i=0;i<n;i++) cnt.insert(a[i]);
  if(cnt.size()==n) {
    cout << "YES" << endl;
  }
 else {
   cout << "NO" << endl;
 }
  return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define MAX (ll)(8e1 + 7)
#define INF (ll)(1e18)
#define MOD (ll)(1e9 + 7)

using namespace std;
using ll = long long;
using cd = complex<double>;

int main () {
	ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	if (v <= w || (v - w) * t < abs (b - a)) {
		cout << "NO\n";
	}
	else {
		cout << "YES\n";
	}
}



Measured memory_bytes: 3632
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] d = new int[N];
    int sum = 0;
    for(int i=0;i<N;i++){
      d[i]=sc.nextInt();
      sum+=d[i];
    }
    int r = 0;
    for(int k=0;k<N-1;k++){
      sum-=d[k];
      r+=d[k]*sum;
    }
    System.out.println(r);
  }
}

Measured memory_bytes: 27060
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int a, b;
    cin >> a >> b;
    string s; cin >> s;

    bool ans = true;
    REP(i,a) {
        if (isdigit(s[i]) == 0) ans = false;
    }
    if (s[a] != '-') ans = false;
    FOR(i,a+1,a+b+1) if (isdigit(s[i]) == 0) ans = false;
    ATYN(ans)

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}


int main (){
    ll n;
    ll ans=0;
    cin >> n;
    for(ll i=1;i<=n;i++){
        if(i%3==0||i%5==0) continue;
        ans+=i;
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 3624
x, y, xx, yy = input().split()
x = int(x)
y = int(y)
xx = int(xx)
yy = int(yy)

xdiff = (xx-x)
ydiff = (yy-y)

if xdiff <= 0 and ydiff <= 0:
    xdiff = abs(xx-x)
    ydiff = abs(yy-y)
    print(str(xx+ydiff),str(yy-xdiff),str(x+ydiff),str(y-xdiff))
elif 0 <= xdiff and 0 <= ydiff:
    xdiff = abs(xx-x)
    ydiff = abs(yy-y)
    print(str(xx-ydiff),str(yy+xdiff),str(x-ydiff),str(y+xdiff))
elif xdiff <= 0 and 0 <= ydiff:
    xdiff = abs(xx-x)
    ydiff = abs(yy-y)
    print(str(xx-ydiff),str(yy-xdiff),str(x-ydiff),str(y-xdiff))
else:
    xdiff = abs(xx-x)
    ydiff = abs(yy-y)
    print(str(xx+ydiff),str(yy+xdiff),str(x+ydiff),str(y+xdiff))

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

int X;

int main() {
    cin>>X;
    int sum = 0;
    for(int i = 1; i <= 100000; i++) {
        sum += i;
        if(sum >= X) {
            cout<<i;
            return 0;
        }
    }
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  string ans;
  if (a <= 8 && b <= 8) ans = "Yay!";
  else ans = ":(";

  cout << ans << endl;
}


Measured memory_bytes: 256
a=input()

if a[-1]=='2' or a[-1]=='4'or a[-1]=='5' or a[-1]=='7'or a[-1]=='9':
    print('hon')
if a[-1]=='0' or a[-1]=='1' or a[-1]=='6' or a[-1]=='8':
    print('pon')
if a[-1]=='3':
    print('bon')

Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int a,b,c;
     scanf("%d %d %d",&a,&b,&c);
     if(a+b>=c)
     {
            printf("Yes");
     }
     else
     {
            printf("No");
      }
      return 0;
}

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


int main() {
int A,B;
  cin>>A>>B;
  int sum=0;
  for(int i=0;i<2;i++){
if(A>B){sum+=A;A--;}
    else if(A<=B){sum+=B;B--;}
  }

  cout<<sum<<endl;
  

  
  
  
  

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

int mod;

int add(int a, int b) {
	return (a + b) % mod;
}

int mul(int a, int b) {
	return (a * b) % mod;
}

int sub(int a, int b) {
	return (a - b + mod) % mod;
}

int binpow(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

vector<int> invs;

int divv(int a, int b) {
	assert(b >= 0);
	assert(b < (int)invs.size());
	return mul(a, invs[b]);
}

struct Polynomial {
	int n;
	vector<int> c;

	Polynomial(vector<int> c_) {
		c = c_;
		n = (int)c.size();
		for (auto &t : c) {
			t += mod;
			t %= mod;
		}
	}

	friend bool operator ==(const Polynomial &a, const Polynomial &b) {
		for (int i = 0; i < max(a.n, b.n); i++) {
			int f = 0;
			int s = 0;
			if (i < a.n) f = a.c[i];
			if (i < b.n) s = b.c[i];
			if (f != s) {
				return 0;
			}
		}
		return 1;
	}

	friend Polynomial mul(const Polynomial &a, const Polynomial &b) {
		vector<int> rs(a.n + b.n);
		for (int i = 0; i < a.n; i++) {
			for (int j = 0; j < b.n; j++) {
				rs[i + j] = add(rs[i + j], mul(a.c[i], b.c[j]));
			}
		}
		while (!rs.empty() && rs.back() == 0) {
			rs.pop_back();
		}
		return Polynomial(rs);
	}

	friend Polynomial divv(Polynomial a, Polynomial b) {
		Polynomial wa = a;
		vector<int> res;
		for (int i = a.n - 1; i >= b.n - 1; i--) {
			int k = divv(a.c[i], b.c[b.n - 1]);
			for (int j = 0; j < b.n; j++) {
				a.c[i - j] = sub(a.c[i - j], mul(k, b.c[b.n - 1 - j]));
			}
			res.push_back(k);
		}
		reverse(res.begin(), res.end());
		Polynomial ans = res;
		Polynomial tmp = mul(ans, b);
		assert(tmp == wa);
		return ans;
	}

	friend Polynomial add(Polynomial a, Polynomial b) {
		vector<int> res(max(a.n, b.n));
		for (int i = 0; i < a.n; i++) {
			res[i] += a.c[i];
		}
		for (int i = 0; i < b.n; i++) {
			res[i] += b.c[i];
		}
		return Polynomial(res);
	}

	int eval(int x) {
		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans = add(ans, mul(c[i], binpow(x, i)));
		}
		return ans;
	}

	Polynomial() {}
};

void init() {
	invs.resize(mod);
	for (int i = 0; i < mod; i++) {
		invs[i] = binpow(i, mod - 2);
	}
}

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

	cin >> mod;
	init();
	vector<int> a(mod);
	for (auto &t : a) {
		cin >> t;
	}
	Polynomial all({0, 1});
	for (int i = 1; i < mod; i++) {
		all = mul(all, Polynomial({-i, 1}));
	}
	Polynomial out;
	for (int i = 0; i < mod; i++) {
		if (a[i]) {
			Polynomial c({-i, 1});
			Polynomial s = divv(all, c);
			int val_in_i = s.eval(i);
			for (auto &t : s.c) {
				t = divv(t, val_in_i);
			}
			out = add(out, s);
		}
	}
	// for (int i = 0; i < mod; i++) {
	// 	cerr << out.eval(i) << ' ';
	// }
	// cerr << endl;
	for (int i = 0; i < mod; i++) {
		if (i < out.n) {
			cout << out.c[i] << ' ';
		} else {
			cout << 0 << ' ';
		}
	}
	cout << '\n';
}


Measured memory_bytes: 384
N, K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

l, r = sum(A)//(N+K), A[-1]
if l == 0: l = 1

if sum([(a-1)//l for a in A]) <= K:
    print(l)
    exit()

while l+1 < r:
    m = (l+r) // 2

    cuts = sum([(a-1)//m for a in A])

    if cuts <= K:
        r = m
    else:
        l = m

print(r)

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

int m,n,x[100010],y[100010],pd[100010],sz[100010],ans;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i)
	scanf("%d%d",&x[i],&y[i]);
	pd[1]=1;
	for(int i=1;i<=n;++i)
	sz[i]=1;
	for(int i=1;i<=m;++i)
	{
		if(pd[x[i]])
		{
			if(sz[x[i]]==1)
			{
				sz[x[i]]--;
				sz[y[i]]++;
				pd[x[i]]=0;
				pd[y[i]]=1;
			}
			else if(sz[x[i]])
			{
				sz[x[i]]--;
				sz[y[i]]++;
				pd[y[i]]=1;
			}
		}
		else if(sz[x[i]])
		{
			sz[x[i]]--;
			sz[y[i]]++;
		}
	}
	for(int i=1;i<=n;++i)
	{
		if(pd[i])
		++ans;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
N, Q = list(map(lambda x: int(x), input().split(' ')))
S = input()

#
buf = [0 for _ in range(N)]
prev = 0
for i in range(N-1):
    if S[i:i+2] == 'AC':
        buf[i+1] = prev + 1
    else:
        buf[i+1] = prev

    prev = buf[i+1]

# print(buf)

for _ in range(Q):
    l, r = list(map(lambda x: int(x), input().split(' ')))
    l -=1
    r -=1
    ans = buf[r] - buf[l]
    print(ans)

Measured memory_bytes: 52256
#include <bits/stdc++.h>
using namespace std;
int n;
bool isBridge(int p, vector<vector<pair<int, int>>>& G) {
	vector<int> dist(n, 1e9);
	queue<int> que;
	que.push(0);
	dist[0] = 0;
	while (que.size()) {
		int q = que.front();
		que.pop();
		for (auto nq : G[q]) {
			if (nq.second == p) continue;
			if (dist[nq.first] > dist[q] + 1) {
				dist[nq.first] = dist[q] + 1;
				que.push(nq.first);
			}
		}
	}
	bool check = 0;
	for (int i = 0; i < n; i++)
		if (dist[i] == 1e9) {
			check = 1;
			break;
		}
	return check;
}
int main() {
	int m;
	scanf("%d%d", &n, &m);
	vector<vector<pair<int, int>>> G(n, vector<pair<int, int>>());
	for (int i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--, b--;
		G[a].push_back({b, i}), G[b].push_back({a, i});
	}
	int ans = 0;
	for (int i = 0; i < m; i++) {
		if (isBridge(i, G)) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(void)
{
	int b,i,j,x,y=0,z=0;
	char a[101][11];
	scanf("%d",&b);
	for(i=0;i<b;i++){
		scanf("%s",a[i]);
	}
	for(i=0;i<b;i++){
		for(j=0;j<b;j++){
			if(strcmp(a[i],a[j])==0){
				y++;
			}
		}
	}
	for(i=0;i<b-1;i++){
		x=strlen(a[i]);
		if(a[i][x-1]!=a[i+1][0]){
			z=1;
		}
	}
	if(y==b){
		if(z==0){
			printf("Yes");
		}else{
			printf("No");
		}
	}else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  string s = "abcdefghijklmnopqrstuvwxyz";
  string ss;
  cin>>ss;
  rep(i,0,s.sz){
    if(ss[0]==s[i]){
      cout << s[i+1] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    init_comb();

    int n, m, k;
    std::cin >> n >> m >> k;

    long long comb_value = comb(n * m - 2, k - 2);
    long long ans = 0;
    for (int x_distance = 1; x_distance < m; x_distance++) {
        ans += (m - x_distance) * n * n % mod * comb_value % mod * x_distance % mod;
        ans %= mod;
    }

    for (int y_distance = 1; y_distance < n; y_distance++) {
        ans += (n - y_distance) * m * m % mod * comb_value % mod * y_distance % mod;
        ans %= mod;
    }

    std::cout << ans << std::endl;
}


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

using namespace std;
using ll=long long;

void solve(){
  while(1){
    int t,d,l;
    cin >> t >> d >> l;
    if(!(t|d|l))return;
    int res=0,last=-1;
    for(int i=1;i<=t;i++){
      int x;
      cin >> x;
      if(x>=l){
        if(last!=-1)
          res+=min(i-last,d);
        last=i;
      }
    }
    if(last!=-1)
      res+=min(t-last,d);
    cout << res << endl;
  }
}

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



Measured memory_bytes: 3116
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    S = input()

    ret = 0
    cntW = 0
    cntB = 0
    for i, si in enumerate(S):
        #cntW,cntB
        if si=='W':
            cntW+=1
            ret+=cntB
        else:
            cntB+=1

    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3500