akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    def solve(m):
        a1 = a[::-1]
        f1 = f[::1]
        res = 0
        for i in range(n):
            if a1[i] * f1[i] <= m:
                continue
            k = m // f1[i]
            res += a1[i] - k
            if res > K:
                return False
        return True

    n, K = LI()
    a = LI()
    a.sort()
    f = LI()
    f.sort()
    ok = max(a) * max(f)
    ng = -1
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if solve(mid):
            ok = mid
        else:
            ng = mid
    print(ok)
    return

#F
def F():
    return


#Solve
if __name__ == '__main__':
    E()


Measured memory_bytes: 144384
import sys
def gcd(a, b):
    for i in range(1, a+1):
        if a % i == 0:
            t = a // i
            if b % t == 0:
                return t
for line in sys.stdin:
    a, b = sorted(map(int, line.split()))
    gcdab = gcd(a, b)
    print(gcdab, a // gcdab * b)

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

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;

const ll mod = 1e9 + 7;

const int N = 5010;
ll dp[2][N];

int main(void){
  int n;
  string s;
  cin >> n >> s;
  assert (n < N);
  dp[0][0] = 1;
  REP(i, 0, n) {
    int t = (i + 1) % 2;
    dp[t][0] = dp[1-t][0] + 2 * dp[1-t][1];
    dp[t][0] %= mod;
    REP(j, 1, N) {
      dp[t][j] = dp[1-t][j - 1];
      if (j < N - 1) {
	dp[t][j] += 2 * dp[1-t][j + 1];
      }
      dp[t][j] %= mod;
    }
  }
  cout << dp[n % 2][s.length()] << endl;
}


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

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<vector<int>> e(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    e[a - 1].emplace_back(b - 1);
    e[b - 1].emplace_back(a - 1);
  }

  queue<int> q;
  q.push(0);
  vector<bool> v(n);
  v[0] = true;
  vector<int> ans(n);
  while (!q.empty()) {
    int x = q.front();
    q.pop();

    for (int i = 0; i < e[x].size(); i++)
      if (!v[e[x][i]]) {
        v[e[x][i]] = true;
        q.push(e[x][i]);
        ans[e[x][i]] = x;
      }
  }

  bool succ = true;
  for (int i = 0; i < n; i++)
    succ = succ && v[i];
  if (succ) {
    printf("Yes\n");
    for (int i = 1; i < n; i++)
      printf("%d\n", ans[i] + 1);
  }
  else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 10216
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

using namespace std;

ll getDivCnt(ll target, ll x) {
  if (target < 0)
    return 0;
  else
    return target / x + 1;
}

int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  cout << getDivCnt(b, x) - getDivCnt(a - 1, x) << endl;

  return 0;
}

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

using namespace std;



