akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

#define ff          first
#define ss          second
#define ll          int64_t
#define ld          long double
#define nl          cout<<"\n"
#define dbg(x)      cerr<<#x<<" = "<<x<<"\n"
#define dbg2(x,y)   cerr<<#x<<" = "<<x<<"   "<<#y<<" = "<<y<<"\n"
#define all(v)      v.begin(),v.end()
#define mset(a,v)   memset((a),(v),sizeof(a))
#define forn(i,a,b) for(int64_t i=int64_t(a);i<int64_t(b);++i)
#define forb(i,a,b) for(int64_t i=int64_t(a);i>=int64_t(b);--i)
#define fastio()    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> 

#define mod         1000000007
#define mod2        998244353 
#define inf         1000000000000007
#define pi          3.14159265358979323846

template<typename T,typename U> static inline void amin(T &x,U y)                   {if(y<x)x=y;}
template<typename T,typename U> static inline void amax(T &x,U y)                   {if(x<y)x=y;}  
template<class L,class R> ostream& operator<<(ostream& out,pair<L,R> &p)            {return out<<"("<<p.ff<<", "<<p.ss<<")";}
template<class T> ostream& operator<<(ostream& out,vector<T> &v)                    {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,deque<T> &v)                     {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,set<T> &s)                       {out<<"{";for(auto it=s.begin();it!=s.end();++it){if(it!=s.begin())out<<", ";out<<*it;}return out<<"}";}
template<class L,class R> ostream& operator<<(ostream& out,map<L,R> &m)             {out<<"{";for(auto it=m.begin();it!=m.end();++it){if(it!=m.begin())out<<", ";out<<*it;}return out<<"}";}

ll count_digits(ll n)   {ll dig=floor(log10(n)+1);return dig;}
ll mpow(ll x,ll y,ll p) {ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;} 
string dec_bin_32(ll n) {string s;for(ll i=31;i>=0;i--){ll k=n>>i;s+=(k&1)?'1':'0';}return s;} 
string dec_bin_64(ll n) {string s;for(ll i=63;i>=0;i--){ll k=n>>i;s+=(k&1)?'1':'0';}return s;} 
ll mod_inv(ll a,ll m)   {ll m0=m,y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;} 
/* const ll MAXN=1000007;ll spf[MAXN+5];vector<ll> prime; */
/* void sieve(ll n)        {forn(i,2,MAXN+1)spf[i]=i;for(ll i=2;i*i<=n;i++)if(spf[i]==i)for(ll j=i*i;j<=n;j+=i)if(spf[j]==j)spf[j]=i;forn(i,2,MAXN+1)if(spf[i]==i)prime.push_back(i);} */

//-------------------------------L_I_Erq34-------------------------------

