akhauriyash/Code-Regression huggingface dataset:
# ?´????(??£'???'c)???"??????"???

n, m = gets.split.map(&:to_i)
s = []
(n-1).times { s << gets.to_i }
a = []
m.times { a << gets.to_i }

dist = [0]
s.each_with_index do |t, idx|
  dist[idx+1] = dist[idx] + t
end

cur_hotel = 0
moves = 0
# p dist

ans = 0
(a + [0]).each_with_index do |cur, i| # ???????????????????¢???????
  # p [cur_hotel, moves]
  if moves == 0 || (moves[-1] > 0 && cur > 0) || (moves[-1] < 0 && cur < 0)
    moves += cur
  else
    dx = dist[cur_hotel+moves] - dist[cur_hotel]
    ans += dx.abs
    cur_hotel += moves
    moves = cur
  end
end

puts ans % 100000

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

// @@ !! LIM()

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

  ll N; cin >> N;
  vector<ll> vec(N+1);
  for (ll x = 1; x <= N; x++) {
    if (x * x > N) break;
    for (ll y = 1; y <= N; y++) {
      if (x * x + y * y > N) break;
      for (ll z = 1; z <= N; z++) {
	if (x * x + y * y + z * z > N) break;
	ll t = x*x + y*y + z*z + x*y + y*z + z*x;
	if (t <= N) vec.at(t)++;
      }
    }
  }
  for (ll i = 1; i <= N; i++) {
    cout << vec.at(i) << "\n";
  }


  return 0;
}



Measured memory_bytes: 3544
import java.util.*;

public class Main {
    public static void main(String[] args) {
        int a, b, area, perimeter;
        Scanner scan = new Scanner(System.in);
        
        a = scan.nextInt();
        b = scan.nextInt();
        area = a * b;
        perimeter = (a + b) * 2;
        
        System.out.print(area);
        System.out.print(' ');
        System.out.println(perimeter);
        
        
    }
}


Measured memory_bytes: 26236
from functools import reduce


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def gcd_n(numbers):
    return reduce(gcd, numbers)


def main():
    N, X, *x = map(int, open(0).read().split())
    x = [abs(X - int(i)) for i in x]
    print(gcd_n(x))
    return


main()


Measured memory_bytes: 14548
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n = int(input())
    l = list(map(int, input().split()))
    k = l[0]
    for i in range(1,n):
        k = gcd(k,l[i])
    print(k)


if __name__=="__main__":
    main(
    )


Measured memory_bytes: 87288
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll a[5005],p[5005];
void solve(){
	ll n,k,res=(-pow(10,10));
	cin>>n>>k;
	for(ll i=1;i<=n;i++)
		cin>>p[i];
	for(ll i=1;i<=n;i++){
		cin>>a[i];
		res=max(res,a[i]);
	}
	if(res<=0){
		cout<<res;
		return;
	}
	for(ll i=1;i<=n;i++){
		ll x=p[i];
		vector<ll> v(1,0),vis(n+1,0);
		while(!vis[x]){
			v.push_back(a[x]);
			vis[x]=1;
			x=p[x];
		}
		for(ll j=1;j<sz(v);j++)
			v[j]+=v[j-1];
		for(ll j=0;j<min(k+1,sz(v));j++){
			ll am=(k-j),sum=v[j];
			if(v.back()>0)
				sum+=(am/(sz(v)-1))*v.back();
			res=max(res,sum);
		}
	}
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 4036
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <queue>
#include <stack>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

class Graph{
public:

Graph(long long int o_size){
    graph_size=o_size;
    node.resize(graph_size,0);
    edge.resize(graph_size);
}

long long int add_edge(long long int a,long long int b){
    edge[a].push_back(b);
    edge[b].push_back(a);
        
    return a+b;
}

long long int node_add(long long int i,long long int a){
    node[i]+=a;
    return node[i];
}

void dfs(long long int start){
    queue<pair<long long int,long long int>> st;
    st.push(make_pair(-1,start));
    while(st.size()){
        long long int where = st.front().second,pre_where=st.front().first;
        //cout << "Unko" << endl;
        st.pop();
        for(auto x:edge[where]){
            if(x!=pre_where){
                st.push(make_pair(where, x));
                node[x] += node[where];
            }
        }
        
    }

}

void print(){
    REP(i,graph_size-1){
        cout << node[i] << " ";
    }
    cout << node[graph_size - 1] << endl;
}


private:
vector<vector<long long int>> edge;
vector<long long int> node;
long long int graph_size;

};

int main(){

    long long int n,q,tmpa,tmpb;
    cin>>n>>q;
    Graph graph(n);
    REP(i,n-1){
        cin>>tmpa>>tmpb;
        graph.add_edge(tmpa-1,tmpb-1);
    }
    REP(i,q){
        cin>>tmpa>>tmpb;
        graph.node_add(tmpa - 1, tmpb) ;
    
    }
    graph.dfs(0);
    graph.print();

    return 0;
}


Measured memory_bytes: 17520
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

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();
        boolean f = false;
        for (int i = 0; i < a; i++) {
            if(c % a == 0){
                f = true;
                break;
            }else{
                c += b;
            }
        }

        io.YESNO(f);
        sc.close();
    }
}

