akhauriyash/Code-Regression huggingface dataset:
// Dmitry _kun_ Sayutin (2019)

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;
using std::queue;

using std::pair;
using std::make_pair;

using std::tuple;
using std::make_tuple;
using std::get;

using std::min;
using std::abs;
using std::max;
using std::swap;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // code here
    int n = input<int>();

    vector<vector<int>> graph(n * n + 1);
    auto add_edge = [&](int a, int b) {
        graph[a].push_back(b);
        graph[b].push_back(a);
    };
    
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j) {
            if (min(i, j) == 0 or max(i, j) == n - 1)
                add_edge(n * n, i * n + j);

            if (i != 0)
                add_edge((i - 1) * n + j, i * n + j);
            if (j != 0)
                add_edge(i * n + (j - 1), i * n + j);
        }
    
    vector<int> dist(n * n + 1, TYPEMAX(int)); dist[n * n] = 0;
    vector<char> isbad(n * n + 1, true); isbad[n * n] = false;
    
    queue<int> q;
    q.push(n * n);

    while (not q.empty()) {
        int v = q.front();
        q.pop();

        for (int u: graph[v])
            if (dist[u] == TYPEMAX(int)) {
                dist[u] = dist[v] + 1;
                q.push(u);
            }
    }

    std::function<void(int)> recalc_neighbors = [&](int v) {
        for (int u: graph[v])
            if (dist[u] > dist[v] + isbad[u]) {
                dist[u] = dist[v] + isbad[u];

                recalc_neighbors(u);
            }
    };
    
    vector<int> perm(n * n);
    for (int& elem: perm)
        elem = input<int>() - 1;

    int64_t ans = 0;
    for (int x: perm) {
        ans += --dist[x];
        isbad[x] = false;

        recalc_neighbors(x);
    }

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


