akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N=3005,M=200005;
const int MOD=1000000007;
int h,w,n;
struct node
{
	int x,y;
}a[N];
int fac[M],inv[M],f[N];
inline int mul(int a,int b){return 1ll*a*b%MOD;}
inline int add(int a,int b){return (a+=b)>=MOD?a-MOD:a;}
inline int sub(int a,int b){return (a-=b)<0?a+MOD:a;}
inline int pw(int x,int p){int res=1;for(;p;p>>=1,x=mul(x,x))if(p&1)res=mul(res,x);return res;}
inline int C(int n,int m){return mul(fac[n],mul(inv[m], inv[n-m]));}
inline bool cmp(node p,node q){return p.x!=q.x?p.x<q.x:p.y<q.y;}
int main()
{
	scanf("%d%d%d",&h,&w,&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].x,&a[i].y);
	a[++n].x=h;a[n].y=w;
	sort(a+1,a+n+1,cmp);
	fac[0]=1;
	for(int i=1;i<=h+w;i++)
		fac[i]=mul(fac[i-1],i);
	inv[h+w]=pw(fac[h+w],MOD-2);
	for(int i=h+w;i>=1;i--)
		inv[i-1]=mul(inv[i],i);
	for(int i=1;i<=n;i++)
	{
		f[i]=C(a[i].x+a[i].y-2,a[i].x-1);
		for(int j=1;j<i;j++)
			if(a[j].x<=a[i].x&&a[j].y<=a[i].y)
				f[i]=sub(f[i],mul(f[j],C(a[i].x+a[i].y-a[j].x-a[j].y,a[i].x-a[j].x)));
	}
	printf("%d\n",f[n]);
	return 0;
}


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

