akhauriyash/Code-Regression huggingface dataset:
//[??????, ????????¶???(0????????????, 1????????????), ????????????(0???X)]?????¶?´??????¶???????????§??????????????????????????§?????????
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <tuple>
#include <functional>
#define int long long
using namespace std;

int n, m, x;
int t[10000];
vector<int> et[10000];
vector<int> ec[10000];

int dp[10000][2][201];

void input() {
	int i, j;
	
	cin >> n >> m >> x;
	for (i = 0; i < n; i++) { cin >> t[i]; }
	for (i = 0; i < m; i++) {
		int a, b, d;
		cin >> a >> b >> d;
		a--; b--;
		et[a].push_back(b);
		ec[a].push_back(d);
		et[b].push_back(a);
		ec[b].push_back(d);
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j <= x; j++) {
			dp[i][0][j] = 1145141919893810;
			dp[i][1][j] = 1145141919893810;
		}
	}
}

typedef tuple<int, int, int, int> T;	//cost, vertex, state, rem_time
priority_queue<T, vector<T>, greater<T> > que;

void dijkstra() {
	que.push(T(0, 0, 0, x));
	
	while (!que.empty()) {
		T now = que.top();
		que.pop();
		
		int cst   = get<0>(now);
		int pos   = get<1>(now);
		int state = get<2>(now);
		int timer = get<3>(now);
		
		if (dp[pos][state][timer] <= cst) {
			continue;
		}
		dp[pos][state][timer] = cst;
		
		for (int i = 0; i < et[pos].size(); i++) {
			int v = et[pos][i];
			int d = ec[pos][i];
			
			if (t[v] == 1) {	//??????
				que.push(T(cst + d, v, state, max(0LL, timer - d)));
			}
			else if (t[v] / 2 == state) {	//????????°?¢? (??????????????¨??°?¢??????????)
				que.push(T(cst + d, v, state, x));
			}
			else {	//??°?¢???????
				if (d < timer) continue;
				que.push(T(cst + d, v, !state, x));
			}
		}
	}
}

