akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int a[100010];
const int P=1000000007; 
int pow(int a,int k){
	if(k==1) return a;
	long long t=pow(a,k/2);
	t%=P;
	t*=t;
	t%=P;
	if(k%2) t*=a;
	return t%P;
}
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	long long ans=0,sum=0;
	for(int i=1;i<n;i++){
		sum+=pow(i,P-2);
		sum%=P;
		ans+=1LL*sum*(a[i+1]-a[i])%P;
		ans%=P;
	}
	for(int i=1;i<n;i++){
		ans*=i;
		ans%=P;
	}
	cout<<ans;
	return 0;
}

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

int main() {
    int64_t h, w;
    cin >> h >> w;
    int64_t ans = (h/2)*(w/2)+((h+1)/2)*((w+1)/2);
    if(h == 1 || w == 1) ans = 1;
    cout << ans << endl;
}


Measured memory_bytes: 256
#A - Divide a Cuboid 
ABC = list(map(int,input().split()))
ABC = sorted(ABC,reverse = True)
A,B,C = ABC[0],ABC[1],ABC[2]
a,b,c = A%2,B%2,C%2

if a == 0 or b == 0 or c == 0:
    diff = 0
else:
    b = (A//2)*B*C
    r = ((A+2-1)//2)*B*C
    diff = r-b
print(diff)

Measured memory_bytes: 9188
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
#include<algorithm>
#define LL long long
using namespace std;
const int N =1e6+10;
const LL mod = 1e9 + 7;
char s[N];
int fac[N];
LL ksm(LL a, LL b) 
{ 
	LL ans =1;
	while(b) 
	{ 
		if(b & 1) 
		ans = ans * a % mod;
	 	a = a * a % mod;
	 	b >>= 1;
	}  
	 	return ans; 
}
void init(int n) {
    fac[0] = 0;
    for(int i=1;i<=n;++i) 
	{
        fac[i] = fac[i - 1];
        int k = i;
        while(k % 2 == 0) 
		{
            fac[i]++;
            k/=2;
        }
    }
}

int C(int n, int m) 
{
    return fac[n] - fac[m] - fac[n - m];
}
int main()
{
	int n;
    scanf("%d", &n);
    scanf("%s", s + 1);
    bool flag0 = 0, flag1 = 0, flag2 = 0;
    for(int i=1;i<=n;++i) 
	{
        s[i]--;
        if(s[i] == '0') flag0 = 1;
        if(s[i] == '1') flag1 = 1;
        if(s[i] == '2') flag2 = 1;
    }
    if(flag0 + flag1 + flag2 <= 1) 
	{
        puts("0"); return 0;
    }
    init(n);
    int ans = 0;
    if(flag1) 
	{
        for(int i=1;i<=n;++i) 
		{
            if(s[i] == '1') 
			{
                if(C(n - 1, i - 1) == 0) ans ^= 1;
            }
        }
    }
    else 
	{
        for(int i=1;i<=n;++i) 
		{
            if(s[i] == '2') 
			{
                if(C(n - 1, i - 1) == 0) ans ^= 1;
            }
        }
        ans = ans * 2;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 5120
fun main(args: Array<String>) {
    val (n,x)= readLine()!!.split(" ").map { it.toInt() }
    val a= readLine()!!.split(" ").map { it.toLong() }.toTypedArray()

    var eatSum=0L
    eatSum += Math.max(0L, a[0]-x)
    a[0] -= eatSum
    (1..a.lastIndex).forEach { i->
        val eat = Math.max(0L, a[i]+a[i-1]-x)
        eatSum += eat
        a[i] -= eat
    }
    println(eatSum)
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int f(int x) {
    int ret = 0;
    while (x > 0) {
        ret++;
        x /= 10;
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    int ret = 0;
    for (int i=1; i<=n; i++)
        ret += f(i) % 2;
    cout << ret << "\n";

    return 0;
}


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

#define LOCAL 0

#define lli long long int
#define llu unsigned long long int
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const long double EPS = 1e-10;
const lli MOD = 1000000007ll;
int INF = (int)1e9;
lli INFINF = (lli)1e18;
int debug = 0;

using namespace std;

lli bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
lli bit(lli _mask,lli _i){return (_mask&(1<<_i))==0?0:1;}
lli powermod(lli _a,lli _b,lli _m=MOD){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli add(lli a,lli b,lli m=MOD){lli x=a+b;while(x>=m)x-=m;return x;}
lli sub(lli a,lli b,lli m=MOD){lli x=a-b;while(x<0)x+=m;return x;}
lli mul(lli a,lli b,lli m=MOD){lli x=a*1ll*b;x%=m;if(x<0)x+=m;return x;}

int N,x;
int ans[200010];

int main()
{
if(LOCAL){
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    debug = 1;
}
    srand (time(NULL));

    cin>>N>>x;
    if(N==2){
        if(x == 2){
            cout<<"Yes\n1\n2\n3";
        }
        else{
            cout<<"No\n";
        }
        return 0;
    }
    if(x == 1 || x == 2*N-1){
        cout<<"No\n";
        return 0;
    }

    if(N == x){
        for(int i=1;i<=2*N-1;i++)
            ans[i] = i;
    }
    else if(x<N){
        set<int> Set;
        for(int i=1;i<=2*N-1;i++)
            Set.insert(i);
        Set.erase(x);
        Set.erase(x-1);
        Set.erase(x+1);
        Set.erase(2*N-2);
        Set.erase(2*N-1);
        ans[N] = x;
        ans[N-1] = x-1;
        ans[N-2] = 2*N-2;
        ans[N+1] = 2*N-1;
        ans[N+2] = x+1;

        for(int i=N-3,j=N+3;!Set.empty();i--,j++){
            set<int>::iterator it;
            ans[i] = *Set.begin();
            Set.erase(Set.begin());
            ans[j] = *Set.begin();
            Set.erase(Set.begin());
        }
    }
    else{
        set<int> Set;
        for(int i=1;i<=2*N-1;i++)
            Set.insert(i);
        Set.erase(x);
        Set.erase(1);
        Set.erase(2);
        Set.erase(x-1);
        Set.erase(x+1);
        ans[N] = x;
        ans[N-1] = 1;
        ans[N-2] = x-1;
        ans[N+1] = x+1;
        ans[N+2] = 2;

        for(int i=N-3,j=N+3;!Set.empty();i--,j++){
            set<int>::iterator it;
            ans[i] = *Set.begin();
            Set.erase(Set.begin());
            ans[j] = *Set.begin();
            Set.erase(Set.begin());
        }
    }

    cout<<"Yes\n";
    for(int i=1;i<=2*N-1;i++)
        cout<<ans[i]<<"\n";

    return 0;
}


Measured memory_bytes: 11648
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
int w, n;
vector <pair <int, int> > vp;

int main(){
    cin >> w >> n;
    rep(i, n){
        int va, ri;
        scanf("%d, %d", &va, &ri);
        vp.push_back(make_pair(va, ri)); 
    }
    vi ans;
    rep(i, w)ans.push_back(i + 1);
    rep(i, w){
        int out = i + 1;
        rep(j, vp.size()){
            if(out == vp[j].first)out = vp[j].second;
            else if(out == vp[j].second)out = vp[j].first;
        }
        ans[out - 1] = i + 1;
    }
    rep(i, w)cout << ans[i] << endl;
}

Measured memory_bytes: 3144
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let K: usize = sc.get();
    let mut w = 1;
    let mut rem = 0;
    for i in 0..K {
        rem = (rem + w * 7) % K;
        if rem == 0 {
            println!("{}", i+1);
            return;
        }
        w = (w * 10) % K;
    }
    println!("-1");
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
    int n;
    cin>>n;
    int a[n];
   for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        if(a[i]==a[i+1]){cout<<"NO";return 0;}
    }
    cout<<"YES";
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
using namespace std;

int par[100000];
int rankt[100000];

void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		rankt[i] = 0;
	}
}

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

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) {
		return;
	}
	if (rankt[x] < rankt[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rankt[x] == rankt[y]) {
			rankt[x]++;
		}
	}
}
bool same(int x, int y) {
	return (find(x) == find(y));
}

int main() {
	int n, m, p[100000], ans = 0;
	cin >> n >> m;
	init(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		unite(a, b);
	}
	for (int i = 0; i < n; i++) {
		if (same(i+1, p[i])||i+1==p[i]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
from collections import defaultdict

N, T, *A = map(int, open(0).read().split())

ctr = defaultdict(int)
m = 10 ** 9 + 7
for i in range(N):
    m = min(m, A[i])
    ctr[A[i] - m] += 1

print(ctr[max(ctr)])


Measured memory_bytes: 69920
N = int(input())
a = [0] + list(map(int, input().split()))
b = [0] + [0 for _ in range(N)]


for i in range(N+1):
    j = N - i
    s = 0
    if j == 0:
        break
    for k in range(int(N/j)):
        s += b[j * (k+1)]
    if s % 2 != a[j]:
        b[j] = 1

b = b[1:]
b_index = []
for i, n in enumerate(b):
    if n == 1:
        b_index.append(str(i+1))

print(len([n for n in b if n == 1]))
if len(b_index) > 0:
    print(' '.join(b_index))



Measured memory_bytes: 17324
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    
    // Problem A
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int product = a*b;
    if(product%2 == 0) {
      System.out.println("Even");
    }
    else {
      System.out.println("Odd");
    }
}
}

Measured memory_bytes: 21716
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        a: usize, b: usize
    };

    let res = a - std::cmp::min(a, b * 2);
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2248
import itertools

n,m,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(q)]
ans=0

for k in itertools.combinations_with_replacement(range(1,m+1),n):
    t=0
    for j in l:
        if k[j[1]-1]-k[j[0]-1]==j[2]:
            t+=j[3]
    
    ans=max(ans,t)
print(ans)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
using namespace std;
typedef long long LL;
typedef pair<LL, int> pli;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<double, double> pdd;
typedef map<char, int> mci;
typedef map<string, int> msi;
template<class T>
void read(T &res) {
  int f = 1; res = 0;
  char c = getchar();
  while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar(); }
  while(c >= '0' && c <= '9') { res = res * 10 + c - '0'; c = getchar(); }
  res *= f;
}
unordered_map<int, int> mp;
int main() {
  int n, x;
  read(n);
  int f = 1;
  for(int i = 0; i < n; ++i) {
    read(x);
    if(!f) continue;
    if(mp[x]) f = 0;
    else mp[x] = 1;
  }
  if(f) puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 8520
#
# abc120 b
#
import sys
from io import StringIO
import unittest


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

    def test_入力例_1(self):
        input = """8 12 2"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """100 50 4"""
        output = """5"""
        self.assertIO(input, output)

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


def resolve():
    A, B, K = map(int, input().split())

    n = 0
    for i in range(min(A, B), 0, -1):
        if A % i == 0 and B % i == 0:
            n += 1
            if n == K:
                print(i)
                exit


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


Measured memory_bytes: 16208
n = int(input())

def make_divisor(n):
    divisor = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisor.append(i)
            if i != n // i:
                divisor.append(n // i)
    divisor.sort()
    return divisor

div = make_divisor(n)
print(sum([s - 1 for s in div if (s - 1) ** 2 > n]))

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

#define ll long long
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define repp(i,a,b) for(int i=a;i<b;i++)
#define repm(i,a,b) for(int i=a;i>b;i--)
#define debug_interval endl
#define dump_interval ' '
#define debug_toggle 0


inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
inline int gcd(int a,int b){return a?gcd(b%a,a):b;} //Don't use C++17
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}

string s;
char m;

main(){
    ios::sync_with_stdio(false);
    cin>>s;
    sort(all(s));
    m=s.front();
    for(int i=1;i<s.size();i++){
        if(m==s[i]){
            dump("no");
            return 0;
        }
        m=s[i];
    }
    dump("yes");
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#include<unordered_map>
#define ll long long int
using namespace std;

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	int r = n % 10;
	if (r == 2 || r == 4 || r == 5 || r == 7 || r == 9)
	{
		cout << "hon";
	}
	else if (r == 3)
	{
		cout << "bon";
	}
	else
	{
		cout << "pon";
	}

	return 0;
}

Measured memory_bytes: 3624
using System;

namespace C_sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ');
            var a = int.Parse(line[0]);
            var b = int.Parse(line[1]);

            var area = a * b;
            var perimeter = 2 * (a + b);
            Console.WriteLine($"{area} {perimeter}");
        }
    }
}



Measured memory_bytes: 15984
#include<iostream>
using namespace std;
int main(){
    int n,m;
    cin >> n;
    double d;
    //d = n * 10;

    int g=0;
    for (int i = 1; i < 10; i++)
    {
        m = n / i;
        if (n % i == 0 && m <=9)
        {
            g = 1;
            break;
        }
    }
    if(g==1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

enum State {
    unseen, // 未訪問
    seen,   // 発見済み
    end     // 探索終了
};

vector<vector<int>> adj; // 隣接行列
int t = 0; // 時刻
int d[110];   // 頂点vを最初に発見した発見時刻　
int f[110];   // 頂点vの隣接リストを調べ終えた完了時刻
State s[110];

void dfs(int u) {
    ++t;
    d[u] = t;
    s[u] = State::seen;
    // uの隣接点を探索
    for (auto &v: adj[u]) {
        if (s[v] == State::unseen) {
            dfs(v);
        }
    }
    // uは探索済み
    s[u] = State::end;
    ++t;
    f[u] = t;
}

int main() {
    int n; cin >> n;
    adj.resize(n);
    rep(i, n) {
        int u, k; cin >> u >> k;
        --u;
        rep(j, k) {
            int v; cin >> v;
            --v;
            adj[i].emplace_back(v);
        }
    }

    // 初期化
    rep(i, n) {
        d[i] = INT_INF;
        f[i] = 0;
        s[i] = State::unseen;
    }

    // DFS
    rep(i, n) {
        if (s[i] == State::unseen) {
            dfs(i);
        }
    }

    // 出力
    rep(i, n) {
        cout << i+1 << ' ' << d[i] << ' ' << f[i] << endl;
    }
}



Measured memory_bytes: 3092
import java.io.*;
import java.util.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int r = sc.nextInt();
        int c = sc.nextInt();
        
        int[][] sheet = new int[r+1][c+1];
        
        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                sheet[i][j] = sc.nextInt();
            }
        }
        
        for (int i = 0; i < r; i++) {
            int tmp = 0;
            
            for (int j = 0; j < c + 1; j++) {
                if (j != c) {
                    tmp += sheet[i][j];        
                }
                else {
                    sheet[i][j] = tmp;
                }
            }
        }
        
        for (int i = 0; i < c + 1; i++) {
            int tmp = 0;
            
            for (int j = 0; j < r + 1; j++) {
                if (j != r) {
                    tmp += sheet[j][i];
                }
                else {
                    sheet[j][i] = tmp;
                }
            }
        }
        
        for (int i = 0; i < r + 1; i++) {
            for (int j = 0; j < c + 1; j++) {
                if (j != c) {
                    System.out.printf("%d ", sheet[i][j]);
                }
                else {
                    System.out.printf("%d\n", sheet[i][j]);
                }
            }
        }
    }
}

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

int main(){
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for ( int i = 0; i < N; i++) cin >> S.at(i); 
  sort(S.begin(), S.end());
  for ( int i = 0; i < N; i++) cout << S.at(i);  
}

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

namespace B___Two_Anagrams
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            var length = Math.Max(s.Length, t.Length);

            var s_arr = new string(s.OrderBy(x => x).ToArray()).PadRight(length);
            var t_arr = new string(t.OrderByDescending(x => x).ToArray()).PadRight(length);

            for (int i = 0; i < length; i++)
            {
                if (s_arr[i] != t_arr[i])
                {
                    Console.WriteLine(s_arr[i] < t_arr[i] ? "Yes" : "No");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN      
using namespace std;
const ll mod=1e9+7;
const int N=2e5+4;

int main()                  
{
    int n; scn(n);

    if(n%2==0 or n%5==0)
    pri(-1);
	else
	{
		if(n==7)
		pri(1);
		else
		{
			if(n%7==0)
			n/=7;

			n*=9;

			int cur=10,ans=1;

			while(cur%n!=1)
			{
				cur=(cur*10)%n; ans++;
			}			

			pri(ans);
		}
	}

    return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n; cin >> n;
    printf("ABC%03d\n", n);
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
S = input()

a = []
for i in range(10):
    a.append(str(i))
    
ans = 0    
s = 0
for i in a:
    for j in a:
        for k in a:
            for l in range(N):
                if S[l] == i and s == 0:
                    s = 1
                elif S[l] == j and s == 1:
                    s = 2
                elif S[l] == k and s == 2:
                    ans += 1
                    break
            s = 0
            
print(ans)

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void Solve(){
	int n,K;
	cin >> n >> K;

	vector<int> v[10];
	rep(i,0,n){
		int c,g;
		cin >> c >> g;
		--g;
		v[g].push_back(c);
	}

	rep(i,0,10) sort(v[i].rbegin(),v[i].rend());

	vector<int> s[10];
	rep(i,0,10) s[i].resize(v[i].size());
	rep(i,0,10){
		rep(j,0,s[i].size()){
			if(j==0) s[i][j]=v[i][j];
			else s[i][j]=s[i][j-1]+v[i][j]+2*j;
		}
	}

	rep(i,0,10) dump(s[i]);

	//static vector<vector<int>> dp(10,vector<int>(K));
	static int dp[10][3000];
	rep(i,0,s[0].size()) dp[0][i]=s[0][i];
	rep(i,1,10){
		rep(j,0,K){
			if(s[i].size()>j) dp[i][j]=s[i][j];
			rep(k,0,j+1){
				if((int)s[i].size()<=j-k-1) continue;
				if(j-k-1<0) dp[i][j]=max(dp[i][j],dp[i-1][k]);
				else dp[i][j]=max(dp[i][j],dp[i-1][k]+s[i][j-k-1]);
			}
		}
	}

	rep(i,0,10) dump(dp[i]);

	cout << dp[9][K-1] << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 1344
#include <stdio.h>
#include<stack>
#include<iostream>
#include<vector>
#include<algorithm>
using  namespace  std;
#define MAXN 50
int main()
{
    char s;
    stack<int> A;
    stack<pair<int,int> > B;
    int i=0,j,ans=0,a;
    while(cin>>s){
        if(s=='\\') A.push(i);
        else if(s=='/'&&!A.empty()){
            j=A.top();A.pop();
            a=i-j;
            ans+=a;
            while(!B.empty() && B.top().first>j){
                a=a+B.top().second;
                B.pop();
            }
            B.push(make_pair(j, a));
        }
        i++;
    }
    cout<<ans<<endl;
    vector<int> X;
    int z;
    z=B.size();
    for(int i =0;i<z;i++){
        X.push_back(B.top().second);
        B.pop();
    }
    cout<<X.size();
    for(int i =X.size()-1;i>=0;i--){
        cout<<" "<<X[i];
    }
    cout<<endl;
    return 0;


    
}


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

using namespace std;

int main(){
    int n,a,b,c;
    cin >> n;
    vector<vector<int>> dp(n,vector<int>(3));
    for(int t=0;t<n;t++){
        cin >> a >> b >> c;
        if(t==0){
            dp[t][0]=a;
            dp[t][1]=b;
            dp[t][2]=c;
        }
        else{
            dp[t][0]=max(dp[t-1][1],dp[t-1][2])+a;
            dp[t][1]=max(dp[t-1][0],dp[t-1][2])+b;
            dp[t][2]=max(dp[t-1][1],dp[t-1][0])+c;
        }
    }
    cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}) << '\n';
}

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

using namespace std;
int main(){
  char X;
  cin >> X;
  if (X == 'a' || X == 'i'){
    cout << "vowel" << endl;
  }
  else if (X == 'u' || X == 'e'){
    cout << "vowel" << endl;
  }
  else if (X == 'o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 200009;

ll freq[2020], arr[N];

int main() {
	fastIO;
#ifdef LOCAL
//	freopen("input.in", "rt", stdin);
#endif
	ll n, p = 2019;
//	cin >> n >> p;
	string str;
	cin >> str;
	freq[0] = 1;
	ll tmp = 1;
	n = str.size();
	for (int i = n - 1; i >= 0; --i) {
		arr[i] = (arr[i + 1] % p + ((str[i] - '0') * tmp) % p) % p;
		freq[arr[i]]++;
		tmp *= 10;
		tmp %= p;
	}
	ll ans = 0;
	for (int i = 0; i < 2019; ++i)
		ans += freq[i] * (freq[i] - 1) / 2;
	cout << ans;
	return 0;
}


Measured memory_bytes: 5304
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 110;
const int MAXK = 510;

string s, t;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> s;
    t = s;
    int n = SZ(s);

    FOR(i,0,n-1)
        if (i % 2) t[i] = '1';
        else t[i] = '0';
    
    int res = 0, cnt = 0;
    FOR(i,0,n-1)
        if (s[i] != t[i]) cnt++;
    res = cnt;

    FOR(i,0,n-1)
        if (i % 2) t[i] = '0';
        else t[i] = '1';

    cnt = 0;
    FOR(i,0,n-1)
        if (s[i] != t[i]) cnt++;
    res = min(res, cnt);
    cout << res;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MOD=1e9+7;
int n,m;
int Res;
int calc(int x){
    int r=1;
    for(int i=2;i<x+1;i++){
        r=((LL)r*i)%MOD;
    }
    return r;
}
int main()
{
    scanf("%d %d",&n,&m);
    if(abs(n-m)>1){
        printf("0");
        return 0;
    }
    Res=((LL)calc(n)*calc(m))%MOD;
    if(n==m){
        Res=((LL)Res*2)%MOD;
        printf("%d",Res);
        return 0;
    }
    printf("%d",Res);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int A,B,C;
    cin >> A>>B>>C;
    if(C-(A-B)<0)cout<<0<<endl;
    else cout<<C-(A-B)<<endl;
}

Measured memory_bytes: 256
i = int(input())
moji_list = ['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']
ans = []

while(i > 0):
    i -= 1
    ans.append(moji_list[i % 26])
    i //= 26

print(''.join(reversed(ans)))

Measured memory_bytes: 9196
import numpy as np
import itertools
 
H, W, K = list(map(int, input().split())) 
c = [input().split() for l in range(H)]
b=[]
d=[]
for m in range(len(c)):
  for item in c[m]:
    item_mod = item.replace("."  , "0")
    item_mod = item_mod.replace("#" , "1")
    item_mod = list(item_mod)
    b.append(item_mod)
  d.append(b)
  b=[]

C_arr = np.array(d , dtype = "int")
C_arr = C_arr.reshape((H, W))
 
In = np.array(list(itertools.product([0,1] , repeat=H)))
Out = np.array(list(itertools.product([0,1] , repeat=W)))
 
ans = 0
for i in range(2**H):
  for j in range(2**W):
    In_matrix = np.diag(In[i])
    Out_matrix = np.diag(Out[j])
 
    In_C = np.dot(In_matrix , C_arr)
    In_C_Out = np.dot(In_C , Out_matrix)
 
    ICO = In_C_Out.flatten()
    ICO = ICO.tolist()
 
    if ICO.count(1) == K:
      ans += 1
      
print(ans)

Measured memory_bytes: 27236
//
//  main.cpp
//  countest
//
//  Created by Reza Godarzi on 11/29/1397 AP.
//  Copyright © 1397 w. All rights reserved.
//
#include <iostream>
#include <set>
#include<math.h>
#include <algorithm>
#include <vector>
#define ll long long
using namespace std ;
const ll N=1e5+10;
#define needforspeed   ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
int main(){
    needforspeed;
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<min(b,c)<<" ";
    if(a>=b+c){
        cout<<"0";
    }else{
        cout<<(b+c)-a;
    }
    
    
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <map>
#include <fstream>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define INF 1e9 
typedef long long ll;
typedef long double ld;
int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> v(h,vector<char>(w));
    REP(i,h)REP(j,w)cin>>v[i][j];
    REP(i,h){
        REP(j,w){
            cout<<v[i][j];
        }
        cout<<endl;
        REP(j,w){
            cout<<v[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3628
<?php
fscanf(STDIN, "%s", $S);
$n = strlen($S);
$dp[0][0] = 0;
for ($i = 0; $i < $n; $i++) {
  $c1 = $c2 = '';
  // 1文字取る
  $c1 = substr($S, $i, 1);
  foreach ($dp[$i] as $k => $v) {
      if (substr($S, $i - $k, $k) !== $c1) {
          if (!isset($dp[$i + 1][1])) {
            $dp[$i + 1][1] = $v + 1;
          } else {
            $dp[$i + 1][1] = max($dp[$i + 1][1], $v + 1);
          }
      }
  }
  if ($i > 0) {
    // 2文字取る
    $c2 = substr($S, $i - 1, 2);
    foreach ($dp[$i - 1] as $k => $v) {
      if (substr($S, $i - $k, $k) !== $c2) {
        if (!isset($dp[$i + 1][2])) {
          $dp[$i + 1][2] = $v + 1;
        } else {
          $dp[$i + 1][2] = max($dp[$i + 1][2], $v + 1);
        }
      }
    }
  }
}
printf("%d", max($dp[$n]));


Measured memory_bytes: 86512
from collections import deque

def main():
    INF = float('inf')

    N, M = (int(x) for x in input().split())
    root = [[] for _ in range(N+1)]
    for i in range(M):
        A,B = (int(x) for x in input().split())
        root[A].append(B)
        root[B].append(A)
    dist = [INF] * (N+1)
    dist[1] = 0
    q = deque([1])

    while q:
        v = q.popleft()
        for r in root[v]:
            if dist[r] == INF:
                dist[r] = v
                q.append(r)
    print('Yes')
    for d in dist[2:]:
        print(d)

if __name__ == '__main__':
    main()

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

struct Point{
	double x,y;
	Point(double _x=0,double _y=0):x(_x),y(_y){}
	Point operator-(const Point & p)const{
		return Point(x-p.x,y-p.y);
	}
	double xx(const Point &p){//返回叉积
		return x*p.y-y*p.x;
	}
	double len(){//返回长度的平方
		return x*x+y*y;
	}
}p[1000010];
struct Cir{
	Point o;
	double r;//半径的平方
};
int n;

Cir p3c(Point p1,Point p2,Point p3)//三点得圆
{
	if(std::abs((p1-p3).xx(p2-p3))<1e-12)//换成给直径求圆
	{
		double l[3]={(p3-p2).len(),(p1-p3).len(),(p1-p2).len()};
		if(l[0]>=l[1]&&l[0]>=l[2])
			return (Cir){Point((p3.x+p2.x)/2,(p3.y+p2.y)/2),l[0]/4};
		if(l[1]>=l[0]&&l[1]>=l[2])
			return (Cir){Point((p3.x+p1.x)/2,(p3.y+p1.y)/2),l[1]/4};
		if(l[2]>=l[1]&&l[2]>=l[0])
			return (Cir){Point((p1.x+p2.x)/2,(p1.y+p2.y)/2),l[2]/4};
	}
	double a=(p1.x-p3.x),b=(p1.y-p3.y),c=(p1.x*p1.x+p1.y*p1.y-p3.x*p3.x-p3.y*p3.y)/2;//ax+by=c
	double d=(p2.x-p3.x),e=(p2.y-p3.y),f=(p2.x*p2.x+p2.y*p2.y-p3.x*p3.x-p3.y*p3.y)/2;//dx+ey=f
	double x=(c*e-b*f)/(a*e-b*d),y=(a*f-c*d)/(a*e-b*d);
	double r=(x-p1.x)*(x-p1.x)+(y-p1.y)*(y-p1.y);
	return (Cir){Point(x,y),r};
}

int main()
{
	// freopen("test.in","r",stdin);
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%lf%lf",&p[i].x,&p[i].y);
	std::random_shuffle(p,p+n);
	Cir ans={p[0],0};

	for(int i=1;i<n;i++)
	{
		if((p[i]-ans.o).len()>ans.r+1e-7)
		{
			ans=(Cir){p[i],0};
			for(int j=0;j<i;j++)
			{
				if((p[j]-ans.o).len()>ans.r+1e-7)
				{
					ans=(Cir){Point((p[i].x+p[j].x)/2,(p[i].y+p[j].y)/2),(p[i]-p[j]).len()/4};
					for(int k=0;k<j;k++)
					{
						if((p[k]-ans.o).len()>ans.r+1e-7)
							ans=p3c(p[i],p[j],p[k]);
					}
				}
			}
		}
	}
	printf("%.10lf\n",sqrt(ans.r));
	return 0;
}


Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    double sum=0;
    cin>>n;
    int arr[n];
    int i;
    for(i=0;i<n;i++)
    cin>>arr[i];
    for(i=0;i<n;i++){
        sum+=1*1.0/arr[i];
    }
    cout<<1*1.0/sum<<endl;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,S;
string s;
map<pair<string,string>,ll> mp;

int main(){
	cin>>n>>s;
	S=1<<n;
	for(int i=0;i<S;i++){
		string A,B;
		for(int j=0;j<n;j++){
			if(i&1<<j) A+=s[n+j];
			else B+=s[n+j];
		}
		mp[{A,B}]++;
	}
	ll t=0;
	for(int i=0;i<S;i++){
		string A,B;
		for(int j=0;j<n;j++){
			if(i&1<<j) A+=s[j];
			else B+=s[j];
		}
		reverse(A.begin(),A.end());
		reverse(B.begin(),B.end());
		t+=mp[{B,A}];
	}
	cout<<t<<endl;
}

Measured memory_bytes: 87040
//It doesn't matter as long as you rise to the top - Katsuki Bakugo
#include<bits/stdc++.h>
using namespace std;
     
     
#define Fast_as_duck ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define rev(i,st,n) for(int i = st; i >= n ; i--)
#define ss second
#define ff first
#define ll long long 

typedef pair <int , int> pii;

const int N = 1e5 + 10 , mod =  1000000007;

void solve(){

    int num; cin >> num;
    
    forn(n,1,num+1){

        int ans = 0;

        forn(x,1,sqrt(n)){
            forn(y,1,sqrt(n)){

                ll c = (ll)n - x*x - y*y - x*y;
                ll b = (x+y);
                ll d = b*b + 4*c;
                ll rootd = sqrt(d);
                if(rootd * rootd != d){
                    continue;
                }
                if(rootd > b && (rootd-b)%2 == 0)ans++;
                // forn(z,1,n){
                //     if(x*x + y*y + z*z + x*y + y*z + z*x == n ){
                //         ans++;
                //     }
                //     if(x*x + y*y + z*z + x*y + y*z + z*x > n ){
                //         break;
                //     }

                // }
            }
        }

    
        cout << ans << "\n";
        
    }

}

int main(){
    Fast_as_duck;

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
*/
    int t = 1; 
    
    // cin >> t;
    

    while(t--){
        solve();
    }




    return 0;
}
      
       


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

#define Bye return 0
#define ll long long
const ll MAX = 3e3+1;
int a[MAX];

void solve(){
    double d, t, s; cin>>d>>t>>s;
    double div = d/s;
    cout<<(div<=t ? "Yes":"No")<<endl;
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
bool dp[1100000];
int main()
{
	dp[0]=1;
	for(int i=1;i<=1000100;i++){
		if(i<100)continue;
		if(dp[i-100]==1)dp[i]=1;
		if(i<101)continue;
		if(dp[i-101]==1)dp[i]=1;
		if(i<102)continue;
		if(dp[i-102]==1)dp[i]=1;
		if(i<103)continue;
		if(dp[i-103]==1)dp[i]=1;
		if(i<104)continue;
		if(dp[i-104]==1)dp[i]=1;
		if(i<105)continue;
		if(dp[i-105]==1)dp[i]=1;
	}
	int x;cin>>x;
	cout<<dp[x];
	return 0;
}

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

int main() {
int N;
cin >> N;
  
string A, B, C;
cin >> A >> B >> C;
  
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(A.at(i) == B.at(i) && A.at(i) == C.at(i) && B.at(i) == C.at(i))continue;
    else if(A.at(i) != B.at(i) && A.at(i) != C.at(i) && B.at(i) != C.at(i))ans += 2;
    else ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define frr(j,i,n) for(int i=j;i<=n;++i)
using namespace std;
int n;
int a[100005],b[100005],c[100005];
ll dp[100005][2][2][2];
ll go(int index,int A,int B,int C)
{
    if(index>n)
        return 0;
    if(dp[index][A][B][C]!=-1)
        return dp[index][A][B][C];
    ll x=0,y=0,z=0;
    if(A)
        x=a[index]+go(index+1,0,1,1);
    if(B)
        y=b[index]+go(index+1,1,0,1);
    if(C)
        z=c[index]+go(index+1,1,1,0);
    
    return dp[index][A][B][C]= max(x,max(y,z));
    
}

void solve()
{
    memset(dp,-1,sizeof(dp));
	cin>>n;
    frr(1,i,n)
    {
        cin>>a[i];
        cin>>b[i];
        cin>>c[i];
    }
    cout<<go(1,1,1,1);
}
int main() 
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--)
	solve();
	return 0;
}



Measured memory_bytes: 18812
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(int i=(int)(x);i<(int)(y);i++)
#define RREP(i,x,y) for(int i=(int)(x);i>(int)(y);i--)
#define all(x) (x).begin(),(x).end()

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

typedef long long ll;

using namespace std;

int N;

int sum(int a, int b) {
    int sum = 0;

    string as = to_string(a);
    string bs = to_string(b);

    REP(i,0,as.length()) {
        sum += as[i] - '0';
    }

    REP(i,0,bs.length()) {
        sum += bs[i] - '0';
    }

    return sum;
}

void solve() {
    int answer = 10000;

    REP(i,1,N/2+1) {
        int a = i;
        int b = N - i;

        answer = min(sum(a, b), answer);
    }

    printf("%d\n", answer);
    return;
}

int main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    solve();
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll ans = 0;
    int carry = 0;
    bool five = false;

    for (ll l = s.size() - 1; l >= 0; l--) {
        int c = s[l] - '0' + carry;
        if (c == 10) {
            carry = 1;
            // no change in ans
            five = false;
        } else if (c == 0) {
            carry = 0;
            // do nothing
            five = false;
        } else if (c < 5) {
            carry = 0;
            ans += c;
            five = false;
        } else if (c == 5) {
            if (five == true) {
                carry = 1;
                ans += 4;
                five = false;
            } else {
                carry = 0;
                ans += c;
                five = true;
            }
        } else if (five == true) {
            // c=6..9
            carry = 1;
            ans += (10 - c - 1);
            five = false;
        } else {
            // c=6..9
            carry = 1;
            ans += (10 - c);
            five = false;
        }
    }
    ans += carry;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1948
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define F first;
#define S second;
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i = a; i <= b; i++)
#define SQ(a) (a)*(a);

/*void print_v(vector<int> v){
    for (int i = 0; i < v.size() ; ++i) {
        printf("%d ",v[i]);
    }
    printf("\n");
}*/

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

    int n;
    scanf("%d", &n);

    vector<int> dp(3);
    for (int day = 0; day < n ; ++day) {
        vector<int> new_dp(3,0);
        vector<int> c(3);

        for (int i = 0; i < 3; ++i) {
            scanf("%d",&c[i]);
        }

        for (int i = 0; i < 3 ; ++i) {
            for (int j = 0; j < 3 ; ++j) {
                if(i != j){
                    new_dp[j] = max(new_dp[j],dp[i] + c[j]);
                }
            }

        }
        dp = new_dp;
    }

    printf("%d",max({dp[0],dp[1],dp[2]}));

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std; 
int main(){
	int S; 
	cin >> S; 
	int A[1000020] = {}; 
	A[1] = S; 
	for(int i = 2; i <= 1000010; i++){
		if(A[i-1] % 2 == 1) A[i] = 3 * A[i-1] + 1; 
		else A[i] = A[i-1]/2; 
	}
	for(int i = 4; i <= 1000005; i++){
		if(A[i] == A[i-3]){
			cout << i << endl; 
			break; 
		}
	}
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std ;
 int  main()
 {
     int n;
     cin>>n;
     long long int a[n]; int f=0;
     for(int i=0;i<n;i++)
     {
         cin>>a[i];
        
     } int x=a[n-1];
    for(int i=n-2;i>=0;i--)
    {
        if(a[i]<=x)
        x=a[i];
        else
        {
            if(a[i]-x>1)
            f=1;
        }
    }
     if(f==1)
     cout<<"No"<<endl;
     else
     cout<<"Yes"<<endl;
   
 }

Measured memory_bytes: 1024