akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())
int main(){
    int N,W;
    int sum=0;
    int ans=0;
    ll INF=pow(10,10);
    cin>>N>>W;
    vector<ll> w(N);
    vector<ll> v(N);
    rep(i,N){
        cin>>w[i]>>v[i];
        sum+=v[i];
    }
    vector<vector<ll> > dp(N+1,vector<ll>(sum+1));
    dp[0][0]=0;
    FOR(j,1,sum+1){
        dp[0][j]=INF;
    }
    rep(i,N){
        rep(j,sum+1){
            if (j<v[i]){
                dp[i+1][j]=dp[i][j];
            }else{
                dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
            }
            if(dp[i+1][j]<=W && ans<j){
                ans=j;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 80256
//A,Elebereth Gilthoniel mantae!
//For Temeria!
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>
#include<cstring> 
using namespace std;
const long long maxn=2e6+1e5;
vector<pair<long long,long long> > v[maxn];vector<long long> col[maxn];long long vis[maxn];
long long bark[maxn];vector<long long> qzr[maxn];long long ful;
long long dis[maxn];
int main()
{
	long long n,m;cin>>n>>m;
	for(long long i=0;i<m;i++)
	{
		long long a,b,c;cin>>a>>b>>c;
		v[a].push_back(make_pair(c,b));v[b].push_back(make_pair(c,a));
		col[c].push_back(a);col[c].push_back(b);
	} 
	for(long long i=1;i<=n;i++)
	{
		sort(v[i].begin(),v[i].end());
	}
	ful=1e6+5;
	for(long long asd=1;asd<=1e6+500;asd++)
	{
		if(col[asd].size()==0) continue;
		for(long long it=0;it<col[asd].size();it++)
		{
			long long  p=col[asd][it];
			if(vis[p]==asd) continue;
			queue<long long> q;vector<long long> kl;kl.clear();
			q.push(p);vis[p]=asd;kl.push_back(p);
			while(!q.empty())
			{
				if(q.size()==0) break; 
				long long t=q.front();q.pop();
				for(long long i=max(bark[t]-10,(long long)0);i<v[t].size();i++)
				{
					pair<long long,long long> u=v[t][i];
					if(vis[u.second]==asd) continue;
					if(u.first>asd)
					{
						bark[t]=i;break;
					}	
					if(u.first<asd)
					{
						continue;
						//bark[t]=i;break;
					}
					kl.push_back(u.second);q.push(u.second);vis[u.second]=asd;
				}
			}
			for(long long i=0;i<kl.size();i++)
			{
			//	cout<<kl[i]<<" ";
				long long t=kl[i];qzr[t].push_back(ful),qzr[ful].push_back(t);
			}//cout<<"\n";
			ful++;
		}
	}
	memset(dis,-1,sizeof(dis));
	priority_queue<pair<long long,long long> > q;
	q.push(make_pair(-0,1));dis[1]=0;
	while(!q.empty())
	{
		if(q.size()==0) break; 
		long long t=(q.top()).second;q.pop();	
		for(long long i=0;i<qzr[t].size();i++)
		{
			long long j=qzr[t][i];
			if(dis[j]==-1)
			{
				dis[j]=dis[t]+1;q.push(make_pair(-dis[j],j));
			}

		}
	}
	if(dis[n]==-1) dis[n]--;
	cout<<dis[n]/2;
	return 0;
}

Measured memory_bytes: 199032
#include <stdio.h>

int main(void)
{
	int i, j;
	int N;

	scanf("%d", &N);

	for( i = 0; i < 9; i++ ) {
		for ( j = 0; j < 9; j++ ) {
			if( (i+1) * (j+1) == N ) {
				printf("Yes");
				return 0;
			}
		}
	}

	printf("No");
	return 0;
}

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

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

    string str;
    cin >> str;

    if (str.length() > n)
    {
        string rep = "...";
        str.replace(n, str.length(), rep);
        cout << str << endl;
    }
    else
    {
        cout << str << endl;
    }
}


Measured memory_bytes: 3576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    public class EijA
    {
        public static void Main(string[] args)
        {
            var c = new ConsoleInput(Console.In);
            int L = c.ReadInt;
            int R = c.ReadInt;
            int d = c.ReadInt;

            int count = 0;
            for (int i = L; i <= R; i++)
            {
                if (i % d == 0) count++;
            }
            Console.WriteLine(count);
        }
    }
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }

}

Measured memory_bytes: 27852
#include<stdio.h>
main(){
int i,j,k;
char s[81];
while(fgets(s,81,stdin)!=0){
char t[3][5]={"the","this","that"};
for(i=1;i<27;i++){
for(j=0;j<3;j++){
for(k=0;k<strlen(t[j]);k++)
t[j][k]=(t[j][k]-'a'+1)%26+'a';
if(strstr(s,t[j])!=0){
for(j=0;j<strlen(s);j++)
if('a'<=s[j]&&s[j]<='z')
for(k=0;k<i;k++)
s[j]+=26*(s[j]-'a'-1<0)-1;
printf("%s",s);
break;
}
}
if(j!=3)
break;
}
}
return 0;
}

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

Q = int(input())
A = deque([])
ans = []

for _ in range(Q):
    q = list(map(int,input().split()))
    if q[0] == 0:
        if q[1] == 0:
            A.appendleft(q[2])
        else:
            A.append(q[2])
    elif q[0] == 1:
        ans.append(A[q[1]])
    else:
        if q[1] == 0:
            A.popleft()
        else:
            A.pop()

print(*ans,sep='\n')


Measured memory_bytes: 21892
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
print(rs()[::2])

Measured memory_bytes: 64492
#include <iostream>
using namespace std;
int main(){
  int A, B, C, X; cin >> A >> B >> C >> X;
  int ans; ans = 0;
  for (int i=0; i<=A; i++){
    for (int j=0; j<=B; j++){
      for (int k=0; k<=C; k++){
        if (500*i + 100*j + 50*k == X){
          ans = ans+1;
        }
      } 
    }    
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ll long long int
#define ALL(x) x.begin(),x.end()
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
vector<ll> vi;
/*--------------------template--------------------*/


int main() {
	cin >> n;
	cin >> s;
	ll a=0;
	REP(i, n) {
		if (s[i] == 'I') {
			counter++;
		}
		else {
			counter--;
		}
		v.push_back(counter);
	}
	v.push_back(a);
	sort(ALL(v));
	cout << v[n] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int a,b;
  string s;
  cin >> a >> b;
  if (a+b >= 10) cout << "error" << endl;
  else cout << a+b << endl; 

  return 0; 
}

Measured memory_bytes: 256
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o C.exe C.cpp 
Execute: ./C
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	int n, k, a[200000]; 
	
	// Input 
	cin >> n >> k; 
	for(int i = 0; i < n; i++) 
		cin >> a[i]; 
		
	for(int i = k; i < n; i++) {
		if(a[i] > a[i-k]) 
			cout << "Yes" << endl; 
		else 
			cout << "No" << endl; 
	}
	
	return 0; 
} 


Measured memory_bytes: 4448
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
const ll E=1e17+7;
#define F first
#define S second
#define MK make_pair




int main(){
    int a,b;
    cin>>a>>b;
    int ans=a;
    if(b<a){ans--;}
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<ctime>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<tuple>
#include<cassert>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<iomanip>
#include<climits>
#include<typeinfo>
#include<utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
double pi = 3.141592653589793238;
using ll = long long;
using namespace std;

ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpcombination[10000][10000];

ll modi = 1000000007;
ll combination(ll n, ll r) {
	if (n == r) { return dpcombination[n][n] = 1; }
	else if (r == 0) { return dpcombination[n][0] = 1; }
	else if (r == 1) { return dpcombination[n][1] = n; }
	else if (dpcombination[n][r]) { return dpcombination[n][r]; }
	else { return dpcombination[n][r] = combination(n - 1, r - 1) % modi + combination(n - 1, r) % modi; }
}

void clockman(int time1) {

	cout << 1.0*(clock() - time1) / CLOCKS_PER_SEC << endl;
	return;
}
//cout << fixed << setprecision(10)



int main() {


	int x, y;
	cin >> x >> y;
	for (int i = 0;i <= x;i++) {
		int j = x - i;
		if (i * 2 + j * 4 == y) { cout << "Yes" << endl;return 0; }
	}
	cout << "No" << endl;


	
	return 0;
}


Measured memory_bytes: 3636
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int s,p,i;
set <int> t;

int main()
{
	cin>>s;
	t.insert(s);
	i=1;
	while(true)
	{
		i++;
		if(s%2==0) s/=2;
		else s=s*3+1;
		p=t.size();
		t.insert(s);
		if(t.size()==p)
		{
			cout<<i<<endl;
			rt0;
		}
	}
	rt0;
}

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

using namespace std;
using ll = long long;

const int mod = 1e9 + 7;
const int mxs = 1e6 + 10;

vector<bool> pr(mxs, true);
map<int, int> mp;

void sieve(int n){
    for(int i = 2; (ll) i * i <= n; i++){
        if(pr[i]){
            for(ll j = i * i; j <= n; j += i){
                pr[j] = false;
            }
        }
    }
}
unordered_map<int, int> fint(int n){
    unordered_map<int, int> res;
    int p = 0;
    for(auto y : mp){
        int x = y.first;
        if((ll) x * x > n) break;
        while(n % x == 0){
            p++;
            n /= x;
        }
        res[x] = p;
        p = 0;
    }
    if(n > 1) res[n]++;
    return res;
}

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

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

ll power(ll a, ll p){
    ll res = 1;
    while(p){
        if(p & 1) res = mul(res, a);
        a = mul(a, a);
        p /= 2;
    }
    return res;
}

ll inv(ll a){
    return power(a, mod - 2);
}

ll _div(ll a, ll b){
    return mul(a, inv(b));
}

int main(){
    int n; cin>>n;
    vector<int> a(n);
    int mx = -1;
    for(int i = 0; i < n; i++){
        cin>>a[i];
        mx = max(mx, a[i]);
    }
    sieve(mx + 1);
    for(int i = 2; i < mx + 1; i++){
        if(pr[i]){
            mp[i] = 0;
        }
    }
    for(auto x : a){
        auto y = fint(x);
        for(auto xx : y){
            mp[xx.first] = max(mp[xx.first], xx.second);
        }
    }
    ll lcm = 1;
    for(auto x : mp){
        lcm = mul(lcm, power(x.first, x.second));
    }
    ll ans = 0;
    for(auto x : a){
        ans = add(ans, _div(lcm, x));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4096
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int compare(const void*a,const void *b) {
	return *(int*)a - *(int*)b;
}

int main() {
	int l=0,r=0,d,k,a,b,c = 0, n, e[100] = { 0 }, ans = 0;
	char s[3], cas[4][4] = {"AC","WA","TLE","RE"};
	scanf("%d%d%d%d", &a, &b, &c, &k);
	for (int i = 0;; i++) {
		if (a < b)break;
		else {
			b *= 2;
			l++;
		}
	}
	for (int i = 0;; i++) {
		if (b < c)break;
		else {
			c *= 2;
			r++;
		}
	}
	if (l + r <= k)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 1732
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        try (Scanner sc = new Scanner(System.in)) {
                int w = sc.nextInt();
                int n = sc.nextInt();
                int[] values = new int[w];
                for (int i = 0; i < values.length; i++) {
                    values[i] = i + 1;
                }
                for (int i = 0; i < n; i++) {
                    String str = sc.next();
                    String[] ab = str.split(",");
                    int a = Integer.parseInt(ab[0]) - 1;
                    int b = Integer.parseInt(ab[1]) - 1;
                    int c=0;
                    c=values[a];
                    values[a]=values[b];
                    values[b]=c;
                    // aとbを使ってvaluesを操作しよう
                }
                for(int i = 0; i < values.length; i++) {
                System.out.println(values[i]);
                }
                // valuesを出力しよう
            }
    }
}




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

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

    int n;
    cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    int ans = 0, mi = 1e9;
    for(int i = 0; i < n; i++){
        if(A[i] <= mi){
            ans ++;
            mi = A[i];
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(void){
    int i = 0;
    int n;

    cin >> n;

    while( i++ < n ){
        int x = i;
        if ( x % 3 == 0 ){
            cout << " " << i;
            continue;
        }
        if( x % 10 == 3 ){
            cout << " " << i;
            continue;
        }
        while( x ){
            x /= 10;
            if( x % 10 == 3 ){
                cout << " " << i;
                break;
            }
        }
    }
    cout << endl;
}



Measured memory_bytes: 3080
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 2e5 + 10, MOD = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int x, y;
	cin >> x >> y;
	if(y & 1) return cout << "No\n", 0;
	if(y > x * 4 || y < x * 2) return cout << "No\n", 0;
	cout << "Yes\n";
}

Measured memory_bytes: 3652
#include<iostream>
#include <stdio.h>
using namespace std;

int main() {
    int S, h, m, s, a;
    cin >> S;

    h = S / 3600;
    m = (S % 3600) / 60;
    s = S % 60;
    
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


Measured memory_bytes: 3104
// O(|V| + |E|)

#include <vector>
#include <cstring>

using namespace std;

class SCC {
#define MAX_V 10001
private:
  int V;
  vector<int> G[MAX_V];
  vector<int> rG[MAX_V];
  vector<int> vs;
  bool used[MAX_V];
  int cmp[MAX_V];

  void Dfs(int v) {
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
      if (!used[G[v][i]]) {
        Dfs(G[v][i]);
      }
    }
    vs.push_back(v);
  }

  void Rdfs(int v, int k) {
    used[v] = true;
    cmp[v] = k;
    for (int i = 0; i < rG[v].size(); i++) {
      if (!used[rG[v][i]]) {
        Rdfs(rG[v][i], k);
      }
    }
  }

public:
  SCC(int V): V(V) { }

  void AddEdge(int from, int to) {
    G[from].push_back(to);
    rG[to].push_back(from);
  }

  int Solve() {
    memset(used, 0, sizeof(used));
    vs.clear();
    for (int v = 0;v < V; v++) {
      if (!used[v]) {
        Dfs(v);
      }
    }
    memset(used, 0, sizeof(used));
    int k = 0;
    for (int i = vs.size() - 1; i >= 0; i--) {
      if (!used[vs[i]]) {
        Rdfs(vs[i], k++);
      }
    }

    return k;
  }

  bool IsSame(int u, int v) {
    return cmp[u] == cmp[v];
  }
};

#include <iostream>

int main() {
  int V, E;
  cin >> V >> E;
  SCC scc(V);
  for (int i = 0; i < E; i++) {
    int s, t;
    cin >> s >> t;
    scc.AddEdge(s, t);
  }
  scc.Solve();
  int Q; cin >> Q;
  for (int i = 0; i < Q; i++) {
    int u, v;
    cin >> u >> v;
    cout << scc.IsSame(u, v) << endl;
  }
  return 0;
}

Measured memory_bytes: 4532
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vstr=vector<string>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define _GLIBCXX_DEBUG
int main()
{
    int k,x;
    cin>>k>>x;
    rep2(i,x-k+1,x+k)cout<<i<<' ';
    return 0;
}

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

signed main(){
  
  string s;
  cin>>s;
  
  string S[7] = {"SUN","SAT","FRI","THU","WED","TUE","MON"};
  
  for(int i=0;i<7;i++){
    
    if( s == S[i] ){
      if( i == 0 ) cout<<7<<endl;
      else cout<<i<<endl;
    }
    
  }
  
  return 0;
}


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

using namespace std;

int main()
{
    long long x;
    long long dep = 100;
    double interest;
    long long interest_int;
    long long years = 0;
    cin>>x;
    while (dep < x)
    {
        interest = double(dep) * 0.01;
        interest_int = static_cast<long long>(interest);
        dep += interest_int;
        years += 1;
    }
    printf("%d\n", years);
    return 0;
}

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

#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

const int NN = 200005;

int N, D, A;


int tree[5000000];
int lazy[5000000];
vector<pair<int, int>> ar;

void update(int node, int a, int b, int i, int j, int val) {
    if (lazy[node] != 0) {
        tree[node] += lazy[node];
        if (a != b) {
            lazy[node * 2] += lazy[node];
            lazy[node * 2 + 1] += lazy[node];
        }
        lazy[node] = 0;
    }
    if (a > b || a > j || b < i)
        return;
    if (a >= i && b <= j) {
        tree[node] -=val;
        if (a != b) {
            lazy[node * 2]-= val;
            lazy[node * 2 + 1]-= val;
        }
        return;
    }
    update(node * 2, a, (a + b) / 2, i, j, val);
    update(1 + node * 2, 1 + (a + b) / 2, b, i, j, val);
//    tree[node] = min(tree[node * 2],
//                     tree[node * 2 + 1]);
}


int query(int node, int a, int b, int i, int j) {
    if (a > b || a > j || b < i) return 0;
    if (lazy[node] != 0) {
        tree[node] += lazy[node];
        if (a != b) {
            lazy[node * 2] += lazy[node];
            lazy[node * 2 + 1] += lazy[node];
        }
        lazy[node] = 0;
    }
    if (a >= i && b <= j) return tree[node];
    return query(node * 2, a, (a + b) / 2, i, j) +
           query(1 + node * 2, 1 + (a + b) / 2, b, i, j);
}

void build(int node, int a, int b) {
    if (a == b) {
        tree[node] = ar[a].second;
        return;
    }
    build(node * 2, a, (a + b) / 2);
    build(1 + node * 2, 1 + (a + b) / 2, b);
}


integer main() {
    ios_base::sync_with_stdio(false);

    cin >> N >> D >> A;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        ar.push_back({a, b});
    }
    sort(ar.begin(), ar.end());
    build(1, 0, N-1);

//    int d = ceil(1.0 * ar[0].second / A);
//    int en = ar[0].first + D * 2;
//    auto ptr = upper_bound(ar.begin(), ar.end(), make_pair(ar[0].first + D * 2, 0));
//    int idx = ptr - ar.begin() - 1;
//    update(1, 0, N-1, 0, idx, d * A);
//    int ans = d;
    int ans = 0;

    for (int i = 0; i < N; i++) {
        int k = query(1, 0, N-1, i, i);
        if (k > 0) {
            int d = ceil(1.0 * k / A);
            int en = ar[i].first + D * 2;
            auto ptr = upper_bound(ar.begin(), ar.end(), make_pair(ar[i].first + D * 2, 10000000000LL));
            int idx = ptr - ar.begin() - 1;

            update(1, 0, N-1, 0, idx, d * A);
            ans += d;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 16620
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const list = lines[0].split("");
    const map = {};
    list.forEach(v=>{
        map[v] = (map[v]||0)+1;
    });
    let flg = true;
    Object.keys(map).forEach(key=>{
        if(map[key]%2===1)flg = false;
    });
    console.log(flg?"Yes":"No");
    
});


Measured memory_bytes: 30936
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, char *argv[])
{
    int n, q, m, d, max, index;
    while (cin >> n >> q, n) {
        vector<int> date(100, 0);
        for (int i = 0; i < n; ++i) {
            cin >> m;
            for (int j = 0; j < m; ++j) {
                cin >> d;
                date[d]++;
            }
        }
        vector<int>::iterator itr = max_element(date.begin(), date.end());
        max = *itr;
        index = distance(date.begin(), itr);
        cout << (max < q ? 0 : index) << endl;
    }
    return 0;
}

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

int main() {
	long long N, B[100], ANS = 0;
	cin >> N;
	for (int i = 0; i < N - 1; i++) cin >> B[i];
	ANS = B[0] + B[N - 2];
	for (int i = 0; i < N - 2; i++) {
		ANS += min(B[i], B[i + 1]);
	}
	cout << ANS << endl;
}

Measured memory_bytes: 256
from collections import defaultdict

N, M = map(int, input().split())

A = list(map(int, input().split()))

cnts = defaultdict(int)

for a in A:
    cnts[a] += 1

for _ in range(M):
    b, c = map(int, input().split())
    cnts[c] += b

cnts = reversed(sorted(cnts.items(), key=lambda x: x[0]))

res = 0
for v, c in cnts:
    if N - c >= 0:
        res += v * c
    else:
        res += v * N
        break
    N -= c
print(res)


Measured memory_bytes: 43296
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);


//tupleの利用
//昇順ソート，降順ソートを入れ替えるときは． -　を入れるとよい

int main(){
  int n;
  cin >> n;
  vector<tuple <string, int,int>>shop;
  //--------- <name, price, id>
  REP(i,n){
    string s;
    int p, id;
    cin >> s >> p;
    p = - p;  // 昇順sort <->　降順 sortを入れ替えるため
    id = i + 1;
    shop.push_back(tie(s,p,id));  //tupleに格納　push_back(tie(a, b, c));
  }

  sort(ALL(shop)); //s,p, idの優先順位でsortされる

  REP(i,n){
    cout << get<2>(shop[i]) << endl;  //値の参照　get<要素数>(配列名[index])
  }
  return 0;
}


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

int main() {
  int A,B,C,D ;
  cin >> A >> B >> C>>D ;

  if ( A+B>C+D ) {
     cout << "Left" << endl;}
  else if (A+B<C+D){
      cout << "Right" << endl;}
  else cout << "Balanced" << endl;
}
    


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



int main() {
  ll x,y; cin>>x>>y;
  ll value=x;
  int count=0;
  while(value<=y){value*=2;
               count++;}
cout<<count<<endl;
  
}

Measured memory_bytes: 256
T1,T2=map(int,input().split())
A1,A2=map(int,input().split())
B1,B2=map(int,input().split())
OU=T1*(A1-B1)
HUKU=T2*(A2-B2)
TOTAL=OU+HUKU
if TOTAL==0:
 print("infinity")
elif (OU>0 and TOTAL>0) or (OU<0 and TOTAL<0):
 print(0)
elif (OU>0 and TOTAL*(-1)>OU) or (OU<0 and TOTAL*(-1)<OU):
 print(1)
else:
 K=int(OU/TOTAL)*-1
 if (OU%TOTAL)==0:
  print(K*2)
 else:
  print(K*2+1)


Measured memory_bytes: 38384
//A - Still TBD
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int y,m,d;
	scanf("%d/%d/%d",&y,&m,&d);
	if((y<2019)||(y==2019 && m<4)||(y==2019 && m==4 && d<=30))
		cout<<"Heisei\n";
	else
		cout<<"TBD\n";
	return 0;
}

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

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

  ll n; cin >> n;
  ll a[100010];
  a[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  a[n+1] = 0;

  ll ans = 0;
  for (int i = 1; i <= n+1; i++) {
    ans += abs(a[i] - a[i-1]);
  }

  for (int i = 1; i <= n ; i++) {
    cout << ans - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i+1] - a[i-1]) << endl;
  }

  return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>

int main(void) {

	int a ,b ;
    scanf("%d %d" , &a , &b );
    if(a < b){
    	printf("a < b\n");
    } else if(a > b){
    	printf("a > b\n");
    } else {
    	printf("a == b\n");
    }

    return 0;
}

Measured memory_bytes: 580
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

const int MAX = 1010;
int table[MAX][MAX];
bool isprime[MAX*MAX];
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
void init(int n){
  fill((int*)table, (int*)table+MAX*MAX, -1);
  int x = MAX/2, y = MAX/2;
  int d = 0, step = 1, cnt = 0, tt = 0;

  for(int i=1;i<=n;++i){
	table[y][x] = i;
	x += dx[d], y += dy[d];
	if(++cnt >= step){
	  cnt = 0, ++d, d %= 4;
	  if(++tt >= 2)
		tt = 0, ++step;
	}		  
  }

  fill(isprime, isprime+MAX*MAX, true);
  isprime[0] = isprime[1] = false;
  REP(i,n+1)
	if(isprime[i])
	  for(int j=i+i;j<=n;j+=i)
		isprime[j] = false;
  
}

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

  int M, N;
  while(cin>>M>>N,M){
	//  init(1000000);
	init(M);
	int sx, sy;
	REP(y,MAX) REP(x,MAX)
	  if(table[y][x] == N){
		sx = x, sy = y; break;
	  }

	VVI row(2, VI(MAX, 0));
	int lx=sx, rx = sx, crt = 0, nxt = 1;
	int ans_n = 0, ans_p = 0;
	bool up = true;
	if(isprime[N])
	  ans_n = 1, ans_p = N, row[crt][sx] = 1;
	while(up){
	  up = false;
	  ++sy;
	  for(int x=max(0,lx);x<=min(rx,MAX-1);++x){
		for(int d=-1;d<=1;++d){
		  if(table[sy][x+d] < 0) continue;
		  up = true;
		  row[nxt][x+d] = max(row[nxt][x+d],
							  row[crt][x] + isprime[table[sy][x+d]]);
		  if(isprime[table[sy][x+d]]){
			if(row[nxt][x+d] > ans_n)
			  ans_n = row[nxt][x+d], ans_p = table[sy][x+d];
			else if(row[nxt][x+d] == ans_n)
			  ans_p = max(ans_p, table[sy][x+d]);
		  }
		}
	  }
	  swap(crt, nxt);
	  --lx, ++rx;
	}
	cout << ans_n << " " << ans_p << endl;
  }
  
  return 0;
}

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