class io {
    public static void br() {
        System.out.println("");
    }

    public static void yesno(boolean f) {
        System.out.println(f ? "yes" : "no");
    }

    public static void YesNo(boolean f) {
        System.out.println(f ? "Yes" : "No");
    }

    public static void YESNO(boolean f) {
        System.out.println(f ? "YES" : "NO");
    }

}

class Algo {
    public static int nibutan(int target, int[] ar) {
        // ar[i] >= target なる最小のiを探す
        int res;
        int high = ar.length;
        int low = 0;
        while (high > low) {
            res = (high + low) / 2;
            if (ar[res] < target) {
                // ↑↓ここを変える
                low = res + 1;
            } else {
                // ↓ここを変える
                high = res;
            }
        }
        return low;
    }

    public static boolean isOdd(int n) {
        return n % 2 == 1;
    }

    public static boolean isEven(int n) {
        return n % 2 == 0;
    }


}



Measured memory_bytes: 21844
import math


def main():
    k = int(input())
    k1 = k + 1

    sum = 0
    for i in range(1, k1):
        for j in range(1, k1):
            for m in range(1, k1):
                sum += math.gcd(math.gcd(i, j), m)
    print(sum)

main()

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

typedef long long ll;

#define PrintLn(X) cout << X << endl
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)

ll a[300000];
int main(void)
{
	int N;
	cin >> N;
	Rep(i, N * 3) cin >> a[i];

	ll ans = 0;
	sort(a, a + N * 3);
	Rep(i, N){
		ans += a[3 * N - 2 - i * 2];
	}
	PrintLn(ans);
	return 0;
}


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

using namespace std;
#define row(x) (x)
#define col(x) ((x) + 100005)

int cmpID;
int xcnt[200005], ycnt[200005];
int vis[200005];
vector< vector<int> > adj;
void dfs(int u){
    if(vis[u]) return;
    vis[u] = 1;
    if(u <= 100000)
        xcnt[cmpID]++;
    else
        ycnt[cmpID]++;
    for(int v:adj[u])
        dfs(v);
}
int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    adj = vector< vector<int> >(200005);
    for(int i=0; i<n; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        adj[row(x)].push_back(col(y));
        adj[col(y)].push_back(row(x));
    }
    for(int i=0; i<adj.size(); i++){
        if(adj[i].size() && !vis[i]) {
            dfs(i);
            cmpID++;
        }
    }
    long long res = 0;
    for(int i=0; i<cmpID; i++)
        res += xcnt[i] * 1ll * ycnt[i];
    printf("%lld\n", res - n);
    return 0;
}

Measured memory_bytes: 10752
N = int(input())
A = list(map(int, input().split()))

b = []

c = 0
for a in A:
    if a < 0:
        c += 1
    b.append(abs(a))

if c % 2 == 0:
    print(sum(b))
else:
    print(sum(b) - 2 *min(b))



Measured memory_bytes: 14412
#include <cstdio>
const int SIZE = 33554432;
#define HASH(A) char* c = A; Hash = 1; while(*c){ Hash <<= 2; Hash += Key[*c]; c++; }

int main() {
  bool dic[SIZE];
  int Hash;
  char Key[85]; Key['A'] = 0; Key['C'] = 1; Key['G'] = 2; Key['T'] = 3;
  int n; std::scanf("%d\n", &n);
  char str[21];
  for( int i = 0; i < n; i++ ) {
    std::fgets(str, 21, stdin);
    if( str[0] == 'i' ) {
      HASH(str+7);
      dic[Hash] = 1;
    } else {
      HASH(str+5);
      std::puts(dic[Hash] ? "yes" : "no");
    }
  }
  return 0;
}


Measured memory_bytes: 8088
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        r: i32
    }
    println!("{}", 2.0*3.141592653589*(r as f64));

}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}



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

    ll a[n];
    rep(i,n) cin >> a[i];

    ll money = 1000;
    ll kabu = 0;

    for(int i=0;i<n-1;i++){
        if(a[i]<a[i+1]){
            //次の日の値の方が大きければ株にしておく
            ll b = money/a[i];
            money = money - b*a[i];
            kabu += b;
            //cout << money << " " << kabu << endl;
        }else if(a[i]!=a[i+1]){
            money += kabu*a[i];
            kabu = 0;
            //cout << money << " " << kabu << endl;
        }
    }

    money += kabu*a[n-1];

    cout << money << endl;
}


Measured memory_bytes: 3620
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: usize,
        a: [usize; n],
    }
    let mut v = vec![0; 9];
    let mut sss = 0;
    for i in 0..n {
        if a[i] >= 3200 {
            sss += 1
        } else {
            v[(a[i] / 400) as usize] = 1;
        }
    }
    let acc = v.iter().sum::<usize>();

    if acc != 0 {
        println!("{} {}", acc, acc + sss);
    } else {
        println!("{} {}", 1, sss);
    }
}


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