int main() {
  int A,B,C,X;
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> X;
  int count = 0;
  for(int i = 0;i <= A;i++) {
    for(int j = 0;j <= B;j++) {
      for(int k = 0;k <= C;k++) {
        if(500 * i + 100 * j + 50 * k == X) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import sys
N,P = map(int,raw_input().split())
src = [tuple(map(int,raw_input().split())) for i in range(N)]

if P == 100:
  print(N)
  sys.exit()

wsum = sum(r[1] for r in src)
score = -wsum * P

xs = [w*(100-P) + b*P for w,b in src]
xs.sort(reverse=True)
i = 0
while score < 0:
  score += xs[i]
  i += 1
print(i)

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

using namespace std;


#define PI 3.14159265358979323846264338327950L

 int main(void) {
 int a, b, h, m;
cin>>a>>b>>h>>m;


 long double rad = PI * 2 * (
 (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long
double)m / 60.0);

 long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
b) * cosl(rad);
cout<<setprecision(20);
cout<<sqrtl(rsq);
// printf("%20.20Lf\n", sqrtl(rsq));



    return 0;
}


Measured memory_bytes: 4152
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll a,b,n;
    cin>>a>>b>>n;
    //ll val = (ll)((ll)a * (ll)n)/b - a * (n/b);
    //if(val<0){
        ll x = min(b-1,n);
        ll aa = (ll)((ll)a * (ll)x);
        ll bb = (ll)(x/b);
        ll val = aa/b - a * bb;
        cout<<val<<'\n';
        //cout<<"1st"<<'\n';
    //}
    //else{
        //cout<<val<<'\n';
    //}
    // ll mx = 0;
    // for(int i=0;i<=n;++i){
    //     ll vv = (a*i)/b - a * (i/b);
    //     mx = max(mx , vv);
    // }
    // cout<<mx<<'\n';
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> state;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }
int ceil(int a,int b){
  // a/bの切り上げを考える
  return (a+b-1)/b;
}

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

  ll ub = (n - 1) * b + a;
  ll lb = b + (n - 1) * a;

  ll ans;
  if(b - a < 0 or n == 0)ans = 0;
  else if(b != a and n == 1)ans = 0;
  else ans = ub - lb + 1;
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int n; cin >> n;
    string s; cin >> s;
    unsigned long long b = 100000007;
    unsigned long long mod = (1LL<<61)-1;
    int ans = 0;
    repr(i,1,n/2+1){
        unsigned long long b_pow = 1;
        rep(j,i){
            b_pow *= b;
        }
        map<unsigned long long, int> hashs;
        unsigned long long hash = 0;
        rep(j,i) hash = hash*b+s[j];
        hashs[hash] = 0;
        //cout << hash << endl;
        repr(j,1,n-i+1){
            hash = hash*b+s[j+i-1]-s[j-1]*b_pow;
            if(hashs.count(hash)){
                if(hashs[hash]+i <= j){
                    ans = max(ans,i);
                    break;
                }
            }
            else hashs[hash] = j;
            //cout << i << " " << j << " " << ans << endl;
        }
    }
    cout << ans << endl;
    
}



Measured memory_bytes: 3960
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():
    A, B, C, D = LI()

    ans = max(min(B, D) - max(A, C), 0)
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10068
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define PI 3.14159265359
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n, l;
	cin >> n >> l;
	vector<string> str(n);
	REP(i, n) {
		cin >> str[i];
	}
	sort(str.begin(), str.end());
	string ans;
	REP(i, n) {
		ans += str[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
-- end of templete



main = do
    [_, _, n] <- getInts
    replicateM n getInts >>= print . sum . binMap (\[x1,y1] [x2,y2] -> let (dx, dy, ax, ay) = (x2-x1, y2-y1, abs dx, abs dy) in ax + ay - cond (min ax ay) 0 (signum dx == signum dy))


Measured memory_bytes: 4856
#include<bits/stdc++.h>
#define ll          long long int
#define pb          push_back
#define mpp         make_pair
#define vll         vector<ll>
#define mll         unordered_map<ll,ll>
#define endl        "\n"
#define debug(x)    cout<< #x <<"="<<x<<"\n"
#define fo(i,a,x)   for(ll i=a;i<x;++i)
#define fastio      ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

ll M = 1000000007;

void solve()
{
    ll n; cin>>n;
    vll arr(n);
    fo(i,0,n)
    {
        cin>>arr[i];
    }   
    vll suff(n);
    suff[n-1] = 0;  
    for(int i=n-2;i>=0;i--)
    {
        suff[i] = suff[i+1]+arr[i+1];
    }
    ll ans = 0;
    fo(i,0,n)
    {
        ans = ans%M + (arr[i]%M * (suff[i]%M)%M)%M;
    }
    cout<<ans<<endl;
}

int main()
{
    fastio;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ll t=1; 
    // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 6340
const fs = require('fs');

function getInput(input: string): [number, number]
{
    const [K, S] = input.split(' ').map(Number);

    return [K, S];
}

function calculate(K: number, S: number): number {
    let numberOfTriples = 0;
    const loopSize = Math.min(K, S);

    for (let X = 0; X <= loopSize; X++) {
        for (let Y = 0; Y <= loopSize; Y++) {
            const Z = S - X - Y;

            if (0 <= Z && Z <= K) {
                numberOfTriples++;
            }
        }
    }

    return numberOfTriples;
}

(() => {
    const [K, S] = getInput(fs.readFileSync('/dev/stdin', 'utf8'));

    const answer = calculate(K, S);

    console.log(answer);
})();

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

for i in range(n-1):
    ai, bi, ci = map(int, input().split())
    ai += max(b, c)
    bi += max(a, c)
    ci += max(a, b)
    a, b, c = ai, bi, ci

print(max(a, b, c))

Measured memory_bytes: 47704
s=gets.chomp.chars
flag=false
saki,ato=[],[]
gets.to_i.times{
  _=gets.split
  if _[0]==?1
    saki,ato=ato,saki
    flag=!flag
  elsif _[1]==?1
    saki<<_[2]
  else
    ato<<_[2]
  end
}
s.reverse! if flag
puts (saki.reverse+s+ato).join

Measured memory_bytes: 32764
# -*- coding: utf-8 -*-

cnt = int(input())
card_list = [int(i) for i in input().split()]

# 2人の得点
alice = 0
bob = 0

# 高得点順にカードを並べ替え
card_list.sort(reverse=True)

for i in range(cnt):
    # 0開始で偶数ならAlice、奇数ならBobに加点する
    if i % 2 == 0:
        alice += card_list[i]
    else:
        bob += card_list[i]
# 得点差を出力
print(alice - bob)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,sum=0,p;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  int m;
  cin>>m;
  while(m--){
    cin>>p;
    int l=0,r=n;
    while(l<r){
      int mid=(l+r)/2;
      if(a[mid]==p){sum++;break;}
      if(p<a[mid])r=mid;
      else l=mid+1;
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3456
import copy

H, W, K = map(int, input().split())
board = [list(input()) for i in range(H)]

ans = 0
for i in range(2 ** H):
    row_colored_board = copy.deepcopy(board)
    for ii in range(H):
        if (i >> ii) & 1:
            row_colored_board[ii] = list('*' * W)
    for j in range(2 ** W):
        cnt = 0
        col_colored_board = copy.deepcopy(row_colored_board)
        for jj in range(W):
            if (j >> jj) & 1:
                for k in range(H):
                    col_colored_board[k][jj] = '*'
        for l in range(H):
            for m in range(W):
                if col_colored_board[l][m] == '#':
                    cnt += 1
    
        if cnt == K:
            ans += 1

print(ans)

Measured memory_bytes: 9380
//コピペ…
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int D;
  cin>>D;
  vector<int> c(26);
  for(int &i:c)
    cin>>i;
  vector<vector<int>> s(D,vector<int>(26));
  for(vector<int> &v:s)
    for(int &i:v)
      cin>>i;
  vector<int> t(D);
  vector<int> A(26,0);
  int mzint=0;
  for(int i=0;i<D;i++){
    int mzi=mzint,mzin=0,k;
    for(int j=0;j<26;j++)
      mzi-=(i+1-A[j])*c[j];
    for(int j=0;j<26;j++){
      int l=mzi+s[i][j]-(i+1-A[j])*c[j];
      if(l>mzin){
        k=j;
        mzin=l;
      }
    }
    A[k]=i+1;
    mzint=mzin;
    t[i]=k+1;
  }
  int M=18000000,ans=mzint;
  while(M--){
    int d=rand()%D,q=rand()%26,ans2=ans;
    ans+=s[d][q]-s[d][t[d]-1];
    int mae=-1,ato=D;
    for(int i=d-1;i>=0;i--){
      if(t[i]==t[d]){
        mae=i;
        break;
      }
    }
    for(int i=d+1;i<D;i++){
      if(t[i]==t[d]){
        ato=i;
        break;
      }
    }
    ans-=(ato-d)*(d-mae)*c[t[d]-1];
    mae=-1,ato=D;
    for(int i=d;i>=0;i--){
      if(t[i]==q+1){
        mae=i;
        break;
      }
    }
    for(int i=d;i<D;i++){
      if(t[i]==q+1){
        ato=i;
        break;
      }
    }
    ans+=(ato-d)*(d-mae)*c[q];
    if(ans2<ans)
      t[d]=q+1;
    else
      ans=ans2;
  }
  for(int i:t)
    cout<<i<<endl;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return(t*t);
    else
        return(t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
    }
    return true;
}

bool cmp(const pair<int , int> &a , const pair<int , int> &b){
    return (a.first < b.first);
}

ll lcm(ll a,ll b){
    return ( a*b/__gcd(a,b));
}

vector<int>a;
ll ans;
int n;
void solve(int i,int cur){
    if(i==n){
        ans+=cur;
        return;
    }
    solve(i+1,cur|a[i]);
    solve(i+1,cur);
}

int main()
{
    weewoo;
    string x;
    cin >> x;
    string y = x;
    reverse(y.begin(),y.end());
    if(x==y){
        y = x.substr(0,x.size()/2);
        string cur = y;
        reverse(y.begin(),y.end());
        if(cur==y){
            y = x.substr(x.size()/2 + 1,x.size());
            cur = y;
            reverse(y.begin(),y.end());
            if(cur==y){
                return cout << "Yes" << endl,0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
// Contest: AtCoder Beginner Contest 156 (https://atcoder.jp/contests/abc156)
// Problem: F: Modularness (https://atcoder.jp/contests/abc156/tasks/abc156_f)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    int k, q; cin >> k >> q;
    vi d(k);
    trav(di, d) cin >> di;

    while (q--) {
        int n, x, m; cin >> n >> x >> m;
        vi d2 = d;
        trav(di, d2) di %= m;
        vi occ(k);
        rep(i, k)
            occ[i] = (n - 1 - i + k - 1) / k;
        int same = 0;
        rep(i, k) same += (d2[i] == 0) * occ[i];
        ll al = x;
        rep(i, k)
            al += (ll)d2[i] * occ[i];
        int larger = al / m - x / m;
        cout << (n - 1 - same - larger) << '\n';
    }

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
	int in[4];
	string s;
	cin >> s;
	REP(i,4){
		in[i] = (int)(s[i]-'0');
	}
	
	int bit;
	for(bit=0; bit<(1<<3); ++bit){
		int ans = in[0];
		REP(i,3){
			if(bit & (1<<i)){
				ans += in[i+1];
			}else{
				ans -= in[i+1];
			}
		}
		if(ans==7){
			break;
		}
	}
	
	REP(i,3){
		cout << in[i];
		if(bit & (1<<i)) cout << "+";
		else cout << "-";
	}
	cout << in[3] << "=7\n";
	
	return 0;
	
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        //// 整数の入力
        //int a = int.Parse(Console.ReadLine());
        //// スペース区切りの整数の入力
        //string[] input = Console.ReadLine().Split(' ');
        //int b = int.Parse(input[0]);
        //int c = int.Parse(input[1]);
        //// 文字列の入力
        //string s = Console.ReadLine();
        ////出力
        //Console.WriteLine((a + b + c) + " " + s);

        string[] input = Console.ReadLine().Split(' ');
        int b = int.Parse(input[0]);
        int c = int.Parse(input[1]);

        int count = 0;
        string[] H = Console.ReadLine().Split(' ');
        foreach(var h in H)
        {
            if ( int.Parse(h) >= c)
            {
                count++;
            }
        }

        Console.WriteLine(count);
    }
}


Measured memory_bytes: 15584
#include "bits/stdc++.h"

using namespace std;

#define print(s) cout << (s) << endl;
#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n) 
#define all(a) (a).begin(), (a).end()
#define inf 10000000
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b; cin>>a>>b;
    if((a==1&&b>2)||(a>b&&b!=1)){
        cout<<"Alice"<<endl;
    } else if((b==1&&a>2)||(b>a&&a!=1)){
        cout<<"Bob"<<endl;
    } else if (a==b){
        cout<<"Draw"<<endl;
    }
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pii, int > a, pair < pii, int > b)//true for a before b
{
	if(a.F.F/300 < b.F.F/300)
		return 1;
	if(a.F.F/300 > b.F.F/300)
		return 0;
	if(a.F.S < b.F.S)
		return 1;
	if(a.F.S > b.F.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (1e2) + 9;
const int M = (1e4) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 100;
const int SQRT = BUCK+9;



void solve()
{
	ll a, b, c, d, g, x, y;
	cin >> a >> b >> c >> d;
	if(a < b || d < b)
	{
		cout << "No\n";
		return;
	}
	a %= b;
	if(a > c)
	{
		cout << "No\n";
		return;
	}
	if(c > b)
	{
		if(d >= b)
			cout << "Yes\n";
		else
			cout << "No\n";
		return;
	}
	g = gcd(b,d);
	
	x = (c-a) / g;
	y = a + (x+1LL)*g;
	if(y < b)
	{
		cout << "No\n";
		return;
	}

	x = a / g;
	y = a - g*x;

	if(y+d < b)
	{
		cout << "No\n";
		return;
	}

	cout << "Yes\n";
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(9);
	cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().strip().split(" ")))
dp=[[10**20]*len(A)  for i in range(0,len(A)+1)]
##dp[length][start_position]
pre=[]
temp=0
for i in range(len(A)):
    temp+=A[i]
    pre+=[temp]
length=1
for i in range(len(A)):
    dp[length][i]=0

for L in range(2,len(A)+1):
    for start in range(0,len(A)-L+1):
        for j in range(start+1,start+L):
            if start>0:
                dp[L][start]=min(dp[j-start][start]+dp[L-j+start][j]+pre[start+L-1]-pre[start-1],dp[L][start])
            else:
                dp[L][start]=min(dp[j-start][start]+dp[L-j+start][j]+pre[start+L-1],dp[L][start])
print(dp[len(A)][0])

Measured memory_bytes: 45276
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if(A <= 9 && B <= 9) {
			System.out.println(A * B);
		}else {
			System.out.println(-1);
		}
		sc.close();
	}
}

Measured memory_bytes: 22740
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()



int main(){
	int A,B,C;
	cin >> A >> B >> C;
	if(A == B && B == C) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    int a, b, c, d;
    while (cin >> a >> b >> c >> d) {
        if (d == 1) cout << 1 << endl;
        else cout << 0 << endl;
    }
}


















Measured memory_bytes: 384
A,B = map(int,input().split())

A -= 1

XorA = 0
XorB = 0

if A % 4 == 0:
    XorA = A
elif A % 4 == 1:
    XorA = 1
elif A % 4 == 2:
    XorA = A + 1
elif A & 3 == 3:
    XorA = 0

if B & 3 == 0:
    XorB = B
elif B & 3 == 1:
    XorB = 1
elif B & 3 == 2:
    XorB = B + 1
elif B & 3 == 3:
    XorB = 0

print( XorA ^ XorB)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    int y[3];
    cin>>y[0]>>y[1]>>y[2];
    sort(y,y+3);
    if (y[0]+y[1]==y[2])
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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 countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
}

ll mPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return mPow(x * x % m, n / 2, m);
  else
    return x * mPow(x, n - 1, m) % m;
}



int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = mPow(2, n, MOD);
    ll X = 1;
    ll Y = 1;
    rep(i, a) {
        X *= (n-i);
        X %= MOD;
        Y *= (i+1);
        Y %= MOD;
    }
    ll tmp = mPow(Y, MOD-2, MOD);
    ans -= X * tmp % MOD;
    if (ans < 0) ans += MOD;
    ans %= MOD;

    X = 1;
    Y = 1;
    rep(i, b) {
        X *= (n-i);
        X %= MOD;
        Y *= (i+1);
        Y %= MOD;
    }
    tmp = mPow(Y, MOD-2, MOD);
    ans -= X * tmp % MOD;
    if (ans < 0) ans += MOD;
    ans %= MOD;
    print(ans-1);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

class UnionFind {
public:
  vector <int> par;
  vector <int> size;
  
  UnionFind(int N)
  {
    for(int i=0; i<N; i++) {
      par.push_back(i);
      size.push_back(1);
    }
  }
  
  int find(int x){
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
  }
  
  void unite(int x, int y){
    int rx = find(x);
    int ry = find(y);
    if(rx == ry) return;
    par[rx] = ry;
    size[ry] += size[rx];
  }
  
  long long getSize(int x){
    return size[find(x)];
  }
};



int main(){
  long long n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  int a[m], b[m];
  for(int i=0; i<m; i++) scanf("%d %d", &a[i], &b[i]);
  
  UnionFind tree(n);
  
  long long inconvenience[m+1];
  
  inconvenience[m] = n * (n-1) / 2;
  
  for(int i=m-1; i>=0; i--){
    inconvenience[i] = inconvenience[i+1];
    if(tree.find(a[i]) != tree.find(b[i])){
      inconvenience[i] -= tree.getSize(a[i]) * tree.getSize(b[i]);
      tree.unite(a[i], b[i]);
    }
    /*
    for(int j=0; j<n; j++) printf("%d ", tree.find(j));
  	printf("\n");
    for(int j=0; j<n; j++) printf("%d ", tree.getSize(j));
  	printf("%lld\n", inconvenience[i]);
    */
  }
  
  for(int i=1; i<=m; i++){
  	printf("%lld\n", inconvenience[i]);
  }
  
  return 0;
}

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

int main() {
    int n;
    cin>>n;
    vector<int>vt(n);
    // for(int i:vt) cin>>vt.at(i);
    for(int i=0;i<n;i++) cin>>vt.at(i);
    // for(int i=0;i<n;i++) cout<<vt.at(i);
    ll ans=0;
    int f=0;
    for(int j=0;j<n;j++){
        f=max(f,vt.at(j));
        ans+=f-vt.at(j);
            // cout<<" "<<ans<<"\n";
    }
    cout<<ans<<endl;
    
  return 0;
}


Measured memory_bytes: 4060
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**7)

# Override `input` function because `stdin.readline()` is 10x faster than built-in `input()`
input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def solve(d, g, pc):
    min_num = 100 * d + 1
    for i in range(2**d):
        num = 0
        score = 0
        offset = -1
        for j in range(d):
            if (i >> j) & 1:
                # Solve full problems
                # print('i = {}, j = {}'.format(i, j))
                p, c = pc[j]
                # print('p = {}, c = {}'.format(p, c))
                num += p
                score += 100 * (j + 1) * p + c
                # print('num = {}, score = {}'.format(num, score))
            else:
                offset = j
                # print('offset:', offset)

        if score < g:
            # Solve incomplete problems
            short = 100 * (offset + 1)
            # print('short:', short)
            need = (g - score + short - 1) // short
            if need >= pc[offset][0]:
                continue
            # print('need:', need)
            num += need
            # print('need added:', num)

        min_num = min(min_num, num)
        # print('min num:', min_num)

    return min_num


def main():
    d, g = read_h()
    pc = read_v(d, m=2)
    # print(pc)

    num = solve(d, g, pc)
    print(num)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
X, N = list(map(int, input().split()))
p = set(map(int, input().split()))

dist = 0

if N == 0:
    print(X)
    dist_max = -2
else:
    dist_max = max(abs(max(p) - X), abs(min(p) - X))

while dist <= dist_max+1:
    if (X - dist in p) and (X + dist in p):
        dist += 1
        continue

    if not (X - dist in p):
        print(X - dist)
        break
    elif not (X + dist in p):
        print(X + dist)
        break

Measured memory_bytes: 9192
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,M; cin>>N>>M;
	vector<vector<int>> adj(N);
	for (int i=0; i<M; i++) {
		int A,B; cin>>A>>B; A--; B--;
		adj[A].push_back(B);
		adj[B].push_back(A);
	}
	vector<int> par(N,-1);
	set<int> st;
	queue<int> q; q.push(0); st.insert(0);
	while(!q.empty()) {
		int cur=q.front(); q.pop();
		for (int nxt : adj[cur]) {
			if(st.count(nxt)) continue;
			st.insert(nxt);
			par[nxt]=cur;
			q.push(nxt);
		}
	}
	for (int i=1; i<N; i++)
		if(par[i]==-1) {
			cout<<"No\n"; return 0;
		}
	cout<<"Yes\n";
	for (int i=1; i<N; i++)
		cout<<par[i]+1<<"\n";
	return 0;
}

Measured memory_bytes: 14864
// ALDS1_10_B.cpp
// Dynamic Programming - Matrix Chain Multiplication

#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
using namespace std;
static const int N = 100;
int main()
{
    int n;
    int P[N + 1];
    int m[N + 1][N + 1];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> P[i] >> P[i + 1];
    }

    for (int k = 0; k < n; k++) {
        for (int i = 1; i + k <= n; i++) {
            if (k == 0) m[i][i+k] = 0;
//            else if (k == 1) m[i][i+1] = P[i - 1] * P[i] * P[i + 1];
            else {
                int res = INT_MAX;
                for (int j = 0; j < k; j++) {
                    res  = min(res, m[i][i+j] + m[i+j+1][i+k] + P[i-1] * P[i+j] * P[i+k]);
                }
                m[i][i+k] = res;
            }
        }
    }

    cout << m[1][n] << endl;
    return 0;
}

