akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
const ll ddx[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const ll ddy[8]={ 1, 0,-1, 0, 1,-1, 1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void dfs(const vvl &g,ll v,vector<bool> &seen,vl &count){
    seen[v]=true;
    for(auto x:g[v]){
        if(seen[x])continue;
        count[x]+=count[v];
        dfs(g,x,seen,count);
    }
}
int main(){
    ll n,q;cin >> n >>q;
    vvl g(n);
    rep(i,n-1){
        ll x,y;cin >> x >>y;
        x--;y--;
        g[x].pb(y);
        g[y].pb(x);
    }
    vl count(n,0);
    rep(i,q){
        ll x,y;cin >> x >>y;
        x--;
        count[x]+=y;
    }
    vector<bool> seen(n,false);
    dfs(g,(ll)0,seen,count);
    rep(i,n)cout << count[i] <<endl;
}


Measured memory_bytes: 30592
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize,s: String};
    let s: String = s;

    let mut v: Vec<char> = Vec::new();
    let mut count = 0;
    let mut red_count = 0;
    let mut index = 0;
    let mut red_d = 0;

    for c in s.as_str().chars() {
        if c == 'R' {
            red_count += 1;
        }

        v.push(c);
    }

    for i in 0..red_count {
        if v[i] == 'W' {
            count += 1;
        }
    }

    println!("{}", count);

    //if red_count == n {
    //    println!("0")
    //} else {
    //    while index < n {
    //        if red_d == red_count - 1 {
    //            // 最後の一個を消せばいい時
    //            println!("{}", count + 1);
    //            break;
    //        } else {
    //            // Wと後ろから見て最初に見つかったRを入れ替える
    //            if v[index] == 'W' {
    //                //
    //                for i in index..n {
    //                    if v[n - i - 1] == 'R' {
    //                        v[index] = 'R';
    //                        v[n - i - 1] = 'W';

    //                        red_d += 1;
    //                        index += 1;
    //                        count += 1;
    //                        break;
    //                    }
    //                }
    //            //
    //            } else {
    //                red_d += 1;
    //                index += 1;
    //            }
    //        }
    //    }
    //}
}


Measured memory_bytes: 3348
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using System;

public class P
{
    public int to { get; set; }
    public int step { get; set; }
}

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var map = new List<int>[n];
        var d = new int[n];
        for (int i = 0; i < n; i++)
        {
            d[i] = -1;
            map[i] = new List<int>();
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]) - 1;
            var b = int.Parse(line[1]);
            for (int j = 0; j < b; j++)
            {
                var c = int.Parse(line[j + 2]) - 1;
                map[i].Add(c);
            }
        }
        d[0] = 0;
        goDfs(map, d);
        print(d);
    }
    public static void print(int[] d)
    {
        var dL = d.Length;
        for (int i = 0; i < dL; i++)
            Console.WriteLine("{0} {1}", i + 1, d[i]);
    }
    public static void goDfs(List<int>[] map, int[] d)
    {
        var n = map.Length;
        var used = new bool[n];
        used[0] = true;
        var q = new Queue<P>();
        foreach (var x in map[0])
        {
            q.Enqueue(new P { to = x, step = 1 });
            used[x] = true;
        }
        while (q.Count() > 0)
        {
            var w = q.Dequeue();
            d[w.to] = w.step;
            foreach (var x in map[w.to])
                if (!used[x])
                {
                    q.Enqueue(new P { to = x, step = w.step + 1 });
                    used[x] = true;
                }
        }
    }
}


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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	int n;
	cin >> n;
	if(n%10 == 9 || (n/10) == 9)
		cout<< "Yes\n";
	else cout << "No\n";	
	return 0;
}

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

using namespace std;

#define int long long

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x = 100, n, ans = 0;
    cin >> n;
    while (x < n) {
        ans++;
        x += x / 100;
    }
    cout << ans << '\n';
    return 0;
}



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

const int MAX_N = 10000;
typedef long long ll;