int main() {
  ll n,m;
  cin >> n >> m;
  
  vector<ll> vote(n);
  rep(i, n)
    cin >> vote.at(i);
  
  sort(vote.begin(), vote.end(), greater<ll>() );
  ll sum = 0;
  
  rep(i, n)
    sum += vote.at(i);
  
  if(vote.at(m-1) * 4 * m >= sum)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

long long N;
string tmp;
char S[200005];

int main(){
	cin >> N >> tmp;

	for(long long i = 0; i < N; i++) {
		S[i] = tmp[i];
	}

	long long ans = 0;
	long long left = 0;
	long long right = N - 1;

	while(true) {
		while(left < N && S[left] == 'R') {
			left++;
		}

		while(right >= 0 && S[right] == 'W') {
			right--;
		}

		if(left < right) {
			swap(S[left], S[right]);
			ans++;
		} else {
			cout << ans << endl;
			return 0;
		}
	}

}

Measured memory_bytes: 3952
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <climits>
#include <map>
using namespace std;

int main() {
    int n, m;
    
    cin >> n >> m;
    
    cout << (n - 1) * (m - 1) << endl;
}

Measured memory_bytes: 256
import math

def isPrime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
    # ２ではない偶数は素数ではない
        return False

# nの半分まで計算する範囲を絞る
    m = math.floor(n / 2) + 1
    for p in range(3, m, 2): # 奇数だけ計算する
        if n % p == 0:
            return False
    return True
n=int(input())
while not isPrime(n):
    n+=1
print(n)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    ll ans=0;
    int N,K;cin>>N>>K;
    ans=K*pow(K-1,N-1);
    cout<<ans<<endl;   
}

Measured memory_bytes: 3916
/* https://codeforces.com/contest/1360/problem/H */
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define f first
#define s second 
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pb push_back
#define	lb lower_bound
#define	ub upper_bound
#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const int MAX = INT_MAX;

int main() {
	
	string s;
	cin>>s;
	if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
		cout<<3<<endl;
	}
	else if (s[0] == 'R' && s[1] == 'R') {
		cout<<2<<endl;
	}
	else if (s[1] == 'R' && s[2] == 'R') {
		cout<<2<<endl;
	}
	else if (s[0] == 'R' ||  s[1] == 'R' || s[2] == 'R') {
		cout<<1<<endl;
	}
	else cout<<0<<endl;

	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
const int maxN = 1e5;

int p[maxN];

int main() {
	int i, j, n, ans = 0; cin >> n;
	for (i = 0; i < n; i++)
		scanf("%d", p + i);
	for (i = 0; i < n - 1; i++) {
		if (p[i] == i + 1) {
			swap(p[i], p[i + 1]);
			ans++;
		}
	}
	if (p[n - 1] == n) ans++;
	printf("%d\n", ans);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INF 1000000000000 //10^12

int main(){
    ll n;
    cin >> n;
    ll ans=0;
    REP(i,n+1){
        if(i%3 ==0 || i%5 ==0)
            continue;
        ans +=i;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a < b){
			System.out.println("a < b");
		}else if(a > b){
			System.out.println("a > b");
		}else if(a == b){
			System.out.println("a == b");
		}
		sc.close();
	}

}

Measured memory_bytes: 25984
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N,D;
int sum[128];
int m;

