akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/12/2018
 
 16:00-
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
//const int MAX_N=1e5+1;
string S;
int K;
void solve() {
  int N=SZ(S);
  VI X;
  REP(i,N) {
    int a=S[i]-'a';
    int needs=(26-a)%26;
    if(needs<=K) S[i]='a',K-=needs;
    else X.push_back(i);
  }
  if(SZ(X)==0) {
    int a=S[N-1]-'a';
    S[N-1]=('a'+(a+K)%26);
  } else {
    int i=X.back();
    int a=S[i]-'a';
    assert(a+K<26);
    S[i]=('a'+a+K);
  }
  cout<<S<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>S>>K;
  solve();
  return 0;
}


Measured memory_bytes: 1020
C = [[int(_) for _ in input().split()] for _ in range(3)]

B = C[0]
A = (0, C[1][1] - B[1], C[2][2] - B[2])

for i in range(3):
    for j in range(3):
        v = A[i] + B[j]
        if not v == C[i][j]:
            print("No")
            exit(0)
print("Yes")


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<tuple<string, int, int>> vec(n);
    for (int i = 0; i < n; i++) {
        string s;
        int p;
        cin >> s >> p;
        vec.at(i) = make_tuple(s, -p, i+1);
    }

    sort(vec.begin(), vec.end());

    for (int i = 0; i < n; i++) {
        cout << get<2>(vec.at(i)) << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<cmath>
#include<cstring>
#include<map>
#include<algorithm>
#include<vector>
#include<ios>
#include<sstream>
#include<locale>
using namespace std;
#define ive(cris) int long long 
#define in(out) long double
#define INF 100000007
int main(){
  int a,b;
  cin>>a>>b;
  if(a+b>=10){
    cout<<"error"<<'\n';
  }
  else{
    cout<<a+b<<'\n';
  }
  return 0;
}


Measured memory_bytes: 256
(defun f (x)
  (concatenate 'list (symbol-name x)))

(let ((a (f (read)))
      (b (f (read)))
      (c (f (read))))

  (format t "~A~%"
          (if (and (char= (car (reverse a)) (car b))
                   (char= (car (reverse b)) (car c)))
            'yes
            'no)))


Measured memory_bytes: 11232
s=gets.chomp.split("").map(&:to_s)
t=gets.chomp.split("").map(&:to_s)
s.sort!
t.sort!
t=t.reverse
s_sort=s.join("")
t_sort=t.join("")
#p s_sort
#p t_sort

if s_sort<t_sort
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 14240
N = int(input())
value_list = input().split()
new_value_list = []
for v in value_list:
	v = float(v)
	new_value_list.append(v)
new_value_list.sort()
#value_list.reverse()
#print(new_value_list)
for i in range(N):
	if i == 0:
		new_value = new_value_list[i]
	else:
		new_value = (new_value + new_value_list[i]) / 2
	
	#print(new_value)

print(new_value)

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    string s; cin >> s;
    if(s.size()==2){
        if(s[0] == s[1]) cout << "1 2" << endl;
        else cout << "-1 -1" << endl;
        return 0;
    }
    REP(i,s.size()-2){
        if(s[i] == s[i+1]){
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }else if(s[i] == s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}

Measured memory_bytes: 3756
import sys
from heapq import heapify, heappop, heappush
import bisect

N, M = map(int, input().split())
AB = sorted([list(map(int, sys.stdin.readline().split())) for _ in range(N)])
A = [x for x, y in AB]

hq = []
heapify(hq)

count = 0

for i in range(1, M + 1):
    c_1 = bisect.bisect_left(A, i)
    c_2 = bisect.bisect_right(A, i)
    if c_2 - c_1 != 0:
        for j in range(c_1, c_2):
            heappush(hq, -AB[j][1])
    
    if hq:
        count += -heappop(hq)
    
print(count)

Measured memory_bytes: 32704
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define ll long long
const int MOD = 1000000007;

int main()
{
    int n = 0,i = 0,j = 0,jilu = 1;
    int a[9], b[11] = { 0 };
    for(i = 0; i < 9; i++)
    scanf("%d", &a[i]);
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &b[i]);
            for (j = 0; j < 9; j++)
            {
                if (b[i] == a[j])
                {
                    a[j] = 0;
                }
            }
    }
    for (i = 0; i <= 6; i += 3)
    {
        if (a[i] == 0 && a[i + 1] == 0 && a[i + 2] == 0)
        {
            jilu = 0;
            break;
        }
    }
    for (i = 0; i <= 2; i++)
    {
        if (a[i] == 0 && a[i + 3] == 0 && a[i + 6] == 0)
        {
            jilu = 0;
            break;
        }
    }
    if (a[0] == 0 && a[4] == 0 && a[8] == 0 ||
        a[2] == 0 && a[4] == 0 && a[6] == 0)
        jilu = 0;
    if (jilu)
    {
        printf("No\n");
    }
    else
        printf("Yes");
    return 0;
}


Measured memory_bytes: 128
n = int(input())
arr = list(map(int, input().split()))
s = sum(arr)
m = {}
for e in arr:
    m[e] = m.get(e, 0)+1
for _ in range(int(input())):
    a, b = map(int, input().split())
    if a not in m:
        print(s)
        continue
    s += (b-a) * m[a]
    if b not in m:
        m[b] = 0
    m[b] += m[a]
    m[a] = 0
    print(s)


Measured memory_bytes: 84756
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

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

/* see https://github.com/pllk/cphb/
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
    tree_order_statistics_node_update> indexed_set;
typedef __int128 lll;
 **/

typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    int a, b;
    cin>>a>>b;

    int d=abs(a-b);
    if(d&1) {
        cout<<"IMPOSSIBLE"<<endl;
    } else {
        cout<<max(a, b)-(d/2)<<endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,M;
    cin>>N>>M;
    
    if(N%2==1){
        for(ll i=1;i<=M;i++){
            printf("%lld %lld\n",i,N+1-i);
        }
    }else{
        for(ll i=1;i<=M;i++){
            if(N+1-2*i>2*i-1){
                printf("%lld %lld\n",i,N+1-i);
            }else{
                printf("%lld %lld\n",i,N-i);
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

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

//----------------------------------------------------------------

int main()
{
    ll n, m;
    cin >> n >> m;
    ll nsum = 1, msum = 1;
    if (n - m == 0)
    {
        for (int i = 1; i <= n; i++)
        {
            nsum = (nsum * i) % mod;
        }
        for (int i = 1; i <= m; i++)
        {
            msum = (msum * i) % mod;
        }
        cout << (nsum * msum * 2) % mod << endl;
    }
    else if (abs(n - m) == 1)
    {
        for (int i = 1; i <= n; i++)
        {
            nsum = (nsum * i) % mod;
        }
        for (int i = 1; i <= m; i++)
        {
            msum = (msum * i) % mod;
        }
        cout << (nsum * msum) % mod << endl;
    }
    else
    {
        cout << "0" << endl;
    }
}


Measured memory_bytes: 256
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7
import itertools

def ddprint(x):
  if DBG:
    print(x)

n,c = inm()
d = []
e = []
for i in range(c):
    d.append(inl())
for i in range(n):
    cc = inl()
    cc2 = [x-1 for x in cc]
    e.append(cc2)

s = [ [0]*c for i in range(3) ]
for i in range(n):
    for j in range(n):
        s[(i+j)%3][e[i][j]] += 1
mn = BIG
pm = itertools.permutations(list(range(c)), 3)
for p in pm:
    sm = 0
    for i in range(3):
        for j in range(c):
            sm += s[i][j]*d[j][p[i]]
    mn = min(mn,sm)
print(mn)


Measured memory_bytes: 44764
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll    long long
#define PR    pair<ll, ll>

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    int n, k;
    cin >> n >> k;
    map<int, int> cnt;
    for (int i = 0; i < k; i++) {
        int x;
        cin >> x;
        for (int j = 0; j < x; j++) {
            int y;
            cin >> y;
            cnt[y]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (cnt[i] == 0) {
            ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3608
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::{vec, cmp, num};


struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

// create Vec<char> from String
#[allow(dead_code)]
fn to_chars(s: String) -> vec::Vec<char> {
    let mut cs = s.chars();
    let mut res = vec::Vec::new();
    while let Some(c) = cs.next() {
        res.push(c);
    }
    res
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n: i32 = sc.read();
    println!("{}", n * (n + 1) / 2);
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

typedef long long ll;

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

    int result = 0;
    for (int i = 0; i <= A; ++i)
    {
        for (int j = 0; j <= B; ++j)
        {
            for (int k = 0; k <= C; ++k)
            {
                if (500 * i + 100 * j + 50 * k == X) ++result;
            }
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
li = na()
mst = li[0]
flag = "Yes"
for i in range(n):
    if li[i] >= mst:
        mst = li[i]
    elif li[i] != mst - 1:
        flag = "No"
        break
print(flag)


Measured memory_bytes: 59632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<vector<int>>;
using Graph = vector<vector<int>>;

const int INF = 1 << 30;
const ll INFL = 1LL << 60;
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; }

int N;

double dp[3000][3000] = {0.0}; //---- dp[i][j]: 最初のi枚を投げたとき、表がj枚出る確率
double p[3000];

int main(){
    cin >> N;
    rep(i,N){
        cin >> p[i+1];
    }
    dp[0][0] = 1;
    for(int i = 1; i <= N; ++i){
        for(int j = 0; j <= i; ++j){
            dp[i][j] = dp[i-1][j] * (1 - p[i]);
            if(j >= 1) dp[i][j] += dp[i-1][j-1] * p[i]; 
        }
    }
    double ans = 0.0;
    for(int i = (N+1)/2; i <= N; ++i){
        ans += dp[N][i];
    }
    cout << fixed << setprecision(10) << ans;
}

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

int main() {
	long long L, R;
	cin >> L >> R;
	R = min(R, L + 4038);
	int ans = 2018;
	for (long long i = L;i < R;++i) {
		for (long long j = i + 1;j <= R;++j) {
			int x = i * j % 2019;
			ans = min(ans,x);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - On the Way
https://atcoder.jp/contests/tenka1-2019-beginner/tasks/tenka1_2019_a

"""
import sys


def solve(A, B, C):
    if A < C < B:
        return 'Yes'
    elif A > C > B:
        return 'Yes'
    return 'No'


def main(args):
    A, B, C = map(int, input().split())
    ans = solve(A, B, C)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 38384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = sc.next() + sc.next() + sc.next();
        int num = Integer.parseInt(str);
        if (num % 4 == 0){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 21844
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
   let (n, m): (usize, usize);
   input!(n, m);
   let mut a = input_vector::<usize>();
   a.sort();
   a.reverse();
   let sum = a.iter().sum::<usize>();

   for i in 0..m {
      if a[i] * 4 * m < sum {
         println!("No");
         return;
      }
   }
   println!("Yes");
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
using namespace std;
int n, a[100010];
long long ans;
int main () {
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf ("%d", &a[i]);
		if (a[i] & 1) ans += a[i] / 2, a[i] = 1;
		else if (a[i]) ans += a[i] / 2 - 1, a[i] = 2;
	}
	for (int i = 1; i <= n; i++) if (a[i]) {
		if (a[i] == 2) ans++;
		else if (a[i] == 1 && a[i + 1]) ans++, a[i + 1]--;
	}
	printf ("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 640
import math
A, B , H , M = map(int, input().split())

d = 5.5 * (60*H+M)
distan = d - 360 * (d // 360)

if distan>180:
    distan=360-distan

cosC = math.cos(math.radians(distan))

Cpow2 = pow(A,2)+pow(B,2)- 2* A * B * cosC

print(Cpow2**(0.5))

Measured memory_bytes: 9512
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x;
    cin >> x;
    
    if (x == 7 || x == 5 || x == 3) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
typedef long long int ll;
int main(){
    int N;
    string S;
    cin>>N>>S;
    int count=0;
    rep(i,N-2){
        if(S.at(i)=='A'&&S.at(i+1)=='B'&&S.at(i+2)=='C'){
            count++;
        }
    }
    cout<<count<<endl;
    
    return 0;
}

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

int main() {
  string s;
  long long k, ans;
  int a = 0, fsup = 0, top = 0, btm = 0;
  bool flag = 1;
  cin >> s >> k;
  for(int i = 0; i < s.size(); i++) if(s.at(0) == s.at(i)) fsup++;
  if(fsup == s.size()) flag = 0;
  if(s.at(0) == s.at(s.size() - 1) && flag) {
    while(s.at(0) == s.at(top)) top++;
    while(s.at(s.size() - 1) == s.at(s.size() - 1 - btm)) btm++;
  }
  for(int i = top; i < s.size() - 1 - btm; i++){
    if(s.at(i) == s.at(i + 1)) {
      s.at(i + 1) = '#';
      a++;
    }
  }
  if(s.size() == fsup) ans = k * s.size() / 2;
  else ans = k * a + top / 2 + btm / 2 + (top + btm) / 2 * (k - 1);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int r;
  get(r);
  print(3 * r * r);
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
c = 0
S = [0 for i in range(N)]

for i in range(N):
    if A[i] < c :
        S[i] = c - A[i]
    elif A[i] > c :
        c = A[i]
  
ans = sum(S)

print(ans)


Measured memory_bytes: 32380
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	int n,m;
	while(cin>>n>>m,n+m){
		vi a(n),b(m);
		rep(i,n)cin>>a[i];
		rep(i,m)cin>>b[i];
		int ma=-1;
		map<int,int>ina,inb;
		rep(i,n){
			int sum=0;
			loop(j,i,n){sum+=a[j];ina[sum]++;}
			ma=max(ma,sum);
		}
		rep(i,m){
			int sum=0;
			loop(j,i,m){sum+=b[j];inb[sum]++;}
			ma=max(ma,sum);
		}
		int co=0;
		loop(i,1,ma+1){co+=ina[i]*inb[i];}
		cout<<co<<endl;
	}
}

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

using namespace std;

#define fi first
#define se second

int main()
{
    int n, d, k=0;
    cin >> n >> d;
    long double K[n][d], D, s;
    int Ki[n][d], Di;
    for (int i = 0; i < n; i++)
    {
        for (int y = 0; y < d; y++)
        {
            cin >> K[i][y];
            Ki[i][y] = K[i][y];
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int y = 0; y < i; y++)
        {
            s = 0;
            for (int u = 0; u < d; u++)
            {
                s += (K[i][u] - K[y][u]) * (K[i][u] - K[y][u]);
            }
            D = sqrt(s);
            Di = sqrt(s);
            if (D == Di)
            {
                k++;
            }
        }
    }
    cout << k;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int N, C[ 50 ], V[ 50 ], i, sum;

  scanf ( "%d", &N );
  for ( i = 0 ; i < N ; i++ )
    scanf ( "%d", &V[ i ] );
  for ( i = 0 ; i < N ; i++ )
    scanf ( "%d", &C[ i ] );
  
  sum = 0;
  for ( i = 0 ; i < N ; i++ )
    {
      if ( V[ i ] > C[ i ] )
	sum += V[ i ] - C[ i ];
    }
  printf ( "%d\n", sum );
  return 0;
}


Measured memory_bytes: 128
// At Corder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
#include <vector>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using p = pair<int, int>;//<key,value>

int main()
{
	char s[10];
	cin >> s;
	int ans = 0;
	rep(i,6)
	{
		if (s[i] == '1')
			ans++;
	}
	cout << ans << endl;

	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

int main() {
  int n, k; cin >> n >> k;
  vector<int> p(n);
  for (auto& e : p) cin >> e;
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i = 0; i < k; i++) ans += p.at(i);
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
using namespace std;

//long long S[200000];
//long long T[200000];
//long long X[200000];

pair <long long, pair <long long, long long> > xst[200000];
long long D[200000];

int sqrtN = 512;
struct SqrtDecomposition{
    int N, K;
    vector <long long> data;
    vector <long long> bucketUpdatedLazy;
     
    SqrtDecomposition(int n){
        N = n;
        K = (N + sqrtN - 1) / sqrtN;
        data.assign(N, -1);
        bucketUpdatedLazy.assign(K, -1);
    }
 
    void propagateLazy(int k){
        if(bucketUpdatedLazy[k] < 0){
            return;
        }
        for(int i = 0; i < sqrtN; i++){
            data[k * sqrtN + i] = bucketUpdatedLazy[k];
        }
        bucketUpdatedLazy[k] = -1;
    }

    long long get(int x){
        propagateLazy(x / sqrtN);
        return data[x];
    }
 
    void update(int x, int y, int a){
        if(y - x < sqrtN){
            for(int i = x; i < y; i++){
                propagateLazy(x / sqrtN);
                propagateLazy((y - 1) / sqrtN);
                data[i] = a;
            }
            return;
        }
        for(int i = x / sqrtN + 1; i < y / sqrtN; i++){
            bucketUpdatedLazy[i] = a;
            //if(bucketUpdatedLazy[i] < 0 && bucketUpdatedLazy[i] != -1){
            //    cerr << "Warning" << endl;
            //}
        }
 
        for(int i = x; i < (x / sqrtN + 1) * sqrtN; i++){
            propagateLazy(x / sqrtN);
            data[i] = a;
        }
        for(int i = y / sqrtN * sqrtN; i < y; i++){
            propagateLazy((y - 1)/ sqrtN);
            data[i] = a;
        }
    }
     
};

int main(){
    int N;
    int Q;
    cin >> N >> Q;
    for(int i = 0; i < N; i++){
        long long S;
        long long T;
        long long X;
        cin >> S >> T >> X;
        xst[i] = make_pair(X, make_pair(S, T));
    }
    for(int i = 0; i < Q; i++){
        cin >> D[i];
    }
    
    sort(xst, xst + N);
    SqrtDecomposition sq(Q);
    for(int i = N - 1; i >= 0; i--){
        auto it_left = lower_bound(D, D + Q, xst[i].second.first - xst[i].first);
        auto it_right = lower_bound(D, D + Q, xst[i].second.second - xst[i].first);
        //cout << it_left - D << " " << it_right - D << endl;
        sq.update(it_left - D, it_right - D, xst[i].first);
    }
    for(int i = 0; i < Q; i++){
        cout << sq.get(i) << endl;
    }

    return 0;
}


Measured memory_bytes: 9728
C = input()

a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

for i in range(len(a)):
  if a[i] == C:
    print(a[i+1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int(a.size())

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int cnt[70],len;
string c;

int query(string s) {
	cout<<"? "<<s<<endl;
	int x;cin>>x;return x;
}

string solve(int l,int r) {
	if(l==r) {
		string ret;
		for(int i=0;i<cnt[l];i++) ret+=c[l];
		return ret;
	}
	int mid=(l+r)>>1;
	string ls=solve(l,mid),rs=solve(mid+1,r);
	int p1=0,p2=0;
	string ret;
	while(p1<sz(ls)&&p2<sz(rs)) {
		string s=ret+ls[p1]+string(rs.begin()+p2,rs.end());
		if(query(s)==len-sz(s)) ret+=ls[p1++];
		else ret+=rs[p2++];
	}
	while(p1<sz(ls)) ret+=ls[p1++];
	while(p2<sz(rs)) ret+=rs[p2++];
	return ret;
}

int main() {
	for(char i='a';i<='z';i++) c+=i;
	for(char i='A';i<='Z';i++) c+=i;
	for(char i='0';i<='9';i++) c+=i;
	for(int i=0;i<62;i++) {
		string s;
		for(int j=0;j<128;j++) s+=c[i];
		cnt[i]=128-query(s);
		len+=cnt[i];
	}
  	string ans=solve(0,61);
	cout<<"! "<<ans<<endl;
	return 0;
}


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

int main() {
	int L, R;
  	int A, B, C, D;

  	cin >> A >>  B >> C >> D;

  	L = A + B;
  	R = C + D;

  	if (L > R) {
      cout << "Left" << endl;
    } else if (R > L) {
      cout << "Right" << endl;
    } else {
      cout << "Balanced" << endl;
    }
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int s,w; cin >> s >> w;
    cout << (s<=w?"unsafe":"safe") << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#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 ALL(a) (a).begin(), (a).end()

int main() {
    string S;
    int K;
    cin >> S >> K;
    char ans = '1';
    int len = min(K, (int)S.length());
    REP(i, len) {
        if (S[i] != '1') {
            ans = S[i];
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import permutations

N, C = map(int, input().split())

D = []
for _ in range(C):
  Ds = list(map(int, input().split()))
  D.append(Ds)

grid = []
for _ in range(N):
  c = list(map(lambda x: int(x)-1, input().split()))
  grid.append(c)

color = [[0]*C for _ in range(3)]

for i in range(N):
  for j in range(N):
    color[(i+j)%3][grid[i][j]] += 1

INF = 10**9
ans = INF

for cols in permutations(range(C), 3):
  temp = 0
  for i, Y in enumerate(cols):
    for X, cnt in enumerate(color[i]):
      temp += D[X][Y] * cnt
  ans = min(ans, temp)

print(ans)

Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ull unsigned long long
#define mp make_pair
#define F first
#define S second
#define mod 1000000007

int H,W;
ll dp[1002][1002];
char a[1002][1002];

int main()
{
    cin >> H >> W;
    for(int i=1;i<=H;i++)
        for(int j=1;j<=W;j++)
            cin >> a[i][j];
    
    dp[1][0] = 1;
    for(int i=1;i<=H;i++)
    {
        for(int j=1;j<=W;j++)
        {
            if(a[i][j] == '.')
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
            else
                dp[i][j] = 0;
        }
    }

    cout << dp[H][W] << endl;



    
}


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

int main() {
    int N;
    cin>>N;
    vector<vector<int>> SA(N, vector<int>(26, 0));
    REP(i, 0, N){
        string s;
        cin>>s;
        REP(j, 0, 10){
            SA[i][s[j]-'a']++;
        }
    }
    sort(SA.begin(), SA.end());
    /*
    REP(i,0,N) {
        REP(j, 0, 26) cout << SA[i][j] << " ";
        cout << endl;
    }
    */
    long count=0, ans = 0;
    REP(i, 0, N-1){
        if(SA[i] != SA[i+1]){
            ans += count*(count+1)/2;
            count = 0;
        }
        else count++;
    }
    ans += count*(count+1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 13568
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iterator>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) // cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

vector<int> rec(int A, int B, int n) {
    if(A <= 1 && B <= 1 && n == 0){
        return vector<int>{A, B};
    }

    int i = -1;
    for(int j=0;j<17;++j) {
        if((A & (1<<j)) != (B & (1<<j))) {
            i = j;
            break;
        }
    }

    int Aprime = (((A & (((1 << (17-(i+1))) - 1) << (i+1))) >> 1) ^ (A & ((1 << i)-1)));
    int C = Aprime^1;
    int Bprime = (((B & (((1 << (17-(i+1))) - 1) << (i+1))) >> 1) ^ (B & ((1 << i)-1)));
    // cerr << A << " " << B << " -> " << Aprime << " " << C << " " << Bprime << endl;
    
    vector<int> ans1 = rec(Aprime, C, n-1);
    vector<int> ans2 = rec(C, Bprime, n-1);
    vector<int> ans;
    copy(ans1.begin(), ans1.end(), back_inserter(ans) );
    copy(ans2.begin(), ans2.end(), back_inserter(ans) );
    int m = ans.size();

    // cerr << A << " " << i << " " << endl;
    for(int j=0;j<m;++j) {
        if(j < m/2) {
            ans[j] = (((ans[j] & (((1 << 17)-1) ^ (1 << i) - 1)) << 1) ^ (ans[j] & ((1 << i) - 1))) ^ (A & (1 << i));
        } else {
            ans[j] = (((ans[j] & (((1 << 17)-1) ^ (1 << i) - 1)) << 1) ^ (ans[j] & ((1 << i) - 1))) ^ (B & (1 << i));
        }
        // cerr << ans[j] << " ";
    }
    // cerr << endl;
    return ans;
}

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n, A, B;
    cin >> n >> A >> B;

    set<int> diff_bits;
    for(int i=0;i<17;++i) {
        if((A & (1<<i)) != (B & (1<<i))) {
            diff_bits.insert(i);
        }
    }

    if(diff_bits.size() % 2 == 0) {
        cout << "NO\n";
        return 0;
    }
    cout << "YES\n";

    vector<int> ans = rec(A, B, n-1);
    for(int x: ans) {
        cout << x << " ";
    }

    return 0;
}


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

#define rep(i,n) for(int i = 0;i<n;i++)
#define cint(a) int a; cin >> a;
#define cstr(str) string str; cin >> str;


using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	int x, y, z;

	int n; cin >> n;
	int ans,cnt = 0;
	for (int i = 1; i <= n; i++) {
		x = 1;
		while (true) {
			if (x * x > i) break;
			y = 1;
			while (y <= x) {
				z = 1;
				while (z <= y) {
					ans = x * x + y * y + z * z + x * y + y * z + z * x;
					if (ans == i) {
						if (x != y && y != z && z != x) cnt += 6;
						else if (x == y && y == z && z == x) cnt += 1;
						else cnt += 3;
					}
						z++;
				}
				y++;
			}
			x++;
		}

		cout << cnt << endl;
		cnt = 0;
		
	}
	return 0;
}

Measured memory_bytes: 3604
N = int(input())
monster = list(map(int, input().split()))
hero = list(map(int, input().split()))

total = 0
i = -1

for i in range(N + 1):
    if i == 0:
        if monster[0] < hero[0]:
            total += monster[0]
            hero[0] -= monster[0]
            monster[0] = 0
        else:
            total += hero[0]
            monster[0] -= hero[0]
            hero[0] = 0
            
    elif i < N:
        if monster[i] < hero[i - 1]:
            total += monster[i]
            hero[i - 1] -= monster[i]
            monster[i] = 0
        else:
            total += hero[i - 1]
            monster[i] -= hero[i - 1]
            hero[i - 1] = 0
            
            if monster[i] < hero[i]:
                total += monster[i]
                hero[i] -= monster[i]
                monster[i] = 0
            else:
                total += hero[i]
                hero[i] = 0
                monster[i] -= hero[i]
    else:
        if monster[N] < hero[N - 1]:
            total += monster[N]
        else:
            total += hero[N - 1]

print(total)


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

using namespace std;
using pii = pair <int, int>;

const int mx = 1e5 + 9;

int clr[mx];
vector <pii> adj[mx];

void color(int u, int par = -1) {
    for (auto v : adj[u]) {
        if (v.first == par) continue;
        clr[v.first] = clr[u];
        if (v.second & 1) clr[v.first] = 1 - clr[v.first];
        color(v.first, u);
    }
}

int main() {
    int n; scanf("%d", &n);
    for (int i = 1; i < n; i++) {
        int u, v, w; scanf("%d %d %d", &u, &v, &w);
        adj[u].emplace_back(v, w);
        adj[v].emplace_back(u, w);
    }

    clr[1] = 0;
    color(1);

    for (int i = 1; i <= n; i++) {
        printf("%d\n", clr[i]);
    }
}

Measured memory_bytes: 12424
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};



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

  int n;
  cin >> n;
  int t = 1;
  while(true) {
    if(t > n) {
      cout << t / 2 << endl;
      break;
    }
    t *= 2;
  }
  return 0;
}



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

using namespace std;

int d, n, b;
double x[16], y[16];

bool ok(double v, double wid, int dnum)
{
    double vx, vy;
    
    double b = sqrt(v * v + wid), c = wid / 2;
    
    if (b * b - 4 * c < 0) return (false);
    
    vx = (b + sqrt(b * b - 4 * c)) / 2, vy = (b - sqrt(b * b - 4 * c)) / 2;
    
    double myx[16], myy[16];
    bool ok = true;
    
    for (int i = 0; i < n; i++){
        myx[i] = x[i];
        myy[i] = y[i];
    }
    for (int i = 0; i < dnum; i++){
        for (int j = 0; j < n; j++){
            if (0 <= myx[j] && myx[j] <= wid){
                if (-(1.0 / (2 * vx * vx)) * myx[j] * myx[j] + vy / vx * myx[j] < myy[j]) ok = false;
            }
            myx[j] -= wid;
        }
    }
    if (ok) return (true);
    
    swap(vx, vy);
    
    for (int i = 0; i < n; i++){
        myx[i] = x[i];
        myy[i] = y[i];
    }
    for (int i = 0; i < dnum; i++){
        for (int j = 0; j < n; j++){
            if (0 <= myx[j] && myx[j] <= wid){
                if (-(1.0 / (2 * vx * vx)) * myx[j] * myx[j] + vy / vx * myx[j] < myy[j]) return (false);
            }
            myx[j] -= wid;
        }
    }
    
    return (true);
}

int main()
{
    scanf("%d %d %d", &d, &n, &b);
    
    for (int i = 0; i < n; i++){
        scanf("%lf %lf", x + i, y + i);
    }
    
    double ans = 1e30;
    for (int i = 0; i <= b; i++){
        double l = 1e-10, r = 1e5, mid;
        double width = d * 1.0 / (i + 1);
        for (int j = 0; j <= 1000; j++){
            mid = (l + r) / 2;
            if (ok(mid, width, i + 1)){
                r = mid;
            }
            else l = mid;
        }
        ans = min(ans, mid);
    }
    
    printf("%.10f\n", ans);
    
    return (0);
}

Measured memory_bytes: 1244
(def N (read))
(def A (read))
(def B (read))

(println (if (= (mod (- B A) 2) 0) 
  (quot (- B A) 2)
  (min (+ A (quot (- B A 1) 2)) 
    (+ (- N B) 1  (quot (- N (+ A (- N B))) 2)))))

Measured memory_bytes: 84500
n,y=map(int,input().split())

flag=0
total = 0

for i in range(n+1):
    for j in range(n+1):
        k=n-i-j
        if k<0:
            break

        total=10000*i+5000*j+1000*k
        if total==y:
            print(i,j,k)
            flag=1
            break 
    if flag == 1:
        break
if flag == 0:
    print('-1 -1 -1')

Measured memory_bytes: 9192
#include <iostream>
#include <iomanip>
#include <cmath>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <fstream>
#include <list>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <ctime>
#include<numeric>


using namespace std;
#define vec vector
#define pb push_back
#define en '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<ll, ll> pull;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef long double ld;
typedef pair<ld, int> pli;
typedef unsigned int ui;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vi2;
typedef vector<vector<ll>> vll2;
typedef vector<vector<ll>> matrix;
typedef vec<vec<vec<int>>> vi3;

#define _DEBUG

#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define for1(i,n) for(int i = 1;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define REP(a,i,b) for (int i = a;i<b;i++);
#pragma warning(disable : 4996)
/*
 #pragma GCC optimize("Ofast")
 #pragma GCC target("avx,avx2,fma")
 */
const int inf = 2e9;
const ll linf = 2e18;
const ld LDINF = 2e18;


void solve()
{
	
	int x;
	cin >> x;
	cout << (x + 1) % 2;
}


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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main() {
	int h,w,a,b;
	for (;;) {
		cin >> h >> w;
		if (h == 0 && w == 0) {
			return 0;
		}
		a = h;
		b = w;
		for (w = b; w > 0; w = w - 1) {
			cout << "#";
		}
		cout << endl;
		for (h = a; h > 2; h = h - 1) {
			cout << "#";
			for (w = b; w > 2; w = w - 1) {
				cout << ".";
			}
			cout << "#" << endl;
		}
		for (w = b; w > 0; w = w - 1) {
			cout << "#";
		}
		cout << endl << endl;
	}
}


Measured memory_bytes: 3076
// #define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  lint a, b, n;
  std::cin >> a >> b >> n;
  lint x = std::min(a,n);
  n -= x;
  a -= x;

  lint y = std::min(b,n);
  n -= y;
  b -= y;
  std::cout << a << " " << b << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void show_result(int A, int B, int C, int K) {
    int i, gt_sum = -1e5, j, sum;
    int result_op, op[3] = {A, B, C};

    for(i = 0; i < 3; i++) {

        j = 0;

        result_op = op[i];

        while(j < K){
            result_op *= 2; 
            j++;
        }

        sum = result_op + op[(i + 1) % 3] + op[(i + 2) % 3];

        if(sum > gt_sum) {
            gt_sum = sum;
        }

    }

    printf("%d\n", gt_sum);

}


int main() {
    int A, B, C, K;

    scanf("%d %d %d\n%d", &A, &B, &C, &K);

    show_result(A, B, C, K);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cmath>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
const int INF=1e9;
int D,G;
int p[15];
int c[15];
bool used[15];
int g;
int ans=INF;
void rec(int d,bool complete,int score,int cnum)
{
  /*
  cout << d << ' ' << endl;
  for(int i=0;i<D;i++)
    {
      cout << "completed: " << used[i] << ' ';
    }
  cout << endl;
  cout << score << ' ' << cnum << ' ' << ans << endl;*/
  if(d<=D-1)
    {
      if(complete) used[d]=true;
      if(complete)
	{
	  score+=100*(d+1)*p[d]+c[d];
	  cnum+=p[d];
	  //cout << d << ' ' << cnum << endl;
	}
      rec(d+1,true,score,cnum);
      used[d+1]=false;
      rec(d+1,false,score,cnum);
    }
  else
    {
      if(score>=G)
	{
	  ans=min(ans,cnum);
	}
      else
	{
	  for(int i=D-1;i>=0;i--)
	    {
	      if(!used[i])
		{
		  for(int j=1;j<p[i];j++)
		    {
		      if(score+100*(i+1)*j>=G)
			{
			  ans=min(ans,cnum+j);
			  break;
			}
		    }
		}
	    }
	}
    }
}

int main(int argc,char const* argv[])
{
  memset(used,false,sizeof(used));
  cin >> D >> G;
  for(int i=0;i<D;i++)
    {
      cin >> p[i] >> c[i];
    }
  rec(0,true,0,0);
  memset(used,false,sizeof(used));
  rec(0,false,0,0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256