akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define All(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int N;
ll K;
vector<ll> P, M, Z;

bool judge_m(ll mid) {
    ll sum = 0;
    for (int i = 0; i < (int)P.size(); i++) {
        ll d = (mid - P[i] + 1) / P[i];
        sum += upper_bound(M.begin(), M.end(), d) - M.begin();
    }
    return sum >= K;
}

bool judge_p(ll mid) {
    ll sum = 0;
    for (int i = 0; i < (int)P.size(); i++) {  // 正と正の積
        ll d = mid / P[i];
        ll tmp = upper_bound(P.begin(), P.end(), d) - P.begin();
        if (i < tmp) tmp--;  // 自身を除く
        sum += tmp;
    }
    for (int i = 0; i < (int)M.size(); i++) {  // 負と負の積
        ll d = mid / M[i];
        ll tmp = upper_bound(M.begin(), M.end(), d) - M.begin();
        if (i < tmp) tmp--;  // 自身を除く
        sum += tmp;
    }
    sum /= 2;
    return sum >= K;
}

int main() {
    cin >> N >> K;
    vector<ll> A(N);
    REP(i, N) cin >> A.at(i);
    REP(i, N) {  // Aを正か負か0かで分類
        if (A[i] > 0) {
            P.push_back(A[i]);
        } else if (A[i] < 0) {
            M.push_back(A[i]);
        } else {
            Z.push_back(A[i]);
        }
    }

    ll p = P.size();
    ll m = M.size();
    ll z = Z.size();
    ll minus = p * m;
    ll zero = z * (z - 1) / 2 + z * p + z * m;
    ll plus = p * p + m * m;

    if (K <= minus) {  // X が負の時
        sort(All(M));
        ll l = -1e18, u = 0;  // 二分探索: (l,u]に答えがある
        while (u - l > 1) {
            ll mid = (u + l) / 2;
            if (judge_m(mid)) {
                u = mid;
            } else {
                l = mid;
            }
        }
        cout << u << endl;

    } else if (K <= minus + zero) {  // X が 0 の時
        cout << 0 << endl;

    } else if (K <= minus + zero + plus) {  // X が正の時
        K -= (minus + zero);
        REP(i, m) M[i] = abs(M[i]);  // 中身を正に変更
        sort(All(P));
        sort(All(M));
        ll l = 0, u = 1e18;  //二分探索: (l,u]に答えがある
        while (u - l > 1) {
            ll mid = (u + l) / 2;
            if (judge_p(mid)) {
                u = mid;
            } else {
                l = mid;
            }
        }
        cout << u << endl;
    }
    return 0;
}


Measured memory_bytes: 4084
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


template <class Monoid>
class SegmentTree
{
public:
  using Func = function<Monoid(Monoid, Monoid)>;
  const Func F;
  const Monoid M1;
  int sz;
  vector<Monoid> seg;

  SegmentTree(int n,const Func fu, const Monoid &m1): F(fu) , M1(m1) {init(n);}
  void init(int n)
  {
      sz= 1;
      while (sz <= n) sz *= 2;
      seg.assign(sz * 2, M1);
  }
  void update(int k,const Monoid &x)
  {
    k+=sz;
    seg[k]=x;
    while(k>>=1)
    {
      seg[k]=F(seg[k*2],seg[k*2+1]);
    }
  }
  Monoid query(int l,int r)
  {
    Monoid L=M1,R=M1;
    l+=sz;r+=sz;
    for(;l<r;l>>=1,r>>=1)
    {
      if(l&1)L=F(L,seg[l++]);
      if(r&1)R=F(seg[--r],R);
    }
    return F(L,R);
  }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;cin>>n>>m;
  vector<vector<ll>>ed(n),red(n);
  vector<ll>d(n),res(n);
  rep(i,m+n-1){
    ll a,b;cin>>a>>b;
    a--;b--;
    ed[a].push_back(b);
    red[b].push_back(a);
  }
  ll root;
  rep(i,n){
    if(red[i].size()==0)root=i;
  }
  vector<ll>flag(n);
  rep(i,n)flag[i]=red[i].size();
  queue<ll>q;
  q.push(root);
  while(!q.empty()){
    ll v=q.front();q.pop();
    for(auto nv:ed[v] ){
      flag[nv]--;
      if(flag[nv]==0){
        q.push(nv);
        res[nv]=v+1;
      }
    }
  }
  rep(i,n)cout<<res[i]<<endl;



  return 0;

}


Measured memory_bytes: 14080
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int A, B;
	cin >> A >> B;
	bool flag = A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0;

	cout << (flag ? "Possible" : "Impossible") << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
'''A - ABC333
https://atcoder.jp/contests/abc109/tasks/abc109_a

>>> main(3, 1)
Yes
>>> main(1, 2)
No
>>> main(2, 2)
No'''


def main(a, b):
    if a * b % 2 == 0:
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    a, b = map(int, input().split(' '))

    main(a, b)


Measured memory_bytes: 2940
from collections import defaultdict as dd
N = int(input())
B = list(map(int, input().split()))

ans = []
for _ in range(N):
  for i in range(len(B))[::-1]:
    if B[i] == i+1:
      ans.append(i+1)
      B = B[:i] + B[i+1:]
      break
  else:
    print(-1)
    exit()

for a in ans[::-1]:
  print(a)

Measured memory_bytes: 3316
def main():
    x, y, a, b, c = map(int, input().split())
    p = list(sorted(list(map(int, input().split())), reverse=True))[:x]
    q = list(sorted(list(map(int, input().split())), reverse=True))[:y]
    r = list(map(int, input().split()))
    print(sum(list(sorted(p+q+r, reverse=True))[:(x+y)]))
if __name__ == "__main__":
    main()

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

int main(){
  int i,j,cnt=0;
  int n;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  ll prod=1;
  for(i=n-1;i>=1;i--){
    if(a[i]==a[i-1]){
      prod*=a[i];
      i--;
      cnt++;
    }
    if(cnt==2)break;
  }
  if(cnt==2)cout<<prod<<endl;
  else cout<<0<<endl;
}

Measured memory_bytes: 640
import math

N,H=map(int, input().split())

A=[]
B=[]
for i in range(N):
    a,b=map(int, input().split())
    A.append(a)
    B.append(b)

ans=0

B.sort(reverse=True)
Am=max(A)
for i in range(N):
    if B[i]>=Am:
        H-=B[i]
        ans+=1
    if H<=0:
        break

if H>0:
    ans+=math.ceil(H/Am)

print(ans)


Measured memory_bytes: 11312
#include <cstdio>
#include <cstring>
#include <iostream>
#define MN 101000

int n, k;

struct xxx{
	int a[MN];
}g, G, p, q, f[7];

xxx inv(xxx a)
{
	xxx c;
	for(int i = 1; i <= n; i++) c.a[a.a[i]] = i;
	return c;
}

xxx mul(xxx a, xxx b)
{
	xxx c;
	for(int i = 1; i <= n; i++) c.a[i] = b.a[a.a[i]];
	return c;
}

xxx init()
{
	xxx a;
	for(int i = 1; i <= n; i++) a.a[i] = i;
	return a;
}

xxx qpow(xxx x, int p)
{
	xxx ans; ans = init();
	for(; p; p >>= 1, x = mul(x, x)) if(p & 1) ans = mul(ans, x);
	return ans;
}

int main()
{
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; i++) scanf("%d", &p.a[i]);
	for(int i = 1; i <= n; i++) scanf("%d", &q.a[i]);
	g = mul(mul(mul(inv(q), p), q), inv(p)); G = inv(g);
	f[0] = init(); f[1] = p; f[2] = q;
	for(int i = 3; i <= 6; i++) 
		f[i] = mul(inv(f[i - 2]), f[i - 1]);
	xxx ans = mul(mul(qpow(g, k / 6 - (k % 6 == 0)), f[k % 6 == 0 ? 6 : k % 6]), qpow(G, k / 6 - (k % 6 == 0)));
	for(int i = 1; i <= n; i++) printf("%d ", ans.a[i]);
}