int main() {
	int N;
	ll a[MAX_N];
	std::cin >> N;
	for(int i = 0; i < N; ++i) {
		std::cin >> a[i];
	}

	ll ans = 0;
	for(int i = 0; i < N; ++i) {
		while(a[i] % 2 == 0) {
			a[i] /= 2;
			++ans;
		}
	}

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

Measured memory_bytes: 384
s_ = input()
n = len(s_)
k = int(input())
s = [ord(s_[i])-97 for i in range(n)]
#print(s)
for i in range(n-1):
    if s[i]:###これないとaの時に消費する
        if 26-s[i]<=k:
            k -= (26-s[i])
            s[i] = 0

#print(s,k)
s[n-1] += k
s[n-1] %= 26

#print(s)
ans = [chr(s[i]+97) for i in range(n)]

print(''.join(ans))

Measured memory_bytes: 47796
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }
const long long INF = 1LL << 60;

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

    int n = s.size();

    bool ans = true;

    rep(i,n){
        if(i % 2 == 1){
            if(s.at(i) == 'R'){
                ans = false;
                break;
            }
        }

        else{
            if(s.at(i) == 'L'){
                ans = false;
                break;
            }
        }
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

int main(){
    int n, p[200000], minim[200000];
    cin >> n;

    rep(i,200000) minim[i] = INF;

    rep(i,n) {
        cin >> p[i];
    }

    minim[0] = min(p[0], INF);

    rep1(i,n) {
        minim[i] = min(p[i], minim[i-1]);

    }
 
    int cnt = 0;

    rep(i,n){
        if (p[i] == minim[i]) cnt++;
    }


    cout << cnt << endl;
   
    return 0;
    
}

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

int main(){
  int d, g, p[11], c[11];
  cin >> d >> g;
  for(int i = 0; i < d; i++){
    cin >> p[i] >> c[i];
  }
  int ans = 1e9;
  for(int bit = 0; bit < (1<<d); bit++){
    int sum = 0; int num = 0; int rest_max = -1;
    for(int i=0; i<d; i++){
      if(bit & (1<<i)){
        sum += 100*(i+1)*p[i] + c[i];
        num += p[i];
      }else{
        rest_max = i;
      }
    }
    if(sum < g){
      int s1 = (rest_max + 1)*100;
      int need;
      if((g - sum) % s1 == 0){
        need = (g - sum)/s1;
      }else{
        need = (g - sum)/s1 + 1;
      }
      if(need >= p[rest_max]) continue;
      num += need;
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
ll po(ll n)
{
	ll k=0;
	while(n%2==0)
	{
		k++;
		n=n/2;
	}
	return k;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,l,m,k,n;
    	cin>>n;
    	ll h[n+1];
    	repi(i,1,n)
    	cin>>h[i];
    	ll dp[n+1];
    	dp[1]=0;
    	if(n>1)
    	dp[2]=abs(h[2]-h[1]);
    	repi(i,3,n)
    	dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    	cout<<dp[n];
    }
    
	return 0;
}

Measured memory_bytes: 1792
N,M,C = map(int,input().split())
Blist = list(map(int,input().split()))
count = 0
for i in range(N):
    Alist = list(map(int,input().split()))
    a = 0
    for j in range(M):
        a += (Blist[j] * Alist[j])
    if a + C > 0:
        count += 1
print(count)

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
    int i,x,s;
    scanf("%d",&x);
    for(i=1;i<=x;i++){
        if( i % 3 == 0|| i % 10==3){
            printf(" %d",i);
        }else {
            s=i;
            while(1){
            s=s/10;
                if(s%10==3){
                    printf(" %d",i);
                    break;
                }else if(s/10 ==0){                
                    break;
                }
            }
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1824
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define i_half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int mod = 1000000007;

const int max_n = i_half_inf;
ll n, c, k, t[max_n];

void solve() {
    sort(t, t + n);
    ll ans = 1, c_temp = 0, t_first = t[0];
    rep(i, n) {
        if (t[i] > t_first + k || c_temp == c) {
            c_temp = 1;
            t_first = t[i];
            ans++;
        } else c_temp++;
    }
    cout << ans << endl;
}

int main() {
    cin >> n >> c >> k;
    rep(i, n) cin >> t[i];
    solve();
    return 0;
}

Measured memory_bytes: 1024
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Locale;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    String s = sc.next();
    if (s.toUpperCase(Locale.ENGLISH).equals(s)) {
      pw.println("A");
    } else {
      pw.println("a");
    }
  }
}


Measured memory_bytes: 35656
#include<iostream>

using namespace std;
int R,G,B,N;
int r,g,b;
int ans=0;
void solve(){
    int k=0;
    for(int i=0;i<=r;i++){
        for(int j=0;j<=g;j++){
                k=N-i*R-j*G;
                if(k>=0&&k%B==0)ans++;
        }
    }
    cout << ans;
}

int main(){
    cin >> R >> G >> B >> N;
    r=N/R;
    g=N/G;
    solve();
}

Measured memory_bytes: 256
package main

import "fmt"

func Sum(nums []int) int {
	sum := 0
	for _, v := range nums {
		sum += v
	}
	return sum
}

func main() {
	var n, m, sum int
	fmt.Scan(&n, &m)
	a := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&a[i])
	}
	sum = Sum(a)
	if n >= sum {
		fmt.Println(n - sum)
	} else {
		fmt.Println(-1)
	}
}

Measured memory_bytes: 2420
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <algorithm>

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

int main()
{
    int N, minhp = 0;
    cin >> N;

    vector<int> x(N);

    rep(i, N) cin >> x.at(i);

    int min = *min_element(x.begin(), x.end());
    int max = *max_element(x.begin(), x.end());



    for (int i = min; i < max; i++)
    {
        int hp = 0;
        rep(j, N)
        {
            hp += pow((i - x.at(j)),2);
        }
        if (hp < minhp || i == min)
        {
            minhp = hp;
        }
    }

    cout << minhp << endl;
    return 0;
}

Measured memory_bytes: 256
#include "math.h"
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <functional>
#include <numeric>
#include <cmath>
using namespace std;

int t;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> t;
	int count = 0;
	for (int i = 1; i < t+1; i++)
	{
		int a;
		cin >> a;
		if (i % 2 == 1 && a % 2 == 1) count += 1;
	}
	cout << count;
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, a, b, c;
    std::cin >> n >> a >> b >> c;
    std::vector<int> v(n);
    int ret = std::numeric_limits<int>::max();
    for (auto &el : v) std::cin >> el;
    for (int i = 0; i < (1 << (2 * n)); i++) {
        int p[4] { 0, 0, 0, 0 };
        int cost = 0;
        for (int j = 0; j < n; j++) {
            int r = (i >> (2 * j)) % 4;
            if (r < 3 && p[r]) cost += 10;
            p[r] += v[j];
        }
        if (!p[0] || !p[1] || !p[2]) continue;
        cost += std::abs(a - p[0]) + std::abs(b - p[1]) + std::abs(c - p[2]);
        ret = std::min(ret, cost);
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
  int r,c;
  cin >> r >> c;
  vvi sh(r+1,vi(c+1,0));
  REP(i,r){
    int sum = 0;
    REP(j,c){
      int a;
      cin >> a;
      sh[i][j] = a;
      sum += a;
      cout << a << " ";
    }
    sh[i][c] = sum;
    cout << sum << endl;
  }
  REP(j,c+1)REP(i,r) sh[r][j] += sh[i][j];
  REP(i,c) cout << sh[r][i] << " ";
  cout << sh[r][c] << endl;
}


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);

