akhauriyash/Code-Regression huggingface dataset:
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
  
using namespace std;
//using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

template <class A, class B> inline int Max(const A &a, const B &b){ return (a < b ? b : a); }
template <class A, class B> inline int Min(const A &a, const B &b){ return (a > b ? b : a); }

int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}

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


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

    int n, m;
    cin >> n >> m;

    int sum = 0;

    rep(i,m){
        int a;
        cin >> a;
        sum += a;
    }

    if(n < sum){
        cout << "-1\n";
    }else{
        cout << n - sum << '\n';
    }

    return 0;
}


Measured memory_bytes: 3644
import sys
input = sys.stdin.readline
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A + 1):
    x = 500 * i
    if x == X:
        ans += 1
        break
    elif x > X:
        break
    for j in range(B + 1):
        x = 500 * i + 100 * j
        if x == X:
            ans += 1
            break
        elif x > X:
            break
        for k in range(C + 1):
            x = 500 * i + 100 * j + 50 * k
            if x == X:
                ans += 1
print(ans)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m;
const int maxn = 1e4 + 5;
int a[maxn];
int main(){
	scanf("%d %d", &n, &m);
	ll sum = 0;
	for(int i = 1; i <= m; i++){
		scanf("%d", &a[i]);
		sum += a[i];
	}
	if(sum > n)
		printf("-1\n");
	else if(sum == n)
		printf("0\n");
	else
		printf("%d\n", n - (int)sum);

	return 0;
}

Measured memory_bytes: 3860
object Main {
    def main(args: Array[String]) {
        val sc = new java.util.Scanner(System.in)
        val n = sc.nextInt
        val m = sc.nextInt
        var a = new Array[Int](m);
        for (i <- 0 to n - 1) {
            val k = sc.nextInt
            for (j <- 0 to k - 1) {
                val ii = sc.nextInt
                a.apply(ii - 1) += 1
            } 
        }
        var ans = 0;
        for (i <- 0 to m - 1) {
            if (a.apply(i) == n) {
                ans += 1
            }
        }
        println(ans)
    }
}

Measured memory_bytes: 27332
h, w = map(int, input().split())
toggle = True
while h != 0:
    # print off the chess board
    for i in range(h):
        for j in range(w):
            char = "#" if (i+j) % 2 == 0 else "."
            print(char, end="")
        print()
    h, w = map(int, input().split())
    print()



Measured memory_bytes: 7000
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long k = sc.nextLong();
		
		// 計算
		if(k <= 1){
		    System.out.println(2);
		    System.out.println((k+1) + " " + 0);
		    return;
		}else if(k <= 50){
		    long[] result = new long[(int)k];
		    int cnt = (int)k;
		    for(int i = 0; i < (int)k; i++){
		        result[i] = max(cnt, 0);
		        cnt--;
		    }
		    System.out.println(result.length);
		    for(int i = 0; i < result.length; i++){
		        System.out.print(result[i] + " ");
		    }
		}else{
		    long[] result = new long[50];
		    for(int i = 0; i < 50; i++){
		        long a = (k-(i+1))/50;
		        result[i] = 50-i+a;
		    }
		    System.out.println(result.length);
		    for(int i = 0; i < result.length; i++){
		        System.out.print(result[i] + " ");
		    }
		}
		
		// 出力
		//System.out.println(result);
	}

}




Measured memory_bytes: 23508
use std::cmp::{max, min};
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let k = parse!(it);
    let a: Vec<usize> = parse!(it, k);
    let mut l = 2;
    let mut r = 2;
    for &ai in a.iter().rev() {
        l = if l % ai == 0 { l } else { (l / ai + 1) * ai };
        r = (r / ai) * ai + (ai - 1);
        if r < l {
            println!("{}", -1);
            return;
        }
    }

    println!("{} {}", l, r);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 8444
//cod2016_final_b.cpp
//Sun Dec  2 19:21:41 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int total = 0;
	int ans = 0;
	int dif = 0;
	for (int i=1;i<=n;i++){
		total = total + i;
		if (total >= n){
			ans = i;
			dif = total-n;
			break;
		}
	}

	for (int i=1;i<=ans;i++){
		if (i!=dif){
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()
 
using namespace std;

inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
 
inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}
 
inline 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;
}
 
inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}
 
inline vector<pair<ll, int>> factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}
 
inline bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
 
ll mod = 1e9+7;

int main(void){
    ll n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    
    ll ans = 0;
    rep(i, n-1){
        if(s[i] == s[i+1]){
            ans ++;
        }
    }
    
    rep(i, k){
        ans += 2;
    }
    if(ans > n-1){
        ans = n-1;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        if (B % A == 0) System.out.println(A + B);
        else System.out.println(B - A);
    }
}