Measured memory_bytes: 3120
n=int(input())
a=list(map(int,input().split()))
d=[0]*(10**5+1)
ans=0
for i in range(len(a)):
  if a[i]<=10**5:
    d[a[i]]+=1
  else:
    ans+=1
for i in range(1,len(d)):
  if d[i]>i:
    ans+=d[i]-i
  elif d[i]<i:
    ans+=d[i]
print(ans)

Measured memory_bytes: 14212
N = int(input())
A = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
     "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
name = ""
s = True
while s:
  a = N % 26
  if a == 0:
    a = 25
  else:
    a -= 1
  name = A[a] + name
  N = (N - a) // 26
  if N == 0:
    s = False

print(name)

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

using namespace std;

#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define all(x) x.begin(), x.end()

typedef pair<int, int> pi;
typedef long long ll;
const int MAX_INT = 2000000000;

int dp[100001][3];

int values[100001][3];

int main()
{
    int N;
    cin >> N;
    FOR(i, 1, N)
    {
        cin >> values[i][0] >> values[i][1] >> values[i][2];
    }

    dp[N][0] = values[N][0];
    dp[N][1] = values[N][1];
    dp[N][2] = values[N][2];

    for (int i = N - 1; i >= 1; i--)
    {
        dp[i][0] = values[i][0] + max(dp[i + 1][1], dp[i + 1][2]);
        dp[i][1] = values[i][1] + max(dp[i + 1][0], dp[i + 1][2]);
        dp[i][2] = values[i][2] + max(dp[i + 1][0], dp[i + 1][1]);
    }

    cout << max(max(dp[1][0], dp[1][1]), dp[1][2]);

    return 0;
}


Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