int main()
{
	fastio();
	ll z,n,m,t,k,i,j,l,d,h,r;
	cin>>r>>k>>d;
	r=abs(r);
	h=(r+d-1)/d;
	h=min(h,k);
	m=r-h*d;
	if((k-h)&1)
		cout<<abs(m+d)<<"\n";
	else
		cout<<abs(m)<<"\n";
	cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    map<char, int> mp;
    rep(i, 26) {
        mp['a'+i] = mod;
    }
    rep(i, n) {
        string s;
        cin >> s;
        map<char, int> now;
        for (char c: s) {
            now[c]++;
        }
        rep(j, 26) {
            mp['a'+j] = min(mp['a'+j], now['a'+j]);
        }
    }
    rep(i, 26) {
        rep(j, mp['a'+i]) {
            cout << (char)('a'+i);
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const ll INF = 1000000000;
//const ll MOD = 1000000007;
const ld PI = (acos(-1));
using Graph = vector<vector<int>>;
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;}
typedef pair<int, int> P;
typedef pair<ll,ll> PLL;
double rad(double a) {return a * 180 / PI;}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//dpTable
//int dp[100050];

int main(){
    int N;
    cin >> N;
    vector<ll> a(N);
    vector<ll> sum(200050,0);
    rep (i,N) {
        cin >> a.at(i);
        sum.at(i + 1) = sum.at(i) + a.at(i);
    }
    ll ans = 100000000000;
    for (int i = 1; i < N; i++) {
        ll a = sum.at(i) - sum.at(0),b = sum.at(N) - sum.at(i);
        ans = min(ans,abs(a - b));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6392
// @ts-ignore
require("fs").readFile("/dev/stdin", "utf8", (err, input) => {
  const [a, b, k] = input.split(" ")
  const m = Math.max(a, b)
  const r = Array.from(Array(m).keys())
    .map((_, i) => {
      return i + 1
    })
    .filter((i) => {
      return a % i == 0 && b % i == 0
    })
  console.log(r[r.length - parseInt(k)])
})


Measured memory_bytes: 11468
#include<bits/stdc++.h>
#define M 100005
using namespace std;
int n,mi=1e9,id;
long long a[M],ans[M];
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++)scanf("%lld",&a[i]),a[i]<<=1;
	ans[1]=0;
	for(int i=1; i<=n; i++) {
		if(i&1)ans[1]+=a[i];
		else ans[1]-=a[i];
	}
	ans[1]/=2;
	for(int i=2; i<=n; i++)
		ans[i]=a[i-1]-ans[i-1];
	for(int i=1; i<=n; i++)printf("%lld ",ans[i]);
	return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
 
int main()
{

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

ll ans=-1;

for(int i=1;i<=10000;i++)
    {
        int a=i*.08;
        int b=i*.1;
        if(a==A &&b==B){
            cout<<i<<endl;
            return 0;
            
        }
    }
cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
k,n = map(int,input().split())
l = list(map(int,input().split()))
m = 0
for i in range(n):
    if i == n-1:
        x = abs(l[0]+k-l[i])

    else:
        x = l[i+1]-l[i]

    if x > m:
        m = x

print(k-m)

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

int main() {
	int n; cin >> n;
	map<int, int>a;
	for (int i = 0, tmp; i < n; i++) {
		cin >> tmp; a[tmp]++;
	}
	int ans = 1;
	for (auto&& x : a) {
		if (x.first == 0) {
			if (n % 2 == 0) {
				if (x.second > 0) { cout << 0 << endl; return 0; }
			}
			else {
				if (x.second != 1) { cout << 0 << endl; return 0; }
			}
		}
		else {
			if (x.second != 2) { cout << 0 << endl; return 0; }
			else (ans *= 2) %= 1000000007;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3200
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::HashSet;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    mut n: u128
    }

    let mut tmp = 26;
    let mut l = 1;
    while n > tmp {
        n -= tmp;
        tmp *= 26;
        l += 1;
    }
    n -= 1;

    let mut vec = vec![];

    for _ in 0..l {
      let amari = n % 26;
      n = n / 26;
      vec.push((amari as u8 + b'a') as char);
    }

     println!("{}", vec.iter().rev().collect::<String>());
}


Measured memory_bytes: 2120
import java.util.*;
 
public class Main {
  private static String solve(int in) {
    while (in > 0) {
      if(in % 10 == 7)
        return "Yes";
      in = in / 10;
    }
    return "No";
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int in = sc.nextInt();
    sc.close();
    System.out.println(solve(in));
  }
}


Measured memory_bytes: 35804
#include <iostream>

using namespace std;
typedef long long ll;


#define REP(i,n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i <= n; i++)

int N, B, A;


int sumnum(int n)
{
    int s = 0;
    while(n > 0) {
        s += n % 10;
        n /= 10;
    }
    return s;
}

int main(void)
{
    int s = 0, sn;
    cin >> N >> A >> B;
    REP1(i, N) {
        sn = sumnum(i);
        if(sn>=A && sn <=B) {
            s+= i;
        }
    }
    cout << s << endl;

}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int R = sc.nextInt();
        int S = sc.nextInt();
        int P = sc.nextInt();
        String T = sc.next();
        sc.close();

        int[] p = new int[N];
        for (int i = 0; i < N; i++) {
            char t = T.charAt(i);
            if (K <= i && T.charAt(i - K) == t && p[i - K] != 0) {
                p[i] = 0;
            } else if (t == 'r') {
                p[i] = P;
            } else if (t == 's') {
                p[i] = R;
            } else {
                p[i] = S;
            }
        }
        long ans = 0;
        for (int i = 0; i < N; i++) ans += p[i];
        System.out.println(ans);
    }
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

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

    ll maxD = 50;
    vector<ll> countOne(maxD, 0);
    REP(i, N)
    {
        ll q = a[i];
        ll digit = 0;
        countOne[digit] += q % 2;
        while(q / 2 > 0)
        {
            digit++;
            q /= 2;
            countOne[digit] += q % 2;
        }
    }
    REP(i, N)
    {
        ll ans = 0;
        ll q = a[i];
        ll r = 1;
        REP(i, maxD)
        {
            ll bitCount = countOne[i] - q % 2;
            q /= 2;
            if (bitCount % 2 == 1)
            {
                ans += r;
            }
            r *= 2;
        }
        cout << ans << " ";
    }
}


Measured memory_bytes: 4784
<?php

    $N = (int)trim(fgets(STDIN));
    $D = explode( " ", trim(fgets(STDIN)) );
    $D_count = [];
    foreach( $D as $Di ){
        $Di = "s". $Di;
        if( empty( $D_count[$Di] ) ){
             $D_count[$Di] = 1;
        }else{
            ++$D_count[$Di];
        }
    }
    
    $M = (int)trim(fgets(STDIN));
    if( $N < $M ) die("NO\n");
    
    $T = explode( " ", trim(fgets(STDIN)) );
    foreach( $T as $Ti ){
        $Ti = "s". $Ti;
        if( empty( $D_count[$Ti] ) ){
            die("NO\n");
        }else{
            --$D_count[$Ti];
            if( (int)$D_count[$Ti] < 0 ) die("NO\n");
        }
    }
    
    echo "YES\n";

Measured memory_bytes: 107220
-- D
local N, Q = io.read("*n", "*n")
local edges = {}
for i=1,N do
    edges[i] = {}
end
for i=1,N-1 do
    local a, b = io.read("*n", "*n")
    table.insert(edges[a], b)
    table.insert(edges[b], a)
end

local q = {}
for i=1,N do
    q[i] = 0
end
for i=1,Q do
    local p, x = io.read("*n", "*n")
    q[p] = q[p] + x
end

local counters = {}
for i=1,N do
    counters[i] = 0
end

local task = {}
local seen = {}
local task_insert_ptr = 0
local function task_add(node, accum)
    if not seen[node] then
        seen[node] = true
        task_insert_ptr = task_insert_ptr + 1
        task[task_insert_ptr] = {node, accum}
    end
end
task_add(1, 0)
local task_remove_ptr = 1
local function task_remove()
    local t = task[task_remove_ptr]
    local n, a = t[1], t[2]
    task_remove_ptr = task_remove_ptr + 1
    return n, a
end
while #task >= task_remove_ptr do
    local node, accum = task_remove()
    local inc = q[node]
    counters[node] = accum + inc
    for k, adj in ipairs(edges[node]) do
        task_add(adj, accum + inc)
    end
end

print(table.concat(counters, " "))


Measured memory_bytes: 82912
# coding: utf-8
# Your code here!
import bisect

N,D,A=map(int,input().split())

log=[]
loc=[]
ene=[]

for _ in range(N):
    X,H=map(int,input().split())
    log.append([X,H])

log.sort(key=lambda x:x[0])

for X,H in log:
    loc.append(X)
    ene.append(H)

syokan=[0]*N

power=0
for i in range(N):
    temp=max(-((-ene[i]+power)//A),0)*A
    power+=temp
    
    rng=bisect.bisect_right(loc,loc[i]+2*D)
    syokan[min(rng-1,N-1)]+=temp
    
    power-=syokan[i]
    #print(syokan)
#print(syokan)
print(sum(syokan)//A)

Measured memory_bytes: 48964
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,m,k;
    cin>>n>>m>>k;
    ll ar[m+n+10];
    vector<ll>csum(m+n);
    for(int i=0;i<n;i++) scanf("%lld",&ar[i]);
    reverse(ar,ar+n);
    for(int i=n;i<m+n;i++) scanf("%lld",&ar[i]);
    csum[0]=ar[0];
    for(int i=1;i<m+n;i++) csum[i]=csum[i-1]+ar[i];

    int mx=0;
    for(int i=0;i<=n;i++){
        int j=upper_bound(csum.begin(),csum.end(),k)-csum.begin();
        if(j>=n) mx=max(mx,j-i);
        k+=ar[i];
    }

    cout<<mx<<endl;

    return 0;
}


Measured memory_bytes: 9624
import java.util.Scanner;
import java.util.Stack;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(800 * N - N / 15 * 200);
    }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "A"
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    int r, g;
    cin>>r>>g;
    g+=g-r;
    cout<<g;
}

Measured memory_bytes: 256
#include<map>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN = 100;
string s1[MAXN + 5], s2[MAXN + 5];
map<string, int>m1, m2;
int main() {
	int N, M;
	scanf("%d", &N);
	int Max = 0;
	for(int i=1;i<=N;i++) {
		cin >> s1[i];
		m1[s1[i]]++;
	}
	scanf("%d", &M);
	for(int i=1;i<=M;i++) {
		cin >> s2[i];
		m2[s2[i]]++;
	}
	for(int i=1;i<=N;i++) {
		Max = max(Max, m1[s1[i]] - m2[s1[i]]);
	}
	printf("%d\n", Max);
}

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

ans = [0]*N
tmp = A[0] #一個前の高さ
for i in range(1, N):
    if A[i] >= tmp:
        tmp = A[i]
    else: #台をおく必要がある
        ans[i] = tmp - A[i] #tmpに合わせたからtmpは変えない

print(sum(ans))


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

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    
    bool tru = false;
    if(s[a] == '-')
    {
        tru = true;
    }
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == '-' && i != a)
        {
            tru = false;
        }
    }
    
    if(tru)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        long[] a = new long[N];
        long[] b = new long[N];
        long[] c = new long[M];
        long[] d = new long[M];
        long[] distance = new long[N];
        Arrays.fill(distance, 999999999);
        long[] ans = new long[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextLong();
            b[i] = sc.nextLong();
        }
        for (int i = 0; i < M; i++) {
            c[i] = sc.nextLong();
            d[i] = sc.nextLong();
        }
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < M; j++) {
                if (distance[i] > (Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]))) {
                    distance[i] = (Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]));
                    ans[i] = j + 1;
                }
            }
        }
        for (int i = 0; i < N; i++) {
            System.out.println(ans[i]);
        }
    }
}

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

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return (ret);
}