Measured memory_bytes: 13956
/************************* In the name of Allah *************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long       ll;
typedef long double     ld;
typedef string          str;
typedef pair<ll,ll>     pll;

#define F               first
#define S               second
#define pb              push_back
#define sep             ' '
#define endl            '\n'
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll MOD = 1e9 + 7,
         INF = 1e18,
         MAXN = 1e5 + 10;

const int N = 1e5 + 10;

int a[N];

int main(){
    fast_io
    int n;
    cin >> n;
    for (int i = 0; i < n; i ++)
        cin >> a[i];
    int ans = 0, now = 0;
    int ptr = 0;
    while (ptr < n)
    {
        now = 0;
        while (ptr + 1 < n && a[ptr] >= a[ptr + 1])
        {
            now ++;
            ptr ++;
        }
        ptr ++;
        ans = max(ans, now);
    }
    cout << ans;
    return 0;
}

/*
 __  __       _         _ _  _____ _           _                __ _
|  \/  |     | |       | (_)/ ____| |         | |              / _(_)
| \  / | __ _| |__   __| |_| (___ | |__   ___ | | _____  _   _| |_ _
| |\/| |/ _` | '_ \ / _` | |\___ \| '_ \ / _ \| |/ / _ \| | | |  _| |
| |  | | (_| | | | | (_| | |____) | | | | (_) |   < (_) | |_| | | | |
|_|  |_|\__,_|_| |_|\__,_|_|_____/|_| |_|\___/|_|\_\___/ \__,_|_| |_|
*/


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <chrono>
#include<math.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std::chrono;
using namespace std;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// declaration: ordered_set os;  methods->  1. *os.find_by_order(x)   2. os.order_of_key(k) ->return int

