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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

using Pos = array<double, 2>;

double distance(Pos& a, Pos& b) {
    double dx = a[0] - b[0];
    double dy = a[1] - b[1];
    return sqrt(dx * dx + dy * dy);
}

void solve() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;

    double tm = H * 60.0 + M;  // 分
    double rotA = tm / 60.0 * 30.0 * M_PI / 180.0;
    double rotB = tm * 6.0 * M_PI / 180.0;

    Pos rA, rB;
    rA[0] = A * sin(rotA);
    rA[1] = A * cos(rotA);
    rB[0] = B * sin(rotB);
    rB[1] = B * cos(rotB);

    double ans = distance(rA, rB);

    cout << setprecision(20) << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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

struct Card
{
	/* data */
	char suit, value;
};

void bubble(struct Card A[], int N)
{
	/* data */
	for(int i=0; i<N; i++){
		for(int j=N-1; j >= i; j-- ){
			if(A[j].value < A[j-1].value){
				Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
			}
		}
	}
}

void selectionSort(struct Card A[], int N){
	for(int i=0; i < N; i++){
		int minj = i;
		for(int j = i; j < N; j++){
			if(A[j].value < A[minj].value) minj = j;
		}
		Card t = A[i]; A[i] = A[minj]; A[minj] = t;
	}
}

