akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define forr(i,a,n) for(ll i=a;i<n;i++)
#define ford(i,a,n) for(ll i=n-1;i>=a;i--)
#define all(v) v.begin(),v.end()
#define testc  ll ts;\
               cin>>ts;\
               while(ts--)
#define arn ll n;\
            cin>>n;\
            ll a[n];\
            forr(i,0,n)cin>>a[i];\
               
#define arr(a,n) ll a[n];\
                 forr(i,0,n)cin>>a[i];\
 
#define sss <<" "<<
#define nnn <<"\n"
#define nl cout<<"\n";
#define prtitr(v) for(auto itr=v.begin(); itr!=v.end() ; itr++)cout<<*itr<<" ";
#define fitr(v) for(auto itr=v.begin(); itr!=v.end() ; itr++)
using namespace std;
ll M=1e9+7;
ll cdiv(ll a,ll b){
    return (a%b==0)?a/b:a/b+1;
}
ll myMod(ll a, ll b){
    ll r = a % b;
    return r < 0 ? r + b : r;
}
ll ModPow(ll a,ll b,ll M)
{
    if(M==1)return 0;
    a%=M;
    ll ans=1,t=1;
    while(t>0&&t<=b)
    {
        if(t&b)
        {
            ans*=a;
            ans%=M;
        }
        t<<=1;
        a*=a;
        a%=M;
    }
    return ans;
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d)cout<<"Yes";
    else cout<<"No";
    return 0;
} 

Measured memory_bytes: 3632
a,b=map(int, input().split())

xa=int(12.5*a-0.0001)+1
xb=10*b
x=max(xa,xb)
ra=int(x*0.08)
rb=int(x*0.1)

if ra==a and rb==b:
    print(x)
else:
    print(-1)

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

int N, K, Q;
int A[2010];
int res=1000000000;
int idx[2010];

bool cmp(int aa, int bb)
{
	return A[aa] < A[bb];
}

int calc(int ii, int jj)
{
	int i;
	int bN = 0, s = 0;
	int d = A[idx[ii]], u = A[idx[jj]];
	int c = 0;
	for(i=0; i<N; i++){
		if(A[i] < d){
			bN = s = 0;
			continue;
		}
		if(A[i] > u)
			bN ++;
		else
			s ++;
		if(bN >= K)
			bN --;
		if(bN + s == K){
			s --;
			c ++;
		}
	}
	if(c >= Q)
		return 1;
	else
		return 0;
}

int bsrch(int ii)
{
	int l=ii, r=N;
	int m;
	while(l<r){
		m = (l+r)/2;
		if(calc(ii, m) == 1)
			r = m;
		else
			l = m+1;
	}
	return l;
}

void solve()
{
	int i;
	for(i=0; i<N; i++)
		idx[i] = i;
	sort(idx, idx+N, cmp);
	int l, tmp;
	for(i=0; i<N; i++){
		l = bsrch(i);
		if(l < N){
			tmp = A[idx[l]] - A[idx[i]];
			if(tmp < res)
				res = tmp;
		}
	}
	printf("%d\n", res);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	int i;
	scanf("%d%d%d", &N, &K, &Q);
	for(i=0; i<N; i++)
		scanf("%d", &A[i]);
	solve();
	return 0;
}

Measured memory_bytes: 128
from itertools import chain
import numpy as np
import networkx as nx

h, w, *X = map(int, open(0).read().split())
C = np.array(X[:100], dtype=int).reshape((10, 10))
A = np.array(X[100:], dtype=int).reshape((h, w))

G = nx.DiGraph(C)
d = {-1:0}
for i in range(10):
    d[i] = nx.shortest_path_length(G, i, 1, weight='weight')
print(sum(d[a] for a in chain.from_iterable(A)))

Measured memory_bytes: 56424
n = gets.to_i
d, x = gets.split.map(&:to_i)
a = []
n.times do
  a << gets.to_i
end

sum = 0
n.times do |i|
  t = 1
  while t <= d do
    sum += 1
    t += a[i]
  end
