akhauriyash/Code-Regression huggingface dataset:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

k = I()
n = 0
c = 0

for i in range(10**6):
    c += 1
    n = ( 10*n + 7 )%k
    if n==0:
        print(c)
        exit()

print(-1)
exit()

Measured memory_bytes: 77228
#include<iostream>
#include<queue>
#define N 100
#define NIL -1

int M[N][N];
int d[N];
int n;

// 初期化処理後、sを開始地点として幅優先探索を行い、探索結果を出力する
// d[N]にはsからの距離を記録し(sは0)、sからたどり着けない頂点はNIL(空)を記録する
void bfs(int s)
{
	for (int i = 0; i < n; i++)d[i] = NIL;

	std::queue<int> Q;
	Q.push(s);
	d[s] = 0;

	while (!Q.empty())
	{
		int u = Q.front();
		Q.pop();
		for (int v = 0; v < n; v++)
		{
			if (M[u][v] == 0)continue;
			if (d[v] != NIL) continue;
			Q.push(v);
			d[v] = d[u] + 1;
		}
	}

	for (int i = 0; i < n; i++)
	{
		std::cout << i + 1 << " " << d[i] << std::endl;
	}
}

int main()
{
	std::cin >> n;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			M[i][j] = 0;
		}
	}

	int u, v, k;
	for (int i = 0; i < n; i++)
	{
		std::cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++)
		{
			std::cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	bfs(0);
}


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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopenen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    int n;
    cin >> n;
    int dp[100005][3];
    int A[100005],B[100005],C[100005];

    FOR(i,0,n){
        cin >> A[i] >> B[i] >> C[i];
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+A[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+B[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+C[i];
    }

    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
int main() {
	std::string str;
	std::cin >> str;
	int ans = 0x7fffffff;
	for (int i = 0; i < str.length() - 2; ++i) {
		ans = std::min(ans, abs(753-std::stoi(str.substr(i, 3))));
	}
	std::cout << ans << std::endl;
}

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

int main()
{
    int n;
    cin>>n;
    vector<string> s(n);
    map<string,int> m;

    for (int i=0;i<n;i++){
        cin>>s[i];

        m[s[i]]+=1;
    }

    int max=0;
    for (const auto& x:m){
        int v=x.second;
        if(v>max) max=v;
    }
    for (auto i=m.begin();i!=m.end();i++){
        if(i->second==max){
            cout<<i->first<<endl;
        }
    }

    


}

Measured memory_bytes: 25152
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

bool ok[100005];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;cin >>n >> m;
  vector<ll> h(n);
  rep(i,n){
    ok[i] = true;
  }
  rep(i,n){
    cin >> h[i];
  }
  rep(i,m){
    ll a,b;cin >> a >> b;
    a--;b--;
    if(h[a] > h[b])ok[b] = false;
    if(h[a]< h[b] ) ok[a] = false;
    if(h[a]==h[b]){
      ok[a] = false;
      ok[b] = false;
    }
  }
  ll ans = 0;
  rep(i,n){
    ans += ok[i];
  }
  cout << ans << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	cin >> n;
	ll res = 0;
	map<string, ll> mp;
	rep (i, n) {
	  string s;
	  cin >> s;
	  sort(s.begin(), s.end());
	  res += mp[s]++;
	}
	cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 11488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
const ll mod = 1000000007;
const ll INF = 1000000000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);
vector<vector<pair<ll,ll>>> e(310,vector<pair<ll,ll>>(0));
ll n;

template <typename T>
vector<T> dijkstra(int s,vector<vector<pair<T, T> > > & G){     
  using Pa = pair<T, T>;
  vector<T> D(301,INF);//----------------
  priority_queue<Pa,vector<Pa>,greater<Pa> > q;
  D[s]=0;
  q.emplace(D[s],s);//最短距離、ゴール頂点番号

  while(!q.empty()){
    ll spath=q.top().first;
    int v=q.top().second;
    q.pop();

    if(D[v]<spath) continue;
    for(auto& e:G[v]){
      int u=e.first;//頂点番号
      T c=e.second;//最短距離
      if(D[u]>D[v]+c){
        D[u]=D[v]+c;
        q.emplace(D[u],u);
      }
    }
  }
  return D;
}

signed main(){
    ll ans=0;cin>>n;
    vector<tuple<int,int,int>> v(0);
    for(int i=0;i < n;i++)
    {
        for(int j=0;j < n;j++)
        {   
            int l;cin>>l;
            if(i<j){
                v.emplace_back(l,i,j);
            }
        }
    }

    sort(all(v));

    for(int i=0;i < siz(v);i++)
    {    
        ll el=get<0>(v[i]);
        ll a=get<1>(v[i]);
        ll b=get<2>(v[i]);
        vector<ll> u = dijkstra(a,e);
        ll spath = u[b];
        //cout<<a<<":"<<b<<";"<<spath<<":"<<el<<endl;

        if(el<spath || i==0){
            e[a].emplace_back(b,el);
            e[b].emplace_back(a,el);
            ans+=el;
            //cout<<"DEBUG"<<ans<<endl;
        }else if(spath<el){
            cout<<-1<<endl;
            return 0;
        }
    }

    cout<<ans<<endl;
}

/* */
            

Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

template <typename T>
struct twodimBIT
{
// 1-indexed
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3095512#1
// https://www.slideshare.net/hcpc_hokudai/binary-indexed-tree
private:
	vector< vector<T> > array;
	const ll n;
	const ll m;

public:
	twodimBIT(ll _n,ll _m):
		array(_n+1,vector<T>(_m+1,0)), n(_n),m(_m){}

	// (1,1) ~ (x,y) ruisekiwa
	T sum(ll x,ll y) {
		T s = 0;
		for(ll i=x;i>0;i-=i&(-i))
			for(ll j=y;j>0;j-=j&(-j))
				s += array[i][j];
		return s;
	}

	// [(x1,y1),(x2,y2)] no souwa (x1<x2,y1<y2)
	T sum(ll x1,ll y1,ll x2,ll y2){
		return sum(x2,y2) - sum(x1-1,y2) - sum(x2,y1-1) + sum(x1-1,y1-1);
	}

	void add(ll x,ll y,T k) {
		for(ll i=x;i<=n;i+=i&(-i))
			for(ll j=y;j<=m;j+=j&(-j))
				array[i][j] += k;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,K;
	cin >> N >> K;
	twodimBIT<ll> hope(3*K+3,3*K+3);
	FOR(i,0,N){
		ll x,y;
		char c;
		cin >> x >> y >> c;
		if(c=='W')y+=K;
		x %= 2*K;
		y %= 2*K;
		if(x<0)x += 2*K;
		if(y<0)y += 2*K;
		hope.add(x+1,y+1,1ll);
	}
	ll ans = 0;
	FOR(i,1,K+2){
		FOR(j,1,K+2){
			ll t = hope.sum(i,j,i+K-1,j+K-1);
			t += hope.sum(i+K,j+K,i+2*K-1,j+2*K-1);
			t += hope.sum(max(0ll,i-K),max(0ll,j-K),i-1,j-1);
			t += hope.sum(max(0ll,i-K),j+K,i-1,j+2*K-1);
			t += hope.sum(i+K,max(j-K,0ll),i+2*K-1,j-1);
			ans = max( ans , t );
			ans = max( ans , N-t );
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 71040
#include <stdio.h>

int main() {
  int i;
  
  scanf("%d", &i);
  
  if(i>=400 && i<600) {
    printf("8");
  } else if(i>=600 && i<800) {
    printf("7");
  } else if(i>=800 && i<1000) {
    printf("6");
  } else if(i>=1000 && i<1200) {
    printf("5");
  } else if(i>=1200 && i<1400) {
    printf("4");
  } else if(i>=1400 && i<1600) {
    printf("3");
  } else if(i>=1600 && i<1800) {
    printf("2");
  } else if(i>=1800 && i<2000) {
    printf("1");
  } else {
    printf("error");
  }
  
  return 0;
}

Measured memory_bytes: 1664
#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 N; cin >> N;
	vvi abc(N, vi(3));
	REP(i, N) cin >> abc[i][0] >> abc[i][1] >> abc[i][2];

	vvi dp(N + 1, vi(3, 0));
	REP(i, N) {
		REP(j, 3) {
			REP(k, 3) {
				if (j == k) continue;
				dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k]);
			}
		}
	}
	cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
}

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


Measured memory_bytes: 11264
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    a=parseMap(split(readline()))
    res=1
    cnt=0
    for i in a
        if i==res
            res+=1
        else
            cnt+=1
        end
    end
    if cnt==n
        println(-1)
    else
        println(cnt)
    end
end
main()

Measured memory_bytes: 123268
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  string S, T;
  cin >> S >> T;
  
  cout << T << S << endl;
  
  return 0;
}


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

using namespace std;

int main() {
  int n;
  cin>>n;
  vector<int> v(n);
  REP(i,n) cin>>v[i];
  sort(ALL(v));
  deque<int> v2(ALL(v));
  deque<int> v3(ALL(v));
  deque<int> d;
  int c = 1;
  REP(i,n) {
    if (c < 2) {
      int a = v2.front();
      v2.pop_front();
      if (c == 0) d.push_front(a);
      else d.push_back(a);
    } else {
      int a = v2.back();
      v2.pop_back();
      if (c == 2) d.push_front(a);
      else d.push_back(a);
    }
    c++;
    c %= 4;
  }
  int64_t sum = 0;
  REP(i,n-1) {
    sum += abs(d[i] - d[i+1]);
  }
  c = 3;
  d.clear();
  REP(i,n) {
    if (c < 2) {
      int a = v3.front();
      v3.pop_front();
      if (c == 0) d.push_front(a);
      else d.push_back(a);
    } else {
      int a = v3.back();
      v3.pop_back();
      if (c == 2) d.push_front(a);
      else d.push_back(a);
    }
    c++;
    c %= 4;
  }
  int64_t sum2 = 0;
  REP(i,n-1) {
    sum2 += abs(d[i] - d[i+1]);
  }
  cout << max(sum, sum2) << endl;
  return 0;
}


Measured memory_bytes: 1536
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<algorithm>
#define ll long long
#define lowbit(x) x&-x
using namespace std;
int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a<b?b:a;}
int ab(int x){return x>0?x:-x;}
const int inf=0x3f3f3f3f,maxn=100010;
int n;
char s[maxn];
int main(){
    scanf("%s",s);
    n=strlen(s);
    bool ok=0;
    for(int i=1;i<=n;i++)if(s[i]!='0')ok=1;
    if(!ok){printf("%d",n);return 0;}
    for(int i=(n>>1)+(n&1);i<n;i++)if(s[i]!=s[n-i-1]||s[i]!=s[i-1]){printf("%d",i);return 0;}
    printf("%d",n);
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin

import numpy as np

# from itertools import accumulate
# from bisect import bisect_right

# import sys
# sys.setrecursionlimit(10**4)


def _li():
    return list(map(int, stdin.readline().split()))


def _li_():
    return list(map(lambda x: int(x) - 1, stdin.readline().split()))


def _lf():
    return list(map(float, stdin.readline().split()))


def _ls():
    return stdin.readline().split()


def _i():
    return int(stdin.readline())


def _f():
    return float(stdin.readline())


def _s():
    return stdin.readline()[:-1]


N, M, K = _li()
A_list = _li()
B_list = _li()

# cum_a = [0] + list(accumulate(A_list))
# cum_b = list(accumulate(B_list))
cum_a = np.cumsum([0] + A_list)
cum_b = np.cumsum(B_list)
#
# ans = 0
# for i, a in enumerate(cum_a):
#     if a > K:
#         cur = 0
#     else:
#         cur = i
#     cand = bisect_right(cum_b, K - a)
#     ans = max(cur + cand, ans)
ans = 0
for i, a in enumerate(cum_a):
    if a > K:
        cur = 0
    else:
        cur = i
    cand = np.searchsorted(cum_b, K - a, side="right")
    ans = max(cur + cand, ans)

print(ans)


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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

// doc: https://shibh308.github.io/library/library/lib/classes/modint.cpp.html
template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;


signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    mint ans = 1;
    vector<int> v(3, 0);
    for(int i = 0; i < n; ++i){
        int cnt = 0;
        int ex = 0;
        for(int j = 0; j < 3; ++j)
            if(v[j] == a[i]){
                ++cnt;
                ex = j;
            }
        ++v[ex];
        ans *= cnt;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

int main(){
	cin.tie(0);					//cinとcoutの結び付きを解除
	ios::sync_with_stdio(false);//stdioとの同期を解除
	
	int n,cnt1,cnt2;
	cin >> n;
	
	llong r[87];	//0~86
	r[0] = 2;	r[1] = 1;
	REP(i,n-1){
		r[i+2] = r[i] + r[i+1];
	}
	
	cout << r[n];
	
	return 0;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    int a,b,c,x;
    int ans=0;
    cin >> a >> b >> c >> x;
    rep(i,a+1){
        rep(j,b+1){
            rep(k,c+1){
                if(i*500 + j*100+ k*50 == x) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define N 100100
using namespace std;
int n,a[N];
long long ans,ans1;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	if(n%2==0){
		for(int i=n/2+2;i<=n;i++)
			ans+=a[i]*2;
		ans+=a[n/2+1];
		for(int i=1;i<=n/2-1;i++)
			ans-=a[i]*2;
		ans-=a[n/2];
		printf("%lld",ans);
	}
	else{
		for(int i=(n+1)/2+1;i<=n;i++)
			ans+=a[i]*2;
		for(int i=1;i<=(n+1)/2-2;i++)
			ans-=a[i]*2;
		ans-=a[(n+1)/2];
		ans-=a[(n+1)/2-1];
		for(int i=(n+1)/2+2;i<=n;i++)
			ans1+=a[i]*2;
		ans1+=a[(n+1)/2];
		ans1+=a[(n+1)/2+1];
		for(int i=1;i<=(n+1)/2-1;i++)
			ans1-=a[i]*2;
		printf("%lld",max(ans,ans1));
	}
	return 0;
}

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

int main(){
    int n, k;
    while(cin >>n >>k){
        if(n == 0 && k == 0) break;
        vector<int> vec;
        int max = 0, now = 0;
        for(int i = 0; i < k; i++){
            int tmp;
            cin >>tmp;
            max += tmp;
            now += tmp;
            vec.push_back(tmp);
        }
        for(int i = k; i < n; i++){
            int tmp;
            cin >>tmp;
            vec.push_back(tmp);
            now += tmp;
            now -= vec[i - k];
            if(max < now) max = now;
        }
        cout <<max <<endl;
    }
    return 0;
}

Measured memory_bytes: 0
import java.util.*;

class Point{
  private long i;
  private long j;
  
  Point(long i,long j){
    this.i=i;
    this.j=j;
  }

  public long getter(){
    return (this.i+this.j-2);
  }
}

class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    long N=scan.nextLong();
    int k=0;
    Point[] points=new Point[10*10*10*10*10*10];
    for(long i=1;i<=(N/i);i++){
      if(N%i==0){
        long j=N/i;
        points[k++]=new Point(i,j);
      }
    }
    long min=points[0].getter();
    for(int i=0;i<k;i++){
      if(min>points[i].getter()){
        min=points[i].getter();
      }
    }
   System.out.println(min); 
  }
}

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

using lli = int64_t;

using vi = vector<lli>;

lli MOD = 1e9 + 7;

lli U = 1e5 + 10;

vi fact(U + 1);

lli powmod(lli a, lli b)
{
    lli r = 1;

    for(lli i = 0; i < 32; i++, a = (a * a) % MOD)
        if(b & 1 << i) r = (r * a) % MOD;

    return r;
}

lli invmod(lli a)
{
    return powmod(a, MOD - 2);
}

lli binomialmod(lli n, lli k)
{
    if(k > n) return 0;
    if(!k) return 1;

    return (fact[n] * invmod((fact[n - k] * fact[k]) % MOD)) % MOD;
}

void init_fact()
{
    fact[0] = 1;

    for(lli i = 1; i <= U; i++)
        fact[i] = (fact[i - 1] * i) % MOD;
}

int main()
{
    ios_base::sync_with_stdio(0);

    init_fact();

    lli n; cin >> n;

    vi test(n + 1);

    vi v(n + 1);

    lli d = 0;

    for(lli i = 0; i < n + 1; i++)
    {
        cin >> v[i];

        test[v[i]]++;

        if(test[v[i]] == 2) d = v[i];
    }

    lli cnt = 0;

    for(lli i = 0; i < n + 1 && v[i] != d; i++) cnt++;
    for(lli i = n; i >= 0 && v[i] != d; i--) cnt++;
    
    for(lli i = 1; i <= n + 1; i++)
    {
        lli r = binomialmod(n + 1, i);

        r = (MOD + r - binomialmod(cnt, i - 1)) % MOD;

        cout << r << '\n';
    }

    return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))

int n, m;
int A[100000];

int main(){
  int i;
  scanf("%d%d", &n, &m);
  for(i=0;i<m;i++){
    int a, b;
    scanf("%d%d", &a, &b);
    if(A[a-1]) A[a-1] = MIN(A[a-1], b-1);
    else A[a-1] = b-1;
  }
  int min = n;
  int j = 0;
 
  for(i=0;i<n-1;i++){
    if(A[i])  min = MIN(min, A[i]);
    if(i == min-1){
      min = n;
      j++;
    }
  }

  printf("%d\n", j);
  return 0;
}


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

x = []
tmp = 0
for i in range(n):
    if i % 2 == 0:
        tmp += a[i]
    else:
        tmp -= a[i]
x.append(tmp//2)

for i in range(n-1):
    x.append(a[i] - x[i])
# print(x)
for i in range(n):
    print(x[i]*2, end=" ")

Measured memory_bytes: 65764
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Convert;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }


        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var Z = cin.ReadInt;
            var W = cin.ReadInt;
            var a = cin.ReadIntArray(N);

            if(N == 1)
            {
                WriteLine(Abs(a[0] - W));
                return;
            }

            var ans = Max(Abs(a[N - 1] - W), Abs(a[N - 2] - a[N - 1]));
            WriteLine(ans);
        }


        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 13296
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b;
	if(b==100){
		c=a*1000+b;
	}
	else if(b>9){
		c=a*100+b;
	}
	else{
		c=10*a+b;
	}
	for(int i=0;i<1000;i++){
		if(c==i*i){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const int N=100005;
const int MOD=1e9+7;
int mul(int x,int y)	{return (LL)x*y%MOD;}
int Pow (int x,int y)
{
	if (y==1) return x;
	int lalal=Pow(x,y>>1);
	lalal=mul(lalal,lalal);
	if (y&1) lalal=mul(lalal,x);
	return lalal;
}
int JC[N],inv[N];
int n,k;
void Init (int n)
{
	JC[0]=1;for (int u=1;u<=n;u++) JC[u]=mul(JC[u-1],u);
	inv[n]=Pow(JC[n],MOD-2);
	for (int u=n-1;u>=0;u--) inv[u]=mul(inv[u+1],u+1);
}
int C (int x,int y)	{return x<y?0:mul(JC[x],mul(inv[y],inv[x-y]));}
int du[N];
int main()
{
	scanf("%d%d",&n,&k);
	Init(k);
	for (int u=1;u<n;u++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		du[x]++;du[y]++;
	}
	int ans=mul(k,C(k-1,du[1]));
	ans=mul(ans,JC[du[1]]);
	for (int u=2;u<=n;u++) 
	{
		ans=mul(ans,C(k-2,du[u]-1));
		ans=mul(ans,JC[du[u]-1]);
	}
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
  string s;
  int q;
  cin>>s>>q;
  string t;
  for(int i=0;i<q;i++){
    int tq;
    cin>>tq;
    if(tq==1){
      swap(s,t);
    }else{
      int num;
      char c;
      cin>>num>>c;
      if(num==1){
        t+=c;
      }else{
        s+=c;
      }
    }
  }
  reverse(t.begin(),t.end());
  t+=s;
  cout<<t<<endl;
  return 0;
}

Measured memory_bytes: 1128
// Problem : A - αlphabet
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define pb push_back
#define mod 1000000007
ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % mod; 
    p = (p * p) % mod; 
  
    return (y%2 == 0)? p : (x * p) % mod; 
} 
ll factorial[1000007];
ll fact(ll n)
{
    memset(factorial,0,sizeof(factorial));
    factorial[0]=1;
factorial[1]=1;

    for(int i=1;i<n;i++)
    {
        factorial[i]=(factorial[i-1]*i)%mod;
    }
    
}
ll ncr(ll n,ll r)
{
    ll ans=1;
    ll i;
    ans=factorial[n];
    ll ans1=power(factorial[n-r],mod-2);
    ll ans2=power(factorial[r],mod-2);
    ans=((ans*ans1)%mod*ans2)%mod;
    return ans;
}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

bool prime[100000006];
void sieve(ll n){
    memset(prime,true,sizeof(prime));
	prime[1]=false; 
    for (ll p=2;p*p<=n;p++){
        if (prime[p]){  
            for (ll i=p*p;i<=n;i+=p)
                prime[i]=false;
        }
    }
}
void bfs(vector<int> v[],int o,int n,int dp[]){
	queue<int> q;
	q.push(o);
	dp[o]=0;
	bool visited[n+1]={0};
	visited[o]=true;
	while(q.empty()==false){
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++){
			if(visited[v[a][i]]==false){
				visited[v[a][i]]=true;
				q.push(v[a][i]);
				dp[v[a][i]]=dp[a]+1;
			}
		}
	}
}
int nov[1000001];
bool visited[1000001];
int dp[1000001];
int dfs(vector<int> v[],int o)
{
    if(visited[o]==0)
    {
        visited[o]=1;
        for(int i=0;i<v[o].size();i++)
        {
            if(visited[v[o][i]]==0)
            {
            dp[v[o][i]]=dp[o]+1;
            nov[o]+=dfs(v,v[o][i]);
            }
        }
        return nov[o]+1;
    }
    else
    return 0;
}
// string s=bitset<64>(n).to_string();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	char c;
	cin>>c;
	if(c>=97)
	cout<<"a";
	else
	cout<<"A";
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

int main(void){
	ll A,B,C;
	cin>>A>>B>>C;
	
	if(A%2 && B%2 && C%2) print(min(min(A*B,B*C),C*A));
	else print(0);

	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n;
    string s;
    cin >> n >> s;
    int cnt_left = 0;
    int cnt_right = 0;
    int cnt1 = 0;
    int cnt2 = 0;
    for (int i = 0; i < n; i++)
    {
        if(s[i]==')')
            cnt1++;
        else
            cnt1--;
        if(cnt1>=cnt_right)
            cnt_right = cnt1;
    }

    for (int i = n-1; i >=0;i--){
        if(s[i]=='(')
            cnt2++;
        else
            cnt2--;
        if(cnt2>=cnt_left)
            cnt_left = cnt2;
    }
    for (int i = 0; i < cnt_right;i++)
        cout << '(';
    cout << s;
    for (int i = 0; i < cnt_left; i++)
        cout << ')';
    cout << "\n";

    return 0;
}

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

const int max_N = 2e5 + 21;

const int max_M = 2e3 + 21;

const int mod = 1e9 + 7;

int n,A[max_N],B[max_N],dp[max_M<<1][max_M<<1],ans;

int fac[max_M<<2],_fac[max_M<<1],inv[max_M<<1];

int main(){
	inv[1]=1;
	for(int i=2;i<=4000;++i){
		inv[i]=1ll*(mod/i)*inv[mod%i]%mod;
		if(inv[i])inv[i]=mod-inv[i];
		assert(1ll*i*inv[i]%mod==1);
	}
	fac[0]=_fac[0]=1;
	for(int i=1;i<=8000;++i){
		fac[i]=1ll*fac[i-1]*i%mod;
	}
	for(int i=1;i<=4000;++i){
		_fac[i]=1ll*_fac[i-1]*inv[i]%mod;
	}
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d%d",A+i,B+i);
		++dp[2000-A[i]][2000-B[i]];
	}
	for(int i=0;i<=4000;++i)
		for(int j=0;j<=4000;++j){
			dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
			dp[i][j+1]=(dp[i][j+1]+dp[i][j])%mod;
		}
	for(int i=1;i<=n;++i){
		ans=(ans+dp[2000+A[i]][2000+B[i]])%mod;
		int tmp=1ll*fac[A[i]*2+B[i]*2]*_fac[A[i]*2]%mod*_fac[B[i]*2]%mod;
		ans=(ans-tmp+mod)%mod;
	}
	ans=1ll*ans*inv[2]%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 65280
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner stdin =new Scanner(System.in);
		int n=stdin.nextInt();
		int i,j,k;
		int point=0;
		int index=n;
		int sum[]=new int[n+1];
		String s[]=new String [n];
		for(i=0;i<n;i++)
			s[i]=stdin.next();
		int m=stdin.nextInt();
		String t[]=new String[m];
		for(i=0;i<m;i++)
			t[i]=stdin.next();

		String takahashi;
		for(i=0;i<n;i++){
			takahashi=new String (s[i]);
			point=0;
			for(j=0;j<n;j++)
				if(takahashi.equals(s[j]))
					point++;
			for(k=0;k<m;k++)
				if(takahashi.equals(t[k]))
					point--;
//			System.out.println("point="+point);
					sum[i]=point;
		}
		int max=0;
		for(i=0;i<=n;i++)
			if(max<sum[i]){
				max=sum[i];
				index=i;
			}
		if(index==n)
			System.out.println(0);
		else
			System.out.println(max);
	}
}


