akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<sstream>
#include<numeric>
#include<queue>
#include<cstdio>
#include<iterator>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb(x) push_back(x)
ll mod = 1e9 + 7;
ll inf = 1e9 + 7;
template<typename T, typename U>
T binpow(T a, U n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1)
        return (binpow(a, n - 1) * a) % mod;
    else {
        ll b = binpow(a, n / 2) % mod;
        return (b * b) % mod;
    }
}
template<typename T>
T gcd(T a, T b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
template<typename T>
istream& operator>>(istream& str, vector<T>& vec) {
    for (auto& w : vec) str >> w;
    return str;
}
template<typename T>
ostream& operator<<(ostream& str, vector<T>& vec) {
    for (auto& w : vec) str << w << ' ';
    return str;
}

struct segtree {
    vector<set<ll>>mn;
    vector<ll>tree;
    size_t size = 1;
    //void build(ll x, ll lx, ll rx, vector<ll>& vec);
    void build(ll size_) {
        while (size < size_) {
            size *= 2;
        }
        tree.resize(size * 2 - 1);
        mn.resize(size * 2 - 1);
    }
    void update(ll i, ll x, ll v, ll lx, ll rx) {
        if (rx - lx == 1) {
            tree[x] = v;
            return;
        }
        ll m = (lx + rx) / 2;
        if (i < m) {
            update(i, 2 * x + 1, v, lx, m);
        }
        else {
            update(i, 2 * x + 2, v, m, rx);
        }
        tree[x] = tree[2 * x + 1] + tree[2 * x + 2];
    }

    ll get(ll l, ll r, ll x, ll lx, ll rx) {
        if (l <= lx && rx <= r) return tree[x];
        if (rx <= l || lx >= r) return 0;
        ll m = (lx + rx) / 2;
        return get(l, r, 2 * x + 1, lx, m) + get(l, r, 2 * x + 2, m, rx);
    }
};



signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<ll>vec(n), dp(n + 1);
    cin >> vec;
    for (int i = n; i > 1; --i) {
        dp[i - 1] = (vec[i - 1] + dp[i]) % mod;
    }
    ll ans = 0;
    for (int i = 0; i < n - 1; ++i) {
        ans += (vec[i] * dp[i + 1]) % mod;
    }
    cout << ans % mod;
}

Measured memory_bytes: 6348
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<cmath>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define show(x) cout<< #x << " = " << (x) << endl
#define show_array(arr) REP(i,int((arr).size()))cout<< #arr << "["<<i<<"]"<<"="<<arr[i]<<endl