end
puts sum + x

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {
	
	int n;
	cin >> n;
	int pre = 0;
	bool ok = true;
	rep(i, n) {
		int h;
		cin >> h;
		if (pre > h)ok = false;
		if (pre < h)h--;
		pre = h;
	}
	
	cout << (ok ? "Yes" : "No") << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <stack>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;

void printarray(int n, int a[])
{
    for (int i = 0; i < n; i++)
    {
        cout << a[i];
        if (i != n - 1)
            cout << " ";
    }
    cout << endl;
}

void swaprange(int b, int t, int e, int a[])
{
    for (int i = 0; i < e - b; i++)
    {
        swap(a[b + i], a[i + t]);
    }
}

int main()
{
    int n, p;
    p = -1000000000-1;
    cin >> n;
    int a[n];
    vector<int> b;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    for (int i = 0; i < n; i++)
    {
        if (a[i] != p){
            b.push_back(a[i]);
            p = a[i];
        }
    }
    int lc = b.size();
    int c[lc];
    int k = 0;
    for (auto itr = b.begin(); itr != b.end(); itr++){
        c[k] = *itr;
        k++;
    }
    printarray(lc,c);
    return 0;
}


Measured memory_bytes: 4228
#include <cstdio>
#include <cmath>
int n;
double x[1005], y[1005], X, Y, d, e;
double dist(double a, double b) {
	return a*a + b*b;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf%lf", &x[i], &y[i]);
		X += x[i]; Y += y[i];
	}
	X /= n; Y /= n;
	double P = 0.1;
	for (int i = 0; i < 30000; i++) {
		int f = 0;
		d = dist(X - x[0], Y - y[0]);
		for (int j = 1; j < n; j++) {
			e = dist(X - x[j], Y - y[j]);
			if (d < e) { d = e; f = j; }
		}
		X += (x[f] - X)*P;
		Y += (y[f] - Y)*P;
		P *= 0.999;
	}
	printf("%.20lf\n", sqrt(d));
}


Measured memory_bytes: 384
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpln(n)
q = deque([])

for i,j in enumerate(a):
  if i == 0:
    q.append(j)
    continue
  c = bisect.bisect_left(q,j)
  if c == 0:
    q.appendleft(j)
  else:
    q[c-1] = j
    
print(len(q))
  


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

int main()
{
  int n;
  cin >> n;
  vector<int> l(n);
  vector<int> r(n);
  vector<int> check(100000);
  int i, j;
  for(i = 0; i < n; i++)
  {
    cin >> l.at(i) >> r.at(i);
  }
  for(i = 0; i < n; i++)
  {
    for(j = l.at(i)-1; j <= r.at(i)-1; j++)
    {
      check.at(j)++;
    }
  }
  int count = 0;
  for(i = 0; i < 100000; i++)
  {
    if(check.at(i) != 0)
    {
      count++;
    }
  }
  cout << count << endl;
}

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

// Macros
#define F      first
#define S      second
#define PB     push_back
#define MP     make_pair
#define ALL(c) c.begin(),c.end()

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = std::pair <int,int>;

// Random
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/* [a,b] */ template<class T> T rnd_IntType(T a, T b){ return uniform_int_distribution<T>(a, b)(rng); }
/* [a,b) */ template<class T> T rnd_RealType(T a, T b){ return uniform_real_distribution<T>(a,b)(rng); }

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m; ll y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// Output, Common Containers
template <typename T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const deque<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef LOCAL
	#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); d__f(_it, args); }
	void d__f(istream_iterator<string> it) {}
	template<typename Head, typename... Tail> void d__f(istream_iterator<string> it, Head H, Tail... T) { cerr << *it << " <=> [" << H << "]\n"; d__f(++it, T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

const int mod = 998244353;

ll add(ll a, ll b) { return (a + b) % mod; }
ll sub(ll a, ll b) { return (a - b) % mod; }
ll mul(ll a, ll b) { return (a * b) % mod; }

signed main() {
	std::ios::sync_with_stdio(false); //Warning: Do NOT use C I/O now.
	std::cin.tie(nullptr); //Note: Comment out this line for interactive questions.
	// std::cout.setf(std::ios::fixed); std::cout.precision(20); //Note: To output decimals correctly.

	// int t; cin>>t;
	// for(int test_no = 1; test_no <= t; ++test_no){}

	int n, W;
	cin>>n>>W;

	vector<ll> w(n), v(n);
	for(int i=0; i<n; ++i) cin>>w[i]>>v[i];

	int V = accumulate(ALL(v),0LL);

	vector<vector<ll>> dp(n, vector<ll>(V+1, 4e18));
	dp[0][0] = 0;
	dp[0][v[0]] = w[0];

	for(int i=1; i<n; ++i)
		for(int j=0; j<=V; ++j){
			dp[i][j] = min(dp[i][j], dp[i-1][j]);
			if(j+v[i] <= V) dp[i][j+v[i]] = min(dp[i][j+v[i]], dp[i-1][j]+w[i]);
		}

	int res = -1;
	for(int i=0; i<=V; ++i)
		if(dp[n-1][i] <= W)
			res = max(res, i);

	// trace(V,dp[n-1]);

	cout<<res;
}

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int k,n; cin>>k>>n;
	if(k>=n)
	{
		cout<<0<<"\n";
		return 0;
	}
	vector<int> v(n),d(n-1);
	for(int i=0;i<n;i++) cin>>v[i];
	sort(v.begin(),v.end());
	for(int i=0;i<n-1;i++) d[i]=v[i+1]-v[i];
	sort(d.begin(),d.end());
	long long s=0;
	for(int i=0;i<n-k;i++) s+=d[i];
	cout<<s<<"\n";
	return 0;
}

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

using namespace std;

map<char,int> vis;
map<char,int> bja;
map<char,int> bj;
map<char,int> lenu;
string sp[123];

void hh(string s) {
    bj.clear();
    int len=s.size();
    for(int i=0; i<len; i++) {
        bj[s[i]]++;
    }
    string y="";
    for(char ch='a'; ch<='z'; ch++) {
        if(bj[ch]&&bja[ch]) {
            vis[ch]++;
            lenu[ch]=min(lenu[ch],min(bj[ch],bja[ch]));
        }
    }
}

int main() {
    for(char ch='a';ch<='z';ch++) {
        lenu[ch]=12345567;
    }
    bja.clear();
    vis.clear();
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++) {
        cin>>sp[i];
    }
    int len=sp[0].size();
    for(int i=0; i<len; i++) {
        bja[sp[0][i]]++;
    }
    if(n==1) {
        sort(sp[0].begin(),sp[0].end());
        cout<<sp[0]<<endl;
        return 0;
    }
    for(int i=1; i<n; i++) {
        hh(sp[i]);
    }
    string p="";
    int flag=0;
    for(char ch='a';ch<='z';ch++) {
        if(vis[ch]>=n-1) {
            flag=1;
            for(int i=0;i<lenu[ch];i++) {
                p+=ch;
            }
        }
    }
    if(flag) cout<<p<<endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
tree = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)

