akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);

	int n, a, b;
	cin >> n >> a >> b;
	vi p(n);
	trav(x, p) cin >> x, --x;
	vi q(n);
	rep(i,0,n) q[p[i]] = i;

	vector<vi> cnt(n+1, vi(n+1));
	rep(i,0,n) cnt[p[i]+1][i+1] = 1;
	rep(h,1,n+1) rep(r,0,n+1) cnt[h][r] += cnt[h-1][r];
	rep(r,1,n+1) rep(h,1,n+1) cnt[h][r] += cnt[h][r-1];
	vector<vi> que(n+1, vi(n+1,-1));
	rep(h,1,n+1) rep(r,1,n+1){
		if(q[h-1] < r){
			que[h][r] = h-1;
		} else {
			que[h][r] = que[h-1][r];
		}
	}
	vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));
	rep(h,1,n+1) rep(r,1,n+1){
		int m = que[h][r];
		if(m == -1) continue;
		int i = q[m];
		dp[h][r] = min(a + dp[m][r],
			ll(b) * (cnt[h][r] - cnt[h][i+1])
				+ dp[m][i]);
			
	}
	cout << dp[n][n] << endl;
}


Measured memory_bytes: 393728
#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
using namespace std;
const int maxN = 2e5 + 5;
const double eps = 1e-6;
typedef long long ll;
typedef pair<ll, ll> P;
priority_queue<P> pq;
bool check(ll ans, int N, ll K)
{
    ll cnt = 0;
    int f, k = 0;
    ll af=0;
    priority_queue<P> pq2 = pq;
    //cout<<"ans="<<ans<<": ";
    for (int i = 0; i < N; i++)
    {

        af = pq2.top().first;
        f = pq2.top().second;
        if (af <= ans)
            continue;
        //k=int(double(af-ans)/f-eps)+1;
        k = (af - ans - 1) / f + 1;
        //cout<<k<<" ";
        cnt += k;
        pq2.pop();
    }
    //memset(&pq2, 0,sizeof(pq2));
    //cout<<endl;
    while (pq2.size())
    {
        pq2.pop();
    }
    if (cnt <= K)
        return true;
    else
        return false;
}

int main()
{
    ll A[maxN] = {0};
    ll F[maxN] = {0};
    ll N, a, f = 0;
    ll K = 0;
    scanf("%lld %lld", &N, &K);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
        
    }
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &f);
        F[i] = -f;
        f = 0;
    }
    sort(A + 0, A + N);
    sort(F + 0, F + N);

    for (int i = 0; i < N; i++)
    {
        P p;
        p.first = -A[i] * F[i];
        p.second = -F[i];
        pq.push(p);
        memset(&p, 0, sizeof(p));
    }

    ll l = 0;
    ll r = pq.top().first;
    ll mid = (l + r) >> 1;
    if (check(0, N, K))
        printf("%lld\n", l);
    else
    {
        while (mid != l)
        {
            if (check(mid, N, K))
            {
                r = mid;
            }
            else
                l = mid;
            mid = (l + r) >> 1;
        }
        printf("%lld\n", r);
    }
    while (pq.size())
    {
        pq.pop();
    }
}

Measured memory_bytes: 10732
n, k = map(int, input().split())
l = [0]*n
ans = 0
for _ in range(k):
    d = int(input())
    ad = list(map(int, input().split()))
    for i in ad:
        l[i - 1] += 1
for i in range(n):
    if l[i] == 0:
        ans += 1
print(ans)

Measured memory_bytes: 9140
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    char[] s = scanner.next().toCharArray();
    int cnt = 0;
    for (int i = 0; i < s.length / 2; i++) {
      if (s[i] != s[s.length - i - 1]) cnt++;
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define tp tuple<int,int,int>
#define mtp make_tuple
using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int cur=1;
    while(a>0&&c>0)
    {
        if(cur) c-=b;
        else a-=d;
        cur^=1;
    }
    if(a>0) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3648
#define ll long long
#define MOD 1000000007 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define T long long t;cin>>t;while(t--)
#define foe(i) for(int i=1;i<=n;i++)
#define fo(i) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  string s;
  cin>>n>>s;
  if(n>=3200)
  cout<<s;
  else cout<<"red";

}

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

/* #define MULTI_INPUT 0 */

const ll MOD = 1000000007;