int main() {
  ll N;
  cin >> N;
  vector<ll> r = divisor(N);

  ll array_size = r.size();
  ll a = array_size / 2;

  ll ans;
  if (N == r[a-1]*r[a]) {
    ans = (r[a-1]-1) + (r[a]-1);
  } else {
    ans = (r[a]-1) + (r[a]-1);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <iostream>
using namespace std;
int n;
set<string> s;
string a;
char lat;
int main(){
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a;
    if(s.count(a)){
      cout<<"No";
      return 0;
    }
    if(i>1&&a[0]!=lat){
      cout<<"No";
      return 0;
    }
    lat=a[a.length()-1];
    s.insert(a);
  }
  cout<<"Yes";
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int fib(int);
int *F;
int main(){
  int n;
  scanf("%d", &n);
  F = (int *)malloc(sizeof(int) * (n + 1));
  int i;
  for(i = n; i >= 0; i--)
    F[i] = 0;
  printf("%d\n", fib(n));
  free(F);
}

int fib(int n){
  if(F[n])
    return F[n];
  if(!n | !(n - 1))
    return F[n] = 1;
  return F[n] = fib(n - 1) + fib(n - 2);
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>

using namespace std;

int verticisNumber;
vector<int> d, f;
vector< vector<int> > g;

void dfs(int cur) {
    static int time = 0;
    time++;
    d[cur] = time;

    for(int i = 0; i < verticisNumber; i++) {
        if(g[cur][i] && !d[i]) {
            dfs(i);
        }
    }

    time++;
    f[cur] = time;

    return;
}

int main() {
    cin >> verticisNumber;
    d.resize(verticisNumber); f.resize(verticisNumber);
    g.resize(verticisNumber);
    for(auto itr = g.begin(); itr != g.end(); itr++) {
        itr->resize(verticisNumber);
    }

    for(int i = 0; i < verticisNumber; i++) {
        int k, degree;
        cin >> k >> degree;
        for(int j = 0; j < degree; j++) {
            int dst;
            cin >> dst;
            g[i][dst - 1] = 1;
        }
    }

    for(int i = 0; i < verticisNumber; i++) {
        if(!d[i]) {
            dfs(i);
        }
    }

    for(int i = 0; i < verticisNumber; i++) {
        cout << i + 1 << " " << d[i] << " " << f[i] << endl;
    }
    return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    
    int d = a;
    bool flag = false;
    for(int i = 0; i < b; i++){
        if(a%b==c){
            flag = true;
            break;
        }
        a += d;
    }
    if(flag) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


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

  int n;
  cin>>n;
  int dp[110000][3]={};
  rep(i,n){
    int a,b,c;
    cin>>a>>b>>c;
    dp[i+1][0]=max(dp[i][1]+a,dp[i][2]+a);
    dp[i+1][1]=max(dp[i][0]+b,dp[i][2]+b);
    dp[i+1][2]=max(dp[i][0]+c,dp[i][1]+c);
  }

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



}

Measured memory_bytes: 2816
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;

class combination {
 public:
  static constexpr int64 divide_by = (int64)1e9 + 7;
  combination(int64 MAX) : fac(MAX), finv(MAX), inv(MAX) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i - 1] * i % divide_by;
      inv[i] = divide_by - inv[divide_by % i] * (divide_by / i) % divide_by;
      finv[i] = finv[i - 1] * inv[i] % divide_by;
    }
  }

  int64 get_comb(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % divide_by) % divide_by;
  }

 private:
  vector<int64> fac, finv, inv;
};

