akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

typedef struct kk{
    double x;
    double y;
} P;

int koch(int ,P ,P);

int main()
{
    int n;
    P s,e;
    s.x = 0.0;
    e.x = 100.0;
    s.y = e.y = 0.0;
    
    scanf("%d",&n);
    printf("%f %f\n",s.x,s.y);
    koch(n,s,e);
    printf("%f %f\n",e.x,e.y);
    
    return 0;
}


int koch(int n,P p1,P p2)
{
    P s,t,u;
    if(n == 0) return 0;
    
    s.x = (2*p1.x + 1*p2.x)/3;
    s.y = (2*p1.y + 1*p2.y)/3;
    t.x = (1*p1.x + 2*p2.x)/3;
    t.y = (1*p1.y + 2*p2.y)/3;
    u.x = (t.x - s.x) * cos(M_PI/3) - (t.y - s.y) * sin(M_PI/3) + s.x;
    u.y = (t.x - s.x) * sin(M_PI/3) + (t.y - s.y) * cos(M_PI/3) + s.y;
    
    koch(n-1,p1,s);
    printf("%f %f\n",s.x,s.y);
    koch(n-1,s,u);
    printf("%f %f\n",u.x,u.y);
    koch(n-1,u,t);
    printf("%f %f\n",t.x,t.y);
    koch(n-1,t,p2);
    
    return 0;
}




Measured memory_bytes: 2104
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return *(int*)b-*(int*)a;}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint_fast32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }

inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

int main(void){
	int n=nextpint();
	int m=nextpint();
	printf("%d\n", n*(n-1)/2+m*(m-1)/2);
}


Measured memory_bytes: 128
N=int(input())
p=list(map(float,input().split()))+[0]

dp=[[0]*(N+1) for i in range(N+1)]
dp[0][0]=1
for i in range(1,N+1):
    dp[0][i]=dp[0][i-1]*(1-p[i-1])

for i in range(N):
    for j in range(N):
        dp[i+1][j+1]=dp[i][j]*p[j]+dp[i+1][j]*(1-p[j])

ans=0
for i in range(N+1):
    if i>=N//2+1:
        ans+=dp[i][N]

print(ans)

Measured memory_bytes: 259720
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Graph{
	private:
	int n;
	vvi g;
	vi DIJ(int s){
		priority_queue<P> q;
		vi d(n,inf);
		d[s]=0;
		q.push({0,s});
		while(!q.empty()){
			P p=q.top();
			q.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(auto i:g[v]){
				int u=i,D=d[v]+1;
				if(d[u]>D){
					d[u]=D;
					q.push({-D,u});
				}
			}
		}
		return d;
	}
	public:
	Graph(int v){
		n=v;
		g=vvi(v);
	}
	void add_edge(int s,int t){
		g[s].push_back(t);
		g[t].push_back(s);
	}
	int D;
	vi a;
	void dfs(int v,int p,int d){
		int t=0;
		for(auto u:g[v]) if(u!=p){
			dfs(u,v,d+1);
			t++;
		}
		a[d]=max(a[d],t);
	}
	ll f(int v){
		a=vi(D/2+1,1);
		dfs(v,-1,0);
		ll res=1;
		for(auto i:a) res*=i;
		return res;
	}
	void solve(){
		vi d=DIJ(0);
		P p={-1,0};
		for(int i=0;i<n;i++) p=max(p,{d[i],i});
		int v=p.second;
		d=DIJ(v);
		p={-1,0};
		for(int i=0;i<n;i++) p=max(p,{d[i],i});
		int u=p.second,c;
		D=d[u];
		vi d_=DIJ(u);
		for(int i=0;i<n;i++) if(d[u]==d[i]+d_[i]&&max(d[i],d_[i])<=d[u]/2) c=i;
		ll res=f(c);
		if(c<=n/2){
			for(auto c_:g[c]) res=min(res,f(c_));
		}
		cout<<D/2/2+1<<' '<<res<<endl;
	}
};

int n;

int main(){
	cin>>n;
	Graph g(2*n-1);
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		g.add_edge(u-1,n+i-1);
		g.add_edge(v-1,n+i-1);
	}
	g.solve();
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;

const ll INF = 1ll << 60;

