akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int n;
	cin >> n;
	
	ll ans(0);
	rep(i, n+1) {
		int c(0);
		int j = i;
		while (j) {
			j /= 10;
			c++;
		}
		if (c % 2 == 1) {
			ans++;
		}
	}
	cout << ans;
	return 0;

}

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

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    ll s;
    in1(s);

    ll prev = s;
    
    set<ll> p;
    p.insert(s);

    repse(i, 2, 10000000)
    {
        ll x = 0;
        if (prev % 2 == 0)
        {
            x = prev / 2;
        }
        else
        {
            x = 3 * prev + 1;
        }

        if (p.count(x) > 0)
        {
            outl(i);
            return 0;
        }

        prev = x;
        p.insert(prev);
    }

    return 0;
}


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

typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vstr;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define asd cout << "ok" << endl;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define trav(it, m) for(auto it = m.begin(); it it!= m.end(); it++)

const char nl = '\n';
const int MOD = 1e9 +7;
const ll INF = 1e19;
const ld PI = acos((ld)-1);
const int MX = 2e5 + 5;


bool comp(pair<string, pair<int, int> > a, pair<string, pair<int, int> > b){
  if(a.fi == b.fi) return a.se.fi > b.se.fi;
    return a.fi < b.fi;
}
int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);

  int n; cin >> n;
  vector< pair<string, pair<int, int> > > v;
  for(int i = 0; i <n; i++){
    string s; int x;
    cin >> s >> x;
    v.pb(mp(s, mp(x, i+1)));
  }
  sort(all(v), comp);
  for(auto u : v) cout << u.se.se << nl;

return 0;




}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>v(n);
  int flag=1;
  for(int i=0; i<n; i++){
    cin>>v[i];
    if(v[i]%2 == 0){
      if(v[i]%3 && v[i]%5){
        flag=0;
      }
    }
  }
  if(flag){
    cout<<"APPROVED";
  }
  else{
    cout<<"DENIED";}
}


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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var ss = Console.ReadLine().Split();
            var A = new int[N];
            for (int i = 0; i < N; i++)
                A[i] = int.Parse(ss[i]);

            Array.Sort(A);
            Array.Reverse(A);

            var x = new int[N - 1];
            var y = new int[N - 1];
            var xI = 0;
            var yI = 0;

            var lastPlus = 0;
            for (int i = 1; i < N; i++)
            {
                if (A[i] > 0)
                {
                    if (i == N - 1)
                    {
                        lastPlus = i;
                    }
                    continue;
                }
                else
                {
                    lastPlus = i - 1;
                    break;
                }
            }

            var sum1 = A[A.Length - 1];
            var startI = (lastPlus == A.Length - 1) ? lastPlus - 1 : lastPlus;
            for (int i = startI; i >= 1; i--)
            {
                x[xI++] = sum1;
                y[yI++] = A[i];
                sum1 -= A[i];
            }
            var sum2 = A[0];
            for (int i = lastPlus + 1; i < A.Length - 1; i++)
            {
                x[xI++] = sum2;
                y[yI++] = A[i];
                sum2 -= A[i];
            }
            x[xI] = sum2;
            y[yI] = sum1;

            Console.WriteLine(sum2 - sum1);
            for (int i = 0; i <= xI; i++)
            {
                Console.WriteLine(x[i] + " " + y[i]);
            }
        }
    }
}

Measured memory_bytes: 27720
from _collections import defaultdict
import sys
import collections
import sys
sys.setrecursionlimit(10**6)


def get_ls():
    return list(map(int, input().split()))


def longest_path_util(node, graph, dp):

    res = 0

    if dp[node] != -1:
        return dp[node]

    for neib in graph[node]:
        res = max(res, longest_path_util(neib, graph, dp) + 1)

    dp[node] = res

    return dp[node]


graph = defaultdict(list)

[n, k] = get_ls()

dp = [-1] * n

for _ in range(k):
    [x, y] = get_ls()
    graph[x - 1].append(y - 1)

ans = 0

for i in range(n):
    ans = max(ans, longest_path_util(i, graph, dp))

print(ans)






Measured memory_bytes: 74076
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
anslist = []

for i in range(1,n-1):
  if a[i] < 0:
    anslist.append([a[-1], a[i]])
    a[-1] -= a[i]
  else:
    anslist.append([a[0], a[i]])
    a[0] -= a[i]
anslist.append([a[-1], a[0]])
ans = a[-1]-a[0]
print(ans)
for i in range(len(anslist)):
  print(anslist[i][0], anslist[i][1])
    
  
      


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

using Lint=long long;