double get_s(int a, int b, double theta)
{
	double t = M_PI_2 - atan(b / (double)a);
	if (theta <= t)
	{
		double l = b * tan(theta);
		return (l * b / 2.0) * a;
	}
	else
	{
		double l = a / tan(theta);
		double n = (double)(a * a * b);
		double m = a * l / 2.0 * a;
		return n - m;
	}
}

double calc(int a, int b, int x)
{
	double l = 0;
	double r = M_PI_2;

	for (int i = 0; i < 10000; i++)
	{
		double m = l + (r - l) / 2.0;
		double s = get_s(a, b, m);
		if (s <= x)
		{
			l = m;
		}
		else
		{
			r = m;
		}
	}

	return l;
}

signed main()
{
	int A, B, X;
	cin >> A >> B >> X;
	double ans = M_PI_2 - calc(A, B, X);
	cout << std::fixed << std::setprecision(15) << (ans / M_PI * 180) << endl;
}



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

int INF = 1000000007;

int main() {
    int N;
    cin >> N;
    priority_queue<int> que;
    vector<int> A(N - 1);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        que.push(a);
    }
    int n = que.top();
    que.pop();
    for (int i = 0; i < N - 1; i++) {
        A[i] = que.top();
        que.pop();
    }
    int distance = INF, r;
    for (int i = 0; i < N; i++) {
        if (abs(n / 2 - A[i]) < distance) {
            r = A[i];
            distance = abs(n / 2 - A[i]);
        }
    }
    cout << n << " " << r << endl;
}