void solve()
{
    int n;
    cin >> n;
    ll dp[2048] = {0, 0, 0, 1};
    for (int i = 4; i <= n; ++i) {
        dp[i] = 1;
        for (int j = 3; j < i; ++j) {
            dp[i] += dp[i - j];
            dp[i] %= MOD;
        }
    }
    cout << dp[n] << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef MULTI_INPUT
    int T;
    cin >> T;
    for (int t = 0; t < T; ++t) {
        solve();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<map>
#include<list>
#include<string>
#include<algorithm>

using namespace std;

int main() {
  string s1,s2;
  int q;
  cin >> s1 >> q;
  // bool flag = true;
  for(int i=0;i<q;i++){
    int t;
    cin >> t;
    if(t == 1){
      swap(s1,s2);
    }else{
      int f;
      string c;
      cin >> f >> c;
      if(f==1){
        s2 += c;
      }else{
        s1 += c;
      }
    }
  }

  reverse(s2.begin(),s2.end());
  cout << s2 + s1 << endl;
}

Measured memory_bytes: 1312
# 参考: https://atcoder.jp/contests/abc081/submissions/7094456
N = gets.to_i
as = gets.chomp.split.map(&:to_i)

maximum = as.max
minimum = as.min

answers = []
if maximum.abs > minimum.abs
  (0..N-2).each do |index|
    while as[index] > as[index + 1]
      max_index = as.index(as.max)
      as[index + 1] += as[max_index]
      answers << [max_index + 1, index + 2]
    end
  end
else
  (N - 1).downto(1) do |index|
    while as[index - 1] > as[index]
      min_index = as.index(as.min)
      as[index - 1] += as[min_index]
      answers << [min_index + 1, index]
    end
  end
end

puts answers.size
answers.each { |answer| puts answer.join(" ") }

Measured memory_bytes: 1788
#include <iostream>
#include <cstdlib>
int main()
{
  int N, t[100001] = {0}, x[100001] = {0}, y[100001] = {0};
  std::cin >> N;
  std::string result = "Yes";
  
  for(int i = 1; i <= N; i++)
  {
    std::cin >> t[i] >> x[i] >> y[i];  
  }
  
  for(int i = 1; i <= N; i++)
  {
    int time = t[i] - t[i-1];
    int dist = std::abs(x[i] - x[i - 1]) + std::abs(y[i] - y[i - 1]);
    if((time < dist) || (time % 2 != dist % 2))
    {
      result = "No";
      break;
    }
  }
    
  std::cout << result;
  return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

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

    int N;
    string S;

    std::cin >> N;
    std::cin >> S;

    int l = 0, al = 0, ar = 0;
    for(int i=0,j=0;i<N;i=j){
        while(j < N && S[j] == '('){
            ++l;
            ++j;
        }

        if(j == N){
            ar += l;
            break;
        }
        
        while(j < N && S[j] == ')'){
            if(l == 0){
                ++al;
            }else{
                --l;
            }

            ++j;
        }

        if(j == N){
            ar += l;
            break;
        }
    }

    std::cout << string(al, (char)'(') << S << string(ar, (char)')') << std::endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------

signed main() {
	int n = read();
	for (int i = 1; i < 10; i++) {
		if (n % i == 0 && n / i < 10) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
}

Measured memory_bytes: 256
n,m=map(int,input().split())
c=sorted(list(map(int,input().split())))
dp=[10**18]*(n+1)
for i in c:
  if i>n:break
  dp[i]=1
  for j in range(i+1,n+1):
    dp[j]=min(dp[j],dp[j-i]+1)
print(dp[n])


Measured memory_bytes: 7520
while(True):
        try:
            a,b,c,d,e,f=map(float,input().split(" "))
            z=a*e-b*d
            if(z!=0):
                x=(c*e-b*f)/z
                y=(a*f-c*d)/z
            print("{:.3f} {:.3f}".format(x+0,y+0))
        except:
            break

Measured memory_bytes: 7356
S = input()
N = len(S)

def check(c):
    if len(c) == 0:
        return False
    if list(c) == list(reversed(c)):
        return True
    return False

result = "No"
if check(S):
    if check(S[:int((N-1)/2)]):
        if check(S[int((N+3)/2)-1:]):
            result = "Yes"
print(result)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mypair;
int main(){
	int a,b;
	cin>>a>>b;
	int na=0,nb=1000,nn;
for(int i=0;i<1000;i++){
	int n = i*(i+1)/2,n2=(i+1)*(i+2)/2;
/*if(a>n){
	na=max(na,i);
	nn =n;
}
if(b<n)nb=min(nb,i);*/
if(n-a==n2-b){
cout<<n-a<<endl;
}

}
//cout<<na<<' '<<na*(na+1)<<endl;
//cout<<nb-na<<endl;
//cout<<na*(na+1)-a<<endl;
return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto& e:c)
#define iter(it,c) for(auto it=c.begin(); it!=c.end(); ++it)

ll const inf = 1<<28;
map<string,int> rtoi;
int d[256][256];
int V;

void solve(){
    rep(i,V)rep(j,V){
        bool C=false, DE=true;
        if(d[i][j]==1 || d[j][i]==1) continue;
        rep(k,V){
            if(k==i || k==j) continue;
            if((d[i][k]==1||d[k][i]==1) && (d[j][k]==1||d[k][j]==1))
                C=true;
            if((d[i][k]==1&&d[k][j]==1) || (d[k][i]==1&&d[j][k]==1))
                DE=false;
        }
        if(C&&DE) d[i][j]=d[j][i]=0;
    }
    rep(k,V)rep(i,V)rep(j,V){
        d[i][j]=min(d[i][j], d[i][k] + d[k][j]);
    }
}

bool ask(string const& p, string const& q){
    int pi=inf,qi=inf;
    if(rtoi.count(p)==1 && rtoi.count(q)==1){
        pi=rtoi[p], qi=rtoi[q];
    }
    return max(pi,qi)!=inf && d[pi][qi]!=inf && d[pi][qi]&1;
}

int main(){
    int n;
    while(cin>>n, n){
        V=0;
        rtoi.clear();
        rep(i,256)rep(j,256) d[i][j]=inf;
        rep(i,n){
            string s;cin>>s;
            int x=s.find('-');
            string p=s.substr(0,x);
            string q=s.substr(x+1);
            if(rtoi.count(p)==0)rtoi[p]=V++;
            if(rtoi.count(q)==0)rtoi[q]=V++;
            int ip=rtoi[p], iq=rtoi[q];
            d[ip][iq]=1;
        }
        solve();
        cout<<V<<endl;
        int m; cin>>m;
        rep(i,m){
            string s;cin>>s;
            int x=s.find('-');
            string p=s.substr(0,x), q=s.substr(x+1);
            puts(ask(p,q) ? "YES" : "NO");
        }
    }
}

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

//#define int long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int main(){
    string S;
    cin>>S;
    int c=0;
    if (S[0]==S[1]==S[2]==S[3]){
        c=1;
    }
    if (S[0]==S[1] && S[2]==S[3]){
        c=1;
    }
    else if(S[0]==S[2] && S[1]==S[3]){
        c=1;
    }
    else if(S[0]==S[3] && S[1]==S[2]){
        c=1;
    }
    else{ c=0;

}
    if (S[0]==S[1] &&S[0]==S[2] &&S[0]==S[3]){
        c=0;
    }
    if (c==1){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" <<endl;
    }
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N);
    int sum_x=0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        sum_x ^= A[i];
    }
    for(int i=0; i<N; i++){
        int ans = sum_x ^ A[i];
        cout << ans << " \n"[i+1 == N];
    }
    return 0;
}


Measured memory_bytes: 3904
def resolve():
    '''
    code here
    '''
    s = int(input())
    is_not_found = True
    cnt = 1
    memo = [False for _ in range(10**7+1)]

    while memo[s] == False:
        cnt += 1
        memo[s] = True
        if s % 2 == 0:
            s //= 2
        else:
            s = 3*s + 1    

    print(cnt)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 87024
using System.Text;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, k, a);
    }
    static void getAns(int n, int k, int[] a)
    {
        var sb = new StringBuilder();
        for (int i = 0; i < n - k; i++)
            sb.Append(a[i + k] > a[i] ? "Yes\n" : "No\n");
        Console.Write(sb);
    }
}