int main(void) {
    long long int x;
    cin >> x;
    
    long long int t_money = 100;
    int counter = 0;
    while (t_money < x) {
        t_money =  floor(t_money * 1.01);
        counter++;
    }
    cout << counter << endl;
    
    
    return 0;
}

Measured memory_bytes: 3740
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int l = S.length();
    if(!parin(S)){
      System.out.println("No");
      return;
    }
    String zenhan = S.substring(0,(l-1)/2);
    String kouhan = S.substring((l+1)/2,l);
    if(!parin(zenhan)||!parin(kouhan)){
      System.out.println("No");
      return;
    }
    System.out.println("Yes");
  }
  
  public static boolean parin(String S){
    for(int i=0;i<S.length()-1;i++){
      if(!S.substring(i,i+1).equals(S.substring(S.length()-i-1,S.length()-i))){
        return false;
      }
    }
    return true;
  }
    
      
  }
  

  

Measured memory_bytes: 23764
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        boolean flag = true;
        while(flag){
            int time = 0;
            int num = a;
            int denomionator = 2;
            while(denomionator<=a){
                if(num%denomionator==0){
                    time++;
                    num = num/denomionator;
                }else{
                    denomionator++;
                }
            }
            if(time==1)
                flag=false;
            a++;
        }
        System.out.println(a-1);
    }}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