int main()
{
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n)
    {
        int t;
        cin >> t;
        mp[t]++;
    }
    int num2 = 0;
    int num1 = 0;
    int ans = mp.size();
    for (auto x : mp)
    {
        if (x.second % 2 == 0)
        {
            num2++;
        }
        else
        {
            num1++;
        }
    }
    if (num2 % 2 == 0)
    {
        cout << ans << endl;
    }
    else
    {
        cout << ans - 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            C();
        }

        static void C()
        {
            var N = ReadInt();
            var ABC = new int[N+1, 3];
            var dp = new int[N+1, 3];

            for (var i = 0; i < N; i++)
            {
                var abc = ReadSplitInt();
                ABC[i, 0] = abc[0];
                ABC[i, 1] = abc[1];
                ABC[i, 2] = abc[2];
            }

            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    for (int k = 0; k < 3; k++)
                    {
                        if (j == k) continue;
                        dp[i + 1, k] = Max(dp[i + 1, k], dp[i, j] + ABC[i, k]);
                    }
                }
            }

            Println(Max(Max(dp[N, 0], dp[N, 1]), dp[N, 2]));
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 17464
# coding:UTF-8

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        self.rank = [0] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return
        elif self.rank[x] > self.rank[y]:
            self.parents[x] += self.parents[y]
            self.parents[y] = x
        else:
            self.parents[y] += self.parents[x]
            self.parents[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

if __name__ == '__main__':
    # ------ 入力 ------#
    # 1行入力
    n, m = list(map(int, input().split()))     # スペース区切り連続数字

    # 定数行入力
    x = m
    abList = sorted([list(map(int, input().split())) for _ in range(x)])     # スペース区切り連続数字(行列)

    # ------ 処理 ------#
    uf = UnionFind(n)
    for i in range(m):
        uf.union(abList[i][0]-1, abList[i][1]-1)

    out = max(uf.size(r) for r in uf.roots())
    # ------ 出力 ------#
    print("{}".format(out))



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

#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)

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

const int INF = 100000000;
const ll LINF = 1e18+5;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A;
    rep(i,N) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(), A.end());
    ll lhs = 0;
    ll rhs = 200001;
    rep(i,30) {
        ll D = (lhs + rhs) / 2;
        ll pos = 0;
        ll Dnum = 0;
        for(ll j=N-1;j>=0;j--) {
            while(A[pos]+A[j] < D) {
                pos++;
                if(pos==N) break;
            }
            if(pos==N) break;
            Dnum += (N-pos);
        }
        if(Dnum>=M) lhs = D;
        else rhs = D;
        if(lhs == rhs || lhs + 1 == rhs) break;
    }
    ll S[100001] = {};
    S[0] = 0;
    REP(i,1,N+1) {
        S[i] = S[i-1] + A[i-1];
    }
    ll D = lhs;
    ll pos = 0;
    ll ans = 0;
    ll count = 0;
    for(ll j=N-1;j>=0;j--) {
        while(A[pos]+A[j] < D) {
            pos++;
            if(pos==N) break;
        }
        if(pos==N) break;
        ans += S[N] - S[pos] + A[j] * (N - pos); 
        count += (N - pos);
    }
    if(count > M) {
        ans -= (count - M) * D;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1908
// {{{ Boilerplate Code <--------------------------------------------------
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

#define FOR(I,A,B) for(long long I = (A); I < (B); ++I)
#define ALL(A)     (A).begin(), (A).end()

using namespace std;

// }}}

long long solve(long long N,long long X,long long M){
        int prev[200000];
        FOR(i,0,M+1){
                prev[i]=-1;
        }

        long long A=X;
        prev[X]=0;

        long long ret=A;

        for(long long i=1; i<N;){
                A=(A*A)%M;

                long long prevpreva=prev[A];
                prev[A]=i;

                if(prevpreva != -1 && i>prevpreva && i-prevpreva <= M && N-i-3 > i-prevpreva) {
                        long long tmpsum=solve(i-prevpreva,A,M);
                        long long repeat = (N-i-2) / (i-prevpreva);
                        ret += tmpsum*repeat;
                        i+=(i-prevpreva)*repeat+1;
                        ret += A;
                } else{
                        ret += A;
                        ++i;
                }
        }

        return ret;
}

int main(){
        long long N,X,M;
        cin>>N>>X>>M;
        cout<<solve(N,X,M)<<endl;
}


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

using namespace std;

bool isTBD(const string &date) {
	auto year = string(date.begin(), date.begin()+4);
	auto month = string(date.begin()+5, date.begin()+7);
	auto day = string(date.begin()+8, date.end());

	if (year > "2019") return true;
	if (year == "2019" && month > "04") return true;

	return false;
}

int main() {
	string date;
	getline(cin, date);
	if (isTBD(date)) {
		cout << "TBD";
	} else {
		cout << "Heisei";
	}
}

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

bool check(int a1, int b1, int a2, int b2, int a3, int b3) {
    for (int i = 1; i < 5; ++i) {
        if (!(a1 == i || a2 == i || a3 == i || b1 == i || b2 == i || b3 == i)) {
            return false;
        }
    }
    return true;
}

int main() {
    int a[3], b[3];
    for (int i = 0; i < 3; ++i)
        cin >> a[i] >> b[i];
    
    bool res = false;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; j++) {
            if (i == j) {
                continue;
            }
            if (b[i] == a[j]) {
                for (int k = 0; k < 3; k++) {
                    if (i==k || j == k) {
                        continue;
                    }
                    if (b[j] == a[k] || b[j] == b[k]) {
                        res = check(a[i], b[i], a[j], b[j], a[k], b[k]);
                    }
                    if (res) break;
                }
            }
            if (b[i] == b[j]) {
                for (int k = 0; k < 3; k++) {
                    if (i==k || j == k) {
                        continue;
                    }
                    if (a[j] == a[k] || a[j] == b[k]) {
                        res = check(a[i], b[i], a[j], b[j], a[k], b[k]);;
                    }
                    if (res) break;
                }
            }
            if (a[i] == a[j]) {
                for (int k = 0; k < 3; k++) {
                    if (i==k || j == k) {
                        continue;
                    }
                    if (b[j] == a[k] || b[j] == b[k]) {
                        res = check(a[i], b[i], a[j], b[j], a[k], b[k]);;
                    }
                    if (res) break;
                }
            }
            if (a[i] == b[j]) {
                for (int k = 0; k < 3; k++) {
                    if (i==k || j == k) {
                        continue;
                    }
                    if (a[j] == a[k] || a[j] == b[k]) {
                        res = check(a[i], b[i], a[j], b[j], a[k], b[k]);;
                    }
                    if (res) break;
                }
            }
            if (res) break;
        }
        if (res) break;
    }
    if (res) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vll;
