akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//  test
//
//  Created by liuyuhan on 20/10/2018.
//  Copyright © 2018 liuyuhan. All rights reserved.
//

#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    int N, T;
    cin >> N >> T;
    int min_c = 1005;
    for(int i=0; i < N; i++) {
        int c, t;
        cin >> c >> t;
        if (t > T)
            continue;
        else {
            if (c < min_c) {
                min_c = c;
            }
        }
    }
    if (min_c == 1005)
        cout << "TLE" << endl;
    else {
        cout << min_c << endl;
    }
    return 0;
}


Measured memory_bytes: 256
x, y = map(int, input().split())
k = (y - 2*x)/2
t = (4 * x - y)/2
ans = "No"
if(k >= 0):
  if(k % 1 == 0):
    if(t >= 0):
      if(t % 1 == 0):
        ans = "Yes"
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>
using namespace std;

int dp(int k, int w, int* a, int* b);

int main(void){
    // Your code here!
    int n;
    std::cin >> n;
    long t = 0;
    int count = 0;
    for(int i = 0; i < n; i++){
        std::cin >> t;
        while(t % 2 == 0){
            t = t / 2;
            count++;
        }
    }
    std::cout << count << std::endl;
}

int dp(int k, int w, int* a, int* b){
    int result = 0;
    if(k == 1){
        if(a[1] > w){
            result = 0;
        } else {
            result = b[1];
        }
    } else {
        if(a[k] > w){
            result = dp(k-1, w, a, b);
        } else {
            result = max(dp(k-1, w, a, b),dp(k-1, w - a[k], a, b) + b[k]);
        }
    }
    return result;
}


Measured memory_bytes: 256
function Main(input) {
    var antena = input.slice(0, 5).map(i => parseInt(i, 10));
    var K = parseInt(input[5], 10);

    var result = 'Yay!';

    for (var i = 1; i < antena.length; i++) {
        for (var j = 0; j < i; j++) {
            if ((antena[i] - antena[j]) > K) {
                result = ':(';
            }
        }
    }
    
    console.log(result);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 7372
import re

s = input().strip()

def check(s):
    p = [
            '\A.*keyence\Z'
            , '\Ak.*eyence\Z'
            , '\Ake.*yence\Z'
            , '\Akey.*ence\Z'
            , '\Akeye.*nce\Z'
            , '\Akeyen.*ce\Z'
            , '\Akeyenc.*e\Z'
            , '\Akeyence.*\Z'
        ]
    for _p in p:
        if re.match(_p, s):
            return True
        # print(s, _p)
    return False

print('YES' if check(s) else 'NO')


Measured memory_bytes: 3188
#include <stdio.h>

int main(void) {
	int e,m,y = 0,z = 0;
	while(scanf("%d",&e) , e != 0){
		m = 1000001;
		for(z = 0;z*z*z <= e;z++){
			for(y = 0;z*z*z+y*y <= e;y++){
				if(z + y + (e - (z*z*z + y*y)) < m){m = z + y + (e - (z*z*z + y*y));}
			}
		}
		printf("%d\n",m);
	}
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,m,i,ma,mb,mina,minb,min;
    scanf("%d %d %d",&a,&b,&m);
    int as[a],bs[b],ms[m][3];
    for(i=0; i<a; i++){
        scanf("%d",&as[i]);
    }
    for(i=0; i<b; i++){
        scanf("%d",&bs[i]);
    }
    for(i=0; i<m; i++){
        scanf("%d %d %d",&ms[i][0],&ms[i][1],&ms[i][2]);
    }
    mina=as[0];
    minb=bs[0];
    for(i=1; i<a; i++){
       if(mina>as[i])
        mina=as[i];
    }/*割引券無し*/
    for(i=1; i<b; i++){
        if(minb>bs[i])
            minb=bs[i];
    }
    
    min=mina+minb;

    for(i=0; i<m; i++){
        ma=ms[i][0]-1;
        mb=ms[i][1]-1;
        if(min>as[ma]+bs[mb]-ms[i][2])
            min = as[ma]+bs[mb]-ms[i][2];
    }
    printf("%d\n",min);
    return 0;
}


Measured memory_bytes: 2176
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

const int MaxN = 100;
using namespace std;

int A, B, a[MaxN + 5][MaxN + 5];
int main() 
{
	while(~scanf("%d%d", &B, &A)) {
		A--; B--;
		memset(a, 0, sizeof(a));
		for (int i = 1; i <= 50; i += 2) {
			for (int j = 2; j <= 100; j += 2) {
				if (A == 0) break;
				a[i][j] = 1;
				A--;
			}
		}
		for (int i = 51; i <= 100; i++)
			for (int j = 1; j <= 100; j++)
				a[i][j] = 1;
		for (int i = 100; i >= 51; i -= 2) {
			for (int j = 2; j <= 100; j += 2) {
				if (B == 0) break;
				a[i][j] = 0;
				B--;
			}
		}
		printf("100 100\n");
		for (int i = 1; i <= 100; i++) {
			for (int j = 1; j <= 100; j++) {
				printf("%c", a[i][j] == 1 ? '#' : '.');
			}
			printf("\n");
		}
	}
	return 0;
}

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

int main(void){

    int N,M; cin>>N>>M;
    pair<pair<int, int>, int> a[M];
    for (int i = 0; i < M; ++i) {
        int P,Y; cin>>P>>Y;
        a[i] = make_pair(make_pair(P,Y),i);
    }
    sort(a, a+M);

    vector<ll> ans(M);
    int prefec=a[0].first.first, year=1;

    for (int i = 0; i < M; ++i) {
        ll zenhan=0;
        if(a[i].first.first == prefec){
            zenhan = ll(prefec)*1000000+year;
        }else{
            year=1;
            zenhan = ll(a[i].first.first)*1000000+year;
        }
        year++;
        prefec = a[i].first.first;
        ans[a[i].second] = zenhan;
    }

    for (int i = 0; i < M; ++i) {
        cout<<setfill('0')<<setw(12)<<right<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3456
import java.util.*;
import java.io.*;

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}

//......................................@uthor_Alx..............................................
static int g=2;
static int f(int[] a, int[] b){
	if(a[0]+a[1]>=g&&b[0]+b[1]>=g){
		return a[0]-b[0];
	}
	return b[0]+b[1]-a[0]-a[1];
}
   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  	int[] a=int_arr();
	        		  	for(int i=0;i<a.length;i++){
	        		  		if(a[i]==0){
	        		  			out.write(i+1+"");
	        		  			break;
	        		  		}
	        		  	}
	
                      out.flush();
	        		 
	}
}
	       
	          



	
  





	
  