Measured memory_bytes: 1276
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<pd> vpd; 

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MX  = 2e5+5; 
const int MOD = 1e9+7; // 998244353;
const ll  INF = 1e18; 
const ld  PI  = acos((ld)-1);

const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 

template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; 
}
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; 
} 

constexpr int pct(int x) { return __builtin_popcount(x); } // number of ones 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
template<class T> T cdiv(T a, T b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 

int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}

template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); 
}

// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); 
}
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

// FILE I/O
void setIn(str S) { freopen(S.c_str(),"r",stdin); }
void setOut(str S) { freopen(S.c_str(),"w",stdout); }
void setIO(str S = "") {
	ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(S)) { setIn(S+".in"), setOut(S+".out"); } // for USACO
}

pi arr[MX];

bool can(int i) {
    return arr[i].f == arr[i].s;
}

int32_t main() { 
	
	setIO();

    int n; cin >> n;

    F0R(i,n) cin >> arr[i].f >> arr[i].s;

    bool res = 0;
    F0R(i,n) {
        if (i+1 < n && i+2 < n) {
            if (can(i) && can(i+1) && can(i+2)) res = 1;          

        } else break;
    }

    cout << (res ? "Yes\n" : "No\n");

}	

Measured memory_bytes: 3652
#include <stdio.h>
#define MAX 1001