int main(){
	
	ios::sync_with_stdio(false);
	int A,B;

	cin>>A>>B;

	int count = 0;
	
	for(int i = A; i <= B; i++ ){
		int k5 = i / 10000 ;
		int k4 = i / 1000 - k5 * 10;
		int k3 = i / 100 - k5 * 100 - k4 * 10 ;
		int k2 = i / 10 - k5 * 1000 - k4 * 100  - k3 * 10;
		int k1 = i % 10;
		if(k5 == k1 && k4 == k2)count++;
	}

		
	cout<<count<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
const int MAX_N=100000;
int main()
{
    int N,A,B; cin >> N >> A >> B;
    char S[MAX_N]; cin >> S;
    int count_all=0;
    int count_b=0;
    for(int i=0;i<N;++i){
        if(S[i]=='a'){
            if(count_all < A+B){
                ++count_all;
                cout << "Yes" << endl;
            }
            else cout << "No" << endl;;
        }else if(S[i]=='b'){
            ++count_b;
            if(count_all < A+B && count_b <= B){
                ++count_all;
                cout << "Yes" << endl;
            }
            else cout << "No" << endl;;
        }else if(S[i]=='c'){
                 cout << "No" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 768
#include<ctime>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

char s[100010];

int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='p')
		{
			ans--;
		}
	}
	printf("%d\n",ans+n/2);
}

Measured memory_bytes: 384
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素



signed main(){

  int N;
  cin>>N;
  vector<int> P(N);
  vector<int> min_map(N);
  for(int i=0;i<N;i++)cin>>P.at(i);
  min_map[0]=P[0];
  for(int i=1;i<N;i++){
    min_map[i]=min(min_map[i-1],P[i]);
  }
  int result=0;
  for(int i=0;i<N;i++){
    if(min_map[i]>=P[i])result++;
  }
  cout<<result;
}

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

int digsum(int a){
    if(a/10==0){return a%10;}
    else{
        int s=digsum(a/10);
        return s+a%10;
    }
}

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int ans=0;
    for(int i=1;i<=n;i++){
       if(digsum(i)>=a&&digsum(i)<=b)ans+=i;
    }
    cout<<ans<<endl;
}


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

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

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int a, b, c;
        cin >> a >> b >> c;

        if ((b - c) * (a - c) < 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
S = input()
odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']
for x in range(len(S)):
    if (x+1) % 2 == 0:
        if not S[x] in even:
            print('No')
            break
    else:
        if not S[x] in odd:
            print('No')
            break
else:
    print('Yes')

Measured memory_bytes: 9116
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <math.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define printA(arr) for(int i = 0; i < SZ(arr); i++){cout << arr[i];if (i==SZ(arr)-1){cout<<endl;}else{cout << " ";}}
typedef long long ll;

int main()
{
  string x;
  cin >> x;
  int K;
  cin >> K;
  int N=x.length();

  vector<string> v;
  REP(i,N){
    for(int n=1;n<=5;n++){
      if(i+n>N){
        break;
      }
      v.push_back(x.substr(i,n));
    }
  }

  sort(all(v));
  unique(all(v));
  cout << v[K-1] << endl;

  return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  bool ans = false;
  if(s[0] == '7') ans = true;
  if(s[1] == '7') ans = true;
  if(s[2] == '7') ans = true;

  ans? Yes: No;

  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
char a[305][305];
int b[305][305];
int c[305];
int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    int cnt=0;
    for(int i=0;i<=n;i++)
	{
        for(int j=0;j<m;j++)
		{
            cin>>a[i][j];
            if(a[i][j]=='#')
			{
				b[i][j]=++cnt;
				c[i]++;
			}
        }
    }
    for(int i=0;i<n;i++)
	{
        if(c[i])
		{
 	       for(int j=0;j<m;j++)
			{
                if(b[i][j])
				{
                    int color=b[i][j];
                    int l=j-1;
                    while(l>=0 and !b[i][l])
					{
						b[i][l--]=color;
					}
                    l=j+1;
                    while(l<m and !b[i][l])
					{
						b[i][l++]=color;
					}
                }
            }
        }
    }
    for(int i=0;i<n;i++)
	{
        for(int j=0;j<m;j++)
		{
            if(!b[i][j])
			{
                int l=i;
                while(l>=0 and !b[l][j])
                {
            		l--;
			    }
                if(l>=0)
				{
					b[i][j]=b[l][j];
					continue;
				}
               	l=i;
               	while(l<=n and !b[l][j])
               	{
               		l++;
				}
               	if(l<n)
				{
					b[i][j]=b[l][j];
					continue;
				}
            }
         }
    }
    for(int i=0;i<n;i++)
    {
    	for(int j=0;j<m;j++)
    	{
    		cout<<b[i][j]<<" ";
		}
		cout<<endl;
	}
}


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

class Item {
  int val;
  int weight;
  public Item(int weight, int value) {
    this.val = value;
    this. weight = weight;
  }
}
public class Main {
 
  public static void main(String[]abc) {
     Main answer = new Main();
     long solution = answer.solve();
     System.out.println(solution);
  }
  
  private long solve() {
	Scanner sc = new Scanner(System.in); 
    int N = sc.nextInt();
    int maxWeight = sc.nextInt();
    // max value of an item = 1000
    // total max value = N items * 1000
    int maxValue = 1000*N;
    long [][] dp = new long[N+1][maxValue+1];
    long INF = (long) 1e9+1;
    for(int i=0;i<=maxValue;i++){
       dp[1][i]= INF;
    }
    Item[] array = new Item[N+1];
    for(int i=1;i<=N;i++){
      array[i]= new Item(sc.nextInt(), sc.nextInt());
    }
    dp[1][array[1].val] = array[1].weight;
    dp[1][0]=0;
    for(int i=2;i<=N;i++){
      for(int j=0;j<=maxValue;j++){
        dp[i][j] = dp[i-1][j];
        if (array[i].val>j) continue;
        dp[i][j] = Math.min( dp[i-1][j], dp[i-1][j-array[i].val] + array[i].weight);
      }
    }
    long bestValue =0;
    for(int i=0;i<=maxValue;i++) {
       if (dp[N][i]<=maxWeight) bestValue = Math.max(bestValue, i);
    }
    return bestValue;
     
  }
  
}


Measured memory_bytes: 140908
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <utility>
#include <map>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
int n,q;
vector<int> a;
vector<int> b;
vector<int> p;
vector<int> x;
ll ans[200000];
vector<vector<int>> E;
ll X[200000];
void dfs(int pos, int parent,ll plus)
{
	ans[pos]=plus+X[pos];
	for(int i=0;i<E[pos].size();i++)
	{
		int next=E[pos][i];
		if(next==parent)continue;//***
		dfs(next,pos,ans[pos]);
	}
}
int main()
{
    cin>>n>>q;
	E.resize(n);
	a.resize(n-1);
	b.resize(n-1);
	p.resize(q);
	x.resize(q);
    for(int i=0;i<n-1;i++)
    {
        cin>>a[i]>>b[i];
		a[i]--;
		b[i]--;
		E[a[i]].push_back(b[i]);
		E[b[i]].push_back(a[i]);  
	}
    for(int i=0;i<q;i++)
    {
    cin>>p[i]>>x[i];
     // ans[p[i]-1]+=x[i];
	 X[p[i]-1]+=x[i];
    }
    dfs(0,-1,0);
    for(int i=0;i<n;i++)
    {
        cout<<ans[i]<<" ";
    }
    return 0;
}





Measured memory_bytes: 28800
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define Boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

template <typename T>
void PrintV(vector <T> &V) {
    int n = V.size();
    for(int i=0;i<n;i++) cout << V[i] << " \n"[i==n-1];
}

struct Seg {
    long l,r,ind,ans;
};

long B = 3;

template <typename T>
void Print(vector <T> &A) {
    int n = A.size();
    for(int i=0;i<n;i++) cout << A[i].l << "," << A[i].r << "," << A[i].ans<< " \n"[i==n-1];
}

bool comp1(const Seg &a,const Seg &b) {
    long al = a.l/B;
    long bl = b.l/B;
    if(al==bl) {
        if(a.r==b.r) return a.l<b.l;
        return a.r<b.r;
    }
    else return al<bl;
}
bool comp2(const Seg &a,const Seg &b) {
    return a.ind<b.ind;
}

void Compute(vector <Seg> &S,vector <long> &A,long k) {
    long m;
    m = S.size();
    vector <long> V(k+1,0);
    long left,right,curr = 0;
    left = right = S[0].l;
    while(right<=S[0].r) {
        if(V[A[right]]==0) curr++;
        V[A[right]]++;
        right++;
    }
    right--;
    // PrintV(V);
    S[0].ans = curr;
    for(int i=1;i<m;i++) {
        if(right<S[i].r){
            right++;
            while(right<=S[i].r) {
                if(V[A[right]]==0) curr++;
                V[A[right]]++;
                right++;
            }
            right--;
        } else {
            while(right>S[i].r) {
                V[A[right]]--;
                if(V[A[right]]==0) curr--;
                right--;
            }
        }
        if(left<=S[i].l) {
            while(left<S[i].l) {
                V[A[left]]--;
                if(V[A[left]]==0) curr--;
                left++;
            }
        } else {
            left--;
            while(left>=S[i].l) {
                if(V[A[left]]==0) curr++;
                V[A[left]]++;
                left--;
            }
            left++;
        }
        // PrintV(V);
        S[i].ans = curr;
    }
} 

void Crack() {
	long n,q,k;
    cin >> n >> q;
    B = floor(sqrt(n));
    vector <long> A(n+1);
    for(int i=1;i<=n;i++) cin >> A[i];
    k = 0;
    for(int i=1;i<=n;i++) k = max(k,A[i]);
    vector <Seg> S(q);
    for(int i=0;i<q;i++) {
        cin >> S[i].l >> S[i].r;
        S[i].ind = i;
    }
    sort(S.begin(),S.end(),comp1);
    // Print(S);
    Compute(S,A,k);
    sort(S.begin(),S.end(),comp2);
    // Print(S);

    for(int i=0;i<q;i++) cout << S[i].ans << endl;
}

int main()
{
	Boost;
    Crack();
	return 0;
}

Measured memory_bytes: 26660
gets
As = gets.split.map(&:to_i)

phase = :buy
money = 1000
kabu = 0
(As.length - 1).times.each do |i|
  now = As[i]
  nex = As[i + 1]
  if phase == :buy
    if nex > now
      phase = :sell
      count = money.div(now)
      money -= count * now
      kabu += count
      # puts "buy #{now} * #{count} -> #{kabu}, #{money}"
    end
  elsif phase == :sell
    if nex < now
      phase = :buy
      count = kabu
      money += count * now
      kabu -= count
      # puts "sell #{now} * #{count} -> #{kabu}, #{money}"
    end
  end
end

now = As.last
count = kabu
money += count * now
kabu -= count
# puts "sell #{now} * #{count} -> #{kabu}, #{money}"

puts money


Measured memory_bytes: 14408
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <map>
#include <cctype>
#include <string>
#include <cstdlib>
#include <math.h>
using namespace std;

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

int main()
{
  cout << setprecision(6);
  cout << setiosflags(ios::scientific);
  cout.flags(ios::fixed);

  while(true){
  int n;
  cin >> n;
  if(n==0) break;

  int score[n];
  REP(i,n){
    cin >> score[i];
  }

  int sum=0;
  REP(i,n){
    sum += score[i];
  }
  double ave = (double)sum / n;

  double t=0.0;
  REP(i,n){
    t += pow(ave - (double)score[i], 2 );
  }
  cout << sqrt(t/n) << endl;

    }
}

Measured memory_bytes: 1236
A, B, C, X, Y = map(int, input().split())

if (A + B > 2 * C):
    ans = min(X, Y) * 2 * C
    if (X > Y):
        ans += (X - Y) * min(A, 2 * C)
    else:
        ans += (Y - X) * min(B, 2 * C)
else:
    ans = X * A + Y * B

print(ans)


Measured memory_bytes: 38256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;

int N;

int S[MAX_N];

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

    cin >> N;

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

    sort(S, S + N);

    int ans = sum;

    if (sum % 10 == 0) {
        for (int i = 0; i <= N; i++) {
            if (i == N) {
                ans = 0;
                break;
            }
            if ((sum - S[i]) % 10 != 0) {
                ans = sum - S[i];
                break;
            }
        }
    }

    cout << ans << "\n";

    return 0;
}

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

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

  int N; cin >> N;
  int res = 0, n = N;
  while (n) {
    res += n % 10;
    n /= 10;
  }
  cout << (N % res == 0 ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

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

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int H; cin >> H;
  int cnt = 0, ans = 0;
  while(H > 0){
    ans += (1ll<<cnt);
    H /= 2;
    cnt++;
  }
  cout << ans << endl;
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007
#define PI 3.141592653589793238462643383

signed main()
{
	init();
	solve();
}

int N, C, K;
vector<int> T;

void init()
{
	cin >> N >> C >> K;
	T.resize(N);
	rep(i, N) cin >> T[i];
	sort(all(T));
}

void solve()
{
	vector<pair<int, int> > bus;
	bus.PB(MP(0, 0));
	rep(i, N) {
		if (bus.back().second == 0 || bus.back().first < T[i]) {
			bus.PB(MP(T[i]+K, C-1));
		} else {
			bus.back().second--;
		}
	}
	cout << bus.size() - 1 << endl;
}



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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<int> dp(n);
    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);
    rep2(i,2,n) {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
using namespace std;
#define lli long long int

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	lli l,r;
	lli i,j;
	cin>>l>>r;
	if((r-l+1)>=2019)
		cout<<0;
	else
	{
		lli ans = 2018;
		for(i=l;i<=r;i++)
		{
			for(j=i+1;j<=r;j++)
			{
				lli temp_i = i % 2019;
				lli temp_j = j % 2019;
				lli val = temp_i*temp_j;
				val = val % 2019;
				val = (val + 2019)%2019;
				ans = min(ans,val);
			}
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 256
/* Click on the checkbox for Add Custom Input and then write the input there before running the program */
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
	    Scanner input = new Scanner(System.in);
	    int[][] a = new int[3][3];
	    for(int i=0;i<3;i++)
	        for(int j=0;j<3;j++)
	            a[i][j] = input.nextInt();
	    
	    int q = input.nextInt();
	    while(q-->0)
	    {
	        int n = input.nextInt();
	        
	        for(int i=0;i<3;i++)
	            for(int j=0;j<3;j++)
	                if(a[i][j]==n)
	                    a[i][j]=-1;
	    }
	    if(isRow(a)||isCol(a)||isDiag(a))
	        System.out.println("Yes");
	    else
	        System.out.println("No");
	}
	static boolean isRow(int[][] a)
	{
	    boolean flag = false;
	    for(int i=0;i<3;i++)
	    {
	        for(int j=0;j<3;j++)
	        {
	            if(a[i][j]==-1)
	                flag = true;
	            else
	            {
	                flag = false;
	                break;
	            }
	        }
	        if(flag)
	            break;
	    }
	    return flag;
	}
	
	static boolean isCol(int[][] a)
	{
	    boolean flag = false;
	    for(int i=0;i<3;i++)
	    {
	        for(int j=0;j<3;j++)
	        {
	            if(a[j][i]==-1)
	                flag = true;
	            else
	            {
	                flag = false;
	                break;
	            }
	        }
	        if(flag)
	            break;
	    }
	    return flag;
	}
	static boolean isDiag(int[][] a)
	{
	    boolean flag1=false,flag2 = false;
	    for(int i=0;i<3;i++)
	    {
	        if(a[i][i]==-1)
	            flag1 = true;
	        else{
	            flag1 = false;
	            break;
	        }
	    }
	    if(a[0][2]==a[1][1]&&a[1][1]==a[2][0])
	        flag2=true;
	    else
	        flag2=false;
	    return flag1||flag2;
	}
}

Measured memory_bytes: 21844
#include<cstdio>
#include<queue>
#define MAX_W 1000
#define MAX_H 1000
#define MAX_N 9
int h, w, n;
char fields[MAX_W + 1][MAX_H] = { };

int INF = 100000000;
int d[MAX_W][MAX_H];
int sx, sy;
typedef
std::pair < int, int >
  P;
P
  gp[MAX_N];
int
dx[4] = { -1, 1, 0, 0 }, dy[4] = {0, 0, -1, 1};

void
initd (void)
{
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      d[j][i] = INF;
}

int
bfs (int m)
{
  std::queue < P > que;
  que.push (P (sx, sy));
  initd ();
  d[sx][sy] = 0;
  while (que.size () > 0)
    {
      P
	p = que.front ();
      que.pop ();
      for (int i = 0; i < 4; i++)
	{
	  int
	    nx = p.first + dx[i];
	  int
	    ny = p.second + dy[i];
	  if (0 <= nx && nx < w && 0 <= ny && ny < h && d[nx][ny] == INF
	      && 'X' != fields[nx][ny])
	    {
	      que.push (P (nx, ny));
	      d[nx][ny] = d[p.first][p.second] + 1;
	      if (gp[m] == P (nx, ny))
		{
		  sx = nx;
		  sy = ny;
		  return d[nx][ny];
		}
	    }
	}
    }
}

int
main (void)
{
  scanf ("%d %d %d\n", &h, &w, &n);
  for (int y = 0; y < h; y++)
    for (int x = 0; x <= w; x++)
      {
	scanf ("%c", &fields[x][y]);
	if ('S' == fields[x][y])
	  {
	    sx = x;
	    sy = y;
	  }
	else if ('1' <= fields[x][y] && fields[x][y] <= '9')
	  {
	    gp[fields[x][y] - '1'] = P (x, y);
	  }
      }
  int
    t = 0;
  for (int d = 0; d < n; d++)
    t += bfs (d);
  printf ("%d\n", t);
  return 0;
}

Measured memory_bytes: 5668
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[] p = new int[n];
        for(int i = 0;i<n;i++){
            p[i] = sc.nextInt();
        }
        Arrays.sort(p);
        long ans = 0;
        for(int i = 0;i<k;i++){
            ans += p[i];
        }
        System.out.println(ans);

    }

}