bool visited[200005];
vector<long> v[200005];
long long ans[200005];

void dfs(long node){
    if(visited[node])return;
    visited[node]=true;
    for(auto u:v[node]){
        if(!visited[u]){
            ans[u]+=ans[node];
            dfs(u);
        }
    }
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long n,q;cin>>n>>q;
    long a,b;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    long p,x;
    for(int i=0;i<q;i++){
        cin>>p>>x;
        ans[p]+=x;
    }
    dfs(1);
    for(int i=1;i<=n;i++){
        cout<<ans[i]<<" ";
    }




}


Measured memory_bytes: 21376
import java.util.Scanner

object Main {

  def solve() = {
    val sc = new Scanner(System.in)
    val N = sc.nextInt()
    var ans = 0
    var prev = false
    (1 to N) foreach { i =>
      val p = sc.nextInt()
      if (prev) {
        ans += 1
        prev = false
      } else {
        prev = p == i
      }
    }
    if (prev) ans += 1
    println(ans)
  }

  def main(args: Array[String]): Unit = {
    solve()
  }
}


Measured memory_bytes: 51916
#include<stdio.h>
int main(){
    int x,a,b,c,d,e,f;
    scanf("%d",&x);
    a=x/500;
    d=x-(a*500);
    b=d/5;
    e=a*1000+b*5;
    printf("%d\n",e);
    return 0;
}

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

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

  if ( a > b ) {
    d = a; a = b; b = d;
  }
  if ( b > c ) {
    d = b; b = c; c = d;
    if ( a > b ) {
      d = a; a = b; b = d;
    }
  }
  cout << a << " " << b << " " << c << endl;
   return 0;
}