Measured memory_bytes: 36368
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

vector<int> G[710];
vector<P> a;
int w, b;
struct BipartiteGraph{
    int n;    
    vector<int> color;
    BipartiteGraph(int _n){
        n = _n;
        color.resize(n, 0);
    }
    bool dfs(int v, int c){
        color[v] = c;
        if(c == 1) w++;
        else b++;
        bool res = true;
        for(int i = 0; i < G[v].size(); i++){
            if(color[G[v][i]] == c) res &= false;
            if(color[G[v][i]] == 0) res &= dfs(G[v][i], -c);
        }
        return res;
    }
    bool isBipartiteGraph(){
        bool res = true;
        for(int i = 0; i < n; i++){
            if(color[i] == 0){
                w = b = 0;
                res &= dfs(i, 1);
                a.push_back({w, b});
            }
        }
        return res;
    }
};

bool f[710][710];
bool used[710];
bool dp[710], nxt[710];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    rep(i, 0, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        f[a][b] = true;
        f[b][a] = true;
    }
    rep(i, 0, n){
        rep(j, i + 1, n){
            if(f[i][j]) continue;
            G[i].push_back(j);
            G[j].push_back(i);
        }
    }
    BipartiteGraph bg(n);
    if(!bg.isBipartiteGraph()){
        cout << -1 << endl;
        return 0;
    }
    dp[0] = true;
    rep(i, 0, a.size()){
        rep(j, 0, 710) nxt[j] = false;
        rep(j, 0, 710){
            if(!dp[j]) continue;
            nxt[j + a[i].first] = true;
            nxt[j + a[i].second] = true;
        }
        swap(dp, nxt);
    }
    int ans = INF;
    rep(i, 0, n + 1){
        if(!dp[i]) continue;
        int tmp = i * (i - 1) / 2 +  (n - i) * (n - i - 1) / 2;
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6016
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	vector<int> H;
	int ans = 0;
	
	cin>>N;
	
	H.resize(N+1);
	
	H[N] = INF;
	
	for(int i = 0; i < N; i++){
		cin>>H[i];
	}
	
	for(int i = 0, con = 0; i < N; i++){
		if(H[i] >= H[i+1]){
			con++;
		} else {
			ans = max(con, ans);
			con = 0;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

int main() {
	int a,b,c,d;
cin>>a>>b>>c>>d;
int ans;
if(a==c-1||a==12&&c==1){
ans=1;
}
else {
ans=0;
}
cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>










int main(){
 int i,j,n,q;
 int count=0;
 int pivot;

scanf("%d",&n);
int S[n];
for(i=0;i<n;i++){ scanf("%d",&S[i]);}

scanf("%d",&q);
int T[q];
for(i=0;i<q;i++){ scanf("%d",&T[i]);}

pivot=S[n/2];

for(i=0;i<q;i++){ 
 if(T[i]<pivot){
  for(j=0;j<n/2;j++){ if(T[i]==S[j]){count++; break;}}
 }else{
  for(j=n/2;j<n;j++){ if(T[i]==S[j]){count++; break;}}
 }

}





printf("%d\n",count);

return 0;
} 

Measured memory_bytes: 2332
import java.util.*;

public class Main {
	public static void main(String[] args) {

            // 入力されるx,yを定義
			Scanner scanner = new Scanner(System.in);
            int x = scanner.nextInt();
            int y = scanner.nextInt();

            // 計算式
            int d = x / y;
            int r = x % y;
            double f = (double)x / y;

            System.out.println(d + " " + r + " " + String.format("%.8f", f));
	}
}



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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
auto& errStream=cerr;
#ifdef LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	string s=readString();
	int n=s.size();
	const string t="keyence";
	REP(i,n+1)REP(j,n-i+1){
		string x=s.substr(0,i)+s.substr(n-j,j);
		if(x==t)
			Yes();
	}
	No();
}


Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
typedef long long ll;
const int N=100010;
bool w[N];
long long sz[N];
int fa[N],a[N],b[N],Mx[N],id[N];
vector <int> q[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline bool cmp(const int &x,const int &y) {return a[x]<a[y];}
inline int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}
int main() {
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++) {
	a[i]=gi(),b[i]=gi(),id[i]=i,fa[i]=i;
	Mx[i]=a[i]=max(0,a[i]-b[i]),sz[i]=b[i];
    }
    for(int i=1;i<=m;i++) {
	int x=gi(),y=gi();
	q[x].push_back(y),q[y].push_back(x);
    }
    sort(id+1,id+1+n,cmp);
    for(int i=1;i<=n;i++) {
	int x=id[i];w[x]=1;
	for(int j=0;j<q[x].size();j++)
	    if(w[q[x][j]]) {
		int y=find(q[x][j]);
		if(x!=y) {
		    sz[x]+=sz[y],fa[y]=x;
		    Mx[x]=min(1LL*Mx[x],Mx[y]+max(0LL,a[x]-sz[y]-Mx[y]));
		}
	    }
	if(i==n) cout<<Mx[x]+sz[x];
    }
    return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

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

void d_err() {
    cerr << endl;
}

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

template <typename T>
void print(T x) {
    cout << x << endl;
}

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

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

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

int NMAX = 1e5 + 10;

vector<vector<int>> E(NMAX);
vector<int> d1(NMAX), d2(NMAX);
vector<bool> used(NMAX, false);

int dfs(int node, int depth) {
    d1[node] = depth;
    used[node] = true;

    int md = depth;
    for(auto &e: E[node]) {
        if (used[e]) continue;

        int d = dfs(e, depth + 1);

        md = max(d, md);
    }

    return d2[node] = md;
}

int solve(int node, int step) {
    used[node] = true;
    if (step > d1[node]) return 0;

    int res = d2[node] - 1;
    for(auto &e: E[node]) {
        if (used[e]) continue;

        res = max(res, solve(e, step+1));
    }

    return res;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, u, v;
    cin >> N >> u >> v;
    u--; v--;

    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        E[a].pb(b);
        E[b].pb(a);
    }

    dfs(v, 0);

    used.assign(N, false);

    print(solve(u, 0));
    
}


Measured memory_bytes: 14528
#include <bits/stdc++.h>
using namespace std;
/*
*/
int dp[100005];
int a[100005];
int main () {
	int n;
	cin >> n;
	for (int i=0; i<n; ++i)
		cin >> a[i];
	if (n==2) {
		cout << abs(a[1]-a[0]);
		return 0;
	}
	dp[n-2] = abs(a[n-1]-a[n-2]);
	//dp[n-3] = a[n-1]-a[n-3];
	for (int i=n-3; i>=0; --i)
		dp[i] = min(dp[i+1]+abs(a[i]-a[i+1]), dp[i+2]+abs(a[i]-a[i+2]));
	cout << dp[0];
	return 0;
}


Measured memory_bytes: 1024
a,b = map(int,input().split())
def f(x):
    if x % 2 ==1:
        if ((x-1)//2)%2==0:
            return 1
        else:
            return 0

    else:
        if ((x-2)//2)%2 == 0:
            return x^1
        else:
            return x
print(f(a-1)^f(b))


Measured memory_bytes: 3060
import sys
from collections import deque
input = sys.stdin.readline


def compress_coordinate(x: list, key=None, reverse=False):
    zipped = {}
    unzipped = {}
    for i, xi in enumerate(sorted(set(x), key=key, reverse=reverse)):
        zipped[xi] = i
        unzipped[i] = xi
    return zipped, unzipped


n, m = map(int, input().split())
line_v = [tuple(map(int, input().split())) for _ in range(n)]
line_h = [tuple(map(int, input().split())) for _ in range(m)]

INF = 10**9 + 10
dx = [+1, 0, -1, 0]
dy = [0, +1, 0, -1]

x_list = [-INF, 0, INF]
y_list = [-INF, 0, INF]
for x1, x2, y in line_v:
    # abc
    x_list.append(x1)
    x_list.append(x2)
    y_list.append(y)
for x, y1, y2 in line_h:
    # def
    x_list.append(x)
    y_list.append(y1)
    y_list.append(y2)

x_zipped, x_unzipped = compress_coordinate(x_list)
y_zipped, y_unzipped = compress_coordinate(y_list)

nx = len(x_zipped)
ny = len(y_zipped)

v_ng = [[0] * (ny + 1) for _ in range(nx + 1)]
h_ng = [[0] * (ny + 1) for _ in range(nx + 1)]
for x1, x2, y in line_v:
    x1 = x_zipped[x1]
    x2 = x_zipped[x2]
    y = y_zipped[y]
    v_ng[x1][y] += 1
    v_ng[x2][y] -= 1
for x, y1, y2 in line_h:
    x = x_zipped[x]
    y1 = y_zipped[y1]
    y2 = y_zipped[y2]
    h_ng[x][y1] += 1
    h_ng[x][y2] -= 1

for x in range(nx):
    for y in range(ny):
        v_ng[x + 1][y] += v_ng[x][y]
        h_ng[x][y + 1] += h_ng[x][y]

# print(nx, ny)
grid = [[False] * (ny + 1) for _ in range(nx + 1)]
q = deque([(x_zipped[0], y_zipped[0])])
while q:
    x0, y0 = q.popleft()
    if grid[x0][y0]:
        continue
    grid[x0][y0] = True
    for k in range(4):
        x1 = x0 + dx[k]
        y1 = y0 + dy[k]
        if x1 < 0 or x1 >= nx or y1 < 0 or y1 >= ny:
            continue
        if grid[x1][y1]:
            continue

        if k == 0 and h_ng[x1][y1] == 0:
            # move x-dir
            q.append((x1, y1))
        elif k == 2 and h_ng[x0][y0] == 0:
            # move x-dir
            q.append((x1, y1))
        elif k == 1 and v_ng[x1][y1] == 0:
            # move y-dir
            q.append((x1, y1))
        elif k == 3 and v_ng[x0][y0] == 0:
            # move y-dir
            q.append((x1, y1))

# print(*grid, sep='\n')
if grid[0][0]:
    ans = 'INF'
else:
    ans = 0
    for x in range(nx):
        for y in range(ny):
            if grid[x][y]:
                ans += (x_unzipped[x + 1] -
                        x_unzipped[x]) * (y_unzipped[y + 1] - y_unzipped[y])

print(ans)


Measured memory_bytes: 376040
#include <bits/stdc++.h>
using namespace std ;
///CHECKING @Tanvir
#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define piii pair<int, pii>
#define mp make_pair


#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(int i=a; i<=b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0)


const int mod = 1e9 + 7;

int ADD(int a, int b, int m = mod) {
    int s = a;
    s += b;
    if( s >= m )
      s -= m;
    return s;
}

int MUL(int a, int b, int m = mod) {
    return (1LL * a * b % m);
}

int power(int a, int b, int m = mod) {
    int res = 1;
    while( b ) {
        if( b & 1 ) {
            res = 1LL * res * a % m;
        }
        a = 1LL * a * a % m;
        b /= 2;
    }
    return res;
}


const int maxn = 1e5 + 5;




int main()
{
    IO;
    int n, k;
    cin>>n>>k;
    int r, sc, p;
    cin>>r>>sc>>p;

    string s;
    cin>>s;

    vector<char> ans(n);

    for(int i=0; i<k; i++){
        if(s[i]=='r') ans[i] = 'p';
        else if(s[i]=='p') ans[i]= 's';
        else if(s[i]=='s') ans[i]= 'r';
    }
    ///d= draw

    for(int i=k; i<n; i++){
        if(s[i]=='r'){
            if(ans[i-k]=='p') ans[i]= 'd';
            else ans[i] = 'p';
        }
        else if(s[i]=='p'){

            if(ans[i-k]=='s') ans[i]= 'd';
            else ans[i]= 's';

        }
        else if(s[i]=='s'){
                if(ans[i-k]=='r') ans[i]= 'd';
                else ans[i]= 'r';
        }

    }
    /*
    for(int i=0; i<n; i++){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
    */
    ll sum = 0;
    for(int i=0; i<n; i++){
        if(ans[i]=='r') sum+= r;
        else if(ans[i]=='p') sum+= p;
        else if(ans[i]=='s') sum+= sc;
    }
    cout<<sum<<"\n";


    return 0;
}

/*********************************************

5 2
8 7 6
rsrpr





********************************************/


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans;
  if ((B-A)%2==0) ans = (B-A)/2;
  else ans = min(A-1, N-B)+1+(B-A-1)/2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;

  return 0;
}


Measured memory_bytes: 3636
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto H = RD;
	auto W = RD;
	long ans;
	if (H % 3 == 0 || W % 3 == 0)
	{
		ans = 0;
	}
	else
	{
		long f(long x, long y)
		{
			long f2(long ax, long bx)
			{
				long a = ax * y;
				long by1 = y / 2;
				long by2 = y / 2 + (y % 2);
				long[] abc;
				abc ~= a; abc ~= bx * by1; abc ~= bx * by2;
				abc.sort();
				return abs(abc[0] - abc[2]);
			}
			long xmod = x % 3;
			auto r    = min(f2(x/3, x/3*2+xmod), f2(x/3+xmod, x/3*2));
			if (xmod == 2) r = min(r, f2(x/3+1, x/3*2+1));
			return min(r, y);
		}
		ans = min(f(H, W), f(W, H));
	}
	writeln(ans);
	stdout.flush();
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<stdlib.h>
using namespace std;

int main()
{
	int i,j,m,h;
	string s;
	char temp[200];
	while(getline(cin,s)){
		if(s == "-") return 0;
		cin>>m;
		for(i=0;i<m;i++){
			cin>>h;
			for(j=0;j<h;j++)
				temp[j] = s[j];
			for(j=0;j<(s.size()-h);j++){
				s[j] = s[j+h];
			}
			for(;j<s.size();j++)
				s[j] = temp[j - (s.size()-h)];
		}
		cout<<s<<endl;
		cin.ignore();
	}
	return 0; 
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

int main(){
	fastread;
	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> b(500001);
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[a[i]] += 1;
	}
	ll ans = 0;


	for(int i=0;i<b.size();i++){
		ll k = b[i];
		ans += (k*(k-1))/2;
	}
	for(int i=0;i<n;i++){
		ll k = b[a[i]];
		ll tans = ans - (k*(k-1))/2;
		k --;
		tans += (k*(k-1))/2;
		cout<<tans<<endl;
	
	}
	

	return 0;
}


Measured memory_bytes: 5376
#include <stdio.h>

int narabikae(int a[],int N);		//数字を降順に

int main(void){
	int N,i,j;
	scanf("%d",&N);
	
	int a[N],sum=0;
	
	for(i=0;i<N;i++){
	scanf("%d",&a[i]);
	}
	
	i=0;
	
	narabikae(a,N);
	
	for(i=1;i<N;i++) sum+=a[i];
	
	if(a[0]<sum) printf("Yes");
	else printf("No");
	
	return 0;
}

int narabikae(int a[],int N){
	int tmp,i,j=0;
	while(j<N){
		for(i=1;i<N;i++){
			tmp=0;
			if(a[i-1]<a[i]){
				tmp=a[i-1];
				a[i-1]=a[i];
				a[i]=tmp;
			}	
		}
		j++;
	}
	return 0;
	
}









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

using namespace std;

string s;

int main() {
    ios_base::sync_with_stdio(false);
    getline(cin, s);
    for (int i = 0; i < (int)s.length(); ++i) {
        if (i == 0 || s[i-1] == ' ') {
            char c = s[i] - 32;
            cout << c;
        }
    }
    cout << endl;
    return 0;
}

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

int main()
{
  int count=0;
  string numbers;
  cin >> numbers;
  for(int i=0; i < numbers.length(); i++)
  {
    if(numbers[i] == '1')
    {
      count += 1;
    }
  }
  cout << count << endl;
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   int f=0;
   while(a>0 and c>0)
   {
//       cout<<f<<" "<<a<<" "<<c<<endl;
     if(f==0)
     {
         f=1;
         c=c-b;
     }
     else
     {
         a=a-d;
         f=0;
     }
   }
   if(a<=0)
    cout<<"No";
   else
    cout<<"Yes";

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int n; cin >> n;

    vector<string> s(n);
    printf("%d\n", 0);
    fflush(stdout);
    cin >> s[0];
    if (s[0] == "Vacant")return 0;

    int l = 1, r = n;
    while (1) {
        int mid = (l + r) / 2;
        printf("%d\n", mid);
        fflush(stdout);
        cin >> s[mid];
        if (s[mid] == "Vacant")return 0;

        if ((mid % 2 == 0 && s[0] == s[mid]) || (mid % 2 == 1 && s[0] != s[mid]))l = mid + 1;
        else r = mid;
    }
}


Measured memory_bytes: 1620
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		long[] a=new long[n];
		Arrays.setAll(a,i->s.nextLong()*2);
		Arrays.parallelPrefix(a,Long::sum);
//		System.err.println(a[n-1]/2);
//		System.err.println(Arrays.toString(a));

		long r=Long.MAX_VALUE;
		for(long i:a)
			r=Math.min(r,Math.abs(a[n-1]/2-i));
		System.out.println(r);
	}
}


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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//----------------------------------------------------------------
ll dp[3010][3010][8];

int main(void) {
  int R, C, K;
  cin >> R >> C >> K;
  vll2(item, R+1, C+1, -1);
  rep(i,K){
    int a, b;
    ll v;
    cin >> a >> b >> v;
    item[a][b] = v;
  }

  rep(i,3010){
    rep(j,3010){
      rep(k,8){
        dp[i][j][k] = 0;
      }
    }
  }

  REP(i,1,R+1){
    REP(j,1,C+1){
      ll tmp=0;
      rep(k,4){chmax(tmp, dp[i-1][j][k]);}
      chmax(dp[i][j][0], tmp);
      if(item[i][j]>0) chmax(dp[i][j][1], tmp+item[i][j]);

      rep(k,4){
        chmax(dp[i][j][k], dp[i][j-1][k]);
        if(k!=0 && item[i][j]>0){
          chmax(dp[i][j][k], dp[i][j-1][k-1]+item[i][j]);
        }
      }
    }
  }

  ll ans=0;
  rep(i,4){
    chmax(ans, dp[R][C][i]);
  }
  prt(ans);
}


Measured memory_bytes: 639896
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int n,k;cin>>n>>k;
	cout<<n-k+1;
}

