akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;



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

	int minFreq[256] = {};
	for (int i = 0; i < 256; ++i)
	{
		minFreq[i] = BIG;
	}

	for (int i = 0; i < n; ++i)
	{
		string s;
		cin >> s;

		int freq[256]={};
		for (int k = 0; k < SZ(s); ++k)
		{
			freq[s[k]]++;
		}

		for (int i = 0; i < 256; ++i)
		{
			amin(minFreq[i], freq[i]);
		}
	}

	string ans;
	for (int i = 'a'; i <= 'z'; ++i)
	{
		ans += string(minFreq[i], i);
	}

	cout << ans << endl;




	return 0;
}


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

int A , B;
int reverse,remind,reference,count;


int main(){
cin >> A >> B;  //値域を取得

for(int i=A; i<=B; i++ ){
	
	reference = i;
	while(reference!=0){//回分数の判定(カンニング)
	remind = reference%10;
	reverse = reverse * 10 + remind;
	reference = reference/10; //次の桁へ

	}

	if(i == reverse){
	count++;
	}
	reverse=0;
	remind =0;
// cout << "reference is" << i << endl;
// cout << "reverse   is" << reverse << endl; 
// reverse=0;
// remainder =0;

}

cout << count <<endl; //<<"A="<< A << endl <<"B=" << B <<endl;
//cout << "reverse=" <<reverse <<endl ;


}

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

lint K;
lint N = 50;
const int MAX_N = 55;
lint a[MAX_N];

int main(){
	ios::sync_with_stdio(false);
	cin>>K;

	for(int i=0;i<N;i++){
		a[i] = (K+N-1)/N+(N-1);
	}

	int t = N-K%N;
	if(t==N)t=0;
	for(int i=0;i<t;i++){
		a[i]-=K%N+1;
	}

	cout << N << endl;
	for(int i=0;i<N;i++){
		cout << a[i] << " ";
	}
	cout << endl;
	return 0;
}

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

int main()
{
  int64_t n;
  cin >> n;
  
  int64_t a[n];
  for(int64_t i = 0; i < n; i++){
    cin >> a[i];
  }
  
  sort(a,a+n);
  for(int64_t i = 0; i < n-1; i++){
    if(a[i] == a[i+1]){
      cout << "NO" << endl;
      return 0;
    }
  }
  
  cout << "YES" << endl;
}

Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
const int LIM=1e5, MOD=1e9+7;
set<int> adjl[LIM+1];
vector<int> lvl(LIM+1,0);
long long int dp[LIM+1];
void dfs(int u)
{
    long long int white_ways=1, black_ways=1;
    for(int v: adjl[u])
    {
        if(lvl[v]==0)
        {
            lvl[v]=lvl[u]+1;
            dfs(v);
            white_ways*=dp[v];
            white_ways%=MOD;
            for(int w: adjl[v]) 
            {
                if(lvl[w]>lvl[v])
                {
                    black_ways*=dp[w];
                    black_ways%=MOD;
                }
            }
            dp[u]=(white_ways+black_ways)%MOD;
        }
    }
    if(adjl[u].size()==1 && u!=1) dp[u]=2;
}
int main()
{
    int n;
    cin>>n;
    if(n==1) 
    {
        cout<<2;
        return 0;
    }
    for(int i=1;i<n;i++)
    {
        int x, y;
        cin>>x>>y;
        adjl[x].insert(y);
        adjl[y].insert(x);
    }
    lvl[1]=1;
    dfs(1);
    cout<<dp[1];
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> nums(n);
  for (int i = 0; i < m; i++)
    cin >> nums.at(i);

  int sum = accumulate(nums.begin(), nums.end(), 0);

  int r;
  if (n - sum >= 0) {
    r = n - sum;
  }
  else {
    r = -1;
  }

  cout << r << endl;
}


Measured memory_bytes: 7220
#include <bits/stdc++.h>
using namespace std;
vector<int> pairs(100, 0);