signed main() {
	input();
	dijkstra();
	
	int ans = 1145141919893810;
	for (int i = 0; i <= x; i++) {
		ans = min(ans, dp[n-1][0][i]);
		ans = min(ans, dp[n-1][1][i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 36640
#include<stdio.h>
int main(){
    int a[13]={0,1,3,1,2,1,2,1,1,2,1,2,1}; 
    int x,y;
    scanf("%d %d",&x,&y);
    if(a[x]==a[y]){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define reg register
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="Sunny")cout<<"Cloudy";
	else if(s=="Cloudy")cout<<"Rainy";
	else cout<<"Sunny"; 
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-5;
const ll MOD=1e9+7;
int main(){
    int h,w;cin>>h>>w;
    vector<int> c1(h),c2(w);
    vector<string> c(h);
    for(int i=0;i<h;i++){
        cin>>c[i];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(c[i][j]=='#')c1[i]++;
        }
    }
    for(int j=0;j<w;j++){
        for(int i=0;i<h;i++){
            if(c[i][j]=='#')c2[j]++;
        }
    }
    for(int i=0;i<h;i++){
        if(c1[i]==0)continue;
        for(int j=0;j<w;j++){
            if(c2[j]==0)continue;
            cout<<c[i][j];
        }
        cout<<endl;
    }
}   


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,x,y) for(int i=(x),i##END=(y);i<=i##END;++i)
#define DOR(i,x,y) for(int i=(x),i##END=(y);i>=i##END;--i)
template<typename T,typename _T>inline bool chk_min(T &x,const _T y){return y<x?x=y,1:0;}
template<typename T,typename _T>inline bool chk_max(T &x,const _T y){return x<y?x=y,1:0;}
typedef long long ll;

int main()
{
	int x;
	scanf("%d",&x);
	printf("%lld\n",3ll*x*x);
	return 0;
}


Measured memory_bytes: 256
import numpy as np
N,M,C= map(int,input().split())
list_B = np.array(list(map(int,input().split())))
cnt = 0
for i in range(N):
    list_Ai = np.array(list(map(int, input().split())))
    if np.dot(list_B,list_Ai) > -C:
        cnt += 1

print(cnt)


Measured memory_bytes: 12504
#include <iostream>
#include <vector>
constexpr int MOD = 1'000'000'007; //'

/**
 * T: int, long, long long, ModInt
 * std::stringを使いたい場合は全部int等に変換すること
 */
template <typename T>
class BIT {
    // 1-indexed
    std::vector<T> data;
    std::size_t size;

   public:
    BIT(const std::size_t &n, const T &value = 0) {
        data.assign(n + 1UL, value);
        size = n;
    }

    // add value to idx-th
    void add(const std::size_t &idx, const T &value = 1) {
        for (std::size_t i = idx; i <= size; i += i & (~i + 1UL)) {  // LSB
            data.at(i) += value;
        }
    }

    // sum of [1, idx]
    T sum(const std::size_t &idx) {
        T res = 0;
        for (std::size_t i = idx; i > 0UL; i -= i & (~i + 1UL)) {  // LSB
            T d = data.at(i);                                      // cast
            res += d;
        }
        return res;
    }

    // sum of [first, last]
    T sum(const std::size_t &first, const std::size_t &last) {
        T res = sum(last) - sum(first - 1UL);  // cast
        return res;
    }

    std::size_t getSize() { return size; }  // debug用
};

/**
 * T: int, long, long long, ModInt
 * std::string を用いる場合は int 等に変換する
 * 要素数 N と 要素の最大値M に対して 𝑶(N logM)
 * 最大で N^2 / 2 なので，たぶん long long で十分
 */
template <typename T>
long long inversionNumber(const std::vector<T> &v) {
    T v_max = 0;
    for (const T &ve : v) {
        if (v_max < ve) v_max = ve;
    }
    BIT<T> bit(v_max);

    long long res = 0LL;
    for (std::size_t i = 0UL; i < v.size(); ++i) {
        // bit.sum(): これまで出てきたうちで自分より小さい要素の数>=0
        long long sum = i - bit.sum(v.at(i));
        res += sum;
        bit.add(v.at(i));
    }
    return res;
}

int main(void) {
    int n;
    long long k;
    std::cin >> n >> k;

    // aの転倒数
    std::vector<int> a(n);
    for (int &ae : a) std::cin >> ae;
    long long inv_a = inversionNumber(a);

    // aaの転倒数
    std::vector<int> aa(2 * n);
    for (int i = 0; i < 2 * n; ++i) aa.at(i) = (a.at(i % n));
    long long inv_aa = inversionNumber(aa);

    // kf = k * aの転倒数
    long long kf = k * inv_a;
    kf %= MOD;

    // ks = { k(k-1)/2 }( aaの転倒数 - 2 * aの転倒数 )
    long long k_sum = k * (k - 1LL) / 2LL;
    long long sub   = inv_aa - (2LL * inv_a);
    long long ks    = (k_sum % MOD) * sub;
    ks %= MOD;

    long long ans = kf + ks;
    ans %= MOD;

    std::cout << ans << std::endl;

    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
#define mod 1000000007
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
ll n,limt,cnt=0;
void make(ll len,string s)
{
    if(len==n)
    {
        cnt++;
        cout<<s<<endl;
        return ;
    }
    char ch='a';
     for(int i=0;i<s.size();i++)
     {
         ch=max(ch,s[i]);
     }
    ch=(char)(ch+1);
    for(char i='a';i<=ch;i++)
    {
        make(len+1,s+i);
    }
}
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);

 cin>>n;
 make(1,"a");
return 0;
}





Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep2(i,x,n) for(int i=x;i<n;++i)

int main()
{
    ios::sync_with_stdio(false); 
    cin.tie(nullptr); 
    
    const i64 MOD = 1e9+7;
    string s;
    cin >> s;

    int n = s.size();
    vector<i64> dp(n+1,0);
    dp[0] = 1;
    rep(i,n) dp[i+1] = (3*dp[i]) % MOD;

    i64 ans = 1;
    rep(i,n)
    {
        if(s[n-i-1]=='1')
        {
            ans = 2*ans + dp[i];
            ans %= MOD;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
	int a;
	cin >> a;
	
	int res = 0;
	int res_k = 1;
	for (int i = 1; i <= a; ++i) {
		int k = i;
		int count = 0;
		while ((k % 2) == 0 && k > 0) {
			k = k >> 1;
			count++;
		}
		
		if (count > res) {
			res = count;
			res_k = i;
		}
	}
	
	cout << res_k << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Solver {
    public void Solve() {
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        System.out.println(z + " " + x + " " + y);
    }

    Scanner sc;

    Solver(Scanner in) {
        this.sc = in;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    }
}


Measured memory_bytes: 21844
N = gets.to_i
Xs = gets.split.map(&:to_i)

xs = Xs.inject(:+)
x2s = Xs.inject(0){|s, x| s + x*x}
f = ->(p){x2s - 2*p*xs + N*p*p}
puts (1 .. 100).map{|p| f[p]}.min

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


#define li          long long int
#define uli         unsigned long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li res[3]={0};
    li a,b;
    cin>>a>>b;
    res[a-1]++;
    res[b-1]++;
    rep(i,3)if(res[i]==0)cout<<i+1<<endl;

    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	long x;
	long hp;
} S_MONSTER;

int cmpAscVal(const void * n1, const void * n2)
{
	if (((S_MONSTER *)n1)->x > ((S_MONSTER *)n2)->x)
	{
		return 1;
	}
	else if (((S_MONSTER *)n1)->x < ((S_MONSTER *)n2)->x)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  long n,d,a;
  scanf("%ld %ld %ld", &n, &d, &a);
  S_MONSTER monster[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld %ld", &monster[i].x, &monster[i].hp);
  }
  qsort(monster, n, sizeof(S_MONSTER), cmpAscVal);
  long list[n][2];
  long start = 0;
  long end = -1;
  long attack;
  long count = 0;
  for (long i = 0; i < n; i++) {
    for (long j = start; j <= end; j++) {
      if (monster[i].hp <= 0) {
        break;
      }
      if (list[j][0] >= monster[i].x) {
        monster[i].hp -= list[end][1];
        if (j != 0) {
          monster[i].hp += list[j-1][1];
        }
        start = j;
        break;
      }
      if (j == end) {
        start = end+1;
      }
    }
    if (monster[i].hp > 0) {
      attack = (monster[i].hp+a-1)/a;
      end++;
      list[end][0] = monster[i].x+d*2;
      list[end][1] = attack*a;
      if (end != 0) {
        list[end][1] += list[end-1][1];
      }
      count += attack;
    }
  }
  printf("%ld\n", count);

  return 0;
}

Measured memory_bytes: 6468
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		String b = scan.next();
		String c = scan.next();
		
		System.out.print(a.charAt(0));
		System.out.print(b.charAt(1));
		System.out.print(c.charAt(2));
	}
}

Measured memory_bytes: 21204
n, k = map(int, input().split())
p = list(map(int, input().split()))
ev = []
for pi in p:
    ev.append((pi + 1) / 2)

ans = 0
cost = sum(ev[:k])
for i in range(k, n+1):
    if ans < cost:
        ans = cost
    if i == n:
        continue
    cost -= ev[i-k]
    cost += ev[i]
    # print(i)

print(ans)
# print(ev)

Measured memory_bytes: 25060
#include<iostream>

int main(){
  int n;
  long long a;
  long long minval = 1000000;
  long long maxval = -1000000;
  long long sum = 0;

  std::cin >> n;

  for(int i = 0; i < n; i++){
    std::cin >> a;
    if(a < minval) minval = a;
    if(a > maxval) maxval = a;
    sum += a;
  }

  std::cout << minval << " " << maxval << " " << sum << std::endl;

  return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define N 200050
#define M 200
#define int long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define ll long long
#define SIZE N
#define MOD mod
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    int l,r,d;
    cin>>l>>r>>d;
    int ans = r/d;
    if(l)ans -= (l-1)/d;
    cout<<ans;
  	return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for(int i = 0; i < H; i++) cin >> s[i];
    vector<vector<int>> dist(H, vector<int>(W, 0));
    queue<pair<int, int>> que;
    dist[0][0] = 1;
    que.push(make_pair(0, 0));
    while(!que.empty()) {
        auto p = que.front();
        que.pop();
        for(int i = 0; i < 4; i++) {
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
            if(dist[ny][nx] != 0) continue;
            if(s[ny][nx] == '#') continue;
            dist[ny][nx] = dist[p.first][p.second] + 1;
            que.push(make_pair(ny, nx));
        }
    }
    int ans = 0;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(s[i][j] == '#') ans++;
        }
    }
    ans = H * W - ans - dist[H - 1][W - 1];
    if(dist[H - 1][W - 1] == 0) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
    string s, t = "Yes";
    cin >> s;
    for(int i = 0; s[i] != '\0'; i++){
        if(i % 2 == 0){
            if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){
                t = "Yes";
            }
            else{
                t = "No";
                break;
            }
        }
        else{
            if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){
                t = "Yes";
            }
            else{
                t = "No";
                break;
            }
        }
    }
    cout << t << endl;

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int ch;
    ch = N % 1000;
    if (ch != 0) {
        cout << 1000 - ch << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    
}

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

