akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}

int main(){
    int N,K,R,S,P;
    string T;
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;
    lint score=0;
    for(int i = 0;i<N;i++){
        if(i+K<N){
            if(T[i]==T[i+K])T[i+K]='u';
        }
        if(T[i]=='r')score +=P;
        else if(T[i]=='p')score +=S;
        else if(T[i]=='s')score +=R;
    }
    cout <<score;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> Q;

int main() {
	int h, w;

	vector<Q> rec;
	for (int i = 1; i <= 150; i++) {
		for (int j = i+1; j <= 150; j++) {
			rec.push_back(Q(i*i + j*j, P(i, j)));
		}
	}

	sort(rec.begin(), rec.end());

	while (cin >> h >> w) {
		if (h == 0 && w == 0) {
			break;
		}
		Q q = Q(h*h + w*w, P(h, w));

		vector<Q>::iterator ite = upper_bound(rec.begin(), rec.end(), q);
		Q qq = *(ite);

		cout << (qq.second).first << ' ' << (qq.second).second << endl;

	}
	return 0;
}


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

int main() {
	int n, max, min, s;
	long sum;

	while (true) {
		cin >> n;
		sum = max = 0;
		min = 1000;

		if (n == 0)	break;

		for (int i = 0; i < n; i++) {
			cin >> s;
			if (s < min)	min = s;
			if (s > max)	max = s;
			sum += s;
		}
		sum -= (min + max);
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;


int main() {
	ll h, w, k;
	cin >> h >> w >> k;

	//i行目まで見たときにj列目にいく通り数
	vector< vector<ll> > dp(h+1, vector<ll>(w+1, 0));
	dp[0][1] = 1;

	vector<int> li;
	for (int bit = 0; bit < (1 << w - 1); bit++) {
		bool ok = 1;
		bool fl = 0;
		for (int i = 0; i < w - 1; i++) {
			if (bit&(1 << i)) {
				if (fl == 1) {
					ok = 0;
					break;
				}
				else {
					fl = 1;
				}
			}
			else {
				if (fl == 1) {
					fl = 0;
				}
			}
		}
		if (ok)li.push_back(bit);
	}



	rep(i, 1, h+1) {
		rep(j, 1, w+1) {
			rep(k, 0, li.size()) {
				if (j>=2 && (li[k]&(1<<(j-2)))) {
					dp[i][j] += dp[i - 1][j - 1] % MOD;
				}
				else if (j<=w-1 &&(li[k] & (1 << (j - 1)))) {
					dp[i][j] += dp[i - 1][j + 1] % MOD;
				}
				else {
					dp[i][j] += dp[i - 1][j] % MOD;
				}
			}
		}
	}

	cout << dp[h][k]%MOD << endl;
	return 0;
}

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

int main(){
  int i;
  int N;
  long lucas;
  long L0 = 2;
  long L1 = 1;
  cin >> N;

  if(N == 1){
    cout << 1 << endl;
    return 0;
  }
  for(i=2;i<=N;++i){
    lucas = L0 + L1;
    L0 = L1;
    L1 = lucas;
  }
  cout << lucas << endl;
  return 0;
}

Measured memory_bytes: 256
list = input().split()
w = int(list[0])
h = int(list[1])
x = int(list[2])
y = int(list[3])
r = int(list[4])

if x - r >= 0 and x + r <= w and y - r >= 0 and y + r <= h:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5596
/*
AUTHOR: Naman
*/
#include <bits/stdc++.h>

using namespace std;
#define endl "\n"
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define all(x) x.begin(),x.end()
#define pb push_back
#define Fo(i,k,n) for(ll i=k;i<=n;i+=1)
#define deb(x) cout << #x << "=" << x << endl
#define in(a,n) Fo( i,0,n-1)cin>>a[i]
#define out(a,n) Fo( i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define IOS     ios_base::sync_with_stdio(0); cin.tie(NULL);
const ll N=2*1e6+1;


int main() {
	IOS
    ll t=1;
	//cin>>t;	
	
	Fo(_,1,t)
	{
	   //cout<<"Case #"<<_<<": ";
	   string s,t1;
	   cin>>s>>t1;
	   
	   ll ans=t1.size();
	   
	   Fo(i,0,(ll)s.size()-(ll)t1.size())
	   {   
	       ll cur=0;
	       Fo(j,0,(ll)t1.size()-1)
	       {
	           if(s[i+j]!=t1[j])cur++;
	       }
	       ans=min(ans,cur);
	   }
	   cout<<ans;
	   
	   
	   


	   cout<<endl;
	   
	}
	
    
}

Measured memory_bytes: 3604
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    
    
    for(int i=0; i<13; i++){
      int A=sc.nextInt();     
      int B=sc.nextInt();  
      if(A==1 && B==1 || A==B){
        System.out.println("Draw");
        break;
      }else if(A==1 || B!=1 && A>B){
        System.out.println("Alice");
        break;
      }else if(B==1 || A!=1 && A<B){
        System.out.println("Bob");
        break;
      }
    }
  }
}

Measured memory_bytes: 23764
#include<stdio.h>
#include<iostream>

using namespace std;

int main(void){
	
	int a, b;

	cin >> a >> b;

	if (b%a == 0) {
		cout << a + b << "\n";
	}
	else {
		cout << b - a << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
//### In The Name Of GOD ###

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

const int MOD = 1000000007;
const int INF = 30 * 1000 + 20;
const int MAXN = 2600;
const int MLOG = 18;
const int NMAX = 60;

#define int ll
#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())
#define ct(x) const_cast<const int&>(x)

int what[MAXN][NMAX][NMAX];

int32_t main(){
	int n;
	cin >> n;
	int a[ct(n)];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	ll all = (int)MOD*10000000;
	for(int i = -100; i <= 100;i++){
		int ans = 0;
		for(int j = 0; j < n ; j++){
			ans += (i-a[j])*(i-a[j]);
		}
		all = min(ans, all);
	}
	cout << all;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

const int MAX_N = 100005;
struct edge{int to, cost;};
typedef pair<int, int> P;

vector<edge> G[MAX_N];

/*
   ダイクストラ法による単一始点最短経路問題solver
n : ノード数
s : 開始ノード(0-indexed)
*/
void dijkstra(int n, int s, long long* d){
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d+n, INF);
	d[s] = 0;
	que.push(P(0, s));

	while(!que.empty()){
		P p = que.top(); que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i=0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n;
	ll d1[MAX_N];
	ll d2[MAX_N];

	cin >> n;

	for(int i=0; i<n-1; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].pb(edge{b, 1});
		G[b].pb(edge{a, 1});
	}

	dijkstra(n, 0, d1);
	dijkstra(n, n-1, d2);

	ll s1 = 0;
	ll s2 = 0;
	for(int i=0; i<n; i++){
		//printf("%lld %lld\n", d1[i], d2[i]);
		if(d1[i] <= d2[i]){
			s1++;
		}else{
			s2++;
		}
	}

	//printf("%lld %lld\n", s1, s2);

	if(s1 == s2){
		puts("Snuke");
	}else if(s1 > s2){
		puts("Fennec");
	}else{
		puts("Snuke");
	}
	
	return 0;
}


Measured memory_bytes: 8176
#include <stdio.h>
#include <algorithm>
#include <set>
#include <vector>
#include <iostream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define vec vector<int>
#define All(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
int main(){
    int n=in();
    ll ans=0;
    set<ll> set;
    vec a(n+2);
    rep(i,n)a[in()]=i+1;
    set.insert(0);
    set.insert(n+1);
    rep2(k,1,n){
        auto x=set.upper_bound(a[k]);
        ans+=(*x-a[k])*(a[k]-*--x)*k;
        set.insert(a[k]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 10368
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int N, K;
	cin >> N >> K;
	vector<int> A, B;
	for (int i = 0; i < N; ++i) {
		int x;
		cin >> x;
		if (x == 0) {
			K--;
		}
		else if (x < 0) {
			A.push_back(-x);
		}
		else {
			B.push_back(x);
		}
	}
	sort(A.begin(), A.end());
	int ans = INF;
	if (K == 0) {
		cout << 0 << endl;
		return;
	}

	int res;
	for (int L = 0; L <= A.size() && L <= K; ++L) {
		if (L == K) {
			ans = min(ans, A[L - 1]);
		}
		else {
			res = 0;
			if (L) {
				res = A[L - 1] * 2;
			}
			int nokori = K - L;
			if (nokori <= B.size()) {
				ans = min(ans, res + B[nokori - 1]);
			}
		}
	}

	for (int R = 0; R <= B.size() && R <= K; ++R) {
		if (R == K) {
			ans = min(ans, B[R - 1]);
		}
		else {
			res = 0;
			if (R) {
				res = B[R - 1] * 2;
			}
			int nokori = K - R;
			if (nokori <= A.size()) {
				ans = min(ans, res + A[nokori - 1]);
			}
		}
	}
	cout << ans << endl;
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
  int d, g; cin >> d >> g;

  vector<pair<int, int>> v(d+1);
  for(int i = 1; i <= d; i++){
    cin >> v[i].first >> v[i].second;
  }

  int cnt = 100000000;
  for(int bit = 0; bit < (1<<d); ++bit){
    int sum = 0;
    int res = 0;
    for(int i = d; i >= 1; i--){
      int cc = 0;

      if(bit & (1<<(i-1))){
        while(cc < v[i].first){
        sum += i * 100;
        res++;
        cc++;
        if(sum >= g){break;}

        }
        if(cc == v[i].first){sum += v[i].second;}
        if(sum >= g){break;}
      }
    }

    if(sum >= g && res < cnt){cnt = res;}
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

int main()
{
	int NumOfC = 0;
	int NumOfH = 0;

	char c;

	int l1, l2, l3;

	while(std::cin>> l1 >> c >> l2 >> c >> l3)
	{
		if(l1*l1+l2*l2 == l3*l3)
		{
			++NumOfC;
		}

		if(l1 == l2)
		{
			++NumOfH;
		}
	}

	std::cout << NumOfC << '\n' << NumOfH << '\n';
}

Measured memory_bytes: 1160
#!/usr/bin/env python3

def main():
    na = list(map(int, input().split()))
    H, W = na[0], na[1]
    mp = []
    for i in range(H):
        mp.append(input())

    w_count = 0
    for s in mp:
        w_count += s.count('.')

    dist = [-1 for i in range(H * W)]
    v = (0, 0, 1)
    dist[0] = 1
    q = []
    q.append(v)
    while 0 < len(q):
        x, y, d = v = q.pop(0)
        if 0 < x and dist[W * y + x - 1] == -1 and mp[y][x - 1] == '.':
            dist[W * y + x - 1] = d + 1
            q.append((x - 1, y, d + 1))
        if x < W - 1 and dist[W * y + x + 1] == -1 and mp[y][x + 1] == '.':
            dist[W * y + x + 1] = d + 1
            q.append((x + 1, y, d + 1))
        if 0 < y and dist[W * (y - 1) + x] == -1 and mp[y - 1][x] == '.':
            dist[W * (y - 1) + x] = d + 1
            q.append((x, y - 1, d + 1))
        if y < H - 1 and dist[W * (y + 1) + x] == -1 and mp[y + 1][x] == '.':
            dist[W * (y + 1) + x] = d + 1
            q.append((x, y + 1, d + 1))
        if dist[H * W - 1] != -1:
            break

    if dist[H * W - 1] == -1:
        print(-1)
    else:
        print(w_count - dist[H * W - 1])


if __name__ == '__main__':
    main()



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

using namespace std;

bool is_prime(int n) {
    if (n % 2 == 0) return false;
    for(int i = 3; i*i <= n; i+= 2) {
        if (n % i == 0) return false;
    }
    return true;
}

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

    if (x % 2 == 0) x++;
    while(true) {
        if (is_prime(x)) {
            cout << x << endl;
            return 0;
        }
        x += 2;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
#include <functional>
#include <array>
#include <cmath>

using namespace std;

int H, W;
char s[50][50]{};

int visit[50][50]{};

queue<pair<int, int>> q;

void Check(int i, int k, int step) {
	if (0 <= i && i < H
		&& 0 <= k && k < W
		&& s[i][k]
		&& !visit[i][k]
		)
	{
		visit[i][k] = step;
		q.emplace(i, k);
	}
}

void Check4d(int i, int k) {
	Check(i - 1, k, visit[i][k] + 1);
	Check(i + 1, k, visit[i][k] + 1);
	Check(i, k - 1, visit[i][k] + 1);
	Check(i, k + 1, visit[i][k] + 1);
}

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

	int wcnt = 0;
	for (int i = 0; i < H; ++i) {
		for (int k = 0; k < W; ++k) {
			char c;
			cin >> c;
			if (c == '.') {
				s[i][k] = 1;
				++wcnt;
			}
		}
	}

	int step = 1;
	visit[0][0] = 1;
	q.emplace(0, 0);

	while (q.empty() == false) {
		//auto[i, k] = q.front();
		auto e = q.front();
		int i = e.first;
		int k = e.second;

		if (i == H - 1 && k == W - 1) {
			cout << wcnt - visit[i][k] << endl;
			return 0;
		}

		Check4d(i, k);
		q.pop();
	}

	cout << -1 << endl;

	return 0;
}



Measured memory_bytes: 256
N=input()
a=list(N)
b=[]
n=len(a)
for i in range(n):
 b.append(0)
count=0

for i in range(n):
  b[i]=a[n-1-i]

for i in range(n):
  if(a[i]==b[i]):
    count +=1

if(count==n):
  print("Yes")
else:
  print("No")
  

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

const int inf = 1e9 + 13;

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

  int n;
  cin >> n;
  string s;
  cin >> s;
  int bal = 0, min_bal = inf;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '(')
      ++bal;
    else
      --bal;
    min_bal = min(bal, min_bal);
  }
  for (int i = 0; i > min_bal; --i) {
    ++bal;
    cout << '(';
  }
  cout << s;
  for (int i = 0; i < bal; ++i)
    cout << ')';
  cout << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
const int bs=400;
int h,l,c[1<<18|10],p[1<<18],d[1<<18|10];
ll inv[1<<18],vl[1<<18],ivl[1<<18],ans;
struct evt{int l,r;ll v;};
vector<evt> ev[1<<18|10][2];
void Md(int&x){x>=mod && (x-=mod);}
void ins(int x,int v){
	int id=x/bs,up=l/bs;
	for(;x<min((id+1)*bs,l+1);x++)Md(c[x]+=v);
	for(id++;id<=up;id++)Md(d[id]+=v);
}
int qry(int x){
	int r=c[x]+d[x/bs];Md(r);
	return r;
}
int main(){
	scanf("%d",&h);l=1<<h-1;inv[1]=1;
	for(int i=2;i<2*l;i++)inv[i]=-mod/i*inv[mod%i]%mod;
	for(int i=0;i<2*l;i++){
		vl[i]=ivl[i]=1;
		for(int j=i;j;j/=2)(vl[i]*=j)%=mod,(ivl[i]*=inv[j])%=mod;
	}
	for(int i=0;i<l;i++){
		scanf("%d",p+i);p[i]--;
		ev[i][0].push_back({p[i],0,vl[i+l]*vl[p[i]+l]%mod});
		for(int j=i+l,k=0;j>1;j/=2,k++){
			if(j&1)continue;
			int lx=(j^1)<<k,rx=lx+(1<<k)-1;
			lx-=l,rx-=l;
			for(int pj=p[i]+l,pk=0;pj>1;pj/=2,pk++){
				int ly=(pj^1)<<pk,ry=ly+(1<<pk)-1;
				ly-=l,ry-=l;
				ll x=vl[i+l]*vl[p[i]+l]%mod*ivl[j/2]%mod*ivl[j/4]%mod*ivl[pj/2]%mod*ivl[pj/4]%mod;
				if(lx)ev[lx-1][1].push_back({ly,ry,-x});
				ev[rx][1].push_back({ly,ry,x});
			}
		}
	}
	for(int i=0;i<l;i++){
		for(evt&x:ev[i][0])
			ins(x.l+1,(x.v+mod)%mod);
		for(evt&x:ev[i][1])
			(ans+=(qry(x.r+1)-qry(x.l))*x.v)%=mod;
	}
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 751700
#include <iostream>
using namespace std;
int ansa,ansb;
int main(void){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0')ansa++;
        else ansb++;
    }
    cout<<s.size()-abs(ansa-ansb)<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K,X;
  cin>>K>>X;
  int d=K-1;
  int m=X-d;
  int M=X+d;
  for(int i=m;i<M;i++) cout<<i<<" ";
  cout<<M<<endl;
}

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

#define N 1000

int main(void) {
	char field[N][N];
	int n;
	int ans;
	
	//int table[N][N];　で初期化宣言するとメモリ不足でエラー
	int **table = new int*[N];
	for(int i = 0; i < N; ++i) table[i] = new int[N];
	
	while(cin >> n) {
		if(n == 0) break;
		
		for(int i = 0; i < n; ++i) cin >> field[i];
		
		for(int i = 0; i < n; ++i) {
			table[0][i] = (field[0][i] == '.') ? 1 : 0;
			table[i][0] = (field[i][0] == '.') ? 1 : 0;
		}
		
		ans = 0;
		for(int i = 1; i < n; ++i) {
			for(int j = 1; j < n; ++j) {
				if(field[i][j] == '.') {
					table[i][j] = min(table[i - 1][j - 1], min(table[i - 1][j], table[i][j - 1]));
					table[i][j] += 1;
					ans = max(ans, table[i][j]);
				} else {
					table[i][j] = 0;
				}
			}
		}
		
		cout << ans << endl;
	}
	
	for(int i = 0; i < N; ++i) delete [] table[i];
	delete [] table;
	
	return 0;
}


Measured memory_bytes: 7728
using System;
using System.Linq;

namespace _0539
{
	class Program
	{
		static int[] store;
		static bool IsOK(int index, int key)
		{
			if (store[index] > key) return true;
			else return false;
		}

		static int Binary_search(int key)
		{
			int ng = -1;
			int ok = store.Count();

			while (ok - ng > 1)
			{
				int mid = ng + (ok - ng) / 2;

				if (IsOK(mid, key)) ok = mid;
				else ng = mid;
			}

			return ok;
		}
		static void Main(string[] args)
		{
			while (true)
			{
				int d = int.Parse(Console.ReadLine());
				if (d == 0) break;
				int n = int.Parse(Console.ReadLine());
				int m = int.Parse(Console.ReadLine());
				store = new int[n]; store[0] = 0;
				for (int i = 1; i < n; i++)
				{
					store[i] = int.Parse(Console.ReadLine());
				}
				Array.Sort(store); long ret = 0;
				for (int i = 0; i < m; i++)
				{
					int x = int.Parse(Console.ReadLine());
					if (store[n - 1] <= x)
						ret += Math.Min(d - x, x - store[n - 1]);
					else
					{
						int a = Binary_search(x);
						ret += Math.Min(store[a] - x, x - store[a - 1]);
					}
				}
				Console.WriteLine(ret);
			}
		}
	}
}


Measured memory_bytes: 18772
const lines=readlines(open("/dev/fd/0"))
let
    state=0
    global input
    input()=lines[state+=1]
end
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
intLine()=map(intSub,split(input()))
function main()
    a,b,k=intLine()
    c=0
    for i in a:-1:1
        c+=a%i<1>b%i
        if c==k
            println(i)
            break
        end
    end
end
main()

Measured memory_bytes: 118692
from sys import stdin
N=int(input())
nodes=[None]*N
class node_tree():
    def __init__(self,node):
        self.node=node
        self.left=None
        self.right=None
        self.brother=None
        self.up=None
for i in range(N):
    node,left,right = list(map(int, (stdin.readline().strip().split())))
    if nodes[node] is not None:
        parent=nodes[node]
    else:parent=node_tree(node)
    if left!=-1:
        if nodes[left] is not None:
            left_node=nodes[left]
        else:left_node=node_tree(left)
        parent.left=left_node
        left_node.up=parent

    if right!=-1:
        if nodes[right] is not None:
            right_node=nodes[right]
        else:right_node=node_tree(right)
        parent.right=right_node
        right_node.up=parent
    if left!=-1 and right!=-1:
        left_node.brother=right_node
        right_node.brother=left_node
    if left!=-1:
        nodes[left] = left_node
    if right!=-1:
        nodes[right] = right_node
    nodes[node]=parent

def search_root(u):
    if u.up!=None:
        return search_root(u.up)
    else:
        return u.node
oya=search_root(nodes[0])
print("Preorder")
def pre(u):
    print("",u.node,end="")
    if u.left is not None:
        pre(u.left)
    if u.right is not None:
        pre(u.right)
pre(nodes[oya])
print("\nInorder")
def ino(u):

    if u.left is not None:
        ino(u.left)
    print("",u.node,end="")
    if u.right is not None:
        ino(u.right)
ino(nodes[oya])
print("\nPostorder")
def pos(u):

    if u.left is not None:
        pos(u.left)
    if u.right is not None:
        pos(u.right)
    print("",u.node,end="")
pos(nodes[oya])
print()


Measured memory_bytes: 5628
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=100005;
int b[maxn],a[maxn],n,vis[maxn],v[2];
ll ans;
void calc(){
	int mid=n/2,l=1,r=n,L,R,fg=0,tmp=0,lt=1;
	b[mid]=a[l++];L=mid,R=mid;
	while(l<=r){
		if(fg==0) b[++R]=lt==0?a[l++]:a[r--],lt^=1;
		else b[--L]=lt==0?a[l++]:a[r--],lt^=1;
		if(++tmp==2)fg^=1,tmp=0;
	}
	ll t=0;
	for(int i=L+1;i<=R;i++)t+=abs(b[i]-b[i-1]);
	ans=max(ans,t);
}
inline int read(){
	int x=0;bool f=1;char ch=getchar();
	while (!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
	while (isdigit(ch))x=(x<<3)+(x<<1)+ch-48,ch=getchar();
	if (f) return x;return -x;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
	if(n<=2){printf("%d\n",a[2]-a[1]);return 0;}
	calc();reverse(a+1,a+n+1);calc();
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int32_t main(){
   int n;
   int x;
   cin>>x;
   cin>>n;
   vector<int> v;
   rep(i,0,n){
      int t;
      cin>>t;
      v.pub(t);
   }
   set<int> s;
   rep(i,0,n){
      s.insert(v[i]);
   }
   int j=0;
   int mn=1e10;
   rep(i,-101,102){
      if(s.find(i)!=s.end()){
         j++;
         continue;
      }
      mn=min(mn,llabs(x-i));
   }
   j=0;
   rep(i,-101,102){
      if(s.find(i)!=s.end()){
         j++;
         continue;
      }
      if(llabs(x-i)==mn){
         cout<<i<<"\n";
         return 0;
      }
   }
   return 0;
}

Measured memory_bytes: 3604
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main
int main() {
    int n;
    string s;
    int q;
    cin >> n >> s >> q;
    
    rep(_, q) {
        int k;
        cin >> k;
        ll ans = 0, now = 0;
        int d_cnt = 0, m_cnt = 0;
        rep(i, k) {
            if (s[i] == 'D') ++d_cnt;
            if (s[i] == 'M') {
                ++m_cnt;
                now += d_cnt;
            }
            if (s[i] == 'C') ans += now;
        }
        rep(i, n - k) {
            if (s[i] == 'D') {
                --d_cnt;
                now -= m_cnt;
            }
            if (s[i] == 'M') --m_cnt;
            if (s[i + k] == 'D') ++d_cnt;
            if (s[i + k] == 'M') {
                ++m_cnt;
                now += d_cnt;
            }
            if (s[i + k] == 'C') ans += now;
        }
        cout << ans << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 4272
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long a, b, v, w, t, x, d;
	cin >> a >> v >> b >> w >> t;

	d = abs(a - b);
	bool valid;

	if (d == 0) valid = true;
	else if (w >= v) valid = false;
	else {
		x = (v - w) * t;
		valid = x >= d;
	}

	if (valid) cout << "YES\n";
	else cout << "NO\n";

	return 0;
}


Measured memory_bytes: 3052
#include<iostream>
#include<cstdio>
#include<list>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<cmath>
#include<set>
using namespace std;
int main()
{
	int n,a[105];
	cin>>n;
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	int minn=99999999;
	for(int i=a[0];i<=a[n-1];i++){
		int sum=0;
		for(int j=0;j<n;j++){
			sum+=(i-a[j])*(i-a[j]);
		}
		if(sum<minn){
			minn=sum;
		}
	}
	cout<<minn<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int A, B, K; cin >> A >> B >> K;
	stack<int> s;
	FOR(i, 1, 101){
		if(not(A%i) and not(B%i)) s.push(i);
	}
	REP(i, K-1)s.pop();
	cout << s.top() << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

int const inf = 1 << 29;
struct Edge {
    Edge(int dst, int weight)
        : dst(dst), weight(weight){}
    int dst, weight;
};

struct State{
    State(int dst, int weight, int rest)
        :dst(dst), weight(weight), rest(rest){}
    int dst, weight, rest;
    bool operator<(const State &s) const {
        return weight > s.weight;
    }
};

typedef vector<vector<Edge>> Graph;

// M : 制限時間
// L : 冷凍できる頂点の数
// A : 始点
// H : 終点
int V, M, L, E, A, H;
bool isL[128];
Graph g;

int dp[128][128];

int solve(){
    priority_queue<State> q;
    rep(i, V)rep(j, M + 1)dp[i][j] = inf;
    dp[A][M] = 0;
    q.emplace(A, 0, M);
    while (q.size()){
        State s = q.top(); q.pop();
        int src = s.dst, weight = s.weight, rest = s.rest;
        if (src == H) return weight;
        if (dp[src][rest] < weight) continue;
        rep(i, g[src].size()){
            int dst = g[src][i].dst;
            int weight = g[src][i].weight;
            if (rest - weight >= 0 && dp[dst][rest - weight] > dp[src][rest] + weight){
                dp[dst][rest - weight] = dp[src][rest] + weight;
                q.push(State(dst, dp[src][rest] + weight, rest - weight));
            }
            if (isL[src]){
                for (int j = 1; rest + j <= M; j++){
                    if (rest + j - weight >= 0 && dp[dst][rest + j - weight] > dp[src][rest] + weight + j){
                        dp[dst][rest + j - weight] = dp[src][rest] + weight + j;
                        q.push(State(dst, dp[src][rest] + weight + j, rest - weight + j));
                    }
                }
            }
        }
    }
    return inf;
}

int main(){
    while (cin >> V >> M >> L >> E >> A >> H && V){
        memset(isL, 0, sizeof(isL));
        g.assign(V, {});
        isL[A] = isL[H] = true;
        rep(i, L){
            int v; cin >> v;
            isL[v] = true;
        }
        rep(i, E){
            int u, v, t;
            cin >> u >> v >> t;
            g[u].push_back(Edge(v, t));
            g[v].push_back(Edge(u, t));
        }
        int ans = solve();
        if (ans >= inf) cout << "Help!";
        else cout << ans;
        cout << endl;
    }
}

Measured memory_bytes: 1592
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
typedef long long ll;
#define tr(container, it) \
    for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int X10=1024,X11=2048,X12=4096,X13=8196,X14=16392,X15=32786,X16=65536,X17=131072,X18=262144,X19=524288,X20=1048576;


void _ (){
    int a,b;
    cin>> a>>b;
    if(a+b==15)cout << "+";
    else if(a*b==15)cout << "*";
    else cout <<"x";

}


int main() {
#ifdef Debug
    freopen("/home/joduskame/Desktop/cpp/IO/Input.txt", "r", stdin);
    freopen("/home/joduskame/Desktop/cpp/IO/Output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();
    return 0;

}








Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,i,cnt=0;
  cin >> n;
  vector<int>a(n),b(n);
  for(i=0; i<n; i++){
    cin >> a.at(i);
  }
  for(i=0; i<n; i++){
    b.at(a.at(i)-1)=i+1;
  }
  for(i=0; i<n; i++){
    cout << b.at(i);
    cnt++;
    if(cnt==n){
      cout << endl;
    }
    else{
      cout << " ";
    }
  }
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    ll absSum = 0;
    ll minAbs = 10000000000;
    int minusNum = 0;
    rep(i, 0, N)
    {
        cin >> A[i];
        absSum += abs(A[i]);
        chmin(minAbs, abs(A[i]));
        if (A[i] < 0) ++minusNum;
    }
    if (minusNum % 2 == 1)
    {
        cout << absSum - minAbs * 2 << endl;
    }
    else
    {
        cout << absSum << endl;
    }
}


Measured memory_bytes: 1024
import java.util.Scanner;
class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();

        if(a < b){
          if(b < c){
            System.out.println("Yes");
          }else{
            System.out.println("No");
          }
        }else{
          System.out.println("No");
        }
    }
}

Measured memory_bytes: 26088
#include<stdio.h>
int main(void)
{
	char S[7];
	scanf("%s",S);
	if(S[2]==S[3]){
		if(S[4]==S[5]){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 1636
package main

import (
	"fmt"
	"os"
	"strconv"
	"strings"
	"bufio"
)

var (
	sc = bufio.NewScanner(os.Stdin)
	buf = make([]byte, 1000)
)

func scanText() string{
	sc.Scan()
	return sc.Text()
}

func scanTextArray(n int) []string {
	out := make([]string, n)
	for i, v := range(strings.Split(scanText(), "")) {
		out[i] = v
	}
	return out
}

func scanInt() int {
	out, e := strconv.Atoi(scanText())
	if e != nil {
        panic(e)
    }
	return out
}

func scanIntArray(n int) []int {
	out := make([]int, n)
	for i, v := range(strings.Split(scanText(), " ")) {
		num, e := strconv.Atoi(v)
		if e != nil {
			panic(e)
		}
		out[i] = num
	}
	return out
}
//  template end

func main() {
	sc.Buffer(buf, 10000)
	nhw := scanIntArray(3)
	N, H, W := nhw[0], nhw[1], nhw[2]
	ans := 0
	for i:=0; i<N; i++ {
		ab := scanIntArray(2)
		if ab[0] >= H && ab[1] >= W {
			ans++
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 640
list1 = list(map(int, input().split()))
a = list1[0]
b = list1[1]
c = list1[2]
k = list1[3]


if k%2 ==0:
    ans = a-b
else:
    ans = b-a

if ans>10**18:
    print("Unfair")
else:
    print(ans)

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

using namespace std;

int main() {
  long long a, b, c, d; cin >> a >> b >> c >> d;
  
  long long x1 = a * c;
  long long x2 = a * d;
  long long x3 = b * c;
  long long x4 = b * d;
  long long ans = max(x1, max(x2, max(x3, x4)));
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
  long long h,w;
  cin >> h >> w;
  long long ans = 0;

  if (h == 1 || w == 1){
    ans = 1;
  }
  else {
  if (h % 2) {
    ans += ((h / 2) + 1) * (w / 2 + w % 2);
    ans += (h / 2) * (w / 2);
  }
  else{
    ans += (h / 2) * (w / 2 + w % 2);
    ans += (h / 2) * (w / 2);
  }
  }

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


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

const int INF = 1000000000;

class MaxFlow {
	struct edge {
		int to, cap, rev;
		edge(int to_, int cap_, int rev_) : to(to_), cap(cap_), rev(rev_) {};
	};

	int V;
	vector<vector<edge>> G;
	vector<int> level;
	vector<int> iter;

	void BFS(int s) {
		fill(level.begin(), level.end(), -1);
		queue<int> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty()) {
			int v = que.front(); que.pop();
			for (size_t i = 0; i < G[v].size(); i++) {
				edge &e = G[v][i];
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}

	int DFS(int v, int t, int f) {
		if (v == t) return f;
		for (int &i = iter[v]; i < (int)G[v].size(); i++) {
			edge &e = G[v][i];
			if (e.cap > 0 && level[v] < level[e.to]) {
				int d = DFS(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

public:
	MaxFlow(int _V) : V(_V), G(_V), level(_V), iter(_V) {}
	void add(int from, int to, int cap) {
		G[from].push_back(edge(to, cap, G[to].size()));
		G[to].push_back(edge(from, 0, G[from].size() - 1));
	}
	int Dinic(int s, int t) {
		int flow = 0;
		while (true) {
			BFS(s);
			if (level[t] < 0) return flow;
			fill(iter.begin(), iter.end(), 0);
			int f;
			while ((f = DFS(s, t, INF)) > 0) {
				flow += f;
			}
		}
	}
};

int main()
{
	int N;
	cin >> N;
	vector<int> a(N), b(N), c(N), d(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> c[i] >> d[i];
	}
	MaxFlow mf(N * 2 + 2);
	int s = N * 2, t = N * 2 + 1;
	for (int i = 0; i < N; i++) {
		mf.add(s, i, 1);
		mf.add(N + i, t, 1);
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (a[i] < c[j] && b[i] < d[j]) {
				mf.add(i, N + j, 1);
			}
		}
	}
	cout << mf.Dinic(s, t) << endl;
	return 0;
}


Measured memory_bytes: 384
N = int(input())
s = input()
ans = 0

l = 0
r = N-1

while l < r:
    if s[l] == 'W' and s[r] == 'R':
        ans += 1
        l += 1
        r -= 1
    elif s[l] == 'W' and s[r] == 'W':
        r -= 1
    elif s[l] == 'R' and s[r] == 'R':
        l += 1
    else:
        l += 1
        r -= 1

print(ans)


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll int N, X, T;
	cin >> N >> X >> T;
	ll int y = ceil((double) N / X);
	cout << y * T;	
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long int
#define tc int t; cin>>t; while(t--)
#define fora(i,n) for(int i=0;i<n;i++)
#define forb(i,a,n) for(int i=a;i<n;i++)
#define dbg(x)    { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)  { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define mod 1000000007
#define pb push_back
#define pii pair<int,int>
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<class T> T power(T N,T P){ return (P==0)?  1: N*power(N,P-1);}
void solve() {
    int cnt=0;
    int ans=0;
    string s; cin>>s;
    fora(i,3) {
        if(s[i]=='R') cnt++;
        else {
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    ans=max(ans,cnt);
    cout<<ans;
}
int32_t main()
{
    fastio
    solve();   
    

    return 0;


}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

// union-find
int N_MAX = 100000;
vi par(N_MAX + 1), dep(N_MAX + 1), siz(N_MAX + 1);

void init(int n) { // 要素数n, 1-ind	
	rep2(i, 1, n + 1) {
		par.at(i) = i;
		dep.at(i) = 0;
		siz.at(i) = 1; // 「その親と」同じ連結成分に含まれる要素の数
	}
}

int find(int x) {
	if (par.at(x) == x) return x;
	else return par.at(x) = find(par.at(x)); // 縮約
}

void unite(int x, int y) {
	x = find(x); y = find(y);
	if (x == y) return;
	if (dep.at(x) > dep.at(y)) {
		par.at(y) = x;
		siz.at(x) += siz.at(y);
	} else if (dep.at(x) < dep.at(y)) {
		par.at(x) = y;
		siz.at(y) += siz.at(x);
	} else if (dep.at(x) == dep.at(y)) {
		par.at(y) = x;
		dep.at(x)++;
		siz.at(x) += siz.at(y);
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}

// 自分と連結なユーザーのうち，友達関係になく，ブロック関係にもないユーザーの数が答え

int main () {
	// 1-ind	
	int N, M, K; cin >> N >> M >> K;
	vector<set<int>> f(N + 1); // ユーザーと友達関係にあるユーザーのset　※友達関係にあれば必ず連結である。
	vi F(N + 1); // 友達関係にあるユーザーの数 ※本来不要
	vi JB(N + 1); // 連結でかつブロック関係にあるユーザーの数
	vi FB(N + 1); // 友達関係にあり，かつ，ブロック関係にあるユーザーの数
	init(N);	
	rep(i, M) {		
		int A, B; cin >> A >> B;		
		unite(A, B);		
		f.at(A).insert(B); f.at(B).insert(A);
		F.at(A)++; F.at(B)++; // ※本来不要
	}
	
	rep(i, K) {
		int C, D; cin >> C >> D;
		if (same(C, D)) {
			JB.at(C)++; JB.at(D)++;
		}
		if (f.at(C).count(D)) {
			FB.at(C)++; FB.at(D)++;
		}
	}
	// rep2(i, 1, N + 1) cout << siz.at(find(i)) << " "; cout << endl;
	// dbv(F); dbv(JB); dbv(FB);

	rep2(i, 1, N + 1) {
		if (i - 1) cout << " ";
		cout << siz.at(find(i)) - 1 - JB.at(i) - F.at(i) + FB.at(i);
	}
}

Measured memory_bytes: 17280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;


class Main{
	static int[][] ban;
	static boolean[][] visited;
	static long sum=0;
	static int H,W;
	static long kuro=0;
	static long siro=0;
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		H=sc.nextInt();
		W=sc.nextInt();
		visited=new boolean[H][W];
		ban=new int[H][W];
		String s;
		for(int i=0; i<H; i++){
			s=sc.next();
			for(int j=0; j<W; j++){
				if(s.charAt(j)=='#'){
					ban[i][j]=1;	//黒
				}
				else{
					ban[i][j]=0;	//白
				}
			}
		}

		for(int i=0; i<H; i++){		//しらべる
			for(int j=0; j<W; j++){
				if(ban[i][j]==1 && !visited[i][j]){
					kuro=0; siro=0;
					dfs(i,j);
					sum+=kuro*siro;
				}
			}
		}
		pl(sum);
	}

	public static void dfs(int y,int x){
		int[] vx={0,1,0,-1};
		int[] vy={-1,0,1,0};
		if(ban[y][x]==1){
			kuro++;
		}
		else{
			siro++;
		}
		visited[y][x]=true;
		for(int i=0; i<4; i++){
			if(x+vx[i]>=0 && x+vx[i]<W && y+vy[i]>=0 && y+vy[i]<H){
				if(ban[y][x]!=ban[y+vy[i]][x+vx[i]] && !visited[y+vy[i]][x+vx[i]]){
					dfs(y+vy[i],x+vx[i]);
				}
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

Measured memory_bytes: 52096
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        200000005
#define mod         1000000007
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll k,i,n,count=0,ans=0,x,y,ans1=0;
    cin>>k;
    if(s.size()==1){
        ans=k/2;
        cout<<ans;
    }
    else{
        n=s.size();
        i=1;
        count=0;
        vector<ll> vi;
        while(i<n){
            while(i<n && s[i-1]==s[i]){
                count++;
                i++;
            }
            i++;
            vi.pb(count+1);
            count=0;
        }
        if(s[n-2]!=s[n-1]){
            vi.pb(1);
        }
        // for(auto x:vi){
        //     cout<<x<<" ";
        // }
        // cout<<endl;
        if(s[0]!=s[n-1] || k==1){
            for(auto x:vi){
                ans+=x/2;
            }
            ans=ans*1ll*k;
            cout<<ans;
        }
        else{
            x=vi.size();
            if(x==1){
                ans=(vi[0]*1ll*k);
                ans=ans/2;
                cout<<ans;
            }
            else{
                y=vi[x-1]+vi[0];
                ll z=vi[x-1];
                vi.pop_back();
                vi.pb(y);
                for(i=1;i<x-1;i++){
                    vi.pb(vi[i]);
                }
                vi.pb(z);
                // for(auto x:vi){
                //     cout<<x<<" ";
                // }
                // cout<<endl;
                k=k-2;
                for(auto x:vi){
                    ans+=x/2;
                }
                y=vi.size();
                for(i=x-1;i<y-1;i++){
                    ans1+=vi[i]/2;
                }
                ans1=ans1*1ll*k;
                ans+=ans1;
                cout<<ans;
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll s;cin>>s;
    ll b=(s-1)/1000000000+1;
    ll a=b*1000000000-s;
    cout<<0<<' '<<0<<' '<<1000000000<<' '<<1<<' '<<a<<' '<<b<<endl;
}

Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()

def resolve():
    ward = 96
    n, s = map(int, input().split())
    mask = int(('1' * 32 + '0' * 64) * (s + 1) , 2)
    Mask = (1 << (s + 1) * ward) - 1
    dp = 1
    for a in map(int, input().split()):
        dp = (dp * 2) + (dp << ward * a)
        dp &= Mask
        dp = (dp & (~mask)) + ((dp & mask) >> 64) * ((1 << 64) % MOD)

    print(((dp >> s * ward) & ((1 << ward) - 1)) % MOD)
resolve()

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

#define ll long long
#define mx  300005
#define mod 1000000009
#define lim 10000000
#define N 18
using namespace std;
int psum[mx][2];

int main(){
	ios_base::sync_with_stdio(false);
	int n;cin>>n;
	string s;cin>>s;
	s=" "+s;
	psum[0][0]=psum[0][1]=0;

	for(int i=1;i<=n;i++)
	{
	    psum[i][0]=psum[i-1][0];
	    psum[i][1]=psum[i-1][1];

	    if(s[i]=='W')psum[i][0]++;
	    else         psum[i][1]++;
	}
	int ans=INT_MAX;

	for(int i=1;i<=n;i++)
	{
            ans=min(ans,psum[i-1][0]-psum[0][0]+psum[n][1]-psum[i][1]);
	}
	cout<<ans<<"\n";
     return 0;
}


Measured memory_bytes: 3056
#include<iostream>
#include<cstdlib>

int D, N;
int T[200];
int A[200], B[200], C[200];
bool suit[200][200];
int dp[200][200];

int main()
{
	std::cin >> D >> N;
	for( int i = 0; i != D; ++i )
		std::cin >> T[i];
	for( int i = 0; i != N; ++i )
		std::cin >> A[i] >> B[i] >> C[i];

	for( int i = 0; i != D; ++i )
		for( int j = 0; j != N; ++j )
			suit[i][j] = A[j] <= T[i] && T[i] <= B[j];

	for( int i = 0; i != D - 1; ++i )
		for( int j = 0; j != N; ++j )
			if( suit[i+1][j] )
				for( int k = 0; k != N; ++k )
					if( suit[i][k] )
						dp[i+1][j] = std::max( dp[i+1][j], dp[i][k] + abs( C[j] - C[k] ) );

	int ans = 0;
	for( int i = 0; i != N; ++i )
		ans = std::max( ans, dp[D-1][i] );

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

	return 0;
}

Measured memory_bytes: 1356
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int r,d,x;
  cin >> r >> d >> x;
  rep(i,10){
    x=r*x-d;
    cout << x << endl;
  }
return 0;}


Measured memory_bytes: 256