int main(){
  ll n, m;
  cin >> n >> m;
  vll a(m), b(m), exist(n+1);
  for (ll i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    if (a[i] == 1) {
      exist[b[i]]++;
    }
  }
  
  string ans = "IMPOSSIBLE";
  for (ll i = 0; i < m; i++) {
    if (exist[a[i]] > 0 && b[i] == n) {
      ans = "POSSIBLE";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4992
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	long MODULO = 1_000_000_000 + 7;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long[] x = new long[n];
		long[] y = new long[m];
		for (int i = 0; i < n; ++i) {
			x[i] = sc.nextLong();
		}
		for (int j = 0; j < m; ++j) {
			y[j] = sc.nextLong();
		}
		System.out.println(sum(x) * sum(y) % MODULO);
	}

	long sum(long[] arr) {
		int n = arr.length;
		long ret = 0;
		long s = 0;
		for (long v : arr) {
			s = (s + v - arr[0]) % MODULO;
		}
		for (int i = 0; i < arr.length; ++i) {
			ret = (ret + s) % MODULO;
			if (i + 1 < arr.length)
				s = (s - (n - 1) * (arr[i + 1] - arr[i]) % MODULO + MODULO) % MODULO;
			--n;
		}
		return ret;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 87472
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	deque<int>bb;
	map<int, int>aa;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		if (a == 1) {
			bb.push_back(b);
		}
		if (b == n) {
			aa[a] = i + 1;
		}
	}
	bool flag = false;
	rep(j, bb.size()) {
		if (aa[bb[j]]>0) {
			flag = true;
			break;
		}
    }
	
	if (flag) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
}

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

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

    int side = 0;
    list<string> ans;
    ans.push_back(s);
    for (int qq = 0; qq < q; qq++){
        int t;
        cin >> t;

        if (t == 1){
            side ^= 1;
        }
        else{
            int f;
            string c;
            cin >> f >> c;

            if (f == 1){
                if (side){
                    ans.push_back(c);
                }
                else{
                    ans.push_front(c);
                }
            }
            else{
                if (side){
                    ans.push_front(c);
                }
                else{
                    ans.push_back(c);
                }
            }
        }
    }
    
    string check;
    if (side){
        for (auto it = ans.rbegin(); it != ans.rend(); it++){
            string tmp = *it;
            for (int i = tmp.length() - 1; i >= 0; i--)
                cout << tmp[i];
        }
    }
    else{
        for (auto it = ans.begin(); it != ans.end(); it++){
            cout << *it;
        }
    }
    cout << '\n';

    return 0;
}



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


int main(){
    int x , n ;
    cin >> x >> n ;
    vector<int> p(n) ;
    if(n != 0 ) rep(i,n) cin >> p[i] ;
    sort(p.begin(),p.end()) ;
    int ans = 100000 ;
    int tem = 0 ;
    int count = 0 ;
    rep(i,1010){
        count = 0 ;
        rep(j,n) if( i == p[j] ) count++  ;
        if(count == 0 ){
            if( ans >= abs(x-i) ){
                if( ans != abs(x-i) ){
                    ans = abs(x-i) ;
                    tem = i - x ;
                }
            }
        } 
    }
    cout << x + tem << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
using namespace std;


int main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=s[i+1]){
            ans++;
        }
    }
    cout<<ans-1<<endl;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int K;
  cin >> K;
  int N=s.size();
  priority_queue<string,vector<string>,greater<string> > pq;
  set<string> se;
  string temp;
  for(int i=0;i<N;i++){
    pq.push(s.substr(i,1));
  }
  se.insert(pq.top());
  for(int i=1;i<K;i++){
    bool flag=false;
    temp=pq.top();
    for(int j=N-temp.size();j<N;j++){
      for(int k=1;k<=N-j;k++){
        if(pq.top()==s.substr(j,k)){
          pq.pop();
          flag=true;
          break;
        }
      }
      if(flag){
        break;
      }
    }
    if(se.count(pq.top())){
      temp=pq.top();
      while(temp==pq.top()){
        pq.pop();
        if(pq.empty()){
          break;
        }
      }
      for(int j=0;j<N-temp.size();j++){
        if(temp==s.substr(j,temp.size())){
          pq.push(s.substr(j,temp.size()+1));
        }
      }
    }
    se.insert(pq.top());
  }
  cout << *(next(se.begin(), K-1)) << endl;
  return 0;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define endl "\n"
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define ss second
#define ff first
#define vpii vector<pii>
#define vvi vector<vi >
#define vs vector<string>
#define all(x) x.begin(),x.end()
#define mii map<int,int>
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
#define M 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n,w;
        cin>>n>>w;
        ll wt[n],p[n],sum=0,sumwt=0;
        rep(i,n)
        {
            cin>>wt[i]>>p[i];
            sum+=p[i];
        }
        vector<ll> dp(sum+1,INT_MAX);
        dp[0]=0;
        rep(i,n)
        {
            for(ll j=sum-p[i];j>=0;j--)
            {
                dp[j+p[i]]=min(dp[j+p[i]],dp[j]+wt[i]);
            }
        }
        ll ans=0;
        rep1(i,sum)
        {
            if(dp[i]<=w)
            {
                ans=i;
            }
        }
        cout<<ans;
    }
}