Measured memory_bytes: 48260
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int sum[200200];

int main(){
    string s;
    cin >> s;
    map<int, int> m;
    int fac = 1;
    m[0]++;
    rep(i, s.length()){
        sum[i+1] = sum[i] + fac*(s[s.length()-i-1] - '0');
        sum[i+1] = sum[i+1] % 2019;
        m[sum[i+1]]++;
        fac = (fac*10) % 2019;
    }
    ll ans = 0;
    for(auto p: m){
        auto a = p.second;
        ans += a*(a-1)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4428
/* 
    Author : Jeff Ahn
    Sat 13 Jun 2020 12:57:43 AM PDT 
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const map<T,T> &vec){ os<< "{"; for (auto p : vec) os << "(" << p.first << "," << p.second << "), "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_map<T,T>&vec){ os<< "{"; for (auto p : vec) os << "(" << p.first << "," << p.second << "), "; os << "}"; return os; }

template <typename T> struct Modular {
  /* to abbreviate the word "Modular" */
  using M = Modular; 

  /* Infers type from template. The struct/class T must have 
     "modulus" defined as member.*/
  using Type = typename decay<decltype(T::modulus)>::type; 

  /* Mod is now an alias to the "modulus" (eg 1e9+7) */

  constexpr static Type Mod() { return  T::modulus; }
  /* v is the value of the Mint. 0 <= v < Mod */
  Type v;
  Modular(long long a = 0) : v((a %= Mod()) < 0 ? a + Mod() : a) {}
  M operator-() const { return M() -= *this; }
  M& operator+=(M r) { if ((v += r.v) >= Mod()) v -= Mod(); return *this; }
  M& operator-=(M r) { if ((v += Mod() - r.v) >= Mod()) v -= Mod(); return *this; }
  M& operator*=(M r) { v = (uint64_t)v * r.v % Mod(); return *this; }
  M& operator/=(M r) { return *this *= mdpow(r, Mod() - 2); }
  friend M operator+(M l, M r) { return l += r; }
  friend M operator-(M l, M r) { return l -= r; }
  friend M operator*(M l, M r) { return l *= r; }
  friend M operator/(M l, M r) { return l /= r; }
  friend bool operator==(M l, M r) { return l.v == r.v; }
  friend M mdpow(M b, unsigned exp) {
    Modular res(1);
    while(exp) {
      if (exp & 1) {
        res *= b;
        if ((res.v += Mod()) >= Mod()) res.v -= Mod();
      }
      b *= b;
      exp >>= 1;
    }
    return res;
  }
};

struct VarMod { static unsigned modulus; };
unsigned VarMod::modulus = 1e9 + 7;
// unsigned& md = VarMod::modulus;
using Mint = Modular<VarMod>;

const int mxn = 1e5 + 10;
Mint dp[mxn];

signed main() {
  fastio;
  unsigned n, k;
  cin >> n >> k;
  Mint res(0);
  for (int i = k; i >= 1; i--) {
    Mint b(k / i);
    b = mdpow(b, n);
    dp[i] = b;
    for (int j = 2*i; j <= k; j += i) {
      dp[i] -= dp[j];
    }
    res += (dp[i] * Mint(i));
  }
  cout << res.v << endl;
  
}


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

int main() {
	int L, R;
	cin >> L >> R;
	int m = 2019;
	if (L/2019 != R/2019) {
		m = 0;
	}	else {
		for (int i = L % 2019; i <= R % 2019; i++) {
			for (int j = i + 1; j <= R % 2019; j++) {
				m = min(m, (i * j) % 2019);
			}
		}
	}
	cout << m << endl;
}


Measured memory_bytes: 256
use std::io;
use std::cmp;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}

