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

using namespace std;

using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

void setIO(string name = ""){
    freopen((name+".in").c_str(), "r", stdin); 
    freopen((name+".out").c_str(), "w", stdout);
}


int main(){
 	ios_base::sync_with_stdio(0); cin.tie(0); 
	// setIO();
    ll n, a[87], cm = 1000; cin >> n;
    for(int i{1}; i<=n; i++) cin >> a[i];

 
    for(int i{1}; i<=n-1; i++){
        ll stock{};
        if(a[i]<a[i+1])
            stock = cm/a[i];

        cm += (a[i+1] - a[i]) * stock;
    }

    cout << cm << "\n";
}


Measured memory_bytes: 3664
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<a;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1);
const double inf = (int)1e8;

void solve(){
  int N;
  int sa,ga,sb,gb,disa,disb,sum;
  
  cin>>N>>sa>>ga>>sb>>gb;
  --sa,--ga,--sb,--gb;
  sum=N*2;
  loop(i,1,N+1){
    disa=abs((sa/i)-(ga/i))+abs((sa%i)-(ga%i));
    disb=abs((sb/i)-(gb/i))+abs((sb%i)-(gb%i));
    sum=min(sum,disa+disb);
  }
  cout<<sum<<endl;
}
int main(void){
  solve();
  return 0;
}

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

int i,j,k,n,m;
double tab[150][150],len[150][150],ans;

int main(){
	while(scanf("%d %d",&n,&m)*n*m){
		for(i=0;i<n;i++){
			len[0][i]=1;
			for(j=0;j+9<n;j+=10)scanf("%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",&tab[i][j],&tab[i][j+1],&tab[i][j+2],&tab[i][j+3],&tab[i][j+4],&tab[i][j+5],&tab[i][j+6],&tab[i][j+7],&tab[i][j+8],&tab[i][j+9]);
			for(;j<n;j++){
				scanf("%lf",&tab[i][j]);
			}
		}

		ans=0;

		if(m==1){printf("1.00\n");continue;}

		for(k=1;k<m;k++){
			for(i=0;i<n;i++){
				len[k][i]=0;
				for(j=0;j<n;j++){
					if(len[k][i]<len[k-1][j]*tab[j][i])len[k][i]=len[k-1][j]*tab[j][i];
				}
				if(k==m-1 && ans<len[k][i])ans=len[k][i];
			}
		}

		printf("%.2lf\n",floor(ans*100+0.5)/100);

	}
	return 0;
}