for i in range(N):
    print(len(tree[i]))

Measured memory_bytes: 9132
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000100
#define mod 1000000007
using namespace std;
char a[maxn];
int n,q,k;
ll ans=0;
void sol(){
	ans=0;
	ll d=0,dm=0,m=0;
	for(int i=0;i<n;i++){
		if(i>=k){
			if(a[i-k]=='D'){
				dm-=m;
				d--;
			}
			if(a[i-k]=='M') m--;
		}
		if(a[i]=='C') ans+=dm;
		if(a[i]=='D') d++;
		if(a[i]=='M') dm+=d,m++;
	}
}
int main(){
	scanf("%d",&n);
	scanf("%s",a);
	scanf("%d",&q);
	while(q--){
		scanf("%d",&k);
		sol();
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1280
import java.util.*

fun main(args: Array<String>) {
    val result = solve(Scanner(System.`in`))
    if (result.isNotEmpty()) println(result)
}

const val MOD = 1000000007L

// b で割る = 1/b を掛ける
// フェルマーの小定理より、b の逆数 1/b (mod P) = b^(P-2)
fun modDiv(a: Long, b: Long): Long = (a * modPow(b, MOD - 2)) % MOD

// O(log p) で累乗 (mod P)
fun modPow(a: Long, p: Long): Long = when {
    p == 0L -> 1
    p % 2 == 1L -> (a * modPow(a, p - 1)) % MOD
    else -> {
        val half = modPow(a, p / 2)
        (half * half) % MOD
    }
}

/**
 * Combination aCb (mod P)
 */
fun modComb(a: Long, b: Long): Long =
    if (b > a - b)
        modComb(a, a - b)
    else
        modDiv(
            (0L until b).fold(1L) { acc, i -> (acc * (a - i)) % MOD },
            (1L..b).fold(1L) { acc, i -> ((acc * i) % MOD) }
        )

fun solve(sc: Scanner): String {
    val X = sc.nextInt()
    val Y = sc.nextInt()

    if ((X + Y) % 3 != 0) {
        return "0"
    }
    val a = ((2 * Y) - X) / 3
    val b = ((2 * X) - Y) / 3
    if (b < 0 || a < 0) {
        return "0"
    }

    return modComb((a + b).toLong(), b.toLong()).toString()
}


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

using namespace std;
typedef long long ll;
const int M = 1000000007, N = 200'010;
ll pw[N];

ll gcd(ll a, ll b) {
    if (!b) return a;
    return gcd(b, a % b);
}

int main() {
    pw[0] = 1;
    for (int i = 1; i < N; i++) pw[i] = pw[i - 1] * 2 % M;
    int n;
    scanf("%d", &n);
    map<pair<ll, ll>, pair<int, int>> m;
    ll a = M - 1;
    for (int i = 0; i < n; i++) {
        ll x, y;
        scanf("%lld%lld", &x, &y);
        if (x < 0) x = -x, y = -y;
        if (x == 0) y = abs(y);
        if (x == 0 && y == 0) {
            a++;
            continue;
        }
        ll g = gcd(abs(x), abs(y));
        x /= g, y /= g;
        if (y > 0) m[{x, y}].first++;
        else m[{-y, x}].second++;
    }
    ll r = 1;
    for (auto &[key, val] : m) {
        r = r * (pw[val.first] + pw[val.second] - 1) % M;
    }
    printf("%lld\n", (a + r) % M);
}


Measured memory_bytes: 17744
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  rep(i,N) cin >> H[i];
  int ans = 0;
  int temp = 0;
  rep(i,N-1) {
    if (H[i] >= H[i+1]) ++temp;
    else {
      ans = max(ans, temp);
      temp = 0;
    }
  }
  ans = max(ans, temp);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3184
import java.util.Scanner;

//Best Pizza
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt(), P = A+n*B;
		int[] c = new int[n+1];
		for(int i=1;i<=n;i++)c[i]=sc.nextInt();
		int[][] dp = new int[n+1][P+1];
		for(int p=A;p<=P;p++)dp[0][p] = C;
		for(int i=1;i<=n;i++)for(int p=A;p<=P;p++){
			dp[i][p] = dp[i-1][p];
			if(A+B<=p)dp[i][p] = Math.max(dp[i][p], dp[i-1][p-B]+c[i]);
		}
		int max = 0;
		for(int p=A;p<=P;p++)max = Math.max(max, dp[n][p]/p);
		System.out.println(max);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include<iostream>

using namespace std;

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

    int h = S / (60 * 60);
    int m = (S % (60 * 60)) / 60;
    int s = S % 60;

    cout << h << ":" << m << ":" << s << endl;
    return 0;
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

 
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<vector<int>> V(N+1, vector<int>(0));
  rep(i,M){
    int A,B;
    cin >> A >> B;
    V[A].push_back(B);
    V[B].push_back(A);
  }
  
  vector<bool> visited(N+1, false);
  int cnt = 0;
  
  for(int i = 1;i<=N;i++){
    if(visited[i]) continue;
    
    //cout << i << endl;
    cnt++;
    
    if(V[i].empty()) continue;
    
    //cout << 'c' << endl;
    queue<int> que;
    que.push(i);
    visited[i]=true;
    
    while(!que.empty()){
      int v = que.front();
      que.pop();
      
      //cout << v << 'p' << endl;
      for(int nv : V[v]){
        //cout << nv << "r" << endl;
        if(visited[nv]) continue;
        visited[nv]=true;
        que.push(nv);
      }
    }
    
  }
  cout << cnt-1 << endl;
}      
       



Measured memory_bytes: 8540
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

int main(void){
	scanf("%d %d",&n,&t);
	FOR scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=t;i++)cev+=a[i];
	printf("%d\n",cev);
	return 0;
}