template<int mod> class ModInt
{
 private:
    Lint val;
 public:
    Lint value(){ return val; }
    ModInt(Lint x=0){ val=x%mod; }
    ModInt pow(int n){
        ModInt res(1),x(val);
        while(n>0){ if(n&1) res*=x; x*=x; n>>=1; }
        return res;
    }
    ModInt inv(){ return pow(mod-2); }
    ModInt& operator+=(ModInt rhs){ val+=rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator-=(ModInt rhs){ val+=mod-rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator*=(ModInt rhs){ val=val*rhs.val%mod; return *this; }
    ModInt& operator/=(ModInt rhs){ *this*=rhs.inv(); return *this; }
    ModInt operator+(ModInt rhs){ return ModInt(val)+=rhs; }
    ModInt operator-(ModInt rhs){ return ModInt(val)-=rhs; }
    ModInt operator*(ModInt rhs){ return ModInt(val)*=rhs; }
    ModInt operator/(ModInt rhs){ return ModInt(val)/=rhs; }
};
using mint=ModInt<1000000007>;

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

   vector<vector<mint>> dp(H,vector<mint>(W));
   dp[0][0]=1;
   for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(s[i][j]=='.'){
      if(i+1<H and s[i+1][j]=='.') dp[i+1][j]+=dp[i][j];
      if(j+1<W and s[i][j+1]=='.') dp[i][j+1]+=dp[i][j];
   }
   cout<<dp[H-1][W-1].value()<<endl;
   return 0;
}


Measured memory_bytes: 9216
n,x=map(int,input().split())
l=[1]
for i in range(50): l+=[l[-1]*2+3]
from functools import lru_cache
@lru_cache(None)
def f(n,x):
  return int(x>0) if n<1 else f(n-1,l[n-1])+1+f(n-1,x-l[n-1]-2) if x>l[n]//2 else f(n-1,x-1)
print(f(n,x))

Measured memory_bytes: 9744
#include <stdio.h>
#include <stdlib.h>

#define N 100000
int a[N+2];
int fsum[N+2];
int bsum[N+2];

int main(void){
    int n;
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        scanf("%d", a+i);
        fsum[i]=fsum[i-1]+abs(a[i]-a[i-1]);
    }
    for(int i=n; i>=1; i--){
        bsum[i]=bsum[i+1]+abs(a[i]-a[i+1]);
    }
    for(int i=1; i<=n; i++){
        printf("%d\n", fsum[i-1]+abs(a[i+1]-a[i-1])+bsum[i+1]);
    }
    return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pi 3.1415926535
#define endl '\n'
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll inf=1e19;
/*ll power(ll x,ll y,ll m)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%m;
        x=(x*x)%m;
        y=y/2;
    }
    return res;
}*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,a,b;
    string s,t,u;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(s==u)
        cout<<a-1<<" "<<b<<endl;
    else
        cout<<a<<" "<<b-1<<endl;
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int i,n,x;
    int a[3];

    while(1){
        i = 0;
        scanf("%d %d", &n, &x);
        if(n == 0 && x == 0) break;
        for(int k = 1; k <= n - 2; k++){
            for(int l = k + 1; l <= n - 1; l++){
                for(int m = l + 1; m <= n; m++){
                    a[0] = k;
                    a[1] = l;
                    a[2] = m;
                    if(x == a[0] + a[1] + a[2]) i++;
                }
            }
        }
        printf("%d\n", i);
    }
    return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=998244353;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int N=1e5+50;
ll s[N];
ll a[N];
int main()
{
	ll n; cin >> n;
	ll a=100;
	int cnt=0;
	while(a<n)
	{
		a=(1.01)*a;
		cnt++;
	}
	cout<<cnt; 
    return 0;
}


Measured memory_bytes: 3624
def c(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


s=int(input())
if s<3:
  print(0)
  exit()
ans=0
for i in range(s//3):
  ans=ans+c(s-3*(i+1)+i,i)
print(ans%mod)

Measured memory_bytes: 67084
a,b,k = map(int,input().split(" "))
r = list(map(int,input().split(" ")))
l = list(map(int,input().split(" ")))
ar = [0]
br = [0]
for i in range(a):
    ar.append(ar[-1] + r[i])
for i in range(b):
    br.append(br[-1] + l[i])
ans = 0
j = b
for i in range(len(ar)):
    if ar[i] > k:
        break
    while True:
        if ar[i] + br[j] <= k:
            t = i + j
            break
        j -= 1
    ans = max(ans,t)
print(ans)

Measured memory_bytes: 47520
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <array>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;

typedef  pair<int,int> P;


int main(){
     int n;
     cin>>n;
     cout<<n*(1+n)/2<<endl; 
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  FOR(i, N) cin >> A[i];
  ll after = 0, all = 0;
  for (ll i = 0; i < N; ++i) {
    for (ll j = 0; j < N; ++j) {
      if (A[i] > A[j]) {
        all++;
        if (i < j)
          after++;
      }
    }
  }
  ll ans = (after * K % MOD + ((K * (K - 1) / 2) % MOD) * all) % MOD;
  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,x;
  cin>>n>>x;
  int sum=0;
  int mi=1000;
  rep(i,0,n){
    int a;
    cin>>a;
    sum+=a;
    mi=min(mi,a);
  }
  cout<<n+(x-sum)/mi<<endl;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    char s[123];
    Scs(s);
    int N = strlen(s);
    bool ans = true;
    if( N%2 ) ans = false;
    Rep(i,N){
        if( s[i] != (i%2?'i':'h') ) ans = false;
    }

    YesNo(ans);

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    char s[12],t[12];
    scanf("%s",s);
    scanf("%s",t);
    int i=0;
    while(s[i]!='\0'){
        if(s[i]!=t[i]){
            printf("No\n");
            return 0;
        }
        i++;
    }
    printf("Yes\n");

    return 0;
}


Measured memory_bytes: 1648
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))//数组(结构体)清零 
#define ll long long
//int A(int a,int b){if(a<b||a<1||b<0)return 0;int k=1;while(b--){k*=a--;}return k;}//数学中的Aab,传递ab,返回Cab//类型为int//如果不符合条件则返回0 
//int C(int a,int b){if(a<b||a<1||b<0)return 0;b=min(a-b,b);int k=A(a,b),t=1;while(--b)k/=++t;return k;}//数学中的Cab,传递ab,返回Cab//类型为int//如果不符合条件则返回0 
//int HW(char*HWa,int HWl,int HWr){if(HWr<HWl)swap(HWl,HWr);for(int i=0;i<(HWr-HWl)/2+1;i++)if(HWa[HWl+i]!=HWa[HWr-i])return 0;return 1;}//传递字符串名,判断区间l r,如果是回文字符串就返回1,否则返回0 
//int SS(int a){if(a>4&&((a-1)%6)&&((a+1)%6))return 0;for(int i=2;i<=sqrt(a);i++)if(a%i==0)return 0;return 1;}//判断一个数是不是质数，是1 否0；请确保a>1; 
/*记得如果改int为long long,就把printf与scanf中相应的%d也改成%lld*/
ll Queue[100010]={0,1,2,3,4,5,6,7,8,9}; 
int main()
{
	int head=1,tail=10;
	int k;
	ll x;
	cin>>k;
	while(tail<=k)
	{
		x=Queue[head++];
		if(x%10)Queue[tail++]=x*10+x%10-1;
		Queue[tail++]=x*10+x%10;
		if(x%10!=9)Queue[tail++]=x*10+x%10+1;
	}
	cout<<Queue[k];
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
      int X,A,B;
      cin >> X >> A >> B;
      string ans;
      if(B-A<=0) ans = "delicious";
      else{
        if(X-(B-A)<0) ans = "dangerous";
        else ans = "safe";
      }
      cout << ans << endl;
    }

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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    REP(i, N) cin >> h[i];

    sort(h.begin(), h.end());
    int minv = 1e9;
    for (int i=0; i<N-K+1; ++i) {
        int total = h[i+K-1] - h[i];
        minv = min(minv, total);
    }
    print(minv);
}

