akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n; cin >> n;
  	auto a = vector<ll>(n+1,0);
    auto h = vector<ll>(n+1,0);  
  	auto b = vector<ll>();
  	for(ll i=1;i<=n;i++){
      cin >> a[i];
    }
  	
  	for(ll i=n;i>=1;i--){
      	bool sum = false;
    	for(ll j=i;j<=n;j+=i) sum^=h[j];
        h[i]=sum^a[i];
      	if(h[i]) b.push_back(i);
    }
  	
  	cout << b.size() << endl;
  	for(auto i:b) cout << i << " ";
  	
  
}

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

int main(){
    string S,T; cin >> S >> T;
        bool flag = false;
        for(int i=0;i<(int)S.size();i++){
            if(S == T){
                flag = true;
                break;
            }
            S = S[(int)S.size()-1] + S.substr(0,(int)S.size()-1);
        }
        if(flag){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
}


Measured memory_bytes: 256
# D

N = int(input())
A = list(map(int, input().split(" ")))

from collections import Counter

pairs = {}

ca = Counter(A)

for k,v in ca.items():
  #print(k,v)
  if v>1:
    pairs[k] = int(v*(v-1)/2)
  else:
    pairs[k] = 0

pairs_sum = int(sum(pairs.values()))

for k in range(N):
  t = ca[A[k]]
  print(pairs_sum-(t-1))

Measured memory_bytes: 32636
li = []

for i in range(5):
    li.append(int(input()))

res = []
for i in range(5):
    if li[i] % 10 == 0:
        res.append((0, li[i]))
    else:
        res.append((((li[i] // 10 + 1) * 10 - li[i]), li[i]))
res.sort(key=lambda x: x[0])

cnt = 0
for i, j in res[:4]:
    cnt += i + j

cnt += res[4][1]
print(cnt)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;

    int slen = s.length (), tlen = t.length();
    
    string tmp[50];
    int cnt = 0;
    for (int i = 0; i <= slen - tlen; i++) {
        bool f = true;
        for (int j = 0; j < tlen; j++) {
            if (s[i + j] == t[j] or s[i + j] == '?') continue;
            f = false; break;
        }

        if (f) {
            for (int j = 0; j < slen; j++) {
                if (j == i) {
                    tmp[cnt] += t;
                    j += tlen - 1;
                    continue;
                }
                tmp[cnt] += (s[j] == '?' ? 'a' : s[j]);
            }
            cnt++;
        }
    }

    if (tmp[0].empty()) return cout << "UNRESTORABLE" << endl, 0;

    string mini = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
    for (int i = 0; i < slen; i++) {
        if (!tmp[i].size()) continue;
        if (tmp[i] < mini) mini = tmp[i];
    }

    cout << mini << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

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

    vector<vector<int>> nums(2, vector<int>(n));
    rep(i, 2) rep(j, n) cin >> nums[i][j];

    vector<vector<int>> cum_sum(2, vector<int>(n));
    rep(j, n) cum_sum[0][j] = nums[0][j] + cum_sum[0][max(0, j-1)];
    for(int j = n-1; j >= 0; j --) cum_sum[1][j] = nums[1][j] + cum_sum[1][min(n-1, j+1)];

    vector<int> sum(n);
    rep(j, n) sum[j] = cum_sum[0][j] + cum_sum[1][j];

    cout << *max_element(all(sum)) << endl;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    string S;
    cin >> S;
    int ans = 0;
    REP(i, S.length() / 2) {
        int t = S.length() - 1 - i;
        if(S[i] != S[t]) { ans++; }
    }
    printf("%lld\n", ans);

    return 0;
}


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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 998244353
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "Yes" : "No" ) << '\n' ;
#define mxn 100005
using namespace std;

void solve(){
    int n,k;
    cin >> n >> k;
    int l[k],r[k];
    for(int i = 0; i < k; i++){
        cin >> l[i] >> r[i];
    }
    int dp[n + 5] = {};
    int pref[n + 5] = {};
    dp[1] = 1;
    pref[1] = 1;
    for(int i = 2; i <= n; i++){
        for(int j = 0; j < k; j++){
            if(i <= l[j])
                continue;

            int left = l[j];
            int right = min(r[j], i - 1);
            int val = (pref[i - left] - pref[i- right - 1] + mod) % mod;
            
            dp[i] = (dp[i] + val ) % mod;
        }
        pref[i] = (pref[i - 1] % mod + dp[i] % mod) % mod;
    }
    cout << dp[n] ;
}

int32_t main()
{
    FLASH
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 6740
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long X){
    ll R = X % 100;
    ll cnt = 0;
    vll a{5, 4, 3, 2, 1};
    REP(i, 5){
        ll t = R / a[i];
        R -= t * a[i];
        cnt += t;
    }
    if( cnt <= X/100)
        cout << 1 << endl;
    else
        cout << 0 << endl;

}

int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int s;
    cin>>s;
    int h,m,ss;
    h=s/3600;
    s=s-h*3600;
    m=s/60;
    s=s-m*60;
    ss=s;
    cout<<h<<":"<<m<<":"<<ss<<endl;
    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
using namespace std;

int main() {
	string S;
	cin >> S;

	if (S == "AAA" || S == "BBB") {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

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

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

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

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

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

fn dec(a: i64, b: i64) -> f64 {
    if a == 0 && b == 0 {
        0.0
    } else {
        100.0 * (b as f64) / ((a + b) as f64)
    }
}

fn max_index(vs: Vec<f64>) -> (usize, f64) {
    let mut max = (0, 0.0);
    for (i, v) in vs.iter().enumerate() {
        if v > &max.1 {
            max = (i, *v);
        }
    }
    max
}

fn main() {
    input! {
        A: i64,
        B: i64,
        C: i64,
        D: i64,
        E: i64,
        F: i64,
    }
    let mut waters = Vec::new();
    for i in 0..F {
        for j in 0..F {
            if A * i * 100 + B * j * 100 <= F {
                waters.push(A * i * 100 + B * j * 100);
            }
        }
    }
    let mut sugers = Vec::new();
    for i in 0..F {
        for j in 0..F {
            if C * i + D * j <= F {
                sugers.push(C * i + D * j);
            }
        }
    }
    waters.sort();
    waters.dedup();
    waters.remove(0);
    sugers.sort();
    sugers.dedup();

    let mut decs = Vec::new();
    let mut ws = Vec::new();
    let mut ss = Vec::new();

    for i in 0..waters.len() {
        for j in 0..sugers.len() {
            if waters[i] * E >= 100 * sugers[j] && waters[i] + sugers[j] <= F {
                decs.push(dec(waters[i], sugers[j]));
                ws.push(waters[i]);
                ss.push(sugers[j])
            }
        }
    }
    let dec = max_index(decs);
    println!("{} {}", ws[dec.0] + ss[dec.0], ss[dec.0]);
}

Measured memory_bytes: 8444
import java.util.*;
 
class Main {
  
   public static int findSumOfDigits (int n){
     int conut = 0;
     int buf[] = new int[5];
     int flag = 0;
     
     while(n>0){
       buf[conut]=n%10;
       n = n/10;
       conut++;
     } 
     if(buf[0]==buf[1]&&buf[3]==buf[4]){
       if(buf[0]==buf[4]){
         flag = 1;
       }
     }else if(buf[0]==buf[4]&&buf[1]==buf[3]){
       flag = 1;
     }
     return flag;
   }
  
  
    public static void main(String[] args) {
      
      
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int conut = 0;
      for(int i=A;i<=B;i++){
        int flag = findSumOfDigits(i);
        if(flag==1){
          conut++;
        }
      }

		System.out.print(conut);
    }
}

Measured memory_bytes: 25812
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)
//string s = to_string(i);
int a = 0, b = 0, c = 0, x = 0, y = 0, z = 0, n = 0, sum = 0, i = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> n;
	vint d(n);
	rep(i, n)cin >> d[i];
	sort(d);
	reve(d);
	cnt = 101;
	rep(i, n) {
		if (cnt > d[i]) {
			cnt = d[i];
			ans++;
		}
	}
	cout << ans << rt;
	please AC;
}

Measured memory_bytes: 256
#include<stdio.h>
int main () {
    int w,h;
    int i,j,k;
    for (i=0;i<1000;i++) {
        scanf("%d %d",&w,&h);
        if (w==0 && h==0)
            break;
        for (j=0;j<w;j++) {
            for (k=0;k<h;k++) {
                printf ("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
} 


Measured memory_bytes: 2056
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const N = readInt();
      auto A = new long[N + 1];
      foreach (d; 0 .. N + 1) {
        A[d] = readLong();
      }
      
      auto mns = new long[N + 1];
      auto mxs = new long[N + 1];
      foreach_reverse (d; 0 .. N) {
        // b[d] + 2 c[d] = A[d + 1] + b[d + 1] + c[d + 1]
        mns[d] = (A[d + 1] + mns[d + 1] + 1) / 2;
        mxs[d] = A[d + 1] + mxs[d + 1];
      }
      debug {
        writeln("mns = ", mns);
        writeln("mxs = ", mxs);
      }
      
      long now = 1 - A[0];
      if (mns[0] <= now && now <= mxs[0]) {
        long ans;
        foreach (d; 0 .. N + 1) {
          ans += A[d] + now;
          if (d == N) {
            break;
          }
          now *= 2;
          now -= A[d + 1];
          chmin(now, mxs[d + 1]);
        }
        writeln(ans);
      } else {
        writeln(-1);
      }
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 7656
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a.at(i);
    }
    ll ans=0;
    rep(i,n-1){
        if(a.at(i)>a.at(i+1)){
            ans+=a.at(i)-a.at(i+1);
            a.at(i+1)=a.at(i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4836
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int a[MAXN];
int main() {
	int n; read(n);
	for (int i = 1; i <= n; i++) {
		int x; read(x);
		a[x] = i;
	}
	int now = 1, ans = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i + 1] > a[i]) now++;
		else {
			chkmax(ans, now);
			now = 1;
		}
	}
	writeln(n - ans);
	return 0;
}

Measured memory_bytes: 1024
def f(x):
    y = (x + 1) % 4
    if y == 0:
        return 0
    elif y == 1:
        return x
    elif y == 2:
        return 1
    else:
        return x ^ (x - 1) ^ (x - 2)


a, b = map(int, input().split())
print(f(b) ^ f(a-1))

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

int A, B;

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

Measured memory_bytes: 256
my ($N, $M) = split(/\s+/, <>);
my %path;
for(my $i=0;$i<$M;$i++){
    my ($a,$b) = split(/\s+/,<>);
    push (@{$path{$a}},$b);
    push (@{$path{$b}},$a);
}
my @level;
my @now=("1");
while(){
    my @ne;
    if($#now==-1 ){
        last;
    }
    for my $c (@now){
        for my $d ( @{$path{$c}}){
            if(!defined($level[$d])){
                push (@ne,$d);
                $level[$d]=$c;
            }
        }
    }
    @now = @ne;
}
print "Yes\n";
for (2..$N){
    print "$level[$_]\n";
}

Measured memory_bytes: 88744
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void ReadFirstInput(int *snukesNumber, int *candyTypes)
{
    //printf("Enter the number of Snukes and SnackTypes: \n");
    scanf("%d %d", snukesNumber, candyTypes);
}

void CountTricks(int *snukesArray, int *snukesNumber)
{
    int counter = 0;
    
    for(int i = 0; i < *snukesNumber; i++)
    {
        if(snukesArray[i] == 0)
        {
            counter++;
        }
    }
    printf("%d \n", counter);
}

void CreateArray(int *snukesNumber, int *candyTypes)
{
    int *dArray = (int*)malloc(250 * sizeof(int));
    int *aArray =  malloc(250 * 250 * sizeof *aArray);
    int *snukesArray = malloc(250 * sizeof(int));
    
    for(int i = 0; i < *candyTypes; i++)
    {
        scanf("%d\n", &dArray[i]);
        for(int j = 0; j < dArray[i]; j++)
        {
            scanf("%d", &aArray[i + j]);
            int snukesWithSnacks = aArray[i + j];
            snukesArray[snukesWithSnacks - 1] = 1;
        }
    }
    
    CountTricks(snukesArray, snukesNumber);
}

int main(int argc, const char * argv[])
{
    int *snukesNumber = malloc(3 * sizeof(int));
    int *candyTypes = malloc(3 * sizeof(int));
    
    ReadFirstInput(snukesNumber, candyTypes);
    CreateArray(snukesNumber, candyTypes);
    
    return 0;
}


Measured memory_bytes: 1732
from collections import Counter
from itertools import accumulate
n = int(input())
A = tuple(map(int, input().split()))
C = Counter(A)
D = [0]*(n+1)
for v in C.values():
  D[v] += 1
E = tuple(accumulate(k*d for k, d in enumerate(D)))
D = tuple(accumulate(D))
F = [0]*(n+1)
for x in range(1, n+1):
  temp = (E[x] + x*(D[n]-D[x])) // x
  F[x] = temp
for k in range(1, n+1):
  ok = 0
  ng = n+1
  while ng-ok > 1:
    mid = (ok+ng)//2
    if k <= F[mid]:
      ok = mid
    else:
      ng = mid
  print(ok)

Measured memory_bytes: 60036
//https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_8_B
//p216.cpp

#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k){
	while ( u != NIL && k != u->key ){
		if ( k < u->key ) u = u->left ;
		else u = u->right;
	}
	return u;
}

void insert(int k){
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	
	while ( x != NIL ){
		y = x;
		if ( z->key < x->key ){
			x = x->left;
		}else{
			x = x->right;
		}
	}

	z->parent = y;
	if ( y == NIL ){
		root = z;
	}else{
		if ( z->key < y->key ) {
			y->left = z;
		}else{
			y->right = z;
		}
	}
}

void inorder(Node *u){
	if ( u == NIL ) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}
void preorder(Node *u){
	if ( u == NIL ) return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}

int main(){
	int n, i, x;
	string com;

	scanf("%d", &n);

	for ( i = 0; i < n; i++ ) {
		cin >> com;
		if ( com[0] == 'f' ){
			scanf("%d", &x);
			Node *t = find(root, x);
			if ( t != NIL )printf("yes\n");
			else printf("no\n");
		} else if ( com == "insert" ) {
			scanf("%d", &x);
			insert(x);
		} else if ( com == "print" ){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}




Measured memory_bytes: 21948
n=int(input())
txylist=[[0,0,0]]
for i in range(n):
    txy=list(map(int,input().split(" ")))
    txylist+=[txy]
for i in range(n):
    p=False
    t0,x0,y0=txylist[i]
    t1,x1,y1=txylist[i+1]
    t=t1-t0
    x=x1-x0
    y=y1-y0
    tt=abs(x)+abs(y)
    legs=t-tt
    if legs>=0 and legs%2==0:
        p=True
    else:
        print("No")
        break
if p==True:
    print("Yes")

Measured memory_bytes: 27156
#include<bits/stdc++.h>
using namespace std;
int main() {
	string a;
	cin>>a;
	int cnt=0;
	for(int i=0; i<a.size(); i++) {
		if(a[i]=='C') {
			cnt=1;
		}
		if(a[i]=='F'&&cnt==1) {
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();

        if(X==3 || X==5 || X==7){
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }
    }
}

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


int main(){
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int dp[n];
    for(int i=2;i<n;i++){
        dp[i]= INT_MAX;
    }
    dp[0]=0; dp[1]= abs(h[0]-h[1]);
    for(int i=2;i<n;i++){
        int cost1= dp[i-2]+ abs(h[i]- h[i-2]);
        int cost2= dp[i-1]+ abs(h[i] - h[i-1]);
        dp[i]= min(dp[i],min(cost1,cost2));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N;
  cin >> N;
  
  int num = 0;
  int count = 0;
 
    while(count < 9){
      num = num + 111;
      
      if(N <= num){
        cout << num << endl;
        break;
      }
      
      count++;
    }
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int N,W[100],all=0,min=0,sa[100],max=0;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d",&W[i]);
    all+=W[i];
  }
  for(int i=0;i<N;i++){
    all-=W[i];
    min+=W[i];
    if(all>=min){
      sa[i]=all-min;
    }else{
      sa[i]=min-all;
    }
  }
max=sa[0];
for(int i=1;i<N;i++){
    if(max>sa[i]){
      max=sa[i];
    }
  }

  printf("%d",max);

  


      
  return 0;
 }
      

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
  
int main(void)
  {
  int n;
  cin>>n;
  int ar[n+1];
  int count=0;
  for(int i=1;i<=n;i++)
    {
    cin>>ar[i];
    if(i&1&&ar[i]&1)
      count++;
    }
  cout<<count;

  return 0;
 }


Measured memory_bytes: 3556
n=int(input())
l=[[j for j,k in enumerate(input())if k=="1"]for i in range(n)]
import sys
sys.setrecursionlimit(10**9)
color=[0]*n
def nibu(v,c):
    #True->nibugrahu
    color[v]=c
    for i in l[v]:
        if color[i]==c:return False
        elif color[i]==0 and not nibu(i,-c):
            return False
    return True
if not nibu(0,1):
    print(-1)

else:
    class WarshallFloyd:
        #O(V^3)で任意２頂点の最短距離
        def __init__(self,n,_first_index=0):
            self.v = n
            self._first_idx=_first_index
            self.d = [[float("INF")]*(n) for _ in range(n)]
            for i in range(n):
                self.d[i][i] = 0
    
        def path(self,x,y,c):
            if x == y:
                return False
            f=self._first_idx
            self.d[x-f][y-f] = c
            self.d[y-f][x-f] = c
            return True
    
        def build(self):
            for k in range(self.v):
                for i in range(self.v):
                    for j in range(self.v):
                        self.d[i][j] = min(self.d[i][j], self.d[i][k] + self.d[k][j])
            return self.d
    w=WarshallFloyd(n)
    for x in range(n):
        for j in l[x]:
            w.path(x,j,1)
    d=w.build()
    ans=0
    for i in range(n):
        ans=max(ans,max(d[i]))
    print(ans+1)

Measured memory_bytes: 56156
def main():
    N = int(input())
    a = sorted(list(map(int, input().split())))

    s = [a[0]]
    for i in range(1, N):
        s.append(s[-1] + a[i])
    # print(a)
    # print(s)
    ans = 1
    for i in range(N-2, -1, -1):
        if s[i] * 2 >= a[i+1]:
            ans += 1
        else:
            break
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14320
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>

#define c0 ios_base :: sync_with_stdio(0); cin.tie (0);
#define s second
#define f first
#define ll long long
#define ull unsigned long long

using namespace std;

const int MaxN = 5e5 + 17;
const int INF = 1e9 + 17;
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const double pi = 3.14159265359;
int n, m;
vector < pair < int, pair < int, int > > > g;
int a[500][500];
int main () {
    scanf ("%d%d", &n, &m);
    for (int i = 1; i <= n; ++ i)
        for (int j = 1; j <= n; ++ j)
            a[i][j] = INF;
    for (int i = 1; i <= n; ++ i)
        a[i][i] = 0;
    for (int i = 1; i <= m; ++ i) {
        int v, to, w;
        scanf ("%d%d%d", &v, &to, &w);
        a[v][to] = min (a[v][to], w);
        a[to][v] = min (a[to][v], w);
        g.push_back (make_pair (w, make_pair (v, to)));
    }
    int cnt = 0;
    for (int k=1; k<=n; ++k)
        for (int i=1; i<=n; ++i)
            for (int j=1; j<=n; ++j)
                a[i][j] = min (a[i][j], a[i][k] + a[k][j]);
    for (int i = 0; i < g.size(); ++ i) {
        int w = g[i].first;
        int v = g[i].second.first;
        int to = g[i].second.second;
        if (a[v][to] < w) {
            ++ cnt;
        }
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	long long n, i, j, k, id, x, ct, iid, ans;
	cin >> n;
	vector<long long> a(n), b(n);
	for (i = 0; i < n; i++) cin >> a[i];
	for (i = 0; i < n; i++) cin >> b[i];

	set<long long> s;
	for (i = 0; i < n; i++) {
		if ((b[i] > b[(i + 1) % n]) && (b[i] > b[(i + n - 1) % n]) && (b[i] > a[i])) s.insert(i);
	}

	ans = 0;
	while (!s.empty()) {
		id = *s.begin();
		s.erase(id);

		x = b[(id + 1) % n] + b[(id + n - 1) % n];
		ct = (b[id] - a[id]) / x;
		b[id] -= ct * x;
		ans += ct;

		i = (id + 1) % n;
		if ((b[i] > b[(i + 1) % n]) && (b[i] > b[(i + n - 1) % n]) && (b[i] > a[i])) s.insert(i);

		i = (id + n - 1) % n;
		if ((b[i] > b[(i + 1) % n]) && (b[i] > b[(i + n - 1) % n]) && (b[i] > a[i])) s.insert(i);
	}

	if (a == b) cout << ans << "\n";
	else cout << "-1\n";

	return 0;
}


Measured memory_bytes: 8064
from collections import deque

N = int(input())
S = [input() for _ in range(N)]
es = [[] for _ in range(N)]

for i in range(N):
    for j in range(i+1,N):
        if S[i][j] == "1":
            es[i].append(j)
            es[j].append(i)

INF = float("inf")
def solve(s):
    dist = [INF] * N
    dist[s] = 0
    union = [[] for _ in range(N)]
    union[0].append(s)

    q = deque()
    q.append(s)
    while q:
        curr = q.popleft()
        for nxt in es[curr]:
            if dist[curr] + 1 >= dist[nxt]:
                continue

            dist[nxt] = dist[curr] + 1
            union[dist[nxt]].append(nxt)
            q.append(nxt)

    return dist, union



d, u = solve(0)

for i in range(N):
    if len(u[i]) > 1:
        for a in u[i]:
            for b in u[i]:
                if S[a][b] == "1":
                    print(-1)
                    exit()

ans = 0
for i in range(N):
    d, _ = solve(i)
    ans = max(ans, max(d) + 1)

print(ans)

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

using namespace std;
#define ll long long int
priority_queue<int> q;
vector<int> v[1000005];

int main(){
    ll N,M;
    ll a,b;
    cin >> N >> M;
    rep(i,N) {
        cin >> a >> b;
        v[a].push_back(b);
    }
    ll res = 0;
    for(int i=M; i>=1; i--) {
        for(int c : v[M-i+1]){
            q.push(c);
        }
        
        if(!q.empty()){
            int x = q.top();
            q.pop();
            res += x;
        }
        
    }
    cout << res << endl;
        
}

Measured memory_bytes: 26752
#include<bits/stdc++.h>
using namespace std;
 
int n,D_1,D_2,cnt;
 
bool chk(int i,int j,int d){
	int u=__builtin_ctz(d);
	if(u&1)return!(i>>(u/2)&1);
	else return!((i^j)>>(u/2)&1);
}
 
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>D_1>>D_2;
	for(int i=0;i<2*n;++i)
		for(int j=0;j<2*n;++j)
			if(chk(i,j,D_1)&&chk(i,j,D_2)){
				cout<<i<<' '<<j<<'\n';
				if(++cnt>=n*n)return 0;
			}
	return 0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long ll;
#define MAX_N 50001

int dp[MAX_N];

void init(){
	rep(i,MAX_N) dp[i] = MAX_N;
}

int main()
{
	init();
	int n,m;
	cin>>n>>m;
	int *coins = new int[m];
	rep(i,m) cin>>coins[i];
	dp[0] = 0;
	for(int i = 1; i <= n; i++){
		rep(j,m){
			if( (i - coins[j]) >= 0){
				dp[i] = min(dp[i], dp[i-coins[j]] + 1);
			}
		}
	}
	cout<<dp[n]<<endl;

	return 0;
}




Measured memory_bytes: 3296
li = list(map(int,input().split()))
out = int(li[0] / (li[1] + li[2])) * li[1]
remain = li[0] - int(li[0] / (li[1] + li[2])) *  (li[1] + li[2])
if(remain > li[1]):
    out += li[1]
else:
    out += remain
print(out)

Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 2000000;
const int inf = 1000000007;
const ll mod = 1000000007;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
 
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
 
 
 
int n, ans;
int a[2][100005];
 
int main() {
 
	cin >> n;
 
	rep(i, 2) {
		rrep(j, n) {
			int tmp;
			cin >> tmp;
			a[i][j] = a[i][j - 1] + tmp;
		}
	}
 
	rrep(i, n) {
		ans = max(ans, a[0][i] + (a[1][n] - a[1][i - 1]));
	}
 
	cout << ans << endl;
 int justin = 9;
	return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Energy Drink Collector
            var line = ReadLine();
            int n = line[0];
            int m = line[1];

            var shops = new List<Shop>();

            for(int i = 0; i < n; i++)
            {
                shops.Add(new Shop());
            }

            //ドリンクの値段の安い順に店をソート
            shops = shops.OrderBy(x => x.Price).ToList();

            //買わなければいけないドリンクの本数
            long remainder = m;
            long money = 0;

            foreach (var s in shops)
            {
                if (remainder >= s.Stock)
                {
                    money += s.Price * s.Stock;
                    remainder -= +s.Stock;
                }
                else
                {
                    money += s.Price * remainder;
                    break;
                }
            }

            Console.WriteLine(money);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine().TrimEnd();
            var array = line.Split(' ');
            var numbers = new List<int>();

            foreach (var s in array)
            {
                int num = int.Parse(s);
                numbers.Add(num);
            }

            return numbers;
        }
    }

    class Shop
    {
        public long Price { set; get; }
        public long Stock { set; get; }

        public Shop()
        {
            var line = Console.ReadLine();
            var s = line.Split(' ');

            Price = long.Parse(s[0]);
            Stock = long.Parse(s[1]);
        }
    }
}

Measured memory_bytes: 27972
using System;
using System.Linq;

namespace ABC063
{
    class C
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var s = Enumerable.Repeat(0, N).Select(_ => int.Parse(Console.ReadLine())).OrderBy(x => x).ToArray();
            var sum = s.Sum();
            if (sum % 10 != 0) { Console.WriteLine(sum); return; }
            for (int i = 0; i < N; i++)
            {
                sum -= s[i];
                if (sum % 10 != 0) break;
                sum += s[i];
            }

            if (sum % 10 == 0) Console.WriteLine(0);
            else Console.WriteLine(sum);

        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <vector>
#include <stack>

using namespace std;

int a[200010];
int ans[200010];

int main(){

  long int n,x;
  cin>>n;

   for(int i=2;i<=n;i++) cin>>a[i];

   for(int i=2;i<=n;i++) ans[a[i]]++;

   for(int i=1;i<=n;i++)
   cout<<ans[i]<<endl;

 return 0;
}


Measured memory_bytes: 5156
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll K,X; cin >> K >> X;
    
    vector<ll> ans(2*K-1);
    
    iota(ans.begin(),ans.end(),X-K+1);
    res = ans;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<vector<ll>>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int a, b, c, n;
int main() {
	scanf("%d%d%d", &n, &a, &b);
	if (a < b) {
		c = a;
		a = b;
		b = c;
	}
	c = a + b - n;
	if (c < 0)c = 0;
	printf("%d %d\n", b, c);
	return 0;
}

Measured memory_bytes: 128
program main
 implicit none
 integer n
 character*100 s
 read(*,*) n
 read(*,*) s
 if(mod(n,2)==0) then
  if(s(1:n/2) == s(n/2+1:n)) then
   write(*,*) 'Yes'
  else
   write(*,*) 'No'
  end if
 else
  write(*,*) 'No'
 end if
end program main

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <algorithm>
#include <complex>
#include <cassert>
#include <vector>
#include <iomanip>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    vll dp(35);
    dp[0] = 1;
    rep(i, 35){
        rep(j, 4)if (j){
            if (i - j >= 0){
                dp[i] += dp[i - j];
            }
        }
    }
    int n;
    while (cin >> n && n){
        cout << dp[n] / 10 / 365 + 1<< endl;
    }
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector <string> a(h);
  for(int i; i<h; i++){
    cin >> a.at(i);
  }
  
  for(int i=0; i<h+2; i++){
    for(int j=0; j<w+2; j++){
      if(i==0||i==h+1||j==0||j==w+1){
        cout << "#";
      }
      else if(j==1){
        cout << a.at(i-1);
      }
    }
   cout << endl;}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

void solve() {
	int n; cin >> n;
	string s; cin >> s;
	rep(i, s.size()) {
		int u = s[i] - 'A';
		u = (u + n) % 26;
		s[i] = 'A' + u;
	}
	cout << s << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init();
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input()) / 50

count = 0
for i in range(a + 1):
    for j in range(b + 1):
        t = x - 10 * i - 2 * j
        if t <= c and 0 <= t:
            count += 1
print(count)

Measured memory_bytes: 38768
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

LL absll(LL x){return x>0?x:-x;}
LL maxll(LL x,LL y){return x>y?x:y;}
LL minll(LL x,LL y){return x<y?x:y;}

const int N = 1e5+5;
const int INF = 2e9;

int n,A,B;
LL d;
struct point{
	LL x,y;
	point(const LL x_=0,const LL y_=0){x=x_;y=y_;}
}a[N];
struct node{
	int l,r,tot;
}tree[N*160];
int tot;
map<LL,int>rth,rtr;

void add(int &now,LL l,LL r,int x,int v){
	if (!now)now=++tot;
	tree[now].tot+=v;
	if (l==r)return;
	int mid=l+r>=0?(l+r)/2:(l+r-1)/2;
	if (x<=mid)add(tree[now].l,l,mid,x,v);
	else add(tree[now].r,mid+1,r,x,v);
}

void clear(point u){
	add(rth[u.x],-INF,INF,u.y,-1);
	add(rtr[u.y],-INF,INF,u.x,-1);
}

void init(){
	fo(i,1,n){
		add(rth[a[i].x],-INF,INF,a[i].y,1);
		add(rtr[a[i].y],-INF,INF,a[i].x,1);
	}
}

point que[N];
int he,ta;
int w;
LL key;

void floodfill(int now,LL l,LL r,int x,int y){
	if (!now||tree[now].tot==0)return;
	if (x<=l&&r<=y){
		if (l==r){
			que[++ta]=w==0?point(key,l):point(l,key);
			clear(que[ta]);
		}
		else{
			int mid=l+r>=0?(l+r)/2:(l+r-1)/2;
			floodfill(tree[now].l,l,mid,x,y);
			floodfill(tree[now].r,mid+1,r,x,y);
		}
		return;
	}
	int mid=l+r>=0?(l+r)/2:(l+r-1)/2;
	if (x<=mid)floodfill(tree[now].l,l,mid,x,y);
	if (y>mid)floodfill(tree[now].r,mid+1,r,x,y);
}

void bfs(){
	he=0,ta=2;
	que[1]=a[A],que[2]=a[B];
	clear(a[A]),clear(a[B]);
	while(he<ta){
		point u=que[++he];
		w=0,key=u.x-d;
		floodfill(rth[u.x-d],-INF,INF,maxll(-INF,u.y-d),minll(INF,u.y+d));
		key=u.x+d;
		floodfill(rth[u.x+d],-INF,INF,maxll(-INF,u.y-d),minll(INF,u.y+d));
		w=1,key=u.y-d;
		floodfill(rtr[u.y-d],-INF,INF,maxll(-INF,u.x-d),minll(INF,u.x+d));
		key=u.y+d;
		floodfill(rtr[u.y+d],-INF,INF,maxll(-INF,u.x-d),minll(INF,u.x+d));
	}
}

LL ans;

void getans(int now,LL l,LL r,int x,int y){
	if (!now)return;
	if (x<=l&&r<=y){
		ans+=tree[now].tot;
		return;
	}
	int mid=l+r>=0?(l+r)/2:(l+r-1)/2;
	if (x<=mid)getans(tree[now].l,l,mid,x,y);
	if (y>mid)getans(tree[now].r,mid+1,r,x,y);
}

void getans(){
	ans=0;
	fo(i,1,ta){
		point u=que[i];
		getans(rth[u.x-d],-INF,INF,maxll(-INF,u.y-d+1),minll(INF,u.y+d-1));
		getans(rth[u.x+d],-INF,INF,maxll(-INF,u.y-d+1),minll(INF,u.y+d-1));
		getans(rtr[u.y-d],-INF,INF,maxll(-INF,u.x-d),minll(INF,u.x+d));
		getans(rtr[u.y+d],-INF,INF,maxll(-INF,u.x-d),minll(INF,u.x+d));
	}
	ans/=2;
	printf("%lld\n",ans);
}

int main(){
	n=get();A=get();B=get();
	fo(i,1,n){
		a[i].x=get(),a[i].y=get();
		int x=a[i].x,y=a[i].y;
		a[i]=point(x+y,x-y);
	}
	d=maxll(absll(a[A].x-a[B].x),absll(a[A].y-a[B].y));
	init();
	bfs();
	init();
	getans();
	return 0;
}

Measured memory_bytes: 103552
//   PIGMEISTER™   //

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

#define ll long long
#define ld long double
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD (ll)1000000007
//#define MOD (ll)998244353
#define PI (ld)3.141592653589793238
#define MAX 100005

int main()
{
    jaldi;
    
    ll n;
    cin >> n;
    vector<ll> l(n);
    sidha (i, 0, n) cin >> l[i];
    sort(sab(l));

    if (n < 3) {
        cout << 0;
        return 0;
    }

    ll ans = 0;
    sidha (i, 0, n) {
        sidha (j, i+1, n) {
            sidha (k, j+1, n) {
                if (l[i] != l[j] and l[j] != l[k] and l[i]+l[j] > l[k]) {
                    ans++;
                }
            }
        }
    }
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
int main()
{
	int A, B, C,K;
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	scanf("%d", &K);

	if (K < A)
		printf("%d", K);
	else if (K <= A + B &&K>=A)
		printf("%d", A);
	else
		printf("%d",A - (K - A - B));

}

Measured memory_bytes: 1732
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#define INF 0xfffffff
#define CL(x,v); memset(x,v,sizeof(x));
#define LL long long
#define REP(i,r,n) for(int i=r;i<=n;i++)
#define RREP(i,n,r) for(int i=n;i>=r;i--)
#define max(x,y) x>y?x:y
#define min(x,y) x<y?x:y
#define EPS 1e-8
using namespace std;
int main()
{

    int q;

    long long p,n;
    char c;
    while(scanf("%d",&q)!=EOF)
    {
        long long ans=0;
        for(int i=0;i<q;i++){
            scanf("%I64d %c %I64d",&p,&c,&n);
            if(c=='('){
                ans+=n;
            }
            else  ans-=n;
            if(ans==0)  printf("Yes\n");
            else printf("No\n");
        }

    }
    return 0;
}

Measured memory_bytes: 1188
#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>>;

ll N, A, B;
string s;

int main(){
    cin >> N >> A >> B;
    ll num = N / (A+B);
    cout << num * A + min(A, N - num * (A + B));
	return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
s = list(input())
a = collections.Counter(s)
a = list(a.items())
ans = 0
# ar = []
# for i in range(1,2000):
#     c_ar = []
#     for j in range(1,n+1,i):
#         c_ar.append(j)
#     if len(c_ar) >= 3:
#         ar.append(c_ar)
# print(ar)
# print(len(ar))
# for i in range(len(ar)):
#     print(ar[i])
#     print(len(ar[i]))
#     for j in range(len(ar[i])-2):
#         print(s[ar[i][j]-1],s[ar[i][j+1]-1],s[ar[i][j+2]-1])
#         print(ar[i][j]-1, ar[i][j+1]-1, ar[i][j+2]-1)
#         if s[ar[i][j]-1] != s[ar[i][j+1]-1] and s[ar[i][j+1]-1] != s[ar[i][j+2]-1] and s[ar[i][j+2]-1] != s[ar[i][j]-1]:
#             cnt += 1
#             print("Y")
#     print(cnt)
# print(a[0][1],a[1][1],a[2][1])
# print(a[0][1]*a[1][1]*a[2][1]-cnt)
if n == 1 or n == 2 or n == 3:
    print(0)
    exit()
if len(a) != 3:
    print(0)
    exit()
for i in range(1,n//2+3):
    cnt = 0
    #print(i)
    for j in range(n):
        if cnt + 2*i > n-1:
            break
        x,y,z = s[cnt], s[cnt+i], s[cnt+2*i]
        #print(cnt, cnt+i, cnt+i+i)
        if x != y and y != z and z != x:
            ans += 1
        cnt += 1
print(a[0][1]*a[1][1]*a[2][1]-ans)



Measured memory_bytes: 68864