int main() {
  int X, Y;
  cin >> X >> Y;
  int64 divide_by = 1e9 + 7;
  int64 ans = 0;
  int one_in_X = Y / 2;
  combination comb(max(X, Y) + 1);
  for (int i = one_in_X; i >= 0; i--) {
    if ((X - i) % 2 != 0) continue;
    int two_in_X = (X - i) / 2;
    if (i * 2 + two_in_X * 1 != Y) continue;
    ans += comb.get_comb(i + two_in_X, i);
    ans %= divide_by;
  }
  cout << ans << endl;
  return 0;
}


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


int main() {
    string s;
    cin >> s;
    
    for (int i = 0; i < s.size(); ++i) {
        if (i % 2 == 0) cout << s.at(i);
    }

}


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

const ll INF = 1LL << 60;

string S;
ll K;

// i: 何文字目か
// j; N未満か
// k: 0が何回出て来たか
ll dp[110][2][110];

int main() {
    cin >> S >> K;
    dp[0][0][0] = 1;

    ll N = S.size();

    for (int i = 0; i < N; i++) {
        int D = S[i] - '0';

        for (int j = 0; j < 2; j++) {
            for (int k = 0; k <= N; k++) {
                int target = (j == 1 ? 9 : D);

                for (int d = 0; d <= target; d++) {
                    int cnt = 0;
                    if (d != 0) cnt++;

                    dp[i + 1][j || (d < D)][k + cnt] += dp[i][j][k];
                }
            }
        }
    }

    ll ans = 0;
    ans += dp[N][0][K];
    ans += dp[N][1][K];

    cout << ans << endl;
}