#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<ll,ll>
#define ll long long int
#define ld long double
const ll mod=1e9+7;
const int N=2e6+5;
/*
ll f(ll x, ll n){
    ll r=1;
    while(n>0){
        if(n&1)
        r=(r*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return r;
}

ll fact[N],ifact[N];
void build(){
    fact[0]=1;
    fact[1]=1;
    for(ll i=2;i<N;i++)
    fact[i]=(fact[i-1]*i)%mod;
    fr(i,0,N)
    ifact[i]=f(fact[i],mod-2);
}
ll C(ll n, ll r){
    if(r==0)
    return 1;
    ll ans=fact[n];
    ans=(ans*ifact[r])%mod;
    ans=(ans*ifact[n-r])%mod;
    return ans;
}
vector<vector<ll> > matmul(vector<vector<ll> > v1,vector<vector<ll> > v2){
    vector<vector<ll> > v(6,vector<ll>(6,0));
    fr(i,0,6){
        fr(j,0,6){
            fr(k,0,6)
            v[i][j]=(v[i][j]+ v1[i][k]*v2[k][j])%mod;
        }
    }
    return v;
}
vector<vector<ll> > matf(ll n){
    vector<vector<ll> >z={
    {1,1,1,1,1,1},
    {1,0,0,0,0,0},
    {0,1,0,0,0,0},
    {0,0,1,0,0,0},
    {0,0,0,1,0,0},
    {0,0,0,0,1,0}},
    r={{1,0,0,0,0,0},
    {0,1,0,0,0,0},
    {0,0,1,0,0,0},
    {0,0,0,1,0,0},
    {0,0,0,0,1,0},
    {0,0,0,0,0,1}};

    while(n>0){
        if(n&1){
            r=matmul(r,z);
        }
        z=matmul(z,z);
        n/=2LL;
    }
    return r;
}*/
void solve(){
    int n;
    cin>>n;
    int a[n];
    fr(i,0,n)
    cin>>a[i];
    int x=0;
    fr(i,0,n)
    x^=a[i];
    fr(i,0,n)
    cout<<(x^a[i])<<" ";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//    build();
    int t=1;
//    cin>>t;
    while(t--)
    solve();

}


Measured memory_bytes: 4376
import sys
import math
import collections
import bisect
import itertools
import decimal

# import numpy as np

# sys.setrecursionlimit(10 ** 6)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    d, t, s = ns()
    flg = d <= t * s
    print("Yes" if flg else "No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 70916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=5005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;
 
ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}
 
ll n,k;
ll a[maxn];
 