Measured memory_bytes: 256
#include <stdio.h>

#include <iostream>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

int main() {
    int N;
    cin >> N;
    vector<int> h(N);

    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        h[i] = tmp;
    }

    vector<int> dp(N);
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    debug(dp);
    for (int i = 2; i < N; i++) {
        dp[i] = min(dp[i - 1] + (abs(h[i] - h[i - 1])),
                    dp[i - 2] + (abs(h[i] - h[i - 2])));
        debug(i, dp, dp[i - 1] + (abs(h[i] - h[i - 1])));
    }
    cout << dp[N-1] << endl;

    return 0;
}


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

using namespace std;

int main() {
    string input;
    cin >> input;

    if (input == "Sunny")
    {
        cout << "Cloudy";
    } else if (input == "Cloudy") {
        cout << "Rainy";
    } else {
        cout << "Sunny";
    }
}


Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next()
  val l = N.length

  def toInt(c: Char) = c.toString.toInt

  val dp = Array.ofDim[Long](l+1, 2)
  for (i <- 0 to l; k <- 0 to 1) {
    dp(i)(k) = Long.MaxValue
  }

  dp(0)(0) = 0
  dp(0)(1) = 1
  for (i <- 1 until l) {
    val now = toInt(N(i-1))
    val next = toInt(N(i))

    dp(i)(0) = Math.min(dp(i-1)(0) + now, dp(i-1)(1) + (10-now))

    val option = if (next == 0) 0 else 1
    val otsuri = (10 - now) - option
    dp(i)(1) = Math.min(dp(i-1)(0) + 1 + now, dp(i-1)(1) + otsuri)
  }

  val now = toInt(N(l-1))
  val ans = Math.min(dp(l-1)(0) + now, dp(l-1)(1) + (10-now))

  println(ans)
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


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

