akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    bool f=0;
    int a=nxt(),b=nxt(),c=nxt();
    for(int i=0;i<=b;i++)
        if(a*i%b==c)
        {
            f=1;
            break;
        }
    if(f)
        cout<<"YES\n";  
    else
        cout<<"NO\n";
    
    
    return 0;   
}




 
 


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

#define int long long

using namespace std;



int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

	int x;
	cin >> x;

	if(x == 0)cout << 1 << '\n';
	else cout << 0 << '\n';    

    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string s(4,'a');
    rep(i,4)cin>>s[i];
    sort(all(s));
    if(s=="1479")cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
A=[]
for i in range(0,n):
    v=int(input())
    A.append(v)
max=A[1]-A[0]
min=A[0]
for i in range(1,n):
    k=A[i]-min
    if max<k:
        max=k
    if min>A[i]:
        min=A[i]
print(max)



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

int main(void) {
  vector<int> v;
  int num, n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> num;
    v.push_back(num);
  }
  int cnt = 0;
  for (int i = 0; i < v.size(); i++) {
    int flag = 0;
    int index = i;
    int min = v[i];
    for (int j = i; j < v.size(); j++) {
      if (min > v[j]) {
        min = v[j];
        index = j;
        flag = 1;
      }
    }
    // for (int i = 0; i < v.size(); i++) {
    //  cout << v[i] << (i == v.size() - 1 ? "\n" : " ");
    // }
    // cout << "index: " << index << endl;
    if(flag == 1) {
      int temp = v[i];
      v[i] = v[index];
      v[index] = temp;
      cnt++;
    }
  }

  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << (i == v.size() - 1 ? "\n" : " ");
  }
  cout << cnt << endl;
}
 


Measured memory_bytes: 3148
import math

a, b, x = map(int, input().strip().split())

vol = a * a * b
if vol <= 2 * x:
    theta = math.atan(2 * (vol - x) / a**3)
else:
    theta = math.atan(a * b**2 / (2 * x))