Measured memory_bytes: 3780
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <vector>
#include <climits>
#include <queue>
#include <utility>
#include <iomanip>
#include <sstream> 
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<typename T1, typename T2>
inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2>
inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
const ll MOD = 1000000007;
const ll INF = 1LL << 60;




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


    ll c[10][10];
    char ch;
    
    rep(i, h) {
        rep(j, w) {
            cin >> ch;
            if (ch == '#')
                c[i][j] = 1;
            else if(ch == '.')
                c[i][j] = 0;
        }
    }

    /*rep(i, h) {
        rep(j, w) {
            cout << c[i][j];
        }
        cout << endl;
    }*/
    
    ll ans = 0;
    ll count;
    for (int ibit = 0; ibit < (1 << h); ++ibit)
    {
        for (int jbit = 0; jbit < (1 << w); ++jbit) {
            //cout << ibit << " " << jbit << endl;
            count = 0;
            rep(i, h) {
                rep(j, w) {
                    if (((ibit & (1 << i)) == 0) && ((jbit & (1 << j)) == 0) && c[i][j]) {
                        count += c[i][j];
                        //cout << ibit << " " << jbit << endl;
                    }

                }
            }
            if (count == k)
                ans++;

        }
    }

    cout << ans;
}




Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
#define sub(T,S) for(int T=(S-1)&S;T;T=(T-1)&S)
using namespace std;
const int maxn=1e5+10;
int n,a[maxn],d[maxn],chc[1<<15],dp[1<<15],ans,u,v,w,W;
int main(){
    scanf("%d",&n);
    rep(i,1,n-1) scanf("%d%d%d",&u,&v,&w),a[u+1]^=w,a[v+1]^=w;
    rep(i,1,n) ++d[a[i]];
    rep(i,1,15) ans+=d[i]>>1,W|=(d[i]&1)<<(i-1);
    rep(i,0,14) rep(S,0,(1<<15)-1) if(S&(1<<i)) chc[S]^=i+1,++dp[S];
    rep(S,1,(1<<15)-1){
        if(chc[S]) continue;--dp[S];
        sub(T,S) if(!chc[T]) dp[S]=min(dp[S],dp[T]+dp[S^T]);
    }
    printf("%d\n",dp[W]+ans);
    return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int[][] rl = new int[s.length()][2];
        int i = 0;
        int j = 0;
        while (i < s.length()) {
            while (i < s.length() && s.charAt(i) == 'R') {
                rl[j][0]++;
                i++;
            }
            while (i < s.length() && s.charAt(i) == 'L') {
                rl[j][1]++;
                i++;
            }
            j++;
        }
        int[] ans = new int[s.length()];
        int m = 0;
        for (int k = 0; k < s.length() - 1; k++) {
            if (s.charAt(k) != 'R' || s.charAt(k + 1) != 'L') {
                ans[k] = 0;
                continue;
            }
            ans[k] = (rl[m][0] + 1) / 2 + rl[m][1] / 2;
            ans[k + 1] = rl[m][0] / 2 + (rl[m][1] + 1) / 2;
            m++;
            k++;
        }

        StringJoiner sj = new StringJoiner(" ");
        for (int k = 0; k < ans.length; k++) {
            sj.add(String.valueOf(ans[k]));
        }
        System.out.println(sj.toString());
    }

}


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

