akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

// 最大公約数
int gcd(int a, int b)
{
    if(a%b == 0){
        return(b);
    }
    else{
        return(gcd(b, a%b));
    }
}

int main(void)
{
    ll N, X, x[100001], d[100001], i, ans;

    cin >> N >> X;

    for(i=1; i<=N; i++){
        cin >> x[i];

        d[i] = abs(x[i]-X);
    }

    if(N == 1){
        cout << d[1] << endl;
    }

    else{
        ans = gcd(d[1], d[2]);

        if(N>=3){
            for(i=3; i<=N; i++){
                ans = gcd(ans, d[i]);
            }
        }

        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	string S;
	cin >> S;
	int maxcd = C;
	if (D > C) maxcd = D;
	for (int i = A - 1; i < maxcd; i++) {
		if (S[i] == '#') {
			if (S[i + 1] == '#') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	int rcnt = 0;
	if (maxcd == D) {
		cout << "Yes" << endl;
		return 0;
	}
	else {
		for (int i = B - 2; i < D+1; i++) {
			if (S[i] == '.') rcnt++;
			else rcnt = 0;
			if (rcnt > 2) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 644
// Problem : B - ... (Triple Dots)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int k;
    string s;
    cin >> k >> s;
    
    if (s.length() <= k)
        cout << s << "\n";
    else
        cout << s.substr(0, k) << "...\n";

    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

string s[10];

int cnt[10][10];

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

bool check() {
	bool f[3] = {};
	REP(i, 8) {
		if (s[i].find('o') != -1)f[0] = 1;
		if (s[i].find('x') != -1)f[1] = 1;
		if (s[i].find('.') != -1)f[2] = 1;
	}
	return f[0] && f[1] && f[2];
}

int count(int y, int x, int d, bool t) {
	int res = 0;
	bool f = 0;
	x += dx[d];
	y += dy[d];
	while (x >= 0 && x < 8 && y >= 0 && y < 8) {
		if (s[y][x] == (t ? 'o' : 'x')) {
			f = 1;
			break;
		}
		else {
			if (t) {
				if (s[y][x] == 'x')res++;
				else break;
			}
			else {
				if (s[y][x] == 'o')res++;
				else break;
			}
		}
		x += dx[d];
		y += dy[d];
	}
	if (f)return res;
	return 0;
}

void print() {
	REP(i, 8) {
		REP(j, 8) {
			cout << s[i][j];
		}
		cout << endl;
	}
}

int main() {
	REP(i, 8)cin >> s[i];
	bool f = 1;
	int err = 0;
	while (1) {
		REP(i, 10)REP(j, 10)cnt[i][j] = 0;
		if (!check())break;
		int ma = 0;
		P pos = { -1,-1 };
		REP(i, 8) {
			REP(j, 8) {
				int ny, nx;
				if (f)ny = i, nx = j;
				else ny = 7 - i, nx = 7 - j;
				if (s[ny][nx] == '.') {
					int w = 0;
					REP(k, 8)w += count(ny, nx, k, f);
					if (ma < w) {
						ma = w;
						pos = { ny,nx };
					}
				}
			}
		}
		if (ma != 0) {
			err = 0;
			REP(i, 8) {
				int y = pos.first, x = pos.second;
				int w = count(y, x, i, f);
				REP(j, w + 1) {
					int ny = pos.first + dy[i] * j,
						nx = pos.second + dx[i] * j;
					//cout << "!" << ny << " " << nx << endl;
					if (f)s[ny][nx] = 'o';
					else s[ny][nx] = 'x';
				}
			}
		}
		else err++;
		if (err >= 2)break;
		//print();
		//cout << endl;
		f = !f;
	}
	print();
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

int n, l[100];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> l[i];
	sort(l, l + n);
	int ans = 0;
	for(int i = 0; i < n - 2; i++)
		for(int j = i + 1; j < n - 1; j++)
			if(l[i] != l[j])
				for(int k = j + 1; k < n; k++)
					if(l[k] != l[i] && l[k] != l[j]){
						bool work = l[k] < l[i] + l[j] && l[k] > l[j] - l[i];
						work |= l[j] > l[k] - l[i];
						work |= l[i] > l[k] - l[i];
						ans += work;
					}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3620
# @author 

import sys

class DRedistribution:
    def solve(self, tc=0):
        MOD = 10 ** 9 + 7
        s = int(input())
        ans = 0

        N = 2000
        C = [[0] * (N + 1) for _ in range(N + 1)]
        C[0][0] = 1
        for j in range(1, N + 1):
            C[j][0] = 1
            for i in range(1, j + 1):
                C[j][i] = (C[j - 1][i] + C[j - 1][i - 1]) % MOD

        for n in range(1, s // 3 + 1):
            ans += C[s - 3 * n + n - 1][n - 1]
            ans %= MOD

        print(ans)


solver = DRedistribution()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 113072
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int n;
double dp[3000][3000];
double p[3000];

signed main(){
    cin >> n;
    rep(i, 0, n) cin >> p[i];
    dp[0][0] = 1.0;
    rep(i, 0, n){
        rep(j, 0, n){
            dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
            dp[i + 1][j + 1] += dp[i][j] * p[i];
        }
    }
    double ans = 0.0;
    rep(i, n / 2 + 1, n + 1) ans += dp[n][i];
    printf("%.10f\n", ans);
}

Measured memory_bytes: 70528
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265359

using namespace std;

/*ll powMod(ll a, ll y)
{
    ll ans = 1;
    
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % MOD; 
  
        y = y>>1;
        a = (a*a) % MOD; 
    } 
    return ans;
}*/

/*ll modInv(ll a)
{
    return powMod(a, MOD-2);	
}*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int d, t, s;
    cin >> d >> t >> s;
    if (d/s + (d%s==0 ? 0 : 1) <= t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}




Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll X, Y; cin >> X >> Y;
	if (abs(X - Y) <= 1)cout << "Brown" << endl;
	else cout << "Alice" << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n;
    cin >> n;
    vector<pair<string, int> > v(n);
    long long ans = 0;
    string x;
    bool f = 0;
    for (int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
    }
    cin >> x;
    for (int i = 0; i < n; i++) {
        if (f) {
            ans += v[i].second;
        }
        if (v[i].first == x) f = 1;
        
    }
    cout << ans << endl;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define MIN -1000000000000000

int main()
{
	int n;cin>>n;
	vector<int> a(n);
	int i,j,k;
	rep(i,n) cin>>a[i];
	vector<vector<ll>> dp(n+1,vector<ll>(3,MIN));
	rep(i,3) dp[0][i]=0;
	rep(j,3)
	{
		for(i=j+1;i<=n;i++)
		{
			if(i==j+1) dp[i][j]=a[i-1];
			else if((i-j-1)%2==0)
			{
				rep(k,j+1)
				{
					dp[i][j]=max(dp[i][j],dp[i-(2+j-k)][k]);
				}
				dp[i][j]+=a[i-1];
			}
			else dp[i][j]=dp[i-1][j];
		}
	}
	dp[n][0]=dp[n-1][0];
	ll ans=MIN;
	rep(i,2+n%2)ans=max(ans,dp[n][i]);
	cout<<ans<<endl;
}


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

const int MN = 3030;
int n;
V<ll> a;
ll dp[MN][MN];
bool vis[MN][MN];
ll solve(int l, int r) {
    if (r + 1 == l) return 0;
    if (vis[l][r]) return dp[l][r];
    vis[l][r] = true;
    ll ans = max(a[l] - solve(l + 1, r), a[r] - solve(l, r - 1));
    return dp[l][r] = ans;
}

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

    cin >> n;
    a = V<ll>(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    cout << solve(0, n-1) << endl;
    return 0;
}


Measured memory_bytes: 80384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	ll n;cin>>n;
	ll a[n];rep(i,0,n)cin>>a[i];
	sort(a,a+n);
	ll val=a[n-1]/2;
	if(a[n-1]&1)val++;
	ll mn=inf,ans;
	rep(i,0,n-1){
		if(abs(a[i]-val)<mn){
			mn=abs(a[i]-val);
			ans=a[i];
		}
	}
	cout<<a[n-1]<<" "<<ans;
	
	return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    long long int ans = 0;
    int nowmin = n+5;
    for(int i = 0; i < n; i++){
        int p;
        cin >> p;
        if (nowmin >= p)ans++;
        nowmin = min(nowmin, p);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    
    vector<int> a((1<<n)+1);
    int i;
    for(i=0; i<(1<<n); i++) {
        scanf("%d", &a[i]);
    }
    a[1<<n]=INF;
    sort(a.rbegin(), a.rend());

    set<pair<int,int> > work;    // level, id
    queue<pair<int,int> > que;
    work.insert(make_pair(n,0));
    int curr=1;
    while( 1 ) {
        while(!que.empty()) {
            auto tmp=que.front();
            if(a[tmp.second]>a[curr]) {
                work.insert(tmp);
                que.pop();
            }
            else break;
        }
        if(work.empty()) {
            break;
        }

        auto it=work.rbegin();
        int tmp=it->first;
        int id=it->second;
        work.erase(*it);

        if(a[curr]==a[id]) {
            printf("No\n"); return 0;
        }
        for(i=tmp-1; i>=0; i--) {
            que.push(make_pair(i,curr));            
        }
        curr++;
    }
    if(curr<(1<<n)+1) {
        printf("No\n"); return 0;
    }
    printf("Yes\n");

    return 0;
}


Measured memory_bytes: 7424
n,m = map(int,input().split())
s = [[] for _ in range(n+1)]
for i in range(m):
    p,y = map(int,input().split())
    s[p].append([y,i])
ans = [0]*m
for p in range(1,n+1):
    cnt = 1
    for (y,i) in sorted(s[p]):
        ans[i] = '{:06}{:06}'.format(p,cnt)
        cnt += 1
for j in range(len(ans)):
    print(ans[j])

Measured memory_bytes: 39088
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}
vector<uint64_t> Nums(10);
typedef struct {
  uint64_t id_Nums[10];
} Num_Array;

int main() {
  uint64_t N;
  string S;
  cin >> N >> S;
  vector<Num_Array> All_Nums(N);
  for (uint64_t i = 0; i < N; ++i) {
    Nums[S[i] - '0']++;
    for (uint32_t j = 0; j < 10; ++j) {
      All_Nums[i].id_Nums[j] = Nums[j];
    }
  }
  set<uint64_t> res;
  vector<uint64_t> tmp(10);
  vector<uint32_t> Achieved(10);
  for (uint64_t i = 0; i < (N - 2); ++i) {
    for (uint64_t k = 0; k < 10; ++k) {
      tmp[k] = Nums[k] - All_Nums[i].id_Nums[k];
      Achieved[k] = 0;
    }
    uint64_t PIN = (S[i] - '0') * 100;
    for (uint64_t j = i + 1; j < (N - 1); ++j) {
      tmp[S[j] - '0']--;
      if (Achieved[S[j] - '0']) continue;
      Achieved[S[j] - '0'] = 1;
      PIN += (S[j] - '0') * 10;
      for (uint64_t k = 0; k < 10; ++k) {
        if ((Nums[k] - All_Nums[j].id_Nums[k]) != 0) {
          res.insert(PIN + k);
        }
      }
      PIN -= (S[j] - '0') * 10;
    }
  }
  cout << res.size() << endl;
  return 0;
}


Measured memory_bytes: 2816
#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

const double PI = acos(-1);
constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class Task{
public:
    void solve(istream& in, ostream& out){
        int X, Y, Z, K;
        in>>X>>Y>>Z>>K;
        vc<lint> A(X), B(Y), C(Z);
        for(auto& a : A) in>>a;
        for(auto& b : B) in>>b;
        for(auto& c : C) in>>c;
        sort(RALL(A));
        sort(RALL(B));
        sort(RALL(C));
        auto check = [&](lint x){
            int cnt = 0;
            REP(i, X){
                REP(j, Y){
                    REP(k, Z){
                        if(A[i]+B[j]+C[k]<x) break;
                        ++cnt;
                        if(cnt>=K) return true;
                    }
                }
            }
            return false;
        };
        lint left = 0, right = 3 * ten(10) + 1;
        while(1<right-left){
            lint mid = (left+right) >> 1;
            if(check(mid)) left = mid;
            else right = mid;
        }
        vc<lint> res;
        REP(i, X){
            REP(j, Y){
                REP(k, Z){
                    if(A[i]+B[j]+C[k]<=left) break;
                    res.push_back(A[i]+B[j]+C[k]);
                }
            }
        }
        sort(RALL(res));
        while(LEN(res)<K) res.push_back(left);
        for(auto& r : res) out<<r<<'\n';
    }
};

int main(){
    istream& in(cin);
    ostream& out(cout);
    ios_base::sync_with_stdio(false);
    in.tie(nullptr), out.tie(nullptr);
    Task solver;
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin >> a >> b >> k;
  for(int i=100;i>0;i--){
    if(a%i==0&&b%i==0)k--;
    if(k==0){
      cout << i;
      return 0;
    }
  }
}


Measured memory_bytes: 256
import java.util.*;

class Pair{
    int A,B,C;
    Pair(int A,int B,int C){
        this.A = A;
        this.B = B;
        this.C = C;
    }
}

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Pair> list = new ArrayList<Pair>();
        while(true){
            int A=sc.nextInt(),B=sc.nextInt(),C=sc.nextInt();
            if(A==-1&&B==-1&&C==-1){
                break;
            }
            Pair p = new Pair(A,B,C);
            list.add(p);
        }
        for(int i=0;i<list.size();i++){
            Pair p = list.get(i);
            if(p.A==-1||p.B==-1){
                System.out.println("F");
            }else if(p.A + p.B>=80){
                System.out.println("A");
            }else if(p.A + p.B>=65 && p.A + p.B < 80){
                System.out.println("B");
            }else if(p.A + p.B>=50 && p.A + p.B < 65){
                System.out.println("C");
            }else if(p.A + p.B>=30 && p.A + p.B < 50){
                if(p.C >= 50){
                    System.out.println("C");
                }else{
                    System.out.println("D");
                }
            }else{
                System.out.println("F");
            }
        }
    }
}



Measured memory_bytes: 26408
#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>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}

#define ll long long
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=5e5+500;
const ll inf=1e17+800;
const ll mod=1e9+7;

void jam(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
ll zarb(ll a,ll b){return (a*b)%mod;}

vector<ll> ger[maxn];
ll a[maxn];
ll b[maxn];
ll w[maxn];

ll minn[2][maxn];
ll dp[2][maxn];
ll dpyal[maxn];
ll dpp[maxn];

ll n,m;

void fillyal(ll s,ll t,ll fas){
	for(ll i=0;i<m;i++){
		if(minn[0][b[i]]+w[i]+minn[1][a[i]]==fas){
			swap(a[i],b[i]);
		}
		if(minn[0][a[i]]+w[i]+minn[1][b[i]]==fas && fas<minn[0][b[i]]*2 && minn[0][a[i]]*2<fas){
			dpyal[i]=zarb(dp[0][a[i]],dp[1][b[i]]);
		}
	}
}
void filldp(ll s,bool bo){
	dp[bo][s]=1;
	vector<pii> vec;
	for(ll i=1;i<=n;i++){
		vec.pb(mp(minn[bo][i],i));
	}
	sort(vec.begin(),vec.end());
	for(auto q:vec){
		ll v=q.S;
		for(auto e:ger[v]){
			if(minn[bo][v]==w[e]+minn[bo][a[e]^b[e]^v]){
				jam(dp[bo][v],dp[bo][a[e]^b[e]^v]);
			}
		}
	}
}
void diks(ll s,bool bo){
	for(ll i=0;i<maxn;i++)minn[bo][i]=inf;
	set<pii> st;
	st.insert(mp(0,s));
	while(st.size()){
		pii q=(*st.begin());
		st.erase(q);
		ll v=q.S;
		ll W=q.F;
		if(minn[bo][v]==inf){
			minn[bo][v]=W;
			for(auto e:ger[v]){
				st.insert(mp(W+w[e],a[e]^b[e]^v));
			}
		}
	}
}
int main(){
	ll s,t;
	cin>>n>>m>>s>>t;
	for(ll i=0;i<m;i++){
		cin>>a[i]>>b[i]>>w[i];
		ger[a[i]].pb(i);
		ger[b[i]].pb(i);
	}
	diks(s,0);
	diks(t,1);
	ll fas=minn[0][t];
	filldp(s,0);
	filldp(t,1);
	fillyal(s,t,fas);


	ll sum=dp[0][t];
	for(ll i=1;i<=n;i++){
		if(minn[0][i]+minn[1][i]==fas && minn[0][i]==minn[1][i]){
			dpp[i]=zarb(dp[0][i],dp[1][i]);
		}
	}
	ll ans=0;
	for(ll i=1;i<=n;i++){
		if(minn[0][i]+minn[1][i]==fas && minn[0][i]==minn[1][i]){
			jam(ans,zarb((sum-dpp[i]+mod)%mod,dpp[i]));
		}
	}
	for(ll i=0;i<m;i++){
		jam(ans,zarb(dpyal[i],(sum-dpyal[i]+mod)%mod));
	}
	cout<<ans;


}




















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

//mod逆元を使ったnCkの計算(速)
const int64_t MAX = 510000;
const int64_t MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
int64_t COM(int64_t n, int64_t k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {

    // input from txt （提出時にこの箇所は削除すること）
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    
    int64_t N, M;
    cin >> N >> M;
    COMinit();
    
    int64_t n = M;
    
    //素因数分解
    map<int64_t,int64_t> mp;
    int a = 2;
    while(n >= a*a){
      if(n %a == 0){
        if(mp.count(a)){
          mp[a]++;
        }
        else{
          mp[a] = 1;
        }
        n /= a;
      }
      else{
        a++;
      }
    }
    if(mp.count(n)){
      mp[n]++;
    }
    else{
      mp[n] = 1;
    }
    
    int64_t ans = 1;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        int64_t x = itr->second;
        //cout << x << endl;
        ans *= COM(x+N-1,N-1);
        ans %= MOD;
    }
    if(M == 1){
        ans = 1;
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 12288
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),d=sc.nextInt();
		System.out.println(a*b-a*d-b*c+c*d);
	}
}


Measured memory_bytes: 22740
import collections
class UnionFind:
    def __init__(self,n):
        super().__init__()
        self.par = [-1]*n
        self.rank = [0]*n
        self.tsize = [1]*n

    
    def root(self,x):
        if self.par[x] == -1:
            return x 
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x_r = self.root(x)
        y_r = self.root(y)
        
        if self.rank[x_r]>self.rank[y_r]:
            self.par[y_r] = x_r

        elif self.rank[x_r]<self.rank[y_r]:
            self.par[x_r] = y_r

        elif x_r != y_r:
            self.par[y_r] = x_r
            self.rank[x_r] += 1

        if x_r != y_r:
            size = self.tsize[x_r]+self.tsize[y_r]
            self.tsize[x_r] = size
            self.tsize[y_r] = size

    def isSame(self,x,y):
        return self.root(x) == self.root(y)

    def size(self,x):
        return self.tsize[self.root(x)]

def main():
    n,k,l = tuple([int(t)for t in input().split()])

    uf_k = UnionFind(n)
    uf_l = UnionFind(n)


    pq = [[int(t)-1 for t in input().split()]for _ in [0]*k]
    for p,q in pq:
        uf_k.unite(p,q)

    rs = [[int(t)-1 for t in input().split()]for _ in [0]*l]
    for r,s in rs:
        uf_l.unite(r,s)

    pair = []
    for i in range(n):
        pair.append((uf_k.root(i),uf_l.root(i)))
    counter = collections.Counter(pair)
    
    ans = []
    for a in pair:
        ans.append(counter[a])
    print(*ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 85404
import copy
import sys
import math

def main():
	n = int(input())
	a = list(map(int,input().split()))
	a.sort()
	xor = a[0] ^ a[1]
	for i in range(2,n):
		xor = xor ^ a[i]
	if(xor == 0):
		print('Yes')
	else:
		print('No')


def listtodict(a):
	b = {}
	for i in a:
		try:
			b[i] += 1
		except:
			b[i] = 1
	return b

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()

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

int main() {
    int N;
	cin >> N;
	char S[N][N];
	for (int i = 0; i < N; i++) {
	    for (int j = 0; j < N; j++) {
		    cin >> S[i][j];
		}
	}
	int s = 0;
	for (int i = 0; i <  N; i++) {
	    int A = i;
	    int B = 0;
	    bool good = true;

	    for (int j = 0; j < N; j++) {
	        int JA;
	        if (j + A - B < N) JA = j + A - B; else JA = j + A - B - N;
	        for (int k = 0; k < N; k++) {
	            int KB;
	            if (k + B - A < 0) KB = k + B - A + N; else KB = k + B - A;
	            if (S[j][k] != S[KB][JA]) {
	                good = false;
	            }
	        }
	    }
	    if (good) {
	        s += N;
	    }
	}

	cout << s << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    long long a,b,c=1;
    cin>>a>>b;
    for(int i=0;i<a;i++){
        if(i==0){
            c*=b;
        }else
        c*=b-1;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
LL n,a,d;
pair<LL,LL> each[200000+1]; 
LL res=0;
LL A[200000+1];
int main(){
	fastio;
	cin>>n>>d>>a;
	d<<=1;
	rb(i,1,n)
		cin>>each[i].FIR>>each[i].SEC;
	sort(each+1,each+1+n);
	LL tmp=0;
	rb(i,1,n){
//		cout<<tmp<<endl;
		each[i].SEC-=tmp;
		if(each[i].SEC>0){
			LL need=(each[i].SEC+a-1)/a;
			tmp+=need*a;
			res+=need;
			int l=i,r=n+1;
			while(l<r-1){
				int mid=(l+r)>>1;
				if(each[i].FIR+d>=each[mid].FIR){
					l=mid;
				}
				else{
					r=mid;
				}
			}
//			cout<<each[i].FIR+d<<endl;
//			cout<<l<<endl;
			A[l]+=need*a;
		}
		tmp-=A[i];
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 4992
N = int(input())
A = list(map(int, input().split()))
f = 0

if 0 in A:
    print("0")
    f = 1
else:

    ans = A[0]
    for i in range(1, N):
        ans = ans * A[i]
        if ans > 10**18:
            print("-1")
            f = 1
            break

if f == 0:
    print(ans)

Measured memory_bytes: 21556
#include <iostream>

int main() {
  std::string S;
  std::cin >> S;
  if(S[0] == S[1] && S[1] == S[2]){
    std::cout << "No" << std::endl;
  }else{
    std::cout << "Yes" << std::endl;
  }
  return 0;
}


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

int main() {
	int m,d;
	cin >> m >> d;
	
	while(m!=0 && d!=0){
		int days=0;
		days+=d;
		
		if(m==2)days+=31;
		else if(m==3)days+=60;
		else if(m==4)days+=91;
		else if(m==5)days+=121;
		else if(m==6)days+=152;
		else if(m==7)days+=182;
		else if(m==8)days+=213;
		else if(m==9)days+=244;
		else if(m==10)days+=274;
		else if(m==11)days+=305;
		else if(m==12)days+=335;
		
		days %= 7;
		
		switch(days){
		case 1: cout << "Thursday";break;
		case 2: cout << "Friday" ;break;
		case 3: cout << "Saturday";break;
		case 4: cout << "Sunday";break;
		case 5: cout<<"Monday";break;
		case 6: cout <<"Tuesday";break;
		case 0: cout <<"Wednesday";break;
		
		}
		cout << endl;
		
		cin >> m >> d;
	}
	return 0;
}

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

using namespace std;

bool cmp(int a,int b) {
    return a>b;
}
int x[100010];

int main() {
//    freopen("in","r",stdin);
    int n;
    cin>>n;
    for(int i=1; i<=n; i++) {
        scanf("%d",&x[i]);
    }
    sort(x+1,x+1+n,cmp);
    int i;
    for(i=1; i<=n; i++) {
        if(i+1>x[i+1])break;
    }
    int sg=0;
    for(int j=1+i; x[j]==i; j++)
        sg^=1;
    sg|=(x[i]-i)&1;
    if(sg)
        cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;

    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

long n;
std::string s;

long ans = 1;

const long MOD = 1000000007;

long alp[26];

int main(){
	scanf("%ld", &n);
	std::cin >> s;
	for(int i = 0; i < n; i++){
		alp[s[i] - 'a']++;
		alp[s[i] - 'a'] %= MOD;
	}
	for(int i = 0; i < 26; i++){
		ans *= (alp[i]+1);
		ans %= MOD;
	}
	printf("%ld\n", ans-1);
	return 0;
}


Measured memory_bytes: 512
import java.util.*;

import com.sun.org.apache.bcel.internal.classfile.Code;

import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        String[] split = str.split("");
        int c = 0;

        for(int i = 0; i < 3; i++){
            if(split[i].equals(split[i+1])){
                //System.out.println(split[i]+split[i+1]);
                c++;
            }else{
                //System.out.println("Good");
            }
        }

        if(c == 0){
            System.out.println("Good");
        }else{
            System.out.println("Bad");
        }
        
    }
}


Measured memory_bytes: 22100
#include <limits>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <bitset>
#include <map>
#include <unordered_map>
#include <cstdint>
using namespace std;

const vector<int> units = {59049,46656,7776,6561,1296,729,216,81,36,9,6,1};
const int inf = 999999999;

int minChange(const vector<int>& value, int n){
  vector<int> dp(n + 1, inf);
  dp[0] = 0;

  for(int i = 0; i <= n; ++i){
    for(int j = 0; j < value.size(); ++j){
      if(i - value[j] >= 0){
        dp[i] = min(dp[i - value[j]] + 1, dp[i]);
      }
    }
  }

  return dp[n];
}

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

    cout << minChange(units, n) << '\n';

    return 0;
}


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

int d[100000];
int f(int x, vector<vector<int>> &v){
  if(d[x] != 0) return d[x];
  if(v[x].size() == 0) return 0;
  int ans = 0;
  for(int a: v[x]){
    ans = max(ans, f(a, v)+1);
  }
  return d[x] = ans;
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> v(n);
  int a, b;
  for(int i=0; i<m; ++i){
    cin >> a >> b;
    --a; --b;
    v[a].push_back(b);
  }
  int ans = 0;
  for(int i=0; i<n; ++i){
    ans = max(ans, f(i, v));
  }
  cout << ans << endl;
}

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

int main(){
  long K, N;
  cin >> K >> N;
  vector<long> A;
  for(int i = 0; i < N; i++){
    long tmp;
    cin >> tmp;
    A.push_back(tmp);
  }
  
  vector<long> diff;
  long tmpans = 0;
  for(int i = 0; i < N-1; i++){
    long tmp = A[i+1] - A[i];
    if(tmp > tmpans){
      tmpans = tmp;
    }
  }
  if(K - A[N-1] + A[0] > tmpans){
    tmpans = K - A[N-1] + A[0];
  }
  
  cout << K - tmpans << endl;
  
  
}


Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#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;

int calc(int a,int b){
  if(b == 0) return 1;
  if(b%2 == 0){
    int d = calc(a,b/2);
    return (d*d)%MOD;
  }
  return (a*calc(a,b-1))%MOD;
}

int comb(int n,int r){
  int tmp = 1,ttmp = 1;
  for(int i = n;i >= n-r+1;i--) tmp = (tmp*i)%MOD;
  for(int i = 1;i <= r;i++) ttmp = (ttmp*i)%MOD;
  return (tmp*calc(ttmp,MOD-2))%MOD;
}

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

  cout << ((comb(c+1+d+1, d+1)-comb(c+1+b, b)-comb(d+1+a, a)+comb(a+b, b))%MOD+MOD)%MOD << "\n";

  return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		 Scanner sc=new Scanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
  //      pw=new PrintWriter("C:\\Users\\Hp\\Desktop\\outt.txt");
        int n=sc.nextInt();
        int k=sc.nextInt();
        int cnt=0;
        while(n!=0) {
        	cnt++;
        	n/=k;
        }
        pw.println(cnt);
        pw.close();
    }

    public static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException, IOException {
            return br.ready();
        }

    }
}

Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define ll long long int 
#define pii pair<int, int>
#define fi first
#define se second
#define maxn 219
#define maxr 100000
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define gc() ((p1 == p2 && (p2 = (p1 = buffer) + fread(buffer, 1, maxr, stdin), p1 == p2)) ? EOF : *p1++)
using namespace std;

char buffer[maxr], *p1, *p2;
template<class T> void read(T& x){
	char ch = gc(); x = 0; bool f = 1;
	while (!('0' <= ch && ch <= '9') && ch != '-') ch = gc();
	if (ch == '-') f = 0, ch = gc();
	while ('0' <= ch && ch <= '9') x = (x << 1) + (x << 3) + ch - '0', ch = gc();
	x = (f) ? x : -x;
}
int n, k;
char s[maxn];
int main(){
	scanf("%s", s + 1);
	scanf("%d", &k);
	n = strlen(s + 1);
	if (s[1] == s[n]){
		int pre = 0, suf = 0, ans = 0;
		rep(i, 1, n){
			int now = s[i], _i = i;
			while (i <= n && s[i] == now) i++;
			if (i - _i == n) {
				printf("%lld", (ll)n * k >> 1);
				return 0;
			}
			if (_i == 1) pre = i - _i;
			else if (i == n + 1) suf = i - _i;
			else ans += ((i - _i) >> 1); 
			i--;
		}
		printf("%lld", (ll)ans * k + (ll)(k - 1) * ((pre + suf) >> 1) + (pre >> 1) + (suf >> 1));
	}
	else {
		int ans = 0;
		rep(i, 1, n){
			int now = s[i], _i = i;
			while (i <= n && s[i] == now) i++;
			ans += ((i - _i) >> 1);
			i--;
		}
		printf("%lld", (ll)ans * k);
	}
	return 0;
}

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

signed main(){
	int N, M, Q, x, i;
	scanf("%lld%lld%lld", &N, &M, &Q);
	vector<int> s(N + 2), srev(N + 2);
	s[0] = -inf;
	for(i = 1; i <= N; i++){
		scanf("%lld", &s[i]);
	}
	s[N + 1] = inf;
	for(i = 0; i <= N + 1; i++){
		srev[i] = -s[N + 1 - i];
	}
	vector<int> t(M + 2), trev(M + 2);
	t[0] = -inf;
	for(i = 1; i <= M; i++){
		scanf("%lld", &t[i]);
	}
	t[M + 1] = inf;
	for(i = 0; i <= M + 1; i++){
		trev[i] = -t[M + 1 - i];
	}
	for(i = 0; i < Q; i++){
		scanf("%lld", &x);
		int LF[2][2];
		LF[0][0] = *lower_bound(s.begin(), s.end(), x);
		LF[0][1] = -*lower_bound(srev.begin(), srev.end(), -x);
		LF[1][0] = *lower_bound(t.begin(), t.end(), x);
		LF[1][1] = -*lower_bound(trev.begin(), trev.end(), -x);
//		printf("(%lld, %lld, %lld, %lld)\n", LF[0][0], LF[0][1], LF[1][0], LF[1][1]);
		int ans = inf;
		for(int j = 0; j < 2; j++){
			for(int k = 0; k < 2; k++){
				for(int l = 0; l < 2; l++){
					ans = min(ans, abs(LF[j][k] - x) + abs(LF[1 - j][l] - LF[j][k]));
				}
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

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

#define PI acos(-1)
#define pb push_back
#define int long long int
#define mp make_pair
#define pi pair<int, int>
#define pii pair<int, pi>
#define fir first
#define sec second
#define MAXN 10000001
#define MAXL 20
#define mod 1000000007

vector<int> dp(MAXN, 2);

void crivo()
{
  for (int i = 2; i < MAXN; i++)
    for (int j = 2; j * i < MAXN; j++)
      dp[j * i]++;
}
signed main()
{
  dp[1] = 1;
  crivo();
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++)
    ans += (dp[i] * i);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 81256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <ctime>
#include <cstdlib>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	int l = 0;
	int p = b;
	while (p != 0){
		l++;
		p /= 10;
	}
	a = a * pow(10, l) + b;
	if (pow(int(sqrt(a)), 2) == a)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

using namespace std;


int main()
{
	char x, y;
	cin >> x >> y;
	if (x > y)
	{
		cout << ">" << endl;
	}
	else if (x < y)
	{
		cout << "<" << endl;
	}
	else
	{
		cout << "=" << endl;
	}

}

Measured memory_bytes: 256
import heapq


def dijkstra(adj, start, goal=None):
    num = len(adj)          # グラフのノード数
    dist = [float('inf') for i in range(num)]  # 始点から各頂点までの最短距離を格納する
    prev = [float('inf') for i in range(num)]  # 最短経路における，その頂点の前の頂点のIDを格納する

    dist[start] = 0
    # プライオリティキュー．各要素は，(startからある頂点vまでの仮の距離, 頂点vのID)からなるタプル
    q = []
    heapq.heappush(q, (0, start))  # 始点をpush

    while q:
        prov_cost, src = heapq.heappop(q)  # pop

        # プライオリティキューに格納されている最短距離が，現在計算できている最短距離より大きければ，distの更新をする必要はない
        if dist[src] < prov_cost:
            continue

        # 他の頂点の探索
        for dest in range(num):
            cost = adj[src][dest]
            if cost != float('inf') and dist[dest] > dist[src] + cost:
                dist[dest] = dist[src] + cost  # distの更新
                # キューに新たな仮の距離の情報をpush
                heapq.heappush(q, (dist[dest], dest))
                prev[dest] = src                      # 前の頂点を記録

    return dist


n, m = map(int, input().split())
mat = [[float('inf')] * n for _ in range(n)]
for i in range(m):
    a, b, c = map(int, input().split())
    mat[a - 1][b - 1] = c
    mat[b - 1][a - 1] = c
for i in range(n):
    mat[i][i] = 0
mat2 = []
for i in range(n):
    mat2.append(dijkstra(mat, i))
ans = 0
for i in range(n):
    for j in range(i, n):
        if mat[i][j] != float('inf') and mat[i][j] != mat2[i][j]:
            ans += 1
print(ans)

Measured memory_bytes: 3568
n, y = list(map(int, input().split()))
for i in range(n + 1):
    for j in range(n - i + 1):
        k = n - i - j
        if 10000 * i + 5000 * j + 1000 * k == y:
            print(' '.join(list(map(str, [i, j, k]))))
            exit()
print('-1 -1 -1')

Measured memory_bytes: 3060
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	private static final String YES = "Yes";

	private static final String NO = "No";

	public static void main(String[] args) {

		int[][] arr = scan();
		System.out.println(process(arr) ? YES : NO);
	}

	private static int[][] scan() {

		Scanner sc = new Scanner(System.in);
		int[][] arr = new int[3][3];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				arr[i][j] = sc.nextInt();
			}
		}
		sc.close();
		return arr;
	}

	private static boolean process(int[][] arr) {

		Map<String, Integer> map = new HashMap<>();

		return invoke(arr, map, 0);
	}

	private static boolean invoke(int[][] arr, Map<String, Integer> map, int j) {

		while (j < arr.length) {
			String aKey = "a" + j;
			int a = arr[0][j];
			if (map.get(aKey) == null) {
				map.put(aKey, a);
			} else {
				a = map.get(aKey);
			}
			if (a < 0) {
				return false;
			}

			int b;
			String bKey;
			for (int i = 0; i < arr.length; i++) {
				bKey = "b" + i;
				b = arr[i][j] - a;

				if (map.get(bKey) == null) {
					map.put(bKey, b);
				} else if (b != map.get(bKey)) {
					if (j > 0) {
						map.put(aKey, map.get(aKey) - 1);
						return invoke(arr, map, j);
					}
					map.put(bKey, b);
				} else {
					b = map.get(bKey);
				}

				if (b < 0 || arr[i][j] != (a + b)) {
					map.put(aKey, map.get(aKey) - 1);
					return invoke(arr, map, j);
				}
			}
			return invoke(arr, map, j + 1);
		}

		return true;
	}
}

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

#define MAXN 55555

using namespace std;

bool F[MAXN+1];
vector<int> V;

int main()
{
  int n;
  int cnt = 0;

  cin >> n;

  for ( int i= 2; i <= MAXN; ++i ) F[i] = true;
  for ( int i = 2; i <= MAXN; ++i ) {
    if ( F[i] ) {
      for ( int j = i*2; j <= MAXN; j += i ) F[j] = false;
    }
  }

  for ( int i = 2; i <= MAXN; ++i ) {
    if ( cnt == n ) break;
    if ( F[i] && i%5 == 1 ) {
      cout << i << " ";
      ++cnt;
    }
  }

  cout << endl;

}


Measured memory_bytes: 256
let cnt = ref 0

let merge a l m r =
  let ai = Array.make (m - l + 1) max_int in
  for i = 0 to m - l - 1 do
    ai.(i) <- a.(l + i)
  done;
  let aj = Array.make (r - m + 1) max_int in
  for i = 0 to r - m - 1 do
    aj.(i) <- a.(m + i)
  done;
  let i = ref 0 in
  let j = ref 0 in
  for k = l to r - 1 do
    incr cnt;
    if ai.(!i) <= aj.(!j) then begin
      a.(k) <- ai.(!i);
      incr i;
    end else begin
      a.(k) <- aj.(!j);
      incr j;
    end
  done

let rec merge_sort a l r =
  if (l + 1) < r then begin
    let m = (l + r) / 2 in
    merge_sort a l m;
    merge_sort a m r;
    merge a l m r
  end

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  merge_sort a 0 n;
  print_int a.(0);
  for i = 1 to n - 1 do
    print_string " ";
    print_int a.(i);
  done;
  print_newline ();
  print_int !cnt;
  print_newline ()

Measured memory_bytes: 22072