ll a, b, c, d, e, f;
vector<ll> water, sugar;
set<ll> w, s;

void water_list(ll now) {
    if(!w.count(now+a) && now+a <= f/100) {
        w.insert(now+a);
        water.push_back(now+a);
        water_list(now+a);
    }
    if(!w.count(now+b) && now+b <= f/100) {
        w.insert(now+b);
        water.push_back(now+b);
        water_list(now+b);
    }
}

void sugar_list(ll now) {
    if(!s.count(now+c) && now+c <= f/2) {
        s.insert(now+c);
        sugar.push_back(now+c);
        sugar_list(now+c);
    }
    if(!s.count(now+d) && now+d <= f/2) {
        s.insert(now+d);
        sugar.push_back(now+d);
        sugar_list(now+d);
    }
}


int main() {
    cin >> a >> b >> c >> d >> e >> f;
    sugar.push_back(0);
    water_list(0);
    sugar_list(0);

    ll ans_w = 1, ans_s = 0;

    rep(i, water.size()) {
        rep(j, sugar.size()) {
            // 容量オーバー
            if(100*water[i] + sugar[j] > f) continue;
            // 溶け残り
            if(e*(100*water[i]+sugar[j]) < (100+e)*sugar[j]) continue;
            if(sugar[j]*(100*ans_w+ans_s) >= ans_s*(100*water[i]+sugar[j])) {
                ans_w = water[i];
                ans_s = sugar[j];
            }
        }
    }

    cout << 100*ans_w + ans_s << " " << ans_s << endl; 

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

int main() {
    int N, K, Q;
    cin>>N>>K>>Q;
    vector<int> A(N, 0);
    REP(i, 0, Q){
        int p;
        cin >> p;
        p--;
        A[p]++;
    }
    REP(i, 0, N){
        if(A[i] > Q-K) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        s: chars,
    }
    puts!("{}\n", if (0..3).any(|i| s[i] == s[i + 1]) { "Bad" } else { "Good" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
import sys
import math
from collections import Counter
import itertools
import fractions
import datetime
from decimal import Decimal
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

N,M=MI()
KA=LLI(N)
like=[0]*M

for ka in KA:
    i = 0
    for a in ka:
        if i == 0:
            i += 1
            continue
        like[a-1] += 1

cnt = 0
for l in like:
    if l == N:
        cnt+=1
print(cnt)





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

#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef long long ll;

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

	int m = (n+1)/2;
	cout << fixed;
	cout << setprecision(7) << (double)m/n << endl;

	return 0;
}


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

cumsumW = []
sumW = 0
for i in range(N):
    sumW += W[i]
    cumsumW.append(sumW)

ans = 1000000
for i in range(N-1):
    s1 = cumsumW[i]
    s2 = cumsumW[N-1] - cumsumW[i]
    ans = min(ans, abs(s1 - s2))

print(ans)

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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;


int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   string s; cin >> s;
   map<int, int> m;
   for(int i = 0; i < s.size(); i++)
   {
      m[s[i]]++;
   }
   for(auto it = m.begin(); it!=m.end(); it++)
   {
      if(it->second %2)
      {
         cout << "No" << nl;
         return 0;
      }
   }
   cout << "Yes" << nl;



	return 0;
}


Measured memory_bytes: 3628
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
t, f = [False for _ in range(N)], [False for _ in range(N)]
for i in range(N):
    if A[i] % 6 == 0: #and A[i] % 3 == 0:
        t[i] = True
    if A[i] % 10 == 0:# and A[i] % 5 == 0:
        f[i] = True
    if A[i] % 2 == 1:
        t[i] = True
        f[i] = True
flag = True
for i in range(N):
    if not t[i]:
        if not f[i]:
            flag = False
print("APPROVED" if flag else "DENIED")

Measured memory_bytes: 3064
open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v end
module MyInt64 = struct
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done
	let string_of_list ?(separator=" ") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls "" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
	let (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v
	let ceildiv m n = (m+n-1L) / n
end open MyInt64

let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f

let () =
	let a,b = get_2_i64 0 in
	Array.init 3 (fun i -> if a*b*((~~|i)+1L) mod 2L = 1L then 1L else 0L)
	|> Array.fold_left (+) 0L
	|> (fun v -> if v > 0L then "Yes" else "No")
	|> print_endline




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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

int main() {
    int n, k;
    cin >> n >> k;
    if(k == 1) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> sum(n+1);
    rp(i, 0, n) {
        int a; cin >> a;
        sum[i+1] = (sum[i] + a) % k;
    }
    ll res = 0ll;
    map<int, ll> m;
    m[0]++;
    rp(i, 1, n+1) {
        // m[sum[i-1]]++;
        // if(i-k>=0) m[sum[i-k]]--;
        int x = (((sum[i] - i) % k) + k) % k;
        res += m[x];
        m[x]++;
        if(i-k+1>=0) {
            int y = (((sum[i-k+1] - (i-k+1)) % k) + k) % k;
            m[y]--;
        }
    }
    cout << res << endl;
    // for(auto x: sum) cout << x;
    // cout << endl;
    return 0;
}


Measured memory_bytes: 16424
#include <bits/stdc++.h>
using namespace std;
 
#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
 #define PI acos(-1)
 #define MOD ((int)1e9+7)
typedef long long     ll;
 
//-*-*-*-*-*-*-*-*-
 
 

 
const int N=2e5+100;
ll visited[100005];
//ll a[200000];
 

#define lop(i,n) for(int i=0;i<n;++i)
//ll n,m,mod;

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

const int MAX = 2e5 + 10 ;
void finis(){cout<<-1;}
vector<pair<int,int>>v;

int a[3001][100];ll h,w;
int valid(ll x,ll y){
    if(x<=0||x>h||y<=0||y>w||a[x][y]==1){return 0;}
    return 1;
}ll ans[100][100];
int main()
{  ios::sync_with_stdio(0);
cin.tie(0);
cin>>h>>w;ll lol=0;
for(int i=1;i<=h;i++){
   for(int j=1;j<=w;j++){
       char xx;cin>>xx;if(xx=='#'){ lol++;a[i][j]=1;}ans[i][j]=10000007;
       
   }
}queue<pair<ll,ll>>q;ans[1][1]=0;
q.push({1,1});
while(!q.empty()){
    pair<ll,ll>l=q.front();
    q.pop();
    ll x=l.first;ll y=l.second;
    ll myans=ans[x][y];
    for(int j=0;j<4;j++){
        ll xx=x+dx[j];
        ll yy=y+dy[j];
        if(valid(xx,yy)&&myans+1<ans[xx][yy]){
            q.push({xx,yy});ans[xx][yy]=myans+1;
        }
    }
}if(a[1][1]||a[h][w]||ans[h][w]==10000007){cout<<-1;return 0;}
cout<<(h*w)-(ans[h][w]+1)-lol;

   
}


Measured memory_bytes: 3696
#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++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b; cin >> a >> b;
    int ans = (a + b) / 2 + (a + b) % 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int h, w, k;
  cin >> h >> w >> k;
  int t[h][w];
  for (int i = 0; i < h; ++i) {
    string s;
    cin >> s;
    for (int j = 0; j < w; ++j) t[i][j] = s[j] == '1';
  }
  int res = h+w;
  for (int p = 0; p < (1<<(h-1)); ++p) {
    int cu = __builtin_popcount(p);
    int s = cu+1;
    int cs[s] {};
    int csi = 0;
    bool f = 1;
    for (int i = 0; i < h; ++i) {
      cs[csi] += t[i][0];
      if (p & (1<<i)) csi++;
    }
    for (int x = 0; x < s; ++x) {
      if (cs[x] > k) f = 0;
    }
    if (!f) continue;
    for (int j = 1; j < w; ++j) {
      int tcs[s] {};
      csi = 0;
      for (int i = 0; i < h; ++i) {
        tcs[csi] += t[i][j];
        if (p & (1<<i)) csi++;
      }
      bool g = 1;
      for (int x = 0; x < s; ++x) {
        cs[x] += tcs[x];
        if (cs[x] > k) g = 0;
      }
      
      if (!g) {
        cu++;
        for (int x = 0; x < s; ++x) {
          cs[x] = tcs[x];
          if (cs[x] > k) f = 0;
        }
        if (!f) break;
      }
    }
    if (f) res = min(res, cu);
  }
  cout << res << endl;
}


Measured memory_bytes: 256
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m
    
n=int(input())
x=list(map(int,input().split()))
mod=10**9+7
l=[]
z=1
for i in range(1,n):
  z*=i
  z%=mod
l2=[z for i in range(n-1)]
for i in range(n-1):
  l.append(x[i+1]-x[i])
for i in range(n-1):
  l2[i]*=mod_inv((i+1),mod)
  l2[i]%=mod
l3=[]
l3.append(l2[0])
for i in range(n-2):
  l3.append(l3[-1]+l2[i+1])
ans=0
for i in range(n-1):
  ans+=l3[i]*l[i]
  ans%=mod
print(ans)

Measured memory_bytes: 66456
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n)==1)
    {
        int i;
        int sum,a,b;
        sum=0;
        priority_queue<int>s;
        while(!s.empty())
            s.pop();
        for(i=0;i<n;i++)
        {
            scanf("%d",&a);
            s.push(a);
        }
        a=-2;
        s.push(a);
        b=-1;
        int j=0;
        for(i=0;i<=n;i++)
        {
            a=s.top();
            s.pop();
            //printf("a=%d\n",a);
            if(a==b)
                j++;
            else
            {
                sum=sum+j%2;
                j=1;
            }
            //printf("j=%d\nsum=%d\n",j,sum);
            b=a;
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }

int main() {
  ull H, W, h, w;
  cin >> H >> W;
  cin >> h >> w;

  cout << (H - h) * (W - w) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<int> x(n+1), y(m+1);
    cin >> x[0] >> y[0];
    repeat (i, n) cin >> x[i+1];
    repeat (i, m) cin >> y[i+1];
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    if (x[x.size()-1] < y[0]) {
        cout << "No War" << endl;
    }
    else {
        cout << "War" << endl;
    }
}

Measured memory_bytes: 256
//
//  main.cpp
//  BC20161109
//
//  Created by TA on 2016/11/09.
//  Copyright © 2016年 TA. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int n;
    int a[3];
    int i = 0;
    while(cin >> n){
        a[i] = n;
        i++;
    }
    if (a[0]==a[1]+a[2]) {
        cout << "Yes";
    }
    else if (a[1]==a[0]+a[2]) {
        cout << "Yes";
    }
    else if (a[2]==a[0]+a[1]) {
        cout << "Yes";
    }
    else{cout << "No";}
    return 0;
}