int main() {
  int n; cin >> n;
  vector<int> a(n); rep(i, n) cin >> a[i];
  rep(i, n) {
    if (a[i] % 2 == 0) {
      if (a[i] % 3 == 0 || a[i] % 5 == 0);
      else {
        cout << "DENIED";
        return 0;
      }
    }
  }
  cout << "APPROVED";
  return 0;
}

Measured memory_bytes: 256
//atcoder clange
#include <stdio.h>

int main(void){
    int r,D,x2000;
      scanf("%d", &r);//数値の取得
      scanf("%d", &D);//数値の取得
      scanf("%d", &x2000);//数値の取得

	int x[10];
  	int i=0;
  
  	x[0] = r*x2000 -D;
  	printf("%d\n",x[0]);
  	for(i=1;i<10;i++){
		x[i] = r * x[i-1] -D;
      printf("%d\n",x[i]);
    }
  	
    //int max = max(a, N);
    return 0;
}




Measured memory_bytes: 128
#include<iostream>
using namespace std;
 
int gcd(int a,int b){
  if(b==0){
    return a;
  }
 
  return gcd(b,a%b);
}
 
int main(){
  int W,H,C;
 
  cin >> W >> H >> C;
 
  int g=gcd(W,H);
  int ans=(W*H)/(g*g);
 
  cout << ans*C << endl;
 
  return 0;
}


Measured memory_bytes: 3124
import java.util.ArrayList;
import java.util.Collections;
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		ArrayList<Integer> nums=new ArrayList<Integer>(N);
		for(int i=0;i<N;i++) {
			nums.add(sc.nextInt());
		}
		int ans=0;
		while(true)
		{
			
			int max=Collections.max(nums);
			if(max==0) {
				break;
			}
			int index=nums.indexOf(max);
			while(true) {
				nums.set(index, max-1);
				if(index==N-1) {
					break;
				}else if(nums.get(index)==nums.get(index+1)-1) {
					index+=1;
				}else {
					break;
				}
			}
			ans++;
			
		}
		System.out.println(ans);
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

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

    int ans = INT_MAX;
    for(long long int a=1;a*a<=n;++a){
        long long int b = n / a;
        if(a*b != n)continue;
        long long int a_ = a, b_ = b;
        int da = 0, db = 0;
        while(a_ > 0){
            a_ /= 10;
            da++;
        }
        while(b_ > 0){
            b_ /= 10;
            db++;
        }
        ans = min(ans, max(da, db));
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
	int k;cin>>k;
	int num=7,count=0;
	while((count++)<1e8) {
		if(num%k==0) {
			cout<<count<<"\n";
			return 0;
		}
		num = (num*10+7)%k;
	}
	cout<<-1<<"\n";
	return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <cmath>
#define PI 3.14159265358979323846264338327950L
using namespace std;

int main(){
  int A;
  int B;
  int H;
  int M;
  long double C,f;
  cin >> A >> B >> H >> M;
  
  f = 2.0* PI*((long double)H/12 + ((long double)M/60)/12 - (long double)M/60);
  
  C = (long double)(A*A + B*B) - (long double)(2.0*A*B)*cosl(f);
  
  printf("%20.20Lf\n", sqrtl(C));

}


Measured memory_bytes: 4100
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m, x, y int
	fmt.Scan(&n, &m, &x, &y)

	xs := make([]int, n+1)
	ys := make([]int, m+1)
	for i := 0; i < n; i++ {
		fmt.Scan(&xs[i])
	}
	xs[n] = x
	for i := 0; i < m; i++ {
		fmt.Scan(&ys[i])
	}
	ys[m] = y

	sort.Ints(xs)
	sort.Ints(ys)

	if xs[n] < ys[0] {
		fmt.Println("No War")
	} else {
		fmt.Println("War")
	}
}


Measured memory_bytes: 512
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	double a;
	cin>>a;
	cout<<shosu(9)<<a*PI*2<<endl;
}











Measured memory_bytes: 3792
#include<iostream>
#include<cstdio>
using namespace std;
int mas[100][100];
int dx[8]={1,1,0,-1,-1,-1,0,1},dy[8]={0,1,1,1,0,-1,-1,-1};
int sx,sy,gx,gy,w,h,cnt=0;
void dfs(int x,int y);
int main(){
  while(1){
    cnt=0;
  cin >> w >> h;
  if(w==0 && h==0) break;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> mas[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(mas[i][j]==1){
        cnt++;
        dfs(j,i);
      }
    }
  }
  cout << cnt << endl;
  }
}
void dfs(int x,int y){
  mas[y][x]=0;
  for(int i=0;i<8;i++){
    int nx=x+dx[i];
    int ny=y+dy[i];
    if(nx >= 0&& nx < w && ny >= 0 && ny < h && mas[ny][nx]==1){
        dfs(nx,ny);
      }
  }
}

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