Measured memory_bytes: 23760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef pair<int, int> P;
const int MAX_N = 1000000000;
const int MAX_E = 100000000;
const int MAX_V = 10000;
typedef int64_t ll;
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; }



int main() {
	int K, N;
	cin >> N >> K;
	vector<int> vec(N);
	rep(i, N) {
		cin >> vec.at(i);
	}
	sort(vec.begin(), vec.end());
	int ans = INF;
	for (int i = 0; i <= N - K; i++) {
		ans = min(ans, abs(vec.at(i) - vec.at(i + K-1)));
	}
	cout << ans << endl;
}

Measured memory_bytes: 3756
//
// ~oisín~ C++ Template
//

#include                <bits/stdc++.h>
#define MX_N            5001
#define mp              make_pair
#define mod7            1000000007
#define modpi           314159
#define PI              3.141592653589793238
#define pb              push_back
#define FastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define All(a)          a.begin(),a.end()
#define fi              first
#define se              second
#define ll              long long int
#define ull             unsigned long long int

int kx[8]  =            {+2, +2, -2, -2, +1, +1, -1, -1};
int ky[8]  =            {+1, -1, +1, -1, +2, -2, +2, -2};
int d9x[9] =            {+1, +1, +1, +0, +0, +0, -1, -1, -1};
int d9y[9] =            {+1, +0, -1, +1, +0, -1, +1, +0, -1};
int dx4[4] =            {+0, +0, +1, -1};
int dy4[4] =            {+1, -1, +0, +0};

ll gcd(ull a, ull b){
    return (a==0)?b:gcd(b%a,a);
}

ll lcm(ull a, ull b){
    return a*(b/gcd(a,b));
}

const long long INF = 1e18;

using namespace std;

int dp[10001];

