akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;

class tree{
public:
    void putparent(int n);
    void putleft(int n);
    void putright(int n);
    int getparent();
    string gettype();
    int getleft();
    int getright();
    tree();
private:
    int parent;
    int left_child;
    int right;
};

typedef struct tree Tree;

tree::tree()
{
    parent = -1;
    left_child = -1;
    right = -1;
}

void tree::putparent(int n)
{
    parent = n;
    return;
}

void tree::putleft(int n)
{
    left_child = n;
    return;
}

void tree::putright(int n)
{
    right = n;
    return;
}

int tree::getparent()
{
    return parent;
}

string tree::gettype()
{
    if(getparent() == -1) return "root";
    else if(getleft() == -1) return "leaf";
    else return "internal node";
}

int tree::getleft()
{
    return left_child;
}

int tree::getright()
{
    return right;
}

int getdepth(Tree a[], int n)
{
    int ans = 0;
    if(a[n].getparent() != -1) return getdepth(a, a[n].getparent()) + 1;
    else return 0;
}

int main()
{
    int n;
    cin >> n;
    Tree t[100000];
    int v, d, c, l;
    for(int i = 0; i < n; i++){
        cin >> v >> d;
        for(int j = 0; j < d; j++){
            cin >> c;
            if(j == 0) t[v].putleft(c);
            else t[l].putright(c);
            l = c;
            t[c].putparent(v);
        }
    }
    for(int i = 0; i < n; i++){
        cout << "node " << i << ": ";
        cout << "parent = " << t[i].getparent() << ", ";
        cout << "depth = " << getdepth(t, i) << ", ";
        cout << t[i].gettype() << ", ";
        cout << "[";
        if(t[i].getleft() != -1){
            cout << t[i].getleft();
            l = t[i].getleft();
            while(t[l].getright() != -1){
                cout << ", ";
                cout << t[l].getright();
                l = t[l].getright();
            }
        }
        cout << "]" << endl;
    }
}

Measured memory_bytes: 2376
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,a[MAXN],pos[MAXN],dp[MAXN];
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {
	read(a[i]);
	pos[a[i]] = i;
    }
    dp[1] = 1;
    for(int i = 2 ; i <= N ; ++i) {
	if(pos[i - 1] < pos[i]) dp[i] = dp[i - 1] + 1;
	else dp[i] = 1;
    }
    int res = N;
    for(int i = 1 ; i <= N ; ++i) {
	res = min(res,N - dp[i]);
    }
    out(res);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 2560
from decimal import *
from math import *
l=list(map(int,input().split()))
x=Decimal(l[0])**(Decimal(0.5))
y=Decimal(l[1])**(Decimal(0.5))
z=Decimal(l[2])**(Decimal(0.5))
if(x+y<z):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 71528
//Dice in Line

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) int n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int n,k;cin>>n>>k;
    vector<double>p(n);
    rep(i,0,n)cin>>p[i];
    rep(i,0,n)p[i]=(p[i]+1)/2;
    double ans = 0,c=0;
    rep(i,0,k)c+=p[i];
    ans=c;
    rep(j,k,n){
        c+=p[j];
        c-=p[j-k];
        ans=max(ans,c);
    }
    cout15(ans);
    return 0;
}

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