using namespace std;

int main() {
  int n; cin >> n;
  int ans = 0;
  while(n--) {
    int x; cin >> x;
    while(x % 2 == 0) {
      ans++;
      x /= 2;
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		int S=Integer.parseInt(str);
		int S1=(S-((int)S/3600)*3600)/60;
		System.out.println(S/3600+":"+S1+":"+S%60);
	}
}

Measured memory_bytes: 24188
#include<iostream>
using namespace std;
long long a, b, n, N, T, A;
int main() {
	cin >> N;
	a = 1, b = 1;
	for (int i = 0; i < N; i++) {
		cin >> T >> A;
		n = max((a+T-1)/T,(b+A-1)/A);
		a = T*n;
		b = A*n;
	}
	cout << a+b  << endl;
	return 0;
}

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

int main() {
  int N, K;
  double T, U, V, L;
  double D[204];
  while(cin >> N >> K >> T >> U >> V >> L) {
    for(int i = 0; i < N; ++i) cin >> D[i];
    D[N] = L;

    double res = D[0]/U;
    double remain = T*V;
    double lim = T*V*(K+1);
    for(int i = 0; i < N; ++i) {
      double dist = D[i+1] - D[i];
      if(dist <= remain) {
	res += dist/V;
	remain -= dist;
      } else {
	res += remain/V + (dist-remain)/U;
	remain = 0;
      }
      remain = min(remain+T*V, lim);
    }
    printf("%.9f\n", res);
  }
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;


int main() {
    vector<ll> tri;    
    tri.reserve(1e6);
    tri.push_back(0);
    for (int i = 1; i < 1e6; i++) {
        auto next = tri.back() + i;
        if (next > 1e6) break;
        tri.push_back(next);
    }
    vector<ll> tetra;
    tetra.reserve(1e6);
    tetra.push_back(0);
    for (int i = 1; i < 1e6; i++) {
        auto t = tri[i];
        auto next = tetra.back() + t;
        if (next > 1e6) break;
        tetra.push_back(next);
    }
    vector<int> dp1(1e6 + 1);
    vector<int> dp2(1e6 + 1);
    for (int i = 0; i <= 1e6; i++) {
        dp1[i] = i;
        dp2[i] = i;
    }
    for (int i = 2; i <= 1e6; i++) {
        int u = dp1[i];
        for (int j = 1; j < tetra.size(); j++) {
            if (tetra[j] > i) break;
            u = min(u, dp1[i - tetra[j]] + 1);
        }
        dp1[i] = u;
    }
    for (int i = 2; i <= 1e6; i++) {
        int u = dp2[i];
        for (int j = 1; j < tetra.size(); j++) {
            if (tetra[j] > i) break;
            if (tetra[j] % 2 == 1) {
                u = min(u, dp2[i - tetra[j]] + 1);
            }
        }
        dp2[i] = u;
    }
    while (true) {
        int a;
        cin >> a;
        if (a == 0) return 0;
        cout << dp1[a] << " " << dp2[a] << endl;
    }
    return 0;
}


Measured memory_bytes: 10560
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;



int main() {
	ll R;
	double ans;
	cin >> R;
	ans = (double)R * 2.0 * 3.14;
	cout << ans<<endl;
	return 0;
}


Measured memory_bytes: 3784
n=int(input())

ans='Yes'
dt=0
cur=0
cur_t=0
dist=0
for i in range(n):
	t,x,y=map(int,input().split())
	dist=abs(cur-(x+y))
	cur=x+y
	dt=t-cur_t
	cur_t=t
	
	if dist>dt:
		ans='No'
		break
	if dt%2==0 and (dist)%2==0 or dt%2==1 and (dist)%2==1:continue
	else:
		ans='No'
		break
print(ans)


Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	//freopen(".in","r",stdin);
	int k,p=1,sum=0;
	cin>>k;
	for (int i = 1; i <= 5000000; ++i)
	{
		sum=(sum+(7LL*p)%k)%k;
		if(!sum){
			cout<<i<<"\n";
			return 0;
		}
		p=(p*10LL)%k;
	}
	cout<<-1<<"\n";
	return 0;
}

//do smth instead of nothing and stay organized
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 3516
#include <iostream>
#include <algorithm>
#include <unordered_map>

#define Nmax int(1e5 + 5)
using namespace std;

typedef long long ll;
int N;
long long nr;
string s[Nmax];
unordered_map <string,ll> m;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin >> N;
    for(int i = 1; i <= N; ++i)
    {
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
        m[s[i]]++;
    }
    for(unordered_map < string,ll>::iterator it = m.begin(); it != m.end(); ++it)
        nr += (it -> second)  * (it -> second - 1) / 2;
    cout << nr;
    return 0;
}

