akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define ff first
#define sc second
#define INF 3000000000
#define SINF 2*(1e18)
#define inf -10000000
#define pb push_back
#define forr(i,p,n) for(int i=p;i<n;i++)
#define mpk make_pair
#define upb(a,s) upper_bound(a.begin(),a.end(),s)
#define lwb(a,s) lower_bound(a.begin(),a.end(),s)
#define mem(a,val) memset(a,val,sizeof a)
#define cc continue
#define eb emplace_back
#define bb break
#define mostbit(n) 32-__builtin_clz(n)-1
#define time_to_forget cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
ll mod=1e9+7;
ll fastpow(ll a,ll b){
  ll pos=1;
  forr(i,0,b){
    pos*=a;
    pos%=mod;
  }
  return pos;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie();
    ll a,b,c,d,n,t,m,k;
    while(cin>>n){
      ll ans=fastpow(10,n)-fastpow(9,n)-fastpow(9,n)+fastpow(8,n);
      ans%=mod;
      ans=(ans+mod)%mod;
      cout<<ans<<endl;
    }
}


Measured memory_bytes: 3696
// inputに入力データ全体が入る
function Main(input) {
	input = input.split("\n");
  	input = input[0].split(" ");
    var A = Number(input[0])
    var B = Number(input[1])
    var T = Number(input[2])
    var time = 1;
    var sum = 0;
	for(var i=0; i<=(T+0.5); i++ ){
      if(i == time*A){
         sum += B;
         time++;
      }
    }
    console.log(sum)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
n = int(input())
a = list(map(int, input().split()))

for i in range(1, n):
    print(' '.join(list(map(str, a))))
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
        a[j + 1] = a[j]
        j -= 1
    a[j + 1] = v

print(' '.join(list(map(str, a))))

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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  ll sum = 0;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    sum += A[i];
  }
  
  vector<ll> dp(N - 1, 0);
  ll x = 0, y = 0;
  for (int i = 0; i < N - 1; ++i) {
    x += A[i];
    y = sum - x;
    dp[i] = abs(x - y);
  }
  cout << *min_element(dp.begin(), dp.end()) << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int n;
  cin>>n;
  vector<pair<int,pair<int,int>>> v(n);
  rep(i,n) cin>>v[i].second.first>>v[i].first>>v[i].second.second;
  // w,s,v 

  sort(all(v), [](const auto &l, const auto &r){
    return (l.first + l.second.first) < (r.first + r.second.first);
  });
dbg(v);
  const int W = 20004;
  vector<long> dp(W, 0);
  rep(i,n){
    int w = v[i].second.first;
    int s = v[i].first;
    long val = v[i].second.second;

    vector<long> nxt(dp);
    rep(j,s+1){
      if(j + w <= W) nxt[j+w] = max(nxt[j+w], dp[j] + val);
    }

    swap(dp, nxt);
  }

  cout << *max_element(all(dp)) << endl;

  return 0;
}


Measured memory_bytes: 608
#include<iostream>
using namespace std;
#define rep(i, n) for (int i=1;i <= (int)n;i++)
typedef long long ll;
ll a, b , c, k;
ll x, y, z;
ll total;