Measured memory_bytes: 3804
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int n;cin>>n;
  int ans = 0;
  for(int i = 1; n >= i; i++){
    if(to_string(i).size()%2)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
from itertools import accumulate, chain
from collections import defaultdict

N,K = map(int,input().split())

A = accumulate(chain((0,),map(lambda x: int(x)-1, input().split())))

d = defaultdict(list)
for i,a in enumerate(A):
    d[a%K].append(i)

cnt = 0
for l in d.values():
    if len(l) == 1:
        continue
    j = 0
    for i,li in enumerate(l):
        li += K
        while j < len(l) and l[j] < li:
            j += 1
        cnt += j-i-1

print(cnt)

Measured memory_bytes: 66344
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <cassert>
#include <stack>
#include <set>
#include <sstream>
using namespace std;
 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long Long;




int main()
{
	
	int K,T;
	cin >> K >> T;
	int ma = 0;
	for (int i = 0; i < T; ++i) {
		int n;
		cin >> n;
		ma = max(ma, n);
	}
	int o = K - ma;
	if(ma < o+1){
		cout << 0 << endl;
	}else{
		cout << (ma-o-1) << endl;
	}
	
	
}
/*

4
5 10000
3 10000
7 10000
6 6



 */


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define ll long long
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define inf 0x7f
#define pii pair<int,int>
#define pdd pair<double,double>
#define pdi pair<double,int>
#define mp(u,v) make_pair(u,v)
#define sz(a) a.size()
#define ull unsigned long long
#define ll long long
#define pb push_back
#define in insert
const int maxn = 2000010;
const ll mod = 1000000007;
const double EPS = 1e-6;
using namespace std;
set<int> st;
int nt[maxn][30];
int now_tot[maxn];
int now[30];
int main()
{
    string s;
    cin>>s;
    int tot=0;
    int len=sz(s);
    repd(i,len-1,0){
        st.in(s[i]-'a');
        now_tot[i]=tot;
        if(sz(st)==26){
            tot++;
            st.clear();
        }
    }
    mt(now,0);
    repd(i,len-1,0){
        rep(j,0,26){
            nt[i][j]=now[j];
        }
        now[s[i]-'a']=i;
    }
    int t=0;
    rep(i,0,26){
        if(!st.count(i)){
            printf("%c",i+'a');
            if(!tot) return 0;
            else t=now[i];
            break;
        }
    }
    rep(i,1,tot){
        rep(j,0,26){
            if(now_tot[nt[t][j]]==now_tot[t]-1){
                t=nt[t][j];
                printf("%c",s[t]);
                break;
            }
        }
    }
    rep(i,0,26)
    {
        if(!nt[t][i])
        {
            printf("%c",i+'a');
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 28036
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
  Node *cur = nil->next;
  while ( cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  Node *cur = nil->next;
  int isf = 0;
  while(1){
    if(cur == nil)
      break;
    if(isf++ > 0)
      printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if(t == nil)
    return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for(i = 0; i < n; i++){
    scanf("%s%d", com, &key);
    if(com[0] == 'i'){
      insert(key);
      np++;
      size++;
    } else if(com[0] == 'd'){
      if(strlen(com) > 6){
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L')
          deleteLast();
      } else {
        deleteKey(key);
        nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}

Measured memory_bytes: 32216
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	std::vector<ll> a(n), b(n), c(m), d(m);
	for(int i=0; i<n; i++) scanf("%ld %ld", &a[i], &b[i]);
	for(int i=0; i<m; i++) scanf("%ld %ld", &c[i], &d[i]);

	for(int i=0; i<n; i++){
		int mind = 0;
		for(int j=0; j<m; j++){
			ll ne = abs(a[i]-c[j]) + abs(b[i]-d[j]);
			if(abs(a[i]-c[mind])+abs(b[i]-d[mind]) > ne) mind = j;
		}
		printf("%d\n", mind+1);
	}
}


Measured memory_bytes: 256
#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   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll h[n+2];
    for(ll i=1;i<=n;i++)
        cin>>h[i];
    ll dp[n+2];
    for(ll i=0;i<n+2;i++)
        dp[i]=1e12;
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    for(ll i=3;i<=n;i++){
        for(ll j=max(0LL,i-k);j<i;j++)
        dp[i]=min(dp[j]+abs(h[i]-h[j]),dp[i]);
    }
    cout << dp[n] <<"\n";

}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 1792
/*
    Problem 67
    https://atcoder.jp/contests/abc065/tasks/arc076_b
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* class */
class DisjointSet {
public:
    vector<int> d;
    DisjointSet () {}
    DisjointSet (int len) { d.assign(len, -1); }

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)];}
};
class Edge {
public:
    int u, v, w;
    Edge () {}
    Edge (int u, int v, int w) : u(u), v(v), w(w) {}
    bool operator < (const Edge &e) const {
        return w < e.w;
    }
};
class Point {
public:
    int x, ind;
    Point () {}
    Point (int x, int ind) : x(x), ind(ind) {}
    bool operator < (const Point &p) const {
        return x < p.x;
    }
};
/* global variables */
/* function */
/* main */
int main() {
    int N;
    cin >> N;
    vector<Point> X(N, Point()), Y(N, Point());
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        X[i] = Point(x, i);
        Y[i] = Point(y, i);
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());

    vector<Edge> edges;
    int cnt = 0;
    for (int len = 1; len <= N-1; len++) {
        for (int l = 0; l < N - len; l++, cnt++) {
            int r = l + len;
            edges.push_back(Edge(X[l].ind, X[r].ind, abs(X[l].x - X[r].x)));
            edges.push_back(Edge(Y[l].ind, Y[r].ind, abs(Y[l].x - Y[r].x)));
        }
        if (cnt >= N-1) break;
    }
    // kruscal
    sort(edges.begin(), edges.end());
    DisjointSet ds = DisjointSet(N);
    int totalCost = 0;
    for (Edge e : edges)
        if (ds.unite(e.u, e.v))
            totalCost += e.w;
    cout << totalCost << '\n';
}

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

int main(){
  int a,b;
  cin>>a>>b;
  if(a>0){
    cout<<"Positive"<<endl;
    return 0;
  }
  if(a<0&&b>0){
    cout<<"Zero"<<endl;
    return 0;
  }
  if((b-a)%2==0){
    cout<<"Negative"<<endl;
    return 0;
  }else{
    cout<<"Positive"<<endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

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

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc079/tasks/abc079_c

string abcd;
string op;

bool dfs(int res, string op2) {
    if (op2.length() == 3) {
        op = op2;
        return res == 7;
    }

    if (dfs(res + (abcd[op2.length()+1] - '0'), op2+"+")) return true;
    if (dfs(res - (abcd[op2.length()+1] - '0'), op2+"-")) return true;
    return false;
}

int main() {
    cin >> abcd;

    if (dfs(abcd[0] - '0', "")) {
        printf("%c%c%c%c%c%c%c=7\n", abcd[0], op[0], abcd[1], op[1], abcd[2], op[2], abcd[3]);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    LL h,w,a,b;
    void no(){cout <<"No"<<"\n"; exit(0);}

    void solve(){
        cin >> h >> w >> a >> b;
        if(h%a==0 and w%b==0)no();
        vector<vector<LL>> ans (h,vector<LL>(w));
        LL sum=0,cnt=0;
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                if(i%a==0 and j%b==0)ans[i][j]=1,sum++;
                if(i%a==h%a and j%b==w%b)cnt++;
            }
        }
        LL add=1e6;
        LL sub=1e6+1;
        /*DBG(sum,cnt)
            DBG(sub,floor((sub-2)/(a*b-1)),ceil((cnt*sub-sum)/(h*w-cnt)+1e-6))
        while(floor((sub-2)/(a*b-1))<ceil((cnt*sub-sum)/(h*w-cnt)+1e-6)){
            DBG(sub,a*b-1,cnt*sub-sum,h*w-cnt)
            DBG(sub,floor((sub-2)/(a*b-1)),ceil((cnt*sub-sum)/(h*w-cnt)+1e-6))
            sub++;
        }
            DBG(sub,floor((sub-2)/(a*b-1)),ceil((cnt*sub-sum)/(h*w-cnt)+1e-6))
        LL add=floor(sub/(a*b-1));*/
        cout << "Yes"<<"\n";
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                if(i%a==0 and j%b==0)cout << add;
                else if(i%a==h%a and j%b==w%b)cout << -sub;
                else cout << 0;

                if(j<w-1)cout <<' ';
            }
            cout <<"\n";
        }





    }
};

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



Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    int ans = 3;
    if(a == b)ans--;
    if(a == c)ans--;
    if(b == c)ans--;
    if(a == b && a == c) ans++;
    fin(ans);
    return 0;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll n,m,k;
  cin>>n>>m>>k;
  while(n!=0){
    vector<ll> dp((n+1)*(m+1));
    FOR(i,0,m){
      dp[i] = 1;
    }

    FOR(i,1,n){
      FORr(j,i*m-1,i-1){
        FOR(x,1,m+1){
          dp[j+x] += dp[j];
        }
        dp[j] = 0;
      }
    }
    ll sum = 0;
    FOR(i,0,n*m){
      ll mx = max((ll)0, i-k);
      sum += (mx+1)*(dp[i]);
    }
    ld div = pow(m,n);
    ld res = sum/div;
    cout(10)<<res<<endl;

    cin>>n>>m>>k;
  }
}



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