Measured memory_bytes: 16036
N, K = map(int, input().split())

# コーナー
if N == 2:
    if K == 0:
        print(1)
        print(1, 2)
    else:
        print(-1)
    exit()

# つくれない
if (N - 1) * (N - 2) // 2 < K:
    print(-1)
    exit()


M = N * (N - 1) // 2
ans = []
for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        ans.append([i, j])

print(M - K)
for i, j in ans[:M - K]:
    print(i, j)


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

sys.setrecursionlimit(10**7)
inf = 10**20
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():
    n = I()
    a = [I()-1 for _ in range(n)]
    f = [False] * n
    t = 0
    c = 0
    while True:
        if t == 1:
            return c
        if f[t]:
            return -1
        f[t] = True
        t = a[t]
        c += 1


print(main())








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

#define pb push_back
#define fi first
#define se second
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pii pair<int,int>
#define mod 998244353

int lowbit(int x) {return x&(-x);}
double f[310][310][310];
int n;
int cnt[4];

double getf(int x,int y,int z) {
	if (f[x][y][z]!=-1) return f[x][y][z];
	double sum=x+y+z;
	f[x][y][z]=1.0*(double)n/sum;
	if (x) f[x][y][z]+=1.0*getf(x-1,y,z)*(double)x/sum;
	if (y) f[x][y][z]+=1.0*getf(x+1,y-1,z)*(double)y/sum;
	if (z) f[x][y][z]+=1.0*getf(x,y+1,z-1)*(double)z/sum;
//	printf("%d %d %d %.2f\n",x,y,z,f[x][y][z]);
	return f[x][y][z];
}