int main(){
  while(scanf("%d%d",&N,&D) && N+D){
    memset(sum, 0, sizeof(sum));
    vector<int>c[128];
    rep(i,N){
      scanf("%d", &m);
      rep(j,m){
	int x;
	scanf("%d", &x);
	c[i].push_back(x);
	sum[i] += c[i].back();
      }
    }
    int f = 1;
    while(f){
      f = 0;
      rep(i,N){
	while(!c[i].empty()){
	  sum[i] -= c[i].back();
	  if(*max_element(sum,sum+N) - sum[i] <= D){
	    c[i].pop_back();
	    f = 1;
	  }else{
	    sum[i] += c[i].back();
	    break;
	  }
	}
      }
    }

    puts(*max_element(sum,sum+N)==0?"Yes":"No");
  }
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define ll long long
#define N 100010
#define M 1010

using namespace std;
int a, b, c, d, e;

int read() {
	int s = 0, f = 0; char ch = getchar();
	while (!isdigit(ch)) f |= (ch == '-'), ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

int main() {
	cin >> a >> b >> c >> d >> e;
	if (a == 0) {
		puts("1");
		return 0;
	} else if (b == 0) {
		puts("2");
		return 0;
	} else if (c == 0) {
		puts("3");
		return 0;
	} else if (d == 0) {
		puts("4");
		return 0;
	} else if (e == 0) {
		puts("5");
		return 0;
	}
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long

int main() {
	int n, b1 = 0, b2 = 0, b4 = 0;
	scanf("%d", &n);
	int arr[n];
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
		if (arr[i] & 1) {
			b1++;
		} else if (arr[i] % 4 == 0)
			b4++;
		else
			b2++;
	}
	if (b2 == 0) {
		if (b1 <= b4 + 1)
			printf("Yes\n");
		else
			printf("No\n");
	} else {
		if (b1  <= b4)
			printf("Yes\n");
		else
			printf("No\n");
	}

}


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

int main()
{
    char c;
    cin>>c;
    if(c=='A')
    cout<<'T'<<endl;
    else if(c=='T')
    cout<<'A'<<endl;
    else if(c=='G')
    cout<<'C'<<endl;
    else if(c=='C')
    cout<<'G'<<endl;
    
}

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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;


template<typename Monoid_Set>
struct SegmentTree {
private:
    using bo = function<Monoid_Set(Monoid_Set, Monoid_Set)>; // Monoid - binary operation
    int n;
    vector<Monoid_Set> node;
    Monoid_Set identity_element;
    bo operation_for_internal_node;
    bo operation_for_external_node;

public:
    SegmentTree(vector<Monoid_Set> v, Monoid_Set _identity_element, bo _operation_for_internal_node, bo _operation_for_external_node): identity_element(_identity_element), operation_for_internal_node(_operation_for_internal_node), operation_for_external_node(_operation_for_external_node) {
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = operation_for_internal_node(node[2*i+1], node[2*i+2]);
    }

    void update(int x, Monoid_Set val) {
        x += (n - 1);
        node[x] = operation_for_external_node(node[x], val);
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = operation_for_internal_node(node[2*x+1], node[2*x+2]);
        }
    }

    Monoid_Set query(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return identity_element;
        if(a <= l && r <= b) return node[k];

        Monoid_Set vl = query(a, b, 2*k+1, l, (l+r)/2);
        Monoid_Set vr = query(a, b, 2*k+2, (l+r)/2, r);
        return operation_for_internal_node(vl, vr);
    }
};


int main() {
    const ll _INF = (1LL << 31) - 1LL;
    int n, q; cin >> n >> q;
    vector<ll> a(n, _INF);

    SegmentTree<ll> seg(a, _INF, [](ll a, ll b){return min(a, b);}, [](ll a, ll b) {return b;});

    rep(i, q) {
        ll com, x, y; cin >> com >> x >> y;
        if (com == 0) seg.update(x, y);
        else cout << seg.query(x, y+1) << endl;
    }

    return 0;
}


    



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

using namespace std;

int main(){
	
	int S;
	cin>>S;
	int h=0,m=0;
	if (S>=3600){
		h=S/3600;
	S-=h*3600;
	}
	if(S>=60){
	
		m=S/60;
		S-=m*60;
	}
	cout<<h<<":"<<m<<":"<<S<<endl;
}





Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define rep(i, a, b) for(int i = a; i < b; ++i)

int debug = 0;

const int N = 3010;
int mod = 998244353;
int n, s, ans, all, a[N], dp[N][N];

main() {
    cin >> n >> s;
    rep(i, 1, n + 1) {
        cin >> a[i];
    }
    dp[0][0] = 1;
    ans = 0;
    rep(i, 1, n + 1) {
        rep(w, 0, s + 1) {
            dp[i][w] = dp[i - 1][w];
            if (w > a[i]) {
                (dp[i][w] += dp[i - 1][w - a[i]]) %= mod;
            } else if (a[i] == w) {
                (dp[i][w] += i) %= mod;
            }
            if (debug) {
                cerr << dp[i][w] - dp[i - 1][w] << ' ';
            }
        }
        if (debug) {
            cerr  << '\n';
        }
        (ans += (dp[i][s] - dp[i - 1][s] + mod + mod) * (n + 1 - i)) %= mod;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 70784
using System;

class F
{
	static void Main()
	{
		var s = Console.ReadLine();
		var t = Console.ReadLine();
		int l = s.Length, m = t.Length;

		var dp = new int[l + 1, m + 1];
		for (int i = 1; i <= l; i++)
			for (int j = 1; j <= m; j++)
				if (s[i - 1] == t[j - 1])
					dp[i, j] = dp[i - 1, j - 1] + 1;
				else
					dp[i, j] = dp[i, j - 1] > dp[i - 1, j] ? dp[i, j - 1] : dp[i - 1, j];

		var cs = new char[dp[l, m]];
		for (int i = l, j = m; i > 0 && j > 0;)
			if (s[i - 1] == t[j - 1])
			{
				i--; j--;
				cs[dp[i, j]] = s[i];
			}
			else
			{
				if (dp[i, j - 1] > dp[i - 1, j]) j--;
				else i--;
			}
		Console.WriteLine(new string(cs));
	}
}


Measured memory_bytes: 46048
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans = 0;
ll N;

void solve(){
    ans = N*(N-1)/2;

    cout << ans << endl;
}

int main(){
    cin >> N;

    solve();
}


Measured memory_bytes: 256
#!/Users/takahiro.kida/git/atcorder/venv/bin/python

import numpy
import scipy

from collections import defaultdict
from pprint import pprint

N = int(input())
A = [int(x) for x in input().split(" ")]
B = [int(x) for x in input().split(" ")]

diff = [0 for x in range(N)]

for i in range(N):
    diff[i] = A[i] - B[i]

if (sum(diff) < 0):
    print (-1)
else:
    point = 0
    ans = 0
    for d in diff:
        if d < 0:
            point += d
            ans += 1
    for d in sorted(diff, reverse=True):
        if point >= 0:
            break
        ans += 1
        point += d
    print(ans)

Measured memory_bytes: 29628
// Course＞Introduction to Programming I ＞ ITP1_2_A:   Small, Large, or Equal
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_2_A&lang=jp

// 以下のソースコードには(複数の？)誤りがあるので、このまま提出しても「誤り」と判定されます。
// ソースコード中の誤りを修正し、「正解」（Accepted）を出してください。

// 適宜、paiza.io (https://paiza.io/ja/projects/new) などのC++実行環境を、確認に用いることを推奨します。


#include <iostream>
using namespace std;

int main(){
	int a,b;
	cin >> a >> b;

		if( a < b )
		{
		cout << "a < b" << endl;
		}else{
			if( a > b)
			{
			cout << "a > b" << endl;
			}else{
			cout << "a == b" << endl;
			}
		}

}


Measured memory_bytes: 3096
from bisect import bisect_left
n = int(input())
A = [int(input()) for i in range(n)]
L = [A[0]]
a = A[0]
for i in A[1:]:
    if L[-1] < i:
        L.append(i)
    else:
        L[bisect_left(L, i)] = i
    a = i
print(len(L))


Measured memory_bytes: 11140
import Control.Monad
import Data.List

main = do
  li <- getLine
  let n = read li
  bas <- forM [1..n] (\_ -> do
    li <- getLine
    let [a,b] = map read $ words li
    return (b,a)
    )
  let ans = compute n bas
  putStrLn $ if ans then "Yes" else "No"

-- 貪欲に締め切り順にこなして、間に合えばそれでいい。
compute :: Int -> [(Int,Int)] -> Bool
compute _ bas = loop 0 $ sort bas

loop :: Int -> [(Int,Int)] -> Bool
loop _ [] = True
loop c ((b,a):bas) = let d = c+a in d <= b && loop d bas


Measured memory_bytes: 279152
n=int(input())
arr=list(map(int,input().split()))
amt=1000
st=0
i=0
while(i<n-1):
    if arr[i]<arr[i+1]:
        mi=arr[i]
        while(i<n-1 and arr[i]<=arr[i+1]):
            i+=1
        st+=amt//mi
        amt-=mi*st
        amt+=arr[i]*st
        st=0
    else:
        while(i<n-1 and arr[i]>=arr[i+1]):
            i+=1
print(amt)





Measured memory_bytes: 61764
#include<bits/stdc++.h>
#define ll long long//
#define rp(i,a,b) for(ll i=a;i<b;i++)
#define r(i,n) for(ll i=0;i<n;i++)
#define rt return
#define db double
#define ldb long double
#define vd void
#define p(x) cout<<(x)<<endl;
#define ce continue;
#define bl bool
#define r0 rt 0;
#define r1 rt 1;
#define elif else if
#define bk break;
#define A p("A")
#define B p("B")
#define C p("C")
#define D p("D")
#define E p("E")
#define F p("F")
#define S(a) sort(a.begin(),a.end());
#define R(a) reverse(a.begin(),a.end());
#define cl cout<<endl;
#define pb(x) push_back(x);
#define str string
using namespace std;
void Cond(int g){if(g)p("YES")else p("NO")rt;}
void cond(int g){if(g)p("Yes")else p("No")rt;}
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)rt b;gcd(b,a%b);}
str su="0123456789";
str m1="abcdefghijklmnopqrstuvwxyz";
str m2="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
map<char,ll>m5;
typedef pair<ll,ll> P;
const ll INF=(ll)1e18+10;
ll t1=0,t2=0,t3=0,t4=0,t5=0,t6=0,t7=0,t8=0,g=0,ans=0;
ll n=0,m=0,k=0,mx=-INF,mn=INF,ct=0;
ll tmp=0,tmp1=0,tmp2=0,tmp3=0,tmp4=0;
ll sum=0,mask=0;
set<P> pst;
set<ll>st,st1,st2;
set<char> cst;
ll powmod(ll a,ll b,ll x){//(a^b)modx
    if(!b)r1
    if(!(b%2)){//B
        ll t=powmod(a,b/2,x);
        rt t*t%x;
    }
    rt ((a)*powmod(a,b-1,x))%x;
}
void di(){m5['a']=0;
    m5['b']=1;
    m5['c']=2;
    m5['d']=3;
    m5['e']=4;
    m5['f']=5;
    m5['g']=6;
    m5['h']=7;
    m5['i']=8;
    m5['j']=9;
    m5['k']=10;
    m5['l']=11;
    m5['m']=12;
    m5['n']=13;
    m5['o']=14;
    m5['p']=15;
    m5['q']=16;
    m5['r']=17;
    m5['s']=18;
    m5['t']=19;
    m5['u']=20;
    m5['v']=21;
    m5['w']=22;
    m5['x']=23;
    m5['y']=24;
    m5['z']=25;
}
map<ll,ll>mp,mp1,mp2,mp3;
typedef std::vector<ll> vl;
typedef pair<ll,ll> P;
typedef pair<ll,P>  P2;
typedef struct edge2{P tos;ll cost;}EDGE2;
typedef struct edge1{ll to,cost;}EDGE;
bl used[(ll)1e9];
const ll M=(ll)1e9+7;
ll fac[1000007],finv[1000007],inv[1000007];
void initcmb(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<1000007;i++){
        fac[i]=fac[i-1]*i%M;
        inv[i]=M-inv[M%i]*(M/i)%M;
        finv[i]=finv[i-1]*inv[i]%M;
    }
}
ll cmb(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%M)%M;
}
db pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196;

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 ll MAX=5+(ll)1e5*3;
vl rui(MAX);

   