int main(){
    for(int x=1;true;++x){
        bool tmp1 = false;
        for(int y=1;true;++y){
            bool tmp2 = false;
            for(int z=1;true;++z){
                int ans = x*x + y*y + z*z + x*y + y*z + x*z;
                if(ans > 10000){
                    break;
                }else{
                    tmp1 = true;
                    tmp2 = true;
                    ++dp[ans];
                }
            }
            if(!tmp2){
                break;
            }
        }
        if(!tmp1){
            break;
        }
    }
    int n;
    cin >> n;
    for(int i=1;i<=n;++i){
        cout << dp[i] << endl;
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)

using namespace std;
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;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() {
    int n;
    cin >> n;
    V<int> b(n-1);
    V<int> a(n);
    rep(i,n-1) {
        cin >> b[i];
    }
    int res = 0;
    rep(i,a.size()) {
        if (i==0) {
            res = b[i];
        } else if (i==a.size()-1) {
            res += b[i-1];
        } else {
            res += min(b[i], b[i-1]);
        }
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int a, b, m;
	cin >> a >> b >> m;
	vi h(a), g(b);
	int mn = 1e9;
	rep(i, a) cin >> h[i], mn = min(mn, h[i]);
	int mn1 = 1e9;
	rep(i, b) cin >> g[i], mn1 = min(mn1, g[i]);
	int ans = mn + mn1;
	rep(i, m){
		int x, y, c;
		cin >> x >> y >> c;
		x--, y--;
		ans = min(ans, h[x] + g[y] - c);
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1024
import numpy as np

def input_numbers():
    temp = list(map(int, input().split()))
    return temp

def GCD(a, b):
    if(a < b):
        temp = a
        a = b
        b = temp
    a = a % b
    if(a == 0):
        return b
    else:
        return GCD(a, b)

class point:
    def __init__(self, x ,y):
        self.x = x
        self.y = y

n = int(input())
names = []

for i in range(n):
    names += [input()]

march = 'MARCH'
count = []
for i in range(5):
    count += [0]

for i in range(n):
    for j in range(5):
        if(names[i][0] == march[j]):
            count[j] += 1

ans = 0
for i in range(5):
    for j in range(5):
        for k in range(5):
            if(i < j and j < k):
                ans += (count[i] * count[j] * count[k])

print(ans)

Measured memory_bytes: 28216
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N, M, ans = 1, A;
    cin >> N >> M;
    for (int64_t i = 1; i * i <= M; i++) {
        if (M % i == 0 && i * N <= M) {
            if (M / i * N <= M) {
                ans = max(M / i, ans);
            }
            else {
                ans = max(i, ans);
            }
        }

    }
    
    cout << ans << endl;


}


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

vector<int> ve;
vector<char> vc;
char ary[1000010];
int main(){
	cin>>ary;
	int cnt,res,ves,sta;
	char nw='X';
	cnt=0;
	sta=strlen(ary);
	for(int i=0;i<sta;i++){
		if(nw==ary[i]){
			cnt++;
		}
		else{
			vc.push_back(nw);
			nw=ary[i];
			ve.push_back(cnt);
			cnt=1;
		}
	}
	vc.push_back(nw);
	ve.push_back(cnt);
	ve.erase(ve.begin());
	vc.erase(vc.begin());
	res=0;
	ves=ve.size();
	if(ves>2)for(int i=0;i<ves-2;i++){
		if(vc[i]=='J'&&vc[i+1]=='O'&&vc[i+2]=='I'&&ve[i]>=ve[i+1]&&ve[i+2]>=ve[i+1]){
			res=max(res,ve[i+1]);
		}
	}
	else res=0;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 9120
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
#define MOD 1000000007
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	int X, A, B;
	cin >> X >> A >> B;
	if (A >= B)
		cout << "delicious";
	else if (B - A <= X)
		cout << "safe";
	else
		cout << "dangerous";
}

Measured memory_bytes: 256
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()

if N >= M:
    print(0)
else:
    sub_X = []
    for i in range(0, M - 1):
        sub_X.append((i, abs(X[i+1] - X[i])))
    sub_X.sort(key=lambda x: x[1], reverse=True)

    division = set()
    if len(sub_X) != 0:
        for i in range(N-1):
            division.add(sub_X[i][0])
    ans = 0
    start = X[0]
    for i in range(M):
        if i in division:
            ans += X[i] - start
            start = X[i+1]
        if i == M-1:
            ans += X[i] - start

    print(ans)

Measured memory_bytes: 20432
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する
vector<vector<int> > G;//頂点iからjまでのグラフが入る,1beginの仕様,普通のワーシャルフロイドでは使わない。
vector<vector<int> > d;//頂点iからjまでの最短距離
int V;//超点数

void washall() {
    for (int k = 1; k <= V; k++) {
            for (int i = 1; i <= V; i++) {
                for (int j = 1; j <= V; j++) {
                    if (d[i][j] > d[i][k] + d[k][j]) {
                    d[i][j] = d[i][k] + d[k][j];
                }
            }
        }
    }
}

void print_d() {
    if (!DEBUG) return;
    REP(i, 1, V + 1) {
        REP(j, 1, V + 1) {
            cout << d[i][j] << " ";
        }
        cout << endl;
    }
}

bool check(int i, int j) {
    if (G[i][j] == INF)return false;
    REP(s, 1, V + 1) {
        REP(t, 1, V + 1) {
            if (d[s][i] + G[i][j] + d[j][t] == d[s][t] || d[i][j] == G[i][j]) {
//                printf("i = %d,j = %d,G[i][j] = %d\n", i, j, G[i][j]);
                return true;
            }
        }
    }
    return false;
}


int main() {
    int N, M;
    cin >> N >> M;
    V = N;
    G = vector<vector<int> >(N + 1, vector<int>(N + 1, INF));
    d = vector<vector<int> >(N + 1, vector<int>(N + 1, INF));
    REP(i, 0, M) {
        int a, b, c;
        cin >> a >> b >> c;
        G[a][b] = c;
        G[b][a] = c;
        d[a][b] = c;
        d[b][a] = c;
    }
    washall();
    int need = 0;
    REP(i, 1, V + 1) {
        REP(j, 1, V + 1) {
            if (i == j) continue;
            if (check(i, j)) {
                need++;
            }
        }
    }
    print_d();
//    printf("need,%d\n", need);
    need /= 2;
    cout << M - need << endl;

    return 0;
}


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

int main() 
{
	int n,r;
	cin>>n;
	r=n%1000;
	if(r==0)
	printf("0\n");
	if(r!=0)
	{
		printf("%d\n",1000-r);
	}
	
	
	return 0;
}

Measured memory_bytes: 3724
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n, m = inm()
print(n*(n-1) // 2 + m*(m-1) // 2)

Measured memory_bytes: 9024
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    int n=s.length();
    int c=0;
    rep(i,0,n){
        if(s[i]=='x') c++;
    }
    cout << (15-c>=8?"YES":"NO")<<"\n";
}

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

using namespace std;

int main()
{
  string S;
  cin >> S;
  int a = 0, b = 0, c = 0;
  for (auto& e : S) {
    if (e == 'a') a++;
    if (e == 'b') b++;
    if (e == 'c') c++;
  }
  int mi = min({a, b, c});
  a -= mi;
  b -= mi;
  c -= mi;
  if (a >= 2 || b >= 2 || c >= 2) cout << "NO" << endl;
  else cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#include <unordered_map>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 200005
#define inf 2000000000
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef pair<int, int> pr;
typedef pair<pair<int, int>, int> tup;

void dfs(int v, int pred, int c, vector<vector<pr>> &g, vector<int> &ar)
{
	int cur_c = 1;
	for (pr to : g[v])
	{
		if (to.first == pred)
			continue;
		if (cur_c == c)
			cur_c++;

		ar[to.second] = cur_c;
		dfs(to.first, v, cur_c, g, ar);
		cur_c++;
	}
}

inline void solve()
{
	int n;
	cin >> n;
	vector<vector<pr>> g(n);
	vector<int> v(n - 1);
	fore(i, 0, n - 1)
	{
		int t1, t2;
		cin >> t1 >> t2;
		--t1;
		--t2;
		g[t1].push_back({ t2, i });
		g[t2].push_back({ t1, i });
	}
	dfs(0, -1, -1, g, v);
	int otv = 0;
	fore(i, 0, n - 1)
	{
		otv = max(otv, v[i]);
	}

	cout << otv;
	cout << '\n';
	fore(i, 0, n - 1)
		cout << v[i] << '\n';
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

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

int main(){
  string str;
  int i,count,n;
  
  cin>>str;
  n=str.size();
  count=0;
  for(i=0;i<n/2;i++){
    if(str.at(i)!=str.at(n-i-1)){
      count++;
    }
  }
  cout<<count<<endl;
}
  

Measured memory_bytes: 256
#学習用
def root(x):
    # xが根であれば
    if x == p[x]:
        # xを返す
        return x
    # xが根でなければp[x]の根をp[x]に設定する
    p[x] = y = root(p[x])
    # p[x]の根を返却する
    return y
def unite(x, y):
    # xとyの根を取得する
    px = root(x); py = root(y)
    # xとyの根が同じならば
    if px == py:
        # 根が同じならば、0を返す
        return 0
    # yの根がxの根より大きければ、
    if px < py:
        # yの根の位置のp[]を、xの根にする
        p[py] = px
        # xの根の位置のサイズszを、yの根の位置のサイズだけ加算する
        sz[px] += sz[py]
    else:
    # yの根がxの根より小さければ
        # xの根の位置のp[]を、yの根を指すようにする
        p[px] = py
        sz[py] += sz[px]
    # 根が異なっていた＝結合した場合は、1を返却する
    return 1

N , M = map(int, input().split())
*p , = range(N)
sz = [1] * N
E = []
for i in range(M):
    a , b = map(int, input().split())
    E.append((a-1, b-1))

ans = [None] * M
E.reverse()
res = 0
ans[-1] = "%d\n" % (N*(N-1)//2)

for i , (a,b) in enumerate(E[:-1]):
    # aのサイズとbのサイズを取得
    sa = sz[root(a)]; sb = sz[root(b)]
    if unite(a , b):
    # aとbを結合した場合（直前には結合されていなかった場合）
        # aの根の位置のサイズを取得
        sc = sz[root(a)]
        # 結合後したグループの組み合わせを加算し、結合前のaとbの各グループの組み合わせを引く
        res += sc*(sc-1)//2 - sa*(sa-1)//2 - sb*(sb-1)//2
    # 回答の配列に、新たな橋を考慮した組み合わせの数を引く
    ans[-2-i] = "%d\n" % (N*(N-1)//2 -res)
open(1, 'w').writelines(ans)    

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

void printArray(int A[], int N) {
    for(int i=0; i<N; i++){
        cout << A[i];
        if(i == N-1){
            cout << endl;
        }else{
            cout << " ";
        }
    }
}

void selectionSort(int A[], int N){
    int i, j, minj, count = 0;
    for(i=0; i<N; i++){
        minj = i;
        for(j=i; j<N; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        swap(A[i], A[minj]);
        if(i != minj) count++;
    }
    // print array
    printArray(A, N);
    cout << count << endl;
}


int main(void){
    int A[102];
    int N;
    cin >> N;
    
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    selectionSort(A, N);
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;

int main() {
	int A, B;
	cin >> A >> B;
	for (size_t i = 1; i < 100000; i++)
	{
		if (int(0.08 * i) == A && int(0.1 * i) == B) {
			cout << i;
			return 0;
		}
	}
	cout << -1;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	long long int sum=0;
	int max,min,n,a,i=1;
	
	scanf("%d",&n);
	while(i<=n)
	{
		scanf("%d",&a);
		if(i==1) min=max=a;
        if(max<a)
            max=a;
        else if(min>a)
            min=a;
        sum=sum+a;
		i++;
	}
	printf("%d %d %lld\n",min,max,sum);
	return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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; }

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int x,y,z;
	cin >> x >> y >> z;
	swap(x,y);
	swap(x,z);

	printf("%d %d %d", x, y, z);
	return 0;
}

Measured memory_bytes: 256
use std::io;
fn read<T: std::str::FromStr>() -> T {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn main() {
    loop {
        let n: Vec<usize> = read_vec();
        if n[0] == 0 && n[1] == 0 {
            break;
        }
        for i in 0..n[0] {
            println!("{}", "#".repeat(n[1]));
        }
        println!();
    }
}



Measured memory_bytes: 5020
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;

int main() {
  int x;
  int rate;
  cin >> x;
  if (400 <= x) {
    if (600 <= x) {
      if (800 <= x) {
        if (1000 <= x) {
          if (1200 <= x) {
            if (1400 <= x) {
              if (1600 <= x) {
                if (1800 <= x) {
                  rate = 1;
                } else {
                  rate = 2;
                }
              } else {
                rate = 3;
              }
            } else {
              rate = 4;
            }
          } else {
            rate = 5;
          }
        } else {
          rate = 6;
        }
      } else {
        rate = 7;
      }
    } else {
      rate = 8;
    }
  }
  cout << rate << endl;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x 
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll dp[22][(1<<22)];
int solve(vector<vector<int>>& compat, int i, int womenSubset, int N)
{
    if(i == N+1)
    {
        if(womenSubset == 0)
            return 1;
        return 0;
    }

    if(dp[i][womenSubset] != -1)
        return dp[i][womenSubset];
    ll ans = 0;
    for(int women = 0; women < N; women++)
    {
        bool available = (((1<<women)&(womenSubset)) == 0) ? 0 : 1;
        if(available && compat[i][women + 1])
        {
            ans = (ans + solve(compat, i+1, womenSubset ^ (1<<women), N)) % mod;
        }
    }
    return dp[i][womenSubset] = ans;
}

int main() {
   int n;
   cin >> n;
   vector<vector<int>> compat(n+1, vector<int>(n+1));
   memset(dp, -1, sizeof dp);
   for(int i = 1; i<=n; i++)
        for(int j = 1; j <= n; j++)
            cin >> compat[i][j];
   cout<<solve(compat, 1, ((1<<(n)) - 1), n);
   return 0;
}


Measured memory_bytes: 721152
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		//int N = sc.nextInt();
    	//int M = sc.nextInt();
      	String S = sc.next();
      	//int list[] = new int[N];
      	//for(int i=0;i<N;i++){
        //	list[i] = sc.nextInt();
        //}
      	//Arrays.sort(list);
      	boolean o1 = S.charAt(0) == 'A';
      	boolean o3 = true;
      	for(int i=1;i<S.length();i++){
        	if(S.charAt(i)!='C' && Character.isUpperCase(S.charAt(i))){
            	o3 = false;
              	break;
            }
        }
      	int cnt = 0;
      	boolean o2 = true;
      	if(S.charAt(0)=='C' ||S.charAt(1)=='C'||S.charAt(S.length()-1)=='C'){
        	o2 = false;
        }else{
      	for(int i=0;i<S.length();i++){
        	if(S.charAt(i) == 'C'){
            	cnt++;
            }
        }
        if(cnt!=1){
                  	o2 = false;
                	
                }
        }
      	if(o1 && o2 && o3){
        	System.out.println("AC");
        }else{
        	System.out.println("WA");
        }
    }
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int sum(int M){
  if(M/10) return sum(M/10)+M%10;
  else return M;
}
int main(){
  int N;
  cin>>N;
  int ans=10000;
  rep(i,N/2){
    int x=sum(i+1)+sum(N-i-1);
    ans=min(ans,x);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int a, b; cin >> a >> b;
	if (a >= 10 || b >= 10) {
		cout << -1 << endl;
		return;
	}
	cout << a * b << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
N=int(input())
A=[0,0,0,0]
for i in range(N):
  a=input()
  if a=='AC':
    A[0]+=1
  elif a=='WA':
    A[1]+=1
  elif a=='TLE':
    A[2]+=1
  else:
    A[3]+=1
print('AC x',A[0])
print('WA x',A[1])
print('TLE x',A[2])
print('RE x',A[3])

Measured memory_bytes: 9208
def main():
    import sys
    N=int(sys.stdin.readline())
    L=[0]*(10**4+1)
    for x in range(1,1000):
        for y in range(x,1000):
            for z in range(y,1000):
                r=x**2+y**2+z**2+x*y+y*z+z*x
                if r>10**4:
                    break
                
                c=len(set((x,y,z)))
                if c==3:
                    L[r]+=6
                elif c==2:
                    L[r]+=3
                elif c==1:
                    L[r]+=1


    for t in L[1:N+1]:
        print(t)

main()

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

typedef long long ll;


int main()
{
    int N;
    int A[10005], B[10005];
    int sa[10005];

    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];

    for(int i = 0; i < N; i++) sa[i] = B[i] - A[i];

    ll add = 0;
    for(int i = 0; i < N; i++) {
        int cnt = sa[i] / 2;
        if(cnt > 0) {
            add += cnt;
            sa[i] -= cnt * 2;
        }
    }
    bool possible = true;
    for(int i = 0; i < N; i++) {
        if(add < -sa[i]) {
            possible = false;
        } else {
            if(sa[i] < 0) {
                add += sa[i];
                sa[i] = 0;
            }
        }
    }
    if(possible) cout << "Yes" << endl;
    else cout << "No" << endl;

    return (0);
}


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

using namespace std;

#define make_unique(a) (a.erase(unique(a.begin(),a.end()),a.end()))
#define allof(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define exists(s, e) (s.find(e)!=s.end())
#define INF 0x3f3f3f3f
#define endl '\n'
#define mp make_pair
#define readln(x) (getline(cin, x))
#define watch(x) cout << (#x) << " is " << (x) << endl;

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

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

const int MAXN = 1e5 + 5;

ll dp[MAXN];

void solve() {
    fill(dp, dp+MAXN-1, 1LL<<30);
    int n, k;
    cin >> n >> k;
    vector<int> h(n+1);
    for(int i=1; i<=n; i++) cin >> h[i];
    dp[1] = 0;
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=k and (i+j)<=n; j++) {
//            printf("index: i=%d j=%d ", i, j);
//            printf("passed!\n");
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]));
        }
    }
//    cout << endl;
    cout << dp[n] << endl;
//    for(int i=1; i<=n; i++) cout << dp[i] << " ";
//    cout << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    solve();
    return 0;
}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
 
#define debug(x) cout << '>' << #x << ':' << x << endl;
 
#define nitro ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
const int mod = 1e9+7;
using namespace std;
using ll = long long int;
const ll invmod = 998244353; 
const int N = 5*(int)(1e5) + 1;
const int MAXN = 1e5+10;
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
 
 
bool compareByfirst(tuple<int, int, int>&a, tuple<int, int, int>&b)
{
	return get<0>(a) > get<0>(b);
}
bool compareBySecond(tuple<int, int, int>&a, tuple<int, int, int>&b)
{
	return get<1>(a) < get<1>(b);
}
 
int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	//clock_t time_req;time_req = clock();
	nitro;
	int a[5];
	for(int i = 0; i < 5; i++)
	{
		cin >> a[i];
	}
	for(int i = 0; i < 5; i++)
	{
		if(a[i] == 0)
		{
			cout << i+1 << '\n';
			break;
		}
	}
}

Measured memory_bytes: 3640
N = int(input())
S = input()

alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
ans = ""

for i in range(len(S)):
    for j in range(26):
        if S[i] == alphabets[j]:
            if j + N < 26:
                ans += alphabets[j + N]
            else:
                ans += alphabets[j + N - 26]
            break
print(ans)


Measured memory_bytes: 3060
A,B,C=map(int,input().split())
if A%2!=0 or B%2!=0 or C%2!=0:
    print(0)
    exit()


if A==B==C:
    print(-1)
    exit()

c=0
while A%2==0 and B%2==0 and C%2==0:
    c+=1
    newA=B//2+C//2
    newB=C//2+A//2
    newC=A//2+B//2
    A=newA
    B=newB
    C=newC

print(c)



Measured memory_bytes: 3060
#include<iostream>
using namespace std;
#include<cstdio>
#include<cmath>

struct Point{ double x, y; };

Point set_p(double a, double b)
{
    Point p;
    p.x = a; p.y = b;
    return p;
}

struct Vector{ double vx, vy; };

Vector set_v(const Point &p1, const Point &p2)
{
    Vector v;
    v.vx = p2.x - p1.x;
    v.vy = p2.y - p1.y;
    return v;
}

double dot(const Vector &v1, const Vector &v2)
{
    return (v1.vx * v2.vx) + (v1.vy * v2.vy);
}

double cross(const Vector &v1, const Vector &v2)
{
    return (v1.vx * v2.vy) - (v1.vy * v2.vx);
}

double cross0(const Point &P0, const Point &P1)
{
	return (P0.x * P1.y) - (P1.x * P0.y);
}

double onenorm(const Vector &v)
{
    return abs(v.vx) + abs(v.vy);
}

double norm(const Vector &v)
{
	return sqrt(v.vx * v.vx + v.vy * v.vy);
}

int ccw(const Point &P0, const Point &P1, const Point &P2)
{
    Vector V1 = set_v(P0, P1);
    Vector V2 = set_v(P0, P2);
    double c = cross(V1, V2);
    if(c > 0){ return 1; }else if(c < 0){ return -1; }
    if(dot(V1, V2) < 0){ return -2; }
    if(onenorm(V1) < onenorm(V2)){ return 2; }
    return 0;
}

int intersect(const Point &P0, const Point &P1, const Point &P2, const Point &P3)
{
    if(ccw(P0, P1, P2) * ccw(P0, P1, P3) <= 0 && ccw(P2, P3, P0) * ccw(P2, P3, P1) <= 0){
        return 1;
    }else{
        return 0;
    }
}

double dist_seg(const Point &P0, const Point &P1, const Point &P2) // Segment P0P1 & Point P2.
{
    Vector V01 = set_v(P0, P1), V12 = set_v(P1, P2), V02 = set_v(P0, P2);
    if(dot(V01, V12) > 0) return norm(V12);
    if(dot(V01, V02) < 0) return norm(V02);
    double c_sum;
    c_sum = cross0(P0, P1) + cross0(P1, P2) + cross0(P2, P0);
    if(c_sum < 0) c_sum *= -1.0;
    return c_sum / norm(V01);
}

int main()
{
    int q;
    double x0, y0, x1, y1, x2, y2, x3, y3, dist;
    Point P0, P1, P2, P3;
    scanf("%d", &q);

    for(int i = 0; i < q; i++){
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3);
        P0 = set_p(x0, y0), P1 = set_p(x1, y1), P2 = set_p(x2, y2), P3 = set_p(x3, y3);
        if(intersect(P0, P1, P2, P3)){
            printf("0\n");
        }else{
            dist = min(min(dist_seg(P0, P1, P2), dist_seg(P0, P1, P3)), min(dist_seg(P2, P3, P0), dist_seg(P2, P3, P1)));
            printf("%.13f\n", dist);
        }
    }
    return 0;
}

Measured memory_bytes: 1260
# 入力：整数a b
# 出力：積が奇数なら Odd と、 偶数なら Even と出力せよ。

a,b = gets.chomp.split(" ").map(&:to_i)
c = a * b
if c % 2 == 0
    puts("Even")
else 
    puts("Odd")
end

Measured memory_bytes: 1788
from math import ceil


def solve(string):
    b, a = map(int, string.split())
    h = 2 * ceil(max((a - 1) / 25, (b - 1) / 25)) + 1
    a -= 1
    b -= 1
    ans = []
    ans.append("{} {}".format(h, 100))
    for i in range(h):
        if i % 2 == 0:
            ans.append("." * 50 + "#" * 50)
        else:
            if a > 0 and b > 0:
                ma = min(a, 25)
                mb = min(b, 25)
                ans.append("#." * ma + "##" * (25 - ma) + "#." * mb + "##" * (25 - mb))
                a -= ma
                b -= mb
            elif a == 0 and b > 0:
                mb = min(b, 25)
                ans.append("." * 50 + "#." * mb + "##" * (25 - mb))
                b -= mb
            elif a > 0 and b == 0:
                ma = min(a, 25)
                ans.append("#." * ma + "##" * (25 - ma) + "#" * 50)
                a -= ma
            """
            ma = min(a, 25)
            mb = min(b, 25)
            ans.append("#." * ma + "##" * (25 - ma) + "#." * mb + "##" * (25 - mb))
            a -= ma
            b -= mb
            a = max(a, 0)
            b = max(b, 0)
            """
    return "\n".join(ans)


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 3064
import java.util.*;
import java.io.*;

public class Main {	
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		int N = fs.nextInt();
		long ans=0;
		
		for(int i=1; i<=N; i++){
			if((i%3==0&&i%5==0)||(i%3==0)||(i%5==0)){
			}else{
				ans +=i;
			}
		}
		
		System.out.println(ans);

	}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");

		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) {
				a[i]=nextInt();
			}
			return a;
		}

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

	}
}


