akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
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)*}
    };
}

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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

fn main() {
    input! {
        s: chars,
    }
    let n = s.len();
    let mut pos = 0;
    let mut a = 0;
    let mut ans = 0usize; // NOTE: 64ビットにしないとWAになる！！！
    while pos < n {
        if s[pos] == 'A' {
            a += 1;
        } else if pos + 1 < n && s[pos] == 'B' && s[pos + 1] == 'C' {
            ans += a;
            pos += 1;
        } else {
            a = 0;
        }
        pos += 1;
    }
    println!("{}", ans);
}


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

int main() {
  string S;
  cin >> S;
  int l;
  l = S.size();
  if (l % 2 == 1) {
    int ans = 0;
    for (int i = 0; i < ((l-1)/2); i++) {
      if (S.at(i) != S.at(l-1-i)) {
        ans++;
      }
    }
    cout << ans << endl;
  }
  if (l % 2 == 0) {
    int ans = 0;
    for (int i = 0; i < l/2; i++) {
      if (S.at(i) != S.at(l-1-i)) {
        ans++;
      }
    }
    cout << ans << endl;
  }      
}


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

int main() {
    int N,X,m,t=1000;
    cin >> N >> X;

    rep(i,N) {
        cin >> m;
        t = min(t,m);
        X -= m;
    }

    cout << N+X/t << endl;
}

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