print(theta * 360 / (2 * math.pi))


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll K, A, B;
    cin >> K >> A >> B;

    if(B-A>2){
    	ll now = 1;
    	ll tataku = min(A-1, K);
    	now += tataku;
    	K -= tataku;
    	if(K>0){
    		now += K/2 * (B-A);
    		if(K%2==1) now++;
    	}
    	cout << now << endl;
    }else{
    	cout << 1 + K << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
void y(bool c) {
	if (c)print("Yes");
	else print("No");
}
bool s, n, w, e;
void solve() {
	int N; cin >> N;
	vector<int>A(N);
	REP(i, N)cin >> A[i];

	REP(i, N)A[i]--;
	int cnt = 0;
	REP(i, N) {
		if (A[A[i]] == i)cnt++;
	}
	print(cnt/2);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}




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

#define fast                     ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int                      long long 
#define pb                       push_back
#define pii                      pair<int,int>
#define vi                       vector<int>
#define vii                      vector<pii>
#define mi                       map<int,int>
#define mii                      map<pii,int>
#define all(a)                   (a).begin(),(a).end()
#define l                        first
#define r                        second
#define sz(x)                    (int)x.size()
#define endl                     '\n'
#define MOD                      1000000007
#define loop(i,a,b)              for(int (i)=(a);(i)<(b);(i)++)
#define rloop(i,a,b)             for(int (i)=(a);(i)>=(b);(i)--)
#define Unique(A)                (A).resize(distance((A).begin(),unique(all((A)))))
#define MXe(A)                   *max_element(all(A))
#define MNe(A)                   *min_element(all(A))
#define SP(val,precision)        fixed << setprecision((precision)) << (val)
#define setBits(x)               __builtin_popcountll(x)
#define zroBits(x)               __builtin_ctzll(x)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define mem(name,val)            memset(name,val,sizeof(name))
#define traceA(A,x)              cerr<<#A<<": ";loop(i,0,x)cerr<<A[i]<<' ';cerr<<endl
#define traceV(A)                cerr<<#A<<": ";for(auto i:A)cerr<<i<<' ';cerr<<endl
#define maxheap                  priority_queue<int>
#define minheap                  priority_queue<int,vector<int>,greater<int>>

using namespace std;

const int N = 2e6+77;
int A[N];
int n , k ;
bool ok(int mid ,int b){
    loop(i,0,n) b-= (A[i]+mid-1) / mid-1;
    return b>=0;
}

int32_t main(){
    cin >> n >> k ;
    loop(i,0,n) cin >> A[i];
    int l = 1 , r = 1e9;
    while(l!=r){
        int m = (l+r)/2;
        if(ok(m,k)) r = m;
        else l = m+1;
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 5108
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

int main() {
    ll N, K;
    cin >> N >> K;
	vector<ll> P(N);
	vector<ll> T(N - K + 1);
	REP(i, N) cin >> P[i];
	ll cnt = 0, j = 1;
	REP(i, N - K + 1){
		while(j < i + K){
			if(P[j-1] > P[j]) cnt++;
			j++;
		}
		T[i] = cnt;
		if(P[i]>P[i+1]) cnt--;
	}

	vector<ll> sm(N - K + 1);
	set<ll> S;
	j = 0;
	REP(i, N - K){
		while(j < i + K + 1)
			S.insert(P[j++]);
		if(*S.begin() == P[i] && * prev(S.end()) == P[j - 1])
			sm[i+1] = 1;
		S.erase(P[i]);
	}

	int ans = 0, z = 0;
	REP(i, N - K + 1) if(!sm[i]){
		if(T[i]) ans++;
		else z++;
	}
	ans += bool(z);
	cout << ans << endl;
}


Measured memory_bytes: 11136
# ABC120 C - Unification
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

S = si()

cnt_0 = S.count('0')
cnt_1 = S.count('1')

if cnt_0 == len(S) or cnt_1 == len(S):
    print(0)
    exit()

if cnt_0 >= cnt_1:
    print(cnt_1*2)
else:
    print(cnt_0*2)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
#define debug(x) cerr << x << endl
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const ll MOD = 1000000007;


int main()
{
    int N, K;
    cin >> N >> K;
    vector<ll> a(N);
    rep(i,N) cin >> a[i];

    vector<ll> dp(K+1);
    dp[0] = 1;
    rep(i,N)
    {
        vector<ll> dp2(K+1);
        ll sum = 0;
        rep(j,K+1)
        {
            sum += dp[j];
            if(j - a[i] - 1 >= 0) sum -= dp[j - a[i] - 1];
            dp2[j] += sum;
            dp2[j] %= MOD;
        }
        swap(dp, dp2);
    }
    ll ans = dp[K] % MOD;
    // debug(dp);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4784
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<map>
#define ran(x) (x).begin(),(x).end()
using namespace std;
int main() {
	int64_t x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	if(x/d > k ) {
		return cout << x - (k * d) << endl, 0;
	}
	if(x == d) {
		if(k % 2 == 0)
			return cout << x << endl, 0;
		else
			return cout << 0 << endl, 0;
	}
	int64_t l = x / d;
	k -= l;
	l = k;
	int64_t n = x % d;
	map<int64_t,int64_t> g;
	vector<int64_t> h;
	for(int64_t i = 0;; ++i) {
		--l;
		if(n <= 0) {
			n += d;
			++g[n];
			h.push_back(n);
		}
		else {
			n -= d;
			++g[n];
			h.push_back(n);
		}
		if(g[n] > 1)
			break;
	}
	if(l % 2 == 0)
		cout << abs(h[0]) << endl;
	else
		cout << abs(h[1]) << endl;
}

Measured memory_bytes: 3588
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr> () -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let N = read::<usize>();
    if N < 1000 {
        println!("ABC");
    }
    else {
        println!("ABD");
    }
}



Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <limits>
#include <type_traits>

using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
    int N;
    int p[60],c[60];
    cin >> N;
    FOR(i,0,N){
        cin >> p[i];
        c[i] = p[i];
    }
    
    sort(p, p+N);
    int cnt = 0;
    FOR(i,0,N){
        if(p[i]!=c[i]) cnt++;
    }
    if(cnt > 2) cout << "NO" ;
    else cout << "YES";
 }


Measured memory_bytes: 256
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

P.sort()
counterA = 0
while P:
    if P[0] <= A:
        counterA += 1
        del P[0]
    else:
        break

counterB = 0
while P:
    if P[0] <= B:
        counterB += 1
        del P[0]
    else:
        break

print(min(counterA, counterB, len(P)))


Measured memory_bytes: 3060
from scipy.misc import comb
from collections import Counter

n = int(input())
a = [int(i) for i in input().split()]

c = Counter(a)
d = dict(c.most_common())

x = sum([comb(v, 2, exact=True) for v in d.values()])
for i in range(n):
    print(x - (comb(d[a[i]], 2, exact=True) - comb(d[a[i]] - 1, 2, exact=True)))


Measured memory_bytes: 48616
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		char[] s = sc.next().toCharArray();
		int[] a = new int[s.length];
		for (int i = 0; i < s.length; i++)
			a[i] = s[i] - '0';

		for (int i = 0; i <= 1 << (a.length - 1); i++) {
			int ans = a[0];
			for (int j = 1; j < a.length; j++) {
				ans += a[j] * (((i >> (j - 1)) & 1) * 2 - 1);
			}
			if (ans == 7) {
				out.print(a[0]);
				for (int j = 1; j < a.length; j++) {
					out.print((((i >> (j - 1)) & 1) == 1 ? "+" : "-") + a[j]);
				}
				out.println("=7");
				break;
			}
		}

		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) return true;
		else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) return false;
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) return buffer[ptr++];
		return -1;
	}

	private boolean isPrintableChar(byte c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) throw new NoSuchElementException();
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

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

	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

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

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll n;
ll ga,sa,ca;
ll gb,sb,cb;
#define nn 5008
ll dp[nn*nn];
void ag(ll &x,ll y){
	x=max(x,y);
}
int main(){
	cin>>n>>ga>>sa>>ca>>gb>>sb>>cb;
	for(int i=ga;i<=n;i++)
		ag(dp[i],dp[i-ga]+gb);
	for(int i=sa;i<=n;i++)
		ag(dp[i],dp[i-sa]+sb);
	for(int i=ca;i<=n;i++)
		ag(dp[i],dp[i-ca]+cb);
	ll have=0;
	for(int i=0;i<=n;i++){
		have=max(have,dp[i]+n-i);
	}
	n=have;
	
		memset(dp,0,sizeof dp);
		for(int i=gb;i<=n;i++)
			ag(dp[i],dp[i-gb]+ga);
		for(int i=sb;i<=n;i++)
			ag(dp[i],dp[i-sb]+sa);
		for(int i=cb;i<=n;i++)
			ag(dp[i],dp[i-cb]+ca);
		for(int i=0;i<=n;i++) have=max(have,dp[i]+n-i);

	
		cout<<have<<"\n";
	
	
	return 0;
}