int main(){
	for (int i=0;i<=300;i++)
		for (int j=0;j<=300;j++)
			for (int k=0;k<=300;k++) f[i][j][k]=-1;
	scanf("%d",&n);
	for (int i=0;i<n;i++) {
		int x;
		scanf("%d",&x);
		cnt[x]++;
	}
	f[0][0][0]=0.0;
	printf("%.11lf",getf(cnt[1],cnt[2],cnt[3]));
	return 0;
}


Measured memory_bytes: 227584
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		int G = 0,P = 0;
		for( int i=0; i<S.length(); i++ ){
			if( S.charAt(i)=='g' ){
				G++;
			}else{
				P++;
			}
		}
		System.out.println((G-P)/2);
	}
}


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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

bool prime[mx3];
Vl v;
LL d[mx3], L, mod = 1e9 + 7;

void sv(LL n)
{
    for(LL i = 2; i * i <= n; i++){
        for(LL j = i * i; j <= n; j += i)
            prime[j] = true;
    }

    for(LL i = 2; i <= n; i++)
        if(!prime[i])
            v.Pb(i);
}

void store(LL n)
{
    for(LL i = 0; i < L; i++){
        LL cnt = 0;
        while(n % v[i] == 0)
            n /= v[i], cnt++;

        d[v[i]] += cnt;
    }
}

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    LL n;
    cin >> n;

    sv(n);

    L = v.size();

    for(LL i = 1; i <= n; i++){
        store(i);
    }

    LL res = 1;
    for(LL i = 1; i <= n; i++){
        LL x = d[i];
        res = (res * (x + 1)) % mod;
    }

    cout << res % mod << '\n';
    return 0;
}



Measured memory_bytes: 256