void print(struct Card A[], int N){
	for(int i = 0; i < N; i++){
		if(i>0) cout << " ";
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N){
	for(int i = 0; i < N; i++){
		if(C1[i].suit != C2[i].suit) return false;
	}
	return true;
}

int main(){
	Card C1[100], C2[100];
	int N;
	char ch;

	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> C1[i].suit >> C1[i].value;
	}
	for(int i=0; i<N; i++) C2[i] = C1[i];
	bubble(C1, N);
	selectionSort(C2, N);

	print(C1, N);
	cout << "Stable" << endl;
	print(C2, N);
	if(isStable(C1, C2, N)){
		cout << "Stable" << endl;
	}else{
		cout << "Not stable" << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
using namespace std;
int n,f[100005][3],a[100005][3];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for (int i=1;i<=n;i++)
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    for (int i=0;i<3;i++)
        f[1][i]=a[1][i];
    for (int i=1;i<n;i++)
    {
        f[i+1][0]=max(f[i][1],f[i][2])+a[i+1][0];
        f[i+1][1]=max(f[i][0],f[i][2])+a[i+1][1];
        f[i+1][2]=max(f[i][1],f[i][0])+a[i+1][2];
    }
    cout << max(f[n][0],max(f[n][1],f[n][2]));
    return 0;
}

Measured memory_bytes: 5920
/*input
15
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 100005;

int main()
{
  ifalse;
  int n;
  cin >> n;
  ll ans = 0;
  for(int i = 1; i <= n; i ++) {
    if(i % 5 != 0 and i % 3 != 0) {
      ans += i;
    }
  }
  cout << ans, nl;
  return 0;
}

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

int N, W, w[100], v[100];
int64_t DP[101][100001];

int main(void){
    cin >> N >> W;
    for(int i=0;i<N;i++)    cin >> w[i] >> v[i];
    
    for(int i=0;i<=W;i++)   DP[0][i] = 0;
    
    for(int i=0;i<N;i++){
        for(int j=0;j<=W;j++){
            if(w[i] <= j)   DP[i+1][j] = max(DP[i][j], DP[i][j-w[i]] + v[i]);
            else            DP[i+1][j] = DP[i][j];
        }
    }
    int64_t ans = 0;
    for(int i=0;i<=W;i++)   ans = max(ans, DP[N][i]);
    
    cout << ans << endl;
}

Measured memory_bytes: 79104
n = int(input())
s = input()
a = [0] * (n + 1)

for i, j in enumerate(s):
    if j == "W":
        a[i + 1] = a[i] + 1
    else:
        a[i + 1] = a[i]

ans = n
zz = n - a[n]
for i in range(1, n + 1):
    b = a[i - 1] + zz - (i - a[i])
    ans = min(b, ans)
print(ans)


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

int main(){
    int n;
    cin >> n;
    vector<int> v(100000, 0);
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        if(a > 100000){cnt++;}
        else{v[a-1]++;}
    }

    for(int i = 0; i < 100000; i++){
        if(v[i] > i + 1){cnt += v[i] - i - 1;}
        else if(v[i] < i + 1){cnt += v[i];}
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

int foc[202000];

int popcount(int x) {
    int ret = 0;
    while(x) {
        if(x&1) ++ret;
        x >>= 1;
    }
    return ret;
}

void foo() {
    foc[0] = 1;
    rip(i,202000,1) {
        foc[i] = foc[i%popcount(i)] + 1;
    }
}

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int k = 0;
    rip(i,n,0) if(s[i] == '1') ++k;
    if(k == 0) {
        rip(i,n,0) {
            printf("1\n");
        }
        return 0;
    }
    else if(k == 1) {
        rip(i,n,0) {
            if(s[i] == '1') printf("0\n");
            else if(i == n-1) {
                printf("2\n");
            }
            else {
                printf("%d\n", (s[n-1] == '1')?2:1);
            }
        }
        return 0;
    }
    foo();
    int da[2] = {0, 0};
    rip(i,n,0) {
        da[0] *= 2;
        da[1] *= 2;
        if(s[i] == '1') {
            da[0] += 1;
            da[1] += 1;
        }
        da[0] %= k+1;
        da[1] %= k-1;
    }
    int now[2] = {1, 1};
    vector<int> ans(n);
    rip(i,n,0) {
        if(s[n-i-1] == '1') {
            ans[n-i-1] = (da[1] - now[1] + (k-1)*2)%(k-1);
        }
        else {
            ans[n-i-1] = (da[0] + now[0])%(k+1);
        }
        now[0] *= 2;
        now[1] *= 2;
        now[0] %= k+1;
        now[1] %= k-1;
    }
    rip(i,n,0) ans[i] = foc[ans[i]];
    rip(i,n,0) printf("%d\n", ans[i]);
}

Measured memory_bytes: 5244
#include <bits/stdc++.h>
using namespace std;
bool fin;
int main(){
  int n,ans;
  cin>>n;
  vector<pair<int,int> >v(n);
  for(int i=0;i<n;++i){cin>>v[i].first;}
  for(int i=0;i<n;++i){cin>>v[i].second;}
  
  sort(v.begin(),v.end());
  if(v[0].first==1){
    cout<<0<<endl;
    return 0;
  }
  ans=v[0].second;
  for(int i=0;i<n;++i){
    if(v[i].first==1){
      ans+=v[i].second;
      fin=1;
      break;
    }
  }
  if(fin){cout<<ans<<endl;}
  else{cout<<0<<endl;}
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;


ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}

int main()
{
    int x;
    cin>>x;
    int i=0;
    while(is_prime(x+i)!=true)
    i++;
    cout<<x+i;
}

Measured memory_bytes: 256
from collections import Counter
from math import factorial
n, m = map(int, input().split())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
c = Counter(prime_factorize(m)).values()
def combinations(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))
ans = 1
mod = 10**9 + 7
for i in c:
  ans *= combinations(i+n-1, i)
  ans %= mod
print(ans)

Measured memory_bytes: 114524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N, M; cin >> N >> M;
 
	vector<vector<int>> v(M);
 
	for (int i = 0; i < M; ++i) {
		int k; cin >> k;
		v[i].resize(k);
		for (int j = 0; j < k; ++j) {
			cin >> v[i][j];
			--v[i][j];
		}
	}
 
	vector<int> p(M);
	for (int i = 0; i < M; ++i) cin >> p[i];
 
	int ans = 0;
	for (int bit = 0; bit < (1 << N); bit++) {  // bit<(1<<n)でbitにはN桁以下の2進数が入る
                                                // bitはスイッチの入れ方
		bool flg = true;
		for (int j = 0; j < M; ++j) {
			int c = 0;
			for (int id : v[j]) {
				if ((bit >> id) & 1) { // onになっているスイッチのカウント
					c++;
				}
			}
			c %= 2;
			if (c != p[j]) { // 点灯できないとき ansにはカウントしない
				flg = false;
			}
		}
		if (flg) {  // 全部付けられたときカウントする
		    ans++;
		}
	}
 
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int solve(int n) {
  int ret{};
  for (int i = 1; i <= n; i += 2) {
    int cnt{};
    for (int k = 1; k <= i; ++k) {
      if (i % k == 0)
        ++cnt;
    }
    if (cnt == 8)
      ++ret;
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  cout << solve(n) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n;
  string s;
  cin >> n >> s;
  
  int ans = 0;
  // 000 ~ 999
  rep(i,1000) {
    int c[3] = {i/100, (i/10)%10, i%10};
    int f = 0;
    rep(j,n) {
      if (s[j] == ('0' + c[f])) f++;
      if (f == 3) break;
    }
    if (f == 3) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


//===

const ll mod = static_cast<ll>(1e9 + 7);



int main() {
	int N;
	cin >> N;
	cout << 180 * (N - 2) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	long long x;
	cin >> x;
	long long a = x % 11;

	long long ans = 2*(x/11);
	if (a > 6)
		ans += 2;
	else if(a!=0)
		ans +=1;

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl

namespace atcoder {
	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int H, W;
	cin >> H >> W;
	vector<string> v(H);
	vector<int> black, white;
	for (int i = 0; i < H; i++) {
		cin >> v[i];
	}
	UnionFind uni(H*W);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (v[i][j] == '#') {
				if (i > 0) {
					if (v[i - 1][j] == '.') {
						uni.unite(i*W + j, (i - 1)*W + j);
					}
				}
				if (i < H - 1) {
					if (v[i + 1][j] == '.') {
						uni.unite(i*W + j, (i + 1)*W + j);
					}
				}
				if (j > 0) {
					if (v[i][j - 1] == '.') {
						uni.unite(i*W + j, i*W + j - 1);
					}
				}
				if (j < W - 1) {
					if (v[i][j + 1] == '.') {
						uni.unite(i*W + j, i*W + j + 1);
					}
				}
			}
		}
	}
	lli ans = 0;
	map<int, lli>b, w;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (v[i][j] == '#') {
				b[uni.root(i*W + j)]++;
			}
			else {
				w[uni.root(i*W + j)]++;
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			ans += b[i * W + j] * w[i * W + j];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 21120
#include <bits/stdc++.h>
typedef long long L;
using namespace std;
 
#define N 100005
#define U [N]={}
map<L,L> path[N];
L par U,dep U,siz U,hev U,cst U,add U,pos U,hl_par U,bit U,
k,n,q,a,b,c,cnt,i,p,r,ret;
void dfs(L a){
    siz[a]=1;
    for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){
        L d=I->first;
        if(d==par[a]) continue;
        par[d]=a;
        dep[d]=dep[a]+1;
        cst[d]=I->second;
        dfs(d);
        siz[a]+=siz[d];
        if(!hev[a] || siz[hev[a]]<siz[d])
            hev[a]=d;
    }
}
   
L edgecost(L a){
    L ret=add[a]+add[par[a]]+cst[a];
    return ret%k ? ret : 0;
}
   
L sum(L i){
    L ret=0;
    while(i){
        ret+=bit[i];
        i-=i&-i;
    }
    return ret;
}
void S(L i, L x){
    x-=sum(i+1)-sum(i);
    i++;
    while(i<N){
        bit[i]+=x;
        i+=i&-i;
    }
}
 
main(){
    cin >> n >> k;
    for(i=0; i<n-1; i++){
        cin >> a >> b >> c;
        path[a][b]=path[b][a]=c;
    }
    dfs(0);
   
    for(i=0; i<n; i++){
        if(i && hev[par[i]]==i) continue;
        L j=i;
        do{
            pos[j]=cnt++;
            hl_par[j]=i;
        }while(j=hev[j]);
    }
    
    for(i=0; i<n; i++)
        S(pos[i], edgecost(hev[i]));
    
    cin >> q;
    for(i=0; i<q; i++){
        string s;
        cin>>s>>a>>b;
        if(s[0]=='a'){
            add[a]+=b;
            S(pos[a], edgecost(hev[a]));
            if(a) S(pos[a]-1, edgecost(a));
        }else{
            for(ret=0;p=hl_par[a],r=hl_par[b],p-r;a=par[p])
                dep[p]<dep[r]?swap(p,r),swap(a,b),0:0,
                ret+=sum(pos[a])-sum(pos[p])+edgecost(p);
            
            cout<<ret+abs(sum(pos[a])-sum(pos[b]))<<endl;
        }
    }
}

Measured memory_bytes: 31892
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define ld long double
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ppb pop_back
#define nuenxfiu ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define TT int testcases;cin>>testcases;while(testcases--)
#define mk make_pair
#define MAX ((int)2e9+17)
#define mod ((int)1e9+7)
#define MOD 1000003
//int fact[1000007]={0};
#define N (int)1e6+10
int fpow(int n, int k, int p = mod) {int r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
using namespace std;


void solve()
{
	int n,k;
	cin>>n>>k;
	
	int a[n];
	
	for(int i=0;i<n;i++)
	cin>>a[i];
	
	for(int i=k;i<n;i++)
	{
		if(a[i]<=a[i-k])
		cout<<"No"<<endl;
		else
		cout<<"Yes"<<endl;
	}
	
	
}
signed main()
{
    
	nuenxfiu
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	//TT
	solve();
     return 0;
}

Measured memory_bytes: 5144
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int64_t const INF = 1e18;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int64_t> A(N);
  int64_t S = 0;
  for(int i = 0; i < 3; ++i) std::cin >> A[i];
  for(int i = 3; i < N; ++i) { std::cin >> A[i]; S += A[i]; }
  int64_t P[4] = { A[0], A[1], A[2], S }, ans = INF;
  int j = 1, l = 3;
  for(int k = 2; k < N-1; ++k) {
    while(j < k-1 && std::abs(P[0]-P[1]) > std::abs(P[0]+A[j]-(P[1]-A[j]))) {
      P[0] += A[j];
      P[1] -= A[j];
      ++j;
    }
    while(l < N-1 && std::abs(P[2]-P[3]) > std::abs(P[2]+A[l]-(P[3]-A[l]))) {
      P[2] += A[l];
      P[3] -= A[l];
      ++l;
    }
    ans = std::min(ans, *std::max_element(P, P+4) - *std::min_element(P, P+4));
    P[1] += A[k];
    P[2] -= A[k];
  }
  fin(ans);
  return 0;
}


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

int a[100000];

int main(void){
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  long long ans = 0;
  mp[0] = 1;
  int s = 0;
  while (n--){
    int x;
    cin >> x;
    s = (s + x) % m;
    ans += mp[s];
    mp[s]++;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3200
use std::io;


fn read_int() -> i64 {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf);
    let trlen = buf.trim_right().len();
    buf.truncate(trlen);
    if let Ok(v) = buf.parse::<i64>() {
        v
    } else {
        panic!("Failed to read integer")
    }
}


fn main() {
    let n = read_int() as usize;
    let mut coll = vec![0; n];

    for i in 0..n {
        coll[i] = read_int();
    }
    
    let mut c: usize = 0;
    let mut ans = 0;

    while c < n {
        if coll[c] == 0 {
            c += 1; continue;
        }
        let mut tmp = 0;
        while c < n && coll[c] != 0 {
            tmp += coll[c];
            c += 1;
        }

        ans += tmp / 2;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    string s;
    cin>>s;
    int ansa=0;
    //最初塗り替える
    ansa++;
    char c=s[0];
    for(int i=1;i<s.size();i++){
        if(i%2==0){
            if(s[i]==c)ansa++;
        }else{
            if(s[i]!=c)ansa++;
        }
    }
    int ansb=0;
    //最初塗り替えない
    for(int i=1;i<s.size();i++) {
        if(i%2==0){
            if(s[i]!=s[0])ansb++;
        }else{
            if(s[i]==s[0])ansb++;
        }

    }

    cout<<min(ansb,ansa)<<endl;


    return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int ans=0;
    int n;
    for (int i = 0; i < 5; i++)
    {
        cin>>n;
        if(n==0)
        {
            ans=i+1;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl
#define MOD 1000000007

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

  ll K; cin>>K;

  ll cntRun = 0;
  ll res = 1;
  while(true) {
    // 数値の各桁の数字をそれぞれ格納した配列arr
    // 1234 -> arr = {1,2,3,4,0,0,0,0,0,0}
    ll arr[10] = {0};
    ll num = res;
    ll len = to_string(res).size();
    rep(j,len) {arr[len-(j+1)] = num%10; num/=10;}

    // ルンルンであるか判定
    bool isRun = true;
    rep(j,len-1) {
      // ルンルンでない場合
      if(abs(arr[j]-arr[j+1]) >= 2) {
        if(arr[j] > arr[j+1]) {       // ex) 12045 -> 12100
          ++arr[j+1];
          reps(k,j+2,len)arr[k]=0;
        }
        else if(arr[j] < arr[j+1]) {  // ex) 12645 -> 13000
          ++arr[j];
          reps(k,j+1,len)arr[k]=0;
        }
        isRun = false;
        break;
      }
    }

    // resの更新
    if(isRun) {
      if(++cntRun==K){cout<<res<<endl; return 0;}
      else ++res;
    }
    else {
      // 配列を数値に戻してresに代入
      res = 0;
      rep(j, len) res += arr[j] * pow(10,len-(j+1));
    }
  }

  return 0;
}


Measured memory_bytes: 512
def convertList(strList, c):
    time = 0
    tmpList = list(strList)
    while tmpList.count(c) != len(tmpList):
        newList = []
        for i in range(len(tmpList[:])-1):
            newList.append(c if (tmpList[i] == c or tmpList[i+1] == c) else tmpList[i])
        tmpList = list(newList)
        time += 1
    return time

S = input()
strList = list(S)
strSet = set(strList)
minTime = 1000000 
for c in strSet:
    time = convertList(strList, c)
    if minTime > time:
        minTime = time
print(minTime)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define FU(i,a,b) for(register int i = a ; i <= b ; ++i)
#define FD(i,a,b) for(register int i = a ; i >= b ; --i)
#define set_max(a) memset(a,0x3f,sizeof a)
#define set_min(a) memset(a,~0x3f,sizeof a)
#define clear(a) memset(a,0,sizeof a)

using namespace std;

template<typename T>inline void chkmax(T & a,T b){ if(a < b) a = b ; }
template<typename T>inline void chkmin(T & a,T b){ if(a > b) a = b ; }

template<typename T>
inline T read()
{
	int res = 0 , flag = 1 ;
	char ch = getchar();
	while(!isdigit(ch))
	{
		if(ch == '-') flag = -1;
		ch = getchar();
	}
	while(isdigit(ch))
	{
		res = (res << 3) + (res << 1) + ch - '0';
		ch = getchar();
	}
	return res * flag;
}

template<typename T>
inline void write(T x)
{
	if(x/10) write(x/10);
	putchar(x%10+'0');
}

const int INF=0x3f3f3f3f;
const int N=4e1;
int n,m,hx,hy;
int ice[N+5][N+5],dp[N+5][N+5][N+5][N+5];

inline void Input()
{
	n = read<int>(); m = read<int>();

	char ch;
	for(register int i = 1 ; i <= n ; ++i)
	 for(register int j = 1 ; j <= m ; ++j)
	 {
		cin >> ch;
		ice[i][j] = ice[i-1][j] + ice[i][j-1] -ice[i-1][j-1] + (ch == '#');
		if(ch == 'P') { hx = i ; hy = j ; }
	 }
}

inline int thick(int dx,int dy,int rx,int ry)
{
//	if(dx > rx || dy > ry) return 0;
	return ice[rx][ry] - ice[rx][dy-1] - ice[dx-1][ry] + ice[dx-1][dy-1];
}

inline int MIN(int a,int b,int c,int d)
{
	return min(min(a,b),min(c,d));
}

inline void Solve()
{
	int ans = INF;
	set_max(dp);
	dp[1][1][n][m] = 0;
	for(register int i = 1 ; i <= hx ; ++i)
	 for(register int j = 1 ; j <= hy ; ++j)
	  for(register int k = n ; k >= hx ; --k)
	   for(register int p = m ; p >= hy ; --p)
	   {
			chkmin(ans , dp[i][j][k][p] + MIN(thick(i,j,hx,hy),thick(hx,hy,k,p),thick(hx,j,k,hy),thick(i,hy,hx,p)));
			for(register int s = i ; s <= k ; ++s)
			 for(register int t = j ; t <= p ; ++t)
			 {
				 if(s >= hx && t >= hy) chkmin(dp[i][j][s][t],dp[i][j][k][p] + thick(s+1,j,k,t) + thick(i,t+1,s,p));
				 if(s <= hx && t <= hy) chkmin(dp[s][t][k][p],dp[i][j][k][p] + thick(s,j,k,t-1) + thick(i,t,s-1,p));
				 if(s >= hx && t <= hy) chkmin(dp[i][t][s][p],dp[i][j][k][p] + thick(i,j,s,t-1) + thick(s+1,t,k,p));
				 if(s <= hx && t >= hy) chkmin(dp[s][j][k][t],dp[i][j][k][p] + thick(i,j,s-1,t) + thick(s,t+1,k,p));
			 }
	   }

	write(ans); putchar('\n');
}

inline void File()
{
	freopen("haner.in","r",stdin);
	freopen("haner.out","w",stdout);
}

int main()
{
	//File();

	Input();
	Solve();

	return 0;
}


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

const int N = 100005;
const int E = 1000000;
const int inf = 2139062143;

struct edge {
	int u, v, len, id;
}e[N];
int chosen[E];
int pre[N], inwei[N], innum[N], id[N], vis[N];
int inc[E], decr[E], pos;

inline int mst(int n, int m, int root = 1) {
	memset(inc,0,sizeof(inc));
	memset(decr,0,sizeof(decr));
	memset(chosen,0,sizeof(chosen));
	int ans = 0, eg = m;
	pos = m;
	while (true) {
		memset(inwei, 127, sizeof(int) * (n + 2));
		memset(id, 0, sizeof(int) * (n + 2));
		memset(vis, 0, sizeof(int) * (n + 2));
		for (int i = 1; i <= m; i++)
			if (e[i].len < inwei[e[i].v]) {
				inwei[e[i].v] = e[i].len;
				pre[e[i].v] = e[i].u;
				innum[e[i].v] = e[i].id;
			}
		inwei[root] = 0;
		for (int i = 1; i <= n; i++)
			if (inwei[i] == inf) return -1;
		int tot = 0;
		for (int i = 1; i <= n; i++) {
			ans += inwei[i];
			if (i != root) chosen[innum[i]]++;
			int j = i;
			while (vis[j] != i && j != root && !id[j])
				vis[j] = i, j = pre[j];
			if (j != root && !id[j]) {
				id[j] = ++tot;
				for (int k = pre[j]; k != j; k = pre[k]) id[k] = tot;
			}
		}
		if (!tot) break;
		for (int i = 1; i <= n; i++)
			if (!id[i]) id[i] = ++tot;
		n = tot;
		for (int i = 1; i <= m; i++) {
			int v = e[i].v;
			e[i].v = id[e[i].v];
			e[i].u = id[e[i].u];
			if (e[i].v != e[i].u) {
				e[i].len -= inwei[v];
				pos++;
				inc[pos] = e[i].id;
				decr[pos] = innum[v];
				e[i].id = pos;
			}
			else swap(e[i--], e[m--]);
		}
		root = id[root];
	}
	while (pos > eg) {
		if (chosen[pos] > 0) {
			chosen[inc[pos]]++;
			chosen[decr[pos]]--;
		}
		pos--;
	}
	return ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int casos = 1;
//	cin >> casos;
	for (int cas = 1; cas <= casos; ++cas) {
	//	cout << "Case #" << cas << ": ";
		int n, m, r;
		cin >> n >> m >> r;
		for (int i = 1; i <= m; ++i) {
			e[i].id = i;
			cin >> e[i].u >> e[i].v >> e[i].len;
			++e[i].u;
			++e[i].v;
		}
		int res = mst(n,m, r+1);
		if (res == -1) cout << "Possums!\n";
		else cout << res << '\n';
	}
}



Measured memory_bytes: 14992
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
#define PI 3.14159265359
typedef long long ll;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}

//素数判定 O(√n)
bool is_prime(int64_t n){
  for(int64_t i = 2; i*i<=n; i++){
    if(n%i==0) return false;
  }
  return n!=1;
}

//約数の列挙 O(√n)
vector<int64_t> dividor(int64_t n){
  vector<int64_t> res;
  for(int64_t i=1; i*i<=n; i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(i);
    }
  }
  return res;
}

//素因数分解 O(√n)
map<int64_t, int64_t> prime_factor(int64_t n){
  map<int64_t, int64_t> res;
  for(int64_t i=2; i*i<=n; i++){
    while(n%i==0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){ 
  int x;
  cin >> x;
  if(x==0) cout << 1 << endl;
  else cout << 0 << endl;
}




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

int main(){
  long N,K;cin>>N>>K;
  vector<long> H(N);
  for(int i=0;i<N;i++) cin>>H.at(i);
  sort(H.begin(),H.end());
  long ans=0;
  for(int i=0;i<N-K;i++) ans+=H.at(i);
  cout<<ans<<endl;
}

Measured memory_bytes: 4748
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		int[][] a = new int[n][n];
		String[] str; 
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < n; ++j){
				a[i][j] = Integer.MAX_VALUE;
			}
			str = br.readLine().split(" ");
			int u = Integer.parseInt(str[0]);
			int k = Integer.parseInt(str[1]);
			for(int j = 0; j < k; ++j) {
				int v1 = Integer.parseInt(str[2 + j * 2    ]);
				int c1 = Integer.parseInt(str[2 + j * 2 + 1]);
				a[u][v1] = c1;
			}
		}

		int[] d = new int[n];
		HashSet<Integer> t = new HashSet<Integer>(n);
		for(int i = 0; i < n; i++){
			d[i] = a[0][i];
			t.add(i);
		}
		
		int[] p = new int[n];
		int u = 0;
		p[u] = 0; // first node
		d[p[u]] = 0; // cost
		while(!t.isEmpty()){
			t.remove(p[u]);
			int min = Integer.MAX_VALUE;
			for(int node : t){
				
				if(d[p[u]] + a[p[u]][node] > 0 && d[p[u]] + a[p[u]][node] < d[node]){
					d[node] = d[p[u]] + a[p[u]][node];
				}
				if(d[node] < min){
					min = d[node];
					p[u+1] = node;
				}
			}
			u += 1;
		}
		
		StringBuffer sb = new StringBuffer();
		for(int i = 0; i < n; i++){
			sb.append(i + " " + d[i] + "\n");
		}
		System.out.print(sb);
	}

}

Measured memory_bytes: 554232
/*input

*/
// https://atcoder.jp/contests/arc099/tasks/arc099_b
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define bits(x,i) ((x >> i) & 1)
#define mid ((l+r)/2)
#define ll long long
#define pr pair<int,int>
using namespace std;
int k;
ll S(ll n){
	string s = to_string(n);
	int ans = 0;
	for(auto c : s) ans += c - '0';
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> k;
	ll cur = 1, add = 1;
	cout << 1 << '\n';
	for(int i=2;i<=k;++i){
		ll nxt = cur + add;
		ll nxt2 = nxt + add;
		if (nxt*S(nxt2) > nxt2*S(nxt)) { // nxt/S(nxt) > nxt2/S(nxt2) --> change to the next digit. 
			add *= 10;
			nxt = cur + add;
		}
		cur = nxt;
		// cur = nxt;
		cout << cur << '\n';
	}
}

Measured memory_bytes: 3704
#include <iostream>
using namespace std;
int w,h;
int mp[20][20],memo[20][20];
int saiki(int x,int y){
  if(y >= h-1) return 1;
  for(int i=-1;i<=1;i++) {
    int nx = x+i, ny = y+1;
    if(nx==x && mp[ny][nx] == 2)while(mp[ny][nx] == 2) ny+=2;
    if(nx <0|| nx >= w ||mp[ny][nx] != 0) continue;
    if(memo[ny][nx]==0) memo[y][x]+=saiki(nx,ny);
    else memo[y][x] += memo[ny][nx];
  }
  if(memo[y][x]==0) mp[y][x] = 1;
  return memo[y][x];
}
int main() {
  while(1) {
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    for(int i=0;i<=19;i++)
      for(int j=0;j<=19;j++)memo[i][j] = mp[i][j] = 0;
    
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin >> mp[i][j];
   
    int cnt = 0;  
    for(int i=0;i<w;i++)
      if(mp[0][i] !=1)cnt+=saiki(i,0);
    cout << cnt <<endl;
  }
  return 0;
}

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

int main(){
  int N;
  cin>>N;
  long long A[N];
  int cnt=0;
  int ODN=0;
  int EN=0;
 
  for (int i=0;i<N;i++){
    cin>>A[i];
    if(A[i]%2==0){
      EN++;
    }
    else ODN++;
  }
   //cout<<ODN<<" "<<EN<<endl;
  if((ODN==0)&&(EN==2)){
    cout<<"YES"<<endl;
    return 0;
  }
  if((ODN==1)&&(EN==1)){
    cout<<"NO"<<endl;
    return 0;
  }
  if((ODN==2)&&(EN==0)){
    cout<<"YES"<<endl;
    return 0;
  }    
 if((ODN%2==1)&&((EN+(ODN/2))%2==1)){
    cout<<"NO"<<endl;
    return 0;
  } 
  cout<<"YES"<<endl;
  
  return 0;
}


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

using namespace std;
int a[3][3];
int b[105];
bool k[3][3];
bool check(){
	for(int i=0;i<3;i++){
		if(k[i][0]==1&&k[i][1]==1&&k[i][2]==1)return 1;
	}
	for(int i=0;i<3;i++){
		if(k[0][i]==1&&k[1][i]==1&&k[2][i]==1)return 1;
	}
	if(k[0][0]==1&&k[1][1]==1&&k[2][2]==1)return 1;
	if(k[0][2]==1&&k[1][1]==1&&k[2][0]==1)return 1;
return 0; 
}
int main(){
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>b[i];
		for(int j=0;j<3;j++){
			for(int l=0;l<3;l++){
				if(b[i]==a[j][l]){
					k[j][l]=1;
				}
			}
		}
	}
	/*for(int i=0;i<3;i++){
		for(int j=0;j<3;j++)cout<<k[i][j]<<" ";
		cout<<endl;
	}*/
	if(check())cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::{input, marker::Usize1};
fn main() {
    let info = Info::read();
    input!(ans: [Usize1; info.day]);
    for i in 0..info.day {
        println!("{}", info.score(&ans[..=i]));
    }
}
struct Info {
    day: usize,
    dec: Vec<i32>,
    inc: Vec<Vec<i32>>,
}
impl Info {
    fn read() -> Self {
        input!(d: usize, c: [i32; 26], s: [[i32; 26]; d]);
        Self {
            day: d,
            dec: c,
            inc: s,
        }
    }
    fn score(&self, ans: &[usize]) -> i32 {
        let mut last = vec![-1; 26];
        ans.iter().enumerate().fold(0, |score, (date, &contest)| {
            last[contest] = date as i32;
            (0..26).fold(score + self.inc[date][contest], |score, contest| {
                score - self.dec[contest] * (date as i32 - last[contest])
            })
        })
    }
}


Measured memory_bytes: 2296
#include <stdio.h>

int main(void)
{
    int n, m;
    int a[100][100] = {0};
    int b[100] = {0};
    int ans[100] = {0};
    int i, j;

    scanf("%d %d", &n, &m);
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    for (i = 0; i < m; i++) {
        scanf("%d", &b[i]);
    }

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

Measured memory_bytes: 648
#include<bits/stdc++.h>
using namespace std;
string S;
int state[200001][26][27];
int main(void){
    cin >> S;
    memset(state, -1, sizeof(state));
    state[0][S[0]-'a'][26] = 1;
    if (S.size()>1){
        state[1][S[0]-'a'][S[1]-'a'] = 1;
    }
    for(int i=0;i<S.size()-1;i++){
        for(int j=0;j<26;j++){
            for(int k=0;k<27;k++){
                if (state[i][j][k]==-1) continue;
                // Grow by 1
                if (k==26){ // last is 1
                    // grow by 1
                    if(S.size()>i+1 && S[i+1]-'a'!=j){
                        state[i+1][S[i+1]-'a'][26] 
                        = max(state[i+1][S[i+1]-'a'][26], state[i][j][k]+1);
                    }
                    // grow by 2
                    if(S.size()>i+2) {
                        state[i+2][S[i+1]-'a'][S[i+2]-'a']
                        = max(state[i+2][S[i+1]-'a'][S[i+2]-'a'], state[i][j][k]+1);
                    }
                }else{ // last is 2
                    // grow by 1
                    if(S.size()>i+1){
                        state[i+1][S[i+1]-'a'][26] 
                        = max(state[i+1][S[i+1]-'a'][26], state[i][j][k]+1);
                    }
                    // grow by 2
                    if(S.size()>i+2
                    && (S[i+1]-'a'!=j || S[i+2]-'a'!=k)) {
                        state[i+2][S[i+1]-'a'][S[i+2]-'a']
                        = max(state[i+2][S[i+1]-'a'][S[i+2]-'a'], state[i][j][k]+1);
                    }
                }
            }
        }
    }
    int ans=1;
    for(int j=0;j<26;j++){
        for(int k=0;k<27;k++){
            ans = max(ans, state[S.size()-1][j][k]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 548996
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll n;
    cin >> n;
    ll ans = 0;

    if(n == 1){
      print(0);
      return 0;
    }
    if(n == 2){
      print(1);
      return 0;
    }
    if(n % 2 != 0){
      ll hf = n / 2 + 1;
      ans += (n % hf);
      REP(i, hf, n){
        ans += i;
      }
      REP(i, 1, n / 2){
        ans += i;
      }
    }
    else{
      REP(i,1,n){
        ans += i;
      }
    }
    print(ans);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
vi G[200005];
vl ans(200005,0), cnt(200005,0);
vi check(200005,0);
void dfs(int u, ll c){
  if(check[u])return;
  c+=cnt[u];
  ans[u]+=c;
  check[u]=1;
  for(auto v:G[u]){
    dfs(v,c);
  }
  return;
}

int main() {
  int n,q;
  cin >> n >> q;
  
  rep(i,n-1){
    int a, b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  rep(i,q){
    int p,x;
    cin >> p >> x;
    p--;
    cnt[p]+=x;
  }
  dfs(0,0);
  rep(i,n){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
  return 0;
}

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

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

    rep(i, 4)
    {
        string order;

        if (i == 0) order = "SS";
        else if (i == 1) order = "SW";
        else if (i == 2) order = "WW";
        else if (i == 3) order = "WS";

        rep(j, n)
        {
            if (order[j] == order[j + 1])
            {
                if (s[(j + 1)%n] == 'o')
                    order.append("S");
                else
                    order.append("W");
            }
            else
            {
                if (s[(j + 1)%n] == 'o')
                    order.append("W");
                else
                    order.append("S");
            }
        }

        if (order[n] == order[0] and order[n+1] == order[1])
        {
            cout << order.substr(0, n) << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    // char ;
    ll n;
    scanf("%lld",&n);
    ll a[n],b[n],sa=0,sb=0;
    rep(i,0,n){
        scanf("%lld",&a[i]);
        sa+=a[i];
    }
    rep(i,0,n){
        scanf("%lld",&b[i]);
        sb+=b[i];
    }
    if(sa>sb){
        printf("No\n");
        return 0;
    }
    if(sa==sb){
        rep(i,0,n){
            if(a[i]!=b[i]){
                printf("No\n");
                return 0;
            }
        }
        printf("Yes\n");
        return 0;
    }

    ll d=0,dd=0;
    rep(i,0,n){
        if(a[i]<b[i]){
            d+= ( b[i]-a[i] ) /2;
        }
    }
    rep(i,0,n){
        if(a[i]>b[i]){
            dd+= a[i]-b[i];
        }
    }
    if(d>=dd){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    // printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 2000001
#define MAX 2000000000
int parent(int);
int left(int);
int right(int);
void buildMaxHeap(int*);
void maxHeapify(int*,int);
void swap(int*,int,int);
void printHeap(int*);
void insert(int*,int);
int extract(int*);
int h=0;//size of heap
int main(void)
{
  int arr[N];//array (1-origin)
  char op[10];//operation
  int key;
  arr[0]=MAX+1;
  for(;;)
    {
      scanf("%s",op);
      if(strcmp(op,"insert")==0)
	{
	  scanf("%d",&key);
	  insert(arr,key);
	}
      if(strcmp(op,"extract")==0) printf("%d\n",extract(arr));
      if(strcmp(op,"print")==0) printHeap(arr);//for debugging
      if(strcmp(op,"end")==0) break;
      
    }
  return 0;
}
int parent(int i)
{
  return i/2;
}
int left(int i)
{
  return 2*i;
}
int right(int i)
{
  return 2*i+1;
}
void buildMaxHeap(int *arr)
{
  int i;//counter
  for(i=h/2;i>=1;i--) maxHeapify(arr,i);
}
void maxHeapify(int *arr,int i)
{
  int l=left(i);
  int r=right(i);
  int largest;
  if(i<1) return;
  if(l<=h&&arr[l]>arr[i]) largest=l;
  else largest=i;
  if(r<=h&&arr[r]>arr[largest]) largest=r;
  if(largest!=i)
    {
      swap(arr,i,largest);
      maxHeapify(arr,largest);
    }
}
void swap(int *arr,int x,int y)
{
  int temp;
  temp=arr[x];
  arr[x]=arr[y];
  arr[y]=temp;
}
void printHeap(int *arr)
{
  int i;
  for(i=1;i<=h;i++) printf(" %d",arr[i]);
  printf("\n");
}
void insert(int *arr,int key)
{
  int index;
  h++;
  arr[h]=key;
  for(index=h;index>=1;index=parent(index))
    {
      if(arr[index]<arr[parent(index)]) break;
      maxHeapify(arr,parent(index));
    }
}
int extract(int *arr)
{
  int ret=arr[1];
  arr[1]=arr[h];
  h--;
  maxHeapify(arr,1);
  return ret;
}



Measured memory_bytes: 5688
#include<stdio.h>
main(){
  int a,b,x,sum,y;
  while(scanf("%d %d",&a,&b)!=EOF){
    sum=a+b;
    for(y=1;sum>9;y++){
      sum/=10;
    }
    printf("%d\n",y);
  }
  return(0);
}

Measured memory_bytes: 0
import sys
sys.setrecursionlimit(10**8)

N = int(input())
g = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append((b, i))
    g[b].append((a, i))

ans = [0] * (N-1)

def dfs(v, c=-1, p=-1):
    global g, ans
    k = 1
    for u, ei in g[v]:
        if u == p:
            continue
        if k == c:
            k += 1
        ans[ei] = k
        k += 1
        dfs(u, ans[ei], v)

dfs(0)
mx = 0
for i in range(N):
    mx = max(mx, len(g[i]))
print(mx)
for i in range(N-1):
    print(ans[i])


Measured memory_bytes: 85692