int main() {
  bool a=0;
  int N;
  cin >> N;
  for(int c=0; 4*c<=N; c++){
    for(int d=0; 4*c+7*d<=N; d++){
      if(4*c+7*d==N){
        a=1;
      }
    }
  }
  if(a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int time = sc.nextInt();
        List<Integer> c = new ArrayList<>();
        List<Integer> t = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            c.add(sc.nextInt());
            t.add(sc.nextInt());
        }
        int min = 10000000;
        int index = 0;
        for(int i = 0;i < n;i++){
            if(t.get(i) > time){
                continue;
            }
            min = Math.min(min,c.get(i));
        }
        if(min >= 10000000){
            System.out.println("TLE");
            return;
        }
        System.out.println(min);
    }
}


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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

class dsu {
private:
	int *id;
	int* sz;

	int root(int i) {
		while (i != id[i]) {
			id[i] = id[id[i]];
			i = id[i];
		}
		return i;
	}
public:
	int n;
	dsu(int v) {
		n = v;
		id = new int[n];
		sz = new int[n];

		for (int i = 0; i < n; i++) {
			id[i] = i;
			sz[i] = 0;
		}
	}

	bool find(int p , int q) {
		return root(p) == root(q);
	}

	void join(int p , int q) {
		int i = root(p);
		int j = root(q);
		if (i == j) {
			return;
		}
		if (sz[i] < sz[j]) {
			id[i] = j ;
			sz[j] += sz[i];
		}
		else {
			id[j] = i;
			sz[i] += sz[j];
		}
	}
};