Measured memory_bytes: 38920
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
#define MOD 1e9 + 7
#define N 1e5 + 10
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll i=0,c=0,count=0,j=0;
	ll h[n];
	for(i=0;i<n;i++)
	{
		cin>>h[i];
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<i;j++)
		{
			if(h[i]>=h[j])
			{
				count++;
			}
		}
		if(count==i)
		{
			//cout<<h[i]<<" ";
			c++;
		}
		count=0;
	}	
	cout<<c;
}	

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public struct Pair<T> { public T x, y; public Pair(T x, T y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        long W = NextLong();
        long H = NextLong();
        long x = NextLong();
        long y = NextLong();

        if (W % 2 == 0 && W / 2 == x)
        {
            if (H % 2 == 0 && H / 2 == y)
            {
                Console.WriteLine((H * W) / 2.0 + " 1");
                return;
            }
            Console.WriteLine((H * W) / 2.0 + " 0");
            return;
        }
        if (H % 2 == 0 && H / 2 == y)
        {
            Console.WriteLine((H * W) / 2.0 + " 0");
            return;
        }

        Console.WriteLine((H * W) / 2.0 + " 0");

    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}


public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 11220
#include <iostream>
using namespace std;
long long a, b, c, sum = 1;

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

int main() {
	cin >> a >> b;
	c = gcd(a, b);
	for (long long i = 2; i * i <= c; i++) {
		if (c % i == 0) {
			sum++;
			while (c % i == 0) c /= i;
		}
	}
	if (c != 1) sum ++;
	cout << sum << endl;
	return 0;
}

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

const int num = 3; //ここを変えるだけで汎用性を広げられるはず　//今回はa,b,cの3個より　const int num=3;

int main() {
	int min=0;
	std::vector<int> v;
	v.resize(num);

	for (auto&& x : v) {
		std::cin >> x;
	}

	for (int i = 0; i < v.size()-1; i++) { 
		for (int j = i+1; j< v.size(); j++) {
			if (i==0&&j==1) {
				min = v[i] + v[j];
				continue;
			}
			min = min >(v[i] + v[j]) ? v[i] + v[j] : min;
		}
	}

	std::cout << min << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
#include <iterator>

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

    std::set<std::string> a;
    for (int i = 0; i < n; i++) 
    {
        std::string s;
        std::cin >> s;
        a.insert(s);
    }

    std::cout << a.size() << std :: endl;
}


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

typedef int in;
#define int long long
int MAX=1e8;

string a,b;
int dp[3005][3005];

int f(int idxa,int idxb)
{
    if(idxa==a.size()||idxb==b.size())
        return dp[idxa][idxb]=0;
    int &ret=dp[idxa][idxb];
    if(ret!=-1)
        return ret;
    ret=f(idxa+1,idxb);
    if(a[idxa]==b[idxb])
        ret=max(ret,f(idxa+1,idxb+1)+1);
    ret=max(ret,f(idxa,idxb+1));
    return ret;
}

in main()
{
    int tc=1;
//    cin>>tc;
    while(tc--)
    {
        cin>>a>>b;
        memset(dp,-1,sizeof dp);
        f(0,0);
        string ans="";
        int idx1=0,idx2=0;
        while(idx1<a.size()&&idx2<b.size()){
            int ret=dp[idx1+1][idx2];
            ret=max(ret,dp[idx1][idx2+1]);
            if(a[idx1]==b[idx2])
                ret=max(ret,dp[idx1+1][idx2+1]+1);
            if(ret==dp[idx1+1][idx2])
                idx1++;
            else if(ret==dp[idx1][idx2+1])
                idx2++;
            else{
                ans+=a[idx1];
                idx1++;idx2++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 74528
n,a,b = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
ans = 0
0.upto(n-2) do |i|
  w = a * (x[i+1] - x[i])
  if w <= b
    ans += w
  else
    ans += b
  end
end
puts ans

Measured memory_bytes: 8452
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int a, b; cin >> a >> b;
	if ((a < 1 || a > 9) || (b < 1 || b > 9)) {
		cout << -1 << endl;
		return;
	}
	cout << a * b << endl;
	return;
}

int main() {
	solve();
  return 0;
}

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

#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define bg begin()
#define ed end()
#define pii pair<int,int>

int main(){
	int a,b,c;
	while(cin >> a >> b >> c){
		//int f = 0 ;
		if(a!=b||b!=c){
			cout<<"No"<<endl;
		}
		else{
			cout<<"Yes"<<endl;
		}
	}
}

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

using namespace std;
int main(){
    int n = 3;
int c[5];
for(int i = 0;i<5;i++) c[i] = 0;
for(int i = 0;i<n;i++){
    int a,b;
    cin >> a >> b;
    c[a]++;
    c[b]++;
}
int fle = 0;
for(int i = 0;i<5;i++) fle += (c[i]%2);
if(fle == 4){cout << "NO";}
else cout << "YES";
}


Measured memory_bytes: 256
def fastio():
    import sys
    from io import StringIO 
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))

n, = I()
ans = 'Christmas'
print(ans + (25 - n)*' Eve')

Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split())) + [0]
kabu = 0
money = 1000