Measured memory_bytes: 23892
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<=0&&b>=0)
    {
        cout<<"Zero"<<endl;
    }
    else if(a>0)
    {
        cout<<"Positive"<<endl;
    }
    else if(b>0)
    {
        if((0-a)%2==0)
        {
            cout<<"Positive"<<endl;
        }
        else
        {
            cout<<"Negative"<<endl;
        }
    }
    else
    {
        if((b-a+1)%2==0)
        {
            cout<<"Positive"<<endl;
        }
        else
        {
            cout<<"Negative"<<endl;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
 
int main(void){
  int w;
  while(true){
    cin >> w;
    if(w == -1)break;
    int sum = 0,pre = 4280;
    sum += 1150;
    if(w >= 10 && w <= 20)sum += (w-10)*125;
    else if(w >= 20)sum += 10*125;
    if(w >= 20 && w <= 30)sum += (w-20)*140;
    else if(w >= 30)sum += 10*140;
    if(w >= 30)sum += (w-30)*160;
    cout << pre - sum << endl;
  }
  return 0;
}


Measured memory_bytes: 3004
def cost(n,clist):
  k = 0
  while k < 10:
    i = 0
    while i < 10:
      j = 0
      while j < 10:
        clist[i][j] = min(clist[i][j],clist[i][k]+clist[k][j])
        j += 1
      i += 1
    k += 1
  return clist[n][1]

def joisino(a,clist):
  note = [-1,0,-1,-1,-1,-1,-1,-1,-1,-1]
  answer = 0
  for raw in a:
    for number in raw:
      if number != -1:
        if note[number] == -1:
          note[number] = cost(number,clist)
        answer += note[number]
      
  return answer

def i_o():
  h, w = map(int,input().split(" "))
  i = 0 
  clist = []
  while i < 10:
    raw = list(map(int,input().split(" ")))
    clist.append(raw)
    i += 1
  a = []
  i = 1
  while i <= h:
    raw = list(map(int,input().split(" ")))
    a.append(raw)
    i += 1
  return h,w,clist,a

if __name__ == '__main__':
  h,w,clist,a = i_o()
  ans =joisino(a,clist)
  
  print(ans, flush=True)

Measured memory_bytes: 3444
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

char s1[110];

int main()
{
	scanf("%s",s1);
	for(int i=0;i<strlen(s1);i++)
	{
		if(s1[i]==',')
		{
			s1[i]=' '; 
		}
	}
	printf("%s",s1);
}

Measured memory_bytes: 256
// AtCoder Beginner Contest 177 (D - Friends) を 参照.
// https://atcoder.jp/contests/abc177/tasks/abc177_d
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
int connection[101010]; // 連結成分番号を保存.

// グラフを幅優先探索する.
// https://ja.wikipedia.org/wiki/幅優先探索
// ※bfsの動作確認用.
// @param G: グラフ.
// @param s: グラフの探索開始頂点.
// @param l: 連結成分番号(※1以上).
// @return: 特に無し.
void bfs(vvi &G, int s, int l){
    // 1. 空のキュー.
    queue<int> q;
    
    // 2. 連結成分番号を設定.
    connection[s] = l;
    
    // 3. 探索地点 s をキュー q に追加.
    q.push(s);
    while(!q.empty()){
        // 4. キューから取り出す.
        int u = q.front();
        q.pop();
        
        // 5. 取り出した要素を処理.
        for(auto &e : G[u]){
            // 6. 訪問済であれば, 処理をスキップ.
            if(connection[e])            continue;
            if(!connection[e] && e != s) connection[e] = l, q.push(e);
        }
    }
    return;
}

int main(){
    
    // 1. 入力情報.
    int N, M, a, b;
    scanf("%d %d", &N, &M);
    vvi G(N);
    rep(i, M){
        scanf("%d %d", &a, &b);
        a--, b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    
    // 2. 探索を行い, 連結成分に分割.
    int idx = 0;
    rep(i, N) if(!connection[i]) bfs(G, i, ++idx);
    
    // 3. 出力.
    printf("%d\n", idx - 1);
    return 0;
    
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 2000; ++i) {
        int x8 = i * 8 / 100;
        int x10 = i * 10 / 100;
        if (x8 == a && x10 == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

int main(){
    long long H,W;
    cin >> H >> W;

    if(min(H,W)==1){
        cout << 1 << endl;
    }
    else{
        cout << ((H*W)+1)/2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
INF = float("inf")
MOD = 998244353



# 処理内容
def main():
    N, K = map(int, input().split())
    
    L = [0]*K
    R = [0]*K
    for i in range(K):
        L[i], R[i] = map(int, input().split())

    dp = [0]*(N*2 + 1)
    a = [0]*(N*2 + 1)
    dp[0] = 1
    a[1] = -1
    for i in range(N):
        for j in range(K):
            a[i+L[j]] += dp[i]
            a[i+R[j]+1] -= dp[i]
        dp[i+1] = (dp[i] + a[i+1]) % MOD
    
    print(dp[N-1])



if __name__ == '__main__':
    main()

Measured memory_bytes: 84892
#include <bits/stdc++.h>
#define MAX (ll)(1e5 + 4)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e18)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

int main () {
	ll k, n;
	cin >>  n >> k;
	ll ar[n];
	for (ll i = 0; i < n; i++) {
		cin >> ar[i];
	}
	sort (ar, ar + n, greater<ll> ());
	ll su = 0;
	for (ll i = k; i < n; i++) {
		su += ar[i];
	}
	cout << su << "\n";	
}


Measured memory_bytes: 1792
import java.io.ByteArrayInputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	
	String INPUT = "";
	
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
		PrintWriter out = new PrintWriter(System.out);
		
		solve(sc, out);
		out.flush();
	}
	
	void solve(Scanner sc, PrintWriter out) {
		int x,y,z;
		
		x = sc.nextInt();
		y = sc.nextInt();
		z = sc.nextInt();
		
		int cnt = 0;
		for (int i = x; i <= y; i++) {
			if (z%i == 0) cnt++;
		}
		System.out.println(cnt);
	}
}



Measured memory_bytes: 26408
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 = ini()
s = list(ins())
n = s.count("R")
t = sorted(s)
ans = 0
for i in range(n):
    if s[i] != t[i]:
        ans += 1
print(ans)

Measured memory_bytes: 12684
#include<stdio.h>

int main(void)
{
  int money;
  int happy,happy1,happy2;
  
  scanf("%d", &money);
  
  happy1=(money/500);
  happy2=(money%500)/5;
  
  happy=(happy1*1000)+(happy2*5);
  printf("%d",happy);
  
  return 0;
}

Measured memory_bytes: 1712
n,k = map(int,input().split())
mod = 10**9+7
if n+1 <= k:
    print(1)
else:
    ans = 0
    for i in range(k,n+2):
        if i == n+1:
            ans += 1
            ans %= mod
        else:
            ans += (n*(n+1)//2-(n-i)*(n-i+1)//2-i*(i-1)//2+1)%mod
            ans %= mod
    print(ans%mod)


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

int main(){
  int K, S;
  cin >> K >> S;
  
  int count = 0;
  
  for(int i=0; i<=K; i++){
    for(int j=0; j<=K; j++){
       if(S-(i+j) >= 0 && S-(i+j) <= K){
         count++;
        }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let a: i32 = sc.read();
    let b: i32 = sc.read();
    let c: i32 = sc.read();
    let d: i32 = sc.read();
    let taka = (a + d - 1) / d;
    let aoki = (c + b - 1) / b;
    let ans = if taka >= aoki { "Yes" } else { "No" };
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 2156
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
int a[10],b[111];
int main()
{
	int s=0;
	for(int i=1;i<=3;i++){
		cin>>a[i];
		b[a[i]]++;
	}
	for(int i=0;i<=111;i++)
		if(b[i]>0)s++;
	cout<<s;
}

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

using namespace std;

const int N = 100005;

char s[N],ch[][10]={"dream","dreamer","erase","eraser"};
bool f[N];
int length[4] = {5,7,5,6};

int main()
{
    while(scanf("%s",s+1)+1)
    {
        int len=strlen(s+1);
        memset(f,false,sizeof(f));
        f[0]=true;
        for(int i=1;i<=len;i++)
        {
            for(int j=0;j<4;j++) if(i>=length[j])
            {
                bool ok=true;
                for(int k=0;k<length[j];k++) if(ch[j][k]!=s[i-length[j]+k+1])
                {
                    ok=false;
                    break;
                }
                if(ok&&f[i-length[j]]) f[i]=true;
            }
        }
        printf("%s\n",f[len]?"YES":"NO");
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
   int n;cin>>n;
   int arr[n];
   map<int,int>mp;
   vector<bool> v(n,0);
   rep(i,0,n){
       cin>>arr[i];
       mp[arr[i]]++;
   } 
   rep(i,0,n){
       for(int j=1;j*j<=arr[i];j++){
           if(arr[i]%j==0){
               if(j==1){
                   if(mp.find(arr[i])!=mp.end()&&mp[arr[i]]>1){
                       v[i]=1;
                       break;
                   }
                   if(mp.find(1)!=mp.end()&&arr[i]!=1){
                       v[i]=1;
                       break;
                   }
               }
               else if(mp.find(j)!=mp.end()||mp.find(arr[i]/j)!=mp.end()){
                   v[i]=1;
                   break;
               }
           }
       }
   }
   int cnt=0;
   rep(i,0,n){
       if(v[i]==0)cnt++;
   }
   cout<<cnt;
 
return 0;
}

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

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

    vector<int> okasi(n, 0);
    for(int i = 0; i < k; i++){
        int d;
        cin >> d;
        for(int j = 0; j < d; j++){
            int a;
            cin >> a;
            okasi[a-1]++;
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(okasi[i] == 0) ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
a_hp,a_at,b_hp,b_at = gets.chomp.split.map &:to_i

cnt = 1
a_flg = nil
b_flg = nil

while a_hp > 0 && b_hp > 0
  b_hp -= a_at if cnt.odd?
  a_hp -= b_at if cnt.even?
  #p "cnt: #{cnt}, a: #{a_hp}, b: #{b_hp}"
  cnt += 1
end

a_flg = 1 if b_hp <= 0  
b_flg = 1 if a_hp <= 0

if a_flg
  print 'Yes'
else
  print 'No'
end

Measured memory_bytes: 14272
n, k = map(int, input().split())

def x_sum(x):
    return (2*n-x+1)*x//2 - x*(x-1)//2 + 1

ans = 0 
for i in range(k, n+2):
    ans += x_sum(i)
ans %= 10 ** 9 + 7

print(ans)

Measured memory_bytes: 9124
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int m, n, sum=0;
    scanf("%d%d", &m, &n);
    int *p;
    p=(int*)malloc(n*sizeof(int));
    int i;
    for(i=0; i<n; i++){
        scanf("%d", &p[i]);
        sum+=p[i];
    }
    int ans=m-sum;
    if(ans>-1){
        printf("%d\n", ans);
    }
    else{
        printf("-1\n");
    }
    return 0;
}

Measured memory_bytes: 1768
fun main(args: Array<String>) {
    var N = readLine()!!
    var flag = false
    for (i in 0..1) {
        flag = flag or (N[i] == N[i + 1] && N[i + 1] == N[i + 2])
    }
    println(if (flag) "Yes" else "No")
}


Measured memory_bytes: 31772