Measured memory_bytes: 3084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest20191101
{
    class Program
    {
        static void Main(string[] args)
        {
            double n = double.Parse(Console.ReadLine());
            double[] a = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
            double sum = 0;
            foreach(double an in a)
            {
                sum += 1 / an;
            }

            Console.WriteLine(1 / sum);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

bool dfs(string &s, vector<string> &add, int p, bool once) {
  if (p == s.size()) return true;
  rep(i,4) {
    bool success = true;
    rep(j,add[i].size()) {
      if (p+j >= s.size() || s[p+j] != add[i][j]) {
        success = false;
        break;
      }
    }
    if (success) {
      if (once) return true;
      else if (dfs(s, add, p+add[i].size(), true) ) {
        return dfs(s, add, p+add[i].size(), false);
      }
    }
  }
  return false;
}

int main() {
  string s; cin >> s;
  vector<string> add = {"dream", "dreamer", "erase", "eraser"};
  if (dfs(s, add, 0, false) ) cout << "YES\n";
  else cout << "NO\n";
  return 0;
}


Measured memory_bytes: 512
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
using System.Text.RegularExpressions;

namespace CsTest
{
    class Program
    {
        static void Main()
        {
            int[] AB = AtCoder.ReadInt32Array();
            int A = AB[0];
            int B = AB[1];
            Console.WriteLine((A + B) % 24);
        }
    }

    public class AtCoder
    {
        public static string[] ReadStringArray() => Console.ReadLine().Split(Array.Empty<char>(), StringSplitOptions.RemoveEmptyEntries);
        public static int[] ReadInt32Array() => ReadStringArray().Select(s => int.Parse(s)).ToArray();
        public static long[] ReadInt64Array() => ReadStringArray().Select(s => long.Parse(s)).ToArray();
    }
}

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

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[A];
        int[] b = new int[B];
        for (int i = 0 ; i < A ; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0 ; i < B ; i++) {
            b[i] = sc.nextInt();
        }
        int[] x = new int[m];
        int[] y = new int[m];
        int[] c = new int[m];
        for (int i = 0 ; i < m ; i++) {
            x[i] = sc.nextInt() - 1;
            y[i] = sc.nextInt() - 1;
            c[i] = sc.nextInt();
        }
        int min = 100000000;
        for (int i = 0 ; i < m ; i++) {
            min = Math.min(min, a[x[i]] + b[y[i]] - c[i]);
        }
        Arrays.sort(a);
        Arrays.sort(b);
        min = Math.min(min, a[0] + b[0]);
        System.out.println(min);
    }

}

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

int main() {
  string a;
  cin >> a;
  
  string b;
  b = "abcdefghijklmnopqrstuvwxyz";
  
  int result = a.compare(0,1,b,0,1);
  cout << b.substr(result+1,1) << endl;
  return 0;
}

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

using namespace std;

const string ord = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(void) {
  int n;
  while (cin >> n, n) {
    vector<int> k(n);
    for (int i = 0; i < n; i++) {
      cin >> k[i];
    }

    string s;
    cin >> s;

    int l = 0;
    string ans = "";
    for (int i = 0; i < s.size(); i++) {
      ans += ord[(ord.find(s[i]) - k[l] + ord.size()) % ord.size()];
      l = (l + 1) % k.size();
    }

    cout << ans << endl;
  }
  

  return 0;
}


Measured memory_bytes: 3152
N = int(input())
temp = input().rstrip().split(" ")
list1 = []
for i in range(N):
    list1.append(int(temp[i]))
list1.sort()
avg = round(sum(list1) / len(list1))
ans = 0
for i in range(N):
    ans += (list1[i] - avg)**2
print(ans)

Measured memory_bytes: 3316
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;

struct Block {
    int w, s, v;
    bool operator< (const Block & b) const {
        return w + s > b.w + b.s;
    }
} bt[1010];

long long rucsac[20100];

int main()
{
    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; i++)
        scanf("%d%d%d", &bt[i].w, &bt[i].s, &bt[i].v);

    sort(bt, bt + n);

    for (int i = 0; i < n; i++) {
        for (int j = bt[i].w; j <= 20000; j++) {
            long long & v = rucsac[min(j - bt[i].w, bt[i].s)];
            v = max(v, rucsac[j] + bt[i].v);
        }
    }

    cout << rucsac[0] << '\n';

    return 0;
}