for p in range(N):
    #株がない時
    if A[p] < A[p+1]:
        kabu += money//A[p]
        money -= (money//A[p])*A[p]
    
    #株があるとき
    if A[p] > A[p+1]:
        money += kabu*A[p]
        kabu = 0 
    #print(str(p+1) + "日目" + str(money) + "  " +str(kabu))

print(money)

Measured memory_bytes: 9072
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n_ = 5*10**5
mod = 10**9+7
fun = [1]*(n_+1)
for i in range(1,n_+1):
    fun[i] = fun[i-1]*i%mod
rev = [1]*(n_+1)
rev[n_] = pow(fun[n_],mod-2,mod)
for i in range(n_-1,0,-1):
    rev[i] = rev[i+1]*(i+1)%mod

def nCr(n,r):
    if r > n:
        return 0
    return fun[n]*rev[r]%mod*rev[n-r]%mod

n,k = nm()
if k >= n-1:
    print(nCr(2*n-1, n-1))
    exit(0)

fur = [1]*(k+1)
for i in range(1,k+1):
    fur[i] = fur[i-1]*(n-1)%mod

dp = [0]*(k+1)
dp[0] = 1
dp[1] = n*(n-1)+ 1
for i in range(2,k+1):
    dp[i] = (nCr(n,i)*nCr(n-1,i) + dp[i-1])%mod
print(dp[k])


Measured memory_bytes: 58388
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    ll N;
    cin >> N;
    ll A[N], B[N], C[N];
    REP (i, N) {
        cin >> A[i];
    }
    REP (i, N) {
        cin >> B[i];
    }
    REP (i, N) {
        cin >> C[i];
    }

    sort(A, A+N);
    sort(B, B+N);
    sort(C, C+N);
    // Bの値を決めるとAとCの値の範囲が自動的に決まる
    ll ans = 0;
    REP (i, N) {
        // B[i]をキーにAとCを二分探索
        ll count_A = lower_bound(A, A+N, B[i]) - A;
        ll count_C = upper_bound(C, C+N, B[i]) - C;;
        ans += count_A * (N - count_C);
    }

    cout << ans << endl;
}