ll cnt[maxn]={1};
ll meow[maxn];
int main()
{
	IOS;
	cin>>n>>k;
	REP(i,n) cin>>a[i];
	REP(i,n){
	    for(int j=maxn-1;j>=0;j--){
	        if(j+a[i]>=maxn) continue;
	        cnt[j+a[i]]+=cnt[j];
	        if(cnt[j+a[i]]>=MOD) cnt[j+a[i]]-=MOD;
	    }
	}
	int ans=0;
	REP(I,n){
	    REP(i,maxn) meow[i]=cnt[i];
	    for(int i=0;i<maxn;i++) if(i+a[I]<maxn){
	        meow[i+a[I]]-=meow[i];
	        if(meow[i+a[I]]<0) meow[i+a[I]]+=MOD;
	    }
	    bool f=0;
	    for(int i=max(0LL,k-a[I]);i<k;i++) if(meow[i]) f=1;
	    if(!f) ans++;
	//REP(i,10) cout<<meow[i]<<" \n"[i==9];
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 384
H, W = map(int, input().split())
a = [input() for _ in range(H)]

yoko = [False] * H
for i in range(H) :
    k = set()
    for j in range(W) :
        k.add(a[i][j])
    if len(k) == 1 and '.' in k :
        yoko[i] = True
        
tate = [False] * W
for i in range(W) :
    k = set()
    for j in range(H) :
        k.add(a[j][i])
    if len(k) == 1 :
        tate[i] = True
        
for i in range(H) :
    if yoko[i] : 
        continue
    s = ''
    for j in range(W) :
        if tate[j] and '.' in k :
            continue
        s += a[i][j]
    print(s)
            

Measured memory_bytes: 39152
package main

import (
  "fmt"
)

func main() {
  var n int
  fmt.Scan(&n)
  ls := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&ls[i])
  }
  max := 0
  sum := 0
  for _, l := range ls {
    sum += l
    if max < l {
      max = l
    }
  }
  sum -= max
  result := "No"
  if max < sum {
    result = "Yes"
  }
  fmt.Println(result)
  
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
  int A;
  int B;
  int C;
  int D;
  
  cin >> A >> B >> C >> D;
  if(A + B > C + D)
  {
    cout << "Left" << endl;
  }
  else if(A + B < C + D)
  {
    cout << "Right" << endl;
  }
  else if(A + B == C + D)
  {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 3616
import math 
a,b,h,m = map(int,input().split())


minutes=h*60+m

sx=b*math.cos(math.radians((90-6*minutes)%360))
sy=b*math.sin(math.radians((90-6*minutes)%360))

tx=a*math.cos(math.radians((90-0.5*minutes)%360))
ty=a*math.sin(math.radians((90-0.5*minutes)%360))


l = math.sqrt(
    (sx-tx)**2 + (sy-ty)**2
    )

print(l)


Measured memory_bytes: 9512
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
input = input.split('\n').map(line => line.split(' '));

const N = Number(input[0][0]);
const M = Number(input[0][1]);

var cp = 0;
var pp = 0;
var done = {};
var pena = {}
for (var i = 1; i < input.length; i++) {
    var p = Number(input[i][0]);
    var S = input[i][1];
    if (!done[p] && S == 'AC') {
        done[p] = true;
        cp++;
        pp += pena[p] ? pena[p] : 0;
    } else if(!done[p] && S == 'WA') {
        if (!pena[p]) {
            pena[p] = 0;
        }
        pena[p]++;
    }
}
console.log(cp+' '+pp);

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n, k;
string s;

int qp(int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1) res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}

int C(int a, int b)
{
	int res = 1;
	for (int i = a; i > a - b; i -- ) res = res * i;
	for (int i = 1; i <= b; i ++ ) res = res / i;
	return res;
}

int main()
{
	cin >> s >> k;
	n = s.size();
	
	int res = 0;
	// for (int i = 1; i < n; i ++ )
		// if (i >= k)
			// res += C(i - 1, k - 1) * qp(9, k);
	
	vector<int> num;
	for (int i = 0; i < n; i ++ ) num.PB(s[i] - '0');
	
	// cout << res << endl;
	
	int last = 0;
	for (int i = 0; i < n; i ++ )
	{
		int x = num[i];
		
		if (x)
		{
			res += C(n - i - 1, k - last) * qp(9, k - last);
			last ++ ;
			res += (x - 1) * C(n - i - 1, k - last) * qp(9, k - last);
		}
		
		// cout << res << endl;
		
		if (last == k)
		{
			res ++ ;
			break;
		}
	}
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin

def main():
    N, Y = map(int, stdin.readline().rstrip().split())
    ans=0
    for i in range(N+1):
      for j in range(N+1):
        k = N-i-j
        if (k >= 0 and 10000*i + 5000*j + 1000*k == Y):
          print("{} {} {}".format(i, j, k))
          return
    print("-1 -1 -1")

input = lambda: stdin.readline()
main()


Measured memory_bytes: 3060
n,m=map(int,input().split())
h=list(map(int,input().split()))
t=[]
for i in range(m):
    t.append(list(map(int,input().split())))
ans=[True]*n
for i in range(m):
    a,b=t[i]
    if(h[a-1]<=h[b-1]):
        ans[a-1]=False
    if(h[b-1]<=h[a-1]):
        ans[b-1]=False
print(ans.count(True))

Measured memory_bytes: 31964
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    LL n, a[5];
    cin >> n;
    for( int i = 0; i < 5; ++i ) cin >> a[i];
    LL m = LINF;

    for( int i = 0; i < 5; ++i ) {
        m = min( m, a[i] );

    }
    LL ans = n / m;
    if( n % m ) ++ans;
    --ans;
    ans += 5;

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



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

using namespace std;

int N, M, mod = 1e9 + 7;
vector < int > a, b;

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int substract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x % mod * y % mod;}

int solve (vector < int > v)
{
    int ans = 0;
    for (int i=1; i<=v.size (); i++)
    {
        int curr = v[i - 1] % mod;
        if (curr < 0) curr += mod;
        ///de i - 1 ori cu +
        int E = i - 1 - ((int) v.size () - i);
        if (E > 0) ans = add (ans, mul (curr, E));
        else ans = substract (ans, mul (curr, -E));
    }
    return ans;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M);
int val;
for (int i=1; i<=N; i++)
    scanf ("%d", &val), a.push_back (val);
for (int i=1; i<=M; i++)
    scanf ("%d", &val), b.push_back (val);
printf ("%d\n", mul (solve (a), solve (b)));
return 0;
}