int c[MAX][MAX];

int LCSLength(char X[], char Y[]){
  int i, j;

  //printf("%s, %s\n", X, Y);

  for( i = 1; X[i] != '\0'; i++){
    c[i][0] = 0;
  }
  for( j = 0; Y[j] != '\0'; j++){
    c[0][j] = 0;
  }

  for( i = 1; X[i-1] != '\0'; i++){
    for( j = 1; Y[j-1] != '\0'; j++){
      
      if(  X[i-1] == Y[j-1] ){
	c[i][j] = c[i-1][j-1] + 1;
	//printf("c[%d][%d] = %d\n", i, j, c[i][j]);
      }
      
      else if( c[i-1][j] >= c[i][j-1] ){
	c[i][j] = c[i-1][j];
      }
      
      else{
	c[i][j] = c[i][j-1];
      }
    
    }
  }

  return c[i-1][j-1];

}


main(){
  int q, i;
  char X[MAX], Y[MAX];

  scanf("%d", &q);

  for( i = 0; i < q; i++){
    scanf("%s %s", X, Y);
    printf("%d\n", LCSLength(X, Y));
  }

  return 0;

}

Measured memory_bytes: 4516
import Control.Monad
import Data.List
main=do
 n<-readLn;s<-replicateM n (sort<$>getLine)
 (print.sum.(map (\x->quot(x*(x-1))2)))(f n (sort s) 1)
  where f 1 _ i =[i]
        f n s i =if(s!!0==s!!1)then(f(n-1)(tail s)(i+1))else(i:(f(n-1)(tail s)1))

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

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define PB push_back
#define F first
#define S second