Measured memory_bytes: 2688
#include<stdio.h>
int main(){
  long long n,d[100],a=0,s,i,j;
  scanf("%lld",&n);
  for(i=0;i<n;i++)scanf("%lld",&d[i]);
  while(1){
    for(j=s=0;j<n;j++){
      s+=d[j]/n;
      d[j]=d[j]%n-d[j]/n;;
    }//printf("%lld\n",s);
    if(s==0)break;
    for(j=0;j<n;j++)d[j]+=s;
    a+=s;
  }
  printf("%lld\n",a);
  return 0;
}


Measured memory_bytes: 128
n = int(input())
Pieces = list(map(int, input().split()))

t = int(input())
commands = list(map(int, input().split()))

for piece in commands:
    if piece != len(Pieces):
        if (Pieces[piece-1]+1) == Pieces[piece] or (Pieces[piece-1]) == 2019:
            pass
        else:
            Pieces[piece-1]+=1
    else:
        if Pieces[piece-1] != 2019:
            Pieces[piece-1]+=1

for i in Pieces:
    print(i)


Measured memory_bytes: 5600
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if (a > b)
    {
        if (b < c && a > c)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    else
    {
        if (a < c && b > c)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    
    return 0;
}

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

typedef int in;
#define int long long
int MAX=1e9;
int MAXEST=1e18;
int MOD=1e9+7;

int n,w;
int v[105],s[105];
int dp[2][100005];

in main()
{
    int tc=1;
//    cin>>tc;
    while(tc--)
    {
        cin>>n>>w;
        for(int i=1;i<=n;i++){
            cin>>s[i]>>v[i];
        }
        for(int i=1;i<=n;i++){
            for(int j=0;j<=w;j++){
                dp[i&1][j]=dp[(i-1)&1][j];
                if(j>=s[i])
                    dp[i&1][j]=max(dp[i&1][j],dp[(i-1)&1][j-s[i]]+v[i]);
            }
        }
        cout<<dp[n&1][w]<<endl;
    }
    return 0;
}


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

class A{
    int a, b, c, d, e, k;
public:
    A();
    int getdiff();
    void hantei();
};

A::A(){
    cin >> a >> b >> c >> d >> e >> k;
}

int A::getdiff(){
    return (e - a);
}

void A::hantei(){
    if (getdiff() <= k)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
}

int main() {
    A str;
    str.hantei();
    return (0);
}

Measured memory_bytes: 256
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2286"

#include<bits/stdc++.h>
using namespace std;

#define call_from_test
#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;
//END CUT HERE
#ifndef call_from_test
signed main(){
  return 0;
}
#endif

#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
vector<int> totient_table(int n){
  vector<int> ts(n+1);
  iota(ts.begin(),ts.end(),0);
  for(int i=2;i<=n;i++){
    if(ts[i]!=i) continue;
    for(int j=i;j<=n;j+=i) ts[j]=ts[j]/i*(i-1);
  }
  return ts;
}
//END CUT HERE
#ifndef call_from_test
//INSERT ABOVE HERE
class CatAndMice {
  using ll = long long;
public:
  long long countDirections(int n, int c) {
    if(n==c) return 8;

    auto ts=totient_table(n);

    ll ans=0;
    for(int i=1;i<=n;i++)
      if((n/i)==c) ans+=ts[i];

    return ans*8LL;
  }
};
/*
  verified on 2019/09/25
  https://vjudge.net/problem/TopCoder-15530
*/
#endif

#undef call_from_test

signed main(){
  const int MAX = 1e6;
  auto ts=totient_table(MAX);
  vector<long long> sm(ts.begin(),ts.end());
  for(int i=0;i<MAX;i++) sm[i+1]+=sm[i];

  int t;
  cin>>t;
  for(int i=0;i<t;i++){
    int n;
    cin>>n;
    cout<<sm[n]+1<<"\n";
  }
  cout<<flush;
  return 0;
}



Measured memory_bytes: 14264
import sys
import numpy as np

# 実行環境(0:vscode, 1:atcoder)
MODE = 1

# 入力の次元
DIMENSION = 0

# int型に変換
INT_TYPE = 1

if not (MODE):
    with open("input.txt", "r") as f:
        s = f.read()
else:
    s = sys.stdin.read()

if DIMENSION == 0:
    if INT_TYPE == 1:
        s = int(s)
elif DIMENSION == 1:
    if INT_TYPE == 0:
        s = s.split()
    elif INT_TYPE == 1:
        s = [int(x) for x in s.split()]
elif DIMENSION == 2:
    if INT_TYPE == 0:
        s = [x.split() for x in s.splitlines()]
    elif INT_TYPE == 1:
        s = [[int(y) for y in x.split()] for x in s.splitlines()]

N = s
cnt = [0 for _ in range(N)]
for x in range(1, 100):
    xx = x*x
    for y in range(x, 100):
        yy = y * y
        xy = x*y
        for z in range(y, 100):
            zz = z * z
            yz = y * z
            zx = z*x
            n = xx + yy + zz + xy + yz + zx
            if n > N:
                break
            else:
                # print(f"({x}, {y}, {z}), n = {n}")
                if x == y and y == z:
                    cnt[n-1] += 1
                elif x == y or y == z:
                    cnt[n-1] += 3
                else:
                    cnt[n-1] += 6
for i in range(N):
    print(cnt[i])


Measured memory_bytes: 27096
#include<bits/stdc++.h> 
typedef long long ll;
using namespace std;
int a[100010];
map<int,int> mp;
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    int mx=0;
    for(int i=0;i<n;i++)mx=max(mx,mp[a[i]]+mp[a[i]-1]+mp[a[i]+1]);
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 5120
#traveling
n=int(input())
flag=True
lists=[(0,0,0)]
for i in range(n):
    a=list(map(int,input().split()))
    lists.append(tuple(a))
for i in range(1,n+1):
    x,y,z=lists[i-1][0],lists[i-1][1],lists[i-1][2]
    a,b,c=lists[i][0],lists[i][1],lists[i][2]
    if abs(b-y)+abs(c-z)<=abs(a-x) and (abs(b-y)+abs(c-z))%2==abs(a-x)%2:
        pass
    else:
        flag=False
        break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 17320
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <list>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

const double PI  = 3.141592653589793238463;
const int INF = 1000000007;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

M warshallFloyd(int n, int m, const V& as, const V& bs, const V& cs){
    M dss(n, V(n, INF));
    for(int i = 0; i < n; i++){
        dss[i][i] = 0;
    }
    for(int i = 0; i < m; i++){
        dss[as[i] - 1][bs[i] - 1] = cs[i];
        dss[bs[i] - 1][as[i] - 1] = cs[i];
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            for(int k = 0; k < n; k++){
                dss[j][k] = min(dss[j][k], dss[j][i] + dss[i][k]);
            }
        }
    }
    return dss;
}