Measured memory_bytes: 384
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int H, W;
  cin >> H >> W;
  vector<string> s(H);
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (s[i][j] == '#') cnt++;
    }
  }
  vector<int> dx = {-1, 0, 1, 0};
  vector<int> dy = {0, 1, 0, -1};
  auto dist = vect(H, vect(W, INF));
  queue<P> q;
  q.push(P(0, 0));
  dist[0][0] = 0;
  while (!q.empty()) {
    P a = q.front();
    q.pop();
    int x = a.first;
    int y = a.second;
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
      if (s[nx][ny] == '#') continue;
      if (dist[nx][ny] == INF) {
        dist[nx][ny] = dist[x][y] + 1;
        q.push(P(nx, ny));
      }
    }
  }
  // for (auto &col : dist) cout << col << endl;
  if (dist[H - 1][W - 1] == INF)
    cout << -1 << endl;
  else
    cout << H * W - dist[H - 1][W - 1] - 1 - cnt << endl;
  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#define INF 100000001

using namespace std;

struct edge{
  int to;
  double cost;
};

typedef pair<double,double>P;
int N;
double d[3001];
vector<edge>G[3001];
vector<int>S;

void dijkstra(void){
  priority_queue<P,vector<P>,greater<P> >que;
  fill(d,d+N+1,INF);
  for(int i=0;i<S.size();i++){
    d[S[i]]=0;
    que.push(P(0,S[i]));
  }

  while(!que.empty()){
    P p=que.top();
    que.pop();
    int v=p.second;
    if(d[v]<p.first)continue;

    for(int i=0;i<G[v].size();i++){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
	d[e.to]=d[v]+e.cost;
	que.push(P(d[e.to],e.to));
      }
    }
  }
}