int main() {
	int n, m,i;
	int r, a = 0;
	cin >> n >> m;
	for (i = 0;i < m;i++) {
			cin >> r;
		a += r;
	}
	if (a > n)cout << "-1" << endl;
	else cout << n-a << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    if(s<t){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll a,b;
    cin>>a>>b;
    if(b>=a)
        cout<<"unsafe";
    else
        cout<<"safe";

    return 0;
}


Measured memory_bytes: 3600
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def gen(e, k):
    r = []
    if e[0]:
        r.append(e[0])
    if e[1]:
        r.append(e[1])
    if e[2]:
        if k:
            r.append("(" + e[2] + ")")
        else:
            r.append(e[2])
    if e[3]:
        r.append(e[3])
    return "".join(r)

def solve():
    s = readline().strip()
    if s == '#':
        return False
    vs = "aiueo"; cs = "kstnhmyrwgzdbp"
    t = []
    L = len(s)
    i = 0
    while i < L:
        c0 = s[i]
        if c0 in cs:
            cc = None
            if c0 == 'n':
                # 撥音
                if i == L-1:
                    t.append((None, "n", None, None))
                    i += 1
                    continue
                c1 = s[i+1]
                if c1 == "'":
                    t.append((None, "n'", None, None))
                    i += 2
                    continue
                if c1 in cs and c1 != 'y':
                    t.append((None, "n", None, None))
                    i += 1
                    continue
            c1 = s[i+1]
            if c1 in cs and c1 not in "nyw":
                # 促音
                cc = c0
                c0 = c1
                i += 1
                c1 = s[i+1]
            if c1 == 'y':
                c0 += c1
                i += 1
                c1 = s[i+1]
            assert c1 in vs, (cc, c0, c1)
            if i+1 < L-1:
                # 長音
                c2 = s[i+2]
                if c2 in "aiu":
                    i += 3
                    t.append((cc, c0, c1, c2))
                    continue
            t.append((cc, c0, c1, None))
            i += 2
        else:
            if i < L-1:
                # 長音
                c1 = s[i+1]
                if c1 in "aiu":
                    i += 2
                    t.append((None, None, c0, c1))
                    continue
            t.append((None, None, c0, None))
            i += 1
    ps = ["k", "s", "t", "h", "p", "ky", "sy", "ty", "hy", "py"]
    i = 0
    L = len(t)
    ans = []
    while i < L:
        a0, b0, c0, d0 = t0 = t[i]
        i += 1
        if b0 not in ps:
            ans.append(gen(t0, 0))
            continue
        if i == L:
            if b0 in ps and c0 in "iu" and d0 is None:
                ans.append(gen(t0, 1))
                continue
        else:
            a1, b1, c1, d1 = t1 = t[i]
            if b1 in ps:
                if c0 in "ao" and c0 == c1:
                    if d0 is None and a1 is None:
                        ans.append(gen(t0, 1))
                        ans.append(gen(t1, 0))
                        i += 1
                        continue
                if c0 in "iu" and d0 is None:
                    ans.append(gen(t0, 1))
                    ans.append(gen(t1, 0))
                    i += 1
                    continue
        ans.append(gen(t0, 0))
    write("".join(ans))
    write("\n")
    return True
while solve():
    ...


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    cout << 180 * (n - 2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  long long ret = 1;
  int crr(a[0]);
  int L(0), R(1);
  while (R < n) {
    if (R < n && !(crr & a[R])) {
      crr ^= a[R];
      R++;
      ret += (R - L);
    } else if (L < R - 1) {
      crr ^= a[L];
      L++;
    } else {
      crr = a[R];
      L++;
      R++;
      ret++;
    }
  }
  cout << ret << '\n';
  return 0;
}

Measured memory_bytes: 1024
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let xs: Vec<i64> = sc.vec(n);
    let mut ans = "APPROVED";
    for &x in xs.iter() {
        if x % 2 == 0 {
            if x % 3 == 0 || x % 5 == 0 {
                ;
            } else {
                ans = "DENIED";
            }
        }
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
/*まずうちさあ屋上あんだけど、焼いてかない？*/
	#include <bits/stdc++.h>
	using namespace std;
	#define IOS ios::sync_with_stdio(false), cin.tie(0)
	#define REP(i, n) for (int i = 0; i < n; i++)
	#define FOR(i, a, b) for (int i = a; i < b; i++)
	#define ALL(x) (x).begin(), (x).end()
	#define dump(x) cout << (x) << endl
	#define LMAX 9223372036854775807LL
	#define LMIN -9223372036854775807LL

	using ll = long long;
	template<typename T>
	using vec = vector<T>;
	using P = pair<ll, ll>;

	template <typename A, size_t N, typename T>
	void Fill(A (&array)[N], const T &val){
		fill((T *)array, (T *)(array + N), val);
	}
	
	ll pas[51][52];
	const ll INF = 1e18;
	const ll mod = 1e9 + 7;

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

	
	bool f[100][10];
	ll p[100][11];
	int main(){
		IOS;
		int n;
		string s;
		cin >> n >> s;
		int cnt = 0;
		int m = 0;	
		REP(i,n){
			if(s[i] == '(')cnt++;
			else cnt--;
			m = min(m,cnt);
		}
		REP(i,-m)s = "(" + s;
		REP(i,cnt - m)s = s + ")";
		dump(s);
	}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 500000
#define SENTINEL 1000000000
int  A[MAX];
int count = 0 ;

void Merge(int left, int mid, int right)
{
    int n1, n2;
    int i, j, k;
    n1 = mid - left;
    n2 = right - mid;
    int L[n1+1],  R[n2+1];
 
    for (i = 0; i < n1; i++){
    L[i] = A[left+i];
    }
   
    for (i = 0; i < n2; i++){
    R[i] = A[mid+i];
    }
    L[n1] = SENTINEL;
    R[n2] = SENTINEL;
    i = 0;
    j = 0;
    for(k = left; k < right; k++){
        count++;
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
        }
        else{ 
            A[k] = R[j];
            j++;
        }
    }
}

void Merge_Sort(int left, int right)
{
    int mid; 
    if(left+1 < right){ 
        mid = (left + right)/2;
        Merge_Sort(left, mid);
        Merge_Sort(mid, right);
        Merge(left, mid, right);
    }
}

 
int main(){
  int n;
  int i;
  int left, mid, right;
  
  scanf("%d", &n);
 
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
 
  left = 0;
  right = n;
  Merge_Sort(left, right);
  
 for(i = 0; i < n; i++){
   printf("%d", A[i]);
   if(i != n-1)printf(" ");
 }
 printf("\n%d\n", count);
 return 0;
}

Measured memory_bytes: 4504
#include <stdio.h>

int n;
int a[100010];
int count;
int max;

int main(void)
{
	scanf("%d", &n);
	
	for(int i = 0 ; i < n ; i++)
	{
		scanf("%d", &a[i]);
	}
	
	for(int i = 1 ; i < n ; i++)
	{	
		if(count > max)
			max = count;
		
		if(a[i] <= a[i - 1])
		{
			count++;
		}
		
		else
		{	
			count = 0;
		}
	}
	
	if(count > max)
		max = count;
	
	printf("%d", max);
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main()
{
	int n,countg=0,countk=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		if(i%2==0){countg++;}
		else if(i%2==1){countk++;}
	}
	int conv=countg*countk;
	printf("%d",conv);
	return 0;
	}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)