int main()
{
	vector<int> v(3);
	int T;
	
	cin >> T;
	for(int t=0; t<T; t++)
	{
		cin >> v[0] >> v[1] >> v[2];
		std::sort(v.begin(), v.end());

		if(v[0] * v[0] + v[1] * v[1] == v[2] * v[2]) 
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

Measured memory_bytes: 0
/*
    Author - Param Kothari
    Ah shit, here we go again
*/
 
/* Ordered Set Implementaton:

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

using namespace __gnu_pbds;

typedef tree<
    int,
    null_type,
    less<int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
ordered_set;
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair 
 
typedef long long ll;
typedef long double ld;

void solve(){
    ll n, k;
    cin >> n >> k;
    ll r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    string res = "";
    map<char, char> pick;
    map<char, int> point;
    pick['s'] = 'r';
    pick['r'] = 'p';
    pick['p'] = 's';
    point['s'] = s;
    point['p'] = p;
    point['r'] = r;
    ll suma = 0;
    for(int i = 0; i < k; i++){
        res = res + pick[t[i]];
        suma += point[pick[t[i]]];
    }
    for(int i = k; i < n; i++){
        if(pick[t[i]] == res[i - k]){
            if(i + k < n){
                res += pick[pick[t[i + k]]];
            }
            else res += t[i];
        }
        else{
            res += pick[t[i]];
            suma += point[pick[t[i]]];
        }
    }
    cout << suma << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 812
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<int,int>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

/* --------------------------------------- */

ll n;
vector<ll> g[5050];
ll subsize[5050];
ll dp[5050][2][5050];
ll combine[5050];

ll dfs1(ll p, ll par) {
	ll ret = 1;
	REP(i, g[p].size()) if(g[p][i] != par) ret += dfs1(g[p][i], p);
	return subsize[p] = ret;
}

void dfs2(ll p, ll par) {
	if(par != -1 && g[p].size() == 1) {
		dp[p][0][1] = 1;
		return;
	}
	REP(i, g[p].size()) if(g[p][i] != par) dfs2(g[p][i], p);
	vector<vector<ll>> tmp(2, vector<ll>(n + 1, 0));
	ll child;
	if(g[p][0] != par) child = g[p][0];
	else child = g[p][1];
	REP(i, 2) REP(j, n + 1) {
		tmp[i][j + 1] += dp[child][i][j];
		tmp[i][j + 1] %= MOD;
		if(j % 2 == 0) {
			tmp[!i][1] += combine[j] * dp[child][i][j];
			tmp[!i][1] %= MOD;
		}
	}
	ll sumNode = subsize[child] + 1;
	REP(c, g[p].size()) {
		if(g[p][c] == child || g[p][c] == par) continue;
		child = g[p][c];
		vector<vector<ll>> ntmp(2, vector<ll>(n + 1, 0));
		REP(i, 2) REP(j, sumNode + 1) {
			REP(k, 2) REP(l, subsize[child] + 1) {
				ntmp[(i + k) % 2][j + l] += tmp[i][j] * dp[child][k][l];
				ntmp[(i + k) % 2][j + l] %= MOD;
				if(l % 2 == 0) {
					ntmp[!((i + k) % 2)][j] += combine[l] * ((tmp[i][j] * dp[child][k][l]) % MOD);
					ntmp[!((i + k) % 2)][j] %= MOD;
				}
			}
		}
		tmp = ntmp;
		sumNode += subsize[child];
	}
	REP(i,2) REP(j,n + 1) {
		dp[p][i][j] = tmp[i][j];
	}
	return;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	REP(i,n - 1) {
		ll x, y;
		cin >> x >> y;
		x--; y--;
		g[x].pb(y);
		g[y].pb(x);
	}
	combine[0] = 1;
	for(ll i = 2; i <= n; i += 2) {
		combine[i] = (i - 1) * combine[i - 2];
		combine[i] %= MOD;
	}
	dfs1(0, -1);
	dfs2(0, -1);
	ll comp = 0;
	for(ll i = 0; i < n; i += 2) {
		comp += combine[i] * (dp[0][1][i] - dp[0][0][i]);
		comp %= MOD;
	}
	ll ans = combine[n] - comp;
	cout << (ans % MOD + MOD) % MOD << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 396928
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int64_t N,K; cin>>N>>K;
    vector<pair<int,int>> Ope(N);
    rep(n,0,N){
        int a,b; cin>>a>>b;
        Ope.at(n)=make_pair(a,b);
    }

    map<int,int64_t> mp;
    for(auto o:Ope) mp[o.first]+=o.second;

    int64_t idx=0,ans;
    for(auto m:mp){
        idx+=m.second;
        if(idx>=K){
            ans=m.first;
            break;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    ll x;
    cin >> x;

    auto rem = (x - 1) % 11;
    auto ans = (x - 1) / 11 * 2 + 1;
    if (6 <= rem) {
        ans++;
    }

    cout << ans << "\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

int main()
{
	int a;
	cin >> a;
	if (a > 888)
	{
		cout << 999;
	}
	else if (a > 777)
	{
		cout << 888;
	}
	else if (a > 666)
	{
		cout << 777;
	}
	else if (a > 555)
	{
		cout << 666;
	}
	else if (a > 444)
	{
		cout << 555;
	}
	else if (a > 333)
	{
		cout << 444;
	}
	else if (a > 222)
	{
		cout << 333;
	}
	else if (a > 111)
	{
		cout << 222;
	}
	else
	{
		cout << 111;
	}
	return 0;
}

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

int main(){
  while(1) {
    int H, W;
    cin >> H >> W;
    if(H == 0 && W == 0) break;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

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

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

    vector <int> v;
    int n,t;
    int res = 0;

    cin >> n;

    for(int i=0;i<n;i++)
    {
    	cin >> t;
    	v.push_back(t);
    }

    int val = 1;

    for(int i=0;i<n;i++)
    {
    	if(v[i]==val)
    	{
    		val++;
    	}
    	else
    	{
    		res++;
    	}
    }

    if(val==1)
    {
    	res = -1;
    }

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

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep2(i,x,n) for(int i=x;i<n;++i)

int main()
{
    int n,m;
    cin >> n >> m;
    vector<vector<bool>> s(n);
    int psum = 0;
    int asum = 0;
    vector<bool> accepted(n, false);
    vector<int> penalty(n, 0);

    rep(i,m)
    {
        int pi;
        string si;
        cin >> pi >> si;
        pi--;
        if(accepted[pi]) continue;

        if(si == "AC")
        {
            accepted[pi] = true;
            asum++;
            psum += penalty[pi];
        }
        else
            penalty[pi]++;
    }

    cout << asum << " " << psum << endl;
    return 0;
}

Measured memory_bytes: 4608
import math
a,b=map(int,input().split())
x=[]
for i in range(1,1251):
    if math.floor(i*0.08)==a:
        if math.floor(i*0.1)==b:
            x.append(i)
if len(x)==0:
    print(-1)
else:
    print(min(x))

Measured memory_bytes: 9084
#include <iostream>
#include <bits/stdc++.h>
#define endl '\n'
#define MAXN 1000000000
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
using namespace std;


long long dp[101][101];
int s[101][101];
void order(int i,int j){
    int k;
    if(i==j) printf("A%d",i);
    else{
        k=s[i][j];
        printf("(");
        order(i,k);
        order(k+1,j);
        printf(")");
    }
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, n1; cin >> n; n1 = n;
    vi dim;
//    dim.push_back(0);
    int r, c;
    cin >> r >> c;
    dim.push_back(r);
    dim.push_back(c);
    n1--;
    while(n1--){
        cin >> r >> c;
        dim.push_back(c);
    }
    n++;
    for (int i = 0; i < n; ++i) {
        dp[i][i] = 0;
    }
    long long cost = 0;
//    n = dim.size() - 1;
    long long mincost = -MAXN;
    for (int len = 2; len < n; ++len) {
        for (int i = 1; i < n - len + 1; ++i) {
            int j = i + len - 1;
            dp[i][j] = MAXN;
            for (int k = i; k < j; ++k) {
                cost = dp[i][k] + dp[k + 1][j] + dim[i - 1] * dim[j] * dim[k];
                if(cost < dp[i][j]){
                    mincost = cost;
                    dp[i][j] = cost;
                    s[i][j] = k;
                }
            }
        }
    }
//    for (int l = 0; l <= n; ++l) {
//        for (int i = 0; i <= n; ++i) {
//            cout << dp[l][i] << " ";
//        }
//        cout << endl;
//    }
//    printf("Minimum Multiplication : %Ld\n",dp[1][n]);
//    printf("Order : ");
//    order(1,n);
//    printf("\n\n");
    cout << dp[1][n - 1] << endl;
//    cout << dp[2][n] << endl;
    return 0;
}


Measured memory_bytes: 3256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

K = INT()
A = LIST()

def f(N):
	left = N
	for a in A:
		left = left//a*a
	return left

l_N_max = 0
r_N_max = sum(A)-K+3
while l_N_max+1 < r_N_max:
	m = (l_N_max+r_N_max)//2
	if f(m) <= 2:
		l_N_max = m
	else:
		r_N_max = m

N_max = l_N_max

l_N_min = 0
r_N_min = sum(A)-K+3
while l_N_min+1 < r_N_min:
	m = (l_N_min+r_N_min)//2
	if f(m) < 2:
		l_N_min = m
	else:
		r_N_min = m
N_min = r_N_min

if N_min > N_max:
	print(-1)
else:
	print(N_min, N_max)


Measured memory_bytes: 21488
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



template<class T> struct Edge {
    int from, to;
    T cost;
    Edge(int f, int t, T c) : from(f), to(t), cost(c) {}
    friend bool operator < (const Edge &e1, const Edge &e2) {return e1.cost < e2.cost;}
    friend bool operator > (const Edge &e1, const Edge &e2) {return e1.cost > e2.cost;}
    friend ostream& operator << (ostream& s, const Edge<T>& E) {
        return s << E.from << "->" << E.to << '(' << E.cost << ')';
    }
};

const int MAX_V = 210000;
template<class T> struct Graph {
    int V;
    vector<Edge<T> > list[MAX_V];
    
    Graph(int n = 0) : V(n) {}
    void init(int n = 0) {V = n; for (int i = 0; i < MAX_V; ++i) list[i].clear();}
    inline vector<Edge<T> >& operator [] (int i) {return list[i];}
    
    void connect(int f, int t, T c) {
        list[f].push_back(Edge<T>(f,t,c));
        list[t].push_back(Edge<T>(t,f,c));
    }
    
    friend ostream& operator << (ostream& s, const Graph& G) {
        s << endl; for (int i = 0; i < G.V; ++i) {s << i << " : " << G.list[i] << endl;}return s;
    }
};

Graph<long long> G;



int N, Q, K;

long long dist[MAX_V];
void rec(int v) {
	//cout << v << ": " << dist[v] << endl;

	for (auto e : G[v]) {
		if (dist[e.to] != -1) continue;
		dist[e.to] = dist[v] + e.cost;
		rec(e.to);
	}
}


int main () {
	while (cin >> N) {
		G.init(N);
		for (int i = 0; i < N-1; ++i) {
			int a, b, c;
			cin >> a >> b >> c;
			--a, --b;
			G.connect(a, b, c);
		}
		cin >> Q >> K;
		--K;
		memset(dist, -1, sizeof(dist));
		dist[K] = 0;
		rec(K);

		for (int i = 0; i < Q; ++i) {
			int x, y;
			cin >> x >> y;
			--x, --y;
			cout << dist[x] + dist[y] << endl;
		}
		
	}
}

Measured memory_bytes: 16128
n = int( raw_input( ) )
dic = {}
for i in range( n ):
	cmd, word = raw_input( ).split( " " )
	if "insert" == cmd:
		dic[ word ] = True
	elif "find" == cmd:
		if word in dic:
			print( "yes" )
		else:
			print( "no" )

Measured memory_bytes: 62704
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;


//int main()
//{
//	int a, b, c;
//	cin >> a >> b >> c;
//	vector<int> a(n);
//	int max_index=0;
//	int max = 0;
//	int temp_max = 0;
//	rep(i, n) {
//		cin >> a[i];
//		
//		max += a[i];
//		if (i>=k-1) {
//			if (max > temp_max) {
//				max_index = i - k + 1;
//				temp_max = max;
//			}
//			max -= a[i - k + 1];
//		}
//	}
//	//sort(a.rbegin(), a.rend());
//	float sum = 0;
//	rep(i, k) {
//		sum += float(a[max_index+i] + 1) / 2;
//	}
//	cout << sum << endl;
//	return 0;
//}
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	string ans = "No";
	if (a == b && b == c) {

	}
	else if (a == b) {
		ans = "Yes";
	}
	else if (a == c) {
		ans = "Yes";
	}
	else if (b == c) {
		ans = "Yes";
	}

	////sort(a.rbegin(), a.rend());
	//float sum = 0;
	//rep(i, k) {
	//	sum += float(a[max_index + i] + 1) / 2;
	//}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, LL>;

int main()
{
    int n;
    vector<PII> v;
    multiset<int> s;
    cin >> n;
    for(int i = 1, x; i <= n; ++i)
    {
        cin >> x;
        v.push_back({x, i});
    }
    sort(v.begin(), v.end(), greater<PII>());
    s.insert(0); s.insert(0);
    s.insert(n + 1); s.insert(n + 1);
    LL ans = 0;
    for(auto i: v)
    {
        int num = i.first, p = i.second;
        auto it = s.lower_bound(p);
        int R2 = *(++it), R1 = *(--it);
        int L2 = *(--it), L1 = *(--it);
        // cout << num << ' ' << p << '\n';
        // cout << '(' << L1 << ',' << L2 << ')' << '(' << R1 << ',' << R2 << ')' << '\n';
        ans += num * 1LL * (R2 - R1) * (p - L2);
        // cout << ans << ' ';
        ans += num * 1LL * (R1 - p) * (L2 - L1);
        // cout << ans << '\n';
        s.insert(p);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 6512
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

A, B = map(int, input().split())
S = input()

if not('-' in S[:A]) and S[A]=='-' and not('-' in S[A+1:]):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
using namespace std;
int main() {
  const long N = 1000000;
  vector<bool> p(N, true); p[0] = p[1] = false;
  int i, j, n, a, c;
  for (i = 2; i * i < N; i++) {
    if (!p[i]) continue;
    for (j = i * i; j < N; j += i) p[j] = false;
  }
  while (cin >> n, n) {
    a = 0, c = 0;
    for (i = 0; a < n; i++) if (p[i]) { a++; c += i; }
    cout << c << endl;
  }
}

Measured memory_bytes: 1316
#include<iostream>

using namespace std;
int main ()
{
	int H,W,i,j;

	while(1)
	{
	cin >> H >> W;
	if(H == 0 && W == 0)break;
	for(i = 0;i < H;i++)
	{
		
		for(j = 0; j < W; j++)
		{
			if(i == 0 || i == H-1 || j == 0 || j == W-1)
			{
				cout << '#' ;
			}
			else
			{
				cout << '.' ;
			}
		}cout << endl;

	}cout << endl;
	}
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }

    int64_t sum = 0;
    int n_neg = 0;
    int mn = INT_MAX;
    for (int i = 0; i < N; i++)
    {
        sum += abs(A.at(i));
        mn = min(mn, abs(A.at(i)));
        if (A.at(i) < 0)
        {
            n_neg++;
        }
    }
    if (n_neg % 2 == 0)
    {
        cout << sum << endl;
    }
    else
    {
        cout << sum - 2 * mn << endl;
    }
}

Measured memory_bytes: 640
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i64,
        i: i64,
    }

    println!("{}", n+1-i);
}


Measured memory_bytes: 4352
#include <iostream>
        #include <cstdio>
        #include <cstring>
        #include <cmath>
        #include <vector>
        using namespace std;
        const int N=2e6;
        int n,rt1,dx=0,px;
        int d[N+10],deep[N+10];
        vector <int> edge[N+10];
        void Add(int u,int v) {
            edge[u].push_back(v);
            edge[v].push_back(u);
        }
        void Dfs1(int x,int fat) {
            deep[x]=dx;
            int cnt=0;
            for (int i=0;i<(int)edge[x].size();i++) {
                int kx=edge[x][i];
                if (kx==fat) continue;
                ++cnt;
                ++dx;
                Dfs1(kx,x);
                --dx;
            }
            if (cnt>=2&&deep[x]>=deep[px]) px=x;
        }
        void Dfs2(int x,int fat,bool vis) {
            if (x==px) vis=1;
            for (int i=0;i<(int)edge[x].size();i++) {
                int kx=edge[x][i];
                if (kx==fat) continue;
                Dfs2(kx,x,vis);
            }
            if (vis&&d[x]==1) rt1=x;
        }
        int Solve(int x,int fat) {
            int sum=0;
            int zero=0;
            for (int i=0;i<(int)edge[x].size();i++) {
                int kx=edge[x][i];
                if (kx==fat) continue;
                int nowx=Solve(kx,x);
                sum+=nowx;
                if (nowx==0) zero++;
            }
            if (zero>1) sum+=zero-1;
            return sum;
        }
        int main() {
            scanf("%d",&n);
            if (n==1) {
                printf("0\n");
                return 0;
            }
            if (n==2) {
                printf("1\n");
                return 0;
            }
            for (int i=1;i<n;i++) {
                int u,v;
                scanf("%d%d",&u,&v);
                u++;
                v++;
                Add(u,v);
                d[u]++;
                d[v]++;
            }
            int rt=1;
            for (int i=2;i<=n;i++)
                if (d[i]>=2) rt=i;
            Dfs1(rt,-1);
            Dfs2(rt,-1,0);
            int ans=Solve(rt1,-1)+1;
            printf("%d\n",ans);
            return 0;
        }

Measured memory_bytes: 60800
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcnt(x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mod 1000000007
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
void init() {
  int n, k, q;
  cin >> n >> k >> q;
  vi b(n, k);
  for (int i = 0; i < q; i++) {
    int p;
    cin >> p;
    --p;
    b[p]++;
  }
  for (auto &x : b)
    x -= q;
  for (auto x : b) {
    cout << ((x > 0) ? "Yes" : "No") << endl;
  }
}
int32_t main() {
  IOS;
  init();
  return 0;
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
using ll =long long ;
int main(){
    int n,p;
    cin >> n >> p;
    vector<int> a(n);
    int h=0;
    for(int i=0;i<n;i++){
        cin >> a.at(i);
        if(a.at(i)%2!=0)h++;
    }
    if(h!=0)cout << (ll)pow(2,n)/2 << endl;
    else{
        if(p==1)cout << 0 << endl;
        else cout << (ll)pow(2,n) << endl;
    }
    return 0;
}

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

int main() {
	int count = 0;
	int N;
	int D;
	int X;
	int A[1001];
	cin >> N >> D >> X;
	for (int i = 0; i < N; ++i) cin >> A[i];

	for (int j = 0; j < N; ++j) {
		int day = 1;
		while (day <= D) {
			count++;
			day = day + A[j];
		}
	}

	int chocolate = count + X;
	cout << chocolate << endl;
}

Measured memory_bytes: 256
import sys
import itertools

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def main():
    N,M,R = LI()
    rs = [int(x) -1 for x in sys.stdin.readline().split()]
    D = [[10**10]*N for _ in range(N)]
    for _ in range(M):
        A,B,C = LI()
        D[A-1][B-1] = C
        D[B-1][A-1] = C
    for i in range(N):
        D[i][i] = 0

    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])

    ans = 10**11
    for trs in itertools.permutations(rs):
        tans = 0
        for i in range(R-1):
            tans += D[trs[i]][trs[i+1]]
        ans = min(ans,tans)
    
    return(ans)

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 42588
#include <deque>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if (b%a == 0)cout << a + b;
	else cout << b - a;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int a,b,c,d,dis1,dis2,dis;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a>=1 || a<=100 || b>=1 || b<=100 || c>=1 || c<=100 )
    {
        if(d>=1 || d<=100)
        {
            dis1=abs(a-b);
            dis2=abs(b-c);
            dis=abs(a-c);
            if(dis<=d)
                printf("Yes\n");
            else if(1)
            {
                if(dis1<=d && dis2<=d)
                    printf("Yes\n");
                else
                    printf("No\n");
            }
        }
    }
    return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
using tpl = tuple<char, int>;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int A, B;
int main(){

    cin >> A >> B;
    if(B % A == 0){
        cout << A + B << endl;
    }
    else{
        cout << -A + B << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
	char ch=getchar();int f=0,x=1;
	while(ch<'0'||ch>'9'){if(ch=='-') x=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f*x;
}
int main()
{
	ll a,b,ans=0;
	cin>>a>>b;
	while(a<=b)
	{
		a<<=1;
		ans++;
	}
	cout<<ans;
}


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


int main(){
  int N;
  cin>>N;
  vector<int> c(N),s(N),f(N);
  for(int i=0;i<N-1;i++){
    cin>>c[i]>>s[i]>>f[i];
  }
  for(int i=0;i<N-1;i++){
    int present=0;

    for(int j=i;j<N-1;j++){
      if(present<s[j]) present=s[j]+c[j];
      else if(present%f[j]==0) present+=c[j];
      else present+=f[j]-(present%f[j])+c[j];
    }
    cout<<present<<endl;
  }
  cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;



namespace Test1 {

    class ClassMain {

        public static void Main(String[] args) {
            string line;

            while ((line = Console.ReadLine()) != null) {
                int n = int.Parse(line);
                if (n == 0) { break; }
                int[] ints = new int[n];
                for (int i = 0; i < n; i++) {
                    ints[i] = int.Parse(Console.ReadLine());
                }
                //Console.WriteLine(string.Join(",",ints));
                int cnt = 0;
                for (int i = 0; i < n - 1; i++) {
                    for (int j = 0; j < n - 1-i; j++) {
                        if (ints[j] > ints[j + 1]) {
                            int tmp = ints[j];
                            ints[j] = ints[j + 1];
                            ints[j + 1] = tmp;
                            cnt++;
                        }
                    }
                }
                Console.WriteLine(cnt);
            }
        }
    }

}

Measured memory_bytes: 5636
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;



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

	cin >> N;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		if (i) {
			if (v[i] && v[i - 1]) {
				ans++;
				v[i]--;
			}
		}
		ans += v[i] / 2;
		v[i] &= 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
N,W = map(int,input().split())
wv = [list(map(int,input().split())) for i in range(N)]
f_min = 0 
dp = [[f_min] * (W+1) for _ in range(N+1)]
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
def chmax(a,b):
    if a < b:
        return b
    else:
        return a
def main():
    # 初期条件

    for i in range(1,N+1):
        w,v = wv[i-1][0], wv[i-1][1]

        for sum_w in range(W+1):
            if sum_w - w >= 0:
                dp[i][sum_w] = chmax(dp[i][sum_w], dp[i-1][sum_w-w]+ v)
            
            dp[i][sum_w] = chmax(dp[i][sum_w],dp[i-1][sum_w])
    
    ans = 0
    for i in range(W+1):
        ans = chmax(ans,dp[N][i])
    print(ans)
            

            
 

if __name__ == "__main__":
    main()

Measured memory_bytes: 118640
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def main():
    n = int(sys.stdin.readline())
    txys = ((map(int, line.split())) for line in sys.stdin.readlines())
    pt, px, py = 0, 0, 0
    for t, x, y in txys:
        distleft =  t - pt - abs(x - px) - abs(y - py)
        if distleft < 0 or distleft % 2 == 1:
            print('No')
            break
        pt, px, py = t, x, y
    else:
        print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 10276
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  int p[N];
  REP(i,N)cin>>p[i];
  sort(p,p+N);
  int ans=0;
  REP(i,K)ans+=p[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3628