Measured memory_bytes: 384
import math

K = int(input())

A = 0

#3つとも同じ数字
for i in range(K):
    A += i+1
    
#2つ同じ数字
for i in range(K):
    for j in range(K):
        if i > j:
            A += 6*math.gcd(i+1, j+1)

#全部違う数字
for i in range(K):
    for j in range(K):
        for k in range(K):
            if i > j and j > k:
                A += 6*math.gcd(math.gcd(i+1, j+1), k+1)

print(A)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;

vector<ll>graph[100010];
ll vertice,edge;

ll dp[100010];

void DFS(ll start)
{
    dp[start]=0;
    ll size,store;
    size=graph[start].size();
    for(ll i=0;i<size;i++)
    {
        store=graph[start][i];
        if(dp[store]!=-1)
        {
            dp[start]=max(dp[start],dp[store]+1);
        }
        else
        {
            DFS(store);
            dp[start]=max(dp[start],dp[store]+1);
        }
    }
}

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

    memset(dp,-1,sizeof(dp));
    cin>>vertice>>edge;
    ll vert1,vert2;
    for(ll i=0;i<edge;i++)
    {
        cin>>vert1>>vert2;
        graph[vert1].push_back(vert2);
    }
    ll ans=NEGINF;
    for(ll i=1;i<=vertice;i++)
    {
        if(dp[i]==-1)
        {
            DFS(i);
        }
        ans=max(ans,dp[i]);
    }
    cout<<ans;
    return 0;
}

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