const int maxE = 100001;
int parent[maxE];
int parent_rank[maxE];


void init(int max_element) {
	for (int i = 0; i < max_element; i++) {
		parent[i] = i;
		parent_rank[i] = 0; 
	}
}

int find(int x) {
	if (x == parent[x]) return x;
	
	parent[x] = find(parent[x]);
	return parent[x];
}

bool same(int x, int y) {
	return find(x) == find(y);
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;

	if (parent_rank[x] > parent_rank[y]) {
		parent[y] = x;
		return;
	}
	parent[x] = y;
	if (parent_rank[x] == parent_rank[y]) {
		parent_rank[y]++;
	}
}


int main() {

	int n, m;

	cin >> n >> m;
	init(n + 1);


	rep(i, m) {
		int x, y, z;
		cin >> x >> y >> z;
		unite(x, y);
	}

	set<int> s;
	for(int i = 1; i <= n; i++) {
		s.insert(find(i));
	}
	cout << s.size() << endl;
	return 0;

}


Measured memory_bytes: 5760
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            //var A = NKM[0];
            //var B = NKM[1];

            var ans = -101;
            var min = long.MaxValue;

            for (int i = -100; i <= 100; i++)
            {
                var tmp = 0L;
                for (int j = 0; j < N; j++)
                {
                    tmp += (A[j] - i) * (A[j] - i);
                }

                if(tmp < min)
                {
                    ans = i;
                    min = tmp;
                }
            }


            Console.WriteLine(min);
        }


    }

}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  in6 n;
  cin >> n;
  vi data(n-1);
  rep(i,n-1) cin >> data[i];
  vi ans(n);
  ans[0] = data[0];
  repa(i,1,n-1) {
    ans[i] = min(data[i-1],data[i]);
  }
  ans[n-1] = data[n-2];
  in6 sum = 0;
  rep(i,n) sum += ans[i];
  cout << sum;
  hinata;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();

{
  ll n,c=0,b=0,gg=0;
  string s;
  cin>>s;
  n=s.length();
  for(int i=0;i<n-1;i++)
  {
    if(s[i]=='B'&&s[i+1]=='W')
    {
      if(b>0)
      { gg++;
        c+=b;
        c++;
        //b=gg;
      }
      else
      {
        gg++;
         c++;

      }
      s[i]='W';
      s[i+1]='B';

    }
    else if(s[i]=='B'&&s[i+1]=='B')
    {
      b++;
    }

  }

  cout<<c<<endl;

}
return 0;
}


Measured memory_bytes: 720
s = input()
def end():
    print("WA")
    exit()
if s[0] != 'A':
    end()
flag = False
for i in s[2:-1]:
    if i == 'C':
        if flag:
            end()
        flag = True
if not flag:
    end()

flag = False
for i in range(1,len(s)):
    if s[i].isupper():
        if flag:
            end()
        flag = True

print("AC")

Measured memory_bytes: 3064
def f_three_variables_game():
    N, A, B, C = list(map(int, input().split()))
    Selections = [input() for i in range(N)]

    count = {'A': A, 'B': B, 'C': C}
    ans = []
    for turn, string in enumerate(Selections):
        s0, s1 = string

        variable_up, variable_down = None, None
        # 変数の両方が 0。ゲーム続行不可能。
        if count[s0] == count[s1] == 0:
            return 'No'
        # 変数の片方が 0。そちらを増やすほかない。
        elif count[s0] == 0:
            variable_up, variable_down = s0, s1
        elif count[s1] == 0:
            variable_up, variable_down = s1, s0
        # 不適切な方法を取るとゲーム続行が不可能なので、さらに次の操作を先読みする。
        # (ただし、現時点が最後の操作なら、好きにしていい)
        elif turn + 1 == N:
            variable_up, variable_down = s0, s1
        # 次の操作に関わっている変数を増やす
        elif s0 in Selections[turn + 1]:
            variable_up, variable_down = s0, s1
        else:
            variable_up, variable_down = s1, s0

        count[variable_up] += 1
        count[variable_down] -= 1
        ans.append(variable_up)

    return ' '.join(['Yes'] + ans)