int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

int modPower(int x, int y , int p) {
	//Used to calculate (x^y)%p
	int res = 1;
	if (y == 0) {
		return 1;
	}

	x = x % p;
	if (x == 0) {
		return 0  ;
	}

	while (y > 0) {
		if (y & 1) {
			res = (res * x) % p;
		}

		y >>= 1;
		x = (x * x) % p;
	}
	return res ;

}


int32_t main() {
	FIO;

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

	int a[100009][3];
	for (int i = 1 ; i <= n ; i++) {
		for (int j = 0 ; j < 3 ; j++) {
			cin >> a[i][j];
		}
	}
	int val = INT_MIN;
	for (int i = 0 ; i < 8 ; i++) {
		vi v ;
		for (int j = 1 ; j <= n ; j++) {
			int s = 0 ;
			for (int k = 0 ; k < 3 ; k++) {
				if ((i / (1 << k)) % 2 == 0) {
					s += a[j][k];
				}
				else {
					s -= a[j][k];
				}
			}
			v.pb(s);
		}
		sort(all(v));
		reverse(all(v));
		int ans = 0 ;
		for (int j = 0 ; j < m ; j++) {
			ans += v[j];
		}
		val = max(val, ans);
	}




	cout << val;





	return 0;
}


Measured memory_bytes: 3660
a = input()
if a == "hi" :
  print('Yes')