Measured memory_bytes: 32824
N,M = map(int, raw_input().split())
EDGES = {}
d = [[float('inf') for j in range(N)] for i in range(N)]
for i in range(M):
  a,b,c = map(int, raw_input().split())
  a -= 1
  b -= 1
  EDGES[(min(a,b),max(a,b))] = c
  d[a][b] = c
  d[b][a] = c

for k in range(N):
  for i in range(N):
    for j in range(N):
      if(d[i][j] > d[i][k] + d[k][j]):
        d[i][j] = d[i][k] + d[k][j]

unused = 0
for j in range(N):
  for i in range(j):
    if((i,j) in EDGES and EDGES[(i,j)] != d[i][j]):
      unused += 1
print unused

Measured memory_bytes: 3204
#include <iostream>

using namespace std;

int N, T;
int t[200000];

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> T;

    for(int i = 0; i < N; i++)
        cin >> t[i];

    int ans = T;

    for (int i = 0; i < N - 1; i++)
        ans += min(t[i + 1] - t[i], T);
    
    cout << ans << '\n';

}



Measured memory_bytes: 1024
ans = 0

def check(num_str):
    for i in ['7', '5', '3']:
        if i not in num_str:
            return 0
    return 1

def make_data(num, num_str):
    global ans
    if num < int(num_str):
        return
    if check(num_str):
        ans += 1

    make_data(num, num_str + '7')
    make_data(num, num_str + '5')
    make_data(num, num_str + '3')


