akhauriyash/Code-Regression huggingface dataset:
import qualified Data.ByteString.Char8 as BS
import qualified Data.Maybe as Maybe
import qualified Debug.Trace as Trace

degree :: Double -> Double
degree r = (360.0 * r) / (2 * pi)

solve :: Double -> Double -> Double -> Double
solve a b x
    | a * ((a * b) / 2) < x = 90.0 - degree (atan ((a * a * a) / (2 * ((a * a * b) - x))))
    | otherwise = 90.0 - degree (atan ((2.0 * x) / (a * b * b)))

main = do
    [a, b, x] <- map (fst . Maybe.fromJust . BS.readInt) . BS.words <$> BS.getLine
    let ans = solve (fromIntegral a) (fromIntegral b) (fromIntegral x)
    print ans

Measured memory_bytes: 4148
#include <iostream>
#include <queue>
using namespace std;
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
int num =1,d[10000][10000];
char A[10000][10000];
bool valid(int x,int y,int W,int H)
{
    return (x>=0&&x<W)&&(y>=0&&y<H);
}
void Init(int W,int H)
{
    int i,j;
    num=1;
    for(i=0;i<W;i++)
        for(j=0;j<H;j++)
            d[i][j]=0;
}
void dfs(int x, int y, int W, int H, char A[10000][10000])
{
    int i;
    for(i=0;i<4;i++)
    {
        if(valid(x+dx[i],y+dy[i],W,H))
        {
            if(A[x+dx[i]][y+dy[i]]=='.' && d[x+dx[i]][y+dy[i]]==0)
            {
                num++;
                A[x+dx[i]][y+dy[i]]='#';
                d[x+dx[i]][y+dy[i]]=1;
                dfs(x+dx[i],y+dy[i],W, H,A);
            }
        }
    }
}
int main()
{
    int W,H,i,j,x,y;
    queue<int> Q;
    cin >> H >> W;
    while(W && H)
    {
        for(i=0;i<W;i++)
        {
            for(j=0;j<H;j++)
                cin >> A[i][j];
        }
        for(i=0;i<W;i++)
            for(j=0;j<H;j++)
            {
                if(A[i][j]=='@')
                {
                    x=i;
                    y=j;
                }
            }
        Init(W,H);
        d[x][y]=1;
        dfs(x, y, W, H, A);
        cout << num << endl;
        cin >> H >> W;
    }
    return 0;
}