int main()
{
  int64_t ans = 0;
  int N, d1, dx, idx;
  cin >> N;
  for (int i = 1; i <= N; i++)
  {
    d1 = i % 10;
    dx = i / (pow(10, to_string(i).size() - 1));
    idx = dx * 10 + d1;
    pairs.at(idx)++;
  }
  for (int i = 0; i < 100; i++)
  {
    if (i % 10 == 0 || pairs.at(i) == 0)
    {
      continue;
    }
    d1 = i % 10;
    dx = i / 10;
    if (d1 == dx)
    {
      ans += pow(pairs.at(i), 2);
    }
    else
    {
      ans += pairs.at(i) * pairs.at(d1 * 10 + dx);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
import itertools as it

def main():
    N = int(input())
    ds = input_nums()
    total = 0
    dd = it.permutations(ds, 2)
    for d in dd:
        total += d[0] * d[1]
    print(total//2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38512
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int ans = 0;
    char[] s = sc.nextLine().toCharArray();
    char[] t = sc.nextLine().toCharArray();
    for (int cnt = 0; cnt < s.length; cnt++) {
      if (s[cnt] != t[cnt]) {
        ans++;
      }
    }
    System.out.println(ans);
    sc.close();
  }
}

Measured memory_bytes: 42824
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	long long a, b, c, k;
	cin >> a >> b >> c >> k;
	

	if (a >= b && a >= c) {
		for (int i = 0; i < k; i++) {
			a *= 2;
		}

		cout << a + b + c << endl;
		return 0;
	}
	
	if (b >= a && b >= c) {
		for (int i = 0; i < k; i++) {
			b *= 2;
		}

		cout << a + b + c << endl;
		return 0;

	}

	if (c >= a && c >= b) {
		for (int i = 0; i < k; i++) {
			c *= 2;
		}

		cout << a + b + c << endl;
		return 0;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main() {
	ios;
	ll x;
	cin>>x;
	ll h=(x/500)*1000;
	x%=500;
	h+=(x/5)*5;
	cout<<h;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
#include <atcoder/modint>
#include <atcoder/lazysegtree>
using mint = atcoder::modint998244353;
struct S{
    mint x, w;
    S(mint x = 0, mint w = 1): x(x), w(w) {}; // デフォルト引数は単位元にしておく
};

S op(S a, S b){
    return S(a.x * b.w + b.x, a.w * b.w);
}
S e(){
    return S();
}

S mapping(int f, S a){
    if(f == 0)return a;
    return S((a.w - 1) / 9 * f ,a.w);
}
int composision(int f, int g){
    if(f == 0)return g;
    return f;
}
int id(){
    return 0;
}
int main() {
    int N, Q;
    cin >> N >> Q;
    atcoder::lazy_segtree<S, op, e, int, mapping, composision, id> t(N);
    rep(i,N){
        t.set(i, S(1, 10));
    }
    rep(qi, Q){
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        t.apply(l, r, d);
        S ans = t.prod(0,N);
        cout << ans.x.val() << endl;
    }
}


Measured memory_bytes: 9776
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    char a[20];
    while(cin>>a)
    {
        char s[20];
        int cnt=0;
        for(int i=0;a[i]!='\0';i++)
        {
            if(a[i]=='1')
                s[cnt++]='1';
            if(a[i]=='0')
                s[cnt++]='0';
            if(a[i]=='B')
                {
                    if(cnt!=0)
                        cnt--;
                }
        }
        for(int i=0;i<cnt;i++)
        {
            cout<<s[i];
        }
        cout<<endl;
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define INF -1000000000000000
#define pb push_back
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define tr(c, i) for (typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c), x) != c.end())

ll n,ara[200005];
vector< vector<ll> > dp(200005, vector<ll> (5,INF));



ll f(ll i, ll j){

  

    if(i>n) return 0;

    if(dp[i][j]!=INF) return dp[i][j];

    if(j==0){ 
        if(i>=n) return 0;  
        dp[i][j] = ara[i] + max(max(f(i+2,0),f(i+3,3)),f(i+4,1));
        return dp[i][j];
    }
    if(j==2) return dp[i][j] = ara[i] + max(f(i+2,2),f(i+3,1)); 
    if(j==3) return dp[i][j] = ara[i] + max(f(i+2,3),f(i+3,1));
    else     return  dp[i][j] = ara[i] + f(i+2,1);
    


}







int main(){
	
    ll i;
    cin>>n;
    for(i=1;i<=n;i++) cin>>ara[i];
    if(n%2==1){  
    cout<<max(max(f(1,0),f(2,2)),f(3,1))<<endl;
    }
    else{
        cout<<max(f(1,2),f(2,1))<<endl;
    }

	return 0;
}

Measured memory_bytes: 23572
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    n, m, c = LI()
    B = LI()
    cnt = 0
    for i in range(n):
        A = LI()
        tmp = c
        for i, a in enumerate(A):
            tmp += B[i] * a
        if tmp > 0:
            cnt += 1
    print(cnt)


main()



Measured memory_bytes: 83672
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

int h[105];
int ans, N;

int main(void) {
    scanf("%d", &N);
    REP(i, 1, N+1) scanf("%d", &h[i]);
    
    while (1) {
      int cnt = 0;
      REP(i, 1, N+1) if (h[i-1] <= 0 && h[i] > 0) cnt++;
      
      if (cnt == 0) break;
      else ans += cnt;
      REP(i, 1, N+1) h[i]--;
        
    }
    
    printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
#ifdef LOCAL_EXEC
#include "include.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define trace(...)
#endif

using LL = long long;
using PLI = pair<LL, int>;
const LL INF = 1e18;

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

	int n, m; cin >> n >> m;
	vector<vector<int>> out(n);
	vector<vector<pair<int, int>>> in(n);
	for (int i = 0; i < m; i++) {
		int l, r, c; cin >> l >> r >> c; l--, r--;
		in[l].emplace_back(c, i);
		out[r].push_back(i);
	}

	vector<LL> dis(n, INF);
	priority_queue<PLI, vector<PLI>, greater<PLI>> heap;
	vector<bool> to_del(m);

	dis[0] = 0;
	for (int i = 0; i < n; i++) {
		while (!heap.empty() && to_del[heap.top().second]) heap.pop();
		if (!heap.empty()) {
			dis[i] = min(dis[i], heap.top().first);
		}

		for (auto& e: in[i]) {
			heap.emplace(dis[i] + e.first, e.second);
		}

		for (int x: out[i]) {
			to_del[x] = true;
		}
	}

	LL ans = dis[n - 1];
	if (ans == INF) ans = -1;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 11776
import math
import heapq
N , M = map(int, input().split())
A = list(map(int , input().split()))
A = list(map( lambda x : x * (-1) , A ))
heapq.heapify(A)
for _ in range(M):
    tmp = heapq.heappop(A) * (-1) / 2
    heapq.heappush(A,tmp * (-1))
A = list(map( lambda x : x * (-1) , A ))
A = list(map( lambda x : math.floor(x) , A ))
print(sum(A))


Measured memory_bytes: 14380
#include<bits/stdc++.h>
using namespace std;
long long n,x=1,sum,a[100002];
int main(){
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]) x=(x+1)%2;
        else sum+=x,x=1;
    }
    if(x%2) sum++;
    cout<<sum<<endl;
    return 0;
}

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

const long long mod =1e9+7 ;
const int N = 4e2+5;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define fr(i,l,m) for(int i=l;i<m;i++)
# define vi vector<int>
#define vii vector<ll>
#define vpr vector<pair<int,int> >
#define dbg(x) cout << #x << " is " << x << endl;
#define spk(x) cout<<x<<endl;
#define inf INT_MAX
/*
stoi - sting to int;
stol - string to long;
stoll - string to ll;
*/

////
////
////
int n;
ll a[N],dp[N][N],b[N];

ll solve(int l,int r)
{
  if(l>r)return 1e18;
  if(l==r)return 0;
  if((l+1)==r)return (a[l]+a[l+1]);
  if(dp[l][r]!=-1)return dp[l][r];
  ll ans=1e18;
  ll sum=0;
  fr(i,l,r+1)
  {
      sum+=a[i];
  }
  fr(i,l,r)
  {
      ll cur=solve(l,i)+solve(i+1,r)+sum;
      ans=min(ans,cur);
  }
  dp[l][r]=ans;
  return ans;
}
////
///
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);