def main():
    num = int(input())
    make_data(num, '0')

    global ans
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define ll long long
const int N = 1e6 + 10;
using namespace std;
string s;
int main() {
  ios::sync_with_stdio(false);
   cin>>s;
   int len=s.size();
   while(len--)   cout<<"x";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string a,b,c;
  int len;
  cin>>len;
  cin>>a>>b>>c;
  // int len = a.length();
  int ans = 0;
  for(int i=0;i<len;i++){
    if(a[i] != b[i] && a[i] != c[i] && b[i] != c[i]) ans += 2;
    if(a[i] == b[i] && b[i] == c[i])continue;
    if(a[i] == b[i] || a[i] == c[i] || b[i] == c[i]) ans ++;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int N;
int arr[200005], ans[200005];
vector<int> v;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> N;
    for(int i = 1; i<=N; i++){
        cin >> arr[i];
    }
    for(int i = N; i>0; i--){
        int tot = 0;
        for(int j = i; j<=N; j+=i){
            tot += ans[j];
        }
        if(tot%2 != arr[i]){
            ans[i] ^=1;
            v.push_back(i);
        }
    }
    cout << v.size() << "\n";
    for(int n : v){
        cout << n << " ";
    }
}


Measured memory_bytes: 2936
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;


    bool flag = false;
    if((b-a) > k){
        flag = true;
    }else if((c-a) > k){
        flag = true;
    }
    else if((c-d) > k){
        flag = true;  
    }
    else if((e-a) > k){
        flag = true;
    }
    else if((c-b) > k){
        flag = true;
    }
    else if((d-b) > k){
        flag = true;
    }
    else if((e-b) > k){
        flag = true;
    }
    else if((d-c) > k){
        flag = true;
    }
    else if((e-c) > k){
        flag = true;
    }
    else if((e-d) > k){
        flag = true;
    }

    if(flag){
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>

ll N;
int main(){
    cin>>N;
    map<string, ll> mp;
    int flg=0;
    rep(i,0,N){
        string s; cin >> s;
        mp[s]++;
        if(mp[s]>1)flg=1;
    }
    if(flg==0)cout<<"YES";
    else cout<<"NO";

    return 0;
}

Measured memory_bytes: 24832
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}

/*!* [itertools] *!*/
/*+* イテレータの操作 *+*/
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}

int main() {
    int N;
    const int M = 4e6;
    cin >> N;
    vector<int> A(N);
    for(int &a : A) cin >> a;
    bitset<M + 1> dp;
    dp[0] = true;
    for(int i = 0; i < N; i++) {
        dp |= dp << A[i];
    }
    int S = sum_up(WHOLE(A));
    int ans = 0;
    for(int j = M; 2 * j >= S; j--) {
        if(dp[j]) ans = j;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
int main(){
  int n,x;
  cin >> n >> x;
  int res = 1;
  int dis = 0;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    dis += a;
    if(dis > x){
      cout << res << endl;
      return 0;
    }
    res ++;
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256