vector<vector<EDGE>>G(1e6);


int main(){//swap(ary１,ary２)
    //a.erase(a.begin()+5),a.insert(a.begin()+3,tmp)    ios_base::sync_with_stdio(0); cin.tie(0);
clock_t start = clock();//timecalc
di();

str s,t;
cin>>s>>t;
r(i,(ll)s.length()){
    ct+=(s[i]!=t[i]);
}
p(ct)


clock_t end = clock();//
const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;//timecalc
//printf("time %lf[ms]\n", time);//
return 0;
}//main


Measured memory_bytes: 29716
N,Y = map(int,input().split(" "))
x,y,z = -1,-1,-1

for  i in range(N+1):
	for j in range(N+1-i):
		k = N - i - j
		tmp = i * 10000 + j * 5000 + k * 1000
		if tmp == Y:
			x,y,z = i,j,k
			break
	else:
		continue
	break
print("{} {} {}".format(x,y,z))

Measured memory_bytes: 3188
import math
a,b,c,d=list(map(int,input().split()))
a-=1
def calculation(x,c,d):
	x=x-(x//c)-(x//d)+(x//((c*d)//math.gcd(c,d)))
	return x
	
print(calculation(b,c,d)-calculation(a,c,d))

Measured memory_bytes: 9180
#include<stdio.h>

int gcd(int a, int b);

int main()
{
	int i, n; 
	
	scanf("%d", &n);
	
	int a[n];
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	
	for(i = 0; i < n - 1; i++){
		a[i + 1] = gcd(a[i], a[i + 1]);
		if(a[i + 1] == 1){
          	a[n - 1] = 1;
			break;
		}
	}
	
	printf("%d", a[n - 1]);

	return 0;
}

int gcd(int a, int b){
	
	int tmp, r;
	
	if(a < b){
		tmp = a;
		a = b;
		b = tmp;
	}
 
	r = a % b;
	while(r != 0){
		a = b;
		b = r;
		r = a % b;
	}
	
	return b;

}

Measured memory_bytes: 512
package main

import (
	"fmt"
)


func main() {
	var p,q,r int
	fmt.Scan(&p,&q,&r)
	
	sht := p+q
	if sht > p+r {
		sht = p+r
	}
	if sht > q+r {
		sht = q+r
	}
	fmt.Println(sht)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll k;
    cin >> k;
    queue<ll> q;
    rep2(i,1,10) q.push(i);
    rep(i,k) {
        ll now = q.front();
        if(i == k-1) cout << now << endl;
        q.pop();
        ll r = now%10;
        if(r > 0) q.push(now*10+r-1);
        q.push(now*10+r);
        if(r < 9) q.push(now*10+r+1);
    }
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(){
int h,w;
while(1){
scanf("%d",&h);scanf("%d",&w);
if(h==0&&w==0)break;
 
for(int i=0;i<h;i++)
{
for(int k=0;k<w;k++)
{
printf("#");
}
printf("\n");
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 1000
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
ll mx(ll a,ll b){if(a>=b) return a;return b;}
ll mn(ll a,ll b){if(a<b) return a;return b;}
#define pb push_back
#define mp make_pair
#define endl "\n"
#define INF (ll) (3e18)
vector<vi> g(100005);
ll indegree[100005],dist[100005];
bool vis[100005];
void dfs(ll s){
    vis[s]=true;
    for(ll i=0;i<g[s].size();i++){
        ll node=g[s][i];
        indegree[node]--;
        dist[node]=mx(dist[node],dist[s]+1);
        if(indegree[node]==0)
            dfs(node);
    }
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll n,m,a,b;
    cin>>n>>m;
    for(ll i=0;i<m;i++){
        cin>>a>>b;
        g[a].pb(b);
        indegree[b]++;
    }
    for(ll i=1;i<=n;i++)
        if(indegree[i]==0 and !vis[i])
            dfs(i);
    ll ans=0;
    for(ll i=1;i<=n;i++)
        ans=mx(ans,dist[i]);
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 10496
#include <cstdio>
#include <cmath>

int max(int x, int y){
    return (x>y) ? x : y;
}

int main(){
    int A, B;
    scanf("%d%d", &A, &B);
    printf("%d\n", max(A+std::abs(B),A*B));
    return 0;
}

Measured memory_bytes: 128
use proconio::input;
use proconio::marker::Usize1;
use std::cmp::Reverse;
use std::collections::BinaryHeap;

fn main() {
    input!{
        n: usize,
        m: usize,
        ab: [(Usize1, Usize1); m],
    }
    let mut g: Vec<Vec<usize>> = vec![vec![]; n];
    for (a, b) in ab {
        g[a].push(b);
        g[b].push(a);
    }

    let ans = solve(g);
    //let l: Vec<usize> = ans.iter().filter(|&&x| x == 0).cloned().collect();
    println!("Yes");
    for i in 1..n {
        println!("{}", ans[i] + 1);        
    }
}

fn solve(graph: Vec<Vec<usize>>) -> Vec<usize> {
    let n = graph.len();
    let mut mins = vec![std::u64::MAX; n];
    let mut marks = vec![0; n];

    let mut r_heap: BinaryHeap<(Reverse<u64>, usize)> = BinaryHeap::new();
    // スタート地点からスタート地点(cost 0)を追加
    r_heap.push((Reverse(0), 0));
    while !r_heap.is_empty() {
        // 最小costを取り出し、ノードまでの最小costを確定
        let (Reverse(cost), node) = r_heap.pop().unwrap();

        // 確定させたノードから、未確定のノードへのパスを抽出
        for &next in &graph[node] {
            if mins[next] <= cost + 1 {continue;}
            mins[next] = cost + 1;
            r_heap.push((Reverse(cost + 1), next));
            marks[next] = node;
        }
    }

    marks
}


Measured memory_bytes: 15964
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 3010
int Adj[MAXN],V[MAXN*2],nxt[MAXN*2],c;
void AddEdge(int u,int v)
{
	c++;V[c]=v,nxt[c]=Adj[u];Adj[u]=c;
}
bool f[MAXN];
int a[MAXN],n;
void dfs(int u,int p)
{
	f[u]=0;
	for(int i=Adj[u];i;i=nxt[i])
		if(V[i]!=p)
		{
			dfs(V[i],u);
			if(f[V[i]]==0&&a[u]>a[V[i]])
				f[u]=1;
		}
}
int main()
{
	scanf("%d",&n);
	int u,v;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		AddEdge(u,v);
		AddEdge(v,u);
	}
	for(int i=1;i<=n;i++)
	{
		dfs(i,0);
		if(f[i])
			printf("%d ",i);
	}
}


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

#define llint long long int

using namespace std;

int main(){
    int N;

    cin >> N;

    vector<int> count(N + 1, 0);

    for(int i = 2; i <= N; i ++){
        int A;

        cin >> A;

        count[A] ++;
    }
    for(int i = 1; i <= N; i ++){
        cout << count[i] << endl;
    }
}

Measured memory_bytes: 4048
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     setbits(x)  __builtin_popcountll(x)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int a,b;
    cin>>a>>b;
    rep(i,1,100000){
        if(i*8/100==a and i/10==b){
            cout<<i;
            return 0;
        }
    }
    cout<<-1;
    return 0;
}


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

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

    if(N % 2) {
        cout << (N - 1) * (N - 1) / 2 << endl;
    } else {
        cout << N * (N - 2) / 2 << endl;
    }
    
    for(int i=1; i<N; ++i) {
        for(int j=i + 1; j<=N; ++j) {
            if(i + j != N + (N + 1) % 2 ) {
                cout << i << ' ' << j << endl;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int cnt_digit(int n)
{
	int res = 0;
	while (n) {
		++res;
		n /= 10;
	}
	return res;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int res = 0;
	while (n) {
		if (cnt_digit(n) & 1)
			++res;
		--n;
	}
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        Map<Character, Integer> left = new HashMap<>();
        Map<Character, Integer> right = new HashMap<>();
        left.put('q',0);
        left.put('a',0);
        left.put('z',0);
        left.put('w',0);
        left.put('s',0);
        left.put('x',0);
        left.put('e',0);
        left.put('d',0);
        left.put('c',0);
        left.put('r',0);
        left.put('f',0);
        left.put('v',0);
        left.put('t',0);
        left.put('g',0);
        left.put('b',0);
        right.put('y',0);
        right.put('h',0);
        right.put('n',0);
        right.put('u',0);
        right.put('j',0);
        right.put('m',0);
        right.put('i',0);
        right.put('k',0);
        right.put('o',0);
        right.put('l',0);
        right.put('p',0);
        
        while (sc.hasNext()) {
            String s = sc.next();
            if (s.equals("#")) break;
            boolean b = left.containsKey(s.charAt(0));
            int res = 0;
            for (int i = 1; i < s.length(); i++) {
                char c = s.charAt(i);
                boolean cur = left.containsKey(c);
                if (b != cur) res++;
                b = cur;
            }
            System.out.println(res);
        }
    }
}

Measured memory_bytes: 27860
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;


int main(){
    string in,ans;
    char c='Z';
    
    cin >> in;
    
    
    for(int i=0;i<in.size();i++){
        
        if(in[i]=='A' || in[i]=='Z'){
            if(c!=in[i]){
                ans+=in[i];
                c=in[i];
            }
        }
    }
    
    if(ans.size()<2){
        puts("-1");
        return 0;
    }
    
    for(int i=0;i<ans.size()-1;i++){
        printf("%c",ans[i]);
    }
    
    if(ans[ans.size()-1]=='Z'){
        puts("Z");
    }else{
        printf("\n");
    }
    
    
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i,a,b) for (int i = a; i <= (int)(b); i++)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template <class T, class F = less<T>>
void sort_uniq(vector<T> &v, F f = F()) {
    sort(begin(v), end(v), f);
    v.resize(unique(begin(v), end(v)) - begin(v));
}

const int N=5e5+5;
int A[N],L[N],R[N];
set<int> dp[N][18];

int n,qq;
map<int,int> seen;

// fenwick
int fenw[N];
void upd( int k, int x ) {
    for ( int i=k; i<=n; i+=i&-i ) {
        fenw[i]+=x;
    }
}

int get( int k ) {
    int res=0;
    for ( int i=k; i; i-=i&-i ) {
        res+=fenw[i];
    }
    return res;
}

// 用BIT記錄i之前，distinct value的數量
// 如果在j位置(j<i)已經出現A[i]，先將j位置-1，在i位置+1
// fenw[i]=1，代表A[i]在位置i最後出現
// 將query按照[l,r]的r升冪排序，
// 再遍歷array A時，如果對到達的r，query BIT，計算distinct value
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> qq;
    REP(i,n) cin >> A[i];
    REP(i,qq) cin >> L[i] >> R[i];
    VI Q(qq),ans(qq);
    iota(ALL(Q),0);
    sort(ALL(Q),[&](int i, int j) {
        return R[i]==R[j] ? L[i]<L[j] : R[i]<R[j];
    });
    int k=0;
    REP(i,n) {
        if ( seen.count(A[i]) ) {
            upd(seen[A[i]],-1);
        }
        upd(i+1,1);
        seen[A[i]]=i+1;
        while ( k<qq && R[Q[k]]-1==i ) {
            ans[Q[k]]=get(R[Q[k]])-get(L[Q[k]]-1);
            k++;
        }
    }
    for ( int i:ans ) {
        cout << i << '\n';
    }
    return 0;
}


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

int gcd(int x,int y){return y?gcd(y,x%y):x;}

int main(){
    int n,X;
    cin>>n>>X;
    vector<int> x(n);
    for(int i=0;i<n;i++) cin>>x[i];

    int ans=0;
    for(int i=0;i<n;i++){
        ans=gcd(ans,abs(X-x[i]));
    }
    cout<<ans<<endl;
} 

Measured memory_bytes: 640
#include<iostream>
using namespace std;
bool is_good_num(int num) {
	int a, b, c, d;
	a = num % 10;
	b = num / 10 % 10;
	c = num / 100 % 10;
	d = num / 1000;
	if ((a == b && b == c) || (b == c&&c == d) ){
		return true;
	}
	return false;
}
int main()
{
	int n;
	scanf("%d", &n);
	int flag = is_good_num(n);
	if (flag) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

def main():
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())
    k = int(input())

    if e - a > k:
        return ':('
    else:
        return 'Yay!'

if __name__ == '__main__':
    print(main())



Measured memory_bytes: 38256
import math

n=int(input())
town=[tuple(map(int,input().split())) for _ in range(n)]

import itertools
seq=list(range(n))
wa=0

for p in itertools.permutations(seq,n):
  for i in range(n-1):
    x=(town[p[i]][0]-town[p[i+1]][0])**2
    y=(town[p[i]][1]-town[p[i+1]][1])**2
    temp=(x+y)**(1/2)
    wa+=temp
print(wa/math.factorial(n))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	int A, B, C, K;
	cin >> A >> B >> C;
	cin >> K;

	int ans = 0;

	while (B <= A) {
		B = 2 * B;
		ans += 1;
	}

	while (C <= B) {
		C = 2 * C;
		ans += 1;
	}

	if (ans <= K) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

int MOD=1000000007;
struct edge {
    int to, cost;
};

int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}

auto factor(int n){
  map<int,int>res;
  for(int i=2;i*i<=n;i++){
      for(; n%i==0;n/=i) res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
////////////////////////////////////////////////////////////
signed main() {
  int h,w;
  cin>>h>>w;
  int c[10][10];
  rep(i,10)rep(j,10){cin>>c[i][j];}
  rep(k,10){
    rep(i,10){
      rep(j,10){
        c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
      }
    }
  }
  int ans=0;
  rep(i,h){
    rep(j,w){
      int a;cin>>a;
      if(a!=-1)ans+=c[a][1];
    }
  }
cout<<ans<<endl;
}


Measured memory_bytes: 3540