elif a == 'hihi':
  print('Yes')
elif a == 'hihi':
  print('Yes')
elif a == 'hihihi':
  print('Yes')
elif a == 'hihihihi':
  print('Yes')
elif a == 'hihihihihi':
  print('Yes')
else:
  print('No')

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


int main(){
  
  int n, i, cnt = 0;
  cin >> n;
  vector<int> p(n);
  
  for(i = 0; i < n; i++) cin >> p.at(i);

  for(i = 1; i < n - 1; i++){
      
    if((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i + 1] < p[i] && p[i] < p[i - 1])){
      cnt++;
    }
  }
    
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void) {
    string s;
    cin >> s;
    s.pop_back();
    while(s.size()>0) {
        string s1 = s.substr(0, s.size()/2);
        string s2 = s.substr(s.size()/2, s.size());
        if(s1==s2) {
            cout << s.size() << endl;
            return 0;
        }
        s.pop_back();
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N, K;
int a[110];
int dp[2][100010];

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

	cin >> N >> K;
	rep(i, 0, N)cin >> a[i];

	rep(i, 0, K+1)rep(j, 0, 2)rep(k, 0, N)
	{
		if (i >= a[k])
		{
			dp[j][i] |= (dp[j ^ 1][i - a[k]]^1);
		}
	}

	cout << (dp[0][K] == 1 ? "First" : "Second") << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>


  

using namespace std;
int main() {

	int n;

	cin >> n;

	int a[200001], b[200001];

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

		b[i] = a[i];

	}

	sort(a, a + n);

	for (int i = 0; i < n; i++) {
		if (b[i] == a[n - 1]) {
			cout << a[n - 2] << endl;
		}

		else {
			cout << a[n - 1] << endl;
		}

	}


}

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

int main(){
  int N;
  cin >> N;
  int X[N];
  rep(i, N) cin >> X[i];
  int ans = 1000000;
  sort(X, X+N);
  rep(i, X[N-1]){
    int sums = 0;
    for (auto x : X){
      sums += (x - (i+1)) * (x - (i+1));
    }
    ans = min(ans, sums);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640