Measured memory_bytes: 1024
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        a: usize,
        op: char,
        b: usize,
    }

    if op=='+' {
        println!("{}", a+b);
    } else if op=='-' {
        println!("{}", a as i64 - b as i64);
    } else {
        return;
    }

}


Measured memory_bytes: 2124
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stdio.h>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    pair< pair<string,int> ,int>  pairs[120];
    vector<string> s(n);
    vector<int> p(n);
    for(int i=0;i<n;i++) {
        cin >> s[i] >> p[i];
        pairs[i] = make_pair(make_pair(s[i],-1*p[i]),i);
    }
    sort(pairs,pairs+n);
    for(int i=0;i<n;i++) cout << pairs[i].second+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

def main():
    N = int(input())
    ans = N-1
    for i in range(2, 10 ** 6 + 1):
        if N % i == 0:
            tmp = (i-1) + (N // i -1)
            ans = min(ans, tmp)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <cstdlib>
#include <cstdio>

int main()
{
    int N,M;
    scanf("%d %d",&N,&M);
    N=(N<2?0:N*(N-1)/2);
    M=(M<2?0:M*(M-1)/2);
    printf("%d\n",N+M);
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;
//#define sort(a) sort(a.begin(),a.end())
//#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define ft first
#define sd second
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)

ll C[51][51]; //C[n][k] -> nCk

void comb_table(int N){ //O(n^2)
    fr(i,N+1){
        fr(j,i+1){
            if(j==0 or j==i)C[i][j]=1LL;
            else C[i][j]=C[i-1][j-1]+C[i-1][j];
        }
    }
}

int main(){
    int N,A,B;cin>>N>>A>>B;
    const int NMAX = 50;
    ll v[NMAX];
    fr(i,N)cin>>v[i];

    comb_table(N);
    sort(v,v+N);
    reverse(v,v+N);

    db ans1 = 0.0;
    fr(i,A)ans1 += v[i];
    ans1 /=A;

    int key1 = 0, key2 = 0;
    fr(i,N){
        if(v[i]==v[A-1]){
            key1++;
            if(i<A)key2++;
        }
    }
    ll cnt = 0;
    if(key2==A){
        for(key2=A;key2<=B;++key2){
            cnt += C[key1][key2];
        }
    }else{
        cnt += C[key1][key2];
    }
    cout.precision(20);
    cout << fixed << ans1<<endl;
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

int main(){
  set<int> si;
  int N,M,ans=0,penalty=0,pen[100010];
  cin>>N>>M;
  memset(pen, 0, sizeof(pen));
  REP(i,M){
    int p;
    string s;
    cin>>p>>s;
    if(s=="WA" && si.find(p)==si.end()){
      pen[p]++;
    }else if(s=="AC" && si.find(p) == si.end()){
      ans++;
      si.insert(p);
    }
  }
  FOR(i,1,N+1)if(si.find(i)!=si.end())penalty+=pen[i];

  cout<<ans<<" "<<penalty<<endl;
}


Measured memory_bytes: 5376
x = str(input())

if x == "SUN":
    print("7\n")
elif x == "MON":
    print("6\n")
elif x == "TUE":
    print("5\n")
elif x == "WED":
    print("4\n")
elif x == "THU":
    print("3\n")
elif x == "FRI":
    print("2\n")
elif x == "SAT":
    print("1\n")



Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=35,MAXM=1e6+5;const ll INF=1e18;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline ll read(){
	ll x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
struct Node{int S,P;ll C;}a[MAXN][MAXN];
int n,s,t,tot,num[MAXN],id[MAXN][MAXN]; 
struct Edge{int to,next;ll w,c;}edges[MAXM];
int cnt=1,head[MAXN*MAXN],cur[MAXN*MAXN],vis[MAXN*MAXN];ll dis[MAXN*MAXN];
inline void add(int x,int y,ll w,ll c){
	edges[++cnt]=(Edge){y,head[x],w,c},head[x]=cnt;
	edges[++cnt]=(Edge){x,head[y],0,-c},head[y]=cnt;
}
inline bool bfs(){
	memset(dis,0x3f,sizeof(dis)),memcpy(cur,head,sizeof(head));queue<int>q;q.push(s),dis[s]=0;
	for(int x;!q.empty();){
		x=q.front(),q.pop(),vis[x]=0;
		for(int i=head[x],y;i;i=edges[i].next)if(edges[i].w&&dis[x]+edges[i].c<dis[y=edges[i].to])
			dis[y]=dis[x]+edges[i].c,(!vis[y]?q.push(y),vis[y]=1:0);
	}return dis[t]<INF;
}
inline ll dfs(int x,ll dist){
	if(x==t||!dist)return dist;vis[x]=1;ll z=0;
	for(int&i=cur[x],y;i;i=edges[i].next)if(edges[i].w&&dis[y=edges[i].to]==dis[x]+edges[i].c&&!vis[y]){
		ll k=dfs(y,min(dist,edges[i].w));edges[i].w-=k,edges[i^1].w+=k,z+=k,dist-=k;if(!dist)break;
	}vis[x]=0;return z;
}
vector<pint>p,q;
inline void Solve(){for(ll d;bfs();){d=dfs(s,INF),p.push_back(mk(dis[t],d));if(d>(1ll<<50))break;}}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),s=tot=0,t=++tot;
	Rep(i,1,n){
		num[i]=read();id[i][0]=s,id[i][num[i]]=t;
		Rep(j,1,num[i]-1)id[i][j]=++tot;
		Rep(j,1,num[i])a[i][j]=(Node){read(),read(),read()};sort(a[i]+1,a[i]+num[i]+1,[](Node x,Node y){return x.S<y.S;});
		Rep(j,1,num[i])add(id[i][j-1],id[i][j],a[i][j].P,0),add(id[i][j-1],id[i][j],INF,a[i][j].C);
	}
	for(int t=read();t--;){
		int x=read(),y=read(),w=read();
		for(int i=1,j=1;i<=num[y];i++){
			for(;j<=num[x]&&a[x][j].S+w<a[y][i].S;j++);
			add(id[y][i-1],id[x][j-1],INF,0);
		}
	}
	Solve();ll x=0,y=0;
	for(auto o:p)q.push_back(mk(x,y)),x+=o.se,y+=o.se*o.fi;
	for(int t=read();t--;){
		ll A=read();int i=lower_bound(p.begin(),p.end(),mk(A,-INF))-p.begin();
		if(i==p.size())puts("-1");else cout<<(q[i].fi*A-q[i].se)<<'\n';
	}
	return 0;
}




Measured memory_bytes: 3840
#include<stdio.h>
#include<algorithm>
#include<iostream>
typedef long long ll;
using namespace std;
const int MAX=1e5+10;

ll a[MAX];
ll b[MAX],sumb[MAX],sumbb[MAX];
ll c[MAX],sumc[MAX];
ll n;
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
    for(int i=1;i<=n;i++) scanf("%lld",&c[i]);
    sort(a+1,a+1+n);
    sort(b+1,b+1+n);
    sort(c+1,c+1+n);

    for(int i=1;i<=n;i++)
    {
        ll pos=lower_bound(a+1,a+1+n,b[i])-a-1;
        if(a[pos]>=b[i])
            pos=pos-1;

        sumb[i]=pos;
    }

    for(int i=1;i<=n;i++)
    {
        ll pos=lower_bound(b+1,b+1+n,c[i])-b-1;
        if(b[pos]>=c[i])
            pos=pos-1;

        sumc[i]=pos;
    }
    //for(int i=1;i<=n;i++) printf("%d %d\n",sumb[i],sumc[i]);
    for(int i=1;i<=n;i++)
    {
        sumbb[i]=sumb[i]+sumbb[i-1];
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ll pos=lower_bound(b+1,b+1+n,c[i])-b-1;
        if(b[pos]>=c[i])
            pos-=1;

        ans=ans+sumbb[pos];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
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; }

int n;
struct abdata {
    long long a; long long b;
};

bool cmp(const abdata &aa, const abdata &bb) {
    return aa.a > bb.a;
}

vector< vector<long long> > dp(2020, vector<long long>(2020, 0));

int main() {
    cin >> n;
    vector<abdata> ain(n);
    for(int i = 0; i < n; ++i) {
        cin >> ain.at(i).a;
        ain.at(i).b = i;
    }
    sort(ain.begin(), ain.end(), cmp);

    for(int i = 0; i < n; ++i) {
        for(int j = 0; i+j < n; ++j) {
            chmax(dp[i+1][j], dp[i][j] + ain.at(i+j).a * (ain.at(i+j).b - i));
            chmax(dp[i][j+1], dp[i][j] + ain.at(i+j).a * ((n-1-j) - ain.at(i+j).b));
        }
    }

    long long ans = 0;
    for(int i = 0; i <= n; ++i) {
        chmax(ans, dp[i][n-i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 34960
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define ll long long int

int main(){
    ll N,X,T,S;

    scanf("%lld%lld%lld",&N,&X,&T);
    int n = N%X;
    S = (N/X) * T;
    if(n == 0){
       printf("%lld\n",S);
    }
    else
    {
        S = S+T;
        printf("%lld\n",S);
    }
    return 0;
}

Measured memory_bytes: 1724
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
	char S1[5000], S2[5000];
	int l1, l2;
	for (; scanf("%s %s", S1, S2) != EOF;) {
		l1 = strlen(S1);
		l2 = strlen(S2);
		int ans = 0;

		for (int p = -(l1 - 1); p < l2; p++) {
			int count = 0;
			for (int i = max(p, 0);; i++) {
				if (S1[i - p] == '\0' || S2[i] == '\0') break;
				if (S1[i - p] == S2[i]) {
					count++;
				}
				else {
					count = 0;
				}
				ans = max(ans, count);
			}
		}

		printf("%d\n", ans);
	}

	return 0;
}

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

ll divisor=1e9+7;
int main(){
	int n,m,x;
	cin>>n>>m>>x;
	int c[n],a[n][m];
	int sum[m]={},sum_cos=0;
	rep(i,n){
		cin>>c[i];
		sum_cos+=c[i];
		rep(j,m){
			cin>>a[i][j];
			sum[j]+=a[i][j];
		}
	}
	rep(i,m){
		if(sum[i]<x){
			puts(-1);
			return 0;
		}else{
			sum[i]-=x;
		}
	}
	int bi=1;
	rep(i,n)bi*=2;
	int ans=0;
	rep(i,bi){
		int sum_[m]={};
		int sum_cost=0;
		rep(j,n){
			if(i & (1<<j)){
				rep(k,m){
					sum_[k]+=a[j][k];
				}
				sum_cost+=c[j];
			}
		}
		rep(j,m){
			if(sum_[j]>sum[j])goto end;
		}
		ans=max(ans,sum_cost);
		end:;
	}
	puts(sum_cos-ans);
}

Measured memory_bytes: 3492
#include<cstdio>
using namespace std;
int n,ans=1;
char ch,now;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<=n;i++)
    {
        scanf("%c",&ch);
        if(i==1) now=ch;
        else if(i>1&&((int)ch!=(int)now))
        {
            ans++;
            now=ch;
        }
        //printf("%d\n",ans);
    }
    printf("%d\n",ans);
    return 0;
}




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

int main(){
  int n,m,i,j;
  cin>>n;
  string s[n];
  for(i=0;i<n;i++){
    cin>>s[i];
  }
  cin>>m;
  string t[m];
  for(i=0;i<m;i++){
    cin>>t[i];
  }
  string p[n+1];
  int cnt=0;
  for(i=0;i<n;i++){
    for(j=0;j<cnt;j++){
      if(s[i]==p[j]){
		  j++;
		  break;
	  }
    }
    if(j==0)j++;
	if(s[i]!=p[j-1]){
		p[cnt]=s[i];
		cnt++;
	}
  }
  int score[cnt];
  for(i=0;i<cnt;i++){
    score[i]=0;
    for(j=0;j<n;j++){
      if(p[i]==s[j])score[i]++;
    }
    for(j=0;j<m;j++){
      if(p[i]==t[j])score[i]--;
    }
  }
  int ma=0;
  for(i=0;i<cnt;i++){
    ma=max(ma,score[i]);
  }
  cout<<ma;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>bool chmax(T &a, const T &b) { if (a<=b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<=a) { a=b; return 1; } return 0; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

ll modpow(ll a,ll n,ll m) {
    ll ret=1;
    ll now=a;
    while(n>0) {
        if(n%2==1) ret=ret*now%m;
        now=now*now%m;
        n/=2;
    }
    return ret;
}

int main() {
    string s;
    cin>>s;
    int n=sz(s);
    vector<ll> A(n+10),AB(n+10),ABC(n+10);
    ll cnt=0;
    rep(i,n) {
        if(s[i]=='A' || s[i]=='?') {
            A[i+1]+=A[i]+modpow(3,cnt,MOD);
            AB[i+1]+=AB[i];
            ABC[i+1]+=ABC[i];
        }
        if(s[i]=='B' || s[i]=='?') {
            A[i+1]+=A[i];
            AB[i+1]+=A[i]+AB[i];
            ABC[i+1]+=ABC[i];
        }
        if(s[i]=='C' || s[i]=='?') {
            A[i+1]+=A[i];
            AB[i+1]+=AB[i];
            ABC[i+1]+=AB[i]+ABC[i];
        }
        A[i+1]%=MOD;
        AB[i+1]%=MOD;
        ABC[i+1]%=MOD;
        
        if(s[i]=='?') cnt++;
    }
    cout<<ABC[n]<<endl;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
int a[maxn],vis[maxn];
vector<int>g;
int main()
{
    fastio();
    ll n,k;
    cin>>n>>k;
    rep(i,1,n) cin>>a[i];
    int u = 1;
    int tt,pos;
    while(1){
        if(vis[u]) {tt=u;break;}
        g.pb(u);
        vis[u] = 1;
        u = a[u];
    }
    int sz = g.size();
    rep(i,0,sz-1) if(g[i]==tt) {pos=i;break;}
    ll r = sz-pos;
    if(k<=pos){
        cout<<g[k]<<endl;
    }else{
        ll e = k-pos;
        e %= r;
        cout<<g[pos+e]<<endl;
    }
    return 0;
}


Measured memory_bytes: 5836
#include<iostream>
#include<cstdlib>
#include<cstdio>
#define w 15*16+15
using namespace std;
int fld[8][3]={0,0,0,0,0,w,0,w,
	0,0,w,w,w,0,0
	,w,0,w,w,w,0,w,w,w};
char* col[]={"black",
	"blue","lime","aqua",
	"red","fuchsia",
	"yellow","white"};
int main(){
	int temp,t,x,y,z,a[8],ren;
	char s[10];
	while(cin>>s,s[0]!='0'){
		temp=100000000;
		for(int i=1;i<8;i++){
			if(s[i]>'9')
			a[i-1]=9+s[i]-'a';
			else a[i-1]=s[i]-'0';
		}
		for(int i=0;i<8;i++){
			x=a[0]*16+a[1]-fld[i][0];
			y=a[2]*16+a[3]-fld[i][1];
			z=a[4]*16+a[5]-fld[i][2];
			ren=x*x+y*y+z*z;
			if(ren<temp){
				t=i;
				temp=ren;
			}
		}cout<<col[t]<<endl;
	}
	return 0;
}

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

int main() {
	

	int N, X, x[100000];
	cin >> N >> X;
	rep(i, N) {
		cin >> x[i];
		x[i] = abs(x[i] - X);
	}

	int r0 = x[0];
	rep(i, N - 1) {
		int r1, r2, r4;
		r1 = max(r0, x[i + 1]);
		r2 = min(r0, x[i + 1]);

		while (r2) {
			r4 = r2;
			r2 = r1 % r2;
			r1 = r4;
		}
		r0 = r1;
	}
	cout << r0 << "\n";
	Would you please return 0;

}

Measured memory_bytes: 640
import math
a,b,c=map(int, input().split(" "))
ans1=a+1
#ans2=(a-1)%b+math.floor((a-1)/b)*c
num1=a-b+1
#print(c*(math.floor(num1/2)))
#print(b*(math.floor(num1/2)))
#print((c-(b-1))*(math.floor(num1/2)))
ans2=((c-b))*(math.floor(num1/2))
ans2+=b+num1%2
#print()
#print(math.floor(a/b)*c)
#print(math.floor((a+1)%b))
print(max(ans1,ans2))

Measured memory_bytes: 3060
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll arr[100005];

int main() {
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
	}
	ll ans = 0;
	ll cnt = 0;
	stack<ll> S;
	for(int i = 0; i < N; i++) {
		if(S.empty()) {
			S.push(arr[i]);
			// cout << arr[i] << "thosn";
		}
		else {
			if(arr[i] <= S.top()) {
				// cout << arr[i] << " hey\n";
				S.push(arr[i]);
				cnt++;
				ans = max(cnt, ans);
			}
			else {
			 	cnt = 0;
			 	// cout << arr[i] << "yo\n";
				 while(!S.empty()) {
				 	S.pop();
				 }
				 S.push(arr[i]);
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 1792
l="keyence"
i=input()
if i[:7]==l or i[-7:]==l: 
    print("YES")
    exit()
for s in range(1,7):
    if (l[:s] in i) and (l[s:] in i):
        if (i.find(l[:s]) < i.find(l[s:])) and (i.find(l[:s])==0 and i[-1]=="e"):
            print("YES")
            exit()
print("NO")

Measured memory_bytes: 3064
#include <cstdio>


using namespace std;

typedef long long int ll;

int main(){
    ll N;
    scanf("%lld",&N);

    if (N==2){
        puts("1");
        return 0;
    }

    int c=2;
    for(ll K=2;K*K<=N;K++) 
        if (N%K==0){
            ll temp=N;
            while (temp%K==0) temp=temp/K;
            if (temp%K==1) c++;
        }

    for(ll K=2;K*K<=N-1;K++) {
        if ((N-1)%K==0){
            ll another=(N-1)/K;
            c++;
            // printf("%lld\n",K);
            if (another!=K) c++;
        }
    }
    
    printf("%d\n",c);

    return 0;
}

Measured memory_bytes: 128
/*

*/
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout << setprecision(12)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((ll)(x).size())
#define cin1(x) cin >> x
#define cin2(x, y) cin >> x >> y
#define cin3(x, y, z) cin >> x >> y >> z
#define cin4(x, y, z, _) cin >> x >> y >> z >> _
#define cin5(x, y, z, p, q) cin >> x >> y >> z >> p >> q
#define cou(x) cout << x
#define cous(x) cout << x << " "
#define coul(x) cout << x << "\n"
#define ret(x) return x
#define MAX 1000000007
#define start int main() {   fastio
#define finish ret(0); }
#define Test ll _t; cin1(_t); rep(w, 0, _t)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cntv(v,a) count(v.begin(),v.end(),a)
#define fans(x) \
    if ( x  ) coul("YES"); \
    else coul("NO")
#define mset(x, y) memset(x, y, sizeof(x))
#define fileshow  freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)

struct point{    int x, y, ind;   char ch;  };
typedef long long ll;
typedef vector<ll> VI;
typedef pair<ll,ll> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod=1000000007;
//ll rnd(ll x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}ret(res);}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[13];
void factorial() {   fact[0]=1;  rep(i, 1, 12) fact[i]=(fact[i-1]*i);  }
 //for sieve function
//void sieve() {    rep(i, 2, MAX)  {  if (spf[i] == 0) {  spf[i] = i;   sie.pb(i);  }    for (ll j=0; j<SZ(sie) && i*sie[j] <= MAX && sie[j] <= spf[i]; j++)   spf[i * sie[j]] = sie[j]; }   }
bool cmp(point A, point B){   if(A.x != B.x) ret(A.x < B.x);  ret(A.y < B.y);   }
//void segPre(ll l, ll h, ll in) {  ll segTree[3*mx];   if ( l == h ){  segTree[ in ] = arr[ l ];   return;  }   ll m = (l + h) / 2; pre(l, m, 2*in);  pre(m+1, h, 2*in+1);    segTree[ in ] = segTree[ in*2 ] | segTree[ in*2+1 ];   segTree[ in ] = segTree[ in*2 ] ^ segTree[ in*2+1 ];    }
// head collected
// Don't use variable name as --> prev, time, _t, w, y1
// Don't use ceil and pow function

ll a, b, c, d, _1, _2;


start;

    cin4(a, b, c, d);

    _1 = ceil((c*1.0)/b);
    _2 = ceil((a*1.0)/d);

    if ( _1 <= _2)
        coul("Yes");
    else
        coul("No");

finish


/*
5 4
3 1 8 9 7
1 1 5
1 2 12
1 9 3
2 1 5


*/


Measured memory_bytes: 3760
import java.util.Scanner;

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

    int x1 = scanner.nextInt();
    int y1 = scanner.nextInt();
    int x2 = scanner.nextInt();
    int y2 = scanner.nextInt();
    int x3 = x2 + y1 - y2;
    int y3 = y2 + x2 - x1;
    int x4 = x3 + y2 - y3;
    int y4 = y3 + x3 - x2;
    System.out.printf("%d %d %d %d\n", x3, y3, x4, y4);
  }
}


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

int main(){
  int N, T;
  cin >> N >> T;
  int ans=1001;
  for(int i=0; i<N; i++){
    int c,t;
    cin >> c >> t;
    if(t<=T){
      ans=min(ans, c);
    }
  }
  if(ans==1001) cout << "TLE" << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, 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);
}
pii Dir [] = {
	{ 1,0 },{ 0,1 }
};



signed main() {
	int h, w;
	scanf("%d %d", &h, &w);

	REP(i, h) {
		char str [100000];
			scanf("%s", str);
			printf("%s\n%s\n", str,str);
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,string> pis;
#define fi first
#define se second
#define mkp make_pair
void writes(string s){for(int i=0;i<s.size();i++)putchar(s[i]);}
int Ask_(string s){
	int x;
	writes("? "),writes(s),puts("");
	fflush(stdout);
	scanf("%d",&x);
	return x;
}
void Answer_(string s){
	writes("! "),writes(s);
}
vector<char>v;
int L=128,n,cnt[62];
string S;
priority_queue<pis,vector<pis>,greater<pis> >pq;
string Merge_String(string s,string t){
	int i=0,j=0;
	string ans;
	while (i<s.size()&&j<t.size()){
		string S=s.substr(0,i+1)+t.substr(j);
		if (Ask_(S)==n-S.size())ans.push_back(s[i]),i++;
		else ans.push_back(t[j]),j++;
	}
	while (i<s.size())ans+=s[i++];
	while (j<t.size())ans+=t[j++];
	return ans;
}
int main(){
	for(char c='a';c<='z';c++)v.push_back(c);
	for(char c='A';c<='Z';c++)v.push_back(c);
	for(char c='0';c<='9';c++)v.push_back(c);
	for(int i=0;i<62;i++){
		S="";
		for(int j=0;j<L;j++)S.push_back(v[i]);
		cnt[i]+=L-Ask_(S);
	}
	for(int i=0;i<62;i++){
		n+=cnt[i],S="";
		for(int j=0;j<cnt[i];j++)S.push_back(v[i]);
		pq.push(mkp(cnt[i],S)); 
	}
	while(pq.size()>1){
		pis x=pq.top();pq.pop();
		pis y=pq.top();pq.pop();
		pq.push(mkp(x.fi+y.fi,Merge_String(x.se,y.se))); 
	}
	Answer_(pq.top().se);
}

Measured memory_bytes: 3768
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    m = int(readline())
    t = 0
    cnt = 0
    for i in range(m):
        d, c = list(map(int, readline().split()))
        t += d * c
        cnt += c
    print(cnt - 1 + (t - 1) // 9)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 40812
#coding:utf-8
n, x = map(int, input().split())
l = list(map(int, input().split()))

d = [0]

#跳ねる座標を計算
for i in range(1, n+1):
    tmp = d[i-1] + l[i-1]
    d.append(tmp)

#print(d)

#判定
counter = 0

for i in range(len(d)):
    if d[i] <= x:
        counter += 1
    else:
        break

print(counter)




Measured memory_bytes: 3060