int main(){
	int i,n,d;
	double r = 100;

	scanf("%d", &n);
	for(i=0; i<n; i++){
		r = r*1.05;
		d = (int)r;
		if(r-d>=0.001){
			r = d + 1;
		}else{
			r = d;
		}
		d = (int)r;
	}
	printf("%d\n", d*1000);
	return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<set>
using namespace std;
#define ll long long

int gcd(int a, int b){
    
    if(b==0)
    return a;
    
    return gcd(b, a%b);
    
}
int main(){
int r,n;
cin>>r>>n;
int maxdis=0;

int a,b,c,d;
cin>>a;
c=a;
for(int i=1;i<n;i++){
    cin>>b;
    maxdis= max(b-a, maxdis);
    a=b;
}
d= r-b;
maxdis= max(maxdis, c+d);

cout<<r-maxdis;


}

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


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


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


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


def main():
    N, M = MI()
    A = LI()

    shre = sum(A) / (4 * M)
    ans = 0
    for a in A:
        if a >= shre:
            ans += 1
    print("Yes" if ans >= M else "No")


main()


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<28);
const ll INFL = (1LL<<61);

ll solve(ll n) {
  ll base = 10, res = 0;
  while (base <= n) {
    res += n / base;
    base *= 5;
  }
  return res;
}