int main(void){
  int M,K,a,b,l,s;

  cin >> N >> M >> K;

  edge e;
  for(int i=0;i<M;i++){
    cin >> a >> b >> e.cost;
    e.to=b;
    G[a].push_back(e);
    e.to=a;
    G[b].push_back(e);
  }
  for(int i=0;i<K;i++){
    cin >> s;
    S.push_back(s);
  }
   
  dijkstra();

  double ans=0;
  for(int i=1;i<=N;i++)
    for(int j=0;j<G[i].size();j++)
      ans=max(ans,round((d[i]+d[G[i][j].to]+G[i][j].cost)/2.0));
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 7132
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int A = String.valueOf(N).length();
		int B = 10;
		int have = N;
		int sum = 0;
		for(int i = 0;i < (A - 2);i++) {
			B *= 10;
		}
		if(N % B == 0) {
			sum = 10;
			System.out.println(sum);
			System.exit(0);
		}
		sum = N / B;
		for(;;) {
			have = have - (have / B) * B;
			B /= 10;
			if(B == 0) {
				break;
			}
			sum += have / B;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 22868
n = int(input())
a = list(map(int,input().split()))

a.sort()

if n % 3 != 0:
    if all((a[i] == 0 for i in range(n))):
        print('Yes')
    else:
        print('No')
else:
    a1 = a[:n//3]
    a2 = a[n//3:n*2//3]
    a3 = a[n*2//3:]
    if all((a1[i] == 0 for i in range(n//3))) and all((a2[i] == a2[0] for i in range(n//3))) and all((a3[i] == a3[0] for i in range(n//3))):
        print('Yes')
    elif all((a1[i] == a1[0] for i in range(n//3))) and all((a2[i] == a2[0] for i in range(n//3))) and all((a3[i] == a3[0] for i in range(n//3))) and a1[0] ^ a2[0] ^ a3[0] == 0:
        print('Yes')
    else:
        print('No')


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int n,i,a[100010], idx[100010];
	scanf("%d",&n);
	for(i=1;i<=n;i++){scanf("%d",&a[i]); idx[a[i]] = i;}
	int counter = 0;
	for(i=1;i<=n;i++){
		if(idx[i]==i){counter++; break;}
	}
	if(counter==0){printf("0\n"); return 0;}
	int cnt = 0;
	for(i=1;i<=n-1;i++){
		int bil1 = a[i], bil2 = a[i+1];
		
		if(idx[bil1]==bil1 && idx[bil2]==bil2){
			swap(idx[bil1],idx[bil2]);
			cnt++;
		}
	}
	for(i=1;i<=n-1;i++){
		int bil1 = a[i], bil2 = a[i+1];
		if(i==1){
			if(idx[bil1]==bil1){
				swap(idx[bil1],idx[bil2]);
				cnt++;	
			}
			
		}else{
			if(idx[bil2]==bil2){
				swap(idx[bil1],idx[bil2]);
				cnt++;
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
};

Measured memory_bytes: 1024
import fractions
from functools import reduce

def gcd_list(A):
	return reduce(fractions.gcd, A)

n, x = map(int, input().split())
X = list(map(int, input().split()))
X.append(x)
X.sort()
Y = [b - a for a, b in zip(X, X[1:])]

print(gcd_list(Y))

Measured memory_bytes: 89364
#include <iostream>
 #include <vector>
 #include <algorithm>
#include <map>
 #include <set>
 #include <cmath>
 #include <cstring>
 #include <iomanip>
 #include <random>
 #include <chrono>
 #include <queue>
 #include <math.h>
 using namespace std;

int main(){
  int a;cin >>a;if(a==7||a==5||a==3) cout <<"YES"<<endl;else cout <<"NO" << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    private static int fact(int n){
        int ans=1;
        for(int i=2;i<=n;i++) ans*=i;
        return ans;
    }
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        int P[] = new int[n];
        int Q[] = new int[n];
        for(int i=0;i<n;i++) P[i] = in.nextInt();
        for(int i=0;i<n;i++) Q[i] = in.nextInt();
        int ans1 = findKthPermutation(P,n);
        int ans2 = findKthPermutation(Q,n);
        out.println(Math.abs(ans1-ans2));
    }
    private static int findKthPermutation(int a[],int n){
        boolean vis[] = new boolean[n+1];
        int sum = 0;
        for(int i=0;i<n;i++){
            int cnt=0;
            for(int j=1;j<a[i];j++){
                if(!vis[j])
                    cnt++;
            }
            sum += cnt*fact(n-i-1);
            vis[a[i]]=true;
        }
        return sum;
    }
    /************* SOLUTION ENDS HERE **********/
} 

Measured memory_bytes: 23252
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

long long int result[100001];
vector<vector<int> > a(100001);

long long int solve(int n)
{
	if(result[n] >= 0) return result[n];
	result[n] = 0;
	if(a[n].size() == 0) return 0;
	long long int mintmp = mod;
	vector<long long int> resulttmp;
	for(int i = 0; i < a[n].size(); i++){
		resulttmp.push_back(solve(a[n][i]) + 1);
	}
	sort(resulttmp.begin(), resulttmp.end());
	for(int i = 0; i < resulttmp.size(); i++){
		result[n] = max(result[n], resulttmp[i] + (long long int)a[n].size() - i - 1);
	}
	return result[n];
}

int main()
{
	int n;
	cin >> n;
	for(int i = 2; i <= n; i++){
		int tmp;
		cin >> tmp;
		a[tmp].push_back(i);
	}
	for(int i = 0; i <= n; i++){
		result[i] = -1;
	}
	cout << solve(1) << endl;
	// for(int i = 2; i <= n; i++){
	// 	cout <<i << " " << result[i] << endl;
	// }
	return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3856