akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;};
  Mint operator-(Mint a) const{return Mint(v)-=a;};
  Mint operator*(Mint a) const{return Mint(v)*=a;};
  Mint operator/(Mint a) const{return Mint(v)/=a;};

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,Int k){
    Mint num(1),dom(1);
    for(Int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n,k;
  cin>>n>>k;

  const Int B = min(n,50000LL);

  using P = pair<Int, Int>;
  vector<P> vp;
  for(Int i=1;i<B;i++)
    vp.emplace_back(i,1);

  Int st=B;
  while(st<=n){
    Int l=st,r=n+1;
    while(l+1<r){
      Int m=(l+r)>>1;
      if((n/m)==(n/st)) l=m;
      else r=m;
    }
    //cout<<st<<":"<<l<<" "<<r<<endl;
    vp.emplace_back(l,r-st);
    st=r;
  }
  vp.emplace_back(n+1,0);

  using M = Mint<Int>;
  Int m=vp.size();
  vector<M> dp(m,1);
  dp[m-1]=0;

  for(Int i=0;i+1<k;i++){
    vector<M> sm(m+1,0);
    for(Int i=0;i<m;i++) sm[i+1]=sm[i]+dp[i]*M(vp[i].second);
    vector<M> nx(m,0);
    for(Int j=0,k=m-1;j<m;j++){
      while(k>0&&vp[j].first*vp[k-1].first>n) k--;
      //cout<<j<<" "<<k<<":"<<vp[j].first<<" "<<vp[k].first<<endl;
      //cout<<n<<":"<<vp[j].first*vp[k-1].first<<":"<<vp[j].first*vp[k].first<<endl;
      nx[j]=sm[k];
    }
    swap(dp,nx);
  }

  M ans{0};
  for(Int i=0;i<m;i++) ans+=dp[i]*M(vp[i].second);
  cout<<ans<<endl;
  return 0;
}


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

#define el '\n'

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

  int n, k;
  cin >> n >> k;
  int a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  bool dp[k+1]; // state of 1st player at stone k, can he win or not
  memset(dp, 0, sizeof(dp));
  for(int stone = 0; stone <= k; stone++){
    for(int i = 0; i < n; i++){
      if(stone-a[i] >= 0 && !dp[stone-a[i]]){
        dp[stone] = true;
      }
    }
  }
  dp[k] ? cout << "First" << el : cout << "Second" << el;
  
  return 0;
}

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