Measured memory_bytes: 196224
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

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

N = I()
n = len(format(N,'b'))

for i in range(N-1):
    i2 = format(i,'b').zfill(n)
    ans = []
    for j in range(i+1,N):
        j2 = format(j,'b').zfill(n)
        for k in range(n):
            if i2[n-1-k] != j2[n-1-k]:
                ans.append(k+1)
                break
    print(*ans)

Measured memory_bytes: 53340
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          163577857
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -1e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

 typedef tree<pii, null_type, less<pii>, rb_tree_tag,  
            tree_order_statistics_node_update>  odst; 


void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   
    #endif
}


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

 int d = n%10;

 if(d==0 || d ==1 || d==6 || d==8 )
 {
  cout<<"pon\n";
 }
 else if(d==3)
 {
  cout<<"bon\n";
 }
 else cout<<"hon\n";

 
}

int32_t main()
{
 pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

 }

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 int n,k;
 cin>>n>>k;
 k=min(k,n);
 int a[n+1];
 int dp[n+1]={0};
 for(int i=1;i<=n;i++)
 {
      cin>>a[i];
 }
 for(int i=1;i<=k;i++)
 {
      dp[i]=abs(a[i]-a[1]);
 }
 for(int i=k+1;i<=n;i++)
 {
      dp[i]=INT_MAX;
      for(int j=1;j<=k;j++)
      {
           dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
      }
 }
 cout<<dp[n];
 
} 