int main(){
    ll d, t, s; cin >> d >> t >> s;
    if(d <= t*s) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
	string nums;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> nums;
		for (int j = 0; j < nums.size() - 1; j++) {
			for (int k = 0; k < nums.size() - 1; k++) {
				if (nums[k] > nums[k + 1]) {
					string tmp;
					tmp = nums[k];
					nums[k] = nums[k + 1];
					nums[k + 1] = tmp[0];
				}
			}
		}
		int num1 = atoi(nums.c_str());
		string tmp="";
		for (int i = nums.size()-1; i >= 0; i--) {
			tmp += nums[i];
		}
		int num2 = atoi(tmp.c_str());
		cout << num2 - num1 << endl;
	}
}


Measured memory_bytes: 3016
#include <iostream>
#define max(a,b) (a>b?a:b)
using namespace std;

int main(){
	int a, b, k;
	cin >> a >> b >> k;
	int i, cnt = 0;
	for (i = max(a,b); i >= 1; i--)
	{
		if (a%i == 0 && b%i == 0)
			cnt++;
		if (k == cnt)
			break;
	}
	cout << i << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == b && b != c) || (a == c && a != b) || (b == c && b != a)) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>

int main()
{
  int n;
  scanf("%d", &n);
  std::set<std::string> set;
  std::string s;
  std::cin >> s;
  set.insert(s);
  char last = s.back();
  for (int i = 1; i < n; ++i)
  {
    std::cin >> s;
    if (last != s[0] || set.count(s) != 0)
    {
      puts("No");
      return 0;
    }
    set.insert(s);
    last = s.back();
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 256
class UnionFind
  
  
  # @param {Integer} n
  def initialize(n)
    @id = Array.new(n)
    @sz = Array.new(n)
    n.times do |i|
      @id[i] = i
      @sz[i] = 1
    end
  end
 
  def connected?(i, j)
    root(i) == root(j)
  end
 
  def unite(i, j)
    iroot = root(i)
    jroot = root(j)
    return if iroot == jroot
    if @sz[iroot] < @sz[jroot]
      @id[iroot] = j
      @sz[jroot] += @sz[iroot]
    else
      @id[jroot] = i
      @sz[iroot] += @sz[jroot]
    end
  end
  
  def size(i)
    @sz[root(i)]
  end
  
  def groups
    0.upto(@id.size-1).group_by {|i| root(i)}
  end
 
  def root(i)
    if @id[i] == i
      i
    else
      @id[i] = @id[@id[i]] # pass compression
      root(@id[i])
    end
  end
end

n, m, k = gets.split.map(&:to_i)

uf = UnionFind.new(n)

graph = Array.new(n) {Array.new}

m.times do
  a,b = gets.split.map(&:to_i)
  graph[a-1] << b-1
  graph[b-1] << a-1
  uf.unite(a-1,b-1)
end
 
blocks = Array.new(n) {Array.new}
 
k.times do
  a,b = gets.split.map(&:to_i)
  blocks[a-1] << b-1
  blocks[b-1] << a-1
end

groups = uf.groups

ans = []

0.upto(n-1) do |i|
  t = uf.size(i) - graph[i].size - 1
  blocks[i].each do |j|
    t -= 1 if uf.connected?(i,j)
  end
  ans << t
end

puts ans.join(' ')

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  cout << abs(A.at(0)-A.at(N-1)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<map>
#include<stdint.h>
#define sqr(x) (x)*(x)
#define int __int128
using namespace std;
int n,m,i,j,wyx=998244353;
map<int,int> dp[111];
string st;
int dfs(int x,int y)
{
	if (x==0) return 1; 
	if (x==1) return y+1;
	if (dp[x].count(y)) return dp[x][y]; 
	int i,j,now=0;
	now+=dfs(x-1,y>>1)*((y&1)+1)%wyx;
	for (i=1;i<=x;i++)
	{
		int t=(y&((((int)1)<<i)-1));
		for (j=1;i*j<=x;j++)
		{
			if (j>1)
			{
				now+=dfs(x-i*j,y>>(i*j))*dfs(i,t)%wyx;
				now%=wyx;
			}
			t&=(y>>(i*j));
		}
	}
	return dp[x][y]=now;
}
signed main()
{
	cin>>st;
	for (i=0;i<st.size();i++) if (st[i]=='1') n|=(((int)1)<<i);
	cout<<((long long)dfs(st.size(),n)); 
	return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 10;

int l[N];

void solve() {
  int n, a, b, c; scanf("%d%d%d%d", &n, &a, &b, &c);
  for (int i = 0; i < n; ++i) scanf("%d", l+i);
  int ans = 1e9;
  for (int i = 0, lmt = 1 << (n*2); i < lmt; ++i) {
    int h[4] = {0};
    int z[4] = {0};
    int cur = 0;
    for (int p, x = i, j = 0; j < n; ++j, x /= 4) {
      p = x%4;
      ++h[p];
      if (p == 3) continue;
      cur += 10;
      z[p] += l[j];
    }
    if (!h[0] || !h[1] || !h[2]) continue;
    ans = min(ans, cur+abs(a-z[0])+abs(b-z[1])+abs(c-z[2])-30);
  }
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3816
// 177

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>

using namespace std;
using ll = long long int;
#define NUM 1000000007

int main(){
    int n; 
    cin >> n;
    vector<int> v(4, 0);
    string str;
    for(int i=0; i<n; i++){
        cin >> str;
        if(str == "AC") v.at(0)++;
        if(str == "WA") v.at(1)++;
        if(str == "TLE") v.at(2)++;
        if(str == "RE") v.at(3)++;
    }
    cout << "AC x " << v.at(0) << endl;
    cout << "WA x " << v.at(1) << endl;
    cout << "TLE x " << v.at(2) << endl;
    cout << "RE x " << v.at(3) << endl;
    return 0;
}


Measured memory_bytes: 3596