fn main() {
    let l = read_t_in_line::<i32>();
    let (a, b, c) = (l[0], l[1], l[2]);
    if a + b >= c {
        println!("Yes");
    }
    else{
        println!("No");
    }
}


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

int main() {
	int n,k,s;
	scanf("%d%d%d",&n,&k,&s);
	for(int i=0;i<k;i++)printf("%d ",s);
	for(int i=k;i<n;i++)printf("%d ",(s==1000000000?s-1:s+1));
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int a[1010];
void solve(int n){
  REP(i,n)cin>>a[i];
  sort(a,a+n);
  int result=1e+7;
  REP(i,n-1)
    if(result>a[i+1]-a[i])
      result=a[i+1]-a[i];
  cout<<result<<endl;
}


int main(){ _;
  int n;
  while(cin>>n,n!=0){
    solve(n);
  }
}

Measured memory_bytes: 3088
#include <iostream>
using namespace std;
int b[105], a[105];
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n - 1; i++)
	{
		cin >> b[i];
	}
	a[1] = a[2] = b[1];
	for (int i = 1; i <= n - 1; i++)
	{
		if (b[i] < max(a[i], a[i + 1]))
		{
			a[i] = b[i];
		}
		a[i + 1] = b[i];
	}
	int sum = 0;
	for (int i = 1; i <= n; i++)
	{
		sum += a[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int A,B,C,X,i,j,k,way;
    way=0;
    scanf("%d%d%d%d",&A,&B,&C,&X);
    for(i=0;i<=A;i++){
        for(j=0;j<=B;j++){
            for(k=0;k<=C;k++){
                if(500*i+100*j+50*k==X)way++;
            }
        }
    }
    printf("%d",way);
    return 0;
}

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

using namespace std;

int main(void) {
  int H, W; cin >> H >> W;
  string S[H]; for (int i = 0; i < H; i++) cin >> S[i];
  int L[H][W];

  for (int i = 0; i < H; i++) {
    int l = 0, r = 0, a = 0;

    while (r != W) {
      if (S[i][r] == '.') {
        if (a == 0) l = r;
        a++;

        if (r == W-1) {
          for (int j = l; j < r+1; j++) {
            L[i][j] = a-1;
          }
        }
      } else {
        if (a != 0) {
          for (int j = l; j < r; j++) {
            L[i][j] = a-1;
          }
        }

        a = 0;
        L[i][r] = -1; 
      }
      r++;
    }

  }

  for (int i = 0; i < W; i++) {
    int u = 0, d = 0, a = 0;

    while (d != H) {
      if (S[d][i] == '.') {
        if (a == 0) u = d;
        a++;

        if (d == H-1) {
          for (int j = u; j < d+1; j++) {
            L[j][i] += a;
          }
        }
      } else {
        if (a != 0) {
          for (int j = u; j < d; j++) {
            L[j][i] += a;
          }
        }

        a = 0;
        L[d][i] = -1; 
      }
      d++;
    }

  }

  int ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      ans = max(ans, L[i][j]);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 26844
#include <iostream>

using namespace std;

int divide(int n){
    if (n % 2 != 0) return 0;
    return 1 + divide(n / 2);
}


int main() {
    int n, ans = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        ans += divide(a);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: String,
    }
    let result: i32 = n
        .chars()
        .into_iter()
        .map(|v| v.to_string().parse::<i32>().unwrap())
        .sum();
    if result % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2400
#include <stdio.h>

int main() {
  int i, j, N, M, tmp, num, cnt = 0;

  scanf("%d %d", &N, &M);

  int food[31];
  for(i = 0; i < M; i++) {
    food[i] = 0;
  }

  for(i = 0; i < N; i++) {
    scanf("%d", &tmp);
    for(j = 0; j < tmp; j++) {
      scanf("%d", &num);
      food[num-1] += 1;
    }
  }

  for(i = 0; i < M; i++) {
    if(food[i] == N) {
      cnt++;
    }
  }
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define DIST(x1,x2, y1, y2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)))
#define DIST3D(x1,x2, y1, y2, z1, z2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)) + ((z1-z2)*(z1-z2)))
#define CLR(a) a.clear()
#define VCLR(a, n) for(int i=0; i<=n+3; i++) a[i].clear()
#define SIZE(a) a.size()
#define ERASE(a, b) memset(a, b, sizeof a)
#define PB(a, b) a.push_back(b)
#define PB2(a,i,b) a[i].push_back(b)
#define LL long long
#define ULL unsigned long long
#define DBG cout<<"I Am Here"<<endl
#define DBGA(a) cout<<a<<endl
#define DBGI(b,a) cout<<b<<' '<<a<<endl
#define DBGL(i,s,e,b) or(int i=s; i<=e; i++) cout<<b<<endl
#define INF 1e9
#define INV 1e-6
#define sll(a) scanf("%I64d", &a)
#define pll(a) printf("%I64d\n", a)
#define si(a) scanf("%d", &a)
#define pii pair<LL,LL>
#define MAX 100006
#define CASE(i) printf("Case %d: ", i);
#define CSH(i) printf("Case #%d: ", i);
#define PI acos(-1)
#define piis pair<int, string>
#define fast1 ios_base::sync_with_stdio(false);
#define fast2 cin.tie(0)
#define CHECK_BIT(var,pos) ((var & (1 << pos)) == (1 << pos))
 
 
LL MOD = 1000000007;
 
using namespace std;
 
LL bigmod(LL b, LL p, LL m)
{
    if(p==0)  return 1;
    if(p%2==0)
    {
        LL x = bigmod(b,p/2,m);
        return (x%m * x%m)%m;
    }
    else return ((b%m)*bigmod(b,p-1,m)%m)%m;
}
 
 
LL MODINVERSE(LL a)
{
    return bigmod(a, MOD-2, MOD);
}
 
int arr[29][100005];
 
int main()
{
    char str[100005];
    scanf("%s", str);
    int len = strlen(str);
 
    int one = -1, two = -1;
    bool flag = false;
    for(int i=1; i<len; i++)
    {
        if(str[i]==str[i-1]){
            one = i-1, two = i;
            flag = true;
            break;
        }
        if(i>=2){
            if(str[i]==str[i-2]){
                one = i-2, two = i;
                flag = true;
                break;
            }
        }
    }
 
    if(flag)
        printf("%d %d", one+1, two+1);
    else
        printf("-1 -1");
}

Measured memory_bytes: 384
n = int(input())
A = list(map(int, input().split()))

def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1

i = partition(A, 0, n-1)
print(' '.join(map(str, A[:i])) + ' [' + str(A[i]) + '] ' + ' '.join(map(str, A[i+1:])))

Measured memory_bytes: 18936
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for i in range(M)]
S=list(set(s))
S2=[s.count(S[i]) for i in range(len(S))]
#print(S,S2)
for i in range(len(S)):
    x=t.count(S[i])
    S2[i]-=x