int main() {
	int x1,x2,x3,x4,x5;
	cin>>x1>>x2>>x3>>x4>>x5;
	int sum=0;
	sum=x1+x2+x3+x4+x5;
	sum=15-sum;
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<math.h>

int main(){
  double a,b,c,d,X,Y,k,x,y;

  scanf("%lf %lf %lf %lf",&a,&b,&c,&d);

  if(a>c){
    x=a-c;
  }else if(a<c){
    x=c-a;
  }
  if(b>d){
    y=b-d;
  }else if(b<d){
    y=d-b;
  }

  X=x*x;
  Y=y*y;
  k=X+Y;

  double z=sqrt(k);

  printf("%f\n",z);

  return 0;
}
  

  
    

  
  

Measured memory_bytes: 1080
def show(A, n):
    for i in range(n):
        if i != n-1:
            print(A[i], end=' ')
        else:
            print(A[i])


def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        c = a % b
        a = b
        b = c
    return b


def main():
    a, b = list(map(int, input().split()))

    print(gcd(a, b))


if __name__ == "__main__":
    main()


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];

    sort(h.begin(), h.end());
    ll res = h[k-1] - h[0];
    rep1(i, n-k+1){
        res = min(res, h[k+i-1]-h[i]);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////


ll a,b,c,d[100005] = {},n,m;
string s,t;

int main(){

    int x,y;
    cin >> x >>y;
    d[1] = 300000;
    d[2] = 200000;
    d[3] = 100000;

    int ans = d[x] + d[y];

    if(x == 1 && y == 1)P(ans + 400000);
    else P(ans);
    return  0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
hs = list(map(int, input().split()))

total_cost = [-1 for i in range(N)]

total_cost[0] = 0
total_cost[1] = abs(hs[1] - hs[0])

for i in range(2, N):
  for k in range(1, K+1):
    if total_cost[i] == -1:
      total_cost[i] = total_cost[i-k] + abs(hs[i] - hs[i-k])
    else:
      total_cost[i] = min(total_cost[i], total_cost[i-k] + abs(hs[i] - hs[i-k]))
    if i == k:
      break

print(total_cost[N-1])


Measured memory_bytes: 56544
#include <stdio.h>
int main(void)
{
	int tall[10];
	int a,b,c,i;
	a=0;
	b=0;
	c=0;
	for (i=0 ; i<=9 ; i++){
		scanf("%d",&tall[i]);
		if(a<=tall[i]){
			c=b;
			b=a;
			a=tall[i];
		}
		else if(b<=tall[i]){
			c=b;
			b=tall[i];
		}
		else if(c<=tall[i]){
			c=tall[i];
		}
	}
	printf("%d\n%d\n%d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 1816
#include <stdio.h>

int main(void)
{

  int N;

  scanf ("%d", &N);

  int x=N%10;
  int y=(N-x)/10;

  if (x==9) {
    printf ("Yes"); }

  else if (y==9) {
    printf ("Yes"); }

  else {
    printf ("No"); }

  return (0);
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
N, A, B, C = map(int, input().split())
mod = 10 ** 9 + 7
t = pow(A + B, mod - 2, mod)

class Factorial:
  def __init__(self, n, mod):
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % mod * self.i[k] % mod
f = Factorial(N * 2, mod)
res = 0
for x in range(N):
  res += (N + x) * f.combi(N + x - 1, x) % mod * pow(A, N, mod) % mod * pow(B, x, mod) % mod * pow(t, N + x, mod) % mod * 100 * t % mod
  res %= mod
  res += (N + x) * f.combi(N + x - 1, x) % mod * pow(A, x, mod) % mod * pow(B, N, mod) % mod * pow(t, N + x, mod) % mod * 100 * t % mod
  res %= mod
print(res)

Measured memory_bytes: 55664
import math
n = [0,0,1] + [1 for _ in range(10**5-2)]

def check_prime(x):
    for i in range(x*2,10**5+1,x):
        n[i] = 0

check_prime(2)
for i in range(3,int(math.sqrt(10**5))+1,2):
    check_prime(i)

c = [0 for _ in range(10**5+1)]
for i in range(1,10**5+1):
    c[i] = c[i-1] + (n[i] * n[(i+1)//2])

for _ in range(int(input())):
    l,r = map(int,input().split())
    ans = c[r] - c[l-1]
    print (ans)


Measured memory_bytes: 52384
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>
#include <tuple>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MT make_tuple
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = 1e9;

struct Edge{
  int to, cost;

  Edge(int t, int c): to(t), cost(c)
  {}
  bool operator>(const Edge& rhs) const{
	return cost > rhs.cost;
  }
};
typedef vector< vector<Edge> > Graph;

int N, M, C, SZ;
vector<Edge> G[6010];

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

  while(cin>>N>>M>>C,N){
	map<string,int> cor;
	string src, dest; cin >> src >> dest;
	SZ = 0;
	cor[src] = SZ++;
	cor[dest] = SZ++;
	C *= 10;
	REP(i,6010) G[i].clear();
	REP(i,N){
	  string s1, s2; int d;
	  cin >> s1 >> s2 >> d;
	  if(!cor.count(s1)) cor[s1] = SZ++;
	  if(!cor.count(s2)) cor[s2] = SZ++;
	  int u = cor[s1], v = cor[s2];
	  G[u].PB(Edge(v,d));
	  G[v].PB(Edge(u,d));
	}

	set<int> LPG;
	REP(i,M){
	  string s; cin >> s;
	  if(!cor.count(s)) continue;
	  LPG.insert(cor[s]);
	}

	typedef tuple<int,int,int> Node;
	priority_queue<Node, vector<Node>, greater<Node> > pq;
	VVI dist(SZ+10, VI(C+10,INF));
	dist[0][C] = 0;
	pq.push(MT(0,0,C));

	int ans = INF;
	while(!pq.empty()){
	  auto tp = pq.top(); pq.pop();
	  int c, v, f;
	  tie(c,v,f) = tp;

	  if(v == 1){
		ans = c; break;
	  }
	  if(dist[v][f] < c) continue;
	  for(auto& e: G[v]){
		int d = e.cost;
		if(f < d) continue;
		int nf = LPG.count(e.to)? C: f-d;
		if(dist[e.to][nf] > dist[v][f] + d){
		  dist[e.to][nf] = dist[v][f] + d;
		  pq.push(MT(dist[e.to][nf], e.to, nf));
		}
	  }
	}

	cout << (ans==INF? -1: ans) << endl;
  }

  return 0;
}

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

#define rep(i, n) for(int i=0; i < (n); ++i)
#define ll long long

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s, t; cin >> n >> s >> t;

    rep(i,n) {
        cout << s[i] << t[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int z=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]<a[i-1])
        {
            z+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<z;
    
}

Measured memory_bytes: 5180
/* This code is written by Nemlit */
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define rep(i, a, b) for(re int i = (a); i <= (b); ++ i)
#define drep(i, a, b) for(re int i = (b); i >= (a); -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define int long long
#define D double
#define inf 1023456789
#define mod 1000000007
#define lb(x) (x)&(-(x))
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
#define maxn 200005
namespace Graph {
	int head[maxn], cnt;
	struct edge { int v, next; }e[maxn << 1];
	il void add(int u, int v) { e[++ cnt] = (edge){v, head[u]}, head[u] = cnt; }
}
//using namespace Graph;
int n, m, sum[maxn * 44], rt, a[maxn], cnt, L = -200000, R = (1e9) + 200000, ls[maxn * 44], rs[maxn * 44];
il void insert(int &k, int l, int r, int ll) {
	if(!k) k = ++ cnt; ++ sum[k];
	if(l == r) return;
	int mid = (l + r) >> 1;
	if(ll <= mid) insert(ls[k], l, mid, ll);
	else insert(rs[k], mid + 1, r, ll);
}
il int query(int k, int l, int r, int ll) {
	if(l == r) return sum[k];
	int mid = (l + r) >> 1;
	if(ll <= mid) return query(ls[k], l, mid, ll);
	else return query(rs[k], mid + 1, r, ll);
}
signed main() {
	n = read();
	rep(i, 1, n) a[i] = read();
	rep(i, 1, n) {
		m += query(1, L, R, i - a[i]);
		insert(rt, L, R, i + a[i]);
	}
	cout << m;
	return 0;
}


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

int main() {
    string str;
    cin >> str;
	string tmp = str;
    for (int i = 1; i < str.size(); i++){
        string test = tmp.erase(tmp.size() - 1);
        if (test.size() % 2 != 0){
            continue;
        }
        string s1, s2;
        s1 = test.substr(0, test.size() / 2);
        s2 = test.substr(test.size()/2);
        if(s1 == s2){
            cout << test.size() << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

#define FOR(i,a,b) for(long long int i =(a); i <(b);i++)
#define REP(i,N)   FOR(i,0,N)
using namespace std;

int town[100000];

int main(void){

    int N;
    int walkCost,telpCost;
    cin >> N >> walkCost >> telpCost;

    REP(i,N){
        cin >> town[i];
    }

    long long int ans = 0;
    REP(i,N-1){
        long long int dist = town[i+1] - town[i];
        long long int tiredW = dist*walkCost;
        long long int tiredT = telpCost;
        ans += min(tiredT,tiredW);
    }

    cout << ans << endl;

    return 0;
}


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

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

  vector<ll> div;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      div.push_back(i);
      if (i != n / i) div.push_back(n / i);
    }
  }

  ll ans = 0;
  for (auto x : div) {
    ll m = n / x - 1;
    if (m == 0) continue;
    if (n / m == n % m) ans += m;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,x,n;
    cin>>n>>k;
    set<int>s1;
    for(int i=1;i<=k;i++){
        cin>>x;
        s1.insert(x);
    }
    int s[10],r=0;
    while(n!=0){
        int t=n%10;
        s[r++]=t;
        n=n/10;
    }
    reverse(s,s+r);
    int y=0,i;
    //r=s.size();
    for(i=0;i<r;i++){
        //d=s[i]-'0';
        if(!s1.count(s[i]))
            y++;
        else
            break;
    }
    int h=s[0];
    while(1){
        if(!s1.count(h)){
            break;
        }
        else
            h++;
    }
    if(y==r){
        for(int i=0;i<r;i++)
            cout<<s[i];
    }
    else if(h>9){
        for(int i=1;i<10;i++){
            if(!s1.count(i)){
                cout<<i;
                break;
            }
        }
        for(int i=1;i<=r;i++){
            for(int j=0;j<10;j++){
                if(!s1.count(j)){
                    cout<<j;
                    break;
                }
            }
        }
    }
    else{
        //cout<<i;
        for(int j=i;j>=0;j--){
            //d=s[j]-'0';
            //cout<<d<<endl;
            for(int l=s[j]+1;l<10;l++){
                if(!s1.count(l)){
                    for(int i=0;i<j;i++)
                        cout<<s[i];

                    cout<<l;
                    for(int i=j+1;i<r;i++){
                        //int d=s[i]-'0';
                        for(int p=0;p<10;p++){
                            if(!s1.count(p)){
                                cout<<p;
                                break;
                            }
                        }
                    }
                    return 0;
                }
            }
        }
        for(int i=1;i<10;i++){
            if(!s1.count(i)){
                cout<<i;
                break;
            }
        }
        for(int i=1;i<=r;i++){
            for(int j=0;j<10;j++){
                if(!s1.count(j)){
                    cout<<j;
                    break;
                }
            }
        }
    }

}


Measured memory_bytes: 3588
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define anal         '\n'
#define mod 1000000007
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
  

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
      
int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
      freopen("input.in", "r", stdin);
      freopen("output.in", "w", stdout);
#endif 

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
          
       int n, k;
       cin >> n >> k;
       int arr[n];
       for(int i = 0; i < n; i++) cin >> arr[i];
        sort(arr, arr + n);
        int ans = 0;
        for(int i = 0; i < k; i++){
           ans += arr[i];
        }
        cout << ans;
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
printclock; 
return  0 ;      
}        



   

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

int M,N;
int V = 1010;//頂点数
const int MAX_V = 1010;
int B[505];
int R[505];
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u, int v) {
	G[u].push_back(v);
	G[v].push_back(u);
}
bool dfs(int v) {
	used[v] = true;
	for (int i = 0; i < G[v].size(); i++) {
		int u = G[v][i], w = match[u];
		if (w < 0 or !used[w] and dfs(w)) {
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int bipairetite_matching() {
	int res = 0;
	memset(match, -1, sizeof(match));
	for (int v = 0; v < V; v++) {
		if (match[v] < 0) {
			memset(used, 0, sizeof(used));
			if (dfs(v)) {
				res++;
			}
		}
	}
	return res;
}

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

int main() {
	while(cin >> M >> N, M) {
		rep(i, 1010) G[i].clear();
		rep(i, M) {
			cin >> B[i];
		}
		rep(i, N) {
			cin >> R[i];
		}
		rep(m, M) {
			rep(n, N) {
				if (gcd(B[m], R[n]) > 1) {
					add_edge(m, n + M);
				}
			}
		}
		cout << bipairetite_matching() << endl;
	}
}
	


Measured memory_bytes: 4860
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long lint; using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define rep(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  int n;
  cin>>n;
  int i=1;
  while(true){
    i*=2;
    if(i >= n){
      if(i!=n){
        cout<<i/2<<endl;
      }else{
        cout<<i<<endl;
      }
      return 0;
    }
  }

}


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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int h,a;
	cin >> h >> a;
	vector<int>v;
	for(int i=0;i<a;i++){
		int l;cin>>l;
		v.push_back(l);
	}
	
	int sums = accumulate(v.begin(),v.end(),0);
	cout << (sums >= h ? "Yes" : "No")<< endl;
	return 0;
}


Measured memory_bytes: 892
//皆さん、第9回シンデレラガール総選挙は、トップでオンリーワンを目指す城ヶ崎美嘉に
//そしてボイスアイドルオーディションは、プログラミングが趣味の才女大石泉に、ぜひ投票をお願いします！
//#城ヶ崎美嘉を009のシンデレラに
//#大石泉の必勝プログラム
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int x[100100][2];
int a[5];
vector<int> out;
bool cal()
{
	int n;string s;
	cin>>n>>a[0]>>a[1]>>a[2];
	rep(i,n){
		cin>>s;
		x[i][0]=(s[0]-'A');
		x[i][1]=(s[1]-'A');
	}
	if(a[x[0][0]]+a[x[0][1]]<1){
		return false;
	}
	rep(i,n){
		//cout<<a[0]<<a[1]<<a[2]<<endl;
		int p;
		if(a[x[i][0]]>a[x[i][1]]) swap(x[i][0],x[i][1]);
		if(i<n-1 && x[i][1]==x[i+1][1]) swap(x[i+1][0],x[i+1][1]);
		if(i<n-1 && a[x[i][1]]==1 && x[i][1]==x[i+1][0] && a[x[i+1][1]]==0 && x[i+1][1]!=x[i][0]) p=1;
		else p=0;
		//cout<<x[i][0]<<' '<<x[i][1]<<' '<<x[i][p]<<endl;
		out.pb(x[i][p]);a[x[i][p]]++;a[x[i][1-p]]--;
		if(a[0]<0 || a[1]<0 || a[2]<0) return false;
	}
	return true;
}
int main()
{
	char c='A';
	if(!cal()) cout<<"No"<<endl;
	else{
		cout<<"Yes"<<endl;
		rep(i,(int)out.size()) cout<<char(c+out[i])<<endl;
	}
}


Measured memory_bytes: 4708
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 0;										/* デバッグプリント 提出時は0 */
int main()
{
	int		i,x,N;
	long long ans=0;
	int		h[10000],w[10000];

	scanf("%d", &N);
	for(i=1;i<=N;i++) {
		x = i;
		if (x%3 == 0) {
			printf(" %d",i);
		} else {
			do {
				if (x%10 == 3) {
					printf(" %d",i);
					break;
				}
				x /= 10;
			} while(x);
		}
	}
	ENTER;
	return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <stack>
#include <queue>

typedef long long ll;

using namespace std;

const ll MOD = 1e9 + 7;
const ll INF = 1e12;

int main(){
  ll i,j,k,n,m;
  string s;
  cin >> n;
  ll l;
  cin >> l;
  ll ret = 0;
  ll ma = 1000000;
  for (i = 1; i <= n; i++)
  {
      ret += l + i - 1;
      if(abs(ma)>abs(l+i-1))
          ma = l + i - 1;
  }
  cout << ret - ma << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll x,y,ans=0;
    cin>>x>>y;
    while(true){
        if(x>y) break;
        ans++;
        x*=2;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
 string S;
 cin >> S;
 if ( S.at(0) != S.at(1) && S.at(1) != S.at(2) && S.at(2) != S.at(3) ) {
  cout << "Good" << endl;
 }
 else{
  cout << "Bad" << endl;
 }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{

 int a, b;

 scanf("%d", &a);

 scanf("%d", &b);

 if(a > b){

 printf("a > b\n");

 }

 else if(a < b){

 printf("a < b\n");

 }

 else{

 printf("a == b\n");

 }

 return 0;

}

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

int f(int n){
	int sum = 0;
  	while(n > 0){
      sum += n%10;
      n /= 10;
    }
  return sum;
}

int main()
{
  int N, A, B;
  cin >> N>>A>>B;
  int total =0;
  for(int i=1;i<=N;++i){
    int sum =f(i);
    if(sum >=A && sum<= B){
      total +=i;
    }
  }
  cout << total << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}



int main()
{
    fastio();
    int r,D,x; cin>>r>>D>>x;
    rep(i,1,10){
        x = r*x - D;
        cout<<x<<endl;
    }
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vs s(h);
    rep(i, h) cin >> s[i];

    int ans = 0;
    rep(ybit, (1<<h)) rep(xbit, (1<<w)) {
        int cnt = 0;
        rep(i, h) rep(j, w) {
            if(ybit>>i&1) continue;
            if(xbit>>j&1) continue;
            if(s[i][j] == '#') cnt++;
        }
        if(cnt == k) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
   	public int maxHappiness(int[][] plan) {
        int n = plan.length;
        int[][] memo = new int[n][3];
        for (int[] row: memo) {
            Arrays.fill(row, -1);
        }
        int result = 0;
        for (int i = 0; i < 3; i++) {
            result = Math.max(result, dfs(plan, 0, i, memo));
        }
		return result;
	}
	private int dfs(int[][] plan, int day, int prevActivity, int[][] memo) {
		int n = plan.length;
		if (day == n) {
			return 0;
		}
        if (memo[day][prevActivity] != -1) {
            return memo[day][prevActivity];
        }
		int maxHappiness = 0;
		for (int i = 0; i < plan[day].length; i++) {
			if (i == prevActivity) {
				continue;
			}
			int currHappiness = plan[day][i] + dfs(plan, day + 1, i, memo);
			maxHappiness = Math.max(maxHappiness, currHappiness);
		}
		return memo[day][prevActivity] = maxHappiness;
	}

    public static void main(String[] args)  {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            int n = Integer.parseInt(br.readLine());
          	int[][] plan = new int[n][3];
            for (int i = 0; i < n; i++) {
                String[] split = br.readLine().split(" ");
                for (int j = 0; j < 3; j++) {
                    plan[i][j] = Integer.parseInt(split[j]);
                }
            }
          	Main app = new Main();
            int result = app.maxHappiness(plan);
            System.out.println(result);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 61124
import math
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

print(sum(abs(x[i]-y[i]) for i in range(n)))
print(sum((abs(x[i]-y[i]) ** 2) for i in range(n)) ** 0.5)
print(sum((abs(x[i]-y[i]) ** 3) for i in range(n)) ** (1/3))
print(max(abs(x[i] - y[i]) for i in range(n)))


Measured memory_bytes: 5708
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i

a % 10 == 0 ? a1=10 : a1=a%10
b % 10 == 0 ? b1=10 : b1=b%10
c % 10 == 0 ? c1=10 : c1=c%10
d % 10 == 0 ? d1=10 : d1=d%10
e % 10 == 0 ? e1=10 : e1=e%10

ary1 = [a1,b1,c1,d1,e1]
min1 = ary1.min
ary = []
last = 0

if min1 == a1
  ary = [b,c,d,e]
  last = a
elsif min1 == b1
  ary = [a,c,d,e]
  last = b
elsif min1 == c1
  ary = [a,b,d,e]
  last = c
elsif min1 == d1
  ary = [a,b,c,e]
  last = d
elsif min1 == e1
  ary = [a,b,c,d]
  last = e
end

ceil = 10
sum = 0

ary = ary.sort
ary.each do |x|
  loop do
    if x <= ceil
      sum += ceil 
      break
    else
      ceil += 10
    end
  end
end

sum += last
p sum



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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i = 0; i<n ; i++){
    cin >> s.at(i);
  }
  
  int y = 0;
  
  for(int i = 0 ; i < n-1; i++){
    for(int j = i+1 ; j<n ; j++){
      if(s.at(i) == s.at(j)){
       y = 1;
      }   
    }
  }
  
  for(int i = 0 ; i<n-1; i++){
    int x;
    x = s.at(i).size();
    if(s.at(i).at(x-1) != s.at(i+1).at(0)){
      y = 1;
      break;
    }
  }
  
  if(y == 1){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

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

int main() {
    int N=0,T=0,mini=1001;
    cin >> N >> T;
    for(int i=0; i<N; i++){
        int cost=0,t=0;
        cin >> cost >> t;
        if(t<=T && cost<mini)mini = cost;
    }
    if(mini == 1001){
        cout << "TLE" << endl;
        return 0;
    }
    cout << mini << endl;
    return 0;
}

Measured memory_bytes: 764
A = int(input())
B = int(input())
C = int(input())
X = int(input())

res=0

for  i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if 500*i + 100*j + 50*k == X:
                res += 1
print(res)

Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A, B, C, D = [int(x) for x in input().split()]

    MOD = 998244353

    dp = [[0] * (D - B + 1) for j in range(C - A + 1)]

    for j in range(C - A + 1):
        if j == 0:
            dp[j][0] = 1
        else:
            dp[j][0] = pow(B, j, MOD)
        for i in range(1, D - B + 1):
            if j == 0:
                dp[j][i] = dp[j][i - 1] * (A + j) % MOD
            else:
                dp[j][i] = (dp[j][i - 1] * (A + j) + (B + i) * dp[j - 1][i] - dp[j - 1][i - 1] * (
                            (A + j - 1) * (B + i - 1))) % MOD

    print(dp[-1][-1] % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 138372
N = gets.to_i
MOD = 10 ** 9 + 7
dp = Array.new(N + 1) { Hash.new { 0 } }
dp[0][''] = 1

def included_agc(ss, ch)
  return false if ss.size <= 1
  return true if (ss[-2..-1] + [ch]).join('') == 'AGC'
  new_ss = ss + [ch]
  (0..(new_ss.size - 2)).any? do |i|
    ts = new_ss.dup
    t = ts[i + 1]
    ts[i + 1] = ts[i]
    ts[i] = t
    ns = (ts + [ch]).join('')
    ns.include?('AGC')
  end
end

N.times do |i|
  dp[i].keys.each do |s|
    ss = s.chars
    %w[A C G T].each do |ch|
      unless included_agc(ss, ch)
        new_s = if ss.size <= 1
          s + ch
        else
          (ss[-2..-1] + [ch]).join('')
        end
        dp[i + 1][new_s] += dp[i][s] % MOD
      end
    end
  end
end
ans = dp[N].values.reduce(0) do |acc, n|
  (acc + n) % MOD
end
puts ans


Measured memory_bytes: 2684
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
using namespace std;
int main()
{
    int N, L, min = 100000000;
    cin >> N >> L;
    vector<int> A(N);
    int sum = 0;
    rep(i, N)
    {
        A[i] = L + i;
        sum += A[i];
    }
    int Z, ans;
    rep(i, N)
    {
        Z = abs(sum - (sum - A[i]));
        if (min > Z)
        {
            min = Z;
            ans = sum - A[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextIntArray()

	sort.Ints(A)
	Q := 0
	W := 0
	for i := N - 1; i >= 0; i -= 2 {
		Q += A[i]
	}
	for i := N - 2; i >= 0; i -= 2 {
		W += A[i]
	}
	fmt.Println(Q - W)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;
typedef long long ll;

ll func(ll m){
    if(m<=1){
        return 0;
    }

    ll sum = 0;
    for(ll i=m/2; i<m; i++){
        sum += i;
    }
    return sum + func(m/2);
}

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

    ll sum = 0;
    sum = func(n);

    cout << sum << endl;
}

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

vector<int>ans;

ll N, A, B;
void ind(){
    for (int i = 0; i < A; ++i) {
        ans.push_back(N - A + 1 + i);
    }
    N -= A; B--;
}

void solve(){
    for (int i = B; i <= N; ++i) {
        ans.push_back(i);
    }
    for (int i = B - 1; i > 0; --i) {
        ans.push_back(i);
    }
}

int main() {
    cin >> N >> A >> B;
    ans.reserve(N);

    if (N + 1 < A + B || N > A * B) {
        cout << -1 << "\n";
        return 0;
    }

    int flag = 0;
    if (A < B) {
        flag = 1;
        ll temp = A;
        A = B;
        B = temp;
    }

    if (N < A * 2) {
        ind();
    } else {
        while (N > A * 2) {
            ind();
        }

        for (int i = A + 1; i <= N; ++i) {
            ans.push_back(i);
        }
        N = A;
        B--;
    }

    if (B) solve();
    if (flag) reverse(ans.begin(), ans.end());
    for (int x: ans) cout << x << " ";
    cout << "\n";
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main(void)
{
	int N;
	int a[101];
	
	cin >> N;
	for(int i = 0; i < N; i++) cin >> a[i];
	
	int min = 1001, max = -1;
	for(int i = 0; i < N; i++){
		if(min > a[i]) min = a[i];
		if(max < a[i]) max = a[i];
	}
	
	cout << max - min;
	return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
  
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int A, B, M;
    cin >> A >> B >> M;
    int a[A], b[B];
    int v1 = inf, v2 = inf;
    rep(i, 0, A) {
        cin >> a[i];
        setmin(v1, a[i]);
    }
    rep(i, 0, B) {
        cin >> b[i];
        setmin(v2, b[i]);
    }
    int ans = v1 + v2;
    rep(i, 0, M) {
        int x, y, c;
        cin >> x >> y >> c; x--; y--;
        setmin(ans, a[x] + b[y] - c);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.print(a * b + " ");
        System.out.println(2 * a + 2 * b);
    }
}


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

int main(void) {
    int N;cin>>N;
    int p[N+1];
    p[0] = 0;
    for (int i = 1; i <= N; i++) cin>>p[i];
    int result = 0;
    for (int i = 1; i <= N; i++) {
        if (i == p[i]) {
            if (i < N) swap(p[i], p[i+1]);
            if (i == N) swap(p[i-1], p[i]);
            result++;
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 640
# フェルマーの小定理
X, Y = map(int, input().split())

m = 1000000007
def mcomb(n, k):
    a = 1
    b = 1
    for i in range(k):
        a *= n - i
        a %= m
        b *= i + 1
        b %= m
    return a * pow(b, m - 2, m) % m
if (X + Y) % 3 != 0:
    print(0)
    exit()

a = (2 * Y - X) // 3
b = (2 * X - Y) // 3

if a < 0 or b < 0:
    print(0)
    exit()

n = a + b
print(mcomb(n, a))


Measured memory_bytes: 9176
n, m = map(int, input().split())
l = [list(map(int, input().split(' '))) for _ in range(m)]

for v in range(m):
    l[v].append(v)

l = sorted(l)


x = l[0][0]
y = 1

for i in range(m):
    if l[i][0] == x:
        l[i][1] = y
        y += 1
    else:
        y = 1
        l[i][1] = y
        y += 1
        x = l[i][0]

l = sorted(l, key=lambda i:(i[2]))

z = []
for j in range(m):
    z.append(str(l[j][0]).rjust(6,'0') + str(l[j][1]).rjust(6,'0'))

for k in range(m):
    print(z[k])

Measured memory_bytes: 39204