cin>>n;
fr(i,1,n+1)
{
    cin>>a[i];
   // b[i]=(b[i-1]+a[i]);

}
memset(dp,-1,sizeof(dp));

cout<<solve(1,n)<<endl;


    return 0;
}


Measured memory_bytes: 1536
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>
#include <limits>
#include <set>
#include <map>
#include <string>
#include <sstream>
#include <stdio.h>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
ull gcd(ull a, ull b){return b? gcd(b, a%b):a;}
using namespace std;

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

	ll blackCount = 0;
	ll ans = 0;
	for(int i = 0; i < S.length(); i++){
		if(S[i] == 'B'){
			blackCount++;
		}else if(S[i] == 'W'){
			ans += blackCount;
		}
	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 720
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int D; cin >> D;
    D %= 10;
    string ans;
    if(D == 5) ans = "Christmas";
    if(D == 4) ans = "Christmas Eve";
    if(D == 3) ans = "Christmas Eve Eve";
    if(D == 2) ans = "Christmas Eve Eve Eve";
    cout << ans << endl;
}


Measured memory_bytes: 3548
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k==x:
                count += 1

print(count)

Measured memory_bytes: 3064
#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 <random>
#include <complex>
#include <random>
 
using namespace std;

namespace String {
    int lim;
    vector<pair<int, int>> v;