int main(){
  cin >> a >> b >> c >> k;
  x = a;
  y = 0;
  z = -c;
  total = 0;
  if (a > k){
    total = total + k;
    cout << total << endl;
  }else{
    k = k - a;
    total = total + x;
    if (b > k){
      cout << total << endl;
    }else{
      k = k - b;
      if (c > k){
        total = total - k;
        cout << total << endl;
      }else{
        total = total - c;
        cout << total << endl;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3188
use scanner::Scanner;

fn main() {
    let mut sc = Scanner::new();
    let n:usize = sc.read();
    println!("{}", (1..n+1).sum::<usize>());
}

mod scanner {
    pub struct Scanner<'a> {
        s: String,
        words: ::std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new() -> Scanner<'a> {
            let s = String::new();
            let words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            Scanner { s: s, words: words }
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T {
            match self.words.next() {
                Some(x) => x.parse().ok().unwrap(),
                None => {
                    self.load();
                    self.read()
                }
            }
        }

        fn load(&mut self) {
            self.s.clear();
            ::std::io::stdin().read_line(&mut self.s).unwrap();
            self.words = unsafe { ::std::mem::transmute(self.s.split_whitespace()) };
        }
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    int N, M, X, Y;
    std::cin >> N >> M >> X >> Y;

    std::vector<int> x(N);
    for (int i = 0; i < N; i++) {
        std::cin >> x[i];
    }

    std::vector<int> y(M);
    for (int i = 0; i < M; i++) {
        std::cin >> y[i];
    }

    std::sort(x.begin(), x.end());
    std::sort(y.begin(), y.end());

    if (std::min(y[0], Y) - std::max(x[N - 1], X) > 0) std::cout << "No War" << std::endl;
    else std::cout << "War" << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <typeinfo>
#include <queue>
#include <math.h>
using namespace std;


int main(){
	string str;
	cin>>str;
	int n=str.size();

	if(n==2) cout<<"Second"<<endl;

	else if (str[0]==str[n-1])
	{
		if (n%2==0)
		{
			cout<<"First"<<endl;
		}
		else cout<<"Second"<<endl;
	}
	else if (str[0]!=str[n-1])
	{
		if (n%2==0)
		{
			cout<<"Second"<<endl;
		}
		else cout<<"First"<<endl;
	}


return 0;
}




Measured memory_bytes: 512
// AOJ 2130: Billion Million Thousand
// 2017.11.10 bal4u@uu

#include <stdio.h>
#include <string.h>

typedef struct { char s[102]; int w, p; } T;
T tbl[101];
char goal[202]; int len;
int dp1[202], dp2[2000];

int main()  
{  
	int n, i, j, k;
	int cno = 0;

	while (scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++) {
			scanf("%s%d", &tbl[i].s, &tbl[i].p);
			tbl[i].w = strlen(tbl[i].s);
		}
		scanf("%s", goal); len = strlen(goal);

		memset(dp1, -1, sizeof(dp1)); dp1[0] = 0;
		memset(dp2, 0x33, sizeof(dp2)); dp2[0] = 0;
		for (i = 0; i <= len; i++) for (j = 0; j < n; j++) {
			k = i - tbl[j].w;
			if (k < 0 || dp1[k] < 0) continue;
			if (!memcmp(goal+k, tbl[j].s, tbl[j].w)) {
				if (dp1[i] < dp1[k] + tbl[j].p) dp1[i] = dp1[k] + tbl[j].p;
			}
		}
		for (k = dp1[len], i = 0; i < n; i++) for (j = 0; j <= k-tbl[i].p; j++) {
			int t = dp2[j] + tbl[i].w;
			if (t < dp2[j+tbl[i].p]) dp2[j+tbl[i].p] = t;
		}
		printf("Case %d: %d\n", ++cno, dp2[k]);
    }  
    return 0;  
}  

Measured memory_bytes: 1816
#include<bits//stdc++.h>
using namespace std;
int main(){
  long long int n,k;
  cin>>n>>k;
  long long int s=0,mod=1000000007;
   while (k <= n + 1) {
        s = (s + ((2 * n - k + 1) * k / 2 - (k - 1) * k / 2 + 1) % mod) % mod;
        k++;
    }
  cout<<s;
  return 0;}

Measured memory_bytes: 3548
#include <stdio.h>

int main(void) {
  int A, B;
  scanf("%d %d", &A, &B);

  int X;
  if(A <= 5) {
    X = 0;
  } else if(A <= 12) {
    X = B / 2;
  } else {
    X = B;
  }
  printf("%d\n", X);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;int K;
  cin>>S>>K;int N=S.size();
  vector<string> p;
  for(int i=1;i<=K;i++){
    for(int j=0;j<=N-i;j++){
      string a=S.substr(j,i);
      p.push_back(a);
    }
  }
  sort(p.begin(), p.end());
  int a=0;K--;
  while(K>0){
    if(p.at(a)!=p.at(a+1)) K--;
    a++;
  }
  cout<<p.at(a)<<endl;
}

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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

int n;
vi a;

int main()
{
    cin >> n;
    REP(i, n)
    {
        int c;
        cin >> c;
        a.push_back(c);
    }
    vi b = a;
    sort(ALL(a));

    int l = a[a.size() / 2 - 1];
    int r = a[a.size() / 2];
    REP(i, n)
    {
        if (b[i] >= r)
        {
            cout << l << endl;
        }
        else
        {
            cout << r << endl;
        }
    }
}

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

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

// code starts
int main()
{
	int d,t,s;
	cin >> d >> t >> s;
	if(s*t >= d) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3628
// Card Eater
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n,k=1;
    cin>>n;
    int a[100000];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }sort(a,a+n);
    for(int i=1;i<n;i++){
        if(a[i-1]!=a[i]){
            k++;
        }
    }
    cout<<k+(k%2)-1;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;

int n,a,b;
int main()
{
    int ans = 0;
    scanf("%d%d%d",&n,&a,&b);
    for(int i=1;i<=n;i++){
        int now = i, sum = 0;
        while(now){
            sum += now % 10;
            now /= 10;
        }
        if(sum>=a&&sum<=b){
            ans += i;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int W = 1e5+10;

//head

int n, w;
ll dp[W];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> w;
  fill(dp+1, dp+W, LINF);
  rep(i, n) {
    int ww, vv;
    cin >> ww >> vv;
    for(int j = W-1; j >= vv; j--) {
      chmin(dp[j], dp[j-vv] + ww);
    }
  }
  for(int i = W-1; i >= 0; i--) {
    if(dp[i] <= w) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 4356
#include <stdio.h>
  
int main(void) {
    int a, b;

    scanf("%d%d", &a, &b);
    int ans[3];

    ans[0] = a + b;
    ans[1] = a - b;
    ans[2] = a * b;

    int max = ans[0];
    if (max < ans[1]) max = ans[1];
    if (max < ans[2]) max = ans[2];

    printf("%d\n", max);

    return 0;
}

Measured memory_bytes: 128
ans=Array.new(10){ Array.new(1001){0}}
ans[0][0]=1

0.upto(100) do |i|
    1000.downto(0) do |j|
        9.downto(1) do |k|
            ans[k][j]+=ans[k-1][j-i] if j-i >= 0
        end
    end
end

while gets do
    n,s=$_.split(nil).map(&:to_i)
    break if n==0 && s==0
    puts ans[n][s]
end

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

int main() {
    int h,w;
    while (cin>>h>>w,h!=0&&w!=0)
    {
        for (int i = 0; i < h; ++i) {
            if (i==0||i==h-1)
            {
                for (int j = 0; j < w; ++j) {
                    cout << "#";
                }
                cout << endl;
            }
            else
            {
                for (int j = 0; j < w; ++j) {
                    if (j == 0 || j == w - 1)cout << "#";
                    else cout << ".";
                }
                cout << endl;
            }
        }
        cout<<endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;
const int N = 1e2 + 10;
const int K = 1e5 + 10;

ll dp[N][K]; 
int a[N]; 

int main()
{

	int n, k;
	cin >> n >> k;

	for(int i = 1; i <= n; i++)
		cin >> a[i];

	dp[0][0] = 1;

	for(int i = 1; i <= n; i++)
	{
		vector<int> s(k + 1);
		s[0] = dp[i - 1][0];

		for(int j = 1; j <= k; j++)
			s[j] = (s[j - 1] + dp[i - 1][j]) % mod;

		for(int j = 0; j <= k; j++)
		{
			int index = j - min(a[i], j);

			dp[i][j] = index ? (s[j] - s[index - 1] + mod) % mod : s[j];

			// for(int w = 0; w <= min(a[i], j); w++)
			// {
			// 	dp[i][j] += dp[i - 1][j - w];
			// }

			// cout << i << " " << j << " " << dp[i][j] << endl;
		}
	}

	cout << dp[n][k] << endl;

	return 0;
}

Measured memory_bytes: 79740
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define ITR(i,x) for(auto i=(x).begin();i!=(x).end();++i)
using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int mod = 1000000007;

bool square(ll a){ll n=(ll)sqrt(a);return a==n*n;}
int digitsum(ll N,int a);//a進数におけるNの各桁の和、計算量はloga(N)
ll mpow(ll x, ll n);
ll inv_mod(ll a){return mpow(a,mod-2);}
int gcd(int x,int y){return y ? gcd(y,x%y) : x;};//xとyの最大公約数
int lcm(int x,int y){return x*y/gcd(x,y);}//xとyの最小公倍数

int main(){
    int N;
    cin>>N;
    vector<ll> h(N);
    REP(i, N) cin >> h[i];
    vector<ll> dp(N);
    dp[0]=0;
    dp[1]=llabs(h[1]-h[0]);
    REP(i,N-2) dp[i+2]=min(dp[i+1]+llabs(h[i+2]-h[i+1]),dp[i]+llabs(h[i+2]-h[i]));
    cout<<dp[N-1]<<endl;
}

int digitsum(ll N,int a){
    if(N==0) return 0;
    int ret=0;
    ret+=digitsum(N/a,a)+N%a;
    return ret;
}
ll mpow(ll x, ll n){ //x^n(mod division) ←普通にpow(x,n)では溢れてしまうため，随時mod計算 2分累乗法だから早い
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}
/*
class Factorial{//階乗とその逆元を求めて計算に利用するクラス
private:
    vector<ll> fac;
public:
    
    Factorial(ll N){
        fac.push_back(1);
        for(int i=0;i<N;i++) fac.push_back(fac[i]*(i+1)%mod);
    }

    ll fact(ll a){return fac[a];}
    ll ifact(ll a){return inv_mod(fac[a]);}

    ll cmb(ll a,ll b){
        if(a==0&&b==0) return 1;
        if(a<b||a<0) return 0;
        ll tmp =ifact(a-b)*ifact(b)%mod;
        return tmp*fac[a]%mod;
    }
};
*/

/*
class UnionFind{//UnionFind木
 private:
    vector<int> Parent;
 public:
    UnionFind(int N){
        for(int i=0;i<N;i++) Parent.push_back(-1);
    }

    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A]=root(Parent[A]);
    }

    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A,int B){
        A=root(A);
        B=root(B);
        if(A==B) return false;
        if(size(A)<size(B)) swap(A,B);
        Parent[A]-=Parent[B];
        Parent[B]=A;
    }
};
*/

Measured memory_bytes: 1792
#%%
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * n
cost = 0
ans = 0

for i in range(n):
    c[i] = a[i] - b[i]
    if c[i] < 0:
        cost -= c[i]
        ans += 1

c.sort(reverse = True)
#print(c)
s = sum(c)

#print(cost, ans)

for i in range(n):
    if cost <= 0:
        break
    else:
        cost -= c[i]
        ans += 1

if cost <= 0:
    print(ans)
else:
    print(-1)
    



Measured memory_bytes: 19068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define f first
long long const mod = 998244353; 
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<pair<ll,ll>, null_type,less<pair<ll,ll> >, rb_tree_tag,tree_order_statistics_node_update> */

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
}

ll power(ll x,ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
	
    ll n;
    cin>>n;
    ll k;
    cin>>k;
    vector<pair<ll,ll> >v;
    for(int i=0;i<k;i++)
    {
        ll l,r;
        cin>>l>>r;
        v.push_back(make_pair(l,r));
    }
    sort(v.begin(),v.end());
    ll dp[n+1];
    dp[0]=0;
    dp[1]=1;
    for(ll i=2;i<=n;i++)
    {
        ll z=0;
        for(auto x:v)
        {
            ll l=x.first;
            ll s=min(x.second,i-1);
            if(l+1<=i)
            {
                z=add(z,sub(dp[i-l],dp[i-s-1]));
            }
            else
            {
                break;
            } 
        }
        dp[i]=add(dp[i-1],z);
        //cout<<i<<" "<<z<<endl;
    }
    cout<<sub(dp[n],dp[n-1])<<endl;
    
    
    return 0;
}




Measured memory_bytes: 5212
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int a, b;

int main(){
  FAST_IO
  cin >> a >> b;

  if(a == b) cout << "Draw\n";
  else if(a == 1) cout << "Alice\n";
  else if(b == 1) cout << "Bob\n";
  else if(a > b) cout << "Alice\n";
  else cout << "Bob\n";

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
#define ll long long
#define trace(x) cerr << #x << " = " << x << endl
using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main()
{
   /*
    #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("ouput.txt","w",stdout);
    #endif 
   */

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while(t--){
	    string s;
	    cin>>s;
	    if(s[(int)s.size() - 1] == 'e')
		    s += 's';
	    else if(s[(int)s.size() - 1] == 's')
		    s += "es";
	    else
		    s += 's';
	   cout<<s<<endl;	    
    }
    return 0;
} 


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

int main()
{
  string S;
  cin >> S;
  int n;
  int i;
  int zero=0,one=0,zerozero=0,oneone=0;
  n=S.length();

  if(n==1)
  {
      cout<<0;
      return 0;
  }

  i=0;
  while(n>i)
  {
      if(S[i]=='0')zero++;
      if(S[i]=='1')one++;
      i=i+2;
  }
  i=1;
    while(n>i)
  {
      if(S[i]=='0')zerozero++;
      if(S[i]=='1')oneone++;
      i=i+2;
  }
  cout << min(one+zerozero,zero+oneone);
  return 0;
}

Measured memory_bytes: 512
//#include "stdc++.h"
#include<bits/stdc++.h>
#include<iostream>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define pb push_back
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0) return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p; }
#define flush fflush(stdout)
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

int main()
{
    IOS;//ifstream fin("input.txt");ofstream fout("output.txt");
    int n;ll W;
    cin>>n>>W;
    ll v[n],w[n];
    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }
    ll dp[100001][n];
    for(int i=0;i<=100000;i++)
        for(int j=0;j<n;j++)
            dp[i][j]=LL_INF;
    for(int i=0;i<n;i++)
        dp[0][i]=0;
    for(int i=1;i<=100000;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(j==0)
            {
                if(v[j]==i)
                    dp[i][j]=w[j];
            }
            else
            {
                if(v[j]<=i)
                dp[i][j]=min(w[j]+dp[i-v[j]][j-1],dp[i][j-1]);
                else
                    dp[i][j]=dp[i][j-1];
            }
        }
    }
    int ans=0;
    for(int i=1;i<=100000;i++)
    {
        if(dp[i][n-1]<=W)
            ans=i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int a, b, t;
	cin >> a >> b >> t;

	cout << (t / a) * b << endl;
}

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

	solve();
}


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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(vs) (ll)(vs.size())
#define rep(i,a,b) for (ll i = a; i < b; ++i)
#define rep_(i,a,b) for (ll i = a; i > b; --i)
#define endl '\n'
const ll mod = 1e9 + 7;

const ll maxn = 1e5;

ll n, m;
ll a[maxn];
vi g[maxn];

void solve() {
	cin >> n >> m;
	int ans = 0;
	rep(i, 0, n) {
		ll x, y;
		cin>> x>> y;
		if (x * x + y * y <= m * m) ans++;
	}
	cout << ans;
}

void aux() {
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout<<fixed<<setprecision(10);
	aux();
	ll _ = 1;
	// cin>>_;
	while(_--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 6000
S = input()
N = len(S)
ans = [0] * N
R = True
even = 1
odd = 0
for i in range(1, N):
    if R and S[i] == 'L':
        if i % 2 == 0:
            ans[i] += even
            ans[i - 1] += odd
        else:
            ans[i] += odd
            ans[i - 1] += even
        odd = 0
        even = 0
        R = False
    else:
        if S[i] == 'R':
            R = True
            if i % 2 == 0:
                even += 1
            else:
                odd += 1

L = True
even = 0
odd = 0
if (N - 1) % 2 == 0:
    even = 1
else:
    odd = 1
for i in range(N - 2, -1, -1):
    if L and S[i] == 'R':
        if i % 2 == 0:
            ans[i] += even
            ans[i + 1] += odd
        else:
            ans[i] += odd
            ans[i + 1] += even
        even, odd = 0, 0
        L = False
    else:
        if S[i] == 'L':
            L = True
            if i % 2 == 0:
                even += 1
            else:
                odd += 1

print(*ans)



Measured memory_bytes: 49980
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

using namespace std;

ll n, m;

int main(){
	cin.sync_with_stdio(0);
	cin >> n >> m;
	
	priority_queue<ll> numbers;
	FOR(i, 0, n) {
		ll next; cin >> next;
		numbers.push(next);
	}
	
	FOR(i, 0, m) {
		ll bigi = numbers.top();
		numbers.pop();
		numbers.push(bigi / 2);
	}
	
	ll output = 0;
	
	FOR(i, 0, n) {
		output += numbers.top();
		numbers.pop();
	}

	
	cout << output << endl;
	
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int MOD  = 1e9 + 7;

int32_t main()
{
  int n,m; cin>>n>>m;
  map<int,int> mp;
  int dp[n + 1] = {};
  for(int i = 0 ; i < m; i++){
  	int tm; cin>>tm;
    mp[tm] = 1;
  }
  dp[0] = 1;
  if(!mp[1]) dp[1] = 1;
  for(int i = 2; i <= n; i++) {
    if(mp[i] == 1) continue; 
  	if(!mp[i - 1]) dp[i] += dp[i - 1];
    if(!mp[i - 2]) dp[i] += dp[i - 2];
    dp[i] %= MOD;
  }
         cout<<dp[n];
  return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    int A,B,C,max;
    A=a+b;
    B=a*b;
    C=a-b;
    max=A;
    if(B>max)
        max=B;
    if(C>max)
        max=C;
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	ll n,c=0;
	cin>>n;
	unordered_map<string,int> m; 
	string s;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		sort(s.begin(),s.end());
		c+=m[s];
		m[s]++;
	}
	cout<<c;
}

Measured memory_bytes: 10660
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            double a = sc.nextDouble();
            System.out.println(a <= 48 ? "light fly" : a <= 51 ? "fly" : a <= 54 ? "bantam" : a <= 57 ? "feather" : a <= 60 ? "light" : a <= 64 ? "light welter" : a <= 69 ? "welter" : a <= 75 ? "light middle" : a <= 81 ? "middle" : a <= 91 ? "light heavy" : "heavy");
        }
    }
}

Measured memory_bytes: 19296
#include <stdio.h>

int main()
{
  int a, b, d, r;
  double f;
  scanf("%d %d", &a, &b);
  d = a/b;
  r = a%b;
  f = (double)a/b;
  printf("%d %d %f\n", d, r, f);

  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-5;
const ll MOD=1e9+7;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
template <typename T>
struct ConvexHullTrick{//単調性仮定CHT
    using L=pair<T,T>;
    vector<L> lines;
    ConvexHullTrick(){}
    bool check(L l1,L l2,L l3){
        if(l1<l3)swap(l1,l3);
        return (l2.first-l3.first)*(l2.second-l1.second)>=(l1.first-l2.first)*(l3.second-l2.second);
    }
    void add(T a,T b){
        L line=make_pair(a,b);
        while(lines.size()>=2&&check(lines[lines.size()-2],lines.back(),line))lines.pop_back();
        lines.push_back(line);
    }
    T f(L line,T x){
        return line.first*x+line.second;
    }
    T query(T x){
        int ng=-1,ok=lines.size()-1;
        while(ok-ng>1){
            int mid=(ok+ng)/2;
            if(f(lines[mid],x)<f(lines[mid+1],x)){
                ok=mid;
            }else{
                ng=mid;
            }
        }
        return f(lines[ok],x);
    }
};
int main(){
    int n;ll c;cin>>n>>c;
    vector<ll> h(n);
    for(int i=0;i<n;i++)cin>>h[i];
    ConvexHullTrick<ll> cht;
    cht.add(-2LL*h[0],h[0]*h[0]);
    for(int i=1;i<n;i++){
        ll dp=cht.query(h[i])+h[i]*h[i]+c;
        cht.add(-2LL*h[i],h[i]*h[i]+dp);
        if(i==n-1)cout<<dp<<endl;
    }
}   


Measured memory_bytes: 8048
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t {... : as Swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool able = (abs(b - a) <= d && abs(c - b) <= d) || abs(a - c) <= d;
    cout << (able ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
until ((n = gets.chomp.to_i) == 0)
	numbers = gets.chomp.split.map(&:to_f)
	squares = numbers.map{|n| n ** 2}
	mean = numbers.inject(:+) / n
	ss = squares.inject(:+)
	sd = Math.sqrt(ss / n - mean ** 2)
	printf("%.5f\n", sd)
end

Measured memory_bytes: 8904
s = input()
li = list(s)
max = 0
count = 0

for i in li:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        count += 1
    else:
        if max < count:
            max = count
        count = 0
if max < count:
    max = count

print(max)


Measured memory_bytes: 2940
#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;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    int n; cin >> n;
    vector<int> G[10005];
    int c[n];
    rep(i,n-1){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,n) cin >> c[i];
    sort(c,c+n); reverse(c,c+n);
    
    vector<P> v;
    rep(i,n) v.push_back(make_pair(G[i].size(),i));
    sort(all(v)); reverse(all(v));
    int ans[n];
    bool visit[n];
    rep(i,n) visit[i] = false;

    queue<int> q;
    q.push(v[0].second);
    int cnt = 0,sum = 0;
    while(!q.empty()){
        int tmp = q.front(); q.pop();
        visit[tmp] = true;
        ans[tmp] = c[cnt];
        cnt++;
        for(auto i : G[tmp]){
            if(!visit[i]) q.push(i);
        }
    }
    for(int i = 1; i < n; i++) sum += c[i];

    cout << sum << endl;
    rep(i,n) cout << ans[i] << ' ';
}

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


using namespace std;

int main() {
    int n; cin >> n;
    long long res;
    cin >> res;
    for (int i = 1; i < n; i++) {
        long long x; cin >> x;
        res = x*res/__gcd(x, res);
    }
    cout << res << endl;
}


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

int main() {
	int i, n, tmp, sum;
	priority_queue<int> q;
	while (1) {
		cin >> n;
		if (n == 0)break;
		sum = 0;
		for (i = 0; i < n; i++) {
			cin >> tmp;
			q.push(tmp);
		}
		q.pop();
		while (q.size() > 1) {
			sum += q.top();
			q.pop();
		}
		q.pop();
		cout << sum / (n - 2) << endl;
	}





	return 0;
}

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

using namespace std;

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

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

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

int N;
vector<int> v[30][2];
int cnt[30];

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

    scanf("%d", &N);

    int a1 = 0, b1 = 0;
    
    for(int i=0;i<N;++i){
        int a;
        scanf("%d", &a);

        if(a & 1){
            ++a1;
        }

        for(int j=1;j<30;++j){
            v[j][a >> j & 1].emplace_back(a & ((1 << j) - 1));
        }
    }

    for(int i=1;i<30;++i){
        for(int j=0;j<2;++j){
            sort(v[i][j].begin(), v[i][j].end());
        }
    }
    
    for(int i=0;i<N;++i){
        int b;
        scanf("%d", &b);

        if(b & 1){
            ++b1;
        }

        for(int j=1;j<30;++j){
            int y = b >> j & 1;
            int w = b & ((1 << j) - 1);
            int n = 0;
            // xi = 0
            n += v[j][0].end() - lower_bound(v[j][0].begin(), v[j][0].end(), (1 << j) - w);
            
            // xi = 1
            n += lower_bound(v[j][1].begin(), v[j][1].end(), (1 << j) - w) - v[j][1].begin();

            if(y == 0){
                cnt[j] ^= n & 1;
            }else{
                cnt[j] ^= (N - n) & 1;
            }
        }
    }

    cnt[0] = (a1 % 2) * ((N - b1) % 2) + ((N - a1) % 2) * (b1 % 2);
    cnt[0] = cnt[0] & 1;
    
    int res = 0;
    for(int i=0;i<30;++i){
        res |= cnt[i] << i;
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 28376
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main(){
	int x, y, z;
	int s, ans;
	scanf("%d %d", &x, &y);


	if(((x+1)/2)<y)printf("NO\n");
	else printf("YES\n");
	return 0;
}



Measured memory_bytes: 128
import java.io.PrintWriter;
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = sc.nextInt();
        switch (n % 10) {
            case 2:
            case 4:
            case 5:
            case 7:
            case 9:
                System.out.println("hon");
                return;
            case 0:
            case 1:
            case 6:
            case 8:
                System.out.println("pon");
                return;
            case 3:
                System.out.println("bon");
                return;
        }

        // out.println("Hello World");
        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 35808
program main
  implicit none
  integer(8) :: m = 10 ** 9 + 7
  integer(8) :: n, k, i, g, res
  integer(8), allocatable :: s(:), t(:)
  read *, n, k
  allocate (s(k), t(k))
  do i = 1, k
    t(i) = get_t(i)
  end do
  s(:) = t(:)
  do g = k, 1, -1
    do i = 2, k / g
      s(g) = s(g) - s(i * g)
      s(g) = modulo(s(g), m)
    end do
  end do
  res = 0
  do g = 1, k
    res = res + g * s(g)
    res = modulo(res, m)
  end do
  print "(i0)", res

  contains

  integer(8) function get_t(f)
    integer(8), intent(in) :: f
    integer(8) :: ng
    ng = k / f
    get_t = pow(ng, n)
  end function get_t

  recursive function pow(n, p) result(res)
    integer(8), intent(in) :: n, p
    integer(8) :: res
    if (p == 0) then
      res = 1
    else if (modulo(p, 2_8) == 0) then
      res = modulo(pow(n, p / 2) ** 2, m)
    else
      res = modulo(pow(n, p - 1) * n, m)
    end if
  end function pow
end program main


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main(){
int n,m,k;
cin>>n>>m>>k;
rep(i,n+1){
  rep(j,m+1){
    int black=(n-i)*j+(m-j)*i;
    
    //if(black<2000) cout<<black<<endl;
    if(black==k){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
}

cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define sc(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d%d", &a, &b)
#define sc3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define scl(a) scanf("%lld", &a)
#define scl2(a, b) scanf("%lld%lld", &a, &b)
#define ss(a) scanf("%s", a)
#define mem(a, b) memset(a, b, sizeof(a))
#define PII pair<int, int>
using namespace std;
const int N = 2e5 + 5;
int a[N], k, n;
bool check(int x)
{
    int res = 0;
    for (int i = 1; i <= n; i++)
    {
        if (a[i] != x)
            res += a[i] / x;
    }
    return res > k;
}
int main()
{
    int res = -1;
    sc2(n, k);
    for (int i = 1; i <= n; i++)
    {
        sc(a[i]);
        res = max(res, a[i]);
    }
    int l = 1, r = res, ans = 0;
    while (l <= r)
    {
        int mid = l + r >> 1;
        if (check(mid))
            l = mid + 1, ans = mid;
        else
            r = mid - 1;
    }
    cout << ans+1 << endl;
    system("pause");
    return 0;
}

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

using namespace std;

int main(){
	string A, B; cin >> A >> B;
	if(A.size() > B.size()){
		cout << "GREATER" << endl;
		return 0;
	}else if(A.size() < B.size()){
		cout << "LESS" << endl;
		return 0;
	}
	for(int i = 0;; ++i){
		if(A[i] > B[i]){
			cout << "GREATER" << endl;
			break;
		}else if(A[i] < B[i]){
			cout << "LESS" << endl;
			break;
		}
		if(A[A.size()-1] == B[B.size()-1]){
			cout << "EQUAL" << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long cnt = K;
		for(int i = 0 ; i < N - 1 ; i++) {
			cnt = cnt * (K - 1);
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 21844
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 100002;

int n;

ll a[N_MAX];

vector <int> edges[N_MAX];

int root;

bool ok = true;

ll dfs (int u, int parent = -1)
{
    if(edges[u].size() == 1)
        return a[u];
    ll sum = 0;
    ll mx = 0;
    for(int v : edges[u])
        if(v != parent)
        {
            ll up = dfs(v, u);
            sum += up;
            mx = max(mx, up);
        }
    ll maxPairs = (sum / 2 - max(0LL, mx - ((sum + 1) / 2)));
    if(sum - a[u] < 0)
        ok = false;
    if(sum - a[u] > maxPairs)
        ok = false;
    return a[u] * 2 - sum;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 1; i < n; i++)
    {
        int u, v;
        cin >> u >> v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    if(n == 2)
    {
        if(a[1] == a[2])
            cout << "YES\n";
        else
            cout << "NO\n";
        return 0;
    }
    for(int i = 1; i <= n; i++)
        if((int)edges[i].size() > 1)
        {
            root = i;
            break;
        }
    if(dfs(root) == 0 && ok == true)
        cout << "YES\n";
    else
        cout << "NO\n";
    return 0;
}


Measured memory_bytes: 16396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
int main(){
    ll n,m;cin>>n>>m;
    if(n&1){
        rep(i,m)cout<<i+1<<' '<<n-i<<endl;
    }
    else{
        vp ans(m);
        rep(i,m)ans[i]=P(i+1,n-i);
        REP(k,n/2/2,m)ans[k].se--;
        rep(i,m)cout<<ans[i].fi<<' '<<ans[i].se<<endl;
    }
}

Measured memory_bytes: 4088
#pragma warning( disable : 6031)

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <math.h>
int minimum(int a, int b) { return a < b ? a : b; }
int maximum(int a, int b) { return a > b ? a : b; }
//const long long mod = 1000000007;
const long long mod = 998244353;
using std::vector;
using std::pair;
using std::string;
using std::map;
using std::abs;
using std::priority_queue;

int main() {
	int K;
	scanf("%d", &K);
	char S[101];
	scanf("%s", S);
	for (int i = 0; S[i] != 0; i++) {
		if (i == K) {
			printf("...");
			break;
		}
		else {
			printf("%c", S[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 1724
N, M, X = map(int, input().split())

l = []
for i in range(N):
	a = list(map(int, input().split()))
	l.append(a)

money_min = 100000000
for bit in range(1 << N):
	bag = []
	for i in range(N):
		if ((bit >> i) & 1):
			bag.append(l[i])
	skill = [0]*M
	enough = [0]*M
	money = 0
	for sub in bag:
		money += sub[0]
		#print(money)
		for j in range(M):
			skill[j] += sub[j+1]
		#print(skill)
	for k in range(M):
		if skill[k] >= X:
			enough[k] += 1
		else:
			enough[k] = enough[k]
	if 0 not in enough:
		if money < money_min:
			money_min = money
		else:
			money_min = money_min

if money_min != 100000000:
	print(money_min)
else:
	print(-1)

Measured memory_bytes: 9100
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    S = input()
    T = input()

    dict = {}
    for s, t in zip(S, T):
        if dict.get(t) is not None and dict[t] != s:
            print("No")
            exit()
        else:
            dict[t] = s

    if len(set(dict.values())) == len(dict):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    resolve()


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

using namespace std ;
#define int long long int

const int maxn = 1e3 + 5;


int32_t main(){
   // #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
      //freopen("output.txt", "w", stdout);
    //#endif
    int n ;
    cin >> n ;
    vector<int>h(n);
    for(int i =0; i < n ; i++ ) cin >> h[i];
    vector<int>dp(n, 1e9);
    dp[0] = 0;
    for(int i = 1 ; i < n ; i++ ){
        if(i - 2 >= 0 ) dp[i] = min(dp[i], dp[i-2] + abs(h[i] -h[i-2]) );
        if(i-1 >= 0 ) dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

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

int func(string s, string t) {
    int ans = 0;
    for (char c = 'a'; c <= 'z'; ++c) {
        bool found_s = false, found_t = false;
        rep(i, s.size()) {
            if (s[i] == c) found_s = true;
        }
        rep(i, t.size()) {
            if (t[i] == c) found_t = true;
        }
        if (found_s && found_t) ++ans;
    }
    return ans;
}

int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    FOR(i, 1, N - 1) {
        int tmp = func(S.substr(0, i), S.substr(i));
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		int ans = x + y + 1;
		while(true) {
			if(x < y) {
				int tmp = x;
				x = y;
				y = tmp;
				continue;
			}
			if(y == 0) {
				ans -= x;
				break;
			}
			x %= y;
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 26332
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

string s[105];
bool used[105][105];
signed main(void)
{
  while(true) {
    int h, w;
    cin >> h >> w;
    if(!h && !w) break;
    REP(i, h) cin >> s[i];

    int x = 0, y = 0;
    memset(used, false, sizeof(used));
    while(true) {
      if(used[y][x]) {
        cout << "LOOP" << endl;
        break;
      }
      used[y][x] = true;
      if(s[y][x] == '>') {
        x++;
      } else if(s[y][x] == '<') {
        x--;
      } else if(s[y][x] == '^') {
        y--;
      } else if(s[y][x] == 'v') {
        y++;
      } else {
        cout << x << " " << y << endl;
        break;
      }
    }
  }

  return 0;
}

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


int main()
{
	int mod = 1e9 + 7;
	int n; cin >> n;
	ll ans = 0, sum = 0;
	for (int i = 0; i < n; ++i)
	{
		ll A; cin >> A;
		ans = (ans + sum * A) % mod;
		sum = (sum + A) % mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3520