signed main() {
    solve();
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define pb push_back
#define PI 3.14159265
int M = 1000000007;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string a, b;
  cin >> a >> b;
  int ans = 0;
  for (int i = 0; i < a.length(); ++i)
  {
    if (a[i] != b[i])
      ans++;
  }
  cout << ans;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;

int n,a,b;  
string s;

int main() {
  cin >> n >> a >> b;
  cout << (abs(a-b)&1?"Borys":"Alice") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 2e5+2;
ll dp[100002][102];

ll recur(vpll &a, ll pos, ll W)
{
    if(pos>=a.size()) 
        return 0;
    if(a[pos].ff>W) 
        return 0;
    if(dp[W][pos]!=-1) 
        return dp[W][pos];

    return dp[W][pos]=max(a[pos].ss+recur(a,pos+1,W-a[pos].ff),recur(a,pos+1,W));
}

int main()
{
    fastio; //remove for interactive
    ll i, j, k, n, m, t;
    vpll a;
    memset(dp,-1,sizeof(dp));

    cin>>n>>k;
    for ( i = 0; i < n; i++)
    {
        ll w,v;
        cin>>w>>v;
        a.pb({w,v});
    }
    sort(all(a));
    recur(a,0,k);
    
    cout<<dp[k][0]<<endl;
    return 0;
}

Measured memory_bytes: 83284
#include<bits/stdc++.h>
using namespace std ;
int m, n ;
int data[100][2][2] ; //[i][0]:上, [i][1]:下
#define TIME 0
#define NUM 1
#define SITA 0
#define UE 1

void Clear( const int& posw, const int& posh) {
  data[posw][posh][TIME] = -1 ;
  data[posw][posh][NUM] = -1 ;
  return ;
}

void doing(queue< int >& ans) {
  for( int i = 0; i < m; i++) {
    for(int j = 0; j < 2; j++) {
      if( data[i][j][TIME] > 0) {
        data[i][j][TIME]-- ;
      }
    }
  }
  
  for(int i = 0; i < m; i++) {
    if(data[i][SITA][TIME] == 0) {
      ans.push( data[i][SITA][NUM]) ;
      Clear( i, SITA) ;
    }
    if(data[i][UE][TIME] == 0 && data[i][SITA][TIME] == -1) {
      ans.push( data[i][UE][NUM]) ;
      Clear( i, UE) ;
    }
  }
  return ;
}

bool find( const int& t, const int& num) {
  for(int i = 0; i < m; i++) {
    if( data[i][UE][TIME] == -1) {
      data[i][UE][TIME] = t ;
      data[i][UE][NUM] = num ;
      return true ;
    }
  }

  int ret = -1 ;
  for(int i = 0; i < m; i++) {
    if( data[i][SITA][TIME] != -1) continue ;
    if( data[i][UE][TIME] < t) continue ;
    if( ret == -1 || data[i][UE][TIME] < data[ret][UE][TIME]) {
      ret = i ;
    }
  }
  if( ret != -1) {
    data[ret][SITA][TIME] = t ;
    data[ret][SITA][NUM] = num ;
    return true ;
  }

  for(int i = 0; i < m; i++){
    if( data[i][SITA][TIME] != -1) continue ;
    if( ret == -1 || data[i][UE][TIME] > data[ret][UE][TIME]) {
      ret = i ;
    }
  }

  if( ret != -1) {
    data[ret][SITA][TIME] = t ;
    data[ret][SITA][NUM] = num ;
    return true ;
  }

  return false ;

}

int main(){
  while( cin >> m >> n, m) {

    fill_n( **data, 100 * 2 * 2, -1) ;
    queue< int > que1, que2 ;
    queue< int > ans ;
    for(int i = 0; i < n; i++) {
      int t ;
      cin >> t ;
      que1.push(t) ;
      que2.push(i) ;
      if( find( que1.front(), que2.front())) {
        que1.pop() ;
        que2.pop() ;
      }
      for(int j = 0; j < 10; j++) { //10分進める 
        doing(ans) ; //進める
        if(!que1.empty() && find(que1.front(), que2.front())) {
          que1.pop() ;
          que2.pop() ;
        }
      }
    }
    while(!que1.empty()) {
      if( find(que1.front(), que2.front())) {
        que1.pop() ;
        que2.pop() ;
        doing(ans) ;
      }
    }
    while(ans.size() < n){
      doing(ans) ;
    }
    for(int i = 0; i < n; i++) {
      cout << ans.front() + 1 << (i == n - 1 ? "\n" : " ") ;
      ans.pop() ;
    }
  }
  return 0 ;
}

Measured memory_bytes: 1200
import java.util.Scanner;

class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    String A = sc.next();
    String B = sc.next();

    if  (A.substring(0,1).equals(B.substring(2,3)) && A.substring(1,2).equals(B.substring(1,2)) && A.substring(2,3).equals(B.substring(0,1))){
      System.out.println("YES");
    }
    else {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

vector<ll> h;
ll N, A, B;

bool isOK(ll target) {
	ll cnt = 0;
	for(int i = 0; i < N; i++) {
		if(h[i] > B * target) cnt += (h[i] - B * target + A - B - 1) / (A - B);
	}
	return (target >= cnt);
}

// 汎用的な二分探索のテンプレ
ll binary_search() {
	ll ng = 0;	  //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll ok = inf;  // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* ok と ng のどちらが大きいかわからないことを考慮 */
	while(abs(ok - ng) > 1) {
		ll mid = (ok + ng) / 2;

		if(isOK(mid))
			ok = mid;
		else
			ng = mid;
	}
	return ok;
}

int main() {
	cin >> N >> A >> B;
	h.resize(N);
	for(int i = 0; i < N; i++) cin >> h[i];
	cout << binary_search() << "\n";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <deque>
#include <string>
using namespace std;

int main() {
  long long N; cin >> N;
  long long A[N]; for (int i = 0; i < N; i++) cin >> A[i];
  long long Q; cin >> Q;
  long long B[Q], C[Q]; for (int i = 0; i < Q; i++) cin >> B[i] >> C[i];
  
  long long num[1000000];
  long long count = 0;
  for (int i = 0; i < 1000000; i++) num[i] = 0;
  for (int i = 0; i < N; i++){
    num[A[i]]++;
    count += A[i];
  }
  for (int i = 0; i < Q; i++){
    count += num[B[i]] * (C[i] - B[i]);
    num[C[i]] += num[B[i]];
    num[B[i]] = 0;
    cout << count << endl;
  }
}

Measured memory_bytes: 13708
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<deque>
#include<string>
using namespace std;
const long long Maxn=1000000+10,Maxm=30000000+200;
const long long dx[]={1,-1,0,0},dy[]={0,0,-1,1};
const long long inf=(1ll<<60);
bool a[1010][1010];
bool vis[Maxn];
long long nxt[Maxm],to[Maxm];
long long len[Maxm],head[Maxn];
long long n,m,s,t;
long long edgecnt;
long long dis[Maxn]; 
struct node{
	long long pos,dis;
	node(long long x,long long y)
	{
		pos=x,dis=y;
	}
	bool operator <(const node &x)const
	{
		return x.dis<dis;
	}
};
inline void add(long long x,long long y,long long c)
{
	++edgecnt;
	nxt[edgecnt]=head[x];
	to[edgecnt]=y;
	len[edgecnt]=c;
	head[x]=edgecnt;
}
inline long long id(long long x,long long y)
{
	return (x-1)*m+y;
}
inline long long read()
{
	long long s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0' && ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
void dij()
{
	deque <int> q;
	for(long long i=0;i<=(n*m)+2;++i)
	vis[i]=0,dis[i]=inf;
	vis[s]=1,dis[s]=0ll,q.push_back(s);
	while(q.size())
	{
		long long x=q.front();
		q.pop_front();
		vis[x]=0;
		for(long long i=head[x];i;i=nxt[i])
		{
			long long y=to[i];
			if(dis[y]>dis[x]+len[i])
			{
				dis[y]=(long long)dis[x]+len[i];
				if(!vis[y])
				{
					vis[y]=1;
					if(!len[i])q.push_front(y);
					else q.push_back(y);
				}
			}
		}
	}
}
inline bool check(long long x,long long y)
{
	return (x<1 || y<1 || x>n || y>m || a[x][y]);
}
int main()
{
	n=read(),m=read();
	long long x=read(),y=read();
	s=id(x,y);
	x=read(),y=read();
	t=id(x,y);
	for(long long i=1;i<=n;++i)
	{
		string str;
		cin>>str;
		for(long long j=1;j<=m;++j)
		if(str[j-1]=='#')a[i][j]=1;
	}
	for(long long i=1;i<=n;++i)
	for(long long j=1;j<=m;++j)
	{
		if(a[i][j])continue;
		for(long long x=i-2;x<=i+2;++x)
		for(long long y=j-2;y<=j+2;++y)
		{
			if(check(x,y) || (i==x && j==y))continue;
			add(id(i,j),id(x,y),1);
		}
		for(long long k=0;k<4;++k)
		{
			long long x=i+dx[k],y=j+dy[k];
			if(check(x,y))continue;
			add(id(i,j),id(x,y),0);
		}
	}
	dij();
	if(dis[t]==inf)puts("-1");
	else printf("%lld\n",dis[t]);
	return 0;
}


Measured memory_bytes: 184724
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
int main()
{
	int N, M, an = 0;
	scanf("%d%d", &N, &M);
	an += (N - M) * 100;
	an += 1900 * M;
	for (int i = 0; i < M; i++) {
		an *= 2;
	}
	printf("%d", an);
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	int a,b,k;
	cin>>a>>b>>k;
	int cnt=0;
	for(int i=min(a,b);i>=1;i--){
		if(a%i==0&&b%i==0)cnt++;
		if(cnt==k){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

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

using namespace std;

int calc_min(int, int);

int main() {
	long N,a;
	cin >> N;
	cin >> a;

	long b;
	long min = pow(10, 9);
	for (int i = 0; i < N-1; i++) {
		cin >> b;
		min = calc_min(a, b);
		a = min;
		if (min == 1)break;
	}
	cout << min << endl;
}

int calc_min(int a, int b) {
	if (a == 0) return b;
	if (b == 0) return a;
	a > b ? calc_min(a%b, b) : calc_min(a, b % a);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define M 1046257
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
  if ( ch == 'A' ) return 1;
  else if ( ch == 'C' ) return 2;
  else if ( ch == 'G' ) return 3;
  else if ( ch == 'T' ) return 4;
  return 0;
}

long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for(i=0;i<strlen(str);i++) {
    sum += p*(getChar(str[i]));
    p*= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]) {
  long long key, i, h;
  key = getKey(str); 
  for(i=0; ;i++) {
    h = (h1(key) + i*h2(key)) % M;
    if( strcmp(H[h],str) == 0) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for(i=0; ; i++) {
    h = (h1(key) + i * h2(key)) %M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) {
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(void) {
  int i, n;
  char str[L], com[9];
  for(i=0;i<M;i++) H[i][0] = '\0';
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s %s",com,str);
    if(com[0] == 'i') {
      insert(str);
    } else {
      if(find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 16100
#include <bits/stdc++.h>
#define vel vector<long long>
#define veb vector<bool>
#define vvel vector<vel>
#define int long long
#define pin pair<int,int>
#define ppin pair<int,pin>
#define mkp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
signed main() {
    int pr = 1000;
    pr *= pr * pr; pr += 7;
    int a, b;
    cin >> a >> b;
    if(abs(a-b) >= 1){
        cout<<max(a, b)*2 - 1<<endl;
    }else{
        cout<<a+b<<endl;
    }
    return 0;
}


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

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

struct UnionFind {
  vector< int > data;
  vector< ll > maxd;
  vector< bool > dup;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
    maxd.assign(sz, -1);
    dup.assign(sz, false);
  }
 
  bool unite(int x, int y, ll dx, ll dy) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x; //yの親はx
    if(maxd[x] < dy) {
        maxd[x] = max(maxd[x], dy);
        dup[x] = false;
    } else if(maxd[x] == dy) {
        dup[x] = true;
    }
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
  
};

int main(void){
    int n, m;
    cin >> n >> m;
    vector<ll> h(n+1);
    vector<bool> high(n+1);
    FOR(i, 1, n) cin >> h[i];
    FOR(i, 1, n) high[i] = true;
    
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        if(h[a] == h[b]) {
            high[a] = false;
            high[b] = false;
        }else if(h[a] < h[b]) {
            high[a] = false;
        }else {
            high[b] = false;
        }
    }
    int sum = 0;
    FOR(i, 1, n) {
        if(high[i]) sum++;
    } 
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3964
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}
void writeA(T)(size_t n,T t){foreach(i,v;t.enumerate){write(v);if(i<n-1)write(" ");}writeln;}

void main()
{
  int n; readV(n);
  int[] x, y; readC(n, x, y);

  auto u = new int[](n), v = new int[](n);
  foreach (i; 0..n) {
    u[i] = x[i] + y[i];
    v[i] = x[i] - y[i];
  }

  auto e = u.all!(ui => ui%2 == 0);
  if (!e && !u.all!(ui => ui%2 != 0)) {
    writeln(-1);
    return;
  }

  if (e) { --u[]; --v[]; }

  auto m = 31;
  if (e) {
    writeln(m+1);
    writeA(m+1, chain([1], iota(m).map!"2^^a"));
  } else {
    writeln(m);
    writeA(m, iota(m).map!"2^^a");
  }

  foreach (i; 0..n) {
    if (e) write('R');
    auto ut = (2^^m-1-u[i])/2, vt = (2^^m-1-v[i])/2;
    foreach (j; 0..m) {
      auto ub = ut.bitTest(j) ? 1 : 0, vb = vt.bitTest(j) ? 1 : 0;
      write(['R', 'U', 'D', 'L'][(ub<<1)|vb]);
    }
    writeln;
  }
}

pragma(inline) {
  pure bool bitTest(T)(T n, size_t i) { return (n & (T(1) << i)) != 0; }
  pure T bitSet(T)(T n, size_t i) { return n | (T(1) << i); }
  pure T bitReset(T)(T n, size_t i) { return n & ~(T(1) << i); }
  pure T bitComp(T)(T n, size_t i) { return n ^ (T(1) << i); }

  pure T bitSet(T)(T n, size_t s, size_t e) { return n | ((T(1) << e) - 1) & ~((T(1) << s) - 1); }
  pure T bitReset(T)(T n, size_t s, size_t e) { return n & (~((T(1) << e) - 1) | ((T(1) << s) - 1)); }
  pure T bitComp(T)(T n, size_t s, size_t e) { return n ^ ((T(1) << e) - 1) & ~((T(1) << s) - 1); }

  import core.bitop;
  pure int bsf(T)(T n) { return core.bitop.bsf(ulong(n)); }
  pure int bsr(T)(T n) { return core.bitop.bsr(ulong(n)); }
  pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); }
}


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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pinin=pair<int ,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sort(x) sort(x.begin(), x.end());
#define rese(x) reverse(x.begin(), x.end());

string yes="Yes",no="No";

int main() {
 ll a,b,c,d;
 cin>>a>>b>>c>>d;
 cout<<max(max(a*d,b*c),max(a*c,b*d));
    
}


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


using namespace std;

int main (void)
{

  char type[4] = {'P','W','G','Y'};
  int i;

  int N;
  cin >> N;
  char S[N];

  string ans;
  ans = "Three";

  for(i=0; i<N; i++)
  {
    cin >> S[i];
    if(S[i] == 'Y')
    {
      ans = "Four";
    }
  }

  cout << ans << endl;


  return 0;

}


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

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        int n;
        n = sc.nextInt();

        int [] h = new int [n];

        for(int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
		
      /*
        for(int ii : h) {
           
        }
        */

        int ans = 0;
        int out = 0;
        for(int i = 0; i < h.length; i++) {

            if(out >= h[i]) {
                out = h[i];
            } else {
                ans += h[i] - out;
                out = h[i];
            }
        }
      
      	 System.out.println(ans);

    }
}

Measured memory_bytes: 22736
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;

struct job {
  int a;
  int b;
  job(int ai, int bi) {
    a = ai;
    b = bi;
  }
};

bool comp(const job &x, const job &y) {
  return x.b < y.b;
}

int main() {
  int n;
  cin >> n;
  vector<job> j;
  for (int i = 1; i <= n; i++) {
    int ai, bi;
    cin >> ai >> bi;
    j.push_back(job(ai, bi));
  }
  sort(j.begin(), j.end(), comp);
  
  int t = 0;
  for (int i = 0; i < j.size(); i++) {
    t += j[i].a;
    if (t > j[i].b) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 2420
/*
 * @Author       : nonameless
 * @Date         : 2020-09-14 00:38:45
 * @LastEditors  : nonameless
 * @LastEditTime : 2020-09-14 00:45:05
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define sz(x) (int)x.size()
#define toStr(name) (#name)
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
const double eps = 1e-6;
const double PI  = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll LNF  = 0x3f3f3f3f3f3f3f3f;
inline int gcd(int a, int b) { return b ? gcd(b,a % b):a;}
inline ll  gcd(ll  a, ll  b) { return b ? gcd(b,a % b):a;}
inline int lcm(int a, int b) { return a * b / gcd(a, b); }

template<class T>
inline void read(T &x){
    x = 0;
    int f = 1;
    char c = getchar();
    while(c < '0' || c > '9') if(c == '-') { f = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
    x = x * f;
}

template<class T>
inline void out(string a, T x){ cout << a << " = " << x << endl; }

vector<int> v1, v2, v3, v4;

bool cmp(int a, int b) { return a > b; }


int main(){

    int n; read(n);
    for(int i = 1; i <= n; i ++){
        int x, y; 
        read(x); read(y);
        v1.pb(x + y);
        v2.pb(-x - y);
        v3.pb(-x + y);
        v4.pb(x - y);
    }
    sort(all(v1), cmp); sort(all(v2), cmp); sort(all(v3), cmp); sort(all(v4), cmp);
    int ans = max(v1[0] + v2[0], v3[0] + v4[0]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6504
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//最小公倍数、最大公約数
ll gcd(ll a, ll b) {
	return b != 0 ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
int main() {
	int N;
	cin >> N;
	vector<ll> A(N), B1(N), B2(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	B1[0] = A[0];
	B2[N - 1] = A[N - 1];
	for (int i = 1; i < N; i++) {
		B1[i] = gcd(B1[i - 1], A[i]);
	}
	for (int i = N - 2; i >= 0; i--) {
		B2[i] = gcd(B2[i + 1], A[i]);
	}
	ll ans = max(B2[1], B1[N - 2]);
	for (int i = 1; i < N-1; i++) {
		ans = max(ans, gcd(B1[i - 1], B2[i + 1]));
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}


bool judge(ll n, ll k) {
    if(n % k == 0) while(n % k == 0) n /= k;
    return n % k == 1;
}

signed main(void) {
    ll n; cin >> n;
    ll ans = -1;
    
    for(int i = 1; i * i <= n - 1; ++i) {
        if((n - 1) % i == 0) {
            ans++;
            if((n - 1) / i != i) ans++;
        }
    }

    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ll d = n / i;
            if(i != 1 && judge(n, i)) ans++;
            if(d != i && judge(n, d)) ans++;
        }
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define inf 1000000007
using namespace std;
map< pair<int,int> , int> mope;
vector< pair<int,int> > v;
vector< pair<int,int> > to[514514]; // idx.cost
int d[514514];
vector<int> trains[114514];
void dijkstra(int s){
	priority_queue< pair<int,int>, vector<pair<int,int> >, greater< pair<int,int> > > que;
	for(int i=0;i<=510000;i++){
		d[i] = inf;
	}
	d[s] = 0;
	que.push( mp(0,s) );
	while(!que.empty()){
		pair<int,int> p = que.top();que.pop();
		int cv = p.second;
		if( d[cv] < p.first)continue;
		for(int i=0;i<to[cv].size();i++){
			int ci = to[cv][i].first;
			int cc = to[cv][i].second;
			if( d[ci] > d[cv] + cc){
				d[ci] = d[cv] + cc;
				que.push(mp(d[ci],ci));
			}
		}
	}
}
signed main(){
	int n,m;
	cin>>n>>m;
	int cur = 0;
	for(int i=1;i<=n;i++){
		mope[ mp(i,0) ] = cur;
		cur ++;
		v.pb(mp(i,0));
	}
	vector<int> a,b,c;
	for(int i=0;i<m;i++){
		int x,y,z;
		cin>>x>>y>>z;
		a.pb(x);b.pb(y);c.pb(z);
		if( mope[mp(x,z)]==0 ){
			mope[mp(x,z)] = cur;
			cur++;
			v.pb(mp(x,z));
			trains[x].pb(z);
		}
		if( mope[mp(y,z)]==0 ){
			mope[mp(y,z)] = cur;
			cur++;
			v.pb(mp(y,z));
			trains[y].pb(z);
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<trains[i].size();j++){
			int zr = mope[mp(i,0)];
			int ci = mope[mp(i,trains[i][j])];
			to[zr].pb(mp(ci,1));
			to[ci].pb(mp(zr,0));
		}
	}
	for(int i=0;i<m;i++){
		int cx = a[i], cy = b[i], cz = c[i];
		int id1 = mope[mp(a[i],c[i])];
		int id2 = mope[mp(b[i],c[i])];
		to[id1].pb(mp(id2,0));
		to[id2].pb(mp(id1,0));
	}
	/* for(int i=0;i<v.size();i++){
		cout<<"v["<<i<<"]: "<<v[i].first<<" "<<v[i].second<<endl;
		cout<<"has "<<to[i].size()<<" way(s)"<<endl;
		for(int j=0;j<to[i].size();j++){
			cout<<"to: "<<v[ to[i][j].first ].first<<" "<<v[ to[i][j].first ].second<<" cost: "<<to[i][j].second<<endl;
		}
	} */
	dijkstra( mope[mp(1,0)] );
	ll ans = d[mope[mp(n,0)]];
	if(ans == inf)ans = -1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 108008
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let v: Vec<_> = (0..n).map(|_| sc.cin::<i64>()).collect();
    let c: Vec<_> = (0..n).map(|_| sc.cin::<i64>()).collect();
    put!(v.iter().zip(c.iter()).map(|(v, c)| v - c).filter(|&x| x > 0).sum::<i64>());
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLine()
    val v = sc.nextLine().split(" ").map { it.toInt() }

    println(problem138_c(a, v))
}

fun problem138_c(a: String, v: List<Int>): String {

    val sort = v.sortedByDescending { -it }

    var ave: Double = sort[0].toDouble()

    for ((index, value) in sort.withIndex()) {

        if (index == 0) {
            continue
        }

        ave = (ave + value) / 2
    }

    return ave.toString()
}

Measured memory_bytes: 36208
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int min(int x, int y)
{
    if (x <= y) return x;
    else return y;
}

int main()
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    int ans = min( abs(a-b) + abs(b-c), min( abs(b-c) + abs(c-a), abs(c-a) + abs(a-b)));
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#dp[i][j]:i番目までの品物の中で重さj以下になるように持った時の価値
#最終的な答えに沿うようにここは決める

N,W = map(int,input().split())
wv = [list(map(int,input().split())) for i in range(N)]#wv:01

dp = [[0]*(W+1) for i in range(0,N,1)]
for i in range(wv[0][0],W+1,1):#一番左の荷物に関しては自明なので
    dp[0][i]=wv[0][1]

for i in range(1,N,1):
    for j in range(0,W+1,1):
        dp[i][j]=max(dp[i-1][j],dp[i][j])
        if j - wv[i][0] >= 0:
            dp[i][j]=max(dp[i-1][j-wv[i][0]]+wv[i][1],dp[i][j])
print(dp[N-1][W])

Measured memory_bytes: 147744
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
#define M 500005
#define N 505
#define F(i,j,k) for(int i=(j);i<=(k);++i)
#define D(i,j,k) for(int i=(j);i>=(k);--i)
using namespace std;
int ecnt,match[N];
struct V{int head;}v[N];
struct E{int u,v,next;}e[M];
bool used[N];
inline void read(int &x){
	char ch=getchar();int f=1;x=0;
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	x*=f;
}
inline void add(int x,int y){
	e[++ecnt].u=x,e[ecnt].v=y;
	e[ecnt].next=v[x].head,v[x].head=ecnt;
}
bool find(int x){
	for(int i=v[x].head;i;i=e[i].next){
		if(used[e[i].v])continue;
		used[e[i].v]=1;
		if(find(match[e[i].v])||!match[e[i].v]){
			match[e[i].v]=x;
			return true;
		}
	}
	return false;
}
int ans,n,a[N],b[N],c[N],d[N];
int main(){
	//freopen("txt.in","r",stdin);freopen("txt.out","w",stdout);
	read(n);
	F(i,1,n)read(a[i]),read(b[i]);
	F(i,1,n)read(c[i]),read(d[i]);
	F(i,1,n){
		F(j,1,n)if(a[i]<=c[j]&&b[i]<=d[j])add(i,j+n);
	}
	F(i,1,n){
		memset(used,0,sizeof(used));
		if(find(i))ans++;
	//	F(j,1,n)printf("%d ",match[n+j]);printf("\n");
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256