int solve(int n, int m, V& as, V& bs, V& cs){
    const M& dss = warshallFloyd(n, m, as, bs, cs);
    V us(m, false);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            for(int k = 0; k < m; k++){
                if(dss[i][j] == dss[i][as[k] - 1] + cs[k] + dss[bs[k] - 1][j]){
                    us[k] = true;
                }
            }
        }
    }
    return count(us.begin(), us.end(), false);
}

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

    int n, m;
    cin >> n >> m;
    V as(m), bs(m), cs(m);
    for(int i = 0; i < m; i++){
        cin >> as[i] >> bs[i] >> cs[i];
    }

    cout << solve(n, m, as, bs, cs) << endl;

    return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int H, int W, string[] S)
        {
            int max = 0;
            var memo = new int[H][];
            for (int i = 0; i < H; ++i)
            {
                memo[i] = new int[W];
                int L = 0, R = 0;
                for (int j = 0; j < W; ++j)
                {
                    int l = j, r = W - j - 1;
                    if (S[i][l] != '#')
                    {
                        ++L;
                        memo[i][l] += L;
                        max = Math.Max(memo[i][l], max);
                    }
                    else
                    {
                        L = 0;
                    }
                    if (S[i][r] != '#')
                    {
                        ++R;
                        memo[i][r] += R;
                        max = Math.Max(memo[i][r], max);
                    }
                    else
                    {
                        R = 0;
                    }
                }
            }
            for (int j = 0; j < W; ++j)
            {
                int T = 0, B = 0;
                for (int i = 0; i < H; ++i)
                {
                    int t = i, b = H - i - 1;
                    if (S[t][j] != '#')
                    {
                        ++T;
                        memo[t][j] += T;
                        max = Math.Max(memo[t][j], max);
                    }
                    else
                    {
                        T = 0;
                    }
                    if (S[b][j] != '#')
                    {
                        ++B;
                        memo[b][j] += B;
                        max = Math.Max(memo[b][j], max);
                    }
                    else
                    {
                        B = 0;
                    }
                }
            }
            return max - 3;
        }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int H = V[0], W = V[1];
            var S = new string[H];
            for (int i = 0; i < H; ++i) { S[i] = Read(); }
            Console.WriteLine(Solve(H, W, S));
        }
    }
}


Measured memory_bytes: 43848
N, M = gets.chop.split.map(&:to_i)
A = gets.chop.split(' ').map(&:to_i)

hoge = A.sort.reverse
sum = A.inject(:+)

flag = true

M.times do |i|
  if sum % (4 * M) == 0
    if hoge[i] < sum / (4 * M)
      flag = false
      break
    end
  else
    if hoge[i] <= sum / (4 * M)
      flag = false
      break
    end
  end
end

puts flag ? 'Yes' : 'No'


Measured memory_bytes: 1788