print(f_three_variables_game())

Measured memory_bytes: 17968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }

int main(){
    ll N, X;
    cin >> N >> X;
    vector<ll> m(N);
    REP(i, N) cin >> m[i];
    ll count = 0;
    DESC(m);
    REP(i, N-1) {
        X -= m[i];
        count++;
    }
    count += X/m[m.size()-1];
    cout << count << "\n";
}


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

int main(){
    long long int ans = 0;
    long long int a = 0;
    long long int b = 0;
    long long int c = 0;
    cin >> a;
    for(int i = 1; i <= a; i++){
        if(i % 3 != 0 && i % 5 != 0){
            ans += i;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  cout<<min(A,B)+min(C,D);
return 0;}

Measured memory_bytes: 3596
n, m = map(int, input().split())
a = list(map(lambda x: -int(x) , input().split()))
import math
import heapq
heapq.heapify(a) # リストを変換
for _ in range(m):
    ai = -heapq.heappop(a) # => 1
    heapq.heappush(a, -(ai//2))

print(-sum(a))

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <vector>

using namespace std;

const int MOD = 1e9 + 7; 

int num(char a) {
    return a - '0';
}

int main() {
    string k;
    int d, n;
    cin >> k >> d;
    n = k.length();

    vector <vector <vector <int> > > dp(n, vector <vector <int> > (d, vector <int> (2, 0)));

    dp[0][num(k[0]) % d][1] = 1;
    for (int i = num(k[0]) - 1; i >= 0; i--) {
            dp[0][i % d][0]++;
    }

    int rrem, critical_digit;
    for (int i = 0; i < n - 1; i++) {
        critical_digit = num(k[i + 1]);
        for (int rem = 0; rem < d; rem++) {
            for (int dig = 0; dig < 10; dig++) {
                rrem = (rem + dig) % d;
                dp[i + 1][rrem][0] = (dp[i + 1][rrem][0] + dp[i][rem][0]) % MOD;
                if (dig < critical_digit)
                    dp[i + 1][rrem][0] = (dp[i + 1][rrem][0] + dp[i][rem][1]) % MOD;
            }
            rrem = (rem + critical_digit) % d;
            dp[i + 1][rrem][1] = (dp[i + 1][rrem][1] + dp[i][rem][1]) % MOD;
        }
    }

    if (dp[n - 1][0][0] + dp[n - 1][0][1] == 0)
        cout << MOD - 1 << '\n';
    else
        cout << dp[n - 1][0][0] + dp[n - 1][0][1] - 1 << '\n';
    return 0;
}

Measured memory_bytes: 55296
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

const (
	maxBufsize = 1000000
)

func inputs(lines int) []string {
	var strSlice []string

	rdr := bufio.NewReaderSize(os.Stdin, maxBufsize)

	for i := 0; i < lines; i++ {

		line := ReadLine(rdr)
		strSlice = append(strSlice, line)

	}

	return strSlice
}

// ReadLine is to read long line
func ReadLine(rdr *bufio.Reader) string {
	buf := make([]byte, 0, maxBufsize)
	for {
		l, p, e := rdr.ReadLine()

		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}

	return string(buf)
}

func main() {
	lines := inputs(2)

	line0 := strings.Split(lines[0], " ")
	N, _ := strconv.Atoi(line0[0])

	line1 := strings.Split(lines[1], " ")

	sums := 0
	for _, v := range line1 {
		a, _ := strconv.Atoi(v)

		sums += a
	}

	if sums > N {
		fmt.Println("-1")
	} else {
		fmt.Println(N - sums)
	}
}


Measured memory_bytes: 2184
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll binpow (ll a, ll n) {
	ll res = 1;
	while (n)
        {
		if (n & 1) {
			res *= a;
                        res %= mod;
                        --n;
		}
		else {
			a *= a;
                        a %= mod;
			n >>= 1;
		}
        }
        return res;
}

ll x,y,n,m,a=1,b=1,c=1;
int main() {
        cin>>x>>y;
        n = (2*y-x)/3;
        m = (2*x-y)/3;
        if(n<0 || m<0 || (x+y)%3>0)
        {
                cout<<0;
                return 0;
        }
        for(ll i=1;i<=(n+m);i++)
                a*=i,a%=mod;

        for(ll i=1;i<=n;i++)
                b*=i,b%=mod;
                
        for(ll i=1;i<=m;i++)
                c*=i,c%=mod;
        ll ans = (a*binpow(b,1e9 + 5))%mod;
        ans *= binpow(c,1e9+5);
        ans %= mod;
        cout<<ans;
}

Measured memory_bytes: 256
def counter(num, c=0):
    if num % 2 != 0:
        return c
    c = counter(num/2, c+1)
    return c

N = int(input())
result = 1
max_num = 0
for i in range(2, N+1, 2):
    temp = counter(i)
    if max_num < temp:
        result = i
        max_num = temp
print(result)

Measured memory_bytes: 3060
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
ll L[52];
ll D[52];

ll calc(int n, ll x){
  if(x == 0)return 0;
  else if(n == 0)return 1;
  else if(x <= L[n-1] + 1)return calc(n-1, x-1);
  else if(x <= 2 + L[n] * 2)return D[n-1] + 1 + calc(n-1, x-2-L[n-1]);
  else return 2 * D[n-1] + 1;
}

int main(int argc, char const* argv[])
{
  int n;
  ll x;
  cin >> n >> x;
  L[0] = 1;
  D[0] = 1;
  rep(i, n){
    L[i+1] = 3 + 2 * L[i];
    D[i+1] = 1 + 2 * D[i];
  }
  cout << calc(n, x) << endl;
	return 0;
}


Measured memory_bytes: 256
// 

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

#define ll long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for (int i=(a);i>(b);i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define caset int ___T; cin >> ___T; while(___T--)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define get1(a) ll int a; cin>>a;
#define get2(a,b) ll int a,b; cin>>a>>b;
#define get3(a,b,c) ll int a,b,c; cin>>a>>b>>c;
#define gets(s) string s; cin >> s;

#define fast_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"

int main() {
	fast_IO;

	map <string, int> m;

	int n;
	cin >> n;

	string s;
	REP(i, n) {
		cin >> s;
		m[s]++;
	}

	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;

	cout << flush;
}



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

typedef long long ll;
#define MAXN 
const int mod = 1e9 + 7;
const int INF = 1e9 + 10;


int main()
{
    ll x, y;
    cin >> x >> y;
    int ans = 1;
    while (x * 2 <= y)
    {
        x <<= 1;
        ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n;
  cin >> n;
  ll a[n+1];
  for(int i=0;i<n+1;i++)cin >> a[i];
  ll b[n];
  for(int i=0;i<n;i++)cin >> b[i];

  ll c=0;
  for(int i=0;i<n;i++){
    if(a[i]>=b[i]){
      c+=b[i];
    }
    else if(b[i]<a[i]+a[i+1]){
      c+=b[i];
      a[i+1]=a[i+1]-(b[i]-a[i]);
    }
    else{
      c+=a[i]+a[i+1];
      a[i+1]=0;
    }
  }

  cout <<c << endl;

}

Measured memory_bytes: 5092
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

int main(){
  LL H;
  cin >> H;
  LL num=1;
  LL ans=0;
  while(H){
    H/=2;
    ans+=num;
    num*=2;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int[] a = new int[m];
		int cnt = 0;
		for (int i = 0; i < m; i++) {
			a[i] = sc.nextInt();
			if (a[i] < x) {
				cnt++;
			}
		}

		System.out.println((cnt < a.length - cnt) ? cnt : a.length - cnt);

	}
}


Measured memory_bytes: 22996
import sys

def count(n, b):
    res = 0
    while n:
        n, r = divmod(n, b)
        res += r
    return res

n = int(sys.stdin.readline().rstrip())

def main():
    res = float('inf')
    for i in range(n + 1):
        res = min(res, count(i, 6) + count(n - i, 9))
    print(res)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h[i];
  vector<int> dp(100010,mod);
  dp[0] = 0;
  for(int i = 0; i < n; i++){
    for(int j = 1; j <= k; j++){
      if(i+j <= n-1) dp[i+j] = min(dp[i+j],abs(h[i]-h[i+j])+dp[i]);
      else break;
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <iomanip>
#include <cstring>
#include <climits>
#include <cstdio>

#define nl '\n'

using namespace std;

int n, a, mn = 1000005, t;

int main(){

    vector<int> v;

    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> a;
        v.push_back(a);
    }

    for(int i = 0; i < 100; i++){
        t = 0;
        for(int j = 0; j < v.size(); j++){
            t += pow((v[j] - i), 2);
        }
        if(t < mn){
            mn = t;
        }
    }

    cout << mn;


    
}
 
//g++ -std=c++14 comp.cpp -o c && c.exe
//g++ -std=c++14 comp.cpp -o c; ./c.exe
//g++ -std=c++14 comp.cpp && ./a.out


//Surely this is going to AC

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int max_count=0;
    for (int i=0;i<s.size();i++) {
        for (int j=1;j<=s.size()-i;j++) {
            string tmp=s.substr(i,j);
            int count=0;
            for (int k=0;k<tmp.size();k++) {
                if (tmp.at(k)=='A'||tmp.at(k)=='C'||tmp.at(k)=='G'||tmp.at(k)=='T') {
                    count++;
                } else {
                    break;
                }
            }
            if (count>max_count) {
                max_count=count;
            }
        }
    }
    cout<<max_count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 26;

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

   ll n;
   cin >> n;
   string s;
   int keta = 0;
   while (n) {
      n--;
      s.resize(keta+1);
      s[keta] = 'a' + n % MOD;
      n /= MOD;
      keta++;
   }
   reverse(all(s));
   cout << s << endl;
   return 0;
}

Measured memory_bytes: 3648
H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]
output = []
for i in range(H-1):
    for j in range(W):
        if a[i][j] % 2 == 1:
            a[i+1][j] += 1
            output.append((i+1, j+1, i+2, j+1))

for i in range(W-1):
    if a[-1][i] % 2 == 1:
        a[-1][i+1] += 1
        output.append((H, i+1, H, i+2))
print(len(output))
for y, x, ay, ax in output:
    print(y, x, ay, ax)

Measured memory_bytes: 26676
#
# abc176 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5
2 1 5 4 3"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5
3 3 3 3 3"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """4
3 1 1 3"""
        output = """4"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    M = A[0]
    ans = 0
    for i in range(1, N):
        if A[i] < M:
            ans += M-A[i]
        else:
            M = A[i]
    print(ans)


if __name__ == "__main__":
    #unittest.main()
    resolve()


Measured memory_bytes: 40044
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
//constexpr auto MAX = 100000;

// ──────────────────────────────────────────────────────────────────


#define N 101

int dp[N + 1][N + 1], p[N + 1];

int main() {
    int n;

    cin >> n;
    for(int i = 1; i < n + 1; ++i) {
        cin >> p[i - 1] >> p[i];
    }

    for(int l = 2; l < n + 1; ++l) {
        for(int i = 1; i < n - l + 2; ++i) {// 対象とする行列の数
            int j = i + l - 1;
            dp[i][j] = (1 << 20); // dp[i][j] := [Mi, Mj]の最小回数
            for(int k = i; k < j; ++k) {
                //cout << l << " " << i << " " << j << " " << k << endl;
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }

    cout << dp[1][n] << endl;

    return 0;
}


Measured memory_bytes: 3116
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, P; string S;
ll dig[int(2e5 + 5)], DP[int(1e4 + 5)];

int Exception(){
  ll ans = 0;
  for (ll i = N - 1; i >= 0; i--){
    int now = S[i] - '0';
    if (now % P == 0) ans += i + 1;
  }
  cout << ans << endl;
  return 0;
}

int main(){
  cin >> N >> P >> S;
  if (P == 2 || P == 5){
    Exception(); return 0;
  }
  ll ten = 1;
  for (int i = N - 1; i >= 0; i--){
    dig[i] = (S[i] - '0') * ten % P;
    ten *= 10; ten %= P;
  }

  ll now = 0;
  for (int i = N; i >= 0; i--){
    now += dig[i]; now %= P;
    DP[now]++;
  }
  
  ll ans = 0;
  for (int i = 0; i < P; i++){
    ans += DP[i] * (DP[i] - 1) / 2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2180
#![allow(unused_imports)]

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")
    };
}

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};

fn main() {
    input! {
        n: usize,
        hs: [i32; n],
    }
    let mut hs = hs;
    hs[0] -= 1;
    for i in 0..hs.len() - 1 {
        if hs[i] < hs[i + 1] {
            hs[i + 1] -= 1;
        } else if hs[i] > hs[i + 1] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 6396
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	s = maximum(a)
	is = indmax(a)
	t = minimum(a)
	it = indmin(a)
	println(2*n-2)
	if s>-t
		for i in 1:n
			if i!=is
				a[i] += s
				println(is, " ", i)
			end
		end
		for i in 2:n
			println(i-1, " ",i)
		end
	else
		for i in 1:n
			if i!=it
				a[i] += t
				println(it, " ",i)
			end
		end
		for i in 1:n-1
			println(n-i+1, " ", n-i)
		end
	end
end

main()

Measured memory_bytes: 168744
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
int main(){
    int k,s;
    cin>>k>>s;
    int ans=0;
    for(int x=0;k>=x;++x){
        for(int y=0;k>=y;++y){
            int z=s-x-y;
            if(z>=0&&z<=k)
            ++ans;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
import collections


G_INF = 2 ** 31


class GraphError(Exception):
    pass


class GraphSearchError(GraphError):

    def __init__(self, reason):
        self.reason = reason

    def __str__(self):
        return str(reason)


class ShortestPathFasterAlgorithm(object):

    def __init__(self, number_of_vertices, adjacency_list, costs, start):
        self.max_v = number_of_vertices
        self.adj = adjacency_list
        self.costs = costs
        self.start = start
        self.dist = None
        self.visits = None

    def initialize(self):
        self.dist = collections.defaultdict(lambda: G_INF)
        self.dist[self.start] = 0
        self.visits = collections.defaultdict(int)

    def single_source_shortest_path(self):
        self.initialize()
        q = collections.deque()
        q.append(self.start)
        while q:
            u = q.popleft()
            self.visits[u] += 1
            if self.visits[u] >= self.max_v:
                if self.max_v == 1:
                    return [0]
                raise GraphSearchError("A negative cycle was detected.")
            for v in self.adj[u]:
                new_length = self.dist[u] + self.costs[(u, v)]
                if new_length < self.dist[v]:
                    self.dist[v] = new_length
                    if v not in q:
                        q.append(v)
        return self.dist


def main():
    max_v, max_e, start = map(int, input().split())
    adjacency_list = collections.defaultdict(lambda: array.array("L"))
    costs = collections.defaultdict(lambda: G_INF)
    for _ in range(max_e):
        s, t, d = map(int, input().split())
        adjacency_list[s].append(t)
        costs[(s, t)] = d
    spfa = ShortestPathFasterAlgorithm(max_v, adjacency_list, costs, start)
    try:
        dist = spfa.single_source_shortest_path()
        for v in range(max_v):
            result = dist[v]
            if result < G_INF:
                print(result)
            else:
                print("INF")
    except GraphSearchError as gse:
        print("NEGATIVE CYCLE")


if __name__ == '__main__':
    main()

Measured memory_bytes: 8728
route=[]
cost=[]
error=[]
best=[]
N,T=map(int,input().split())
for i in range(N):
    route.append([int(j) for j in input().split()])

for i in range(len(route)):
    if route[i][1]<=T:
        cost.append(route[i][0])
    if route[i][1]>T:
        error.append(route[i][1])
    

        
if len(error)==N:
    print("TLE")
else:
    print(min(cost))
            
    
    


    
    
    

    
	


Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

int n;
int *H;

int parent(int i){
    return i/2;
}

int right(int i){
    return i*2;
}

int left(int i){
    return i*2 + 1;
}

void maxheap(int i){
    int l = left(i);
    int r = right(i);
    int largest = i;
    //cout<<sizeof(*H)<<endl;
    if(l<=n && H[i] < H[l]){
        largest = l;
    }
    if(r<=n && H[largest] < H[r]){
        largest = r;
    }
    if(largest != i){
        int tmp;
        tmp = H[i];
        H[i] = H[largest];
        H[largest] = tmp;
        maxheap(largest);
    }
    /*for(int j=0;j<n;j++){
        if(j==n-1) printf("%d\n", H[j+1]);
        else printf("%d ", H[j+1]);
    }*/
}

void buildmh(){
    //cout<<sizeof(*H)/sizeof(int)-1<<endl;
    for(int i=0;i<n/2;i++){
        maxheap(n/2 - i);
    }
}

int main(){
    cin>>n;
    H = (int*)malloc(sizeof(int)*(n+1));
    for(int i =0;i<n;i++) cin>>H[i+1];
    buildmh();
    for(int j=0;j<n;j++){
        if(j==n-1) printf(" %d\n", H[j+1]);
        else printf(" %d", H[j+1]);
    }
    free(H);
}


Measured memory_bytes: 4540
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

int A[100000];

int main(void)
{
	int N;
	cin >> N;

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

	sort(A, A + N, std::greater<int>());

	long long S = 1;
	int cnt = 0;
	for (int i = 0; i < N - 1; ++i) {
		if (cnt == 2)	break;
		if (A[i] == A[i + 1]) {
			S *= A[i];
			++cnt;
			++i;
		}
	}

	if (cnt < 2) {
		cout << "0" << endl;
	} else {
		cout << S << endl;
	}

	return 0;
}

Measured memory_bytes: 640
#include <iostream>


int main() {

    char S[3];
    std::cin >> S;

    bool a = false;
    bool b = false;
    bool c = false;

    for (int i=0; i<3; i++) {
        if (S[i] == 'a') a = true;
        if (S[i] == 'b') b = true;
        if (S[i] == 'c') c = true;
    }

    if (a && b && c) std::cout << "Yes" << std::endl;
    else             std::cout << "No" << std::endl;

    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[10005];
long long b[10005];
int main ()
{
  int n;
  cin>>n;
  int sum = 0 ;
  for(int i =1;i<=n;i++)
  {
    cin>>a[i];
    while(a[i] %2 == 0)
    {
      a[i]/=2;
      sum++;
    }
  }
  cout<<sum<<endl;
  return 0 ;
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    val s= readLine()!!
    val t= readLine()!!

    val x=(0 .. s.length-t.length).lastOrNull { i ->
        t.indices.all { t[it]==s[i+it] || s[i+it]=='?'}
    }
    if(x==null) {
        println("UNRESTORABLE")
    } else {
        println(
            (s.take(x) + t + s.drop(x + t.length)).replace('?','a')
        )
    }

}

Measured memory_bytes: 33732
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val s = List.fill(n)(sc.next())
  val m = sc.nextInt()
  val t = List.fill(m)(sc.next())
  val tg = t.groupBy(identity).view.mapValues(_.length).toMap.withDefaultValue(0)
  val ans = s.groupBy(identity).map{
    case (x, p) => p.length - tg(x)
  }.max.max(0)
  println(ans)
}


Measured memory_bytes: 55796
#include<bits/stdc++.h>
//#define int long long
using namespace std;

signed main() {
	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	for (int i = 0; i < n; ++i)cin >> s[i];
	sort(s.begin(), s.end());
	string ans;
	for (auto t : s)ans += t;
	cout << ans << endl;
}

Measured memory_bytes: 256
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input()) - 1
print(A[k])

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    int n;
    cin >> n;
    int i = n;
    while (i % 111 != 0)
        i++;
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
int main() {
	std::string odd, even;

	std::cin >> odd;
	std::cin >> even;
	const char* codd = odd.c_str();
	const char* ceven = even.c_str();

	std::string res;

	for (int i=0;i<odd.size();++i) {
		if (ceven[i] == NULL) {
			res += codd[i];
		}
		else {
			res += codd[i];
			res += ceven[i];
		}
	}

	std::cout << res;
}

Measured memory_bytes: 256