Measured memory_bytes: 34232
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
	
	void run() {
		
		long n = sc.nextLong();
		
		
		BigInteger ans = BigInteger.ZERO;
		
		for(long i = 1; i*i < n; i++) {
			if(n % i ==0) {
				long t = n / i - 1;
				if(n%t !=0 ) {
					ans = ans.add(BigInteger.valueOf(t));
				}
			}
		}		
		
		System.out.println(ans.toString());
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <cmath>
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

const int MAX = 1100000;
const int mod = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit(){
  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 % mod;
    inv[i] = mod - inv[mod%i] * (mod / i) % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}

long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main(){
  ll x, y;
  cin >> x >> y;
  if ((x + y) % 3 == 0){
    ll n = (x + y) / 3;
    ll m = abs(x - y);
    ll r = (n + m) / 2;
    COMinit();
    cout << COM(n, r) << endl;
  }
  else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 25984
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define Pi 3.1415926535
#define MOD 1000000007;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << endl;}
void no(){cout << "No" << endl;}

int solve(){
    double a,b; cin >> a;


    cout << a*2*Pi << endl;

    return 0;
}

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


Measured memory_bytes: 3796
N, M = map(int, input().split())
L_R = [list(map(int, input().split())) for i in range(M)]

L = [L_R[i][0] for i in range(M)]
R = [L_R[i][1] for i in range(M)]

L_max = max(L)
R_min = min(R)

if L_max <= R_min:
    ans = R_min - L_max + 1
else:
    ans = 0

print(ans)

Measured memory_bytes: 67224
#!/usr/bin/env python3
 
import sys
import math
# 以下を記述しないとTLEになる, 何故？
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
# ---- ここまで -----------------------

S = input()
T = input()
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
    F1[alpha.index(S[i])] = True
for i in range(lenT):
    F2[alpha.index(T[i])] = True
for i in range(26):
    if not F1[i] and F2[i]:
        print(-1)
        sys.exit()

ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
    S = S[ind+1:] + S[:ind+1]
    ind = S.index(T[i])
    ans += ind+1

print(ans)


Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

typedef vector<int> V;
typedef vector<V> VV;

//The number of outdegree of vertex in graph "in" is 1
struct sunny_graph{
    int size;
    VV g,in;
    V S,R;
    int getloop(int v){
        return S[v];
    }
    int getroot(int v){
        return R[v];
    }
    int dfs(int v,V& out,int id,V &loop){
        S[v]=-2;
        int u=out[v];
        if(S[u]>=0){
            S[v]=size;
            return -1;
        }
        if(S[u]==-2||(u=dfs(u,out,id,loop))>=0){
            S[v]=id;
            R[v]=v;
            loop.pb(v);
            if(v==u)return -1;
            else return u;
        }
        S[v]=size;
        return -1;
    }
    void dfs2(int v){
        for(auto &u:in[v]){
            S[u]=S[v];
            R[u]=R[v];
            dfs2(u);
        }            
    }
    sunny_graph(V out){
        size=out.size();
        in.resize(size);
        S.resize(size,-1);
        R.resize(size);
        int id=0;
        REP(v,size){
            V L;
            if(S[v]==-1)dfs(v,out,id,L);
            if(L.size()){
                g.pb(L);
                id++;
            }
        }
        REP(v,size)if(S[v]==size)in[out[v]].pb(v);
        for(auto &s:g)for(auto &v:s)dfs2(v);
    }
};
int N,K;
int res=0;
int f(int v,VV &g){
    int md=0;
    for(auto u:g[v]){
        int len=f(u,g);
        if(len==K&&v!=0)res++,len=0;
        chmax(md,len);
    }
    return md+1;
}
int main(){
    cin>>N>>K;
    V a(N);
    cin>>a;
    if(a.front()!=1){
        a.front()=1;
        res++;
    }
    REP(i,N)a[i]--;
    sunny_graph sg(a);
    f(0,sg.in);
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 11640
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int X;
bool dp[101111];

void MAIN() {
    scanf("%d", &X);
    dp[0] = true;
    REP (i, X) if (dp[i]) {
	REP (t, 6) dp[i+100+t] = true;
    }
    printf("%d\n", dp[X]);

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

int main() {
  int N,Y;
  cin>>N>>Y;
  int res10000=-1,res5000=-1,res1000=-1;
  for (int i=0;i<=N;++i){
    for (int j=0;j<=(N-i);++j){
      int sum=10000*i+5000*j+1000*(N-i-j);
      if (Y==sum) {
        res10000=i;
        res5000=j;
        res1000=N-i-j;
      }
    }
  }
  cout<<res10000<<" "<<res5000<<" "<<res1000<<endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
#include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);

int N, D;
int d[500500];
int Q;
int a[500500];
int b[500500];
int main(){
	cin >> N >> D;
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	a[0] = D;
	for (int i = 1; i < N; i++) {
		a[i] = min(abs(a[i - 1] - d[i - 1]), a[i - 1]);
	}
	b[N] = 1;
	for (int i = N - 1; i >= 0; i--) {
		if (b[i + 1] <= d[i] / 2)b[i] = b[i + 1];
		else b[i] = b[i + 1] + d[i];
	}
	cin >> Q;
	int q;
	for (int i = 0; i < Q; i++) {
		cin >> q;
		q--;
		
		if (a[q] >= b[q + 1])cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define IOS ios::sync_with_stdio(false);
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1000005
#define quick_pow_mod 1000000007
#define PII pair<int,int>
const int factor_N = 10000005;
const int tree_arr_N = 1000005;
using namespace std;
/*
	1.注意边界情况
	2.优先考虑时间复杂度
!!! 3.求最大值时，答案应至多初始化为INT_MIN；求最小值时，答案应至少初始化为INT_MAX
	4.遇事不决先暴力
	5.代码要写简洁
*/
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
	return x * f;
}
ll a, b, c, d;
int main() {
	cin >> a >> b >> c >> d;
	ll ans = a * c;
	ans = max(ans, a * d);
	ans = max(ans, b * c);
	ans = max(ans, b * d);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pair<int, int>, int> ppi;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef bitset<60> Bitset;
const ll INFL = 1LL << 60;
const int INF = 1000000005;
const int MAX = 300000;
const int MOD = 1000000007;
struct Graph{int to,coin; ll cost;};
struct Edge{int from,to,coin; ll cost;};
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n;cin>>n;
    vl a(n);
    for(int i = 0; i < n; i++) cin>>a[i];
    vl sum(n+1,0);
    for(int i = n-1; i >= 0; i--) {
        sum[i] = (sum[i+1] + a[i]) % MOD;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        ans += (a[i] * sum[i+1]) % MOD;
        ans %= MOD;
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 6352
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 2000000000
#define MOD 2018012016
#define N 200005
#define M 1000005
#define LOG 1000000
#define KOK 32000
#define EPS 0.000000001
using namespace std;

int main() {

	//freopen("input.txt","r",stdin);

	int n,x;

	scanf("%d",&n);

	int alle=0;

	for(int i=1;i<=n;i++) {

		scanf("%d",&x);

		alle+=x%2;

	}

	printf(alle?"first":"second");

}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b==c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(){
    int n, m;
    cin >> n >> m;
    vector<string> a, b;
    for(int i=0;i<n;i++) {
        string s;
        cin >> s;
        a.push_back(s);
    }
    for(int i=0;i<m;i++) {
        string s;
        cin >> s;
        b.push_back(s);
    }
    string ans="No";
    for(int i=0;i<n-m+1;i++) {
        for(int l=0;l<n-m+1;l++) {
            bool flag = true;
            for(int j=0;j<m;j++) {
                for(int k=0;k<m;k++) {
                    if(b[j][k]!= a[i+j][l+k])
                        flag = false;
                }
            }
            if(flag) {
                ans = "Yes";
                break;
            }

        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from heapq import*
N,M,*t=map(int,open(0).read().split())
v=[[]for _ in'_'*M]
z=i=0
for _ in'_'*N:M<t[i]or v[t[i]-1].append(t[i+1]);i+=2
q=[0]*M
for i in v:
	for j in i:heappush(q,-j)
	z-=heappop(q)
print(z)

Measured memory_bytes: 25060
#include <iostream>
#include <math.h>
typedef long long ll;

#define FOR(i,a,b) for(ll i = (a);i < (b);++i)
#define REP(i,n) FOR(i,0,n)

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int arr[55555];

void Eratosthenes(int N){
  for(int i = 0; i < N; i++){
    arr[i] = 1;
  }
  for(int i = 2; i < sqrt(N); i++){
    if(arr[i]){
      for(int j = 0; i * (j + 2) < N; j++){
        arr[i *(j + 2)] = 0;
      }
    }
  }

  for(int i = 2; i < N; i++){
    if(arr[i]){
      // cout << i << endl;
    }
  }
}

int main(void){

  int N;
  cin >> N;
  Eratosthenes(55555);

  int cnt = 0;
  int i = 2;
 while(N > cnt){
    if(arr[i] and i % 5 == 1){
      if(cnt != N-1){
        cout << i << " ";
      }else{
        cout << i;
      }
      cnt++;
    }
    i++;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main ()
{
	int x;
	cin >> x;
	int n = x/100;
	int a = x%100;
	for (int i=1; i<=n; i++){
		a-=5;
	}
	if (a > 0){
		cout << "0" << endl;
	}
	else {
		cout << "1" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Fp cout << fixed <<  setprecision(9)
using namespace std;
double dp[3090][6090] ,  prop[3090] ;
int n;

double Dp(int i , int heba){
if(i == n){
    if( heba > 0 ) return 1;
    else
        return 0;

}

double &ret = dp[i][heba + 3000];

if(ret == ret) return ret ;

return ret = prop[i]*Dp(i+1 , heba+1) + (1 - prop[i])*Dp(i+1 , heba-1);

}
int main()
{
    Fp;
    cin >> n;
    for(int i=0;i<n;i++) cin >> prop[i];
    memset(dp , -1 , sizeof dp);
    cout << Dp(0 , 0);
    return 0;
}


Measured memory_bytes: 147584
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int d[] = new int[n];
    int sum = 0;
    for(int i = 0; i < n; i++) {
      d[i] = Integer.parseInt(sc.next());
    }
    for(int i = 0; i < n; i++) {
      for(int j = i+1; j < n; j++) {
        sum = sum + d[i] * d[j];
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 21844
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;

int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll r;
	cin>>r;
	if(r<1200)
	cout<<"ABC";
	else if(r<2800)
	cout<<"ARC";
	else
	cout<<"AGC";
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		// 出力
		System.out.println(((a*b) % 2 == 0) ? "Even" : "Odd");
	}
}


Measured memory_bytes: 23892
#include<stdio.h>
#include<string.h>
 
typedef struct p{
  char name[100];
  int time;
}Process;
 
Process Que[100000];
int head, tail, n;
 
void enqueue(Process x){
  Que[tail] = x;
  tail = (tail + 1)%100000;
}
 
Process dequeue(){
  Process x = Que[head];
  head = (head + 1)%100000;
  return x;
}
 
int main(void){
  int i, n, q, e=0;
  scanf("%d %d\n", &n, &q);
  for (i=0;i<n;i++){
      Process que;
      scanf("%s %d", que.name, &que.time);
      enqueue(que);
  }

  while (head != tail){
      Process pro = dequeue();
      if (pro.time <= q){
          e += pro.time;
          printf("%s %d\n", pro.name, e);
      }
      else{
          e += q;
          pro.time -= q;
          enqueue(pro);
      }
  }
}

Measured memory_bytes: 11860
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 222222


ll num[MAX];


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


  cin >> n >> m;
  vpll v;
  ans = 0;
  rep(i, n) {
    ll t, d;
    cin >> t >> d;
    num[t]++;
    ans += d;
    v.pb(make_pair(d, t));
  }
  ll cnt = 0;
  rep(i, MAX) if (num[i]) cnt++;
  ans += cnt * cnt;
  sort(all(v));

  queue<pll> q;
  ll cur = 0, idx = 0;
  while (cur < n - m) {
    if (idx == n) break;
    if (num[v[idx].second] == 1) {
      q.push(v[idx]);
      idx++;
      continue;
    }

    if (q.empty()) {
      ans -= v[idx].first;
      num[v[idx].second]--;
      idx++; cur++;
    }
    else {
      pll p = q.front();
      if (2 * cnt - 1 + p.first < v[idx].first) {
        q.pop();
        ans -= 2 * cnt - 1 + p.first;
        cnt--; cur++;
      }
      else {
        ans -= v[idx].first;
        num[v[idx].second]--;
        idx++; cur++;
      }
    }
  }

  while (cur < n - m) {
    pll p = q.front();
    q.pop();
    ans -= 2 * cnt - 1 + p.first;
    cnt--; cur++;
  }
  cout << ans << endl;


  return 0;
}

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

#define int long long
#define rep(i, a) for (int i = 0; i < (a); i++)
#define repd(i, a) for (int i = (a)-1; i >= 0; i--)
#define reps(i, a, j) for (int i = (j); i < (a); i++)
#define deb(x) cout << #x << " " << x << endl;
#define debs(x) cout << #x << " " << x << " ";
#define deba(x) for (auto _i:x) cout << _i << " "; cout << endl;
#define ms(a) memset(a,0,sizeof(a));
#define mp make_pair
#define eb emplace_back
#define pii pair < int , int >
#define all(a) a.begin(),a.end()

void solve() {
    double d,t,s; cin >> d >> t>> s;
    if (d/s <= t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t; t=1;
    while (t--) solve();
}

Measured memory_bytes: 3724
A, B, C, K = map(int, input().split())
sum = 0


if K-A >= 0:
    sum = sum + A
    K = K-A
    
    if K-B >= 0:
        K = K-B
        
        if K - C >=0 :
            sum = sum - C
            
        else:
            sum = sum - K
            
    else:
        pass
    
else:
    sum = sum + K
    


print(sum)

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

#define MP make_pair
#define FF first
#define SS second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pie;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const ll LINF = 4e18;
const ll delta = 10289;

int a, b, c, S;

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> a >> b >> c;
	S = a + b + c;
	if (a == b && b == c)
		return cout << (a % 2 ? 0 : -1) << endl, 0;
	else {
		int res = 0;
		while (1) {
			if (a % 2 || b % 2 || c % 2)
				return cout << res << endl, 0;
			res++;
			a = (S - a) / 2;
			b = (S - b) / 2;
			c = (S - c) / 2;
		}
	}
}



Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0

#include<bits/stdc++.h>

using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void) {

    int N;
    cin >> N;
    vector<int> a(N + 1, 0);
    for (int i = 1; i <= N; ++i) {
        cin >> a[i];
    }
    vector<int> ans(N + 1, 0);
    for (int i = N; i >= 1; --i) {
        int cnt = 0;
        for (int j = i+i; j <= N; j += i) {
            cnt += ans[j];
        }
        if (cnt % 2 == a[i]) continue;
        else {
            while (cnt % 2 != a[i]) {
                cnt++;
                ans[i]++;
            }
        }
    }

    int sum = 0;
    for (int i = 1; i <= N; ++i) {
        if (ans[i] != 0) sum += ans[i];
    }

    cout << sum << endl;
    for (int i = 1; i <= N; ++i) {
        if (ans[i] != 0) cout << i << " ";
    }
}

Measured memory_bytes: 2432
S = str(input())
day = 0
if S == "SUN":
    day = 7
elif S == 'MON':
    day = 6
elif S == 'TUE':
    day = 5
elif S == 'WED':
    day = 4
elif S == 'THU':
    day = 3
elif S == 'FRI':
    day = 2
elif S == 'SAT':
    day = 1
print(day)



Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
	public static void Main()
	{
		var n = int.Parse(ReadLine());
		if(n == 0)
			WriteLine("1");
		else
			WriteLine("0");
	}
}


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

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;

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

	int M;
	cin >> M;
	for (int i = 0; i < M; i++) {
		int P, X;
		cin >> P >> X;
		cout << sum - T[P-1] + X << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main() {
    string s;
    cin >> s;
    
    if (s == "ABC") {
    cout << "ARC" << endl;
    } else {
    cout << "ABC" << endl;
    }
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    vector<ll> ans(n);
    vector<pair<ll, ll>> u(n+1);
    u[n] = make_pair(0, 0);
    for (ll i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        u[i] = make_pair(x, i);
    }
    sort(u.begin(), u.end(), greater<>());
    ll cur = 0, m = n+1;
    while(cur != n+1){
        if(u[cur].first != u[cur+1].first) {
            m = min(m, u[cur].second);
            ans[m] += (u[cur].first-u[cur+1].first)*(cur+1);
        }
        cur++;
    }
    for (int i = 0; i < n; ++i) {
        cout << ans[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 3456
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

LL n, k, l1, l2, r1, r2;

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif

  int x;
  scanf("%d", &x);
  if (x >= 30) puts("Yes");
  else puts("No");

#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

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


int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a*b > c*d)
	{
		cout << a * b << endl;
	}
	else
	{
		cout << c * d << endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <array>
#include <vector>
#include <unordered_set>
#include <cstdint>
#include <functional>

using namespace std;
using ll = int64_t;

constexpr ll MOD = 1'000'000'007;
vector<unordered_set<int>> edge;

vector<array<int, 2>> dp;

ll dfs(int v, bool b, int parent = -1){
    if(dp[v][b] != -1) return dp[v][b];
    ll ans = 1;
    for (auto &&u : edge[v]) {
        if(u == parent) continue;
        ll c = dfs(u, false, v);
        if(!b) c += dfs(u, true, v);
        c %= MOD;
        ans *= c;
        ans %= MOD;
    } // end u

    return dp[v][b] = ans;
}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    edge.clear(); edge.resize(N);
    for (int i = 0; i < N-1; ++i) {
        int x, y;
        cin >> x >> y; x--; y--;
        edge[x].insert(y);
        edge[y].insert(x);
    } // end i
    dp.clear();
    dp.resize(N, {-1, -1});

    ll ans = dfs(0, true) + dfs(0, false);
    ans %= MOD;

    cout << ans << endl;
}


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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


bool BipartiteGraph(int v, int prev, int c, const vvi &G, vi &color) {
    color[v] = c;
    for (auto next : G[v]) {
        if (next == prev) continue;
        if (color[next] == color[v]) return false;
        if (color[next] == -1 && !BipartiteGraph(next, v, 1 - c, G, color)) return false;
    }
    return true;
}

int main() {
    ll N; cin >> N;
    vvi G(N);
    rep(i, N) {
        rep(j, N) {
            char c; cin >> c;
            if (c == '1') {
                G[i].pb(j);
            }
        }
    }

    vi color(N,-1);

    bool g = BipartiteGraph(0,-1,0,G,color);

    if (!g) {
        cout << -1 << endl;
        return 0;
    }

    //各点をV1としてkを最大化する
    int ans = 1;
    vi col(N);
    rep(s, N) {
        col.assign(N, -1);
        queue<int> q;

        col[s] = 1;
        q.push(s);
        while (!q.empty()) {
            int v = q.front(); q.pop();
            chmax(ans, col[v]);

            for (auto nv : G[v]) {
                if (col[nv] != -1) continue;
                col[nv] = col[v] + 1;
                q.push(nv);
            }
        }
    }

    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
const int maxn=2e5+5;
int a[maxn],m,v,p,n,ans;
bool check(int pos){
	int f=a[pos]+m>=a[n-p+1];
	if (!f)return 0;
	if (pos>=v)
		return f;
	int d=v-pos;
	if (d<=p-1){
		if (a[pos]+m>=a[n-p+1])
			return f;
	}else{
		ll sum=1ll*(d-p+1)*m;
		for (int i=pos+1;i<=n-p+1;i++){
			if (a[pos]+m<a[i]) break;
			sum-=a[pos]+m-a[i];
		}
		return (sum<=0);
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&v,&p);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	
//	check(1);
	int l=1,r=n;
	while (l<=r){
		int mid=l+r>>1;
		if (check(mid))
			r=mid-1;
		else
			l=mid+1;
	}
	cout << n-l+1 << '\n';
}/*
4 5 2 2
2 2 2 102*/

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;
vector<ll> a;
ll k;
bool check(ll mid){//積がmid以下になるような組み合わせがk個以上になるような最小のmidを求めたい.
    ll cnt = 0;

    for(ll now:a){
        if(now == 0 && mid >= 0)cnt += (ll)(a.size() - 1);
        else if(now > 0 && mid >= 0){
            cnt += (ll)(upper_bound(a.begin(),a.end(),mid/now) - a.begin());
            if(now * now <= mid)cnt--;
        }
        else if(now > 0 && mid < 0){
            if(abs(mid) % now == 0){
                cnt += (ll)(upper_bound(a.begin(),a.end(),mid/now) - a.begin());
            }
            else cnt += (ll)(lower_bound(a.begin(),a.end(),mid/now) - a.begin());
        }
        else if(now < 0 && mid >= 0){
            cnt += (ll)(a.end() - lower_bound(a.begin(),a.end(),mid/now));
            if(now * now <= mid)cnt--;
        }
        else if(now < 0 && mid < 0){
            if(abs(mid) % abs(now) == 0)cnt += (ll)(a.end() - lower_bound(a.begin(),a.end(),mid/now));
            else cnt += (ll)(a.end() - upper_bound(a.begin(),a.end(),mid/now));
        }
    }
    if(cnt/2 >= k)return true;
    else return false;
}
int main(){
    int n;
    cin >> n;
    cin >> k;
    a.resize(n);
    for(int i = 0;i < n;i++)cin >> a[i];
    sort(a.begin(),a.end());

    ll ng = -1e18-1;
    ll ok = 1e18; 

    while(ok - ng > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid)){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }

    cout << ok << endl;

}

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

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

    int n;
    cin>>n;
    map<string,int> cnt;
    while(n--)
    {
        string s;
        cin>>s;
        cnt[s]++;
    }
    map<int,vector<string>,greater<int>> strs;
    for(auto p:cnt)
        strs[p.y].push_back(p.x);
    vector<string> ans=strs.begin()->y;
    sort(ans.begin(),ans.end());
    for(string s:ans)
        cout<<s<<"\n";
}


Measured memory_bytes: 27120
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i, j, n, q, k, b, e, counter;
		try (Scanner sc = new Scanner(System.in)) {
			n = sc.nextInt();
			int[] a = new int[n];
			for(i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
			q = sc.nextInt();
			for(i = 0; i < q; i++) {
				counter = 0;
				b = sc.nextInt();
				e = sc.nextInt();
				k = sc.nextInt();
				for(j = b; j < e; j++) {
					if(a[j] == k) {
						counter++;
					}
				}
				System.out.println(counter);
			}
		}
	}
}


Measured memory_bytes: 36376
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
ll N, M, L;
ll ans = 0;

ll prohibitedArea;
ll mx;
vector<bool > seen;
vector<vector<pair<ll, ll> > > G;
vector<ll > prever;
 
vector<ll > dijkstra(ll start){
    //準備
    vector<bool > used(N, false);
    vector<ll > dist(N, 114514191919);
    prever.assign(N, -1);
    priority_queue<pair<ll, ll > , vector<pair<ll, ll > >, greater<pair<ll, ll > > > que;
    //初期化
    que.push(make_pair(0, start));
 
    //cout << que.top().first << endl;
 
    while(!que.empty()){
        //距離
        ll d = 0;
        //次の頂点
        ll t_v = 0;
        d = que.top().first;
        t_v = que.top().second;
        //topから削除
        que.pop();
        //探査済みなら処理しない
        if(used[t_v] == true) continue;
        //探査済みにする
        used[t_v] = true;
        //キューの上には既に最小距離が来ているので
        dist[t_v] = d;
        
        //次探査する頂点はt_vなのでt_vから更に次にの頂点の繋がりをキューにいれる
        for(ll i = 0; i < G[t_v].size(); i++){
            //もし探査済みの頂点で，そこまでの累積距離より今更新しようとしている距離が
            //大きいときは更新しない
            ll to = G[t_v][i].first;
            ll cost = d+G[t_v][i].second;
            if(dist[to] <= cost) continue;
            prever[to] = t_v;
            //累積距離と次の頂点
            que.push(make_pair(cost, to));
            //仮dist
            dist[to] = cost;
        }
        //cout << endl;
    }   
    
    return dist;
 
}

vector<ll > get_path(ll t){
    vector<ll > path;
    for(; t != -1; t = prever[t]){
        //cout << prever[t] << endl;
        path.push_back(t);
    }
    //reverse(path.begin(), path.end());
    return path;
}


void dfs(ll idx, ll from = -1, ll pathSize = 0){

    seen[idx] = true;

    if(idx == prohibitedArea){
        return;
    }

    mx = max(mx, pathSize);

    for(ll i = 0; i < G[idx].size(); i++){
        //次の行き先は？
        ll to = G[idx][i].first;
        //探査済み
        if(seen[to] == true){
            continue;
        }
        dfs(to , idx, pathSize + 1);
    }

    return;
}

int main() {
    //頂点数
    cin >> N >> M >> L;

    G.assign(N, vector<pair<ll, ll > >());
    seen.assign(N, false);
 
    for(ll i = 0; i < N-1; i++){   
        ll u, v, w;
        cin >> u >> v;
        w = 1;
        u--;
        v--;
        //双方向に貼りましょうね
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(u, w));    
    }

    vector<ll > dist = dijkstra(M-1);
    //頂点0からget_path(ある頂点)までの経路
    vector<ll > path = get_path(L-1);

    //cout << dist[L-1] << endl;
    ll ans = dist[L-1] / 2 + dist[L-1] % 2;
    //cout << ans << endl;
    //cout << ans << endl;
    //できるだけ近づいて後一歩で捕まえられるという位置
    ll next_start = path[ans];
    //cout << next_start << endl;
    //後一歩で捕まえられるという位置には近づかずにどこまで逃げれるか
    prohibitedArea = path[ans - 1];
    //cout << prohibitedArea << endl;
    //dfs 
    
    dfs(next_start);

    ans += mx;

    cout << ans - 1 << endl;

}

Measured memory_bytes: 13312
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
signed main(){
  Int h,w,x,y;
  cin>>h>>w>>x>>y;
  if((h*w%2==1)&&((x+y)%2==1)) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}



Measured memory_bytes: 3108
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace ALDS1_9C_2{
    public class Program{
        public static void Main(string[] args){
            var pq = new PriorityQueue<int>();
            var sb = new StringBuilder();

            while(true){
                var query = Console.ReadLine().Split(' ');

                if(query[0][0] == 'i') pq.Enqueue(-int.Parse(query[1]));
                else 
                if(query[0][1] == 'x') sb.AppendLine((-pq.Dequeue()).ToString());
                else break;
            }

            Console.Write(sb);
            //---------------------------------
        }
    }

    public class PriorityQueue<T> : IEnumerable<T> where T : IComparable{
        private readonly List<T> _list = new List<T>();

        public int Count{
            get { return _list.Count; }
        }

        IEnumerator<T> IEnumerable<T>.GetEnumerator(){
            return _list.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator(){
            return _list.GetEnumerator();
        }

        public void Clear(){
            _list.Clear();
        }

        public bool Contains(T value){
            return _list.Contains(value);
        }

        public T Peek(){
            return _list[0];
        }

        public void Enqueue(T value){
            _list.Add(value);
            PushHeap();
        }

        public T Dequeue(){
            var ret = _list[0];
            _list[0] = _list[_list.Count - 1];
            _list.RemoveAt(_list.Count - 1);
            PopHeap();
            return ret;
        }

        private void PushHeap(){
            var i = _list.Count - 1;
            while(i != 0){
                var p = (i - 1) / 2;
                if(_list[i].CompareTo(_list[p]) > 0) return;

                SwapIndex(i, i = p);
            }
        }

        private void PopHeap(){
            var i = 0;
            while(true){
                var l = 2 * i + 1;
                var r = l + 1;

                var maxi = i;
                if(l < _list.Count && _list[maxi].CompareTo(_list[l]) > 0) maxi = l;
                if(r < _list.Count && _list[maxi].CompareTo(_list[r]) > 0) maxi = r;
                if(maxi == i) return;

                SwapIndex(i, i = maxi);
            }
        }

        private void SwapIndex(int left, int right){
            var tmp = _list[left];
            _list[left] = _list[right];
            _list[right] = tmp;
        }
    }
}

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++) ans+=s[i]-'0';
    if(ans%9)cout<<"No";
    else cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    
    string s = "";
    int amount = 0;
    cin >> s;
    cin >> amount;
    string res = "";
    for(int q = 0; q < s.length(); q+=amount){
        res += s[q];
    }

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    int a, b;
    int n, ans=0;
    
    scanf("%d%d", &a, &b);
    
    n=b-a;
    
    for (int i=1; i<n; i++) {
        ans+=i;
    }
    
    printf("%d", ans-a);
    
    return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define inf (long long)1e9
using namespace std;

long long n, u, v;
vector<long long> edge[100005];
vector<long long> disu, disv;
queue<long long> qu;

long long solve();

int main() {
  cin >> n >> u >> v;
  --u, --v;
  for(int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    edge[--a].push_back(--b);
    edge[b].push_back(a);
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0, id = u;
  disv.assign(n, inf);
  disv[v] = 0;
  qu.push(v);
  while(!qu.empty()) {
    long long now = qu.front();
    qu.pop();
    for(long long nextp : edge[now])
      if(disv[nextp] > disv[now] + 1) {
        disv[nextp] = disv[now] + 1;
        qu.push(nextp);
      }
  }
  disu.assign(n, inf);
  disu[u] = 0;
  qu.push(u);
  while(!qu.empty()) {
    long long now = qu.front();
    qu.pop();
    for(long long nextp : edge[now])
      if(disu[nextp] > disu[now] + 1 &&
         disu[now] + 1 < disv[nextp]) {
        disu[nextp] = disu[now] + 1;
        qu.push(nextp);
        id = nextp;
      }
  }
  for(int i = 0; i < n; ++i)
    if(disu[i] != inf) {
      long long now = 0;
      now = disu[i];
      now += disv[i] - disu[i] - 1;
      res = max(res, now);
    }
  return res;
}

Measured memory_bytes: 8064
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10


def main():
    N, L = map(int, input().split())
    a_list = list(map(int, input().split()))

    for i in range(N - 1):
        if a_list[i] + a_list[i + 1] >= L:
            break
    else:
        print("Impossible")
        return

    print("Possible")
    for x in range(1, i + 1):
        print(x)
    for x in range(N - 1, i, -1):
        print(x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14684
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int n,m,q;
int t[100][5];
vector<int> v1;

int check2(){
	int i;
	int s=0;
	for(i=0;i<q;i++){
		if(v1[t[i][1]]-v1[t[i][0]]==t[i][2])s+=t[i][3];
	}
	return s;
}

int check(){
	if(v1.size()==n)return check2();
	int i,a;
	int s=0;
	if(v1.empty())a=1;
	else a=v1.back();
	for(i=a;i<=m;i++){
		v1.push_back(i);
		s=max(s,check());
		v1.pop_back();
	}
	return s;
}

int main(){
	int i,j,k;
	int a,b,c;
	cin>>n>>m>>q;
	for(i=0;i<q;i++){
		for(j=0;j<4;j++){
			cin>>t[i][j];
		}
		t[i][0]--,t[i][1]--;
	}
	cout<<check()<<endl;
}

Measured memory_bytes: 3640
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit, maxsize


def find(n, data):
    temp = [0] * (n * (n+1) // 2)
    maximum = -maxsize

    for row in data:
        index = 0
        num_cell = 1

        for end in range(n, -1, -1):
            for i in range(end):
                k = index + i

                now = sum(row[i:i+num_cell])
                if temp[k] < 0:
                    temp[k] = now
                else:
                    temp[k] += now

                if maximum < temp[k]:
                    maximum = temp[k]

            index += end
            num_cell += 1

    return maximum


def main(readline=stdin.readline):
    n = int(readline())

    a = []
    for _ in range(n):
        a.append([int(s) for s in readline().split()])

    print(find(n, a))
    exit()


if __name__ == '__main__':
    main()

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int N = 1e6;
const int LOG = 21;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLMOD = 998244353;
const ll LLINF = 1e18;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s, t;
    cin >> s >> t;
    vector<vi> letters(26);
    ll ans = 0;
    forn(i, sz(s)) {
        letters[s[i] - 'a'].pb(i);
    }
    int lastpos = sz(s);
    for (char c : t) {
        int id = c - 'a';
        if (sz(letters[id]) == 0) {
            cout << "-1\n";
            return 0;
        } else {
            if (letters[id].back() <= lastpos) {
                ans++;
                lastpos = letters[id].front();
            } else {
                int idx = (int) (lower_bound(all(letters[id]), lastpos) - letters[id].begin());
                if (letters[id][idx] == lastpos) idx++;
                lastpos = letters[id][idx];
            }
        }
    }
    cout << (ans-1ll)*1ll*sz(s)+1ll*lastpos+1ll << "\n";
    return 0;
}

Measured memory_bytes: 1228