    void trim(int x) {
        while (!v.empty() && prev(v.end())->first >= x) {
            v.pop_back();
        }
    }

    bool add(int to) {
        vector<pair<int, int>> poped;
        for (int i = to; i >= 0; i--) {
            if (v.empty() || v.back().first < i) {
                v.push_back({i, 1});
                break;
            }
            v.back().second++;
            if (v.back().second == lim) {
                if (i == 0) return false;
                poped.push_back({v.back().first, 0});
                v.pop_back();
            } else {
                break;
            }
        } 
        reverse(poped.begin(), poped.end());
        for (auto t : poped) {
            v.push_back(t);
        }
        return true;
    }

    void init(int lim_) {
        lim = lim_;
        v.clear();
    }
};

int n;
vector<int> a;

bool can(int x) {
    String::init(x);
    int clen = 0;
    for (int i = 0; i < n; i++) {
        if (clen < a[i]) {
            //
        } else {
            String::trim(a[i]);
            if (!String::add(a[i] - 1)) {
                return false;
            }
        }
        clen = a[i];
    }
    return true;
}

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

    cin >> n;
    a.resize(n);
    for (auto &t : a) {
        cin >> t;
    }
    {
        int ans1 = 1;
        for (int i = 0; i + 1 < n; i++) {
            if (a[i] >= a[i + 1]) {
                ans1 = 0;
            }
        }
        if (ans1) {
            cout << 1 << endl;
            exit(0);
        }
    }
    int l = 1;
    int r = n;
    while (r - l > 1) {
        int m = (r + l) >> 1;
        if (can(m)) {
            r = m;
        } else {
            l = m;
        }
    }       
    cout << r << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<algorithm>
#include<string>
using namespace std;
char in[110];
string url[110];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++){
			scanf("%s",in);
			url[i]=in;
		}
		while(b--){
			string A,B;
			scanf("%s",in);A=in;
			scanf("%s",in);B=in;
			string now="";
			int Aat=0;
			int Bat=0;
			for(int i=0;i<A.size();i++){
				if(i+1<A.size()&&A[i]=='.'&&A[i+1]=='.'){
					if(now.size()<=1){
						Aat=-1;break;
					}
					now.erase(now.size()-1);
					while(now[now.size()-1]!='/')now.erase(now.size()-1);
					i+=2;continue;
				}else if(i&&A[i-1]=='/'&&A[i]=='.'){
					i+=1;continue;
				}
				now+=A[i];
				bool ok=false;
				for(int j=0;j<a;j++)if(now.size()<=url[j].size()&&url[j].substr(0,now.size())==now){
					ok=true;break;
				}
				if(!ok){Aat=-1;break;}
			}
	//		printf("%s %d\n",now.c_str(),Aat);
			if(!~Aat){printf("not found\n");continue;}
			Aat=-1;
			for(int i=0;i<a;i++){
				if(now.size()<=url[i].size()&&url[i].substr(0,now.size())==now){
					if(now==url[i]||(now[now.size()-1]=='/'&&now+"index.html"==url[i])||
					(now+"/index.html"==url[i])){Aat=i;break;}
				}
			}
			if(!~Aat){printf("not found\n");continue;}
			now="";
			for(int i=0;i<B.size();i++){
				if(i+1<B.size()&&B[i]=='.'&&B[i+1]=='.'){
					if(now.size()<=1){
						Bat=-1;break;
					}
					now.erase(now.size()-1);
					while(now[now.size()-1]!='/')now.erase(now.size()-1);
					i+=2;continue;
				}else if(i&B[i-1]=='/'&&B[i]=='.'){
					i+=1;continue;
				}
				now+=B[i];
				bool ok=false;
				for(int j=0;j<a;j++)if(now.size()<=url[j].size()&&url[j].substr(0,now.size())==now){
					ok=true;break;
				}
				if(!ok){Bat=-1;break;}
			}
		//	printf("%s %d\n",now.c_str(),Bat);
			if(!~Bat){printf("not found\n");continue;}
			Bat=-1;
			for(int i=0;i<a;i++){
				if(now.size()<=url[i].size()&&url[i].substr(0,now.size())==now){
					if(now==url[i]||(now[now.size()-1]=='/'&&now+"index.html"==url[i])||(now+"/index.html"==url[i])){Bat=i;break;}
				}
			}
			if(!~Bat){printf("not found\n");continue;}
			if(Aat==Bat)printf("yes\n");
			else printf("no\n");
		}
	}
}