int main(void){

  
  int N;
  int ans = 0;

  
  cin >> N;

for(int i = 1 ; i <= N ; i++){

  string str = to_string(i);
  if((str.length() % 2) == 1){
   ans++;
  }
}
 

  cout << ans << endl;

  return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm>
#include <utility>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i, s, n) for(int i=(s); i<=(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define fi first
#define se second
#define mkp make_pair

#define INF 0x3f3f3f3f
#define NIL -1
using namespace std;

int N;
vector <int> G[102];
int far[102];

void slv()
{
   queue <int> que;
   que.push(1);
   memset( far, NIL, sizeof(far) );
   far[1] = 0;

   while(!que.empty()){
      const int u = que.front();
      que.pop();
      rep(i, G[u].size()){
         const int next = G[u][i];
         if( far[next] == NIL ){
            far[next] = far[u] + 1;
            que.push( next );
         }
      }
   }

   reps(i, 1, N)
      cout << i <<  ' ' <<  far[i]  << '\n';
   return;
}

signed main()
{
   cin.tie(0), ios::sync_with_stdio(false);
   cin >> N;

   reps(i, 1, N){
      int u, k, a;
      cin >> u >> k;
      while(k--){
         cin >> a;
         G[u].push_back(a);
      }
   }

   slv();
   return (0);
}




Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  ll N, X, M;
  cin >> N >> X >> M;
  vector<ll> v, vloop;
  set<ll> s;
  s.insert(X);
  v.push_back(X);
  ll ans = X;
  ll nrest = N - 1;
  for (int i = 1; i < N; i++) {
    ll a = v[i - 1] * v[i - 1] % M;
    if (s.count(a) == 0) {
      s.insert(a);
      v.push_back(a);
      ans += a;
      nrest--;
    } else {
      for (int j = 0; j < i; j++) {
        if (v[j] == a) {
          vloop.resize(i - j);

          copy(v.begin() + j, v.begin() + i, vloop.begin());
          break;
        }
      }
      break;
    }
  }
  ll sum = 0;
  for (ll i : vloop) {
    sum += i;
  }

  if (nrest != 0) {
    ans += sum * (nrest / vloop.size());
    nrest %= vloop.size();

    for (int i = 0; i < nrest; i++) {
      ans += vloop[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 6404
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Collections;

class Main {
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int N = sc.nextInt();
    ArrayList<Integer> A = new ArrayList<>();
    
    for (int i = 0; i < N; i++) {
    A.add(sc.nextInt());
    }
    
    Collections.sort(A, Comparator.reverseOrder());
    
    for (int i = 0; i < N; i++) {
    H -= A.get(i);
    }
    
    if (H <= 0) {
      System.out.print("Yes");
    } else {
      System.out.print("No");
    }
    
  }
}

Measured memory_bytes: 59008
#include<stdio.h>
#include<set>
#include<cstring>
#include<vector>

using namespace std;

char s[8002];
vector <int> pe[2];
set <int> gigi;
int x, y;

int main ()
{
    scanf("%s\n%d%d", s, &x, &y);

    int n = strlen(s);
    s[n] = 'T';
    n++;

    int i = 0;
    while(i < n && s[i] != 'T') {
            i++;
    }

    x -= i;
    i++;

    int bagiin = 1;
    int tilnow = 0;
    for(; i < n; i++) {
        if(s[i] == 'F') {
            tilnow++;
        } else {
            if(tilnow != 0) {
                pe[bagiin].push_back(tilnow);
            }
            tilnow = 0;
            bagiin = (bagiin ^ 1);
        }
    }

    vector <int> aux;
    aux.clear();
    //printf("%d %d\n", x, y);
    int potx, poty;
    potx = 0;
    poty = 0;
    gigi.insert(0);
    for(auto &it : pe[0]) {
        //printf("%d ", it);
        for(auto &iii : gigi) {
            aux.push_back(iii + it);
            aux.push_back(iii - it);
        }
        gigi.clear();
        for(auto &iii : aux) {
            gigi.insert(iii);
        }
        aux.clear();
    }

    if(gigi.count(x)) {
        potx = 1;
    }

    //printf("sdasdd");
    //fflush(stdout);

    gigi.clear();
    gigi.insert(0);
    //printf("asd\n");
    for(auto &it : pe[1]) {
        //printf("%d ", it);
        for(auto &iii : gigi) {
            aux.push_back(iii + it);
            aux.push_back(iii - it);
        }
        gigi.clear();
        for(auto &iii : aux) {
            gigi.insert(iii);
        }
        aux.clear();
    }

    if(gigi.count(y)) {
        poty = 1;
    }

    if(potx && poty) {
        printf("Yes");
    } else {
        printf("No");
    }

    return 0;
}





Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
string st;
int t,a[1010];
int main()
{
    getline(cin,st);
    for(int i=0;i<=st.size();i++)
    {
    	if(st[i]=='0') a[++t]=0;
    	if(st[i]=='1') a[++t]=1;
    	if(st[i]=='B')
    	{
    		if(t>=1) t--;
		}
	}
	for(int i=1;i<=t;i++) cout<<a[i];
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]

    """
    解答方針は正しかったが、選んだ竹のA,B,Cへの割り振り方の実装にてこずったので、
    潔く模範解答を写経することにする。
    こういう全列挙は再帰を使うと超あっさり書けるのは聞いてたけど、まだ実践力が足らぬ。。
    再帰を木構造に書き表せたら自然にdfsと結びつくのか！
    """

    def dfs(cur, a, b, c):
        if cur == N: # 全ての竹をチェックし終わった時
            if min(a, b, c) > 0: # a, b, cのどれにもベースの竹が取れている時
                return abs(a - A) + abs(b - B) + abs(c - C) - 30 # 最初の0本から1本への合成にはMP10は使わないので最後に引く
            else:
                return 10**10
        ret0 = dfs(cur + 1, a, b, c)                # curの竹を使わない時
        ret1 = dfs(cur + 1, a + L[cur], b, c) + 10  # curの竹をaに繋いだ時
        ret2 = dfs(cur + 1, a, b + L[cur], c) + 10  # curの竹をbに繋いだ時
        ret3 = dfs(cur + 1, a, b, c + L[cur]) + 10  # curの竹をcに繋いだ時
        return min(ret0, ret1, ret2, ret3)

    print(dfs(0, 0, 0, 0))





if __name__ == "__main__":
    main()


Measured memory_bytes: 44252
#include <iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if((a==5 && b==5 && c==7) || (b==5 && c==5 && a==7)||(a==5 && c==5 && b==7)){
        cout<<"YES"<<endl;
    }else cout<<"NO"<<endl;

}

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

void prians(bool answer) {
  if(answer)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
int n;
string w, bf;
map<string, int> mp;

int main() {
  int i;
  bool ans = 1;
  cin >> n;
  for(i = 0; i < n; ++i) {
    cin >> w;
    if(i != 0 && bf[bf.size() - 1] != w[0]) ans = 0;
    if(mp.find(w) != mp.end()) ans = 0;
    mp[w] = 1;
    bf = w;
    if(!ans) break;
  }
  prians(ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define iso ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
#define cases int t;cin>>t;while(t--)
int main()
{
    iso;
    /* #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif */
   int n;cin>>n;
   int ar[n];
   f(i,0,n)cin>>ar[i];
    sort(ar,ar+n);
    ll ans=0;
    
    for(int i=2;i<n;i++)
    {
      for(int j=i-1;j>=0;j--)
      {
         int x=upper_bound(ar,ar+i+1,ar[i]-ar[j])-ar;
         ans+=max(0,j-x);
      }
    }
    
    cout<<ans;
}
//7
//218 786 704 233 645 728 389

Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    string s;
    cin >> s;

    ll l = 0;
    ll r = s.size()-1;

    ll count = 0;
    while(l<r){
        if(s[l]==s[r]){
            l++;
            r--;
        }
        else if(s[l]=='x'){
            count++;
            l++;
        }
        else if(s[r]=='x'){
            count++;
            r--;
        }
        else{
            p(-1);
            return 0;
        }
    }
    
    p(count);
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
using namespace std;
int main(){
	int a = 0, b = 0, c=0, d[100000], e[100000],f=0,g=0,h=0, count = 0;
	char ac,uc[100000];
	string manji,gage;
	cin >>a>>b;
	if (b == 100) {
		b = b + 1;
	}
	if (a == 0) {
		cout << b << endl;
	}
	if (a == 1) {
		cout << 100 * b << endl;
	}
	if (a == 2) {
		cout << 100* 100*b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# 組み合わせ計算
# 約分してから計算するアルゴリズム
# 10^9 + 7 で割ったあまりを返すバージョン
MOD = 1000000007

def combination(n, r):
    # n >= 0, r >= 0, r <= n を仮定
    if n < 0 or r < 0 or n < r:
        return -1

    # r <= n - r を仮定
    if n - r < r:
        r = n - r

    # r < 2 の場合
    if r == 0:
        return 1
    if r == 1:
        return n

    # nCr の分子
    # [n - r + 1, n - r + 2, ... , n - 1, n]
    numerator = [n - r + 1 + i for i in range(r)]


    # nCr の分母
    # [1, 2, ... , r - 1, r]
    denominator = [i + 1 for i in range(r)]

    # nCr を約分する
    for i in range(r):
        # i番目の分母で約分する
        # 0番目は1なので省略

        # 元の（今までの約分を行う前の）i番目の分母の値
        original_denominator = i + 1

        # 今までの約分を行った後の、i番目の分母の値
        # 今回の約分で割る数
        divisor = denominator[i]

        # divisorが1（全て約分済み）の場合は無視する
        if divisor == 1:
            continue

        # 約分する相手の分子を決める
        # 0～i番目の分子（約分前）の中で、
        # original_denominatorで割り切れる数
        # （一つしかない）を選ぶ
        # remainder = i番目の分子 % original_denominator
        # とするとき、
        # (i - remainder)番目の分子 = i番目の分子 - remainder
        # (i - remainder)番目の分子 % original_denominator
        #  = (i番目の分子 - remainder) % original_denominator
        #  = 0
        # なので、(i - remainder)番目の分子を選べばよい。

        # remainder = i番目の分子 % original_denominator
        #           = (n - r + i + 1) % (i + 1)
        #           = (n - r) % (i + 1)
        remainder = (n - r) % original_denominator

        # divisor で約分できるペアをすべて約分する
        for j in range(i, r, original_denominator):
            numerator[j - remainder] = numerator[j - remainder] // divisor
            denominator[j] = denominator[j] // divisor

    ans = 1
    for i in numerator:
        ans = (ans * i) % MOD
    return ans


N, K = map(int, input().split())
for i in range(1, K + 1):
    if N - K + 1 >= i:
        print(combination(N - K + 1, i) * combination(K - 1, i - 1) % MOD)
    else:
        print(0)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout<<setprecision(15);

    int r; cin>>r;
    long double c = 2*3.14159265359;
    cout<<c*r<<"\n";

    return 0;
}

Measured memory_bytes: 3752
{-# LANGUAGE CPP #-}
module Main where

import qualified Data.Vector as V 
import qualified Data.Map.Strict as M
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

dump :: (Show a) => a -> IO()
#if __GLASGOW_HASKELL__ >= 850
dump x = print x
#else
dump _ = pure ()
#endif

readint :: IO Int
readint = (fst . fromJust . BS.readInt) <$> BS.getLine

readvec :: IO [Int]
readvec = (fmap (read . BS.unpack) . BS.words) <$> BS.getLine

newtype UF a = UF (M.Map a a) deriving (Show) -- Map node parent

makeuf :: Int -> UF Int
makeuf n = let m = M.fromList $ zip [0..n] [0..n]
                in UF m

union :: (Eq a, Ord a) => a -> a -> UF a -> UF a
union l r uf@(UF m) = let lp = find l uf
                          rp = find r uf
                      in if lp == rp
                         then uf
                         else if size l uf < size r uf
                              then UF $ M.update (const $ Just rp) lp m
                              else UF $ M.update (const $ Just lp) rp m

find :: (Eq a, Ord a) => a -> UF a -> a
find x uf@(UF m) = let px = m M.! x
                in if px == x
                   then px
                   else find px uf -- TODO 貼り直し

size :: (Eq a, Ord a) => a -> UF a -> Int
size x (UF m) = M.size $ M.filter (\par -> par==x) m

main :: IO()
main = do
  [n, m, c] <- readvec
  bs <- V.fromListN m <$> readvec
  ass <- V.fromListN n <$> (forM [1..n] $ \i -> do
    V.fromListN m <$> readvec)
  let
    f :: V.Vector Int -> Bool
    f as =
        let s = sum $ V.zipWith (\a b -> a * b) as bs
        in s + c > 0
  print $ length $ V.filter f ass



Measured memory_bytes: 1020
a = int(input())
b = int(input())
c = int(input())
x = int(input())

result = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                result += 1

print(result)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    List<Integer> list = new ArrayList<Integer>();
    int num = sc.nextInt();

    for(int i = 0; i < num; i++) {
      int number = sc.nextInt();
      list.add(number);
    }
    sc.close();

    for(int j = (list.size() - 1); j >= 0; j--) {
      if(j == 0) {
        System.out.println(list.get(j));
      } else {
        System.out.print(list.get(j) + " ");
      }
    }
  }
}


Measured memory_bytes: 26160
N = int(input())
t_x_y = [list(map(int, input().split())) for _ in range(N)]
t_x_y.insert(0, [0, 0, 0])
 
ans = 'Yes'
for i in range(N):
  dt = t_x_y[i+1][0] - t_x_y[i][0]
  dist = abs(t_x_y[i+1][1] - t_x_y[i][1]) + abs(t_x_y[i+1][2] - t_x_y[i][2])
  
  # dt < dist が必要
  if dt < dist:
    ans = 'No'
    break
  else:
    # dt >= dist の上で、dtとdistの偶奇が一致すればよい
    if (dt - dist) % 2 != 0:
      ans = 'No'
      break
  
print(ans)

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

class Stack{
    int s[100];
    int top = -1;
public:
    void push(int num){
        s[++top] = num;
    }
    int pop(){
        return s[top--];
    }
};

int main(){
    Stack s;
    string c;
    while (cin >> c) {
        if (c == "+" || c == "-" || c == "*") {
            int num1 = s.pop();
            int num2 = s.pop();
            if (c == "+") s.push(num2 + num1);
            if (c == "-") s.push(num2 - num1);
            if (c == "*") s.push(num2 * num1);
        } else {
            s.push(stol(c));
        }
    }
    cout << s.pop() << endl;
    return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <stdio.h>
#include <unordered_map>
#include <vector>
using namespace std;
using namespace std;
long long mod = 1e9 + 7;

long long GetValue(long long n, long long m) {
    long long ans = 0;
    for (long long i = 1; i < n; i++) {
        ans = (ans + i * (n - i)) % mod;
    }
    ans = ans * (m * m) % mod;
    return ans;
}
 typedef long long ll;
 void exgcd(ll a,ll b,ll& d,ll& x,ll& y){
     if(!b) { d = a; x = 1; y = 0; }
     else{ exgcd(b, a%b, d, y, x); y -= x*(a/b); }
 }
 ll inv(ll a, ll p){
     ll d,x,y;
    exgcd(a,p,d,x,y);
    return d == 1 ? (x % p + p)%p : p - 1;
}
long long F(long long a, long long p) {
    return inv(a, p);
}

long long C(long long n, long long m) {
    if (n == 0) { return 1; }
    long long ans = 1;
    for (long long i = 1; i <= m; i++) {
        ans = ans * (n - i + 1) % mod * F(i, mod) % mod;
    }
    return ans;
}

int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  long long ans = 0, mod = 1e9 + 7;
  ans = GetValue(n, m) + GetValue(m, n);
  if (ans >= mod) {
    ans -= mod;
  }
  ans = ans * C(n * m - 2, k - 2) % mod;
  printf("%lld\n", ans);
  return 0;
}


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

using namespace std;

const int ms = 1e5 + 17;
int k;
int x[ms], y[ms];
char c[ms];
int arr[2017][2017];

int amount(int x1, int y1, int x2, int y2)
{
    if(x2 > 2 * k - 1 || y2 > 2 * k - 1)
        return 0;

    if(x1 < 0 || y1 < 0)
        return 0;

    x2 = max(0, x2);
    y2 = max(0, y2);
    x1 = min(2 * k - 1, x1);
    y1 = min(2 * k - 1, y1);


    return arr[y1][x1] - (x2 > 0 ? arr[y1][x2 - 1] : 0) - (y2 > 0 ? arr[y2 - 1][x1] : 0) + (y2 > 0 && x2 > 0 ? arr[y2 - 1][x2 - 1] : 0);
}

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

    int n;
    cin >> n >> k;

    for(int i = 1; i <= n; ++i)
        cin >> x[i] >> y[i] >> c[i];

    for(int i = 1; i <= n; ++i)
    {
        if(c[i] == 'W')
        {
            x[i] += k;
            c[i] = 'B';
        }
    }

    for(int i = 1; i <= n; ++i)
    {
        x[i] %= 2 * k;
        y[i] %= 2 * k;

        ++arr[y[i]][x[i]];
    }


    for(int i = 1; i < 2 * k; ++i)
        arr[0][i] += arr[0][i - 1];


    for(int i = 1; i < 2 * k; ++i)
        arr[i][0] += arr[i - 1][0];

    for(int i = 1; i < 2 * k; ++i)
        for(int j = 1; j < 2 * k; ++j)
            arr[i][j] += arr[i - 1][j] + arr[i][j - 1] - arr[i - 1][j - 1];


    int answer = 0;

    for(int i = 0; i < 2 * k; ++i)
        for(int j = 0; j < 2 * k; ++j)
        {
            int temp = 0;

            for(int dx = -4; dx <= 4; ++dx)
                for(int dy = -4; dy <= 4; ++dy)
                    if(abs(dx + dy) % 2 == 0)
                    {
                        int ii = i + dx * k;
                        int jj = j + dy * k;
                        temp += amount(ii, jj, ii - k + 1, jj - k + 1);//centr
                    }

            answer = max(answer, temp);
        }


    cout << answer << '\n';
}


Measured memory_bytes: 17024
#include <stdio.h>
 
int main()
{
    int n,i=1,x;
    scanf("%d",&n);
    while(i<=n){
        if(i%3==0){
            printf(" %d",i);
        }
        else{
            if(i%10==3){
                printf(" %d",i);
            }
            else{
                x=i;
                while(x){
                    if(x%10!=3){
                    x/=10;
                    }
                    else{
                        printf(" %d",i);
                        break;
                    }
                }
            }
        }
        i++;
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2044
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    A.sort(reverse=True)

    c = 0
    ans = A[0]

    for i in range(2, N):
        if i % 2 == 0:
            c += 1
        ans += A[c]

    print(ans)

    
    

if __name__ == '__main__':
    main()



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

const int INF = 1<<28;

struct Edge {
  int v, w;
};

typedef vector<vector<Edge> > Graph;
typedef pair<int, int> Pair;

int N, M, S, G1, G2;
Graph G, rG;

vector<int> dijkstra(int src, const Graph &g) {
  const int n = g.size();
  vector<int> cost(n, INF);
  priority_queue<Pair, vector<Pair>, greater<Pair> > que;
  cost[src] = 0;
  que.push(Pair(0, src));
  while(que.size()) {
    const Pair s = que.top();
    que.pop();
    if(s.first > cost[s.second]) continue;
    for(int i = 0; i < g[s.second].size(); ++i) {
      Pair t(s.first + g[s.second][i].w, g[s.second][i].v);
      if(t.first >= cost[t.second]) continue;
      cost[t.second] = t.first;
      que.push(t);
    }
  }
  return cost;
}

int main() {
  while(cin >> N >> M >> S >> G1 >> G2 &&
        (M|N|S|G1|G2)) {
    --S; --G1; --G2;
    G = rG = Graph(N);
    for(int i = 0; i < M; ++i) {
      int a, b, c;
      cin >> a >> b >> c;
      --a; --b;
      G[a].push_back((Edge){b, c});
      rG[b].push_back((Edge){a, c});
    }
    vector<int> s = dijkstra(S, G);
    vector<int> t = dijkstra(G1, rG);
    vector<int> u = dijkstra(G2, rG);
    int res = INF;
    for(int i = 0; i < N; ++i) {
      res = min(res, s[i] + t[i] + u[i]);
    }
    cout << res << endl;
  }
  return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int k, n; std::cin >> k >> n;
  vi a(n); rep(i, n) std::cin >> a[i];
  int diff = 0;
  rep(i, n-1) {
    chmax(diff, a[i+1]-a[i]);
  }
  chmax(diff, k-a[n-1]+a[0]);
  std::cout << k - diff << "\n";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()


int main(){
  ll N,M,K,k=0,s=-1,t=-1,ans=0,x=0,y=0;
  cin >> N >> M >> K;
  vector<ll> A(N),B(M);
  rep(i,N){
    cin >> A.at(i);
    if(x==0&&k+A.at(i)<=K){
      k+=A.at(i);
      s=i;
    }else{
      x=1;
    }
  }
  rep(j,M){
    cin >> B.at(j);
    if(y==0&&k+B.at(j)<=K){
      k+=B.at(j);
      t=j;
    }else{
      y=1;
    }
  }
  ans=s+1+t+1;
  while(s>=0){
    ll a;
    k-=A.at(s);
    s--;
    while(t<M-1&&k+B.at(t+1)<=K){
      k+=B.at(t+1);
      t++;
    }
    a=s+1+t+1;
    ans=max(ans,a);
  }
  cout << ans << endl;
}

Measured memory_bytes: 6432
while True:
    n,x = map(int,input().split())
    if n == 0 and x ==0:
        break
    count = 0
    for i in range(1,n+1):
        for j in range(1,i):
            for k in range(1,j):
                if i + j + k == x:
                    count = count + 1
    print(count)


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

int main() {
    int n;
    cin >> n;
    vector <int> v;
    for (int i=0; i<n; i++)
    {
        int p;
        cin >> p;
        v.push_back(p);
    }
    vector <int> w = v;
    sort(v.begin(), v.end());
    int sum = 0;
    for (int i=0; i<n; i++)
        if (w[i] != v[i])
            sum++;
    cout << (sum==0 || sum==2 ? "YES":"NO");
    return 0;
}

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

int main()
{
    int n, count = 0;
    string s;
    cin >> n >> s;
    for (int i = 0; i < s.size() - 2; i++)
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            count++;
        }
    }
    cout << count << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v) reverse(v.begin(),v.end())
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }

void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const ll MOD =1000000007;
#define PI 3.14159265258979

#define P pair<int,int>
#define Pll pair<ll,ll>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

struct UnionFind{
	vector<int> par; //データiが属する親の番号
	vector<int> sizes; //根ノードiの木に含まれるデータの数

	// 最初は全てのデータiがグループiに存在するものとして初期化
	UnionFind(int n):par(n),sizes(n, 1){
		REP(i,n) par[i] = i;
	}

	// 根を張り替えながら再帰的に根ノードを探す
	int find(int x){
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}

	// 2つのデータx, yが属する木をマージする
	void unite(int x, int y) {
		// データの根ノードを得る
		x = find(x);
		y = find(y);

		// 既に同じ木に属しているならマージしない
		if (x == y) return;

		// xの木がyの木より大きくなるようにする
		if (sizes[x] < sizes[y]) swap(x, y);

		// xがyの親になるように連結する
		par[y] = x;
		sizes[x] += sizes[y];
		sizes[y] = 0;  // sizes[y]は無意味な値となるため
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// データxが含まれる木の大きさを返す
	int size(int x) {
		return sizes[find(x)];
	}
};
int gcd(int n,int m){
	if(m>n) return gcd(m,n);
	if(m==0) return n;
	else return gcd(m,n%m);
}

int main(void){
	int N,a,count=1;
	set<P> A;

	cin>>N;
	REP(i,N){
		cin>>a;
		A.insert(P(a,count++));
	}

	for(auto x:A) cout << x.second << " ";

	cout<<endl;
}


Measured memory_bytes: 5504
k = int(input())

def f(k):
  if k % 2 == 0 or k % 5 == 0:
    return -1    

  val = 7
  cnt = 1
  while cnt < 10 ** 6:
    val %= k
    if val % k == 0:
      break
    cnt += 1
    val = val * 10 + 7
  else:
    return -1
  return cnt
    
print(f(k))

Measured memory_bytes: 9108
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = n % 10;
        if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9)
            System.out.println("hon");
            else if(a == 3)
                System.out.println("bon");
                else
                    System.out.println("pon");
    }
}

Measured memory_bytes: 35812
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <unordered_map>

using namespace std;

int main() {
    int K, X;
    cin >> K >> X;
    if(500*K>=X)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

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

class Program
{
	static void Main()
	{
		int[] AB = InInts().ToArray();
		int ans;
		if (AB[0] >= 10 || AB[1] >= 10)
			ans = -1;
		else
			ans = AB[0] * AB[1];
		Console.WriteLine(ans);
	}

	static string[] InStrs()
	{
		return Console.ReadLine().Split(' ');
	}
	static IEnumerable<int> InInts()
	{
		return Console.ReadLine().Split(' ').Select(x => int.Parse(x));
	}
	static IEnumerable<long> InLongs()
	{
		return Console.ReadLine().Split(' ').Select(x => long.Parse(x));
	}
}

Measured memory_bytes: 13396
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N, A, B = mi()

alld = A*N
print(min(alld, B))




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

int main(){
    int mod=1000000007;
    int n,k,ans;
    scanf("%d %d",&n,&k);
    vector <int> h(n);
    for (auto&e:h) scanf("%d",&e);
    int dp[n+1];
    for (int i=0;i<=n;i++) dp[i]=mod;
    dp[1]=0;
    for (int i=1;i<n;i++) {
        for (int j=1;j<=k;j++) {
            if (i+j>n) break;
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i-1]-h[i-1+j]));
        }
    }
    printf("%d\n",dp[n]);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N, A, B; cin >> N >> A >> B;
    if((B - A) % 2 == 1) {
        cout << "Borys" << endl;
    } else {
        cout << "Alice" << endl;
    }
	return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,k;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n>>k;
      rrep(i,1,n+1){
        pos=i%k;
        if(pos*2==k){
          cmp=n+pos;
          cmpp=cmp/k;
          ans+=cmpp*cmpp;
        }
        else{
          if(pos%k!=0)continue;
          cmp=n/k;
          ans+=cmp*cmp;
        }
      }
      Cout(ans);
      
     

       