Measured memory_bytes: 1912
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_CHAR_CNT		26										// 文字種類数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i, j;
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 文字列数取得
	int liSCnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d", &liSCnt);

	// 最小文字数 - 初期化
	int li1Min[D_CHAR_CNT];
	for (i = 0; i < D_CHAR_CNT; i++) {
		li1Min[i] = D_CHAR_CNT;
	}

	// 文字列取得
	for (i = 0; i < liSCnt; i++) {
#ifdef D_TEST
		fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
		fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif

		// 各文字数 - 初期化
		int li1Cnt[D_CHAR_CNT];
		memset(li1Cnt, 0, sizeof(li1Cnt));

		// 各文字数 - 取得
		for (j = 0; lc1Buf[j] != '\0'; j++) {
			li1Cnt[lc1Buf[j] - 'a']++;
		}

		// 最小文字数 - 更新
		for (j = 0; j < D_CHAR_CNT; j++) {
			if (li1Min[j] > li1Cnt[j]) {
				li1Min[j] = li1Cnt[j];
			}
		}
	}

	// 結果セット
	int liNo = 0;
	for (i = 0; i < D_CHAR_CNT; i++) {
		for (j = 0; j < li1Min[i]; j++) {
			lc1Out[liNo] = 'a' + i;
			liNo++;
		}
	}
	lc1Out[liNo] = '\n';
	lc1Out[liNo + 1] = '\0';

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;

typedef long long ll;
ll MOD = 1e9+7;

int black[200010];
int white[200010];
int main()
{
	int n;
	string s;
	int ans=1e8-1;
	cin>>n;
	cin>>s;
	fill(black,black+n+10,0);
	fill(white,white+n+10,0);
	for(int i=0;i<n;i++)
	{
		if(s[i]=='.')
		{
			white[i+1]=white[i]+1;
			black[i+1]=black[i];
		}else{
			white[i+1]=white[i];
			black[i+1]=black[i]+1;
		}
	}
	//区切る場所
	for(int i=1;i<n;i++)
	{
		int cnt=(i-white[i])+((n-i)-(black[n]-black[i]));
		//cerr<<i-white[i]<<" "<<(n-i)-(black[n]-black[i])<<endl;
		ans=min(ans,cnt);
	}
	//全部黒
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='.')
			cnt++;
	}
	ans=min(cnt,ans);
	cnt=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='#')
			cnt++;
	}
	ans=min(cnt,ans);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2180
from fractions import math

N,M = map(int,input().split())

ans = 1
for i in range(1,int(math.sqrt(M))+1):
    if M%i==0: #Mの約数か
        j = M//i
        if j<=M/N and j>ans:
            ans = j
        elif i<=M/N and i>ans:
            ans = i
            
print(ans)

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

