akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int asc(const void *a, const void *b){
  return *(int *)a - *(int *)b;
}

int
main(int argc, char *argv[])
{
  int n;
  scanf("%d", &n);
  int a[100000], b[100000], c[100000];
  for(int i = 0; i < n; i++) scanf("%d", &a[i]);
  for(int i = 0; i < n; i++) scanf("%d", &b[i]);
  for(int i = 0; i < n; i++) scanf("%d", &c[i]);

  qsort(a, n, sizeof(int), asc);
  qsort(b, n, sizeof(int), asc);
  qsort(c, n, sizeof(int), asc);

  int k = 0; long long ia[100000], xb[100000];
  xb[n] = 0;
  for(int i = 0; i < n; i++){
    while(a[i] >= b[k] && k < n) k++;
    ia[i] = k;
  }
  
  k = 0;
  for(int i = 0; i < n; i++){
    while(b[i] >= c[k] && k < n) k++;
    xb[i] = n - k;
  }

  k = n - 1;
  long long sb[100000] = {};
  sb[n - 1] = xb[n - 1];
  while(k > 0){
    k--;
    sb[k] = sb[k + 1] + xb[k];
  }

  long long ans = 0;
  for(int i = 0; i < n; i++){
    ans += sb[ia[i]];
  }
  
  printf("%lld\n", ans);

  return 0;
}
				  


Measured memory_bytes: 4104
import queue

"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
#N = int(input())
#print("{:.0f}".format((N*(N-1)/2)))
(A,B) = (int(i) for i in input().split(" "))
print(int((B-1+A-2)/(A-1)))

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

#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MAX (int)1e9 + 99
#define maxof(a,b,c) max(a,max(b,c))
#define minof(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vvi vector<vector<int>>
#define vb vector<bool>
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pa pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define bitcnt(x) __builtin_popcount(x)
#define gcd(a,b) __gcd(a,b)
#define all(x) (x).begin(),(x).end()
#define ts(x) to_string(x)
#define rsort(a) sort(all(a)); reverse(all(a))
#define set0(x) memset(x, 0, sizeof(x))
const double pi = 3.14159265358979323846;
ll binpow(ll, ll);
ll mult(ll, ll);
ll add(ll , ll);
ll division(ll, ll);
ll nCr(ll, ll);
ll inv(ll);
void calc();
void maxi(int &a, int b) {if(a<b) a = b;}
void mini(int &a, int b) {if(a>b) a = b;}
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) {if (!v.empty()) {os << v.front();for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];} return os;}
const int N=50010;
const int MOD = 1e9+7;
//ll fact[N];






void solve()
{
    int n;
    cin>>n;
    if(n==0) cout<<1;
    else cout<<0;
}