int main() {
  ll n; cin >> n;
  if (n & 1) {
    cout << 0 << endl;
  } else {
    cout << solve(n) << endl;
  }
  return 0;
}


Measured memory_bytes: 384
def find(id):
    if id != parent[id]:
        parent[id] = find(parent[id])
    return parent[id]

def union(id1, id2):
    par1, par2 = find(id1), find(id2)
    if par1 == par2:
        return 0
    ret = size[par1] * size[par2]
    if rank[par1] > rank[par2]:
        parent[par2] = par1
        size[par1] += size[par2]
    else:
        parent[par1] = par2
        if rank[par1] == rank[par2]:
            rank[par2] += 1
        size[par2] += size[par1]
    return ret

nVertices, nEdges = map(int, input().split())
edges = [tuple(map(lambda v: int(v) - 1, input().split())) for _ in range(nEdges)]
parent = list(range(nVertices))
rank = [0] * nVertices
size = [1] * nVertices
count = [0] * (nEdges - 1) + [nVertices * (nVertices - 1) // 2]
for i in range(nEdges - 2, -1, -1):
    u, v = edges[i + 1]
    count[i] = count[i + 1] - union(u, v)
print('\n'.join(map(str, count)))


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

using namespace std;

string a, b;
int A[100050], B[100050];
int main(){
	cin >> a >> b;
	int n=a.length(), m=b.length();
	for(int i = 0; i<n; i++){
		if(a[i] == 'A') A[i+1]=1;
		else A[i+1]=2;
	}
	for(int i = 0; i<m; i++){
		if(b[i] == 'A') B[i+1]=1;
		else B[i+1]=2;
	}
	for(int i = 1; i<=n; i++) A[i]+=A[i-1];
	for(int i = 1; i<=m; i++) B[i]+=B[i-1];
	int q; cin >> q;
	while(q--){
		int c, d, e, f; cin >> c >> d >> e >> f;
		if((A[d]-A[c-1])%3 == (B[f]-B[e-1])%3) cout << "YES\n";
		else cout << "NO\n";
	}
}


Measured memory_bytes: 1792
// #define _GLIBCXX_DEBUG

#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <vector>
#include <chrono>
#include <cmath>

#define int long long

using namespace std;


signed main() {
  std::string s;
  cin >> s;
  int n = s.size();

  for (int i = 0; i < n; i++) {
    if (s[i] == '?') {
        s[i] = 'D';
    }
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 3752
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        if (s.equals("AAA") || s.equals("BBB")) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 21844
S=input()
A=list(S)
number=[]
for i in A:
    if i == "A" or i == "C" or i == "G" or i == "T":
        number.append(1)
    else:
        number.append(0)

count=0
maxcount=0

for i in number:
    if i == 1:
        count = count + 1
        if count > maxcount:
            maxcount=count
    elif i == 0:
        count = 0
        
print(maxcount)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 
ll a[500][500],c[500],co[500];
int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> n >> m >> x;
	for(i=1;i<=n;i++)
	{
		cin >> co[i];
		for(j=1;j<=m;j++)
			cin >> a[i][j];		
	}

	ll mn=1e18;
	for(i=1;i<(1<<n);i++)
	{
		y=0;
		for(j=1;j<=m;j++)
			c[j]=0;
		for(j=0;j<n;j++)
		{
			if(i&(1<<j))
			{
				y+=co[j+1];

				for(k=1;k<=m;k++)
					c[k]+=a[j+1][k];
			}
		}
		ll f=0;
		for(j=1;j<=m;j++)
		{
			if(c[j]<x)f=1;
		}
		if(!f)
			mn=min(mn,y);
	}
	if(mn==1e18)
		cout<<-1<<endl;
	else
		cout<<mn<<endl;
}

Measured memory_bytes: 3660
import java.util.ArrayList;
import java.util.Scanner;

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

        for(int i = 0; i < n; i ++)
            values.add(sc.nextInt());

        sc.close();

        long ans = 0;
        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n; j++){
                ans += values.get(i) * values.get(j);
            }
        }

        System.out.println(ans);

    }
}