Measured memory_bytes: 1792
@h, @w = gets.chomp.split(" ").map(&:to_i)
@color = []
@h.times do
  row = gets.chomp.split("").map{|x| x == "#"}
  @color << row
end

@di = [-1, 0, 1, 0]
@dj = [0, 1, 0, -1]

def isin(i, j)
  i >= 0 && i < @h && j >= 0 && j < @w
end

def check(i, j, d)
  ni = i + @di[d]
  nj = j + @dj[d]
  return false if !isin(ni, nj)
  return false if @color[i][j] == @color[ni][nj]
  true
end

used = Array.new(@h){Array.new(@w, false)}

ans = 0
b = 0
w = 0
@h.times do |i|
  @w.times do |j|
    next if used[i][j]
    b = 0
    w = 0
    que = []
    used[i][j] = true
    que << [i, j]
    while !que.empty?
      ci, cj = que.pop
      if @color[ci][cj]
        b += 1
      else
        w += 1
      end
      4.times do |d|
        next if !check(ci, cj, d)
        ni = ci + @di[d]
        nj = cj + @dj[d]
        next if used[ni][nj]
        used[ni][nj] = true
        que << [ni, nj]
      end
    end
    ans += b * w
  end
end

puts ans

Measured memory_bytes: 8956
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
  ll x2, k, d;
  cin >> x2 >> k >> d;
  ll x = abs(x2);
  ll kai1 = x/d;
  ll kai2 = kai1 + 1;
  if(k <= kai1){
    ll ans = abs(x-k*d);
    cout << ans << endl;
    return 0;
  }
  if((k-kai1)%2 == 0){
    ll ans = abs(x-kai1*d);
    cout << ans << endl;
  }
  else {
    ll ans = abs(x-kai2*d);
    cout << ans << endl;
  } 
}


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

int main()
{
	string s1, s2, s3;  cin >> s1 >> s2 >> s3;

	string ans;
	
	ans += (s1.at(0) - ('a' - 'A'));
	ans += (s2.at(0) - ('a' - 'A'));
	ans += (s3.at(0) - ('a' - 'A'));
	
	cout << ans << endl;
	
	return 0;	
}

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

import sys
input=sys.stdin.readline
import itertools

def main():
    n = int(input())
    s = input()

    ans = 0
    for i in range(10):
        a = s.find(str(i))
        if a == -1:
            continue
        for j in range(10):
            b = s.find(str(j),a+1)
            if b == -1:
                continue
            for k in range(10):
                c = s.find(str(k),b+1)
                if c == -1:
                    continue
                else:
                    ans += 1
    print(ans)

if __name__=="__main__":
    main()


Measured memory_bytes: 63264
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;