return 0;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h.at(i);
    vector<int> dp(n);
    dp[0] = 0;
    for(int i=1;i<n;i++) {
        int minval = 1e9;
        for(int j=1;j<=min(i,k);j++){
            int a = dp[i-j] + abs(h[i]-h[i-j]);
            minval =min(minval, a);
        }
        dp[i] = minval;
    }
    cout << dp[n-1] << endl;

    return 0;
}

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


int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for( int i = 0; i < N; ++i ) cin >> a[i];


    vector<int> num = {1};
    sort( a.begin(), a.end() );
    
    int num_left;
    bool isleft = false;
    for( int i = 0; i < N-1; ++i ){
        int count = 1;
        while( a[i] == a[i+1] && i+1 < N ) ++i, ++count;
        int tmp = count;
        if( isleft ){
            count += num_left;
            isleft = false;
        }
        num_left = tmp;
        if( a[i+1] == a[i]+1 && i+1 < N ){
            ++count;
            int pos = i+1;
            while( a[pos] == a[pos+1] && pos+1 < N ) ++pos, ++count;
            isleft = true;
        }
        num.push_back( count );
    }

    cout << *max_element( num.begin(), num.end() ) << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
	//Implement solution here.
		int x = ni();
		int y = ni();
		mod = 1000000007;		      
		int a = 2 * y - x;
		int b = 2 * x - y;
		if(a % 3 != 0 || a < 0 || b % 3 != 0 || b < 0) {
			System.out.println(0);
			return;
		}		
		a /= 3;
		b /= 3;
		System.out.println(combinationMod(a+b, a));
	}
	
	static long combination(int n, int k) {
		double out = 1;
		for(int i = 0; i < k; i++) {
			out = (out * (double)(n - i) / (k - i));
		}
		return (long)out;
	}
	
	static long combinationMod(int n, int k) {
        if (k == 0)return 1; 
        long[] fac = new long[n + 1];
        fac[0] = 1; 
        for (int i = 1 ;i <= n; i++) {
        	fac[i] = modMul(fac[i - 1], (long)i); 
        }            
        return modMul(modMul(fac[n],modInverse(fac[k])),modInverse(fac[n - k]));
    }
	
	static int mod;
	static long modSum(long a, long b) {
		return (a % mod + b % mod) % mod;
	}
	static long modMul(long a, long b) {
		return ((a % mod) * (b % mod)) % mod;
	}
	
	static long modInverse(long n) {
        return power(n, mod-2);
    }
	
	static long power(long a, long b) {
        long result = 1;
        a = a % mod;
        while (b > 0) {
            if (b % 2 == 1)
            	result = (result * a) % mod;
            b = b >> 1;
            a = (a * a) % mod;
        }
        return result;
    }

    //Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
            	br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 25428
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  int s;
  cin >> s;

  vector<int> dp(s + 1);

  dp[0] = 1;
  for (int i = 3; i <= s; i++) {
    for (int j = 3; j <= i; j++) {
      dp[i] += dp[i - j];
      dp[i] %= MOD;
    }
  }

  cout << dp[s] << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int main(){

    int N; cin >> N;

    int ans = 0;
    if (400 <= N && 599 >= N){
        ans = 8;
    }
    else if (600 <= N && 799 >= N){
        ans = 7;
    }
    else if (800 <= N && 999 >= N){
        ans = 6;
    }
    else if (1000 <= N && 1199 >= N){
        ans  = 5;
    }
    else if (1200 <= N && 1399 >= N){
        ans = 4;
    }
    else if (1400 <= N && 1599 >= N){
        ans = 3;
    }
    else if (1600 <= N && 1799 >= N){
        ans = 2;
    }
    else{
        ans = 1;
    }

    cout << ans << endl;


}



Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

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