Measured memory_bytes: 22868
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <vector>
#define mod 100000000
typedef long long int ll;
typedef long double ld;
using namespace std;

/*int fun(int *arr, int n) {
  if (n == 0 || n == 1) return 0;
  if (n == 2) return abs(arr[1] - arr[0]);
  int ans1 = abs(arr[n - 1] - arr[n - 2]) + fun(arr, n - 1);
  int ans2 = abs(arr[n - 1] - arr[n - 3]) + fun(arr, n - 2);
  return min(ans1, ans2);
}*/

ll minCost(ll *arr, ll n) {
  ll *dp = new ll[n + 1];
  dp[0] = dp[1] = 0;
  dp[2] = abs(arr[1] - arr[0]);
  for (ll i = 3; i < n + 1; i++) {
    ll ans1 = abs(arr[i - 1] - arr[i - 2]) + dp[i - 1];
    ll ans2 = abs(arr[i - 1] - arr[i - 3]) + dp[i - 2];
    dp[i] = min(ans1, ans2);
  }
  return dp[n];
}

int main() {
/*#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif*/
  ll n;
  cin >> n;
  ll *arr = new ll[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  cout << minCost(arr, n) << endl;
  return 0;
}


Measured memory_bytes: 1792
def b():
    n = int(input())
    s = input()
    if n % 2 != 0:
        print("No")
        return

    half = n // 2
    if s[0:half] == s[half:n]:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    b()

Measured memory_bytes: 38384