int main(void) {
    int N;

    cin >> N;
    ll A[N];

    rep(i,N){
      cin >> A[i];
      if(A[i]==0){
        cout << 0 << endl;
        return 0;
      }
    }
    ll ans;
    ans = 1;

  for(int i=0; i<N; i++){
    if(A[i]<=1000000000000000000/ans )
      ans *= A[i];
    else{
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
	long long H, N;
	cin >> H >> N;
	vector<long long> A( N );
	for( long long i = 0; i < N; i++ ) {
		cin >> A[i];
	}

	string ans = "No";
	for( long long i = 0; i < N; i++ ) {
		H -= A[i];
		if( H <= 0 ) {
			ans = "Yes";
			break;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
  int res = 1;
  x = x % p;
  while (y > 0)
  {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc;
  tc = 1;
  //cin>>tc;
  while (tc--)
  {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n;i++){
      if(i%3&&i%5){
        ans += i;
      }
    }
    cout << ans;
  }

  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>

using namespace std;

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

	//一回の提出でかかる時間
	int onetime = 100 * (N - M) + 1900 * M;

	int value = 1;
	//必要な回数の期待値
	for (int i = 1; i <= M; i++) {
		value *= 2;
	}

	int ans = onetime * value;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <math.h>
using namespace std;

const long long INF = 1LL << 60;  // どういう意味だろうか

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

long long dp[100010];
long long h[100010];

int main() {
	int N, K;
	int temp;

	cin >> N >> K;

	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}

	for (int i = 0; i < 100010; ++i){
		dp[i] = INF;
	}

	dp[0] = 0;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < K; j++) {
			chmin(dp[i + j + 1], dp[i] + abs(h[i] - h[i + j + 1]));
		}
	}

	cout << dp[N-1] << endl;
}


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

#define For(i, j, k) for (int i = j; i <= k; i++)

using namespace std;

const int N = 2e5 + 10;

int n;
vector<int> G[N];
int fa[N], Max[N];
int ans[N];

void DFS_init(int o, int mx, int u, int se) {
	mx = max(mx, o), se = max(o, se);
	Max[o] = mx;
	if (mx == o || se <= Max[fa[mx]]) ans[mx]++;
	else ans[u]++;
	for (int v : G[o]) {
		if (v == fa[o]) continue;
		fa[v] = o;
		DFS_init(v, mx, mx == o ? v : u, mx == o ? 0 : se);
	}
}

void DFS_work(int o) {
	ans[o] += ans[fa[o]];
	for (int v : G[o]) {
		if (v == fa[o]) continue;
		DFS_work(v);
	}
}

int main() {

	scanf("%d", &n);
	For(i, 2, n) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v), G[v].push_back(u);
	}
	For(i, 1, n) sort(G[i].begin(), G[i].end());
	DFS_init(1, 0, 0, 0);
	DFS_work(1);
	For(i, 2, n) printf("%d%c", ans[i] - 1, i == n ? '\n' : ' ');

	return 0;
}

Measured memory_bytes: 30464
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	int n,m;cin>>n>>m;
	int x[N];
	rep(i,m) cin>>x[i];
	sort(x,x+m);
	int dx[N];
	rep(i,m-1) dx[i]=x[i+1]-x[i];
	sort(dx,dx+m-1,greater<int>());
	int ans=0;
	for(int i=n-1;i<m-1;i++) ans+=dx[i];
	cout<<ans<<endl;
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vi a(n), b(n);
  REP(i, n) {
    cin >> a[i];
  }
  REP(i, n) {
    cin >> b[i];
  }

  vector<P> tmpa(n), tmpb(n);
  REP(i, n) {
    tmpa[i] = {a[i], i};
    tmpb[i] = {b[i], i};
  }

  sort(ALL(tmpa));
  sort(ALL(tmpb));
  bool aa = true, ab = true;
  REP(i, n) {
    if(tmpa[i].first > tmpb[i].first) {
      cout << "No" << endl;
      return 0;
    }
    if(i == n-1) break;
    aa &= tmpa[i].first < tmpa[i+1].first;
    ab &= tmpb[i].first <= tmpa[i+1].first;
  }

  if(!aa || !ab) {
    cout << "Yes" << endl;
    return 0;
  }

  map<int, int> mp;
  REP(i, n) {
    mp[tmpa[i].second] = tmpb[i].second;
  }
  // cout << tmpa << endl;
  // cout << tmpb << endl;

  int cnt = 0;
  int now = 0;
  while(1) {
    cnt++;
    now = mp[now];
    if(now == 0) break;
  }

  cout << (cnt == n ? "No" : "Yes") << endl;

  return 0;
}