int main() {
  int N,M;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  
  for(int i= 0;i<M;i++){
   cin >> L[i];
   cin >> R[i];
 }
  sort(L.begin(),L.end());
  sort(R.begin(),R.end());
  int Lmax = 0;
  int Rmin = 0;
  
  Lmax = L[M-1];//共通区間の左端
  Rmin = R[0];//共通区間の右端
  if(Lmax <= Rmin) cout << Rmin-Lmax+1<< endl;
  else cout << 0 << endl;
  
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s;cin>>s;
  int l,r;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'){
      l=i;
      break;
    }
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s[i]=='Z'){
      r=i;
      break;
    }
  }
  cout<<(r-l)+1<<endl;

  return 0;
}


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

int main(int argc, char const *argv[])
{
	long long a,b;
	cin>>a>>b;
	long long ans=0LL;
	ans+=(((b>>1)-(a>>1))^(b&1))%2;
	int n=1;
	while ((a>>n)|(b>>n))
	{
		ans+=(long long)((((a>>n)&(a&1LL))^(((b>>n)&(~(b%2LL)&1))))<<n);
		++n;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
    string A, B;
    cin >> A >> B;
    if (A.size() > B.size()) cout << "GREATER" << endl;
    else if (A.size() < B.size()) cout << "LESS" << endl;
    else {
        if (A > B) cout << "GREATER" << endl;
        else if (A < B) cout << "LESS" << endl;
        else cout << "EQUAL" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <cmath>
#include <stack>
#include <vector>
#include <string>
#include <complex>
#include <iostream>
using namespace std;

vector<string> to_postfix(string exp) {
	map<char,int> pd {{'+',0},{'-',0},{'*',1},{'/',1}};
	stack<char> op;
	vector<string> pf;
	string num;
	for (auto c = exp.begin();c != exp.end();++c) {
		if ((*c >= '0' && *c <= '9') || *c == 'i') {
			if (!(num == "0" && *c == '0')) {
				num.push_back(*c);
			}
		} else {
			if (!num.empty()) {
				if (num.front() == '0' && num.size() != 1) {
					num.erase(0,1);
				}
				pf.push_back(num);
				num.clear();
			}
			switch (*c) {
				case '(':
					op.push('(');
					break;
				case ')':
					while (op.top() != '(') {
						pf.push_back(string().assign(1,op.top()));
						op.pop();
					}
					op.pop(); // pop '('
					break;
				default: // '+','-','*','/'
					while (!op.empty() && op.top() != '(' && pd[op.top()] >= pd[*c]) {
						pf.push_back(string().assign(1,op.top()));
						op.pop();
					}
					op.push(*c);
			}
		}
	}
	if (!num.empty()) {
		pf.push_back(num);
	}
	while (!op.empty()) {
		pf.push_back(string().assign(1,op.top()));
		op.pop();
	}
	return pf;
}

bool is_overflow(long long n) {
	return n > 10000ll || n < -10000ll;
}

string calculate(vector<string> pf) {
	stack< complex<int> > ans; // stack of answers of calculation
	bool overflow = false;
	for (auto i = pf.begin();i != pf.end();++i) {
		complex<int> first,second;
		if (i->back() == 'i') {
			if (i->size()-1 > 10) {
				overflow = true;
				break;
			}
			long long image = *i == "i" ? 1l : stoll(i->substr(0,i->size()-1));
			if (is_overflow(image)) {
				overflow = true;
				break;
			}
			ans.push(complex<int>(0,static_cast<int>(image)));
		} else if (i->back() >= '0' && i->back() <= '9') {
			if (i->size() > 10) {
				overflow = true;
				break;
			}
			long long real = stoll(*i);
			if (is_overflow(real)) {
				overflow = true;
				break;
			}
			ans.push(complex<int>(static_cast<int>(real),0));
		} else {
			complex<int> second = ans.top();
			ans.pop();
			complex<int> first = ans.top();
			ans.pop();
			complex<int> res;
			switch (i->back()) {
				case '+':
					res = first + second;
					break;
				case '-':
					res = first - second;
					break;
				case '*':
					res = first * second;
					break;
				case '/':
					res = first / second;
			}
			if (is_overflow(res.real()) || is_overflow(res.imag())) {
				overflow = true;
				break;
			}
			ans.push(res);
		}
	}
	string result;
	if (overflow) {
		result = "overflow";
	} else {
		auto com = ans.top();
		if (com.real() == 0 && com.imag() == 0) {
			result = "0";
		} else if (com.real() == 0) {
			result = to_string(com.imag()) + "i";
		} else if (com.imag() == 0) {
			result = to_string(com.real());
		} else {
			result = to_string(com.real()) + (com.imag() < 0 ? "-" : "+") + to_string(abs(com.imag())) + "i";
		}
	}
	return result;
}

int main() {
	string exp;
	while (cin >> exp) {
		cout << calculate(to_postfix(exp)) << endl;
	}
}

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

int n, x;

int main()
{
    int res = 1;
    int cur = 0;
    scanf("%d %d", &n, &x);
    for (int i = 0; i < n; i++) {
        int a; scanf("%d", &a);
        cur += a;
        if (cur <= x) res++;
        else break;
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
using namespace std;
typedef long long ll;
int inf = 1000000000;
int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if ((a[1] - a[0]) % 2 == 0) {
		if ((a[2] - a[1]) % 2 == 0)cout << (a[2] - a[1]) / 2 + (a[2] - a[0]) / 2 << endl;
		else cout << (a[2] - a[1]) / 2 + (a[2] - a[0]) / 2 + 1 << endl;
	}
	else {
		if ((a[2] - a[1]) % 2 == 0)cout << (a[2] - a[1] + 1) / 2 + (a[2] - a[0]) / 2 + 2 << endl;
		else cout << (a[2] - a[1] + 1) / 2 + (a[2] - a[0]) / 2 + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int n;
int x[1003], p[1003];
VI adj[1003];

PII DP(int at) {
	VP V;
	for (int v : adj[at]) {
		PII z = DP(v);
		if (z.first == -1) return z;
		V.push_back(z);
	}

	VI dp(5003, 1000000000);
	dp[0] = 0;
	for (PII v : V) {
		VI ndp(5003, 1000000000);
		for (int i = 0; i <= 5000; i++) {
			int ni = i + v.first;
			if (ni <= 5000) ndp[ni] = MIN(ndp[ni], dp[i] + v.second);
			ni = i + v.second;
			if (ni <= 5000) ndp[ni] = MIN(ndp[ni], dp[i] + v.first);
		}
		dp = ndp;
	}

	int z = 1000000000;
	for (int i = 0; i <= x[at]; i++) {
		z = MIN(z, dp[i]);
	}
	if (z == 1000000000) return PII(-1, -1);
	return PII(z, x[at]);
}

int main()
{
	scanf("%d", &n);
	for (int i = 2; i <= n; i++) {
		scanf("%d", &p[i]);
		adj[p[i]].push_back(i);
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", &x[i]);
	}

	PII z = DP(1);
	if (z.first == -1) {
		printf("IMPOSSIBLE\n");
	}
	else {
		printf("POSSIBLE\n");
	}

	return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

void trace(int A[], int n)
{
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << A[i];
	}

	cout << endl;
}

int main()
{
	int n;
	int A[100];
	int key;

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

	trace(A, n);
	int j;
	for (int i = 1; i < n; i++) {
		key = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > key) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = key;
		trace(A, n);
	}

	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

signed main(){
	int n, k;
	string s;
	cin >> n >> k >> s;

	vector<int> p, b;
	int t = s.front() - '0';
	int cnt = 0;
	rep(i,n){
		if(s[i] == t + '0'){
			cnt++;
		}else{
			p.emplace_back(cnt);
			b.emplace_back(t ^ 1);
			cnt = 1;
			t ^= 1;
		}
	}
	if(cnt != 0){
		p.emplace_back(cnt);
		b.emplace_back(t ^ 1);
	}

	//for(auto i : p) cout << i << ' '; cout << endl;

	int left = 0, right = 0;
	int ksum = 0, sum = 0;
	int ans = 0;
	while(left < p.size() and right < p.size()){
		while(right < p.size() && ksum + b[right] <= k){
			sum += p[right];
			ksum += b[right];
			right++;
		}
		ans = max(ans, sum);

		while(ksum == k){
			sum -= p[left];
			ksum -= b[left];
			left++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int d, n;
    scanf("%d%d", &d, &n);
    if (n == 100)n++; //eg.d=1,n=100でn*100をすると10,000になり、100で2回割れることになるから
    if(d == 0) {
        printf("%d\n", n);
    }
    else if (d == 1) {
        printf("%d\n", n * 100);
    }
    else printf("%d\n", n * 10000);
    return 0;
}

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

template< typename T >
T extgcd(T a, T b, T &x, T &y) {
  T d = a;
  if(b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}

int main(){
    long long int a, b;
    cin >> a >> b;
    long long int x, y;
    long long int ans = a / extgcd(a, b, x, y);
    ans *= b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
H,W = list(map(int,input().split()))

S=[input() for i in range(H)]
color1 = -1
color_list1 = [[-1 for j in range(W)] for i in range(H)]
color_num1 = [0 for i in range(H*W)]
flag=True
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            flag=True
        else:
            if j==0:
                flag=True
            if flag:
                color1+=1
                color_list1[i][j]=color1
                color_num1[color1]+=1
                flag=False
            else:
                color_list1[i][j]=color1
                color_num1[color1]+=1

color2 = -1
color_list2 = [[-1 for j in range(W)] for i in range(H)]
color_num2 = [0 for i in range(H*W)]
flag=True
for j in range(W):
    for i in range(H):
        if S[i][j]=="#":
            flag=True
        else:
            if i==0:
                flag=True
            if flag:
                color2+=1
                color_list2[i][j]=color2
                color_num2[color2]+=1
                flag=False
            else:
                color_list2[i][j]=color2
                color_num2[color2]+=1
ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            ans=max(color_num1[color_list1[i][j]]+color_num2[color_list2[i][j]]-1,ans)

print(ans)


Measured memory_bytes: 279488
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  int A, B;
  cin >> A >> B;
  int x[3] = {A, B, A+B};
  for (auto i = 0; i < 3; ++i) {
    if (x[i]%3 == 0) {
      cout << "Possible" << endl;
      return 0;
    }
  }
  cout << "Impossible" << endl;
  return 0;
}


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

char a[60],b[60];
int c[60],d[60];

long long dp[60];

const long long mod = 1e9 + 7;

int main()
{
    int n;

    int cnt = 0;
    int pos = 0;

    scanf("%d",&n);

    scanf("%s",a);
    scanf("%s",b);

    for (int i = 0;i < n; )
    {
        if (a[i] == b[i])
        {
            c[pos] = d[pos] = cnt++;
            pos++;
            i++;
        }
        else
        {
            c[pos] = cnt++;
            d[pos] = cnt++;
            pos++;
            i += 2;
        }
    }

    if (c[0] == d[0]) dp[0] = 3;
    else dp[0] = 6;

    for (int i = 1;i < pos;i++)
    {
        if (c[i-1] == d[i-1])
        {
            dp[i] = (dp[i-1] % mod) * 2 % mod;
        }
        else
        {
            if (c[i] == d[i]) dp[i] = dp[i-1];
            else dp[i] = (dp[i-1] % mod) * 3 % mod;
        }
    }

    printf("%lld\n",dp[pos-1]);

    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

/*
動作確認
*/


class Program
{
	static int H,W,K,ans;
	static char[][] grid;

	//全探索
	static void Search(int cnt, List<int> selectedH, List<int> selectedW){
		if(cnt < H){
			List<int> Hls = new List<int>(selectedH);
			Hls.Add(cnt);
			cnt ++;
			Search(cnt, Hls, selectedW);
			Search(cnt, selectedH, selectedW);
		}
		else if(cnt < H + W){
			List<int> Wls = new List<int>(selectedW);
			Wls.Add(cnt - H);
			cnt ++;
			Search(cnt, selectedH, Wls);
			Search(cnt, selectedH, selectedW);
		}
		else{
			Solve(selectedH, selectedW);
		}
	}

	//答えを出す
	static void Solve(List<int> selectedH, List<int> selectedW){
		int cnt = 0;

		for(int i=0; i<H; i++){
			if(selectedH.Contains(i)){
				continue;
			}
			else{
				for(int j=0; j<W; j++){
					if(selectedW.Contains(j)){
						continue;
					}
					else{
						if(grid[i][j] == '#'){
							cnt ++;
						}
					}
				}
			}
		}

		if(cnt == K){
			ans ++;
		}
	}

	//Main
	static void Main(string[] args)
	{
		//読み込む
		string[] S = Console.ReadLine().Split(' ');
		H = int.Parse(S[0]);
		W = int.Parse(S[1]);
		K = int.Parse(S[2]);

		grid = new char[H][];

		//読み込む
		for(int i=0; i<H; i++){
			string line = Console.ReadLine();
			grid[i] = new char[H];
			grid[i] = line.ToCharArray();
		}

		//計算させる
		List<int> Hls = new List<int>();
		List<int> Wls = new List<int>();
		Search(0, Hls, Wls);

		Console.WriteLine(ans);
	}
}



Measured memory_bytes: 18444
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll mod = 1'000'000'007;
// constexpr int max_n = 200'000 + 5;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    int k; cin >> k;
    ll res = 0;
    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++)
        {
            for (int c = 1; c <= k; c++)
            {
                res += gcd(gcd(a,b), c);
            }
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3616
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
const long long int N = 6999999;
#define all(x) begin(x),end(x)
#define ll long long int
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
using namespace std;

int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n,m,c=0,s=0,a;
  cin >> n >> m;
  vector < int > v(n);
  for (int i = 0; i < n; ++i)
  {
    cin >> v[i];
    s += v[i];
  }
  for (int i = 0; i < n; ++i)
  {
    if(v[i]*4*m >= s)
        c++;
  }
  if (c >= m)
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
prev = 99
for i in a:
    ans += b[i-1]
    if prev == i-1:
        ans += c[prev-1]
    prev = i

print(ans)


Measured memory_bytes: 38516
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 1000
using namespace std;
int main() {
  string a, b, c;
  cin >> a >> b >> c;
  cout << char(a[0] + ('A'-'a')) << char(b[0] + ('A'-'a')) << char(c[0] + ('A'-'a'))<< endl;
  return 0;
}


Measured memory_bytes: 256