int main(){
  int m, d;
  cin >> m >> d;
  vector<int>mcnt(101, 0);
  for(int i=1; i<=d; i++){
    if(i%10<=1)continue;
    if(i/10<=1)continue;
    mcnt[(i%10)*(i/10)]++;
  }
  int ret=0;
  for(int i=1; i<=m; i++){
    ret += mcnt[i];
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>

using namespace std;

int n, m;
string s;
vector<int> v[202020];
int d1[202020], d2[202020];
int z[202020];

void dfs(int x) {
	if (d1[x] >= 1 && d2[x] >= 1) return;
	if (z[x]) return;
	z[x] = 1;
	for (auto u : v[x]) {
		if (s[x] == 'A') d1[u]--;
		if (s[x] == 'B') d2[u]--;
		if (!z[u] && (d1[u] < 1 || d2[u] < 1)) dfs(u);
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	cin >> s;
	s = "#"+s;
	for (int i = 1; i <= m; i++) {
		int a, b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
		if (s[a] == 'A') d1[b]++; else d2[b]++;
		if (s[b] == 'A') d1[a]++; else d2[a]++;
	}
	for (int i = 1; i <= n; i++) {
		dfs(i);
	}
	for (int i = 1; i <= n; i++) {
		if (d1[i] >= 1 && d2[i] >= 1) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
}


Measured memory_bytes: 16188
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n + 2];
		long total = 0;
		for (int i = 1; i <= n; i++) {
		    arr[i] = sc.nextInt();
		    total += Math.abs(arr[i] - arr[i - 1]);
		}
		total += Math.abs(arr[n + 1] - arr[n]);
		StringBuilder sb  = new StringBuilder();
		for (int i = 1; i <= n; i++) {
		    int d = Math.abs(arr[i] - arr[i - 1]) + Math.abs(arr[i + 1] - arr[i]) - Math.abs(arr[i + 1] - arr[i - 1]);
		    sb.append(total - d).append("\n");
		}
		System.out.print(sb);
	}
}


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

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<vector<long long>> d(n + 1);
    for(int i = 0; i < n; i++){
        long long x, y;
        cin >> x >> y;
        d[x].emplace_back(y);
    }
    vector<long long> d0, d1;
    for(int i = 1; i <= n; i++){
        if(d[i].size() == 0) continue;
        sort(rbegin(d[i]), rend(d[i]));
        d1.push_back(d[i][0]);
        for(int j = 1; j < d[i].size(); j++){
            d0.push_back(d[i][j]);
        }
    }
    sort(rbegin(d0), rend(d0));
    sort(rbegin(d1), rend(d1));
    int c = max(0, k - (int)d0.size());
    long long sum = 0;
    for(int i = 0; i < c; i++){
        sum += d1[i];
    }
    for(int i = 0; i < k - c; i++){
        sum += d0[i];
    }
    long long ans = 0;
    while(1){
        ans = max(ans, sum + (long long)c * c);
        if(c >= d1.size() || c >= k) break;
        sum -= d0[k - c - 1];
        sum += d1[c];
        c++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6904
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    string w = "MARCH";
    vector<ll> a(5,0);
    rep(i,n){
        string s;
        cin >> s;
        rep(i,5){
            if(s[0]==w[i]) a[i]++;
        }
    }

    ll ans = 0;

    // rep(i,5){
    //     cout << a[i] << endl;
    // }

    for(ll i=0;i<3;i++){
        for(ll j=i+1;j<4;j++){
            for(ll k=j+1;k<5;k++){
                ans += a[i] * a[j] * a[k];
            }
        }
    }

    cout << ans << endl;



    return 0;
}

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

void fnInput(int& rnMaxNum)
{
  cin >> rnMaxNum;
}

int64_t fnIntGet(const vector<char>& cnrvcNum)
{
  const vector<int> cnvnDgt = {0, 3, 5, 7};
  int64_t nRtn = 0;
  int nNumPos = 0;

  for (int i = cnrvcNum.size() - 1; i >= 0; i--)
  {
    if (cnrvcNum[i] == '0') break;
    nRtn += cnvnDgt[ cnrvcNum[i] - '0' ] * pow(10.0, nNumPos++);
  }

  return nRtn;
}

bool fnDgt753_Check(const vector<char>& cnrvcNum)
{
  int nDgt3Cnt = 0;
  int nDgt5Cnt = 0;
  int nDgt7Cnt = 0;

  for (int i = cnrvcNum.size() - 1; i >= 0; i--)
    if      (cnrvcNum[i] == '1') nDgt3Cnt++;
    else if (cnrvcNum[i] == '2') nDgt5Cnt++;
    else if (cnrvcNum[i] == '3') nDgt7Cnt++;

  if (nDgt3Cnt && nDgt5Cnt && nDgt7Cnt)
    return true;
  else 
    return false;
}

int fnDgt753_Count(int nMaxNum)
{
  int nDgt753Cnt = 0;
  int nDgtSiz = to_string(nMaxNum).size();
  vector<char> vcNum(nDgtSiz + 1, '0');

  while (fnIntGet(vcNum) <= nMaxNum)
  {
    if (fnDgt753_Check(vcNum)) nDgt753Cnt++;

    vcNum[vcNum.size() - 1]++;
    for (int i = vcNum.size() - 1; i > 0; i--)
      if (vcNum[i] > '3')
      {
        vcNum[i - 1]++;
        vcNum[i] = '1';
      }
  }

  return nDgt753Cnt;
}

int main()
{
  int nMaxNum;

  fnInput(nMaxNum);
  cout << fnDgt753_Count(nMaxNum) << endl;

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/2/24
Solved on 2019/2/24
@author: shinjisu
"""


# ABC 119
def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7


def dmp(x, cmt=''):
    global debug
    if debug:
        if cmt != '':
            print(cmt, ':  ', end='')
        print(x)
    return x


def gen2Bits(n):  # n個の0/1のリストを生成　[0]から変化
    bits = zeros(n)
    for i in range(4**n):
        for k in range(n):
            bits[k] = i % 4
            i //= 4
        yield bits


def probC():
    N, A, B, C = getIntList()
    L = []
    for i in range(N):
        L.append(getInt())
    dmp((N, A, B, C ))
    dmp(L)
    d = zeros(3)
    d[0] = A
    d[1] = B
    d[2] = C
    dmp(d)
    minMP = 99999999999999999999
    for f in gen2Bits(N):
        dmp(f)
        mp = 0
        lg = zeros(4)
        for i in range(N):
            if lg[f[i]] > 0 and f[i] < 3:
                mp += 10
            lg[f[i]] += L[i]
            dmp((i,lg,mp))
        #dmp(lg)
        allUsed = True
        for i in range(3):  # 4番目は使用しない竹
            if lg[i] == 0:
                allUsed = False
                break
            mp += abs(lg[i]-d[i])
        if not allUsed:
            continue
        dmp((minMP, mp))
        minMP = min(minMP, mp)
    return minMP


debug = False  # True False
print(probC())


def gcd(x, y):  # 最大公約数
    m = max(x, y)
    n = min(x, y)
    while m % n != 0:
        w = m % n
        m = n
        n = w
    return n


def probD():
    N, M = getIntList()
    A = getIntList()
    dmp((N, M))
    dmp(A)
    return num


def probA():
    S = input()
    dmp(S)
    y = int(S[0:4])
    m = int(S[5:7])
    d = int(S[8:10])
    dmp((y,m,d))
    HEI = 'Heisei'
    if y <= 2018:
        return HEI
    if m <= 4:
        return HEI
    else:
        return 'TBD'


def probB():
    N = getInt()
    dmp(N)
    sm = 0.0
    for i in range(N):
        x, u = [a for a in input().split()]
        dmp((x,u))
        if u == 'JPY':
            x = int(x)
        else:
            x = float(x) * 380000.0
        sm += x
    return sm




Measured memory_bytes: 3320
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  ll a, b, c, k;cin>>a>>b>>c>>k;
  ll ans;
  if(k%2==0)ans=a-b;
  else ans=b-a;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
// Practice AtCoder
// author: Loenardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let k = get!();
    let mut ps = vec![];
    let mut fs = vec![];
    for _ in 0 .. n {
        ps.push(get!());
    }
    for _ in 0 .. n {
        fs.push(get!());
    }
    ps.sort();
    fs.sort();
    fs.reverse();
    
    
    let mut lp = 0;
    let mut rp = fs.iter().zip(ps.iter()).map(|(&a,&b)| a*b).max().unwrap()+1;
    let mut cnt = 0;
    while lp < rp {
        cnt += 1;
        if cnt > 100 { break; }
        let hp = (lp + rp) / 2;
        let mut sum = 0;
        for i in 0 .. n {
            let e = hp / fs[i];
            if ps[i] > e {
                sum += ps[i] - e;
            }
        }
        if sum > k {
            lp = hp + 1;
        } else {
            rp = hp;
        }
    }
    println!("{}", lp);
}


Measured memory_bytes: 14584
def main():
  N = int(input())
  P = list(map(int, input().split()))
  

  minP = 1000000000000000000000
  cnt = 0
  
  for i in range(N):
    if P[i] <= minP:
      minP = P[i]
      cnt += 1
  
  print(cnt)
  
  
  
main()

Measured memory_bytes: 32248
import Prelude
import Data.List

differencepre :: [Int]->[Int]
differencepre [x]=[]
differencepre (x:y:ys)=(y-x-1):(differencepre (y:ys))

difference list = (head list):(differencepre list)

func1 :: Char->String->Int
func1 c s = maximum $ difference $ (elemIndices c s)++[length s]

func2 :: String -> Int
func2 s = minimum $ [func1 x s|x<-s]

main :: IO ()
main = do
    -- 文字列の入力
    s <- getLine
    putStrLn $ show $ func2 s



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

#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
    fast_io;
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0 ; i < n; i++)
    {
        char c = 'x';
        s[i] = c;
    }
    cout << s;
}


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

#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPS(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define RREPS(i, n) for (int i = ((int)(n)); i > 0; i--)
#define IREP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define IREPS(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVISORT(v) sort(v.begin(), v.end(), greater<int>());
#define ALL(v) v.begin(), v.end()

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;

typedef long long ll;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const ll mod=1e9+7;
int main()
{
    cin.tie( 0 );
    ios::sync_with_stdio( false );
	
	int n;cin>>n;
	VI v(n);
	REP(i,n)cin >> v[i];

	VSORT(v);

	vector<PII> vpi;
	int ans=-v[0]+v[n-1];
	IREP(i,1,n-1){
		ans+=abs(v[i]);
	}

	cout << ans << endl;

	int i=n-2;
	int prev=v[0];
	while(i>0&&v[i]>=0){
		cout << prev << " " << v[i] << endl;
		prev-=v[i];
		i--;
	}
	
	cout << v[n-1] << " " << prev << endl;
	prev=v[n-1]-prev; // 負のprevを正に変換

	while(i>0){
		cout << prev << " " << v[i] << endl;
		prev-=v[i];
		i--;
	}

    return 0;
}

Measured memory_bytes: 2304
program main
	implicit none
	character(100) S
	integer :: N, K
	read(*, *) N, K
	read(*, *) S
	if(S(K:K) == "A") then
		S(K:K) = "a"
	else if(S(K:K) == "B") then
		S(K:K) = "b"
	else
		S(K:K) = "c"
	end if
	write(*, *) trim(S)
end program main

Measured memory_bytes: 768
/// a.cpp
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < decltype(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < pll >
# define pb push_back
# define pdd pair < db , db >
# define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n;
    fi>>n;
    static int s[1 << 20];
    for (int i = 1;i <= n;++i)
        fi>>s[i];
    static deque < int > d;
    d.pb(1);
    for (int i = 3;i <= n;i += 2)
    {
        d.pb(i - 1);
        d.push_front(i);
    }
    vi v(d.begin(),d.end());
    if (!(n & 1))
        v.pb(n),reverse(v.begin(),v.end());
    for (auto it : v)
        fo << s[it] << ' ';
    fo << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; ++i) {
        string row;
        cin >> row;
        cout << row << "\n" << row << "\n";
    }
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    cout<<a[n-1]-a[0];

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  if(S=="SUN"){
    cout<<7<<endl;
  }
  else if(S=="MON"){
    cout<<6<<endl;
  }
  else if(S=="TUE"){
    cout<<5<<endl;
  }
  else if(S=="WED"){
    cout<<4<<endl;
  }
  else if(S=="THU"){
    cout<<3<<endl;
  }
  else if(S=="FRI"){
    cout<<2<<endl;
  }
  else {
    cout<<1<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int res = 0;
    rep(i, A+1) rep(j, B+1) rep(k, C+1) {
        int temp = 500*i + 100*j + 50*k;
        if(temp == X) res++;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void main_sub(void);
int main(int argc, char* argv[]) {
    cout << std::fixed << std::setprecision(10);
    main_sub();
    return 0;
}
// int を int64_t にする
// g++ に -DUSE_STRICT_INT をつけるか、
// 下のコメントアウトを外すと無効化
// #define USE_STRICT_INT
using i64 = int64_t;
#ifndef USE_STRICT_INT
#define int i64
#endif
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF = (1 << 30);
constexpr i64 INFL = (1LL << 62);
constexpr i64 MOD = 1000000007;

void main_sub(void) {
    int n, m, d;
    cin >> n >> m >> d;
    if (d) {
        cout << (long double)2 * (n - d) / n / n * (m - 1) << endl;
    } else {
        cout << (long double)(m - 1) / n << endl;
    }
    return;
}

Measured memory_bytes: 256
N=int(input())
h=list(map(int, input().split()))
c=[0]*N

for i in range(N):
	if i==0:
		c[i]=0
	elif i==1:
		c[i]=abs(h[i]-h[i-1])
	else:
		c[i]=min(c[i-1]+abs(h[i]-h[i-1]),c[i-2]+abs(h[i]-h[i-2]))

print(c[N-1])

Measured memory_bytes: 13928
num = input()
A = int(num[0])
B = int(num[1])
C = int(num[2])
D = int(num[3])
if 7-A==B+C+D:
  op1='+'
  op2='+'
  op3='+'
elif 7-A==B+C-D:
  op1='+'
  op2='+'
  op3='-'
elif 7-A==B-C+D:
  op1='+'
  op2='-'
  op3='+'
elif 7-A==C+D-B:
  op1='-'
  op2='+'
  op3='+'
elif 7-A==B-C-D:
  op1='+'
  op2='-'
  op3='-'
elif 7-A==C-D-B:
  op1='-'
  op2='+'
  op3='-'
elif 7-A==D-C-B:
  op1='-'
  op2='-'
  op3='+'
elif 7-A==-D-C-B:
  op1='-'
  op2='-'
  op3='-'
print(num[0]+op1+num[1]+op2+num[2]+op3+num[3]+"=7")

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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
struct Edge {
    int to, cost;
    Edge(int to, int cost): to(to), cost(cost) {}
};

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<Edge>> AdjList;
AdjList graph;

const int INF = 100000000;

LL d[10][10];
int main() {
    //cout << fixed << setprecision(15);

    int n;
    while(cin >> n){
        if(n==0) break;

        for(int i=0; i<10; ++i){
            for(int j=0; j<10; ++j){
                d[i][j] = INT_MAX;
            }
        }
        for(int i=0; i<10; ++i) d[i][i]=0;
        set<int> st;
        REP(i, n){
            int u, v, c; cin >> v >> u >> c;
            d[v][u] = c;
            d[u][v] = c;
            st.insert(u);
            st.insert(v);
        }

        REP(k, 9) REP(i, 9) REP(j, 9) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

        int ans_idx=0;

        int min_cost=1000000;
        for(auto e: st){
            LL cost = 0;
            for(auto f: st){
                cost += d[e][f];
            }
            if(min_cost > cost){
                ans_idx = e;
                min_cost = cost;
            }
        }

        cout << ans_idx << " " << min_cost << endl;


    }

}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
int sigma(int n){
    int sum=0;
    for (int i=1; i<=(n); i++){
        sum+=i;
    }
    return sum;
}
int distance(int yo,int xo,int yi,int xi){
    return (yo-yi)*(yo-yi)+(xo-xi)*(xo-xi);
}
signed main(){
    int A,B;
    cin >> A >> B;
    if((A==1&&B==2)||(A==2&&B==1)){
        cout << 3 << endl;
        return 0;
    }
    if((A==2&&B==3)||(A==3&&B==2)){
        cout << 1 << endl;
        return 0;
    }
    if((A==1&&B==3)||(A==3&&B==1)){
        cout << 2 << endl;
        return 0;
    }
}


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

namespace AtCoder.Grand016
{
    public class AGC016B_ColorfulHats
    {
        public static void Main(string[] args)
        {

            // 整数の入力
            int catNum = int.Parse( Console.ReadLine() );

            // スペース区切りの整数の入力
            int[] hatNum = Console.ReadLine().Split( ' ' ).Select(int.Parse).ToArray();

            // 最小（大）値、最小（大）値の数            
            int minHatTypeNum = hatNum.Min();
            int maxHatTypeNum = hatNum.Max();
            int minCatCnt = hatNum.Count( val => val == minHatTypeNum);
            int maxCatCnt = catNum - minCatCnt;
            

            string result = "Yes";

            // 色数に2以上の差が付くことはありえない
            if ( maxHatTypeNum - minHatTypeNum > 1 )
            {
                result = "No";
            }

            if ( minHatTypeNum == maxHatTypeNum )
            {
                // 全員が同じ値(x)
                // 各色に1匹、もしくは各色に２匹以上

                // 各色に２匹以上(x!=N-1)であれば、種類数がN/2を上回ることはない
                if ( minHatTypeNum != catNum - 1 && minHatTypeNum > catNum / 2  )
                {
                    result = "No";
                }

            }
            else
            {
                // xとx-1が混在
                // １匹しかいないのが1～x-1組、残りは２匹以上のグループ
                // ２匹以上のペアはx-単独数できるため、ペアに属する猫は(x-単独数)*2匹以上になる

                // １匹しかいない色数（＝x-1の数）は、1～x-1の範囲内でないとおかしい
                if ( minCatCnt > minHatTypeNum )
                {
                    result = "No";
                }

                // ２匹以上グループの猫数は、(x-単独数)*2匹以上でないとおかしい
                if ( maxCatCnt < (maxHatTypeNum - minCatCnt) * 2 )
                {
                    result = "No";
                }

            }
            
            // 結果出力
            Console.WriteLine( result );
            
        }
        
    }
}

Measured memory_bytes: 19040
#include <stdio.h>

int main (){
  int n1,n2,temp;

  scanf("%d%d",&n1,&n2);
  while(1){
    if(n1<n2){
      temp = n1;
      n1=n2;
      n2=temp;
    }
    if(n1%n2!=0)n1%=n2;
    else break;
  }
  printf("%d\n",n2);
  return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    long long int n;
    cin>>n;
    long long int a[n];
    for (long long int i=0;i<n;i++)
    cin>>a[i];
    
    long long int ans=0;
    for (long long int i=0;i<n-1;i++)
    {
        if (a[i+1] < a[i])
        {
            ans += (a[i] - a[i+1]);
            a[i+1] = a[i]; 
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
    
}

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

bool check()
{

}

int main()
{
    int n, m;
    cin >> n >> m;

    char a[n][n], b[m][m];
    rep(i, n)
    rep(j, n)
        cin >> a[i][j];
    rep(i, m)
    rep(j, m)
        cin >> b[i][j];
    
    for (int i = 0; i + m - 1 < n; i++)
    for (int j = 0; j + m - 1 < n; j++)
    {
        bool c = true;
        rep(k, m)
        {
            rep(l, m)
                c &= a[i+k][j+l] == b[k][l];
            if (not c)
                break;
        }
        if (c)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

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

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

int main() {
	char ans[4]="";
	for(int i=0;i<3;i++)cin >> ans[i];
	
	if (!strcmp(ans, "SSS")) { cout << "0" << endl; return 0; }
	else if (!strcmp(ans, "SSR")) { cout << "1" << endl; return 0; }
	else if (!strcmp(ans, "SRS")) { cout << "1" << endl; return 0; }
	else if (!strcmp(ans, "SRR")) { cout << "2" << endl; return 0; }
	else if (!strcmp(ans, "RSS")) { cout << "1" << endl; return 0; }
	else if (!strcmp(ans, "RSR")) { cout << "1" << endl; return 0; }
	else if (!strcmp(ans, "RRS")) { cout << "2" << endl; return 0; }
	else if (!strcmp(ans, "RRR")) { cout << "3" << endl; return 0; }


	return 0;

}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const double PI  = 3.1415926535897932384626433832795028841971;
const int    INF = 1000000007;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

int m, n;
int brd[110][110];

int main(){
    cin >> m >> n;
    rep(i,m) rep(j,n){
        char x;
        cin >> x;
        if(x == '-') continue;
        if(x == 'o'){
            brd[i+1][j] = 1;
            brd[i+1][j+1] = 1;
            brd[i+1][j+2] = 1;
        } else{
            for(int u = -1; u <= 1; u++) for(int v = -1; v <= 1; v++){
                brd[i+1+u][j+1+v] = 1;
            }
        }
    }
    int ans = 0;
    for(int i = 2; i <= m; i++) for(int j = 1; j <= n; j++) if(brd[i][j] == 0) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 1208
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int m = s.nextInt();
		int[][] arr=new int[n][m];
		for(int i=0;i<n;i++) {
			String str=s.next();
			for(int j=0;j<m;j++) {
				char c=str.charAt(j);
				if(c=='.')
					arr[i][j]=0;
				else
					arr[i][j]=1;
			}
		}
		int[][] dp=new int[n][m];
		for(int i=0;i<n;i++)
		Arrays.fill(dp[i],-1);
		int a=dfs(0,0,arr,dp);
		System.out.println(a);

	}
	public static int dfs(int i, int j, int[][] arr, int[][] dp) {
		if(i==arr.length-1 && j==arr[0].length-1) {
			return 1;
		}
		if(i<0 || j<0 || i>=arr.length || j>=arr[0].length || arr[i][j]==1) {
			return 0;
		}
		if(dp[i][j]!=-1) {
			return dp[i][j];
		}
		dp[i][j]=dfs(i+1,j,arr,dp)%1000000007+dfs(i,j+1,arr,dp)%1000000007;
		return dp[i][j]%1000000007;
	}
}


Measured memory_bytes: 38556
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
b = Array.new(n/2+1,0)
ans = 0
if n.odd? && a.all?{|num|num%2 == 0}
  a.each do |num|
    b[num/2] += 1
  end
  if b[0] == 1 && b[1..-1].all?{|num|num == 2}
    ans = 2**(n/2)%(10**9+7)
  end
elsif !(n.odd?) && a.all?{|num|num%2 == 1}
  a.each do |num|
    b[num/2] += 1
  end
  if b[0..-2].all?{|num|num == 2}
    ans = 2**(n/2)%(10**9+7)
  end
end
puts ans

Measured memory_bytes: 9108
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = 1e13+7;

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

vector<vector<ll>> d;

void warshall_floyd(int n){
    rep(i,0,n){
        rep(j,0,n){
            rep(k,0,n){
                d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
            }
        }
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m,r; cin >> n >> m >>r;
    vector<int> R(r);
    rep(i,0,r){
        cin >> R[i];
        R[i]--;
    }
    d.resize(n);
    rep(i,0,n){
        d[i].assign(n,LNF);
        d[i][i] = 0;
    }
    rep(i,0,m){
        int a,b; ll c; cin >> a >> b >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    warshall_floyd(n);
    ll ans = LNF;
    sort(all(R));
    do{
        ll x = 0;
        rep(i,0,r-1){
            x += d[R[i]][R[i+1]];
        }
        chmin(ans,x);
    }while(next_permutation(all(R)));
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
#include <map>
#include <list>
#include <bitset>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

const double PI  = 3.141592653589793238463;
const int INF = 1000000007;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

V count_chars(string& s){
    V res('z' - 'a' + 1);
    for(int i = 0; i < s.size(); i++){
        res[s[i] - 'a']++;
    }
    return res;
}

V count_chars(int n, vector<string>& ss){
    M css;
    for(int i = 0; i < n; i++){
        css.push_back(count_chars(ss[i]));
    }
    V res;
    for(int i = 0; i < 'z' - 'a' + 1; i++){
        int c = 100;
        for(int j = 0; j < n; j++){
            c = min(css[j][i], c);
        }
        res.push_back(c);
    }
    return res;
}


string solve(int n, vector<string>& ss){
    const V& cs = count_chars(n, ss);
    string res;
    for(int i = 0; i < cs.size(); i++){
        res += string(cs[i], 'a' + i);
    }
    return res;
}


int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<string> ss(n);
    for(int i = 0; i < n; i++){
        cin >> ss[i];
    }
    cout << solve(n, ss) << "\n";

    return 0;
}


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

int main (){
	double a,b,x;
	cin >> a>>b>>x;
    double s = x/a;
    double rad =0;
    if(s>a*b/2){
        double h = ((a*b -s)*2) / a;
        rad = atan2(h,a);
    }else{
        double w = (2*s)/b;
        rad = atan2(b,w);
    }
    double PI = acos(-1);
    double deg = rad/(PI*2)*360;
    printf("%.10f",deg);
  
    cout<<endl;

}



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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

const int MAX = 1003;
int dp[MAX][MAX];

int lcs(string x, string y) {
  int m = x.length();
  int n = y.length();
  x = ' ' + x;
  y = ' ' + y;
  rep(i,m+1) dp[i][0] = 0;
  rep(i,n+1) dp[0][i] = 0;

  int ans = 0;
  for (int i=1; i<=m; i++) {
    for (int j=1; j<=n; j++) {
      if (x[i] == y[j]) dp[i][j] = dp[i-1][j-1] + 1;
      else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      //printf("[*] %d %d %d\n", i, j, dp[i][j]);
      ans = max(ans, dp[i][j]);
    }
  }

  return ans;
}

int main() {
  int n;
  cin >> n;
  string x, y;
  vector<int> ans;
  rep(i,n) {
    cin >> x;
    cin >> y;
    ans.push_back(lcs(x, y));
  }

  rep(i,ans.size()) cout << ans[i] << endl;
  return 0;
}



Measured memory_bytes: 7128
#include <bits/stdc++.h>
using namespace std;
long long a,b,c;
int main() 
{cin>>a>>b>>c;
 if(a%2==0||b%2==0||c%2==0) 
   {cout<<0;
    return 0;
   }
 cout<<min(min(a*b,a*c),b*c);
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
  
int main()
{
  int64 N, H, d[100000], h[100000];
  
  cin >> N >> H;
  for(int i = 0; i < N - 1; i++) {
    cin >> d[i] >> h[i];
  }
  
  
  int64 power = H , ret = 0LL;
  int64 hill[100000];
  int64 now[100000];
  for(int i = 0; i < N - 1; i++) hill[i] = h[i];
  
  
  for(int i = 0; i < N - 1; i++) {
    now[i] = power;
    power -= d[i];
    while(power <= 0) {
      int MaxPos = i;
      int64 hoge = H;
      for(int j = i; j >= 0; j--) {
        hoge = min(hoge, H - now[j]);
        h[j] = min(h[j], hoge);
        if(h[MaxPos] < h[j]) MaxPos = j;
        if(hoge == 0) break;
      }
 
      int64 hori = min(-power / h[MaxPos] + 1, (H - now[MaxPos]) / h[MaxPos]);
      ret += hori;
      power += hori * h[MaxPos];
      for(int j = MaxPos; j <= i; j++) {
        now[j] += hori * h[MaxPos];
        now[j] = min(now[j], H);
      }
    }
  }
 
  cout << ret << endl;
}

Measured memory_bytes: 3500
fn read_num() -> i32 {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf);
  buf.trim().parse().unwrap()
}

fn read_nums() -> Vec<i32> {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf);
  buf.split_whitespace().map(|x| x.parse().unwrap()).collect()
}

fn main() {
  let n = read_num();
  let h = read_nums();
  let mut r = 1;
  let mut max_h = h[0];
  for (i, item) in h.iter().enumerate() {
    if i == 0 {
      continue;
    }
    if *item >= max_h {
      r += 1;
      max_h = *item;
    }
  }
  println!("{}", r);
}

Measured memory_bytes: 4352
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((n (read))
         (s (make-array n :element-type 'bit :initial-element 0)))
    (declare (uint32 n))
    (dotimes (i n)
      (when (char= #\o (read-char))
        (setf (sbit s i) 1)))
    (dotimes (bits 8 (println -1))
      (let ((res (make-array n :element-type 'bit :initial-element 0)))
        (setf (aref res 0) (ldb (byte 1 0) bits))
        (setf (aref res 1) (ldb (byte 1 1) bits))
        (setf (aref res 2) (ldb (byte 1 2) bits))
        (loop for pos from 3 below n
              do (setf (sbit res pos)
                       (logxor (sbit s (mod (- pos 1) n))
                               (sbit s (mod (- pos 2) n))
                               (sbit res (mod (- pos 3) n)))))
        (when (loop for pos below n
                    always (= (sbit s pos)
                              (logxor (sbit res (mod (- pos 1) n))
                                      (sbit res (mod pos n))
                                      (sbit res (mod (+ pos 1) n)))))
          (loop for b across res
                do (write-char (if (zerop b) #\W #\S)))
          (terpri)
          (return-from main))))))

#-swank(main)


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



int main(){
  int n,x,l,d;
  d = 0;
  cin >> n >> x;
  for(int i=1;i<=n;i++){
    cin >> l;
    if(d+l>x){
      cout << i << endl;
      return 0;
    }else{
      d = d+l;
    }
  }
  cout << n+1 << endl;
  return 0;
}


Measured memory_bytes: 256
def prime(p):
    memo = [p]
    for i in range(2,(int(p**0.5)+1)):
        if p%i == 0:
            memo.append(i)
            memo.append(p//i)
    return memo

x = int(input())

if x== 1:
    print(0)
    exit()

memo = prime(x)

ans = 0

for i in memo:
    if x%(i-1)==x//(i-1):
        ans += i-1
print(ans)

Measured memory_bytes: 65440
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[])
{
	int n;
	cin>>n;
	if(n%2==0)
		printf("%d\n",(n/2)*(n/2));
	else
		printf("%d\n",(n/2)*(n/2+1));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
ll p[100002];
ll find(ll x)
{
  return p[x]==x ? x :p[x]=find(p[x]);//p[x]=find(p[x]) necessary else TLE as it takes longer time to find parent
}
int main()
{
  IOS;
  ll n,m,i;
  cin>>n>>m;
  ll link[m][2],sum[n],ans[m];
  for(i=0;i<n;i++)
  {
    p[i]=i;
    sum[i]=1;
  }
  for(i=0;i<m;i++)
  {
    cin>>link[i][0]>>link[i][1];
  }
  ans[m-1]=(n*(n-1)/2);
  for(i=m-1;i>0;i--)
  {
    ll q,w;
    q=find(link[i][0]);
    w=find(link[i][1]);
    if(q!=w)
    {
      ans[i-1]=ans[i]-(sum[q]*sum[w]);
      sum[w]+=sum[q];
      p[q]=w;
    }
    else ans[i-1]=ans[i];
  }

  for(auto g: ans) cout<<g<<endl;
  return 0;
}


Measured memory_bytes: 5248
package main

import (
  "fmt"
  "container/list"
  "strconv"
  "strings"
)

func main() {
  var s string
  var m,n int
  fmt.Scan(&s)
  n = len(s)
  queue := list.New()
  queue.PushBack(s[n-1:n])
  m = 1
  for k:=n-2;k>=0;k-- {
    var p string = s[k:k+1]
    for i:=0;i<m;i++ {
      t,_ := queue.Remove(queue.Front()).(string)
      queue.PushBack(p+t)
      queue.PushBack(p+" "+t)
    }
    m *= 2
  }
  var sum int64 = 0
  for i:=0;i<m;i++ {
    t,_ := queue.Remove(queue.Front()).(string)
    var u []string = strings.Split(t," ")
    for j:=0;j<len(u);j++ {
      p,_ := strconv.Atoi(u[j])
      sum += int64(p)
    }
  }
  fmt.Println(sum)
}

Measured memory_bytes: 768
#include <stdio.h>
int main(){
	long long int n,a,b,c,d,e,x;
	scanf("%lld%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d,&e);
	long long int ans;
	x = a<b ? a:b;
	x = x<c ? x:c;
	x = x<d ? x:d;
	x = x<e ? x:e;
	ans = 4 + (n%x==0 ? n/x : n/x+1);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
 
int main(){
  int a, b, c, k ;
  cin >> a >> b >> c >> k ;
  if(k <= a) cout << k ;
  if(a < k && k <= a+b) cout << a ;
  if(a+b < k) cout << 2*a + b - k ;
  return 0 ;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define name "test"
#define fi first
#define se second
#define ll long long
#define db double
#define pb push_back
#define wrln cout<<'\n';
#define ii pair<int,int>
#define li pair<long long,int>
#define iii pair<int,ii>

using namespace std;
const int N=2e3+100;

ll a[N][N],p[N],x,n,f[N],res;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    if ( fopen(name".inp","r") )
    {
        freopen(name".inp","r",stdin);
        freopen(name".out","w",stdout);
    }
    cin>>n; int d=0;
    for (int i=1; i<=n; i++)
    {
        int x,y;
        cin>>x>>y;
        if (x==y) d++; else d=0;
        if (d==3)
        {
             cout<<"Yes"; return 0;
        }
    }
    cout<<"No";
}


Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int sum = 0;
        int max = 0;
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (ch == 'R') {
                sum++;
                max = Math.max(max, sum);
            } else {
                sum = 0;
            }
        }
        System.out.println(max);
    }
}


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

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

    if(a > b){
        for(int i = 0; i < a; i++)
            cout << b;
    }
    else{
        for(int i = 0; i < b; i++)
            cout << a;
    }

    return 0;
}


Measured memory_bytes: 3612
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toInt() }
    var all = 1
    var bad = 1
    for (i in a) {
        all *= 3
        if (i % 2 == 0) bad *= 2
    }
    println(all - bad)
}


Measured memory_bytes: 36392
n,k = map(int,input().split())
x = [1]*n
for i in range(k):
    d = int(input())
    y = list(map(int,input().split()))
    for j in y:
        x[j-1] = 0
count = 0
for i in x:
    if i == 1:
        count+=1
print(count)

Measured memory_bytes: 9188
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <cmath>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int N;
    int T, A;
    cin >> N;
    cin >> T >> A;
    int H[N];
    double temp[N];
    double diff = 10000000;
    int ans;
    for(int i = 0; i < N; i++){
        cin >> H[i];
        temp[i] = T - H[i] * 0.006;
        double tempDiff= temp[i] - (double)A;
        if(abs(tempDiff) < diff){
            diff = abs(tempDiff);
            ans = i+1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256