int main()
{
    fastio;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    
    rep(i,t)
    {
        solve();
        cout<<"\n";
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}








ll add(ll a, ll b){
    a+=b;
    while(a>=MOD) a-=MOD;
    while(a<0) a+=MOD;
    return a;
}

ll mult(ll a, ll b){
    return (a * 1ll * b) % MOD;
}


ll binpow(ll a, ll b){
    ll c = 1;
    while(b > 0)
    {
        if(b % 2 == 1)
            c = mult(c, a);
        a = mult(a, a);
        b /= 2;
    }
    return c;   
}

ll inv(ll a){
    return binpow(a, MOD-2);
}

ll division(ll a, ll b){
    return mult(a, inv(b));
}
/*
ll nCr(ll n, ll r){
    if(r > n) return 0;
    return division(fact[n], mult(fact[n-r], fact[r]));
}

void calc(){
    fact[0] = 1;
    srep(i,1,N-1)
        fact[i] = (i*1ll*fac[i-1])%MOD;

}*/

Measured memory_bytes: 3816
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include "boost/multiprecision/cpp_int.hpp"
using ll = long long;
using ull = unsigned long long;
namespace mp = boost::multiprecision;

int main() {

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

	int N, M; std::cin >> N >> M;
	std::vector<std::vector<int>> nodes(N);
	std::vector<std::pair<int, int>> edges;

	int ans = 0;

	for (int i = 0; i < M; i++) {
		int a, b; std::cin >> a >> b;
		nodes[a - 1].push_back(b - 1);
		nodes[b - 1].push_back(a - 1);
		edges.push_back(std::make_pair(a - 1, b - 1));
	}

	for (int i = 0; i < M; i++) {
		std::vector<bool> memo(N, false);
		std::queue<int> q;
		q.push(0);
		while (!q.empty()) {
			int from = q.front();
			q.pop();
			memo[from] = true;
			for (auto& to : nodes[from]) {
				if ((edges[i].first == from && edges[i].second == to) || (edges[i].first == to && edges[i].second == from)) {
					continue;
				}
				if (!memo[to]) {
					q.push(to);
				}
			}
		}

		if (std::any_of(memo.begin(), memo.end(), [](auto a) {return !a; }))ans++;

	}

	std::cout << ans;


	return 0;

}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

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

    vector<pair<int,int>> points(2*N);
    REP(i,N){
        int a,b; cin >> a >> b;
        points[a] = {b,0};
    }

    REP(i,N){
        int a,b; cin >> a >> b;
        points[a] = {b,1};
    }

    int ans = 0;
    REPR(i,2*N-1){
        if(points[i].second==0){
            int min_itr = INF;
            int min_y = INF;
            FOR(j,i+1,2*N){
                if(points[i].first<points[j].first && points[j].second==1){
                    if(min_y > points[j].first){
                        min_y = points[j].first;
                        min_itr = j;
                    }
                }
            }
            if(min_y!=INF){
                ans++;
                points[min_itr].second = -1;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
while True:
    student = list(map(int,input().split()))
    m = student[0]
    f = student[1]
    r = student[2]

    if m==-1 and f==-1 and r==-1:
        break

    if m==-1 or f==-1:
        print("F")
    elif m+f>=80:
        print("A")
    elif 80>m+f and m+f>=65:
        print("B")
    elif 65>m+f and m+f>=50:
        print("C")
    elif 50>m+f and m+f>=30:
        if r>=50:
            print("C")
        else:
            print("D")
    else:
        print("F")



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define pii pair<ll,ll>
#define pll pair<long long, long long >
#define ll long long
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define maxn 1000000007
#define endl '\n'
#define trace(x) cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
ll mod(ll x,ll y)
{
  ll s;
  s = abs(x)/y;
  if(x<0)s--;
  return x-y*s;
}
ll dir8[2][8] = {{1,-1,0,0,1,-1,1,-1},{0,0,1,-1,1,-1,-1,1}};
ll dir4[2][4] = {{1,-1,0,0},{0,0,1,-1}};
ll m,n,row,col;
char s[10005];
vector<ll> num;
ll memo[10006][2][104];
ll add(ll x,ll y)
{
  if(x+y < maxn)return x+y;
  return (x+y)%maxn;
}
ll dp(ll i,ll tight,ll sum)
{
  if(i >= num.size())
  {
    if(sum == 0)return 1;
    return 0;
  }
  if(memo[i][tight][sum]!=-1)return memo[i][tight][sum];
  ll lim = 9;
  if(tight == 1)lim = num[i];
  ll newT;
  ll ans = 0;
  for(ll w=0;w<=lim;w++)
  {
    if(w == num[i])newT = tight;
    else newT = 0;
    ans = add(ans,dp(i+1,newT,(sum + w)%n));
  }
  memo[i][tight][sum] = ans;
  return ans;

}
void solve()
{
  scanf("%s",s);
  scanf("%lld",&n);
  memset(memo,-1,sizeof memo);
  for(ll i=0;s[i];i++)num.pb(s[i]-48);
  ll ans = dp(0,1,0);
  if(ans == 0)cout<< maxn-1 << endl;
  else cout << ans-1 << endl;

}
void test()
{
  ll t;
  //scanf("%d",&t);
  t = 1;
  for(ll test=1;test<=t;test++)
  {
    solve();
  }
}
int main()
{
  test();
  return 0;
}


Measured memory_bytes: 17664
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	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;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	ll X;
	std::cin >> X;
	
	repeq(A, -1000, 1000) {
		repeq(B, -1000, 1000) {
			if (A * A * A * A * A - B * B * B * B * B == X) {
				std::cout << A << " " << B << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<string, int> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}

int main()
{
	ios_base::sync_with_stdio(false);
	ll n, k,a,b,c,ans=0;
	cin >> n >> a;
	vi v(n);
	rep(i, n) cin >> v[i];
	sort(all(v));
	rep(i, n) {
		a -= v[i];
		ans++;
		if (a <= 0) break;
	}
	if (a != 0) ans--;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// ABC 51 C

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;

typedef long long ll;

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; }
const long long INF = 1LL<<60;


int main()
{
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  tx -= sx;
  ty -= sy;
  sx = 0;
  sy = 0;

  // 1 往路
  rep(i, tx) {
    cout << "R";
  }
  rep(i, ty) {
    cout << "U";
  }

  // 1 復路
  rep(i, tx) {
    cout << "L";
  }
  rep(i, ty) {
    cout << "D";
  }

  // 2 往路
  cout << "D";
  rep(i, tx+1) {
    cout << "R";
  }
  rep(i, ty+1) {
    cout << "U";
  }
  cout << "L";

  // 2 復路
  cout << "U";
  rep(i, tx + 1) {
    cout << "L";
  }
  rep(i, ty + 1) {
    cout << "D";
  }
  cout << "R";

  cout << endl;

  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
int H,W,Sr[111][111],Sc[111][111],f[111][111][111],Ex,Ey;
char a[111][111];
int rows(int i,int l,int r){return l<=r?Sr[i][r]-Sr[i][l-1]:0;}
int cols(int i,int l,int r){return l<=r?Sc[r][i]-Sc[l-1][i]:0;}
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a>b?a:b;}
void cmax(int&a,int b){b>a?a=b:1;}
int main(){
	scanf("%d%d",&H,&W);
	for(int i=1;i<=H;i++){
		scanf("%s",a[i]+1);
		for(int j=1;j<=W;j++){
			Sr[i][j]=Sr[i][j-1]+(a[i][j]=='o');
			Sc[i][j]=Sc[i-1][j]+(a[i][j]=='o');
			if(a[i][j]=='E')Ex=i,Ey=j;
		}
	}
	for(int u=1,rd=H-Ex+1;u<=Ex;u++,rd++)
	for(int d=H,ru=H-Ex+1;d>=Ex;d--,ru--)
	for(int l=1,rr=W-Ey+1;l<=Ey;l++,rr++)
	for(int r=W,rl=W-Ey+1;r>=Ey;r--,rl--){
		if(u-1>=ru)f[d][l][r]+=rows(u-1,max(l,rl),min(r,rr));
		if(d+1<=rd)cmax(f[d][l][r],f[d+1][l][r]+rows(d+1,max(l,rl),min(r,rr)));
		if(l-1>=rl)cmax(f[d][l][r],f[d][l-1][r]+cols(l-1,max(u,ru),min(d,rd)));
		if(r+1<=rr)cmax(f[d][l][r],f[d][l][r+1]+cols(r+1,max(u,ru),min(d,rd)));
	}
	printf("%d\n",f[Ex][Ey][Ey]);
}

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

using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;

const ll mo=1000000007;
ll comb(ll N_, ll C_) {
    const int NUM_=2400001;
    static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
    if (fact[0]==0) {
        inv[1]=fact[0]=factr[0]=1;
        for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
        for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
    }
    if(C_<0 || C_>N_) return 0;
    return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
int comb1(int x,int y){
    int ans = 0;
    FOR(i,1,y+2){
        ans+=comb(x+i,x);
    }
    return ans%mo;
}
int32_t main() {
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    
    
    ini(x,y,x1,y1);
    int total = 0;
    total+=comb1(x1,y1);
    total+=comb1(x-1,y-1);
    total-=comb1(x-1,y1);
    total-=comb1(x1,y-1);
    total+=mo;
    total%=mo;
    out(total);
        
  
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 56576
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  int A[200000];
  for(int i=0;i<N;i++)
    cin>>A[i];
  for(int i=0;i<N;i++)
    A[i]-=i+1;
  sort(A,A+N);
  int b=A[(N-1)/2];
  long long res=0;
  for(int i=0;i<N;i++)
    res+=abs(A[i]-b);
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
//#include <boost/multiprecision/cpp_int.hpp>

#define BIT(a) (1 << (a))

using namespace std;
//using namespace boost::multiprecision;

long long MOD = 1000000007;


long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}


int main(void){
    int input[3];
    for (int i = 0; i < 3; i++){
        cin >> input[i];
    }
    sort(input, input+3);
    int ans = 0;
    ans += input[2] - input[1];
    input[0] += (input[2] - input[1]);
    if ((input[2] - input[0]) % 2){
        ans += (input[2] - input[0])/2 + 2;
    }else{
        ans += (input[2] - input[0])/2;
    }
    cout << ans << endl;
}



Measured memory_bytes: 888
from fractions import gcd

a, b, c, d = map(int, input().split())
lcm = c * d // gcd(c, d)


def nd(n, c, d):
    return n - n // c - n // d + n // lcm


ans = nd(b, c, d) - nd(a-1, c, d)
print(int(ans))

Measured memory_bytes: 64492
class Graph
  attr_accessor :n, :ver, :matrices
  def initialize(number_of_vertexes)
    @n = number_of_vertexes
    gets_matrices
    create_vertexes
  end

  def prim
    set_root(0)
    loop do
      break unless u = next_mincost_vertex
      add_minimum_spanning_tree(u)
      update_mincosts(parent: u)
    end
  end

  def sum_cost
    ver.inject(0){|a,v| a + v.weight}
  end

  private
    def set_root(v)
      ver[v].weight = 0
      ver[v].parent = -1
    end

    def next_mincost_vertex
      mincost = Float::INFINITY
      u = nil
      ver.each do |v|
        if v.color != :black && v.weight < mincost
          mincost = v.weight
          u = v.id
        end
      end
      u
    end

    def add_minimum_spanning_tree(u)
      ver[u].color = :black
    end

    def update_mincosts(parent:)
      matrices[parent].each_with_index do |cost,idx|
        if ver[idx].color != :black && cost < ver[idx].weight
          ver[idx].weight = cost
          ver[idx].parent = parent
          ver[idx].color = :gray
        end
      end
    end

    def gets_matrices
      @matrices = Array.new(n){Array.new(n,-1)}
      n.times do |i|
        gets.split.map(&:to_i).each_with_index do |j,idx|
          j = Float::INFINITY if j == -1
          matrices[i][idx] = j
        end
      end
    end

    def create_vertexes
      @ver = []
      n.times {|i| ver << V.new(i)}
    end
end

class V
  attr_accessor :id, :color, :weight, :parent
  def initialize(id)
    @id = id
    @color = :white
    @weight = Float::INFINITY
  end
end

n = gets.to_i
graph = Graph.new(n)
graph.prim
puts graph.sum_cost



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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repk(i,n,k) for(ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    string s;
    vector<ll> cnt(4,0);
    rep(i,n){
        cin >> s;
        if(s=="AC") cnt[0]++;
        else if(s=="WA") cnt[1]++;
        else if(s=="TLE") cnt[2]++;
        else cnt[3]++;
    }
    print("AC x "<<cnt[0]<<"\nWA x "<<cnt[1]<<"\nTLE x "<<cnt[2]<<"\nRE x "<<cnt[3]);
    return 0;
}

Measured memory_bytes: 3652
# 1 "h.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "h.cpp"
# 1 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 1
       
# 12 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/bits/stdc++.h" 1
 #include <bits/stdc++.h>
# 13 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/assoc_container.hpp" 1
 #include <ext/pb_ds/assoc_container.hpp>
# 14 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/tree_policy.hpp" 1
 #include <ext/pb_ds/tree_policy.hpp>
# 15 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2







using namespace std;
using namespace __gnu_pbds;

using ii = pair<long long, long long>;
using vi = vector<long long>;
using vd = vector<long double>;
using vb = vector<bool>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvd = vector<vd>;
using vvb = vector<vb>;
using vvii = vector<vii>;
# 50 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
inline long long mod(const long long n, const long long m = ((long long)1e9+7)){
    return (n%m + m)%m;
}

/**
 * Euclidean GCD.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long gcd(const long long a, const long long b){
    if(a < 0 or b < 0)
        return gcd(abs(a), abs(b));
    if(a == 0)
        return b;
    return gcd(b%a, a);
}

/**
 * Euclidean derivated LCM.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long lcm(const long long a, const long long b){
    // same as a*b/gcd(a, b) but avoiding overflow.
    return a/gcd(a, b)*b;
}
# 2 "h.cpp" 2

int32_t main(){
    (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL));
    long long n, m;
    cin >> n >> m;
    vector<string> grid(n);
    for(string &s:grid)
        cin >> s;
    vvi ans(n, vi(m));
    ans[0][0] = (grid[0][0] != '#');
    for(long long i=0; i<n; ++i){
        for(long long j=0; j<m; ++j){
            if(!i and !j or grid[i][j] == '#')
                continue;
            if(i)
                ans[i][j] += ans[i-1][j];
            if(j)
                ans[i][j] += ans[i][j-1];
            ans[i][j] = mod(ans[i][j]);
        }
    }
    cout << ans[n-1][m-1] << "\n";
    return 0;
}


Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <functional>
#include <set>
#include <numeric>
#include <queue>
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
#define PI 3.14159265358979323846264338327950


int main() {
	ll N, height=0, ans=0;

	cin >> N ;
	vector<ll> a(N);
	rep(i, N)cin >> a[i];

	rep(i, N){
		if (a[i] < height){
			ans += (height - a[i]);
		}
		else{
			height = a[i];
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4808
//Name: Heian-Kyo Walking
//Level: 2
//Category: 動的計画法,DP
//Note:

/*
 * 通れないパターンを覚えておき、グリッドグラフの最短経路数え上げをする。
 *
 * オーダーは O(XY log P)。
 */
#include <iostream>
#include <set>
#include <utility>
#include <vector>

using namespace std;

typedef pair<int,int> Pt;

void solve() {
    int X, Y;
    cin >> X >> Y;
    int P;
    cin >> P;
    set<pair<Pt,Pt>> prohibited;
    for(int i = 0; i < P; ++i) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        prohibited.insert(make_pair(Pt(x1, y1), Pt(x2, y2)));
        prohibited.insert(make_pair(Pt(x2, y2), Pt(x1, y1)));
    }

    vector<vector<int>> dp(X+1, vector<int>(Y+1, 0));
    dp[0][0] = 1;
    for(int x = 0; x <= X; ++x) {
        for(int y = 0; y <= Y; ++y) {
            if(x > 0 && !prohibited.count(make_pair(Pt(x-1,y), Pt(x,y)))) dp[x][y] += dp[x-1][y];
            if(y > 0 && !prohibited.count(make_pair(Pt(x,y-1), Pt(x,y)))) dp[x][y] += dp[x][y-1];
        }
    }
    if(dp[X][Y] == 0) {
        cout << "Miserable Hokusai!" << endl;
    } else {
        cout << dp[X][Y] << endl;
    }
}

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

    int N;
    cin >> N;
    while(N--) solve();
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int s[110];
  bool flag = true;
  int ans = 0;
  int minus;
  for (int i = 0; i < N; i++) {
    cin >> s[i];
    if (s[i] % 10 != 0) flag = false;
    ans += s[i];
  }

  if (flag) {
    cout << 0 << endl;
    return 0;
  }

  sort(s, s + N);

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

  cout << ans << endl;
}

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

typedef long long ll;

int main(){
  int N, A, B, x1, x2;
  ll ans = 0;
  scanf("%d %d %d %d", &N, &A, &B, &x1);
  for(int i=1; i<N; i++){
    scanf("%d", &x2); ans+=min((x2-x1)*(ll)A, (ll)B);
    x1 = x2;
  }
  printf("%lld\n", ans);
  return 0;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int n=0; n<N; n++) {
        int p;
        cin >> p;
        if(p==n+1) {
            vec[n]=1;
        } else {
            vec[n]=0;
        }
    }
    
    int ans=0;
    for(int n=0; n<N; n++) {
        if(vec[n]==1) {
            ans++;
            if(n+1<N && vec[n+1]==1) {
                n++;
            }
        }
    }
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define F first
#define S second
#define s(x) #x<<" "<<x<<" | "<<
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define all(A)  A.begin(),A.end()  
#define has(m,x)   (m.find(x)!=m.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
#define endl "\n"
const int MSIZE = 2e5+5;
const int MOD = 1e9+7 ;


int arr[MSIZE];

int main(){

    FIO
    int n; cin>>n;
    int xr = 0;
    f(i,0,n-1)   {
        cin>>arr[i];
        xr^=arr[i];
    } 
    f(i,0,n-1) cout<<(xr^arr[i])<<" ";
    
    
    
    
    return 0;
}
    


Measured memory_bytes: 4388
// see https://github.com/LumaKernel/vimfiles/tree/master/snippets/cp-cpp/temp.snip
const bool DEBUG = 1;
/// --- .lumrc Template {{{ ///
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>
#include <cassert>
#include <functional>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = tuple<ll, ll>;
using P3 = tuple<ll, ll, ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VP = vector<P>;
using VS = vector<string>;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define FORI(i,a,b) for(int i=int(a);i<=int(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REPI(i,n) FORI(i,0,n)
#define RFOR(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define RFORI(i,a,b) for(int i=int(b);i>=int(a);--i)
#define RREP(i,n) RFOR(i,0,n)
#define RREPI(i,n) RFORI(i,0,n)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique(ALL(a)),(a).end())
#define PB push_back
#define EACH(i,c) REP(i,(c).size())
#define REACH(i,c) RREP(i,(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))

#define BR cout<<"\n";

#define dump(x) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)<<"\n";
#define dump2(x,y) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
  <<" , "<<#y<<"="<<(y)<<"\n";
#define dump3(x,y,z) if(DEBUG)cerr<<"["<<__LINE__<<"] "<<#x<<"="<<(x)\
  <<" , "<<#y<<"="<<(y)\
<<" , "<<#z<<"="<<(z)<<"\n";

#define SAY(x) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<(x)<<"\n";

#define YES(x) cout<<((x)?"YES":"NO")<<"\n";
#define Yes(x) cout<<((x)?"Yes":"No")<<"\n";
#define yes(x) cout<<((x)?"yes":"no")<<"\n";

inline int omajinai_int_in(){omajinai;int n;cin>>n;return n;}
inline ll omajinai_ll_in(){omajinai;ll n;cin>>n;return n;}
inline string omajinai_string_in(){omajinai;string n;cin>>n;return n;}
inline int int_in(){int n;cin>>n;return n;}
inline ll ll_in(){ll n;cin>>n;return n;}
inline string string_in(){string n;cin>>n;return n;}
#define oini omajinai_int_in()
#define oinl omajinai_ll_in()
#define oins omajinai_string_in()
#define ini int_in()
#define inl ll_in()
#define ins string_in()

#define isInside(y,x) (0<=(y)&&(y)<h&&0<=(x)&&(x)<w)

#define fi(x) (get<0>(x))
#define se(x) (get<1>(x))
#define th(x) (get<2>(x))
#define fo(x) (get<3>(x))
#define fif(x) (get<4>(x))

template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; EACH(i, v) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }

template <typename T> inline void smax(T &a, T b) { a = a > b ? a : b; }
template <typename T> inline void smin(T &a, T b) { a = a < b ? a : b; }

/// }}}--- ///

constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr int MOD = 1e9+7;

ll ans;

int main() {
  string s=ins;
  s[3]='8';
  cout << s << endl;
}

//


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, X;
  cin >> N >> X;
  int count = 0;
  int a = 2000, b;
  for(int i = 0; i < N; i++) {
    cin >> b;
    X -= b;
    if (a > b) a = b;
    count++;
  }
  cout << count + (X / a) << endl;
  return 0;
}

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

using namespace std;
typedef long long LL;

const int Mod=1e9+7;

int m;
LL fib[100];
vector<pair<LL,LL> > good[100];

void Getgoodnumber(int x)
{
	for (auto d:good[x-1])
	{
		LL add=d.first; swap(d.first,d.second);
		for (d.first+=add;d.first<=fib[x+2];d.first+=add)
			good[x].push_back(d);
	}
	sort(good[x].begin(),good[x].end());
	good[x].erase(unique(good[x].begin(),good[x].end()),good[x].end());
}

void FindAns(LL a,LL b)
{
	int ans=1;
	for (int i=2;i<=90;++i)
		if (fib[i]<=a && fib[i+1]<=b) ans=i;
		else break;
	if (ans==1)
		printf("%d %lld\n",ans,1ll*(a%Mod)*(b%Mod)%Mod);
	else 
	{
		LL ret=0;
		for (auto d:good[ans-1])
		{
			if (d.first<=a) ret=(ret+(b-d.second)/d.first)%Mod;
			if (d.first<=b) ret=(ret+(a-d.second)/d.first)%Mod;
		}
		printf("%d %lld\n",ans,ret);
	}
}

void Solve()
{
	fib[0]=fib[1]=1; for (int i=2;i<=91;++i) fib[i]=fib[i-1]+fib[i-2];
	good[1].push_back(make_pair(2,1)); good[1].push_back(make_pair(3,1));
	for (int i=2;i<=91;++i) Getgoodnumber(i);
	scanf("%d",&m); LL a,b;
	for (int i=1;i<=m;++i)
	{
		scanf("%lld%lld",&a,&b);
		if (a>b) swap(a,b);
		FindAns(a,b);
	}
}

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

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int n;
    cin>>n;
    long double ans=1;
    rep(i,n){
        long double a;
        cin>>a;
        ans*=a;
        if(ans>1e18){
            ans=-1;
        }
        if(ans<0)ans=-1;
    }
    cout<<(ll)ans<<endl;
}


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

int main() {
  double l; cin >> l;
  double tmp = l/3;
  double ans = tmp * tmp * tmp;
  printf("%.20f\n", ans);
  
  return 0;
}

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

int main() {
    int N, M;
    cin>>N>>M;
    int x[M], y[M];
    map<int, vector<int> > graphmap;
    map<int, int> edge;
    for(int i=0;i<M;++i){
        cin>>x[i]>>y[i];
        graphmap[x[i]].push_back(y[i]);
        edge[y[i]]++;
    }
    queue<int> que;
    for(int i=1;i<=N;++i){
        if(edge[i]==0) que.push(i);
    }

    int state;
    map<int, int> graph;
    while(!que.empty()){
        state = que.front();
        que.pop();
        for(int i=0;i<graphmap[state].size();++i){
            edge[graphmap[state][i]]--;
            graph[graphmap[state][i]] = max(graph[graphmap[state][i]], graph[state]+1);
            if(edge[graphmap[state][i]]==0)que.push(graphmap[state][i]);
        }
    }
    int ans = 0;
    for(int i=1;i<=N;++i){
        if(ans < graph[i])ans = graph[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 21376
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[] scoreList;

		int totalMult = 0;
		int totalNotMult = 0;
		ArrayList<Integer> mult10 = new ArrayList<Integer>();
		ArrayList<Integer> notMult10 = new ArrayList<Integer>();

		Scanner in = new Scanner(System.in);
		int iter = in.nextInt();
		scoreList = new int[iter];
		for(int i = 0; i < iter; i++){
			scoreList[i] = in.nextInt();
			if(scoreList[i] % 10 == 0){
				mult10.add(scoreList[i]);
				totalMult += scoreList[i];
			}
			else {
				notMult10.add(scoreList[i]);
				totalNotMult += scoreList[i];
			}
		}

		if(totalNotMult % 10 == 0 && notMult10.size() > 0){
			int min = 101;
			for(int i = 0; i < notMult10.size(); i++){
				int score = notMult10.get(i);
				if(score < min) min = score;
			}
			totalNotMult -= min;
		}


		int totalScore = totalNotMult + totalMult;
		if(totalScore % 10 == 0) System.out.println(0);
		else System.out.println(totalScore);
		in.close();
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int L;
  cin >> L;
  int n(0), m(-3);
  stack<int> stk;
  while (L) {
    if (L & 1) {
      stk.push(n);
      m++;
    }
    L /= 2;
    n += 1;
    m += 2;
  }
  stk.pop();
  cout << n << ' ' << m << '\n';
  for (int i = 1; i <= n - 1; i++) {
    cout << i << ' '  << i + 1 << ' ' << (1 << (i - 1)) <<'\n';
    cout << i << ' '  << i + 1 << ' ' << 0 <<'\n';
  }
  int wt = (1 << (n - 1));
  while (!stk.empty()) {
    int s = stk.top() + 1;
    stk.pop();
    cout << s << ' ' << n << ' ' << wt << '\n';
    wt += (1 << (s - 1));
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main() {
	ll N;
	ll a[5];
	cin >> N;
	for (int i = 0;i < 5;++i)cin >> a[i];
	ll minv = a[0];
	ll time = 0;
	for (int i = 1; i < 5; ++i)minv = min(minv, a[i]);
	if (N % minv == 0)time--;
	N /= minv;
	time+=N;
	time += 5;
	cout << time << endl;
	return 0;
}

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


int main()
{
	int a,b,c,d,L,R;
	cin >> a >> b >> c >> d;
	L = a + b;
	R = c + d;
		cout <<(L==R ? "Balanced" :(L>R ? "Left" : "Right"))   << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<int> x(n), y(n), h(n);
    int bx, by, bh;
    for(int i=0; i<n; i++){
        cin>>x[i]>>y[i]>>h[i];
        if(h[i]!=0){
            bx=x[i], by=y[i], bh=h[i];
        }
    }

    for(int i=0; i<=100; i++){
        for(int j=0; j<=100; j++){
            int H=bh+abs(bx-i)+abs(by-j);
            bool ok=true;
            for(int k=0; k<n; k++){
                int ph=max(H-abs(x[k]-i)-abs(y[k]-j), 0);
                if(ph!=h[k]) ok=false;
            }

            if(ok){
                cout << i << " " << j << " " << H << endl;
                return 0; 
            }
        }
    }
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let b: usize = read(&mut stdin_lock, &mut buf, b'\n');
    for i in 1..3 + 1 {
        if i != a && i != b {
            println!("{}", i);
        }
    }
}


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

const int MAXN = 100005;

int N, A[MAXN];
int main(){
	scanf("%d", &N);
	
	int g = 0;
	for(int i = 0; i < N; i++){
		scanf("%d", &A[i]);
		g = __gcd(g, A[i]);
	}
	printf("%d\n", g);
		
	return 0;
}


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

int main()
{
	char str[21];
	int i;
	cin >> str;
	i = strlen(str);
	for (i -= 1; 0 <= i; i--) {
		cout << str[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1136
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma GCC diagnostic ignored "-Wunused-result"

#include <cstdio>
#include <chrono>
#include <random>
using namespace std;
using namespace chrono;

constexpr int c_max = 26;
constexpr int D = 365;
constexpr int INF = 1e9;
constexpr int time_limit = 1980;

int c[c_max];
int s[D][c_max];
int best_score[D];
int last[c_max];
int schedule[D];

inline int calc_score(const int &day, const int &examining) {
  int ret;
  if (day == 0) ret = s[day][examining];
  else ret = best_score[day - 1] + s[day][examining];
  
  for (int i = 0; i < c_max; i++) {
    if (i == examining) continue;
    ret -= (day - last[i]) * c[i];
  }

  return ret;
}

inline int calc_score_diff(const int &day1, const int &day2) {
  int prev_interval_1 = 0;
  for (int i = day1 - 1; i >= 0; i--) {
    prev_interval_1++;
    if (schedule[i] == schedule[day1]) break;
  }

  int prev_interval_2 = 0;
  for (int i = day2 - 1; i >= 0; i--) {
    prev_interval_2++;
    if (schedule[i] == schedule[day2]) break;
  }

  int new_interval_1 = 0;
  for (int i = day2 - 1; i >= 0; i--) {
    new_interval_1++;
    if (schedule[i] == schedule[day1]) break;
  }

  int new_interval_2 = 0;
  for (int i = day1 - 1; i >= 0; i--) {
    new_interval_2++;
    if (schedule[i] == schedule[day2]) break;
  }

  int ret = s[day1][schedule[day2]]
          + s[day2][schedule[day1]]
          - s[day1][schedule[day1]]
          - s[day2][schedule[day2]];
  
  ret += c[day1] * ((prev_interval_1 + 1) * prev_interval_1 - (new_interval_1 + 1) * new_interval_1) / 2;
  ret += c[day2] * ((prev_interval_2 + 1) * prev_interval_2 - (new_interval_2 + 1) * new_interval_2) / 2;

  return ret;
}

int main() {
  system_clock::time_point start = system_clock::now(), now;

  random_device seed;
  mt19937 rnd(seed());

  /* input */
  scanf("%*d");

  for (int i = 0; i < c_max; i++) {
    scanf("%d", &c[i]);
  }

  for (int i = 0; i < D; i++) {
    for (int j = 0; j < c_max; j++) {
      scanf("%d", &s[i][j]);
    }
  }

  /* calc initial solution */
  for (int d = 0; d < D; d++) {
    int best = -INF;
    int contest_to_hold = 0;
    for (int type = 0; type < c_max; type++) {
      int score = calc_score(d, type);
      if (best < score) {
        best = score;
        contest_to_hold = type;
      }
    }
    last[contest_to_hold] = d;
    schedule[d] = contest_to_hold;
  }

  /* try and error */
  int day1, day2, score_diff;
  while (1) {
    now = system_clock::now();
    if (duration_cast<milliseconds>(now - start).count() > time_limit) break;
    day1 = rnd() % D;
    day2 = rnd() % D;
    score_diff = calc_score_diff(day1, day2);
    if (score_diff > 0) {
      swap(schedule[day1], schedule[day2]);
    }
  }

  /* output */
  for (const int &x : schedule) {
    printf("%d\n", x+1);
  }

  return 0;
}

Measured memory_bytes: 3412
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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 COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




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

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  while(1){
    ll n,m;
    cin>>n>>m;
    if(n==0 && m==0) return 0;
    vector<ll> v(n),ans;
    rep(i,n) cin>>v[i];
    rep(i,n-1){
      for(ll j=i+1;j<n;j++){
        if(v[i]+v[j]<=m) ans.push_back(v[i]+v[j]);
      }
    }
    if(ans.size()>=1){
      sort(ALL(ans),greater<ll>());
      cout<<ans[0]<<endl;
    }else{
      cout<<"NONE"<<endl;
    }
  }
}


Measured memory_bytes: 10800
s = list(str(input()))
t = list(str(input()))
s_dict = {}
count = 0
for s_ in s:
    if s_ not in s_dict.keys():
        s_dict[s_] = count
        count += 1
t_dict = {}
count = 0
for t_ in t:
    if t_ not in t_dict.keys():
        t_dict[t_] = count
        count += 1
s = [s_dict[i] for i in s]
t = [t_dict[i] for i in t]
if s == t:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 8240
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<tuple>

//AtCoderC++.cpp

using namespace std;

template<typename T> void Show(const vector<vector<T>>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(const vector<T>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (!ts[i][j])return false;
	return true;
}

vector<string> split(string& content, char delim) {
	auto ss = vector<string>();
	string s = "";
	for (size_t i = 0; i < content.length(); i++) {
		if (content[i] == delim) {
			ss.push_back(s);
			s = "";
			continue;
		}
		s += content[i];
	}
	if (s != "")ss.push_back(s);
	return ss;
}

int main() {
	int N; cin >> N;
	auto hs = vector<int>(N);
	for (size_t i = 0; i < N; i++)cin >> hs[i];
	int max = hs[0]; 
	int count = 0;
	for (size_t i = 0; i < N; i++) {
		if (max <= hs[i]) {
			count++;
			max = hs[i];
		}
	}
	cout << count << endl;
}



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

bool isPalindrome(string str) {
	for (int i = 0; i < str.length()/2 ; i++) {
		if (str[i] != str[str.length() - 1 - i]) {
			return false;
		}
	}
	return true;
}

int main() {
	int A, B;
	int ans = 0;
	
	cin >> A >> B;

	for (int i = A; i <= B; i++) {
		if (isPalindrome(to_string(i))) {
			ans++;
		}
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
 
namespace Application
{
	class Solution
	{
		static void Main(string[] args)
		{
			var inputWords = Console.ReadLine().Split(' ');
 
			var rangeMax = int.Parse(inputWords[0]);
			var min = int.Parse(inputWords[1]);
			var max = int.Parse(inputWords[2]);
 
			var result = 0;
			for(var i=1; i <= rangeMax; i++)
			{
				var sum = GetEachDigitSum(i);
				if (min <= sum && sum <= max)
					result += i;
			}
 
			Console.WriteLine(result);
		}
 
		// 数値の各桁の合計値を取得する
		static int GetEachDigitSum(int number)
		{
			var sum = 0;
			while (number != 0)
			{
				sum += number % 10;
				number /= 10;
			}
 
			return sum;
		}
	}
}

Measured memory_bytes: 13140
import sys
import math

count = 0
judge = 0

for line in sys.stdin.readlines():
    num = int(line.strip())
    if judge == 0:
        judge = 1
    else:    
        flag = 0
        for i in range(2, int(math.sqrt(num)) + 1):
            if num % i == 0:
                flag = 1
                break
        if flag == 0:
            count += 1

print count

Measured memory_bytes: 7224
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e7+7;
int n, cnt[N];
main() {
    cin >> n;
    int ans = 0;
    for(int i=1; i<=n; i++) {
        for(int j=i; j<=n; j+=i)
            ans += j;
    }
    cout << ans;
} 

Measured memory_bytes: 3676
S = input()
MOD = 10**9 + 7

dp = [[0] * 13 for _ in range(2)]
dp[0][0] = 1

n = len(S)
for i in range(n):
    if i == 0:
        mod_array = [i for i in range(10)]
    else:
        mod_array = [i * 10 % 13 for i in mod_array]
    s = S[n-i-1]
    if s == '?':
        for a in mod_array:
            for k in range(13):
                dp[1][(k+a)%13] += dp[0][k]
    else:
        a = mod_array[int(s)]
        for k in range(13):
            dp[1][(k + a) % 13] += dp[0][k]
    for k in range(13):
        dp[0][k] = dp[1][k] % MOD
        dp[1][k] = 0

print(dp[0][5])




Measured memory_bytes: 44884
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int W, H, sx, sy, cnt;
vector<int> dxy;
string field[20];

void fun(int y, int x){
    field[y][x] = '#';
    cnt++;
    for(int i=0; i<4; ++i){
        int ny = y + dxy[i+1],
            nx = x + dxy[i];
        if(ny < 0 || ny >= H ||nx < 0 || nx >= W || field[ny][nx] != '.') continue;
        fun(ny, nx);
    }
}
    
int main(){
    dxy.push_back(1);
    dxy.push_back(0);
    dxy.push_back(-1);
    dxy.push_back(0);
    dxy.push_back(1);
    while(cin >> W >> H, (W||H)){
        cnt = 0;
        string str;
        cin.ignore();
        for(int i=0; i<H; ++i){
            cin >> field[i];
        }

        for(int i=0; i<H; ++i){
            for(int j=0; j<W; ++j){
                if(field[i][j] == '@'){
                    sx = j; sy = i;
                }
            }
        }
        
        fun(sy, sx);
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3252
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
 
using namespace std;
#define inf 0x3f3f3f3f
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mp make_pair
#define pb push_back
#define sz(v) (int)v.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
 
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
const int N=1e5+7;
ll n,m,x,y,k,ans;
 
int main(){
    fast;
    char s[N];
    cin>>s>>k;
    n=strlen(s);
    forn(i,n){
        if('z'-s[i]+1<=k&&s[i]!='a'){
            k-='z'-s[i]+1;
            s[i]='a';
            //cout<<k<<endl;
        }
    }
    s[n-1]=k%26+s[n-1];
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 512