if max(S2)>=0:
    print(max(S2))
else:
    print(0)

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
using namespace std;

template<typename T>
inline int gcd(T a, T b) {
	if (a > b) {
		T c = a;
		a = b;
		b = c;
	}
	if (a == 0) {
		return b;
	}
	
	return gcd(b % a, a);
}
inline int gcd_of_all(vi v) {
	int l = v.size();

	int temp = v[0];
	for (int i = 0; i < l; i++) {
		temp = gcd(temp, v[i]);
	}

	return temp;
}

vi make(vi v) {
	vi ans(v.size() - 1);
	for (int i = 0; i < v.size() - 1; i++) {
		ans[i] = v[i + 1] - v[i];
	}

	return ans;
}
int main() {
	int N, X;
	cin >> N >> X;
	vi v(N);
	rep(i, N) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	vector<int>::iterator iter;
	int index;
	iter = lower_bound(v.begin(), v.end(), X);//When X is at the beginning of the vector?
	index = distance(v.begin(), iter);
	v.insert(v.begin() + index, X);// N + (1)
	vi diff(v.size() - 1);

	diff = make(v);

	int ans = gcd_of_all(diff);
	cout << ans << endl;

}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000007;
using namespace std;

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

  for(int i = 0;i < 10;i++){
    cin >> s;
    ans += s;
  }
  cout << ans << endl;
  return 0;
}




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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}	
const int mod = 1e9+7;
int main()
{
	int x;
	cin >> x; 
	while(1){
		if(IsPrime(x)){
			cout << x << endl;
			return 0;
		}else{
			x++ ;
		}
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

ll A[80][80] = { 0 };
ll B[80][80] = { 0 };
ll num[80][80] = { 0 };
bool data[80][80][12810] = { 0 };

void solve() {
  ll H, W;
  cin >> H >> W;
  rep (h, H) rep (w, W) cin >> A[h][w];
  rep (h, H) rep (w, W) cin >> B[h][w];
  rep (h, H) rep (w, W) num[h][w] = abs(A[h][w] - B[h][w]);
  data[0][0][0] = true;
  rep (h, H) rep (w, W) rep (b, 12810) {
    if (!data[h][w][b]) continue;
    ll tmp = abs(b + num[h][w]);
    ll tmp2 = abs(b - num[h][w]);
    // cout << "tmp: " << tmp << ", tmp2: " << tmp2 << endl;
    if (h < H - 1) {
      data[h+1][w][tmp] = true;
      data[h+1][w][tmp2] = true;
    }
    if (w < W - 1) {
      data[h][w+1][tmp] = true;
      data[h][w+1][tmp2] = true;
    }
  }
  ll ans = 12810;
  rep (b, 12810) if (data[H-1][W-1][b]) {
    ans = min(ans, abs(b - num[H-1][W-1]));
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 79616
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdint>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <memory>
#include <vector>

// constexpr std::int64_t INF = 1ull << 50;
constexpr int INF = 1 << 20;

int f(int i) {
  switch (i) {
    case 1:
      return 2;
    case 7:
      return 3;
    case 4:
      return 4;
    case 2:
    case 3:
    case 5:
      return 5;
    case 6:
    case 9:
      return 6;
    case 8:
      return 7;
    default:
      return INF;
  }
}

auto main() -> int {
  int N, M;
  std::cin >> N >> M;

  std::vector<int> As(M);
  for (auto i = 0; i < M; ++i) {
    std::cin >> As[i];
  }
  std::sort(As.begin(), As.end(), std::greater<int>{});

  // dp[i][0]: i 本のマッチを使い切って何桁の数が作れるか (-1: 作れない)
  // dp[i][j]: そのとき j がいくつ作れるか
  std::vector<std::array<int, 10>> dp(N + 1);
  dp[0][0] = 0;
  dp[1][0] = -1;

  for (auto i = 2; i <= N; ++i) {
    // i - f(As[j]) 本のマッチで作れる数字の最大桁数
    int mi = 0, ma = -1, max = -1;
    for (const auto Ai : As) {
      int ti = i - f(Ai);
      if (ti < 0) continue;
      if (dp[ti][0] > max) {
        max = dp[ti][0];
        mi = ti;
        ma = Ai;
      }
    }

    if (ma != -1) {
      dp[i] = dp[mi];
      dp[i][0]++;
      dp[i][ma]++;
    } else {
      dp[i][0] = -1;
    }

    // for (auto j = 0ul; j < 10; ++j) {
    //   std::cout << j << ' ' << dp[i][j] << std::endl;
    // }
    // std::cout << "--------------------------------" << std::endl;
  }

  for (auto i = 9ul; i > 0ul; --i) {
    for (auto j = 0; j < dp[N][i]; ++j) std::cout << i;
  }
  std::cout << std::endl;
}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, int b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    cin >> n;

    int i;
    for (i = 1; i * i <= n; i++)
        ;
    i--;

    cout << i * i << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;



int main() {
  ll N, D, A;
  cin >> N >> D >> A;
  vector<P> p(N+1);
  vector<ll> v;
  ll i;
  
  priority_queue<P> q;
  for(i=0; i<N; i++) {
    ll x, h;
    cin >> x >> h;
    p[i].ft=x;
    p[i].sc=(h+A-1)/A;
  }
  p[N]=P(INF, INF);
  sort(p.begin(), p.end());
  
  vector<ll> x(N+1);
  vector<ll> h(N+1);
  for(i=0; i<=N; i++) {
    x[i]=p[i].ft;
    h[i]=p[i].sc;
  }
  
  ll k=0;
  ll cnt[MAX*2]={};
  ll ans=0;
  for(ll l=0; l<N;) {
    ll r=upper_bound(x.begin(), x.end(), x[l]+D*2)-x.begin();
    
    ll dam=h[l]-cnt[l];
    ans+=dam;
    cnt[l]+=dam;
    cnt[r]-=dam;
    
    while(l<r) {
      cnt[l+1]+=cnt[l];
      if(h[l+1]<=cnt[l+1]) {
        l++;
      }else {
        l++;
        break;
      }
    }
    
  }
  
  
  pt(ans);
  
}




















Measured memory_bytes: 8064
#import <stdio.h>

long long f(int n, long long x) {
    if (n==0) return 1;
    if (x<=1) return 0;

    long long p = 1LL<<(n+1);

    if (x<p-1) {
        return f(n-1,x-1);
    } else if (x==p-1) {
        return p/2;
    } else if (x>=2*p-3) {
        return p-1;
    } else {
        return p/2+f(n-1,x-p+1);
    }
}

int main(){
    int n;
    long long x;
    scanf("%d %lld",&n,&x);
    printf("%lld\n", f(n,x));
    return 0;
}



Measured memory_bytes: 7500
#include <stdio.h>

int factorial(int n);

int main(void)
{
    int n;

    scanf("%d", &n);

    printf("%lld\n", factorial(n));

}

int factorial(int n)
{
    int i;
    long long int fac;

    fac = 1;
    for (i = 2; i <= n; i++){
        fac *= i;
    }

    return (fac);
}



Measured memory_bytes: 2044
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  int l = 0;
  ll ans = 0;
  ll sum = 0;
  for(int r=0; r<N; r++){
    while(l<r){
      bool can = true;
      for(ll i=0; i<=20; i++){
        if(sum&(1LL<<i) && A[r]&(1LL<<i)){
          can = false;
        }
      }
      if(can){
        break;
      }
      // cout << "check:" << r << endl;
      // bitset<10> su(sum);
      // bitset<10> s(A[r]);
      // cout << s << endl;
      // cout << su << endl;
      sum -= A[l];
      l++;
    }
    sum += A[r];
    ans += (r-l+1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

void vecscl(double c, const double v0[2], double v1[2])
{
    v1[0] = v0[0] * c;
    v1[1] = v0[1] * c;
}

void vecadd(const double v0[2], const double v1[2], double v2[2])
{
    v2[0] = v0[0] + v1[0];
    v2[1] = v0[1] + v1[1];
}

void vecsub(const double v0[2], const double v1[2], double v2[2])
{
    v2[0] = v0[0] - v1[0];
    v2[1] = v0[1] - v1[1];
}

double vecprd(const double v0[2], const double v1[2])
{
    return v0[0] * v1[1] - v0[1] * v1[0];
}

double vecsum(const double v0[2], const double v1[2])
{
    return v0[0] * v1[0] + v0[1] * v1[1];
}

double veclen(const double v[2])
{
    return sqrt(v[0] * v[0] + v[1] * v[1]);
}

bool vecnrm(double eps, const double v0[2], double v1[2])
{
    double len = veclen(v0);
    if (len < eps) {
        return false;
    }
    vecscl(1 / len, v0, v1);
    return true;
}

const double eps = 1e-12;

void solve()
{
    int x0, y0, x1, y1;
    scanf("%d%d%d%d", &x0, &y0, &x1, &y1);
    double p0[2] = { (double)x0, (double)y0 };
    double p1[2] = { (double)x1, (double)y1 };
    double v01[2];
    vecsub(p1, p0, v01);

    int Q;
    scanf("%d", &Q);
    int t;
    for (t = 0; t < Q; t++) {
        int x, y;
        scanf("%d%d", &x, &y);
        double v[2] = { (double)x, (double)y };
        double v02[2];
        vecsub(v, p0, v02);

        double tmp=vecprd(v01, v02);
        if (tmp > eps) {
            printf("COUNTER_CLOCKWISE\n");
        }
        else if (tmp < -eps) {
            printf("CLOCKWISE\n");
        }
        else {
            double tmp2 = vecsum(v01, v02);
            if (tmp2 < -eps) {
                printf("ONLINE_BACK\n");
            }
            else {
                double v12[2];
                vecsub(v, p1, v12);
                double tmp3 = vecsum(v01, v12);
                if (tmp3 > eps) {
                    printf("ONLINE_FRONT\n");
                }
                else {
                    printf("ON_SEGMENT\n");
                }
            }
        }
    }

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



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

#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define forup(i,l,r) for (register int i = l ; i <= r ; i += lowbit(i))
#define fordown(i,id) for (register int i = id ; i ; i -= lowbit(i))
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define lowbit(x) (x&(-x))

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pr;

const ld inf = 2e18;
const int N = 3e6 + 10;
const int maxn = 4000020;
const ll mod = 1e9 + 7;

inline ll power(ll x,ll y){
	if ( y < 0 ) return 1;
	ll res = 1;
	while ( y ){
		if ( y & 1 ) res = res * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int n,T,a[maxn],mx,mn,k,cnt[maxn];
ll fac[maxn],inv[maxn],f[2020][2020];

void init(){
	fac[0] = inv[0] = 1;
	int tmp = n * k;
	rep(i,1,tmp) fac[i] = fac[i - 1] * i % mod;
	inv[tmp] = power(fac[tmp],mod - 2);
	repd(i,tmp - 1,1) inv[i] = inv[i + 1] * (i + 1) % mod;
}

inline void up(ll &x,ll y){ x = (x + y) % mod; }
inline ll C(int n,int m){
	if ( n < 0 || m < 0 || n < m ) return 0;
	return fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int main(){
	cin>>n>>k;
	init();
	f[0][0] = 1;
	if ( k == 1 ){ printf("1\n"); return 0; }
	rep(i,0,n){
		rep(j,0,i){
			if ( !f[i][j] ) continue;
			if ( i > j ) up(f[i][j + 1],f[i][j] * C(n * k - i - j * (k - 1) - 1,k - 2) % mod * C(n - j,1));
			up(f[i + 1][j],f[i][j]);
		}
	}
	cout<<f[n][n]<<endl;
}



Measured memory_bytes: 97024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		int ac = Math.abs(c-a);
		int ab=Math.abs(b-a);
		int bc = Math.abs(c-b);
		if(ac<=d) {
			System.out.println("Yes");
		}else if(ab<=d && bc<=d) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define MAX_V 100010

using namespace std;

typedef pair<int,int> ii;
typedef vector<ii>   vii;
typedef vector<int>   vi;
const int DFS_WHITE = -1; // unvisited
const int DFS_BLACK =  1; // visited

int V,E;
int dfsNumberCounter,rootChildren,dfsRoot;
vi dfs_num,dfs_low,dfs_parent,articulation_vertex;
vii AdjList[MAX_V];// ii(neighbor,weight)

vii ans;

void articulationPointAndBridge(int u)
{
  dfs_low[u] = dfs_num[u] = dfsNumberCounter++;
  for(int j=0;j<(int)AdjList[u].size();j++)
    {
      ii v = AdjList[u][j];
      if(dfs_num[v.first] == DFS_WHITE)
	{
	  dfs_parent[v.first] = u;
	  if(u == dfsRoot)rootChildren++;

	  articulationPointAndBridge(v.first);

	  if(dfs_low[v.first] >= dfs_num[u])
	    articulation_vertex[u] = true;
	  if(dfs_low[v.first] >  dfs_num[u])
	    ans.push_back(ii(min(u,v.first),max(u,v.first)));
	    //printf("Edge (%d,%d) is a bridge\n",u,v.first);
	  dfs_low[u] = min(dfs_low[u],dfs_low[v.first]);

	}
      else if(v.first != dfs_parent[u])
	dfs_low[u] = min(dfs_low[u],dfs_num[v.first]);
    }
}

void compute()
{
  dfsNumberCounter = 0; dfs_num.assign(V,DFS_WHITE); dfs_low.assign(V,0);
  dfs_parent.assign(V,0); articulation_vertex.assign(V,0);
  //puts("Bridges:");
  for(int i = 0; i < V; i++)
    if(dfs_num[i] == DFS_WHITE)
      {
	dfsRoot = i; rootChildren = 0;
	articulationPointAndBridge(i);
	articulation_vertex[dfsRoot] = (rootChildren > 1);// special case
      }
  //puts("Articulation Points");
  //for(int i = 0; i < V; i++)
  //if(articulation_vertex[i])
      //printf("Vertex %d\n",i);
}

int main()
{
  scanf("%d%d",&V,&E);
  rep(i,V)AdjList[i].clear();
  rep(i,E)
    {
      int s,t;
      scanf("%d%d",&s,&t);
      AdjList[s].push_back(ii(t,1));
      AdjList[t].push_back(ii(s,1));
    }

  ans.clear();
  compute();
  sort(ans.begin(),ans.end());
  ans.erase(unique(ans.begin(),ans.end()),ans.end());
  rep(i,ans.size())cout << ans[i].first << " " << ans[i].second << endl;

  return 0;
}

Measured memory_bytes: 6064
count = int(raw_input())
total = 0.0
for i in range(count):
    otoshidama = raw_input().split(' ')
    if otoshidama[1] == 'JPY':
        total += int(otoshidama[0])
    else:
        total += float(otoshidama[0]) * 380000
print(total)

Measured memory_bytes: 2568
#include <iostream>
#include <string>

using ll = long long;
using std::cout;
using std::cin;
using std::endl;

int main(){
    ll n;
    cin >> n;
    std::string s;
    ll c0=0,c1=0,c2=0,c3=0; 
    for(ll i=0; i<n; i++){
        cin >> s;
        if(s == "AC"){
            c0++;
        }else if(s == "WA"){
            c1++;
        }else if(s == "TLE"){
            c2++;
        }else if(s == "RE"){
            c3++;
        }
    }
    cout << "AC x " << c0 << endl;
    cout << "WA x " << c1 << endl;
    cout << "TLE x " << c2 << endl;
    cout << "RE x " << c3 << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
    int b[4][4], N, t;
    for (int i = 1; i <= 3; i++)
        for (int j = 1; j <= 3; j++)
            cin >> b[i][j];
    cin >> N;
    while (N--)
    {
        cin >> t;
        for (int i = 1; i <= 3; i++)
            for (int j = 1; j <= 3; j++)
                if (b[i][j] == t)
                    b[i][j] = -1;
    }
    for (int i = 1; i <= 3; i++)
    {
        if (b[i][1] == b[i][2] && b[i][2] == b[i][3])
        {
            printf("Yes");
            return 0;
        }
    }
    for (int i = 1; i <= 3; i++)
    {
        if (b[1][i] == b[2][i] && b[2][i] == b[3][i])
        {
            printf("Yes");
            return 0;
        }
    }
    if (b[1][1] == b[2][2] && b[2][2] == b[3][3])
    {
        printf("Yes");
        return 0;
    }
    if (b[1][3] == b[2][2] && b[2][2] == b[3][1])
    {
        printf("Yes");
        return 0;
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 256