Measured memory_bytes: 10324
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e;

    map<int, int> hist;
    for(auto& e : a) hist[e]++;

    int res = 0;
    for(auto e : hist){
        int x = e.first;
        int cnt = e.second;
        if(x > cnt) x = 0;
        res += max(0, cnt - x);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

using namespace std;

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

  bool b[26] = {false};
  rep(i, s.length()) {
    int index = s[i] - 'a';
    if (b[index] == true) {
      cout << "no" << endl;
      return 0;
    }
    b[index] = true;
  }
  cout << "yes" << endl;
  return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	var line = input.split("\n");
	var numStation = Number(line[0]);

	var takeTime = [];
	var firstTime = [];
	var period = [];

	for(var i = 1; i < numStation; i++){
		var tmp = line[i].split(" ");
		takeTime.push(Number(tmp[0]));
		firstTime.push(Number(tmp[1]));
		period.push(Number(tmp[2]));
		// departureTime = firstTime + period * i
		// arrivalTime = departureTime + takeTime
	}

	var minTime = [];
	var ans = [];

	for(var j = 0; j < numStation; j++){

		minTime[j] = [];

		for(k = j; k < numStation; k++){
			if(k === j){
				minTime[j][k] = 0;
			} else if(k === j+1){
				minTime[j][k] = firstTime[j] + takeTime[j];
			} else{
				if(minTime[j][k-1] <= firstTime[k-1]){
					minTime[j][k] = firstTime[k-1] + takeTime[k-1];
				} else{
					var waitTime;
					if((minTime[j][k-1]-firstTime[k-1])%period[k-1] === 0){
						waitTime = 0;
					} else{
						waitTime = period[k-1] - (minTime[j][k-1]-firstTime[k-1])%period[k-1];
					}
					minTime[j][k] = minTime[j][k-1] + waitTime + takeTime[k-1];
				}
			}
		}

		ans[j] = minTime[j][numStation-1];
	}

	console.log(ans.join("\n"));


}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11068
#include<cstdio>
#include<deque>
using namespace std;
typedef long long LL;
int t=1;
deque<int> q;
void dfs(LL n)
{
    if(n==1) return;
    if((n-1)%2==0)
    {
        dfs((n-1)/2);
        q.push_back(++t);
    }
    else
    {
        dfs(n-1);
        q.push_front(++t);
    }
}
int main()
{
    LL n;
    int i,m;
    scanf("%lld",&n);
    q.push_back(1);
    dfs(n);
    m=q.size();
    printf("%d\n",m*2);
    while(!q.empty())
    {
        printf("%d ",q.front());
        q.pop_front();
    }
    for(i=1;i<=m;i++)
        printf("%d ",i);
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int k, q;
  cin >> k >> q;
  vector<int> d(k);
  for (int i = 0; i < k; ++i) {
    cin >> d[i];
  }
  vector<int64> pre(k + 1), cnt(k + 1);
  while (q--) {
    int n, x, m;
    cin >> n >> x >> m;
    for (int i = 0; i < k; ++i) {
      pre[i + 1] = pre[i] + d[i] % m;
      cnt[i + 1] = cnt[i] + (d[i] % m == 0);
    }
    n -= 1;
    int64 sum = n / k * pre[k] + pre[n % k] + x % m;
    // trace(pre[k], x, n, k);
    int64 ret = n - sum / m;
    ret -= n / k * cnt[k] + cnt[n % k];
    cout << ret << endl;
  }
  return 0;
}


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