int main(){
  string w;
  vector<int> cnt(26, 0);
  
  cin >> w;
  
  for(int i = 0;i < w.size();i++) cnt.at(w.at(i) - 'a')++;
  
  for(int i = 0;i < 26;i++){
    if(cnt.at(i) % 2){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 3600
N = int(input())
p = list(map(float, input().split()))

dp = []
for i in range(N+1):
	z = []
	for j in range(N):
		z.append(0)
	dp.append(z)

dp[0][0] = 1-p[0]

for i in range(N-1):
	dp[0][i+1] = dp[0][i]*(1-p[i+1])

dp[1][0] = p[0]

for i in range(N+1):
	for j in range(N-1):
		if j >= i-1 :
			dp[i+1][j+1]=p[j+1]*dp[i][j] + (1-p[j+1])*dp[i+1][j]
k = (N//2)+1
sump = 0
while(k<=N):
	sump += dp[k][N-1]
	k+=1
print(sump)

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

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

    vector<int> a(M);

    int s = 0;

    for (int i = 0; i < M; ++i) {
        cin >> a.at(i);
        s += a.at(i);
    }

    if (s <= N) { cout << N - s << endl; }
    else { cout << -1 << endl; }

}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define pb push_back
#define ppb pop_back
#define cs(n) cout<<n<<" "
#define cn(n) cout<<n<<"\n"
#define rep(i,j,k) for(int i=j;i<k;i++)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define N 500005
int seg[4 * N + 7];
int arr[N + 7];
map<int , int>mp;
map<pair<pair<int , int>, int> , int>mp1;
vector<pair<pair<int , int>, int> >v, v1;
ll bin(ll a, ll b)
{
	if (b == 0)
		return 1;
	if (b % 2 == 0)
		return bin((a * a) % mod , b / 2) % mod;
	return ((a % mod) * (bin((a * a) % mod , b / 2) % mod)) % mod;
}
int query(int i, int j, int k, int a, int b) {
	if (a > k || j > b) {
		return 0;
	}
	if (a <= j && b >= k) {
		return seg[i];
	}
	int mid = (j + k) / 2;
	int val1, val2;
	val1 = query(2 * i, j, mid, a, b);
	val2 = query(2 * i + 1, mid + 1, k, a, b);
	return (val1 + val2);
}
void update(int i, int j, int k, int a , int val) {
	if (j == k) {
		seg[i] = val;
		return;
	}
	int mid = (j + k) / 2;
	if (a <= mid)
		update(2 * i, j, mid, a, val);
	else
		update(2 * i + 1, mid + 1, k, a, val);
	seg[i] = seg[2 * i] + seg[2 * i + 1];
}
void solve()
{
	int n;
	int q;
	cin >> n;
	cin >> q;
	rep(i, 1, n + 1) {
		cin >> arr[i];
		pair<pair<int , int>, int>p;
		p.first.first = i;
		p.first.second = -1;
		p.second = arr[i];
		v.pb(p);
	}
	while (q--) {
		int a, b;
		cin >> a >> b;
		pair<pair<int , int>, int>p;
		p.first.first = b;
		p.first.second = a;
		p.second = 0;
		v.pb(p);
		v1.pb(p);
	}
	sort(v.begin(), v.end());
	rep(i, 0, v.size()) {
		if (v[i].first.second == -1) {
			if (mp[v[i].second] == 0) {
				update(1, 1, n, v[i].first.first, 1);
				mp[v[i].second] = v[i].first.first;
			}
			else {
				update(1, 1, n, mp[v[i].second], 0);
				update(1, 1, n, v[i].first.first, 1);
				mp[v[i].second] = v[i].first.first;
			}
		}
		else {
			mp1[v[i]] = query(1, 1, n, v[i].first.second, v[i].first.first);
		}
	}
	rep(i, 0, v1.size()) {
		cout << mp1[v1[i]] << "\n";
	}
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif
	fastio;
	int t;
	//cin >> t;
	t = 1;
	while (t--)
	{
		solve();
	}
	return 0;
}

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

#define INF 1e9
#define LLINF 1e18
#define pi 3.14159265358979323
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    int ha, ma, hb, mb, k;
    cin >> ha >> ma >> hb >> mb >> k;
    int time = (hb - ha) * 60;
    time += mb - ma;
    cout << time - k << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define endl '\n'
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    ll dp[n];
    dp[0]=0;
    for(ll i=1;i<n;i++)dp[i]=1e9;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<=i+k && j<n;j++){
           if(j<n)dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1792
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

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

    l = len(S)
    R0 = [-1] * 26
    R1 = [-1] * 26

    is_ok = True
    for i in range(l):
        S_num = ord(S[i]) - ord('a')
        T_num = ord(T[i]) - ord('a')
        # print(S_num, T_num)
        if R0[S_num] == -1:
            R0[S_num] = T_num
        else:
            if R0[S_num] != T_num:
                is_ok = False 
                break
        if R1[T_num] == -1:
            R1[T_num] = S_num
        else:
            if R1[T_num] != S_num:
                is_ok = False 
                break

    if is_ok:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10128
package main

import "fmt"

func main(){
	var dis, t, speed int
	var err error

	_, err = fmt.Scanf("%d %d %d", &dis, &t, &speed)
	if err != nil {
		return
	}

	if t*speed >= dis{
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}
	
}


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

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0;i<n;i++)cin >> a[i];
	ll ans = 0;
	for(int i = 0;i<n;i++)ans ^= a[i];
	//cout<<ans<<endl;
	for(int i = 0;i<n;i++)
	{
		cout<<(ans^a[i])<<' ';
	}
	cout<<endl;
}

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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) (in).begin(),(in).end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
  int n,h,w;
  cin >> n >> h >> w;
  int ans = 0;
  for(int i=0;i<n;i++){
    int a,b;
    cin >> a >> b;
    if(a>=h && b>=w)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>
#include <complex>

#define INF 100000000
#define EPS 1e-9

using namespace std;

typedef long long ll; 

#define MAX_N 31
#define MAX_M 501

int N;

string alpha[10];

vector<string> ans_list;

int main(){
  
  cin >> N;

  alpha[1] = ".,!? ";
  alpha[2] = "abc";
  alpha[3] = "def";
  alpha[4] = "ghi";
  alpha[5] = "jkl";
  alpha[6] = "mno";
  alpha[7] = "pqrs";
  alpha[8] = "tuv";
  alpha[9] = "wxyz";

  while(N > 0){
    N--;
    string str, ans;
    cin >> str;
    for(int i = 0; i < str.length(); i++){
      if(str[i] == '0')
	continue;
      int num = 0;
      for(int e = i+1; e < str.length(); e++){
	if(str[i] != str[e]){
	  num = e - i;
	  break;
	}
      }
      ans += alpha[str[i] - '0'][(num-1) % alpha[str[i] - '0'].length()];
      i += num;
    }
    ans_list.push_back(ans);
  }

  for(int i = 0; i < ans_list.size(); i++){
    cout << ans_list[i] << endl;
  }

  return 0;
  
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll a(n);
    vvll x(n), y(n);
    REP(i, n) {
        cin >> a[i];
        vll tx(a[i]), ty(a[i]);
        REP(j, a[i]) {
            cin >> tx[j] >> ty[j];
            tx[j]--;
        }
        x[i] = tx, y[i] = ty;
    }

    ll res = 0;
    // 正直者の可能性を全探索, 矛盾が無ければカウント
    REP(p, (1LL << n)) {
        ll tmp = p, cur = 0;
        vll pset(n);
        REP(i, n) {
            pset[i] = (tmp >> i) & 1;
            cur += pset[i];
        }
        ll ng = 0;
        REP(i, n) {
            if (pset[i]) {
                // i : 正直者なので i の証言は信用するとして矛盾が生じないか調べる
                REP(j, a[i]) {
                    if (pset[x[i][j]] != y[i][j]) {
                        ng = 1;
                        break;
                    }
                }
                if (ng) break;
            }
        }
        if (!ng) res = max(res, cur);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 101,W = 1e5+5;
vvi dp(N,vi (W,0));
int solve()
{
	ll n,w;cin>>n>>w;
	vi a(n),b(n);
	rep(i,0,n) cin>>a[i]>>b[i];

	rep(i,0,n) 
	{
		rep(j,0,w+1)
		{
			if(i==0) dp[i][j] = (j>=a[i]?b[i]:0);
			else dp[i][j] = max((j>=a[i]?dp[i-1][j-a[i]]+b[i]:dp[i-1][j]),dp[i-1][j]);
		}
	}	

	ll ans=0;
	rep(j,0,w+1) ans=max(ans,dp[n-1][j]);
	cout<<ans<<"\n";

	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

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

using namespace std;

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

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

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

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

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

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

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

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

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



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

    if(a+b < c &&  4*a*b < (c-a-b)*(c-a-b))Yes;
    else No;
    
    return  0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#define llong long long
using namespace std;

vector<int>div(int n){
  vector<int>ret;
  for(int i=1; i*i<=n; i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i==n)continue;
      ret.push_back(n/i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

int main(){
  int n, k;
  cin >> n >> k;
  vector<int>a(n);
  for(int i=0; i<n; i++)cin >> a[i];
  int as = accumulate(a.begin(), a.end(), 0);
  vector<int>asd=div(as);
  vector<int>prem(n, 0), mrem(n, 0);
  int ret=1;
  for(int d: asd){
//    cerr << d << ':' << endl;
    long cnt=0;
    for(int i=0; i<n; i++){
      prem[i] = (d-(a[i]%d))%d;
      mrem[i] = d-prem[i];
    }
    sort(mrem.begin(), mrem.end());
    long mul=accumulate(prem.begin(), prem.end(), 0L)/d;
    cnt=accumulate(mrem.begin(), mrem.begin()+mul, 0L);
//    cerr << cnt << endl;
    if(cnt<=k)ret=d;
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int N,M;
vector<int> g[100010];

ll dp[100010];
ll ans[100010];
vector<ll> child[100010];

ll dfs(int now,int par){
  ll res=1;
  for(int nex:g[now]){
    if(nex==par) continue;
    ll z=dfs(nex,now);
    child[now].push_back(z);
    res=res*(z+1)%M;
  }
  res=(res+M)%M;
  return dp[now]=res;
}

void solve(int now,int par,ll pans){
  if(par!=-1){
    ll res=(pans+1)%M;
    for(int i=0;i<child[now].size();i++){
      res=(res*(child[now][i]+1))%M;
    }
    ans[now]=res;
  }

  int n=child[now].size();
  vector<ll> left(n+2),right(n+2);
  left[0]=1;
  right[n+1]=1;
  for(int i=1;i<=n;i++) left[i]=(left[i-1]*(child[now][i-1]+1)%M)%M;
  for(int i=n;i>=1;i--) right[i]=(right[i+1]*(child[now][i-1]+1)%M)%M;

  int p=0;
  for(int i=0;i<g[now].size();i++){
    if(g[now][i]==par){
      p=1;
      continue;
    }
    solve(g[now][i],now,((left[i-p]*right[i+2-p])%M*(pans+1)%M)%M);
  }
}

int main(){
  cin>>N>>M;
  for(int i=1;i<N;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }

  ans[0]=dfs(0,0);
  solve(0,-1,0);
  for(int i=0;i<N;i++) cout<<ans[i]<<endl;

  return 0;
}


Measured memory_bytes: 24832
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;

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

    cout << x*x*x << endl;


    return 0;
}


Measured memory_bytes: 3088
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        char[] s = scanner.next().toCharArray();
        int n = s.length;
        long ans = 0;
        int pre = -2;
        int preCount = 0;
        for (int i = 2; i < n; ++i) {
            if (s[i - 2] == 'A' && s[i - 1] == 'B' && s[i] == 'C') {
                int prefixA = 0;
                int suffixBC = 0;
                int j;
                for (j = i - 2; j >= 0; --j)
                    if (s[j] == 'A')
                        ++prefixA;
                    else
                        break;
                if (j == pre)
                    prefixA += preCount;
                for (j = i; j < n; j += 2)
                    if (s[j - 1] == 'B' && s[j] == 'C')
                        ++suffixBC;
                    else
                        break;
                pre = i = j - 2;
                preCount = prefixA;
                ans += (long) prefixA * suffixBC;
            }
        }
        writer.println(ans);
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 26580
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  ll result = 1;
  for (int i=1; i<=N; i++) { result = (result * i) % MOD; }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 3e5 + 9, M = 1e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll arr[N], arr2[N];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n;
  cin >> n;
  for (int i = 0; i <= n; ++i) {
    cin >> arr[i];
  }
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    cin >> arr2[i];
    ll mn = min(arr2[i], arr[i]);
    ans += mn;
    arr2[i] -= mn;
    if(arr2[i] > 0) {
      mn = min(arr2[i], arr[i + 1]);
      ans += mn;
      arr[i + 1] -= mn;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3072
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int
#define ld long double

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10
#define PI acos(-1LL)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	string s,t;
	cin>>s>>t;

	t+=s;
	cout<<t<<endl;

}

Measured memory_bytes: 3644
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            佛祖保佑       永无BUG
*/
#include<stdio.h>
#define re register
const int maxn=1e5+5;
int n,num[maxn];
char s[maxn];
int main()
{
	scanf("%d%s",&n,s);
	for(re int i=0;i<=1;++i)
	{
		for(re int j=0;j<=1;++j)
		{
			num[0]=i,num[1]=j;
			for(re int k=2;k<n;++k)
				num[k]=(s[k-1]=='x'^num[k-2]^num[k-1]);
			int t0=num[n-1]^num[1]^num[0]^(s[0]=='x');
			int tn=num[0]^num[n-2]^num[n-1]^(s[n-1]=='x');
			if(t0==0&&tn==0)
			{
				for(re int i=0;i<n;++i)
					if(num[i]==0) putchar('S');
					else putchar('W');
				printf("\n");
				return 0; 
			}
		}
	}
	printf("-1");
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
using namespace std;
const int N = 2e5+5,M = 1e6+5;
int h[N],n,c,ans[N];
const int inf = 1e18;
int a[N][3];
int dp[N][3];
main() {
    ios::sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        for (int j = 0; j < 3; j++)
        cin >> a[i][j];
    for (int i = 0;i < 3; i++)
        dp[1][i] = a[1][i];
    for (int i = 2; i <= n; i++) {
        for (int j = 0; j < 3; j++)
            for (int k = 0; k < 3; k++)
            if (j != k)
            dp[i][j] = max(dp[i][j],a[i][j] + dp[i-1][k]);
    }
    cout << max({dp[n][0],dp[n][1],dp[n][2]});
}


Measured memory_bytes: 8336
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int a,b,c,d=0;
    cin>>a;
    int arr[a];
    memset(arr,0,sizeof(arr));

    for(int i=1;i<a;i++){
        cin>>b;
        b--;
        arr[b]++;

    }
    for(int i=0;i<a;i++){
        cout<<arr[i]<<endl;
    }


    return 0;

}



Measured memory_bytes: 4400