Measured memory_bytes: 1064
//shara's here
#include <bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
typedef long long ll;
int main(){
    ll x,k,l;
    cin>>x>>k>>l;
    if(x+k>=l){cout<<"Yes";}
    else cout<<"No";
return 0;}


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

int main() {
	int n,l;
	cin>>n>>l;
	string s[n+4],res="";
	for(int i=0;i<n;i++)
	cin>>s[i];
	sort(s,s+n);
	for(int i=0;i<n;i++)
	res+=s[i];
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC053B
{
    class Program
    {
        static void Main(string[] args)
        {
            string target = Console.ReadLine();
            int findex = 0;
            int lindex = target.Length-1;
            while(target[findex] != 'A') findex++;
            while(target[lindex] != 'Z') lindex--;
            Console.WriteLine(lindex-findex+1);
        }
    }
}


Measured memory_bytes: 13180
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
 
const int N = 5e5 + 5;
const int MAXN = 1e5 + 5;
const int mod = 1e9 + 7;
const int MOD = 1e9 + 7;
const int INF = 1e15;
const int LG = 21;
const long double PI = acos(-1);

int arr[N];

int get(int l, int r)
{
	if(l == 0) return arr[r];
	else return arr[r] - arr[l - 1];
}

vector<int> v[N];

void solve() 
{
	int n;
	cin >> n;
	for(int i = 2; i <= n; i++)
	{
		int data;
		cin >> data;
		v[data].push_back(i);
	}
	for(int i = 1; i <= n; i++)
	{
		cout << v[i].size() << endl;
	}
}

 
 
int32_t main() 
{	
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

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

const int MAXN = 1e5 + 10;

int N, M;
vector<int> V[MAXN];
int P[MAXN], A[MAXN];

void dfs(int here, int par){
  P[here] = par;
  for(int there : V[here]) if(!P[there]) dfs(there, here);
  int s = 0;
  for(int there : V[here]) {
    if(there == par) continue;
    if(P[there] == here && A[there] == 0) s ^= 1;
    if(P[there] != here && here < there) s ^= 1;
  }
  A[here] = s;
}

void p(int x, int y){
  cout << x << ' ' << y << '\n';
}
int main(void){
  cin >> N >> M;
  if(M & 1) return cout << -1, 0;
  for(int i = 1 ; i <= M ; i++){
    int x, y;
    cin >> x >> y;
    V[x].push_back(y);   V[y].push_back(x);
  }

  dfs(1, -1);
  for(int here = 1 ; here <= N ; here++) {
    for(int there : V[here]) {
      if(P[here] == there) continue;
      if(P[there] == here) {
        if(A[there]) p(there, here);
        else p(here, there);
      }
      else {
        if(here < there) p(here, there);
      }
    }
  }

  return 0;
}

Measured memory_bytes: 15488
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    w,h = LI()
    p = sorted([I() for _ in range(w)])
    q = sorted([I() for _ in range(h)])
    r = 0
    pi = 0
    qi = 0
    for i in range(w+h):
        if qi == h:
            r += p[pi] * (h-qi+1)
            pi += 1
        elif pi == w:
            r += q[qi] * (w-pi+1)
            qi += 1
        elif p[pi] < q[qi]:
            r += p[pi] * (h-qi+1)
            pi += 1
        else:
            r += q[qi] * (w-pi+1)
            qi += 1

    return r

print(main())



Measured memory_bytes: 16688
#include <stdio.h>

int main(void){
  int n;
  int max=-1,mn=-1;
  int a,v;
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&a,&v);
    if(max<v){
      max=v; mn=a;
    }else if(max==v){
      if(mn>a) mn=a;
    }
  }
  printf("%d %d\n",mn,max);
  return 0;
}

Measured memory_bytes: 600
//ITP1_4_B

using System;
using System.Collections.Generic;
/*using System.Linq;
using System.Text;
using System.Threading.Tasks;*/

