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

#define M 1046527
#define NIL (-1)
#define L 14

char Hash[M][L];

// ??????????????°????????????
int getchar(char ch) {
    if ( ch == 'A' ) return 1;
    else if ( ch == 'C' ) return 2;
    else if ( ch == 'G' ) return 3;
    else if ( ch == 'T' ) return 4;
    else return 0;
}

long long getkey (char str[]) {
    long long sum = 0, p = 1, i;
    for ( i = 0; i < strlen(str); i++ ) {
        sum += p*(getchar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1 ( int key ) { return key % M; }
int h2 ( int key ) { return 1 + (key % (M-1)); }

int find( char str[] ) {
    long long key, h, i;
    key = getkey(str);
    for ( i = 0; ; i++ ) {
        h = (h1(key) + i*h2(key)) % M;
        if ( strcmp(Hash[h], str) == 0 ) return 1;
        else if ( strlen(Hash[h]) == 0 ) return 0;
    }
    return 0;
}

int insert( char str[] ) {
    long long key, h, i;
    key = getkey(str);
    for ( i = 0; ; i++ ) {
        h = (h1(key) + i * h2(key)) % M;
        if ( strcmp(Hash[h], str) == 0 ) return 1;
        else if ( strlen(Hash[h]) == 0 ) {
            strcpy(Hash[h], str);
            return 0;
        }
    }
    return 0;
}

int main() {
    int n;
    char ORDER[10], MOJI[L];
    
    for (int i = 0; i < M; i++) Hash[i][0] = '\0';
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%s %s", ORDER, MOJI);
        if ( ORDER[0] == 'i' ) insert(MOJI);
        else {
            if ( find(MOJI) ) printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}

Measured memory_bytes: 17464
#include <bits/stdc++.h>
#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++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    int H[N],count=0,mcount=0;
    REP(i,N)cin>>H[i];
    REP(i,N){
        if(i>0 && H[i-1] < H[i])count=0;
        if(i>0 && i<N &&H[i-1] >= H[i])count++;
        if(mcount<count)mcount=count;
    }
    cout << mcount << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

vector<int> divisor(int n){
	vector<int> res;
	for(int i = 1; i * i <= n; i++){
	if(n % i == 0){
			res.push_back(i);
			if(i != n / i) res.push_back(n / i);
		}
	}
	return res;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> d = divisor(m);
	int ans = 1;
	for(auto i : d){
		if(m / i >= n) ans = max(ans, i);
	}
	cout << ans << endl;
}

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

typedef long long ll;

int main(){
    ll Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;

    S = min(S, min(4*Q, 2*H));
    D = min(D, 2*S);
    if(N%2==0){
        cout << D*(N/2) << endl;
    }else{
        cout << D*(N/2) + S << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int to_int(char c) {
  return c - 48;
}
int main() {
  int n;
  cin >> n;
  string s = to_string(n);
  int sum = 0;
  for(int i = 0;i < s.size();i++) {
    sum += to_int(s.at(i));
  }
  if(n % sum == 0) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
values = [500*a + 100*b + 50*c for a in range(A+1) for b in range(B+1) for c in range(C+1)]
counter = 0
for value in values:
  if value == X:
    counter+=1
print(counter)



Measured memory_bytes: 8276
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

#define x first
#define y second
#define NMAX 100005

int n, val, ans, ans2;

int main (){
    
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        scanf("%d",&val);
        ans += (val&1);
    }
    ans2 = n - ans;
    
    if(ans&1){
        if(n == 1)
            printf("YES\n");
        else
            printf("NO");
    }
    else
        printf("YES\n");
    
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<math.h>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int f(ll a,ll b){
    int a_count = 0,b_count = 0;
    while(a > 0){
        a/=10;
        a_count++;
    }
    while(b > 0){
        b/=10;
        b_count++;
    }
    return max(a_count,b_count);
}
int main(){
    ll n;
    cin >> n;
    int i;
    for(i=floor(sqrt(n));i >= 1;i--){
        if(n%i == 0){
            break;
        }
    }
    cout << f(i,n/i) << endl;
    return 0;
}

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

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

int c[1000001];
char s[1000005];

int main() {
  int n,m,i,j;
  while(scanf("%d", &n), n) {
    memset(c, 0, sizeof(c));
    scanf("%d", &m);
    scanf("%s", s);

    for(int k=m-1; k>1; --k)
      if(s[k] == 'I' && s[k-1] == 'O' && s[k-2] == 'I')
	c[k-2] = c[k]+1;

    int ans = 0;
    rep(i,m)
      if(c[i] >= n) ans++;

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

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    string s;
    cin >> s;
    int slen = s.size();
    int a=0, b=0, c=0;
    rep(i, slen){
        if(s[i]=='a'){
            a++;
        }else{
            if(s[i]=='b'){
                b++;
            }else{
                c++;
            }
        }
    }
    if(max(abs(a-b), max(abs(b-c), abs(c-a)))>1){
        cout << "NO";
    }else{
        cout << "YES";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define reg(i,a,b) for(int i=a;i<=b;i++)
#define reh(i,a,b) for(int i=a;i>b;i--)
#define in(x) scanf("%d",&x)
#define fro freopen("D:\\testdata.in", "r", stdin)
#define il inline
#define lson(q) q<<1
#define rson(q) q<<1|1
using namespace std;
typedef long long ll;
const int mx=1e5+10;
int a[mx];
int b[mx];
int n,m;

int main(){
	cin>>n>>m;
	if(m*2>=n){
		cout<<0<<endl;
	}else{
		cout<<n-m*2<<endl;
	}

	return 0;
}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int X,Y;
  cin>>X>>Y;
  if(X==Y||X%Y==0){
    cout<<-1<<endl;
  }else{
    int num=X;
    while(num%Y==0){
      num+=X;
    }
    cout<<num<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rint register int
#define mem(a,b) memset(a,(b),sizeof(a))
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define For(i,j,k) for(Rint i=(j),i##end=(k);i<=i##end;i++)
#define Fordown(i,j,k) for(Rint i=(j),i##end=(k);i>=i##end;i--)
#define Travel(i,u,v) for(Rint i=beg[u],v=to[i];i;i=nex[i],v=to[i])
 
using namespace std;
typedef long long LL;
 
template<typename T>inline void read(T &x){
	x=0;T w=1,ch=getchar();
	while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
	x=x*w;
}
 
const int N=1e5+10,mod=1e9+7;
int n,a[N],inv[N];
int fac=1,sum,ans;
 
inline int Qpow(int x,int k){
	int res=1;
	while(k){
		if(k&1)res=1LL*res*x%mod;
		x=1LL*x*x%mod;
		k>>=1;
	}
	return res;
}
 
int main(){
//	File("B");
	read(n);
	For(i,1,n)read(a[i]),fac=1LL*fac*i%mod;
	For(i,1,n)inv[i]=(inv[i-1]+Qpow(i,mod-2))%mod;
	For(i,1,n)sum=(sum+1LL*a[i]*((inv[i]+inv[n-i+1]-1)%mod)%mod)%mod;
	printf("%lld\n",1LL*sum*fac%mod);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=100005,mod=998244353,K=512;
int n;
struct data{
	ll a[N]; int sg[N],to[N];
	vector<int> v[N];
	
	void solve(){
		int m=read();
		For(i,0,m-1){
			int s=read(),t=read();
			if(s>t)swap(s,t);
			v[s].pb(t);
		}
		Rep(i,n,1){
			for(auto j:v[i])to[sg[j]]=1;
			while(to[sg[i]])sg[i]++;
			for(auto j:v[i])to[sg[j]]=0;
		}
		ll t=1000000000000000000%mod,pw=1;
		For(i,1,n){
			pw=pw*t%mod;
			a[sg[i]]=(a[sg[i]]+pw)%mod;
		}
	}
}T[3];
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	n=read();
	For(i,0,2){
		T[i].solve();
	}
	ll ans=0;
	For(i,0,K-1)For(j,0,K-1){
		ans+=T[0].a[i]*T[1].a[j]%mod*T[2].a[i^j]%mod;
	}
	cout<<ans%mod<<endl;
}


Measured memory_bytes: 16128
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t {... : as Swift
#define forin(i, t) for(ll i = 0; i < t; i++)

using namespace std;
using ll = long long;
using P = std::pair<ll, ll>;

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

    vector<P> rs;
    forin(i, m) {
        ll f, t;
        cin >> f >> t;
        if (f > t) {
            auto tmp = f;
            f = t;
            t = tmp;
        }
        rs.push_back(P{f, t});
    }
    sort(rs.begin(), rs.end(), [](P l, P r) {
        return l.first != r.first ? l.first < r.first : l.second > r.second;
    });
    ll erased = 0;
    for (auto i = 1; i < rs.size(); i++) {
        if (rs[i - 1].second >= rs[i].second) {
            erased++;
        }
        else if (rs[i].first < rs[i - 1].second) {
            rs[i].second = rs[i - 1].second;
            erased++;
        }
    }

    cout << rs.size() - erased << endl;

}



Measured memory_bytes: 3444
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var dp = new int[n + 1, 4];
            for (int i = 0; i < n + 1; i++)
                for (int j = 0; j < 4; j++) dp[i, j] = int.MaxValue;
            dp[0, 0] = 0;
            var p = new int[n]; var t = new int[n];
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                p[i] = int.Parse(line[0]);
                t[i] = int.Parse(line[1]);
            }
            getAns(dp, p, t);
        }
    }
    public static void getAns(int[,] dp, int[] p, int[] t)
    {
        var n = p.Length;
        if (p[0] > t[0]) { Console.WriteLine("NG 1"); goto end; }
        else dp[1, 1] = p[0];
        for (int i = 1; i < n; i++)
            for (int j = 1; j <= 3; j++)
            {

                if (dp[i, j] != int.MaxValue)
                {
                    if (j <= 2 && checkGet(p, t, i, j))
                    {
                        dp[i + 1, j + 1] = Math.Min(dp[i + 1, j + 1], dp[i, j] + Math.Abs(p[i] - p[i - 1]));
                    }
                    if (checkGoHome(p, t, i, j))
                    {
                        dp[i + 1, 1] = Math.Min(dp[i + 1, 1], dp[i, j] + p[i] + p[i - 1]);
                    }
                }
            }
        getAns2(dp, p);
        end:;
    }
    public static void getAns2(int[,] dp, int[] p)
    {
        var n = dp.GetLength(0);
        var ok = false;
        var ans = int.MaxValue;
        for (int i = 0; i < 4; i++)
            if (dp[n - 1, i] != int.MaxValue)
            {
                ans = Math.Min(ans, dp[n - 1, i]);
                ok = true;
            }
        if (ok) { Console.WriteLine("OK {0}", p[n - 2] + ans); return; }
        else
        {
            for (int i = 1; i < n; i++)
            {
                var flg = false;
                for (int j = 0; j < 4; j++)
                    if (dp[i, j] != int.MaxValue) flg = true;
                if (!flg) { Console.WriteLine("NG {0}", i); return; }
            }
        }
    }
    public static bool checkGoHome(int[] p, int[] t, int i, int b)
    {
        var nt = p[i - 1] * (b + 1) + p[i];
        return nt <= t[i] - t[i - 1];
    }
    public static bool checkGet(int[] p, int[] t, int i, int b)
    {
        var L = Math.Abs(p[i] - p[i - 1]);
        var nt = L * (b + 1);
        return nt <= t[i] - t[i - 1];
    }
}




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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

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


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


int main(void){
    string A,B;
    cin >> A;
    cin >> B;
    sort(A.begin(), A.end());
    sort(B.begin(), B.end(),std::greater<char>());
    if(A < B){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}   

Measured memory_bytes: 3588
fn main() {
    proconio::input! {
        n: usize,
        m: usize,
        hs: [i64; n],
        ab: [(usize, usize); m],
    }
    let mut roads = std::collections::HashMap::new();
    for (a, b) in ab {
        roads.entry(a).or_insert(vec![]).push(b);
        roads.entry(b).or_insert(vec![]).push(a);
    }
    let ans = hs
        .iter()
        .enumerate()
        .filter(|(i, h)| match roads.get(&(i + 1)) {
            None => true,
            Some(v) => v.iter().all(|item| h > &&hs[item - 1]),
        })
        .count();
    println!("{}", ans);
}


Measured memory_bytes: 15064
#include <stdio.h>

int main()
{
int a[100][100];
int b[100];
int n,m;
scanf("%d %d",&n,&m);
for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){
		scanf("%d",&a[i][j]);
	}
}
for(int i=0;i<m;i++){
	scanf("%d",&b[i]);
}
for(int i=0;i<n;i++){
	int ans=0;
	for(int j=0;j<m;j++){
		ans+=a[i][j]*b[j];
	}
	printf("%d\n",ans);
}
}


Measured memory_bytes: 2716
S = input()
T = input()
listS = list(S)
listT = list(T)
for i in S:
 #   print(listS,listT)
    if listS == listT:
        print("Yes")
        exit()
    else:
        hoge = listS.pop(0)
        listS.append(hoge)
print("No")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000

template <typename T>
struct Z_algorithm{
	vector<int> A;
	Z_algorithm(T &s){
		A.resize(s.size(),0);
		A[0] = s.size();
		int i=1,j=0;
		while(i<s.size()){
			while (i+j<s.size()&&s[j]==s[i+j])j++;
			A[i] = j;
			if(j==0){
				i++;
				continue;
			}
			int k = 1;
			while(i+k<s.size()&&k+A[k]<j){
				A[i+k] = A[k];
				k++;
			}
			i+=k;
			j-=k;
		}
	}
	//[0,S.size)と[pos,S.size)の最長共通接頭辞の長さ
	int get_length(int pos){
		return A[pos];
	}
	
};


int main(){
	
	int N;
	cin>>N;
	string S;
	cin>>S;
	
	int ans = 0;
	
	for(int i=0;i<S.size();i++){
		string T = S.substr(i);
		Z_algorithm<string> Z(T);
		
		for(int j=0;j<S.size()-i;j++){
			ans = max(ans,min(Z.get_length(j),j));
		}
	}
	
	cout<<ans<<endl;
		
	
	return 0;
}

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

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;

    vector <string> s(H + 2);
    for (int i = 0; i < W + 2; i++){
        s[0].push_back('.');
        s[H + 1].push_back('.');
    }
    for (int i = 1; i < H + 1; i++){
        string a;
        cin >> a;
        s[i] = '.' + a + '.';
    }

    bool flag = true;
    for (int i = 1; i < H + 1; i++){
        for (int j = 1; j < W + 1; j++){
            if (s[i][j] == '#'){
                if (s[i-1][j] == '#' || s[i][j-1] == '#' || s[i+1][j] == '#' || s[i][j+1] == '#'){
                }else{
                    flag = false;
                    break;
                }
            }
        }
        if (flag == false){
            break;
        }
    }

    if (flag == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 764
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

LL n,m,ans = 0,col[3],cnt,rep,ect;
LL vis[200005] = {0},cco[200005] = {0};

LL ec = 0,nxt[400005],to[400005],hed[200005] = {0},w[400005];
void add_edge(LL f,LL t,LL cst){
	++ ec; to[ec] = t; nxt[ec] = hed[f]; hed[f] = ec; w[ec] = cst;
}

void dfs(LL u,LL co){
	cnt ++; col[co] ++;
	vis[u] = 1; cco[u] = co;
	for(LL i = hed[u];i;i = nxt[i]){
		LL v = to[i];
		if(w[i] == 1) ect ++;
		if(vis[v]){
			if((co + w[i] + 3) % 3 != cco[v]) rep = 1;
			continue;
		}
		dfs(v,(co + w[i] + 3) % 3);
	}
}

int main(){
	LL u,v;
	cin >> n >> m;
	for(LL i = 1;i <= m;i ++){
		cin >> u >> v;
		add_edge(u,v,1);
		add_edge(v,u,-1);
	}
	memset(vis,0,sizeof(vis));
	for(LL i = 1;i <= n;i ++){
		if(vis[i]) continue;
		col[0] = col[1] = col[2] = 0;
		cnt = 0; rep = 0; ect = 0; dfs(i,0);
//		cout << i << ' ' << col[0] << ' ' << col[1] << ' ' << col[2] << endl;
		if(rep) ans += cnt * cnt;
		else if(col[0] && col[1] && col[2]) ans += (col[0] * col[1] + col[1] * col[2] + col[2] * col[0]);
		else ans += ect;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 16768
#define C

#ifdef C
#include <stdio.h>
#define abs(a) ((a) < 0 ? -(a) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define isdigit(a) ((a) >= '0' && (a) <= '9' ? true : false)
#endif
#ifdef Cpp
#include <bits/stdc++.h>
using namespace std;
#endif

#define freopen(x) freopen(x".in", "r", stdin);freopen(x".out", "w", stdout)
#define repl(i, t) for (int i = fi[t]; i; i = ne[i])
#define rep(i, a, b) for (int i = (int) a;  i <= (int) b; ++i)
#define per(i, a, b) for (int i = (int) a;  i >= (int) b; --i)
#define _r read()
#define readtype long long

typedef long long var;

const int INF = 0x3f3f3f3f;
const int N = 1e6 + 1;

int top, fi[N], ne[N], to[N];
int have[N], res[N];

readtype read();
void add(int u, int v);
void DFS(int t, int s = 0, int f = 0);

int main() {
  int n = _r, q = _r;
  rep(i, 2, n) add(_r, _r);
  rep(i, 1, q) {
    int u = _r, v = _r;
    have[u] += v;
  }
  DFS(1);
  rep(i, 1, n - 1) printf("%d ", res[i]);
  printf("%d\n", res[n]);
  return 0;
}

readtype read() {
  readtype a = 0, c = getchar(), s = 0;
  while (!isdigit(c)) s |= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return s ? -a : a;
}

void add(int u, int v) {
  ne[++top] = fi[u], fi[u] = top, to[top] = v;
  ne[++top] = fi[v], fi[v] = top, to[top] = u;
}

void DFS(int t, int s, int f) {
  res[t] = s + have[t];
  repl(i, t) {
    if (to[i] == f) continue;
    DFS(to[i], res[t], t);
  }
}


Measured memory_bytes: 28672
#include<iostream>
#include<cmath>

using namespace std;

int main(){

	int a;
	int h,m;
	int x,y;
	int cnt;
	bool f;

	cin>>a;

	cnt=0;
	if(a%2==0) cnt++;

	h=a/10;
	m=a%10;
	f=true;

	for(int i=1;h!=0;i++){
		if((h+m)%2==0&&f&&h<=m) cnt++;
		if(h%10==0) f=false;
		else f=true;
		m+=pow(10.0,i)*(h%10);
		h/=10;
	}

	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <cstdio>

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

	int d, r;
	double f;
	d = a / b;
	r = a % b;
	f = (double) a / b;

	printf("%d %d %.5lf\n", d, r, f);

	return 0;
}

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


int main() {
  int N ; 
  cin >> N ; 
  double O ; 
  
  if ( N % 2 == 0 ){
    O = 1.0/2.0 ; 
    cout << O << endl ; 
  }
  else {
    O = (N+1.0)/(2.0*N) ; 
    cout << O << endl ; 
  }
  
}

Measured memory_bytes: 3764
S = input()

flag = True

for i in range(len(S)):
    if i % 2 == 0 and S[i] == 'L':
        flag = False
    elif i % 2 == 1 and S[i] == 'R':
        flag = False

if flag:
    print('Yes')
else:
    print('No')


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

int main() {
  int N, K;
  string S;
  cin >> N >> S >> K;
  
  char c = S[K - 1];
  for (int i = 0; i < N; i++) {
    if (S[i] != c) {
      S[i] = '*';
    }
  }
  
  cout << S << endl;
}


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

class blanch{
	public:
		bool visited;
		int distance;
		int from;
		int to;
};
typedef vector <blanch> vb;
typedef vector <vb> vvb;

int make_graph(vvb &graph, vb &nodes){

	int n=nodes.size();
	for (int i=0; i<n; i++){
		nodes[i].visited = false;
		nodes[i].distance = INT_MAX;
	}

	for (int i=0; i<n; i++){
		int i2, n2;
		cin>>i2;
		cin>>n2;

		blanch tmp;
		tmp.visited = false;
		tmp.from = i2;

		for (int j=0; j<n2; j++){
			cin>>tmp.to;
			cin>>tmp.distance;
			graph[i2].push_back(tmp);
		}
	}
	return 0;
}

int Shortest_Path(vvb &graph, vb &nodes){

	int p1=0;
	nodes[p1].distance = 0;

	int p2;
	while (p1 != -1){
		nodes[p1].visited=true;
		for (int i = 0; i < (int)graph[p1].size(); i++){
			blanch tmp = graph[p1][i];
			p2=tmp.to;
			if (!nodes[p2].visited){
				int tmp2 = tmp.distance + nodes[p1].distance;
				if (tmp2 < nodes[p2].distance){
					tmp.distance = tmp2;
					nodes[p2] = tmp;
				}
			}
		}

		p1 = -1;
		int tmp = INT_MAX;
		for (int i=0; i<(int)graph.size(); i++){
			if (!nodes[i].visited && nodes[i].distance<tmp){
				p1 = i;
				tmp = nodes[i].distance;
			}
		}
	}
	return 0;
}

int resultout(vb &nodes){
	for (int i=0; i<(int)nodes.size(); i++){
		cout<<i<<" "<<nodes[i].distance<<endl;
	}
	return 0;
}

int main(void){

	int n;
	cin>>n;
	vvb G(n, vb());
	vb nodes(n);

	make_graph(G, nodes);

	Shortest_Path(G, nodes);

	resultout(nodes);
	G.clear();
	nodes.clear();

	return 0;
} 

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

int main()
{
  int N;scanf("%d",&N);
  int a[N];long long sum=0,suma=0;
  for(int i=0;i<N;i++){scanf("%d ",&a[i]);sum+=a[i];}
  pair<long long,long long> p[2];
  for(int i=0;i<N;i++)
  {
    suma+=a[i];
    if(suma<=sum-suma)p[0].first=suma,p[0].second=sum-suma;
    else {p[1].first=sum-suma,p[1].second=suma;break;}
  }
  printf("%lld",min(p[0].second-p[0].first,p[1].second-p[1].first));
}

Measured memory_bytes: 4488
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool b = true;
    for(char i = 'a'; i <= 'z'; i++){
        int c = 0;
        for(int j = 0; j < n; j++){
            if(s.at(j) == i)
            c++;
        }
        if(c % 2 != 0){
            b = false;
            break;
        }
    }
    if(b == true)
    cout << "Yes" << endl;
    else 
    cout << "No" << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>

int main() 
{
    int num;
    int a, b, c;

    scanf("%d", &num);

    a = (int)(num / 100);
    b = (int)((num - a*100) / 10);
    c = (int)(num - a*100 - b*10);
    
    if ( a == 7 ){
        printf("Yes");
    } else if ( b == 7 ){
        printf("Yes");
    } else if ( c == 7 ){
        printf("Yes");
    } else{
        printf("No");
    }

    return 0;

}



Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  string t="NA";
  if((s.at(2)=='0' && s.at(3)!='0') || (s.at(2)=='1' && s.at(3)<'3')){
    t="YYMM";
    if((s.at(0)=='0' && s.at(1)!='0') || (s.at(0)=='1' && s.at(1)<'3')){
    t="AMBIGUOUS";
      cout << t;
      return 0;
    }
  }
  if((s.at(0)=='0' && s.at(1)!='0') || (s.at(0)=='1' && s.at(1)<'3')){
     t="MMYY";
  }
  cout << t;
}
     


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int n;
  cin >> n;
  int sum = 0, ans = 0;
  vector<int> x(n);
  arep(i, x) cin >> i, sum += i, sum %= mod1;
  rep(i, 0, n) {
    sum -= x[i];
    sum = (sum + mod1) % mod1;
    ans = (ans + sum * x[i]) % mod1;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4680
#include <stdio.h>
int Search(int *,int, int);

int main(){
 int S[100000],T[50000];
    int n,q,i,count=0;

    scanf("%d",&n);

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

    scanf("%d",&q);

    for(i=0;i<q;i++) {
        scanf("%d",&T[i]);
        if(Search(S,n,T[i])==1) count++;
    }

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

    return 0;
}

int Search(int *A,int n,int key){
    int left=0,middle=0,right=0;
    right=n;

    while(left<right){
        middle=(left+right)/2;
        if(A[middle]==key) return 1;
        if(A[middle]<key) left=middle+1;
        else if(A[middle]>key) right=middle;
    }
    return 0;
}


Measured memory_bytes: 2352
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int x=0;
    int a[n];
    int b[n];
    int c[n];
    int d=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i2=0;i2<n;i2++)
    {
        cin>>b[i2];
    }
    for(int i3=0;i3<n;i3++)
    {
        cin>>c[i3];
    }
    for(int i4=0;i4<n;i4++)
    {
        x+=b[i4];
    }
    for(int m=0;m<n;m++)
    {
        if(a[m+1]-a[m]==1)
        {
            d=a[m];
            x+=c[d-1];
        }
    }
    cout<<x;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <sstream>
#include <string>
#include <algorithm>
#include <limits>

using namespace std;

int main()
{
  //skip the first line
//  cin.ignore(numeric_limits<streamsize>::max(), '\n');
  int r, c;
  cin >> r >> c;
  cin.ignore(numeric_limits<streamsize>::max(), '\n');

  vector<int> row_sums;
  vector<int> column_sums(c);

  for (string line; getline(cin, line);) {
    istringstream is {line};
    int n, row_sum = 0;
    auto column_it = column_sums.begin();
    while (is >> n) {
      cout << n << " ";
      row_sum += n;
      *column_it += n;
      ++column_it;
    }

    row_sums.push_back(row_sum);

    cout << row_sum << endl;
  }

  for (int x : column_sums)
    cout << x << " ";

  // finally, print out the sum of the row sums (= the sum of the column sums)
  cout << accumulate(row_sums.begin(), row_sums.end(), 0) << endl; 
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int H, W, M; cin >> H >> W >> M;
	vector<int> tate(H+1), yoko(W+1);
	map<pair<int, int>,bool> mp;
	int h = 0, w = 0;
	for (int i = 0; i < M; i++) {
		int x, y; cin >> x >> y;
		tate[x]++, yoko[y]++;
		h = max(h, tate[x]), w = max(w, yoko[y]);
		mp[make_pair(x, y)] = true;
	}

	vector<int> a, b;
	//cout << "h=" << h << endl;
	//cout << "w=" << w << endl;
	for (int i = 1; i <= H; i++) {
		if (tate[i] == h) {
			a.push_back(i);
			//cout << "tate=" << i << endl;
		}
	}
	
	for (int i = 1; i <= W; i++) {
		if (yoko[i] == w){
			b.push_back(i);
			//cout << "yoko=" << i << endl;
		}
	}

	bool fl = false;
	for (int i = 0; i < a.size(); i++) {
		for (int j = 0; j < b.size(); j++) {
			if (!mp[make_pair(a[i], b[j])]) {
				/*
				cout << "tate2=" << a[i] << endl;
				cout << "yoko2=" << b[j] << endl;
				*/
				fl = true;
				break;
			}
		}
	}

	if (fl)cout << h + w << endl;
	else cout << h + w - 1 << endl;
}





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

int bubbleSort(int A[], int N) {
	int result = 0;
	bool flg = true;

	while (flg) {
		flg = false;
		for (int j = 1; j < N; j++) {
			if (A[j - 1] > A[j]) {
				swap(A[j], A[j - 1]);
				flg = true;
				result += 1;
			}
		}
	}
	return result;
}

int main() {
	int N, *A;
	cin >> N;
	A = new int[N];
	for (int i = 0; i < N; i++) cin >> A[i];

	int cnt = bubbleSort(A, N);

	for (int i = 0; i < N; i++) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << cnt << endl;
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	int l, r,d;
	cin >> l >> r >> d;
	int ans = 0;
	for (int i = l; i <= r; i++) {
		if (i % d == 0) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3592
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-19 14:53:28
                2020-04-19 16:16:46 余計な部分を削った版
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define INF 1000000000

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> red(n), blue(n);
    for (int i = 0; i < n; i++)
        cin >> red[i].first >> red[i].second;
    for (int i = 0; i < n; i++)
        cin >> blue[i].first >> blue[i].second;

    sort(all(red), compare_by_b);
    reverse(all(red));

    sort(all(blue));

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            pair<int, int> r = red[j];
            pair<int, int> b = blue[i];

            if (r.first < b.first && r.second < b.second) {
                // cout << r.first << "," << r.second << " " << b.first << "," << b.second << endl;
                ans++;
                red[j].second = INF;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h> 
#include <stdlib.h> 
 
int alg ( int a, int b ) 
{ 
    int src = a + b;                                                                   
    int result = 0;  
 
    do  
    {   
        result++; 
    } while ( (src /= 10) != 0 );  
 
    return result; 
} 
 
int main ( void ) 
{ 
    int a, b;  
 
    while ( scanf( "%d %d", &a, &b ) != EOF ) 
    {   
        printf( "%d\n", alg( a, b ) );  
    }   
 
    return 0;  
} 

Measured memory_bytes: 600
import math
def prime_diviation(n):
    factors = []
    i = 2
    while i <= math.floor(math.sqrt(n)):
        if n%i == 0:
            factors.append(int(i))
            n //= i
        else:
            i += 1
    if n > 1:
        factors.append(n)
    return factors
N = int(input())
#素因数分解
ls = prime_diviation(N)
now = 0 #現在参照する数字
ren = 0 #連続している数
target = 2 #連続している数の目標
ans = 0 #割り切れる回数
for i in range(len(ls)):
    if i == 0:
        #はじめの処理
        now = ls[i]
        ans += 1
    else:
        #もしnowと同じなら
        if ls[i] == now:
            ren += 1
            if ren == target:
                ans += 1
                ren = 0
                target += 1
        else:
            ans += 1
            ren = 0
            target = 2
            now = ls[i]
print(ans)

Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
#define int long long
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return rand()%x;
}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=4005,mod=1000000007;
int n,m,k,dp[N][N],ans;
inline void add(int &a,int b){
	a=(a+b)%mod;
}
signed main(){
	n=read(); m=read(); k=read(); swap(n,m);
	int jb=k-1;
	dp[0][0]=1; dp[0][1]=-1;
	for(int i=0;i<(n+m-1)/(k-1);i++){
		for(int j=0;j<=n;j++){
			if(j)add(dp[i][j],dp[i][j-1]);
			add(dp[i+1][j],dp[i][j]);
			add(dp[i+1][j+k],-dp[i][j]);
			if(j+((n-j)%jb==0?jb:(n-j)%jb)<=n&&(i+1)*jb-(j+((n-j)%jb==0?jb:(n-j)%jb))<m)ans=(ans+dp[i][j])%mod;
			//cout<<dp[i][j]<<" "<<i<<" "<<j<<" "<<(i+1)*jb-(j+(n-j)%jb)<<endl;
		}
	}
	cout<<(ans+mod)%mod<<endl;
}

Measured memory_bytes: 124544
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

#define mp make_pair
#define ull unsigned long long
#define M 1000000007
#define F first



int main(){
    string s;cin>>s;
    int sum=0;
    for(int i=0;i<s.length();i++){
        int x;
        if(s[i]=='0') x=0;
        else if(s[i]=='1') x=1;
        else if(s[i]=='2') x=2;
        else if(s[i]=='3') x=3;
        else if(s[i]=='4') x=4;
        else if(s[i]=='5') x=5;
        else if(s[i]=='6') x=6;
        else if(s[i]=='7') x=7;
        else if(s[i]=='8') x=8;
        else if(s[i]=='9') x=9;

        sum+=x;

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

Measured memory_bytes: 3744
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.length() == 2 && s.charAt(0) == s.charAt(1)) {
            System.out.println("1 2");
            return;
        }
        for (int i = 0; i < s.length() - 2; i++) {
            String str = s.substring(i, i + 3);
            if (str.charAt(0) == str.charAt(1) || str.charAt(1) == str.charAt(2)
                || str.charAt(0) == str.charAt(2)) {
                System.out.printf("%d %d%n", i + 1, i + 3);
                return;
            }
        }
        System.out.println("-1 -1");
    }
}


Measured memory_bytes: 28520
#include <iostream>

using namespace std;

int main()
{
    int a[101] = {};

    int n;
    while (cin >> n) {
        a[n-1] += 1;
    }

    int ma = 0;

    for (int i = 0; i < 100; ++i) if (ma < a[i]) ma = a[i];

    for (int i = 0; i < 100; ++i) if (a[i] == ma) cout << i + 1 << endl;
}

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main()
{
	double a,b,c,d,e,f,x,y;

	while(cin >> a >> b >> c >> d >> e >> f){
		if( ((b*f)-(e*c)) == 0){ x=0;}
		else{ x = ((b*f) - (e*c))/((b*d) - (e*a));}
		if( ((a*f)-(d*c)) == 0){y=0;}
		else { y = ((a*f) - (d*c))/((a*e) - (b*d));}
		printf("%.3f %.3f\n", x, y);
	}

	return 0;
}

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  int64 c;
  scanf("%d%lld",&n,&c);
  int i;
  int64 x[100000];
  int v[100000];
  for(i=0;i<n;i++){
    scanf("%lld%d",x+i,v+i);
  }

  int64 f[100000];
  int64 max=MAX(0,v[0]-x[0]);;
  int64 sum=v[0];
  f[0]=max;
  for(i=1;i<n;i++){
    sum+=v[i];
    max=MAX(max,sum-x[i]);
    f[i]=max;
  }
  sum=0;
  for(i=n-1;i>=0;i--){
    sum+=v[i];
    max=MAX(max,sum-(c-x[i]));
    if(i-1>=0){
      max=MAX(max,sum-2*(c-x[i])+f[i-1]);
    }
  }

  f[n-1]=MAX(0,v[n-1]-(c-x[n-1]));
  sum=v[n-1];
  for(i=n-2;i>=0;i--){
    sum+=v[i];
    f[i]=MAX(f[i+1],sum-(c-x[i]));
  }
  sum=0;
  for(i=0;i<n-1;i++){
    sum+=v[i];
    max=MAX(max,sum-2*x[i]+f[i+1]);
  }

  printf("%lld\n",max);
  return;
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    cin >> k;
    long long sum = 0;
    for (int a = 1; a <= k; a++)
        for (int b = 1; b <= k; b++)
            for (int c = 1; c <= k; c++)
                sum += __gcd(__gcd(a, b), c);
    cout << sum;
    return 0;
}

Measured memory_bytes: 3636
object Main extends App {
    val in = io.Source.stdin.getLines.map(_.trim.split(" ").map(_.toInt))
    val n = in.next.head
    val t = (0 to n-1).toArray
    val d = in.toSeq
    val es = (for (i <- (0 to n-2); j <- (i+1 to n-1) if d(i)(j) != -1) yield (i, j, d(i)(j))).sortBy(_._3)
    var cost = 0

    def find(m: Int): Int = if(t(m) == m) m else {t(m) = find(t(m)); t(m)}
 
    def unite(x: Int, y: Int) = {
        val _x = find(x)
        val _y = find(y)
        if(_x != _y) t(_x) = _y
    }
 
    es.foreach(e => if (find(e._1) != find(e._2)) {unite(e._1, e._2); cost += e._3})
    println(cost)
}

Measured memory_bytes: 48728
#include <iostream>

using namespace std;

int main() {
	string s;
	int w;
	cin >> s >> w;
	
	string result = s.substr(0, 1);
	
	int size = s.size();
	for (int i = w; i < size; i += w){
		result += s[i];
	}
	
	cout << result << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M,L = map(int,readline().split())
ABC = [list(map(int,readline().split())) for _ in range(M)]
Q = int(readline())
ST = [list(map(int,readline().split())) for _ in range(Q)]
    
def warshall_floyd(d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

INF = 10**11
d = [[INF]*N for i in range(N)] 
a =  [[INF]*N for i in range(N)] 
for x,y,z in ABC:
    if z <= L:
      d[x-1][y-1] = z
      d[y-1][x-1] = z
for i in range(N):
    d[i][i] = 0
    a[i][i] = 1
chk = warshall_floyd(d)

for i in range(N-1):
  for j in range(i+1,N):
    if chk[i][j] <= L:
      a[i][j] = 1
      a[j][i] = 1
ans = warshall_floyd(a)

for s,t in ST:
  answer = ans[s-1][t-1]
  if answer == INF:
      print(-1)
  else:
      print(answer-1)

Measured memory_bytes: 69340
#include <stdio.h>

typedef long long int lld;

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

  lld a = 0, b = x;
  while (a < b)
  {
    lld m = (a + b) / 2;
    if (m == b)
      m--;
    
    lld n5 = m / 2;
    lld n6 = (m + 1) / 2;

    if (n5 * 5 + n6 * 6 >= x)
      b = m;
    else
      a = m + 1;
  }

  printf("%lld\n", a);

  return 0;
}


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

constexpr int64_t INF = 1e18;
constexpr int MAX = 15;
int n;
int64_t x[MAX], y[MAX], p[MAX];
int64_t dpx[MAX][1 << MAX];
int64_t dpy[MAX][1 << MAX];
int64_t ans[MAX + 1];

void init() {
	for(int i = 0; i < MAX; ++i) {
		ans[i] = INF;
		for(int j = 0; j < (1 << MAX); ++j) {
			dpx[i][j] = abs(x[i]);
			dpy[i][j] = abs(y[i]);
		}
	}
	for(int j = 0; j < (1 << MAX); ++j) {
		for(int k = 0; k < MAX; ++k) {
			if(j >> k & 1) {
				for(int i = 0; i < MAX; ++i) {
					dpx[i][j] = min(dpx[i][j], abs(x[i] - x[k]));
					dpy[i][j] = min(dpy[i][j], abs(y[i] - y[k]));
				}
			}
		}
	}
}

int main() {
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> x[i] >> y[i] >> p[i];
	init();
	for(int mask = 0; mask < pow(3, n); ++mask) {
		int msk = mask;
		int mskx = 0, msky = 0;
		int cnt = 0;
		for(int i = 0; i < n; ++i) {
			if(msk % 3 == 1) {
				mskx |= (1 << i);
				++cnt;
			}
			if(msk % 3 == 2) {
				msky |= (1 << i);
				++cnt;
			}
			msk /= 3;
		}
		int64_t sum = 0;
		for(int i = 0; i < n; ++i) {
			sum += min(dpx[i][mskx], dpy[i][msky]) * p[i];
		}
		ans[cnt] = min(ans[cnt], sum);
	}
	for(int i = 0; i <= n; ++i) {
		cout << ans[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 11724
n = gets.to_i
a = gets.split.map(&:to_i).sort
plus = a.map{|i| i + 1}
minus = a.map{|i| i - 1}
arr = Array.new(100001,0)

sum = a + plus + minus
sum.each do |i|
  next if i < 0
  arr[i] += 1
end

p arr.max


Measured memory_bytes: 15156
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    ll n, a, b, c, d; cin>>n>>a>>b>>c>>d;

    bool valid = false;
    for(ll i=0; i<n; i++){
        ll lb = c * i - (n - 1 - i) * d;
        ll ub = d * i - (n - 1 - i) * c;

        if(a + lb <= b && b <= a + ub){
            valid = true;
        }
    }

    cout << (valid ? "YES" : "NO") << endl;

    return 0;
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b)
{
	int res = 1;

	while (b)
	{
		if (b & 1) res = (res * a);

		a = (a * a); 
		b >>= 1;
	}
	return res;
}

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

#define N 500010
#define MOD 1000000007

int seg[4 * N] = {};
int n;
string s;

void build(int node, int l, int r)
{
	if (l == r)
	{
		seg[node] = (1ll << (s[l - 1] - 'a'));
		return;
	}

	int mid = l + r >> 1;
	build(2 * node, l, mid);
	build(2 * node + 1, mid + 1, r);
	seg[node] = (seg[2 * node] | seg[2 * node + 1]);
}

void update(int node, int l, int r, int pos, char val)
{
	if (l == r)
	{
		// cout << l << " " << r << " " << node << "u\n";
		seg[node] ^= (1ll << (s[l - 1] - 'a'));
		s[l - 1] = val, seg[node] |= (1ll << (val - 'a'));
		return;
	}

	int mid = l + r >> 1;
	if (pos <= mid)
		update(2 * node, l, mid, pos, val);
	else
		update(2 * node + 1, mid + 1, r, pos, val);

	seg[node] = (seg[2 * node] | seg[2 * node + 1]);
}


int query(int node, int l, int r, int ql, int qr)
{
	if (ql > qr)
		return 0;

	if (ql == l && qr == r)
	{
		return seg[node];
	}

	int mid = l + r >> 1;

	return (query(2 * node, l, mid, ql, min(mid, qr)) | query(2 * node + 1, mid + 1, r, max(ql, mid + 1), qr));
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	cin >> n >> s;

	int q;
	cin >> q;

	int t, l, r;
	char ch;
	build(1, 1, n);

	for (int i = 0; i < q; ++i)
	{
		// cout << s << endl;	
		cin >> t >> l;

		if (t == 1)
		{
			cin >> ch;
			update(1, 1, n, l ,ch);
		}
		else
		{
			cin >> r;
			cout << __builtin_popcountll(query(1, 1, n, l, r)) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 11164
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int MAXN = 100000;
struct node{
	int u,v,dist;
}a[MAXN + 10];
int n,m;
int fa[MAXN + 10];
int cnt;
int num[MAXN + 10];
int tot;

bool cmp(const node &x,const node &y){
	return x.dist < y.dist;
}

int find(int x){
	return x == fa[x] ? x : fa[x] = find(fa[x]);
}

int main(){
	while(scanf("%d%d",&n,&m) == 2 && n && m){
		cnt = 0;
		tot = 0;
		for(int i = 1;i <= m;i++){
			int u,v,dist;
			scanf("%d%d%d",&u,&v,&dist);
			a[++cnt].u = u;
			a[cnt].v = v;
			a[cnt].dist = dist;
			a[++cnt].v = u;
			a[cnt].u = v;
			a[cnt].dist = dist;
		}
		for(int i = 1;i <= n;i++)
			fa[i] = i;
		sort(a + 1,a + cnt + 1,cmp);
		for(int i = 1;i <= cnt;i++){
			int x = find(a[i].u);
			int y = find(a[i].v);
			if(x == y)
				continue;
			num[++tot] = a[i].dist;
			fa[x] =y;
		}
		printf("%d\n",num[(tot + 1) / 2]);
	}
}//

Measured memory_bytes: 2992
N, M, C = map(int,input().split())
B = list(map(int,input().split()))

ans = 0


for i in range(N):
  result = 0
  A = list(map(int,input().split()))
  for j in range(M):
    result += A[j]*B[j]
 
  result =result + C
  if result >0:
    ans += 1
    
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll n,ans=0;
void Main(){
    cin>>n;
    vector<ll> l(n);
    For(i,0,n)cin>>l.at(i);
    sort(ALL(l));
    For(i,0,n-2){
        For(j,i+1,n-1){
            For(k,j+1,n){
                if(l.at(i)+l.at(j)>l.at(k)) ans++;
            }
        }
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(){
  int N; cin>>N;
  vector<int> K(N);
  for(int i=0; i<N; i++){
    cin>>K.at(i);
  }
  sort(K.begin(),K.end());
  K.at(N-1)/=2;
  int H=0;
  for(int i=0; i<N; i++){
    H+=K.at(i);
  }
  cout<<H<<endl;
}
    


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

using namespace std;

int main()
{
    string o, e;
    cin >> o >> e;

    for (int i = 1; i <= o.size() + e.size(); i++) {
        if (i % 2 == 1) cout << o[(i-1)/2];
        else cout << e[(i-1)/2];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	lld n;
	set<lld> s;

	cin >> n;

	for(int i = 0; i < n; i++)
	{
		lld a;
		cin >> a;

		if (s.count(a) > 0)
		{
			s.erase(a);
		}else
		{
			s.insert(a);
		}
	}

	cout << s.size() << endl;

	return 0;
}

Measured memory_bytes: 4864