int main() {
	int a[3][3];
	rep(i, 3) {
		rep(j, 3) {
			cin >> a[i][j];
		}
	}
	if (a[0][0] - a[0][1] == a[1][0] - a[1][1] &&
		a[1][0] - a[1][1] == a[2][0] - a[2][1] &&

		a[0][1] - a[0][2] == a[1][1] - a[1][2] &&
		a[1][1] - a[1][2] == a[2][1] - a[2][2] &&
		
		a[0][0] - a[1][0] == a[0][1] - a[1][1] &&
		a[0][1] - a[1][1] == a[0][2] - a[1][2] &&
		
		a[1][0] - a[2][0] == a[1][1] - a[2][1] &&
		a[1][1] - a[2][1] == a[1][2] - a[2][2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

int main() {
	int64_t a; cin>>a;
	long double b;cin>>b;
	long long B=b*100+0.5;
	long long x=(a*B)/100;
	cout<<x<<endl;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define inf 1000000000

using namespace std;

typedef long long ll;
ll n,a,b,A[100050];

bool test(ll t){
	ll tries = 0;
	for(ll i = 0; i<n; i++){
		if(A[i] >= b*t) tries += (A[i]-b*t)/a + ((A[i]-b*t)%a != 0);
	}
	return tries <= t;
}

int main(){
//	freopen("widespread.in","r",stdin);
	cin >> n >> a >> b;
	a -= b;
	for(ll i = 0; i<n; i++) cin >> A[i];
	ll s = 0, e = inf, m;
	while(m = (s+e)/2, e-s>1){
		if(test(m)) e=m;
		else s=m;
	}
	cout << e;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
using namespace std;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    ll i,j,k,x,y,z,p,q;
    ll n,m,tmp;
    string s[200000];
    string str;
    ll sum=0;
    ll strr[200005];
    cin>>n>>m;
    if(n==m){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;

    }

    return 0;
}

Measured memory_bytes: 1792
# coding: utf-8
# Your code here!
def seki(x):
    a=[]
    for i in range(600//x):
        a.append((i*x)**2*x)
    print(sum(a))

while 1:
    try:
        n=int(input())
    except EOFError:
        break
    
    seki(n)


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N;
	vector<llong> A;

	cin >> N;
	A.resize(N);
	for(int i = 0; i < N; i++)
		cin >> A[i];

	llong ans = 0;

	sort(BE(A));
	for(int k = 0; k < 2; k++){
		for(int i = 0; i < 4; i++){
			deque<llong> d;
			d.insert(d.begin(),A[A.size()-1]);
			int f = 0, b = A.size()-2;
			for(int j = 0; f <= b; j++){
				int check = (i+j)%4;
				if(check == 0)
					d.insert(d.begin(), A[f++]);
				else if(check == 1)
					d.insert(d.end(), A[f++]);
				else if(check == 2)
					d.insert(d.begin(), A[b--]);
				else
					d.insert(d.end(), A[b--]);
			}

			llong res = 0;
			// cerr << d[0] << " ";
			for(int i = 1; i < d.size(); i++){
				// cerr << d[i] << " ";
				res += abs(d[i] - d[i-1]);
			}
			// cerr << endl;
			ans = max(ans,res);
		}
		reverse(BE(A));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1884