class Program
{
    static void Main(string[] args)
    {
        //?????????????????????????????????int??????iaaray????????????????????\

        double r = double.Parse(Console.ReadLine());

        double pai = 3.141592653589793;
        double s = r * r * pai;
        double c = r * 2.000000 * pai;

        Console.WriteLine(s.ToString("0.000000") + " " + c.ToString("0.000000"));
        }
}

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

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b; cin>>a>>b;
	if(a==2 || b==2) cout<<"No\n";
	else if((a==4 || a==6 || a==9 || a==11) && (b==4 || b==6 || b==9 || b==11)) cout<<"Yes\n";
	else if(a==4 || a==6 || a==9 || a==11) cout<<"No\n";
	else cout<<"Yes\n";
	return 0;
}











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

struct Point{ double x,y; };

void koch(int n, Point a, Point b){
  if(n == 0) return;
  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;


  koch(n - 1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n - 1, t, b);
}

int main(){
  Point a, b;
  int n;

  scanf("%d", &n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);
}



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

bool isprime(int n){
    for(int i=2; i*i<=n; i++){
        if(n%i==0) return false;
    }
    return n!=1;
}

int main(){
	ll n,m,ans;
	cin>>n>>m;
	if(isprime(m) && n!=1){
		cout<<1;
		return 0;
	}
	for(ll i=n;;i++){
		if(m%i==0){
			ans=m/i;
			break;
		}
	}
	cout<<ans;
	return 0;
}

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