Measured memory_bytes: 916
#include<stdio.h>
int main()
{
	int a,b,c,d;
	int cnt1,cnt2;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	cnt1=0;
	cnt2=0;
	while(1){
		if(a<=0) break;
		else{
			c=c-b;
			cnt1++;
		}
		if(c<=0) break;
		else{
			a=a-d;
			cnt2++;
		}
	}
	if(cnt1>cnt2) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 1636
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int consent = 1;
    int count = 0;
    while (consent < B) {
      consent += A - 1;
      count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 22736
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 1
/*------------------------------------------------------------*/

int main(){
	string s;
	cin>>s;
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')outy;
	 else outn;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define fi first
#define se second

int n,a[100005];

signed main(){
	cin >> n;
	for(int i = 1 ; i <= n ; i ++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	int dif = LONG_MAX, res = 1;
	for(int i = 1 ; i < n ; i ++)
		if(dif > abs(a[n] - 2*a[i]))
			dif = abs(a[n] - 2*a[i]), res = i;
	cout << a[n] << " " << a[res];
}


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

long long n,d[300],k,cnt,sum,res;
long long dp[301][90001][2];

int E869120(int p,int q){
	long long e=1;
	for(int i=0;i<q;i++){
		e*=p;
		e%=MOD;
	}
	return e;
}

void DP(int p){
	dp[0][0][0]=1;
	for(int i=1;i<=p;i++){
		for(int j=0;j<=90000;j++){
			for(int k=0;k<2;k++){
				if(dp[i-1][j][k]>=1){
					dp[i][j][k]+=dp[i-1][j][k];
					dp[i][j][k]%=MOD;
					dp[i][j+d[i-1]][(k+1)%2]+=dp[i-1][j][k];
					dp[i][j+d[i-1]][(k+1)%2]%=MOD;
				}
			}
		}
	}
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>d[i];
	}
	cin>>k;
	DP(n);
	res=0;
	for(int i=0;i<=k;i++){
		res+=(dp[n][i][0]*E869120(k-i,n))%MOD;
		res-=(dp[n][i][1]*E869120(k-i,n))%MOD;
		res=(res+MOD)%MOD;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 184888
#![allow(unused_imports)]
#![allow(non_snake_case)]
use proconio::{input, fastout};
use proconio::marker::{Chars, Bytes, Usize1};

use std::collections::HashSet;

#[fastout]
fn main() {
    input!{
        H:usize, W:usize, M:usize,
        bomb:[(Usize1, Usize1); M]
    }
    let mut f = vec![0; H];
    let mut g = vec![0; W];
    for &(y, x) in &bomb {
        f[y] += 1;
        g[x] += 1;
    }
    let &mh = f.iter().max().unwrap();
    let &mw = g.iter().max().unwrap();
    let mut fl = Vec::new();
    let mut gl = Vec::new();
    for i in 0..H {
        if f[i] == mh {
            fl.push(i);
        }
    }
    for i in 0..W {
        if g[i] == mw {
            gl.push(i);
        }
    }

    let mut hash = HashSet::new();
    for &v in &bomb {
        hash.insert(v);
    }
    for &y in &fl {
        for &x in &gl {
            if !hash.contains(&(y, x)) {
                println!("{}", mh + mw);
                return;
            }
        }
    }
    println!("{}", mh + mw - 1);
}


Measured memory_bytes: 30976
#include <stdio.h>
int main(int argc, char const *argv[])
{
	int a;
	scanf("%d",&a);
	if( a == 25){
		printf("Christmas");
	}else if( a == 24){
		printf("Christmas Eve");
	}else if( a == 23){
		printf("Christmas Eve Eve");
	}else{
		printf("Christmas Eve Eve Eve");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

#include <bits/stdc++.h>
using namespace std;
signed main(){
    int A,B; cin>>A>>B;
    Out(A*B);
}


Measured memory_bytes: 3648
#テストファイルで実行する時
import sys
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')

#2次元的な入れ方
h,w = map(int,input().split())
l = []
for i in range(h):
	x = list(input())
	#読み込む文字列xの中に#がある場合
	if '#' in x:
		l.append(x)
	else:
		h = h - 1

test = 0

for i in range(w):
	test = 0
	for j in range(h):
		if l[j][i] == '.':
			test = test + 1
	#print(test)
	if test == h :
		for k in range(h):
			l[k][i] = ''

for i in range(h):
	print(''.join(l[i]))


Measured memory_bytes: 3188
n,a,b = list(map(int, input().split()))
MOD = 10**9 + 7

from functools import lru_cache

MOD = 10**9+7
fact = [1]
fact_inv = [1]
fact_rev = [1]

for i in range(1, max(a,b)+1):
    fact.append(fact[i-1] * i % MOD)
    fact_inv.append(pow(fact[i], MOD-2, MOD))
    fact_rev.append(fact_rev[i-1] * (n-i+1) % MOD)

@lru_cache(maxsize=None)
def combi(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fact_rev[n] * fact_inv[k] % MOD

pattern = pow(2, n, MOD) - 1 
if a==b:
    pattern -= (combi(a, a))
else:
    pattern -= (combi(a, a) + combi(b, b))

print(pattern%MOD)

Measured memory_bytes: 115472
#include <bits/stdc++.h>
using namespace std;
#define maxn 110

int a[maxn];

int main(){
	int n;
	cin>>n;
	for (int i=1; i<=n; i++) cin>>a[i];
	int ans= 0;
	for (int i=2; i<=n; i++){
		if (a[i]==a[i-1]){
			a[i]= -1;
			ans++;
		}
	}	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitsf(n) __builtin_popcount(n)
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"
ll power(ll x, ll y); 

const ll MOD = 1000000007;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
	int n,m;
	cin >> n >> m;
	vector<int> v[m + 5];
	rep(i, 0, n){
		int a, b;
		cin >> a >> b;
		if(a > m) continue;
		v[m - a].pb(b);
	}
	priority_queue<int> q;
	ll res = 0;
	rrep(i, m - 1, 0){
		for(auto x : v[i]) q.push(x);
		if(!q.empty()) res += q.top(), q.pop();
	}

	cout << res;
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 5504
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			String s = sc.next();
			char[] c = s.toCharArray();
			if(c[0] == c[1] && c[1] == c[2] && c[0] != 's') {
				if(c[0] == 'o') {
					System.out.println("o");
				}else {
					System.out.println("x");
				}
			}else if(c[3] == c[4] && c[4] == c[5] && c[3] != 's') {
				if(c[3] == 'o') {
					System.out.println("o");
				}else {
					System.out.println("x");
				}
			}else if(c[6] == c[7] && c[7] == c[8] && c[6] != 's') {
				if(c[6] == 'o') {
					System.out.println("o");
				}else {
					System.out.println("x");
				}
			}else if(c[0] == c[3] && c[3] == c[6] && c[0] != 's') {
				if(c[0] == 'o') {
					System.out.println("o");
				}else {
					System.out.println("x");
				}
			}else if(c[1] == c[4] && c[4] == c[7] && c[1] != 's') {
				if(c[1] == 'o') {
					System.out.println("o");
				}else {
					System.out.println("x");
				}
			}else if(c[2] == c[5] && c[5] == c[8] && c[2] != 's') {
				if(c[2] == 'o') {
					System.out.println("o");
				}else {
					System.out.println("x");
				}
			}else if(c[0] == c[4] && c[4] == c[8] && c[0] != 's') {
				if(c[0] == 'o') {
					System.out.println("o");
				}else {
					System.out.println("x");
				}
			}else if(c[2] == c[4] && c[4] == c[6] && c[2] != 's') {
				if(c[2] == 'o') {
					System.out.println("o");
				}else {
					System.out.println("x");
				}
			}else {
				System.out.println("d");
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 26012
#include<bits/stdc++.h>
using namespace std;
int main()
{
   
        int x;
    cin>>x;
    if(x==25)cout<<"Christmas"<<endl;
    else if(x==24)cout<<"Christmas Eve"<<endl;
    else if(x==23)cout<<"Christmas Eve Eve"<<endl;
     else if(x==22)cout<<"Christmas Eve Eve Eve"<<endl;
   return 0;
}


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

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

  int first;
  int second;

  for(int i=0;i<n;i++){
    if(s[i]=='A'){
      first=i;
      break;
    }
  }
  for(int i=n-1;i>=0;i--){
    if(s[i]=='Z'){
      second=i;
      break;
    }
  }

  cout<< second-first+1 <<endl;
  return 0;
}

    
  


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;
const int INF = 0x3f3f3f3f;
#define DEBUG(x) cout << x << '\n'

int n, a[MAXN], vis[MAXN], pos[MAXN];
ll k;
int dfs(int u){
    if(~vis[a[u]]) return a[u];
    vis[a[u]] = vis[u] + 1;
    pos[vis[a[u]]] = a[u];
    return dfs(a[u]);
}
int main(){
#ifdef Irene
    freopen("in.txt", "r", stdin);
#endif // Irene
    ios::sync_with_stdio(false);

    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> a[i], vis[i] = -1;
    vis[1] = 0, pos[0] = 1;
    int x = dfs(1);
    int mx = *max_element(vis + 1, vis + n + 1) + 1;
    int ans;
    if(k < mx) ans = pos[k];
    else{
        int circle = mx - vis[x];
        k -= vis[x];
        k %= circle;
        ans = pos[vis[x]+k];
    }
    cout << ans;
}


Measured memory_bytes: 5888
#include<stdio.h>
#include<math.h>
int main(){
  double x1,x2,y1,y2;
  scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
  printf("%f\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
  return 0;
}

Measured memory_bytes: 2692
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        int r = scan.nextInt(), c = scan.nextInt();
        scan.nextLine();
        char[][] grid = new char[r][c];
        for (int i = 0; i < r; i++)
        {
            String s = scan.nextLine();
            for (int j = 0; j < c; j++)
                grid[i][j] = s.charAt(j);
        }
        int[][] dp = new int[r][c];
        dp[0][0] = 1;
        for (int i = 0; i < r; i++)
        {
            for (int j = 0; j < c; j++)
            {
                if (grid[i][j] == '#')
                    continue;
                if (i != 0)
                    dp[i][j] += dp[i - 1][j];
                if (j != 0)
                    dp[i][j] += dp[i][j - 1];
                dp[i][j] %= (int) 1e9  + 7;
            }
        }
        System.out.println(dp[r - 1][c - 1]);
    }
}

Measured memory_bytes: 47596
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int a, b, c;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> a >> b >> c;
    int sum = a + b + c, ans = 0;
    for (int i = sum; i < 250; i += 2) {
        if (i % 3 != 0) {
            ans++;
        } else {
            int k = i / 3;
            if (3 * k - 2 * ans == sum) {
                if (k >= a && k >= b && k >= c) break;
            }
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
d = [(1,0),(-1,0),(0,1),(0,-1)]
while 1:
    w,h = map(int, input().split())
    if w == h == 0:
        break
    s = [input() for i in range(h)]
    bfs_map = [[1 for i in range(w)] for j in range(h)]
    for y in range(h):
        for x in range(w):
            if s[y][x] == "@":
                ans = 1
                q = deque()
                q.append((y,x))
                bfs_map[y][x] = 0
                while q:
                    y, x = q.popleft()
                    for dy,dx in d:
                        y_ = y+dy
                        x_ = x+dx
                        if 0 <= y_ < h and 0 <= x_ < w:
                            if bfs_map[y_][x_] and s[y_][x_] == ".":
                                ans += 1
                                bfs_map[y_][x_] = 0
                                q.append((y_,x_))
                print(ans)
                break



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

using namespace std;

int n, memo[105][5][5][5], bigmod = 1000000007, temp;

int dp(int pos, int prv3, int prv2, int prv1) {
	int ret = 0, a[5], x, y;
	bool valid;
	if (pos == n)
		return 1;
	if (memo[pos][prv3][prv2][prv1] != -1)
		return memo[pos][prv3][prv2][prv1];
	a[0] = prv3;
	a[1] = prv2;
	a[2] = prv1;
	for (int i = 1; i < 5; i++) {
		a[3] = i;
		x = 0;
		for (int j = 1; j < 4; j++)
			x = (10 * x) + a[j];
		if (x == 132)
			continue;
		valid = true;
		for (int j = 0; j < 3; j++) {
			temp = a[j];
			a[j] = a[j + 1];
			a[j + 1] = temp;
			x = 0;
			for (int k = 0; k < 3; k++)
				x = (10 * x) + a[k];
			y = 0;
			for (int k = 1; k < 4; k++)
				y = (10 * y) + a[k];
			temp = a[j];
			a[j] = a[j + 1];
			a[j + 1] = temp;
			if ((x == 132) || (y == 132)) {
				valid = false;
				break;
			}
		}
		if (valid)
			ret = (ret + dp(pos + 1, prv2, prv1, i)) % bigmod;
	}
	memo[pos][prv3][prv2][prv1] = ret;
	return ret;
}

int main() {
	int ans;
	scanf("%d", &n);
	memset(memo, -1, sizeof memo);
	ans = dp(0, 0, 0, 0);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int num[100],i,j;
    float weight,height,bmi[100];
    while(scanf("%d,%f,%f",&num[i],&weight,&height)!=EOF) {
        bmi[i] = weight/(height*height);
        i++;
    }
    for(j=0;j<i;j++) {
        if(bmi[j]>=25) printf("%d\n",num[j]);
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 998244353;

double xs, ys, xt, yt;
int n;
vector<pair<pair<double, double>, double>> v;
vector<pair<int, double>> g[1005];

double dst_start(double x, double y,double xi,double yi,double r) {
	double dst = sqrt((x - xi)*(x - xi) + (y - yi)*(y - yi));
	if (dst < r)return 0;
	else return dst - r;
}

double dst_c(double xi, double yi, double ri, double xj, double yj, double rj) {
	double dst = sqrt((xj - xi)*(xj - xi) + (yj - yi)*(yj - yi));
	if (dst < ri + rj)return 0;
	else return dst - ri - rj;

}

void calc_dst() {

	REP(i, n) {
		g[i + 1].push_back({ 0, dst_start(xs, ys, v[i].first.first, v[i].first.second, v[i].second) });
		g[0].push_back({ i + 1, dst_start(xs, ys, v[i].first.first, v[i].first.second, v[i].second) });
	}
	REP(i, n) {
		FOR(j, i + 1, n) {
			g[i + 1].push_back({ j + 1,dst_c(v[i].first.first,v[i].first.second,v[i].second,v[j].first.first,v[j].first.second,v[j].second) });
			g[j + 1].push_back({ i + 1,dst_c(v[i].first.first,v[i].first.second,v[i].second,v[j].first.first,v[j].first.second,v[j].second) });
		}
	}
	REP(i, n) {
		g[i + 1].push_back({ n + 1, dst_start(xt, yt, v[i].first.first, v[i].first.second, v[i].second) });
		g[n + 1].push_back({ i + 1, dst_start(xt, yt, v[i].first.first, v[i].first.second, v[i].second) });	
	}
	g[0].push_back({ n + 1,sqrt((xs - xt)*(xs - xt) + (ys - yt)*(ys - yt)) });
	g[n + 1].push_back({ 0,sqrt((xs - xt)*(xs - xt) + (ys - yt)*(ys - yt)) });
}

void dijkstra() {


	vector<double> d(n + 5, INFL);
	VB vis(n + 5, false);

	d[0] = 0;
	min_priority_queue<pair<double, int>> que;
	que.push({ 0, 0 });

	while (!que.empty()) {
		auto q = que.top();
		que.pop();
		double cst = q.first;
		int cu = q.second;
		if (vis[cu]) continue;
		vis[cu] = true;
		for (auto p : g[cu]) {
			double cst2 = cst + p.second;
			int to = p.first;
			if (d[to] > cst2) {
				que.push({ cst2, to });
				d[to] = cst2;
			}
		}
	}

	cout << fixed << setprecision(15) << d[n + 1] << endl;

}



int main() {
	cin >> xs >> ys >> xt >> yt;
	cin >> n;
	REP(i, n) {
		double a, b, c;
		cin >> a >> b >> c;
		v.push_back({ {a,b},c });
	}
	calc_dst();

	dijkstra();




}

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

int main() {
  int N;
  cin >> N;
  
  int M = N % 10;
  
  if (M == 3){
  	cout << "bon" << endl;
  }
  else if (M == 0 || M == 1){
  	cout << "pon" << endl;
  }
  else if (M == 6 || M == 8){
  	cout << "pon" << endl;
  }
  else {
  	cout << "hon" << endl;
  }
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
	const ll INF = 4e18, V_MAX = 100010;
	ll dp[2][V_MAX];
	int N, W, w[110], v[110];
	cin >> N >> W;
	for (int i = 1; i <= N; ++i){
		cin >> w[i] >> v[i];
	}

	for (int j = 0; j < V_MAX; ++j){
		dp[0][j] = INF;
		dp[1][j] = INF;
	}

	dp[0][0] = 0LL;
	for (int i = 1; i <= N; ++i){
		for (int j = 0; j < V_MAX; ++j){
			if (j-v[i] < 0){ 
                dp[i%2][j] = dp[(i-1)%2][j];
            } else {
                dp[i%2][j] = min(dp[(i-1)%2][j], dp[(i-1)%2][j-v[i]] + w[i]);
            }
		}
	}

	int ans = 0;
	for (int j = 0; j < V_MAX; ++j){
		if (dp[N%2][j] <= W) ans = j;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5204
//B
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();

		int b = sc.nextInt();

		int c = sc.nextInt();

		int d = sc.nextInt();

		int e = sc.nextInt();

		int k = sc.nextInt();

		boolean flag = false;

		if(e-a>k) flag = true;

		if(flag)System.out.println(":(");

		else System.out.println("Yay!");
	}

}


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

int main(){
    int a[3];
    
    cin >> a[0] >> a[1] >> a[2];
    
    int work;
    for(int i=2;i>0;--i){
        for(int k=0;k<i;++k){
            if(a[k] > a[k+1]){
                work = a[k];
                a[k]=a[k+1];
                a[k+1]=work;
            }
        }
    }
    
    cout << a[0] << " " << a[1] << " " << a[2] << endl;
    /*
    for(int i=0;i<3;++i){
        cout << a[i];
        if(i!=2){
            cout << " ";
        }
    }
    cout << endl;
    */
    return 0;
    
}


Measured memory_bytes: 3088
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Edge = Tuple!(int, "to", int, "w");

void main() {
    int n;
    scan(n);

    auto adj = new Edge[][](n, 0);

    foreach (i ; 0 .. n - 1) {
        int u, v, w;
        scan(u, v, w);
        u--, v--;
        w %= 2;
        adj[u] ~= Edge(v, w);
        adj[v] ~= Edge(u, w);
    }

    auto ans = new int[](n);
    ans[] = -1;

    debug {
        writeln(adj);
    }

    void dfs(int v, int par, int col) {
        ans[v] = col;

        foreach (e ; adj[v]) if (e.to != par) {
            if (e.w == 0) {
                dfs(e.to, v, col);
            }
            else {
                dfs(e.to, v, col ^ 1);
            }
        }
    }

    dfs(0, -1, 0);

    foreach (i ; 0 .. n) {
        writeln(ans[i]);
    }
}























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

//alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 17508
#include <bits/stdc++.h>
// #include <atcoder/all> // NOTE: AtCoderライブラリ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
// using namespace atcoder; // NOTE: AtCoderライブラリ
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef pair<int, int> pii;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

const ll MOD = 1e9 + 7;
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;

        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll N; 

ll dfs(string s, int n) {
    if (n == N) {
        bool ok0 = false, ok9 = false;
        for (int i = 0; i < N; i++) {
            if (s.at(i) == '0') ok0 = true;
            if (s.at(i) == '9') ok9 = true;
        }
        if (ok0 && ok9) {
            return 1;
        } else {
            return 0;
        }
    }

    ll cnt = 0;
    for (int i = 0; i < 10; i++) {
        string tmp = s;
        tmp += (i + '0');
        cnt += dfs(tmp, n + 1);
    }

    return cnt;
}

int main() {
    cin >> N;

    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = (modpow(10, N, MOD) - (modpow(9, N, MOD) * 2) % MOD + modpow(8, N, MOD)) % MOD;
    if (ans < 0) ans += MOD;
    cout << ans << endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll N;
    cin >> N;
        
    vector<ll> d;
    for (ll i = 1; i*i <= N; i++) {
        if(N%i==0) {
            d.pb(i);
            if(i*i != N) d.pb(N/i); //Nが平方数である時の対策
        }
    }
    int ans = 0;
    // SORT(d);
    // DEBUG_VEC(d);

    for(auto&& di : d){
        ll tn = N;
        if(di==1)continue;
        while((tn%di)==0)tn /= di;
        if(tn==1)ans++;
        else if(((tn-1)%di)==0)ans++;
    }

    ll N2 = N-1;
    vector<ll> d2;
    for (ll i = 1; i*i <= N2; i++) {
        if(N2%i==0) {
            d2.pb(i);
            if(i*i != N2) d2.pb(N2/i); //Nが平方数である時の対策
        }
    }
    // SORT(d2);
    // DEBUG_VEC(d2);

    int n2 = d2.size()-1;
    ans += n2;
    pr(ans);
}

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

using namespace std;
string s;

void solve(){
    int gnum=0, pnum=0, score=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='g'){
            gnum++;
        }
        else{
            pnum++;
        }
    }
    cout << s.length()/2-pnum << endl;
}

int main(){
    cin >> s;
    solve();
}

Measured memory_bytes: 512
import functools, operator
r,c = tuple(int(n) for n in input().split())
A = [[int(a) for a in input().split()] for i in range(r)]
for a in A:
    a.append(sum(a))
R = [functools.reduce(operator.add, x) for x in zip(*A)]
A.append(R)
for j in A:
    print(" ".join(map(str,j)))


Measured memory_bytes: 6324
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
    char suit;
    int value;
};

struct Card L[MAX/2+2],R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right){
    int i,j,k;
    int n1=mid-left;
    int n2=right-mid;
    for(i=0;i<n1;i++) L[i]=A[left+i];
    for(i=0;i<n2;i++) R[i]=A[mid+i];
    L[n1].value=R[n2].value=SENTINEL;
    i=j=0;
    for(k=left;k<right;k++){
        if(L[i].value<=R[j].value) A[k]=L[i++];
        else A[k]=R[j++];
    }
}

void mergeSort(struct Card A[], int n, int left, int right){
    int mid;
    if(left+1<right){
        mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
    }
}

int partition(struct Card A[], int n, int p, int r){
    int i,j;
    struct Card t,x;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++){
        if(A[j].value<=x.value){
            i++;
            t=A[i];
            A[i]=A[j];
            A[j]=t;
        }
    }
    t=A[i+1];
    A[i+1]=A[r];
    A[r]=t;
    return i+1;
}

void quickSort(struct Card A[], int n, int p, int r){
    int q;
    if(p<r){
        q=partition(A,n,p,r);
        quickSort(A,n,p,q-1);
        quickSort(A,n,q+1,r);
    }
}

int main(){
    int n,i,v;
    struct Card A[MAX],B[MAX];
    char S[10];
    int stable=1;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%s %d",S,&v);
        A[i].suit=B[i].suit=S[0];
        A[i].value=B[i].value=v;
    }
    
    mergeSort(A,n,0,n);
    quickSort(B,n,0,n-1);
    
    for(i=0;i<n;i++) if(A[i].suit!=B[i].suit) stable=0;
    
    if(stable==1) printf("Stable\n");
    else printf("Not stable\n");
    for(i=0;i<n;i++) printf("%c %d\n",B[i].suit,B[i].value);
    
    return 0;
    }


Measured memory_bytes: 4204
#include <stdio.h>

int main()
{
  int N,i,p;
  long long sum =0 ,min =100000000;
  int x[101] = {0};

  scanf("%d",&N);

  for(i=0;i<N;i++)
    scanf("%d",&x[i]);

  for(p=1; p <= 100; p++)
    {
      for(i=0; i<N; i++){
        sum += ((x[i]-p)*(x[i]-p)) ;
      }
      if( sum < min ){min = sum;}
    sum = 0;
    }
  printf("%lld", min);
  return 0;
}


Measured memory_bytes: 1708
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    string S;
    ll K;
    cin >> S >> K;
    ll N = S.length();
    ll l = 0;
    ll r = 0;
    ll out = 0;
    if(S[0]==S[N-1]){
        rep(i,N){
            if(S[i]==S[0]) l++;
            else break;
        }
        if(l!=N){
            rep(i,N){
                if(S[N-1-i]==S[N-1]) r++;
                else break;
            }
            out += l/2 + r/2 + (l+r)/2*(K-1);
        }else{
            r=N;
            out = N*K/2;
        }
    }
    for(ll i=l;i<N-r;i++){
        if(S[i]==S[i+1]){
            out += K;
            i++;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
/* Author VS_CODE */

#include<bits/stdc++.h>
#define int long long
#define TCI int t;cin>>t;while(t--)
#define foR(n) for(int i=1;i<=n;i++)
#define For(n) for(int i=0;i<n;i++)
#define ln "\n"
#define vpair vector< pair <int , int > >
#define fr first
#define sc second
#define pb emplace_back
#define vll vector<int>
#define inf INT64_MAX
#define Point complex<double>
using namespace std;

void online()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
/* CODE STARTS HERE */

const int N = 1e5;
int k=1;

void solve ()
{
	int n,x,t;
	cin>>n>>x>>t;
	if(n%x==0)
		cout<<t*(n/x);
	else
		cout<<t*(n/x+1);
	
}


/* CODE ENDS HERE AND MAIN STaARTS */

int32_t main()
{
	online();
	// TCI
	solve();
}

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

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rep2(i,a,b,c) for(i=a;i<=b;i+=c)
#define maxn 100000
int par[maxn];
pair<pair<int,int>,int> ar[maxn];
pair<int,pair<int,int> > edge[2*maxn-2];

int fp(int mas){
	if(mas==par[mas]){
		return mas;
	}
	return par[mas]=fp(par[mas]);
}

bool gabung(int a,int b){
	int aa=fp(a),bb=fp(b);
	if(aa==bb){
		return false;
	}
	par[aa]=bb;
	return true;
}

int main(){
	int N,i;
	cin>>N;
	rep(i,0,N-1){
		cin>>ar[i].f.f>>ar[i].f.s;
		ar[i].s=i;
	}
	sort(ar,ar+N);
	rep(i,1,N-1){
		edge[i-1]=mp(ar[i].f.f-ar[i-1].f.f,mp(ar[i].s,ar[i-1].s));
	}
	rep(i,0,N-1){
		swap(ar[i].f.f,ar[i].f.s);
	}
	sort(ar,ar+N);
	rep(i,1,N-1){
		edge[i+N-2]=mp(ar[i].f.f-ar[i-1].f.f,mp(ar[i].s,ar[i-1].s));
	}
	rep(i,1,N-1){
		par[i]=i;
	}
	sort(edge,edge+2*N-2);
	int has=0;
	rep(i,0,2*N-2){
		if(gabung(edge[i].s.f,edge[i].s.s)){
			has+=edge[i].f;
		}
	}
	cout<<has<<"\n";
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;
L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,d;char s U;
L M(L f){return f?B[f]+M(f^f&-f):0;}
L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}
L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)
  d=I->first,!Z[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,Z[d]=1,D(d),Z[f]+=Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}
L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}
main(){for(cin>>n>>k;++d<n;*Z-=T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(a=n=0);n<d;a=H[P[++n]]-n?n:0)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;
       for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

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

int main()
{
	int n;
	cin  >> n;
	vector<int> a(n);
	rep(i,n)cin >> a[i];
	sort(ALL(a));
	rep(i,n-1)if(a[i]==a[i+1])
	{
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"YES"<<endl;
	return 0;
}

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

int main() {
  	int N;
   	cin >> N;
  
  	bool flag = false;
  
  	if (N % 10 == 7) flag = true;
  	N /= 10;
  	if (N % 10 == 7) flag = true;
  	N /= 10;
  	if (N % 10 == 7) flag = true;
  
  	if (flag == true) cout << "Yes" << endl;
  	if (flag == false) cout << "No" << endl;
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}


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

const ll MAX_N = 1e5;
struct edge{
  ll to, cost;
};
vector<edge> g[MAX_N] = {}; //g[i] = (edges from i)
ll dist[MAX_N] = {};
ll N;
ll parent[MAX_N];
void dfs(ll v, ll par){
  parent[v] = par;
  for (edge& e: g[v]){
    if(e.to == par) continue;
    dfs(e.to, v);
    chmax(dist[v], dist[e.to] + e.cost);
  }
}

int main(){
  cin >> N;
  REP(i, N - 1){
    ll a, b, w;
    cin >> a >> b >> w;
    g[a].pb((edge) {b, w});
    g[b].pb((edge) {a, w});
  }
  dfs(0, -1);
  ll farthest = 0;
  while(dist[farthest] != 0){
    for (auto& e: g[farthest]){
      if(e.to == parent[farthest]) continue;
      if(dist[e.to] + e.cost == dist[farthest]){
        farthest = e.to;
        break;
      }
    }
  }
REP(i, N) dist[i] = 0;
dfs(farthest, -1);
cout << dist[farthest] << endl;
}



Measured memory_bytes: 16436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    INIT;
    vector<int> consume(5);
    REP(i,5){
        cin >> consume.at(i);
    }
    int stay;
    int time = 0;
    int mi = 11;
    bool check = true;
    REP(i,5){
        time += consume.at(i);
        if(consume.at(i) % 10 != 0){
            time += 10 - consume.at(i) % 10;
            mi = min(consume.at(i) % 10, mi);
            check = false;
        }
    }
    if(check) cout << time << endl;
    else cout << time -(10 - mi) << endl;
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int cnt = 0;
        for (int x = 1; x*x <= i; x++)
        {
            for (int y = 1; y * y <= i; y++)
            {
                int b = x + y, c = i - x*x - y*y - x*y;
                if(c > 0)
                {
                    double z = (-b + sqrt(b * b + 4 * c)) / 2;
                    if (ceil(z) == floor(z)) cnt++;
                }
            }
        }
        cout << cnt << '\n';
    }
    return 0;
}

Measured memory_bytes: 3576
#include <stdio.h>

int main () {
	int n;
	scanf("%d", &n);
	
	int firstDigit = n / 100;
	int secondDigit = (n / 10) % 10;
	int thirdDigit = n % 10;
	
	while ( n > 0) {
		if ( firstDigit == 7) {
			puts("Yes");
			break;
		}
		else if ( secondDigit == 7) {
			puts("Yes");
			break;
		}
		else if ( thirdDigit == 7) {
			puts("Yes");
			break;
		}
		else {
			puts("No");
			break;
		}
	} 
	return 0;
}

Measured memory_bytes: 1612
from bisect import bisect_right
n = int(input())
d = {}
for a in map(int, input().split()):
  if a in d:
    d[a] += 1
  else:
    d[a] = 1
alist = list(sorted(d.keys(), reverse = True))
amax = alist[0]
t = 1
power_of_two = []
while t < 2 * amax:
  t *= 2
  power_of_two.append(t)
result = 0
for a in alist:
  if a not in d:
    continue
  t = power_of_two[bisect_right(power_of_two, a)] - a
  if t not in d:
    continue
  if a != t:
    if d[a] < d[t]:
      i = d[a]
    else:
      i = d[t]
  else:
    if d[a] == 1:
      continue
    i = d[a] // 2
  result += i  
  if d[a] == i:
    del d[a]
  else:
    d[a] -= i
  if d[t] == i:
    del d[t]
  else:
    d[t] -= i
print(result)


Measured memory_bytes: 44560
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  Vi a(9);
  rep(i,0,9) cin >> a[i];
  bool ok = true;
  
  if(a[0]-a[3]!=a[1]-a[4] || a[1]-a[4]!=a[2]-a[5]) ok = false;
  if(a[6]-a[3]!=a[7]-a[4] || a[7]-a[4]!=a[8]-a[5]) ok = false;
  if(a[0]-a[1]!=a[3]-a[4] || a[3]-a[4]!=a[6]-a[7]) ok = false;
  if(a[1]-a[2]!=a[4]-a[5] || a[4]-a[5]!=a[7]-a[8]) ok = false;
  
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int H, W;
  cin>>H>>W;
  char a[H][W];
  int row[W]={0},col[H]={0};
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++) cin>>a[i][j];
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++){
      if(a[i][j]=='#'){
        col[i]=1;
        row[j]=1;
      }
    }
  for(int i=0;i<H;i++){
    int count=0;
    for(int j=0;j<W;j++){
      if(col[i]==1&&row[j]==1){
        count++;
        cout<<a[i][j];
      }
    }
    if(count>0) cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#  --*-coding:utf-8-*--

def main():
    S = input()

    blocks = []
    rc = 0
    lc = 0
    stat=0

    for c in S:
        if c == 'R':
            if stat == 0:
                rc += 1
            else:
                blocks.append((rc, lc))
                rc = 1
                lc = 0
                stat = 0
        else:
            lc += 1
            if stat == 0:
                stat = 1

    blocks.append((rc, lc))

    X = [0]*len(S)
    offset = 0

    for rc, lc in blocks:
        nEven = (rc+lc)//2
        nOdd = (rc+lc+1)//2

        if rc%2 == 1:
            X[offset + rc-1] = nOdd
            X[offset + rc] = nEven
        else:
            X[offset + rc-1] = nEven
            X[offset + rc] = nOdd

        offset += (rc + lc)

        
    print(' '.join(map(str, X)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14068