int main(){
    int N,L;
    std::cin>>N>>L;
    std::vector<std::string> S(N);
    for(int i=0;i<N;++i) std::cin>>S[i];
    std::sort(S.begin(),S.end());
    for(int i=0;i<N;++i) std::cout<<S[i];
    std::cout<<'\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,k;
    cin >> n >> k;
    int moda,modb,modc;
    vector<ll>num(200000,0);
    FOR(i,1,n+1){
        num[i%k]++;
    }
    ll answer = 0;
    FOR(i,0,k){
        moda = i;
        modb = (k-moda)%k;
        modc = (k-moda)%k;
        if((modb+modc)%k != 0){
            continue;
        }
        answer += num[moda]*num[modb]*num[modc];
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1792
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) 

def combination(n,a,b):
    k = a
    ans = 1
    for i in range(n,n-k,-1):
        ans = ans*i%mod
    for i in range(1,k+1):
        ans = ans*pow(i,mod-2,mod)%mod
    ans1 = ans
    for i in range(n-k,n-b,-1):
        ans1 = ans1*i%mod
    for i in range(k+1,b+1):
        ans1 = ans1*pow(i,mod-2,mod)%mod
    return ans + ans1

def main():
    n,a,b = inpm()
    ans = pow(2,n,mod) - 1
    ans += mod
    ans -= combination(n,a,b)
    print(ans%mod)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 42220
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <math.h>
int main() {
	double x1, y1, x2, y2,distance;

	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	distance = (x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1);
	printf("%f\n", sqrt(distance));


	






	return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <queue>

using namespace std;
typedef long long ll;
#define MOD 1000000007

int main() {
    ll N, D;
    cin >> N >> D;

    ll r = 2 * D + 1;

    cout << (N + (r - 1)) / r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// C - Same Integers
int A, B, C;
int ans = 0;
vector<int> num;

int main(){
    cin >> A >> B >> C;
    num.push_back(A);
    num.push_back(B);
    num.push_back(C);
    sort(all(num));
    ans += num[2] - num[1];
    ans += (num[2] - (num[0] + ans)+1)/2;

    int diff = num[2] - num[1] + num[2] - num[0];
    if(diff%2 == 1) ++ans;

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




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();

        for (int i = 1; i <= 9; i++) {
            int target = i * 111;
            if (n <= target) {
                System.out.println(target);
                break;
            }
        }
    }

}


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


using namespace std;
using Graph = vector<vector<int>>;


int main() {
    int N, X, Y;
    cin >> N >> X >> Y;

    --X;
    --Y;

    Graph g(N);
    g[0].push_back(1);
    g[N - 1].push_back(N - 2);
    g[X].push_back(Y);
    g[Y].push_back(X);
    for (int i = 1; i < N - 1; ++i) {
        g[i].push_back(i - 1);
        g[i].push_back(i + 1);
    }

    vector<int> ans(N, 0);

    for (int k = 0; k < N; ++k) {
        vector<int> dist(N, -1);
        queue<int> que;
        dist[k] = 0;
        que.push(k);

        while (!que.empty()) {
            int v = que.front();
            que.pop();

            for (int nv: g[v]) {
                if (dist[nv] != -1) continue;
                dist[nv] = dist[v] + 1;
                que.push(nv);
            }
        }

        for (int j = 0; j < N; ++j) {
            ans[dist[j]]++;
        }
    }

    for (int l = 1; l < N; ++l) {
        cout << ans[l] / 2 << endl;
    }
}


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

namespace AOJ {
    class Stack {
      public:
        Stack();
        ~Stack();

        l pop();
        void push(long n);
        void trace() {
            rep(i, top_) cout << array_[i] << " ";
            cout << endl;
        }

      private:
        int size_;
        int top_;
        l *array_;
    };

    Stack::Stack() : size_{1000}, top_{0} { array_ = new long[size_]; }
    Stack::~Stack() { delete array_; }

    long Stack::pop() { return array_[--top_]; }
    void Stack::push(l n) { array_[top_++] = n; }
}; // namespace AOJ

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    AOJ::Stack stack;
    string input;

    while (cin >> input) {
        if (input == "+") {
            l right = stack.pop();
            l left = stack.pop();
            stack.push(left + right);
        } else if (input == "-") {
            l right = stack.pop();
            l left = stack.pop();
            stack.push(left - right);
        } else if (input == "*") {
            l right = stack.pop();
            l left = stack.pop();
            stack.push(left * right);
        } else {
            stack.push(stol(input));
        }
        // stack.trace();
    }
    cout << stack.pop() << endl;
}



Measured memory_bytes: 3240