Measured memory_bytes: 3296
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn gcd<T>(a: T, b: T) -> T
where
    T: Copy + std::cmp::PartialEq + std::ops::Rem<Output = T> + std::convert::From<u8>,
{
    if b == T::from(0u8) {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input! {
        n: usize,
        x: i64,
        xs: [i64; n],
    }
    let xs = xs.iter().map(|i| (*i - x).abs() as i64).collect::<Vec<_>>();
    let ans = xs.iter().skip(1).fold(xs[0], |sum, x| gcd(sum, *x));
    println!("{}", ans);
}


Measured memory_bytes: 6396
/*
ID: barish21
LANG: C++14
TASK: test
*/

/****Author: Barish Namazov****/
#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <stack>
#include <cstring>
#include <cmath>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sz(s) (intt)s.size()

#define ms0(arr) memset(arr,0,sizeof arr)
#define ms63(arr) memset(arr,63,sizeof arr)

#define forn(i,a,b) for(intt i=a;i<=b;i++)
#define rofn(i,a,b) for(intt i=a;i>=b;i--)
#define setf(it,myset) for(set<intt>::iterator it=myset.begin();it!=myset.end();it++)

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define VI vector<intt>
#define PII pair<intt,intt>
#define VPII vector< PII >

#define posl(ch) (int)(ch-'a'+1)
#define posL(ch) (int)(ch-'A'+1)

#define IO ios_base::sync_with_stdio(false);cin.tie();
/***************/

/***Additional Functions***/
intt powmod(intt a,intt b,intt mod){intt res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
intt gcd(intt a,intt b){return __gcd(a, b);}
intt lcm(intt a,intt b){return a*b/gcd(a,b);}
intt is_prime(intt n){if(n==1)return 0;if(n==2)return 1;if(n%2==0)return 0;for(intt i=3;i<=sqrt(n);i+=2)if(n%i==0)return 0;return 1;}
intt is_integer(double n){if(floor(n)==ceil(n))return 1;return 0;}

intt sto_int(string s){stringstream ss(s);intt n;ss>>n;return n;}
string to_string(intt n){stringstream ss;ss<<n;string s=ss.str();return s;}

/**************************/

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    IO;
    string s1, s2;
    cin >> s1 >> s2;
    if (s1.size() == s2.size())
        forn (i, 0, s1.size() - 1)
            cout << s1[i] << s2[i];
        else
    if (s1.size() > s2.size())  {
        forn (i, 0, s2.size() - 1)
            cout << s1[i] << s2[i];
        cout << s1[s1.size() - 1];
    }
    else {
        forn (i, 0, s1.size() - 1)
            cout << s1[i] << s2[i];
        cout << s2[s2.size() - 1];
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
c_list = sorted(list(map(int,input().split())),reverse = True)
a = 0
b = 0

for i in range(1,len(c_list) + 1):
    if i % 2 == 0:
        b += c_list[i-1]
    else: 
        a += c_list[i-1]
print(a-b )

Measured memory_bytes: 61616
#include <bits/stdc++.h>
using namespace std;
const int N = 100000;

void solve()
{
    int k; cin >> k;
    string s; cin >> s;

    if(s.size() > k)
        cout << s.substr(0, k) << "..." << '\n';
    else cout << s << '\n';
}

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

    //freopen("input.txt", "r", stdin);
    // int t; cin >> t;
    // while(t--)
        solve();
}

Measured memory_bytes: 3608
w = input()

letters = ['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', ]

counts = []

for letter in letters:
  counts.append(w.count(letter))

isEven = True
for c in counts:
  if (c % 2 == 1):
    isEven = False

result = 'Yes' if isEven else 'No'
print(result)


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
using namespace std;

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

    string S, T;
    cin >> S >> T;
    int l = T.size();
    if (S.size() < l) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    string ans;
    rep(i, S.size() - l + 1) {
        string S2 = S.substr(i, l);
        rep(j, l) {
            char s = S2[j];
            char t = T[j];
            if (s == '?' || s == t) {
                if (j == l - 1) {
                    string tmp = S;
                    S.replace(i, l, T);
                    if (ans.empty()) ans = S;
                    else ans = min(ans, S);
                    S = tmp;
                    break;
                } else continue;
            } else break;
        }
    }

    if (ans.empty()) {
        cout << "UNRESTORABLE" << endl;
    } else {
        rep(i, ans.size()) {
            if (ans[i] == '?') ans[i] = 'a';
        }
        cout << ans << endl;
    }

    return 0;
}


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

struct Problem {

    void Solve() {
        double r; cin >> r;
        const double pi = 3.14159265358979;
        cout << (r * r * pi) << " " << (r * 2.0 * pi) << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}



Measured memory_bytes: 3280
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int a[1000001];

int main(void)
{
  int K;
    scanf("%d",&K);
    a[1]=7%K;
    for(int i=2;i<=K;i++)a[i]=(a[i-1]*10+7)%K;

    for(int i=1;i<=K;i++)if(a[i]==0){
        printf("%d\n",i);
        return 0;
    }
    printf("-1\n");

  return 0;
}


Measured memory_bytes: 7628
import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str

isdelim(x::UInt8, xs::Set{UInt8}) = x in xs

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        if !isdelim(c, delims)
            break
        end
    end
    push!(out, c)
    if eof(s)
        return out
    end
    while !eof(s)
        c = read(s, UInt8)
        if isdelim(c, delims)
            break
        end
        push!(out, c)
    end
    return out
end

delimset = Set([0x0a, 0x20])

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

readvec(tys::Tuple , len::Signed)::Vector{Tuple{tys...}} = @inbounds Tuple{tys...}[reads(tys...) for i in 1:len]

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i = 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

function main()
    a,b,c,k = reads(Int,Int,Int,Int)
    c = 0
    k -= a
    if k <= 0
        println(k+a)
        return
    end
    c += a
    k -= b
    if k <= 0
        println(a)
        return
    end
    println(a-k)
end

main()


Measured memory_bytes: 194916
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
using namespace std;
const int N=1000;
const int mod=1e9+7;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int C[N][N],inv[N],qpow[N];
int head[N],nxt[N],to[N];
int ans=1,cnt,dfn[N],low[N],st[N],top,col,go[N],pre[N];
inline int gcd(int x,int y) { return y?gcd(y,x%y):x; }
inline int polya(int n) {
	int ans=0;
	for (int i=1;i<=n;i++) (ans+=qpow[gcd(i,n)])%=mod;
	return 1LL*ans*inv[n]%mod;
}
inline void dfs(int k,int fa) {
	dfn[k]=low[k]=++cnt;
	st[++top]=k;
	int s,i;bool flag;
	for (i=head[k];i;i=nxt[i]) if (to[i]!=fa) {
			if (!dfn[to[i]]) {
				dfs(to[i],k),low[k]=min(low[k],low[to[i]]);
				if (low[to[i]]>=dfn[k]) {
					s=0;flag=false;
					while (1) {
						s+=pre[st[top]]+1,flag|=go[st[top]]>1;
						if (st[top--]==to[i]) break;
					}
					ans=1LL*ans*(s==2?col:(flag?C[s+col-1][col-1]:polya(s)))%mod;
				}
			} else low[k]=min(low[k],dfn[to[i]]),pre[k]+=dfn[to[i]]<dfn[k];
			go[k]+=low[to[i]]<=low[fa];
		}
}
int main()
{
	int n=gi(),m=gi(),i,tot=0,a,b,j;col=gi();
	for (i=2,inv[1]=1;i<=m;i++) inv[i]=mod-1LL*inv[mod%i]*(mod/i)%mod;
	for (i=C[0][0]=1;i<=m+col;i++)
		for (j=C[i][0]=1;j<=i;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	for (i=qpow[0]=1;i<=m;i++) qpow[i]=1LL*qpow[i-1]*col%mod;
	while (m--) {
		a=gi(),b=gi();
		to[++tot]=b,nxt[tot]=head[a],head[a]=tot;
		to[++tot]=a,nxt[tot]=head[b],head[b]=tot;
	}
	for (i=1;i<=n;i++) if (!dfn[i]) dfs(i,0);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
from collections import Counter
n = int(input())
ctr = Counter(list(map(int, input().split())))
side = []
for k in sorted(ctr.keys(), reverse=True):
    if ctr[k] >= 4:
        side.append(k)
        side.append(k)
    elif ctr[k] >= 2:
        side.append(k)
print(side[0] * side[1] if len(side) >= 2 else 0)

Measured memory_bytes: 18592
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int A, B;
  cin >> A >> B;
  int ans = 0;
  if (A < B) swap(A, B);
  if (A == B) {
    ans = 2 * A;
  } else {
    ans = 2 * A - 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#define MAX_N 55
#define int long long

using namespace std;

int n,ans=0;
int a[MAX_N];

inline bool check()
{
	for(int i=1;i<=n;i++) if(a[i]>=n) return false;
	return true;
}

signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	while(!check())
	{
		int mx=0,id=0;
		for(int i=1;i<=n;i++) if(a[i]>mx) mx=a[i],id=i;
		int t=mx/n; a[id]-=t*n,ans+=t;
		for(int i=1;i<=n;i++) if(i!=id) a[i]+=t;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

S = input()
S_length = len(S)
black_indices = []
for i in range(S_length):
    if S[i] == 'B': black_indices.append(i)

total_blacks_indices = sum(black_indices)

black_count = len(black_indices)
index = S_length-1
result_black_indices = 0
for _ in range(black_count):
    result_black_indices += index
    index -= 1

print(result_black_indices - total_blacks_indices)



Measured memory_bytes: 13488
using System;

namespace a
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] X = Console.ReadLine().Split(' ');
            int A = int.Parse(X[0]);
            int B = int.Parse(X[1]);
            int ans = (A-1) * (B-1);
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
using namespace std;

typedef pair<int,int> pi;
#define MK make_pair
#define F first
#define S second

int dp[100][4];
pi s[100]={};


bool search(int n){
    bool j=false;
    int t=s[n].F;
    int w=s[n].S;
    int td=s[n+1].F;
    int wd=s[n+1].S;
    if(dp[n][0]!=-1 && abs(wd-w)*2<=td-t){
        j=true;
        dp[n+1][1]=dp[n][0]+abs(wd-w);
    }
    if(dp[n][0]!=-1 && w*2+wd<=td-t){
        j=true;
        if(dp[n+1][0]==-1){
            dp[n+1][0]=dp[n][0]+w+wd;
        }
        else{
            dp[n+1][0]=min(dp[n][0]+w+wd,dp[n+1][0]);
        }
    }
    
    
    if(dp[n][1]!=-1 && abs(wd-w)*3<=td-t){
        j=true;
        dp[n+1][2]=dp[n][1]+abs(wd-w);
    }
    if(dp[n][1]!=-1 && w*3+wd<=td-t){
        j=true;
        if(dp[n+1][0]==-1){
            dp[n+1][0]=dp[n][1]+w+wd;
        }
        else{
            dp[n+1][0]=min(dp[n][1]+w+wd,dp[n+1][0]);
        }
    }
    
    
    if(dp[n][2]!=-1 && w*4+wd<=td-t){
        j=true;
        if(dp[n+1][0]==-1){
            dp[n+1][0]=dp[n][2]+w+wd;
        }
        else{
            dp[n+1][0]=min(dp[n][2]+w+wd,dp[n+1][0]);
        }
    }
    return j;
}




int main(){
    while(1){
        
        
        
    
    fill(&dp[0][0],&dp[99][4],-1);
    dp[0][0]=0;
    fill(s,s+100,MK(0,0));
    int n;
    cin>>n;
        if(n==0){break;}
    int w=0;
    for(int i=1;i<=n;i++){
        cin>>s[i].S>>s[i].F;
        if(i==n){w=s[i].S;}
    }
    int ans=-1;
    for(int i=0;i<n;i++){
        if(!search(i)){ans=i; break;}
    }
        /*
        for(int i=0;i<=n;i++){
            for(int t=0;t<3;t++){
                cout<<dp[i][t]<<" ";
            }
            cout<<endl;
        }
        */
        
    if(ans!=-1){
        cout<<"NG "<<ans+1<<endl;
        continue;
    }
    int dis=1e9;
        if(dp[n][0]!=-1){dis=dp[n][0]+w;}
        if(dp[n][1]!=-1){dis=min(dis,dp[n][1]+w);}
        if(dp[n][2]!=-1){dis=min(dis,dp[n][2]+w);}
    cout<<"OK "<<dis<<endl;
        
        
        
        
        
    }
    
    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;

int main(void){
    for(int n, a, b, sa = 0, sb = 0; cin >> n, n; cout << sa << " " << sb << endl, sa = sb = 0)
        while(n --){
            cin >> a >> b;
            int res = a - b;
            sa += (!res) ? a:(res > 0) ? a + b:0;
            sb += (!res) ? b:(res < 0) ? a + b:0;
        }

    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll k,n,i,ans=INT_MIN;
    cin>>k>>n;
    vector<ll>a(n);
    cin>>a[0];
    for(i=1;i<n;++i)
    {
        cin>>a[i];
        ans=max(ans,a[i]-a[i-1]);
    }
    ans=max(ans,k-a[n-1]+a[0]);
    cout<<k-ans;
    
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int limit = 100000;
int main()
{

	bool prime[limit+1];
	for(int i=0; i<=limit; i++){
		prime[i]=true;
	}
	prime[0]=false;
	prime[1]=false;
	for(int i=2; i<=limit; i++){
		if(prime[i]){
			int tmp=i*2;
			while(tmp<=limit){
				prime[tmp] = false;
				tmp += i;
			}
		}
	}
	int cnt[limit+1];
	cnt[0]=0;
	cnt[1]=0;
	for(int i=2; i<=limit; i++){
		cnt[i]=cnt[i-1];
		if(prime[i] && prime[(i+1)/2]){
			cnt[i]++;
		}
	}

	int q;
	cin >> q;
	int l,r;
	for(int i=0; i<q; i++){
		cin >> l >> r;
		int ans = cnt[r]-cnt[l-1];
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int A, B, C;
	
	cin>>A>>B>>C;
	
	if(A%2 || B%2 || C%2) cout<<0<<endl;
	else if(A == B && B == C && C == A) cout<<-1<<endl;
	else {
		for(int i = 0; ; i++){
			// cout<<A<<" "<<B<<" "<<C<<endl;
			if(A%2 || B%2 || C%2){
				cout<<i<<endl;
				return 0;
			}
			int a = B/2+C/2, b = A/2+C/2, c = B/2+A/2;
			A = a, B = b, C = c;
		}
	}
	return 0;
}

Measured memory_bytes: 256
from decimal import Decimal


def main_v1():
    A, B = input().split()
    A = int(A)
    B = Decimal(B)
    print(int(A * B))


def main_v2():
    A, B = input().split()
    A = int(A)
    B = int(B.replace(".", ""))
    print(A * B // 100)


if __name__ == "__main__":
    main_v2()


Measured memory_bytes: 9920
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      Set<String> set = new HashSet<>();
      while(n-- > 0)
        set.add(sc.next());
      System.out.println(set.size());
  }
}

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

int main() {
  int x;
  cin >> x;
  if (x==3||x==5||x==7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        abs: [(i64, i64); n],
        cds: [(i64, i64); m],
    }
    fn distance(a: &(i64,i64), b: &(i64,i64)) -> i64 {
        (a.0 - b.0).abs() + (a.1 - b.1).abs()
    }
    for ab in abs {
        let mn = cds.iter().min_by(|l,r| {
            distance(&ab, l).cmp(&distance(&ab, r))
        }).unwrap();
        println!("{}", cds.iter().position(|x| *x == *mn).unwrap() + 1);
    }
}


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

string decrypt(string str1, int move) {
	string str2 = str1;
	for (int i = 0; i < str1.length(); i++) {
		if (str1[i] >= 'a' && str1[i] <= 'z') {
			str2[i] = (str1[i] - 'a' + move) % 26 + 'a';
		}
	}
	return str2;
}

int main(void) {
	string str1, str2;
	while (getline(cin, str1)) {
		for (int i = 0; i < 26; i++) {
			str2 = decrypt(str1, i);
			if (str2.find("this") != string::npos || 
				str2.find("that") != string::npos ||
				str2.find("the") != string::npos)
				break;
		}
		cout << str2 << endl;
	}
}


Measured memory_bytes: 2992
// 3人でカードゲームイージー  /  理解できた
// #16973056
#include <bits/stdc++.h>
using namespace std;

int main(){
    vector<string> s(3);
    cin >> s[0] >> s[1] >> s[2];
    vector<int> i(3, 0);
    char c[]={'A', 'B', 'C'};
    int t=0;
    while(true){
        if(i[t]==s[t].size()){
            cout << c[t] << endl;
            return 0;
        }
        i[t]++;
        t=s[t][i[t]-1]-'a';
        
    }
}

Measured memory_bytes: 3608
function Main(input){
  
  var str = input;
  var tmp = str.split("\n");
  var a = tmp[0];
  var b = tmp[1];
  var c = tmp[2];
  var d = tmp[3];
  var e = tmp[4];
     //console.log(a);
　var a1 = parseInt(a.slice(-1),10);
  var b1 = parseInt(b.slice(-1),10);
  var c1 = parseInt(c.slice(-1),10);
  var d1 = parseInt(d.slice(-1),10);
  var e1 = parseInt(e.slice(-1),10);
  
　var array = [a1,b1,c1,d1,e1];
  
  for(i=0;i<5;i++){
    if(array[i]==0){
      array[i]=10;
    }//if end
    
  }//for owari
      //console.log(array);
   //console.log(Math.min.apply(null,array));
  var min_index = array.indexOf(Math.min.apply(null,array));
  //var min_index = array.indexOf('5');  
    //console.log(min_index);

  var kekka = 0;
  
  for(i=0;i<5;i++){
    if(i==min_index){
      tmp[i]= parseInt(tmp[i],10);
    }else{
      tmp[i]=Math.ceil(tmp[i]/10)*10;
    }
    
  }//for end
    //console.log(tmp);
function sum(a) {
  return a.reduce(function(x, y) { return x + y; });
}
  
  var kekka = sum(tmp);
     console.log(kekka); 
  
}//function end
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define ll long long
#define pii pair<int, int>
using namespace std;

string s, c1, c2;

int main(){
    #ifdef DEBUG
       freopen("input.txt", "r", stdin);
    #endif // DEBUG
    cin >> s;
    c1 = "";
    for(int i = 5; i <= 6; ++i){
        c1 += s[i];
    }
    c2 = "";
    for(int i = 8; i <= 9; ++i){
        c2 += s[i];
    }
    cout << "2018/" << c1 << '/' << c2 << endl;
    return 0;
}



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

typedef long long ll;
 
int main(){
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  for(int i=0; i<=a; i++){
    for(int j=0; j<=b; j++){
      for(int k=0; k<=c; k++){
        if(i*500+j*100+k*50==x) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
a, b, c, x = [int(input()) for _ in range(4)]
cnt = 0
for ai in range(0, a+1):
    for bi in range(0, b+1):
        for ci in range(0, c+1):
            if 500*ai + 100*bi + 50*ci == x:
                cnt += 1
print(cnt)


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

#define For(i, j, k) for(int i = j; i <= k; i++)

const int N = 500010;

using namespace std;

struct Point{
	double x, y;

	Point(double _x = 0, double _y = 0):x(_x), y(_y) {}

}q[N];

typedef Point Vector;

Vector operator + (const Vector& A, const Vector& B){	
	return Point(A.x + B.x, A.y + B.y);
}

Vector operator - (const Vector& A, const Vector& B){	
	return Point(A.x - B.x, A.y - B.y);
}

int n, L;

int main(){

	int l = 0, r = -1;
	Point sum;

	scanf("%d%d", &n, &L);
	while(n--){
		Point p;
		scanf("%lf%lf", &p.y, &p.x);
		p.y *= p.x;

		while(l <= r && sum.x > L - p.x){
			sum = sum - q[l];
			if(sum.x < L - p.x){
				double len = L - p.x - sum.x;
				q[l] = Point(len, q[l].y / q[l].x * len);
				sum = sum + q[l];
				break;
			}
			++l;
		}

		q[++r] = p;
		sum = sum + p;

		printf("%.8lf\n", 1.0 * sum.y / L);

		while(l < r && q[r].y / q[r].x < q[r - 1].y / q[r - 1].x){
			q[r - 1] = q[r - 1] + q[r]; --r;
		}
	}
	
	return 0;
}

Measured memory_bytes: 17280
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>
#include<map>

int main()
{
	int n;
	scanf("%d", &n);
	if (n / 10 % 111 == 0 || n % 1000 % 111 == 0)
		printf("Yes\n");
	else
		printf("No\n");
	
	return 0;
}

Measured memory_bytes: 256
r, c = gets.chomp.split(' ').map { |i| i.to_i }
table = Array.new(r)
col_sum = Array.new(c, 0)
(0..r-1).each_with_index { |ro,ri|
  table[ri] = gets.chomp.split(' ').map { |i| i.to_i }
}

row_sum = 0
table.each_with_index { |ro,ri|
  ro.each_with_index { |co,ci|
    if ci < ro.size-1 then
      row_sum += co
      col_sum[ci] += co
      print "#{co} "
    else
      row_sum += co
      col_sum[ci] += co
      print "#{co} #{row_sum}\n"
      row_sum = 0
    end
  }
}

col_sum.each_with_index { |co,ci|
  if ci < col_sum.size-1 then
    row_sum += co
    print "#{co} "
  else
    row_sum += co
    print "#{co} #{row_sum}\n"
  end
}

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

int main() {
    int a[3];
    
    cin >> a[0] >> a[1] >> a[2];

    int count_5 = 0;
    int count_7 = 0;

    for(int i = 0; i < 3; i++){
        if(a[i] == 5){
            count_5++;
        }
        if(a[i] == 7){
            count_7++;
        }
    }

    if(count_5 == 2 && count_7 == 1){
        cout << "YES" << endl;
    } 
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3568
def main():
    class unionfind():
        def __init__(self,n):
            self.par = [i for i in range(n)]
            self.size = [1 for i in range(n)]
            self.rank = [0 for i in range(n)]
 
        def root(self,x):
            if self.par[x] == x:
                return x
            else:
                self.par[x] = self.root(self.par[x])
                return self.par[x]
 
        def same(self,x,y):
            return self.root(x) == self.root(y)
 
        def unite(self,x,y):
            x = self.root(x)
            y = self.root(y)
            if x==y:return
            else:
                if self.rank[x] < self.rank[y]:
                     x,y = y,x
                if self.rank[x] < self.rank[y]:
                    self.rank[x]+=1
                self.par[y] = x
                self.size[x] +=self.size[y]
        def get_size(self,x):
            x = self.root(x)
            return self.size[x]
 
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    n,m,k = map(int,input().split())
    uff = unionfind(n)
    fr = [0 for i in range(n)]
 
 
    for i in range(m):
        a,b = map(int,input().split())
        uff.unite(a-1,b-1)
        fr[a-1]+=1
        fr[b-1]+=1
 
 
    ans = [uff.get_size(i) -fr[i]-1 for i in range(n)]
 
    for i in range(k):
        c,d = map(int,input().split())
        if uff.same(c-1,d-1):
            ans[c-1] -=1
            ans[d-1] -=1
    print(*ans)
if __name__=="__main__":
    main()

Measured memory_bytes: 47152
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;
    int n,d,x;

    int f(int n){
        int count=0;
        int i=0;
        while(1){
            if(n*i+1>d)return count;
            count++;
            i++;
        }
    }
int main(){
    cin>>n>>d>>x;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    int count=0;
    rep(i,n){
        count+=f(a[i]);
    }
    cout<<count+x;
    return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int INF=1e9;

int main(){
	int N;
  	cin>>N;
	int F[101][10];
	rep1(i,N)rep(j,10)cin>>F[i][j];
	int P[101][11];
	rep1(i,N)rep(j,11)cin>>P[i][j];
	int ans=INF*(-1);
  cout<<endl;
	rep1(t,pow(2,10)-1){
		int b=0;
		rep1(i,N){
			int same=0;
			rep(j,10)if(F[i][j]==1&&(t>>j)&1==1)same++;
			b+=P[i][same];
		}
		ans=max(ans,b);
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x, y;
    cin >> x >> y;
    vector<int> v1 = {1, 3 ,5, 7, 8, 10, 12};
    vector<int> v2 = {4, 6, 9, 11};
    if (find(v1.begin(), v1.end(), x) != v1.end() && find(v1.begin(), v1.end(), y) != v1.end() ||
        find(v2.begin(), v2.end(), x) != v2.end() && find(v2.begin(), v2.end(), y) != v2.end()) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    priority_queue<int> q;
    REP(i,N){
        int a; cin >> a;
        q.push(a);
    }
    REP(i,M){
        int x = q.top(); q.pop();
        x /= 2;
        q.push(x);
    }
    LL ans = 0;
    while(!q.empty()){
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;

}


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

int N, color[9], Maxcnt, Mincnt;

void MaxMinCol(int a[]) {
	int iru;
	Maxcnt = 0, Mincnt = 0;
	for(int c=0;c<=8;c++) color[c] = 0; //初期化
	for (int i = 0;i <= N - 1;i++) {
		iru = a[i] / 400;
		if (iru > 8) iru = 8;
		color[iru]++;
	}
	for (int j = 0;j <= 7;j++) {
		if (color[j] != 0) Maxcnt++;
	}
	Mincnt = Maxcnt;

	Maxcnt += color[8]; //自由色の人数分を足す
	//if (Maxcnt > 8) Maxcnt = 8; //色は最大8

	if (Mincnt < 1) Mincnt = 1; //色は最低1
}



int main() {
	int a[102];

	cin >> N;
	for (int i = 0;i <= N - 1; i++) {
		cin >> a[i];
	}

	MaxMinCol(a);

	cout << Mincnt << " " << Maxcnt << endl;

	return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        string[] sp = Console.ReadLine().Split(' ');
        int x = int.Parse(sp[0]);
        int y = int.Parse(sp[1]);
        if (x == y) Console.WriteLine("a == b");
        else if (x > y) Console.WriteLine("a > b");
        else Console.WriteLine("a < b");
    }
}

Measured memory_bytes: 5292
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		//Sを左右半分ずつ切り出す		
		String S1 = S.substring(0,N/2);
		String S2 = S.substring(S.length()-N/2);
      
	  //Nが奇数の場合除外
      //左半分と右半分が等しければYes
      //そうでなければNo
      if(N%2!=0){
        System.out.println("No");
      }else if(S1.equals(S2)){
        System.out.println("Yes");
      }else{
        System.out.println("No");
    }
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

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

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

string op="Opened by ";
string cl="Closed by ";
string un="Unknown ";
string ID[257];
string IC;
int n;
int flag=0;

void search(){
  for(int i=0;i<n;i++){
    if(IC==ID[i] && flag==0){
      flag=1;
      cout << op << IC << endl;
      return;
    }else if(IC==ID[i] && flag==1){
      flag=0;
      cout << cl << IC << endl;
      return;
    }
  }
    cout << un << IC << endl;
}

int main(){
  int m,i;
  
  cin >> n;
  for(i=0;i<n;i++){
    cin >> ID[i];
  }
  cin >> m;
  for(i=0;i<m;i++){
    cin >> IC;
    search();
  } 		  
}
    

Measured memory_bytes: 1220
n,m=map(int,input().split())
broken=[False]*(n+1)
for i in range(m):
  broken[int(input())]=True
dp=[0]*(n+1)
dp[0]=1
dp[1]=0 if broken[1] else 1

for i in range(2,len(dp)):
  if broken[i]:
    dp[i]=0
  else:
    dp[i]=(dp[i-2]+dp[i-1])%1000000007
  
print(dp[-1])


Measured memory_bytes: 7668
move = [[0, 1], [0, -1], [-1, 0], [1, 0], [1, 1], [1, -1], [-1, -1], [-1, 1]]
from collections import deque
def main(w, h):
    c = [list(map(int, input().split())) for i in range(h)]
    ans = 0
    for y in range(h):
        for x in range(w):
            if c[y][x]:
                ans += 1
                q = deque()
                q.append((x, y))
                while q:
                    xx, yy = q.popleft()
                    for mx, my in move:
                        xm = xx + mx
                        ym = yy + my
                        if 0 <= xm < w and 0 <= ym < h:
                            if c[ym][xm]:
                                c[ym][xm] = 0
                                q.append((xm,ym))
    print(ans)


while 1:
    w, h = map(int, input().split())
    if w == h == 0:
        break
    main(w,h)


Measured memory_bytes: 6012
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define DEBUG
#ifdef DEBUG
    #define IFD(...) __VA_ARGS__
    #define IFN(...)
    #define L cout<<__LINE__<<"\n";
    #define PRINT(...) __VA_ARGS__ cout<<__LINE__<" : "<<#__VA_ARGS__<<"\n"
    #define PRT(x) cout<<__LINE__<<" : "<<#x<<" = "<<x<<"\n"
#else // DEBUG
    #define IFD(...)
    #define IFN(...) __VA_ARGS__
    #define L
    #define PRINT(...) __VA_ARGS__
    #define PRT(x)
#endif // DEBUG

#define it iterator
#define rit reverse_iterator
#define mp make_pair
#define mems(a,b) memset(a,b,sizeof(a))
#define mem0(a) mems(a,0)
#define mem1(a) mems(a,1)
#define mem255(a) mems(a,255)
#define halt exit(0)
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front
#define fort0(i,a,b) for(ll i=a,i##_TO=b;i<i##_TO;i++)
#define for0(i,n) fort0(i,0,n)
#define fort1(i,a,b) for(ll i=a,i##_TO=b;i<=i##_TO;i++)
#define for1(i,n) fort1(i,1,n)
#define ford(i,a,b) for(ll i=a,i##_TO=b;i>=i##_TO;i--)

using namespace __gnu_pbds;
using namespace std;

#define int ll

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b;
    cin>>a>>b;
    int d=b-a;
    cout<<d*(d+1)/2-b;
}


Measured memory_bytes: 256
//一道挺综合的组合数题 
#include<cstdio>
#define N 4005
#define ll long long
using namespace std;
int k,n,m,q;
ll c[N][N],Pow[N];
const ll mod=998244353;
void init()
{
	c[0][0]=1;
	Pow[0]=1;
	for(int i=1;i<=4000;i++)
	{
		Pow[i]=Pow[i-1]*2%mod;
		c[i][0]=1;
		for(int j=1;j<=i;j++)
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	}
}
ll calc(int x)
{
	m=q=0;
	for(int i=1;i<=k;i++)
	{
		if(1<=x-i&&x-i<=k)
		{
			if(x-i!=i)q++;
		}
		else m++;
	}
	ll res=0;
	q/=2;
	for(int j=0;j<=q;j++)
		res=(res+c[q][j]*Pow[j]%mod*c[n+m-1][j+m-1]%mod)%mod;
	if(!(x&1))
	{
		for(int j=0;j<=q;j++)
			res=(res+c[q][j]*Pow[j]%mod*c[n-1+m-1][j+m-1]%mod)%mod;
	}
	return res;
}
int main()
{
	init();
	scanf("%d %d",&k,&n);
	for(int i=2;i<=2*k;i++)
		printf("%lld\n",calc(i));
	return 0;
}

Measured memory_bytes: 123648
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[41000];
int c[41000];
int d[41000];
int e[41000];
struct wolf{
	int p,q;
	wolf(){}
	wolf(int A,int B){
		p=A;q=B;
	}
};
inline bool operator<(const wolf&a,const wolf&b){
	return (long long)a.p*b.q<(long long)a.q*b.p;
}
wolf t[41000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a+1;i++)scanf("%d%d%d%d",b+i,c+i,d+i,e+i);
	long long ret=0;
	long long now=0;
	int n=0;
	for(int i=0;i<a;i++){
		int p=max(c[i+1]-d[0],0);
		int r=max(c[0]-d[i+1],0);
		if(r==0&&p!=0){
			printf("-1\n");return 0;
		}else if(r==0){
			continue;
		}
		int q=(b[i+1]+r-1)/r;
		if(e[i+1]>e[0])ret+=p;
		t[n++]=wolf(q,p);
		now+=p;
	//	printf("%d %d\n",p,q);
	}
	std::sort(t,t+n);
	ret-=now;
	for(int i=0;i<n;i++){
		ret+=(long long)t[i].p*now;
		now-=t[i].q;
		if(ret>=b[0])break;
	}
	if(ret<b[0])printf("%lld\n",ret);
	else printf("-1\n");
}

Measured memory_bytes: 1944
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <cmath>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for (int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
   ios::sync_with_stdio(NULL);
   cin.tie(NULL); cout.tie(NULL);
   int a,b; cin >> a >> b;
   if (a == b){
      cout << "Yes" << endl;
   }
   else{
      cout << "No" << endl;
   }
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e5+5;
const int mod=998244353;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    if(n%2)
    {
        int i=1,j=n;
        while(m--)
        {
            cout<<i<<" "<<j<<'\n';
            i++;
            j--;
        }
        /*int i=1,j=n/2;
        while(m)
        {
            cout<<i<<" "<<j<<'\n';
            m--;
            i++;
            j--;
            if(i>=j)
                break;
        }
        i=n/2+1,j=n;
        while(m--)
        {
            cout<<i<<" "<<j<<'\n';
            i++;
            j--;
        }*/
    }
    else
    {
        int i=1,j=n/2;
        while(m)
        {
            cout<<i<<" "<<j<<'\n';
            m--;
            i++;
            j--;
            if(i>=j)
                break;
        }
        i=n/2+2,j=n;
        while(m--)
        {
            cout<<i<<" "<<j<<'\n';
            i++;
            j--;
        }
    }


}


Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int p[200010];
int main(void)
{
    int n,sum=0,mi=1e9;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> p[i];
    for(int i=1;i<=n;i++)
    {
        if(p[i]<mi)
        {
            mi=p[i];
            sum++;
        }
    }
    cout << sum;
    return 0;
}

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

import sys
input=sys.stdin.readline

n,x,m=map(int,input().split())
values=[]
s=set()
loop_start=-1
for i in range(n):
    if x in s:
        loop_start=values.index(x)
        break
    values.append(x)
    s.add(x)
    x=(x*x)%m
if loop_start==-1:
    ans=sum(values)
    print(ans)
    exit()
else:
    ans=sum(values[:loop_start])
    loops=values[loop_start:]
    loops_sum=sum(loops)
    n-=loop_start
    l=len(loops)
    ans+=n//l*loops_sum+sum(loops[:n%l])
    print(ans)

Measured memory_bytes: 13532
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  s=S()

  return s.count('ABC')

# main()
print(main())


Measured memory_bytes: 6864
value = gets.chomp.split(" ")
bill_count = value[0].to_i
amount_of_money = value[1].to_i

(bill_count + 1).times do |i|
    #print i," ",bill_count-i,"\n"
 
    max_money = i*10000 + (bill_count-i)*5000
    little_money = (bill_count-i)*1000

    if amount_of_money > max_money || amount_of_money < little_money
        #puts "飛ばします"
        next
    end

    (bill_count - i + 1).times do |j|
        
        k = bill_count - j - i

        if amount_of_money == (i*10000+j*5000+k*1000)
            print i," ",j," ",k,"\n"
            exit
        end

    end

end

puts "-1 -1 -1"


Measured memory_bytes: 3836