int main() {
 string s,t;
  cin >> s;
  cin >> t;
  sort(s.begin(),s.end());
  sort(t.rbegin(),t.rend());
  if(s<t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
}

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

#define MAXINF 1000000005
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repc(it, x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rrepc(it, x) for(auto it = (x).rbegin(); it != (x).rend(); ++it)
#define all(x) (x).begin(), (x).end()
#define P pair<int, int>

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    if(m == 1) {
        if(n == 1) {
            cout << 0 << endl;
            return 0;
        }
    }
    int ans = 0;
    ans += n*(n-1)/2;
    ans += m*(m-1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from functools import reduce
from fractions import gcd
def gcd_list(numbers):
    return reduce(gcd, numbers)
n,k = map(int,input().split())
A = list(map(int,input().split()))
if k % gcd_list(A) == 0 and k <= max(A):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 16276
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  int ans = 0;
  while(true) {
    rep(i,n) {
      if(a[i] % 2 != 0) {
        cout << ans << endl;
        return 0;
      }
      a[i] /= 2;
    } 
    ans++;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3628
import sys
import math
#from queue import *
#import random
#sys.setrecursionlimit(int(1e6))
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

s=insr()
ara=["Sunny", "Cloudy", "Rainy", "Sunny", "Cloudy", "Rainy"]

if s[0]=='S':
	print(ara[1])
elif s[0]=='C':
	print(ara[2])
else:
	print(ara[0])


Measured memory_bytes: 9024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){

	long long int n;
	cin >> n;
	string tmp = to_string(n);
	int ans = tmp.size();
	for(int i=1; i<=sqrt(n); i++){
		if( n % i == 0 ){
			string x = to_string(i);
			string y = to_string(n/i);
			int q = max((int)x.size(), (int)y.size());
			ans = min(ans, q );
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <set>
using namespace std;

string s, t, res;

void allswap(char a, char b){
    char tmp = a;
    replace(s.begin(), s.end(), b, '#');
    replace(s.begin(), s.end(), a, b);
    replace(s.begin(), s.end(), '#', tmp);
    return;
}

int alphabet_pos(const char c){
  if('a' <= c && c <= 'z') return (c-'a');
  return -1;
}

int main(){
    res = "Yes";
    vector<char> alphabet;
    for (char c = 'a'; c <= 'z'; c++) {
        alphabet.push_back(c);
    }
    cin >> s >> t;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        if(s[i] == t[i]) continue;
        if( find(alphabet.begin(), alphabet.end(), s[i]) != alphabet.end() &&
            find(alphabet.begin(), alphabet.end(), t[i]) != alphabet.end()){

            int y = alphabet_pos(t[i]);
            alphabet[y] = '#';
            allswap(s[i], t[i]);
        }
        else{
            res = "No";
            break;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

const int MAX = 3000000;
const int P = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

void COMBinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % P;
        inv[i] = P - inv[P % i] * (P / i) % P;
        finv[i] = finv[i - 1] * inv[i] % P;
    }
}

int COMB(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % P) % P;
}

signed main()
{
    int n, k;
    cin >> n >> k;
    COMBinit();
    rep(i, 1, k + 1)
        cout << ( (COMB(n-k+1, i) % P) * (COMB(k-1, i-1) % P) ) % P<< endl;    
    return 0;
}

Measured memory_bytes: 73920
#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>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int LIM = 5000;

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

	int x;
	cin >> x;
	for (int i = -LIM; i <= LIM; i++) {
		for (int j = -LIM; j <= LIM; j++) {
			if (i * i * i * i * i - j * j * j * j * j == x) {
				cout << i << ' ' << j << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t;
    cin>>n>>t;
    int c[n];
    int b[n];
    for(int i=0;i<n;i++){
        cin>>c[i]>>b[i];
    }
    int count=0;

    for(int i=0;i<n;i++){
        if(b[i]>t) count++;
    }

    int num=1010;
    for(int i=0;i<n;i++){
        if(b[i]<=t){
            if(c[i]<num) num=c[i];
        }
    }
    if(count==n) cout<<"TLE"<<endl;
    else cout<<num<<endl;
    return 0;
}









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

int main()
{

int n ;
cin>>n;
int a = n%10;
if(a==3)
    cout<<"bon"<<endl;
else if(a==0||a==1||a==6||a==8)
    cout<<"pon"<<endl;
else
    cout<<"hon"<<endl;
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    ll K;
    cin >> S >> K;
    int cnt1 = 0;
    char ans;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '1') cnt1++;
        else {
            ans = S[i];
            break;
        }
    }
    if (K <= cnt1) cout << 1 << '\n';
    else cout << ans << '\n';
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  ll A,B,V,W,T;
  cin >> A >> V;
  cin >> B >> W;
  cin >> T;

  string ans;

  if(W >= V){
    ans = "NO";
  } else {
    ll diff = abs(A - B);
    if( (V - W) * T >= diff){
      ans = "YES";
    } else {
      ans = "NO";
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES


#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <numeric>

#include <cmath>

using namespace std;

typedef long long LL;

int main() {
	vector<pair<int, int>> vec;
	int H, W;

	while (true)
	{
		cin >> H >> W;
		if (H == 0 && W == 0) break;

		auto p = make_pair(H, W);
		vec.emplace_back(p);
	}

	for (auto&& v : vec) {
		for (int j = 0; j < v.first; ++j) {
			for (int i = 0; i < v.second; ++i) {
				if (i == 0 || j == 0 || j == v.first - 1 || i == v.second - 1) cout << "#";
				else cout << ".";
			}
			cout << "\n";
		}
		cout << "\n";
	}

	return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
    string T;
    cin >> T;
    replace(T.begin(), T.end(), '?', 'D');
    cout << T << endl;
}


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

int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int j = pow(2,k);
    int x = max(max(a,b),c);
    cout << a+b+c-x+x*j << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n;

long long dp[4][100001]={0};

long long func(int k,int* a,int* b,int* c,int i){
    if(i==n+1)
        return 0;
    if(dp[k][i]!=0)
        return dp[k][i];
    if(k==1)
        dp[k][i]=max(func(2,a,b,c,i+1)+b[i],func(3,a,b,c,i+1)+c[i]);
    else if(k==2)
        dp[k][i]=max(func(3,a,b,c,i+1)+c[i],func(1,a,b,c,i+1)+a[i]);
    else if(k==3)
        dp[k][i]=max(func(2,a,b,c,i+1)+b[i],func(1,a,b,c,i+1)+a[i]);
    else
        dp[k][i]=max(max(func(2,a,b,c,i+1)+b[i],func(3,a,b,c,i+1)+c[i]),func(1,a,b,c,i+1)+a[i]);
    return dp[k][i];
}

int main()
{
   cin>>n;
   int a[n+1],b[n+1],c[n+1];
   for(int i=1;i<=n;i++){
    cin>>a[i]>>b[i]>>c[i];
   }
    cout<<func(0,a,b,c,1);
}

Measured memory_bytes: 11520
import java.util.Scanner;

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

        double[] l = new double[n];
        for(int i = 0; i < n; i++){
            l[i] = (sc.nextDouble() + 1) / 2;
        }

        double[] sum = new double[n - k + 1];
        for(int i = 0; i < k; i++){
            sum[0] += l[i];
        }
        for(int i = 1; i < n - k + 1; i++){
            sum[i] = sum[i - 1] + l[k + i - 1] - l[i - 1];
        }
        double max = sum[0];
        for(int i = 1; i < n - k + 1; i++){
            max = Math.max(max, sum[i]);
        }

        System.out.println(max);
        sc.close();
    }
}

Measured memory_bytes: 160504
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma comment(linker, "/STACK:2000000")

#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'
using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 3e5 + 5, LG = 19, MOD = 998244353;
const int SQ =320;
const long double EPS = 1e-7;
void printCase(int cs){
  cout << "Case #" << cs<<": ";
}

int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  int n, m, x;
  cin >> n >> m;
  vector<int>a(n);
  int sum = 0;
  f(i,0,n){
    cin >> a[i];  sum += a[i];
    ///x >= 1 / 4 * m
  }
  int ans = 0;
  f(i,0,n){
    if(a[i] * 4 * m >= sum)
      ans++;
  }

  if(ans>=m)cout<<"Yes\n";
  else cout << "No\n";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

bool is_leap(int y) {
	return (y%400 == 0) || (y%4 == 0 && y%100 != 0);
}

int main() {
	bool first = true;
	while (true) {
		int a,b;
		cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		if (first) {
			first = false;
		} else {
			cout << endl;
		}
		int delta = 1;
		bool have = false;
		for (int y = a;y <= b;y += delta) {
			if (is_leap(y)) {
				if (!have) {
					have = true;
				}
				if (delta == 1) {
					delta = 4;
				}
				cout << y << endl;
			}
		}
		if (!have) {
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 3044
from collections import defaultdict

N, M = [int(x) for x in input().split()]
a = []

for _ in range(M):
    a.append(int(input()))

MOD = 1000000007

dict = defaultdict(int)

dict[0] = 1
a_s = set(a)
for i in range(N):
    if not i in a_s:
        dict[i + 1] += dict[i]
        dict[i + 2] += dict[i]


print(dict[N] % MOD)




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

int main(){
	int n, q;
	scanf("%d%d", &n, &q);
	vector<list<int> > ls(n);
	for(int i = 0; i < q; i++) {
		int id, t;
		scanf("%d", &id);
		if(id == 0) {
			int x;
			scanf("%d%d", &t, &x);
			ls[t].push_back(x);
		}
		if(id == 1) {
			scanf("%d", &t);
			bool flag = true;
			for(auto x: ls[t]) {
				if(flag) {
					printf("%d", x);
					flag = false;
				}else
					printf(" %d", x);
			}
			printf("\n");
		}
		if(id == 2) {
			int s;
			scanf("%d%d", &s, &t);
			if(!ls[s].empty()) {
				ls[t].splice(ls[t].end(), ls[s]);
			}
		}
	}
}



Measured memory_bytes: 18856
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    if(n/10==9 || n%10==9) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
typedef long long int ll;
ll u(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll d(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  char s[300];
  scanf("%s",s);
  int l=strlen(s);
  ll k;
  scanf("%lld",&k);
  if(l==1){
    PRN(k/2);
    return 0;
  }
  if(k==1){
    int sum=0;
    FOR(l-1){
      if(s[i]==s[i+1]){
        sum++;
        i++;
      }
    }
    PRN(sum);
  }else{
    int cnt=0,diff=0,x=0;
    FOR(strlen(s)-1){
      if(s[i]==s[i+1]){
        cnt++;
      }else{
        x+=(cnt+1)/2;
        cnt=0;
        diff=1;
      }
    }
    x+=(cnt+1)/2;
    int flg=0,sum=0;
    if(!diff){
      PRL((cnt+1)*k/2);
      return 0;
    }
    for(int i=0;i<l*2-1;i++){
      if(s[i%l]==s[(i+1)%l]){
        cnt++;
      }else{
        if(!flg){
          flg++;
        }else{
          sum+=(cnt+1)/2;
        }
        cnt=0;
        if(i>=l)break;
      }
    }
    PRL(x+sum*(k-1));
  }
  return 0;
}


Measured memory_bytes: 128
# -*- coding:utf-8 -*-
N, K = map(int, input().split())
D = list(map(int, input().split()))
for tmp in range(N, 10*N+1):
    flag = True
    factor = list(map(int, str(tmp)))
    for num in D:
        if num in factor:
            flag = False
            break
    if flag:
        print(tmp)
        break

Measured memory_bytes: 3060