akhauriyash/Code-Regression huggingface dataset:
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = rl();
    let ok = N.contains('7');
    println!("{}", if ok { "Yes" } else { "No" })
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;

int main(){
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    rep(i,N){
        cin >> S[i];
    }
    sort(all(S));
    rep(i,N){
        cout << S[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 1; i <= n; i++) {
			int x = i;
			if (x % 3 == 0) {
				System.out.print(" " + i);
			} else {
				while (x > 0) {
					if (x % 10 == 3) {
						System.out.print(" " + i);
						break;
					} else {
						x /= 10;
					}
				}
			}
		}
		System.out.println();
		sc.close();
	}

}


Measured memory_bytes: 28564
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define all(a) begin(a), end(a)
#define sz(a) (int)(a.size())
#define deb(a) cout << #a << ": " << a << ENDL
#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli> ii;
typedef vector<lli> vi;

const int MAX = 1e5 + 5;

lli MOD = 1e9 + 7;

int main()
{   _

    lli n, k; cin >> n >> k;
    vi v(n); fore(i, 0, n) cin >> v[i];
    reverse(all(v));
    vector<vector<lli>> dp(n, vector<lli>(MAX, 0));
    fore(i, 0, v[0] + 1) dp[0][i] = 1;
    fore(i, 1, n) {
        lli acum = 0;
        fore(j, 0, MAX) {
            acum = (acum + dp[i - 1][j]) % MOD;
            if(j >= v[i] + 1) acum = (MOD + acum - dp[i -1][j - v[i] - 1]) % MOD;
            dp[i][j] = acum;
        }
    }
    cout << dp[n - 1][k] << ENDL;
    return 0;
}


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

int main(){
    stack<int>st;
    int x;
    while(cin >> x){
        if(x==0){
            cout << st.top() <<endl;
            st.pop();
        }else{
            st.push (x);
        }
    }    
    return 0;
}

Measured memory_bytes: 2972
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

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

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);

    int n;
    ll ans=0,z=0,sum=0,x=0;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>arr[i];
    for(int i=0; i<n; i++)
    {
        int pos=i+1;
        sum=arr[i];
        x=arr[i];
        z=1;
        if(arr[i]==0)
        {
            ll zero=1;
            int nxt=i;
            while(pos<n && arr[pos]==0)
            {
                nxt=pos;
                zero++;
                pos++;
            }
            z=0;
            while((pos<n && arr[pos]==0)|| (pos<n && (sum+arr[pos])==(x^arr[pos])))
            {
                z++;
                sum+=arr[pos];
                x^=arr[pos];
                pos++;
            }
            ans+=((zero*(zero+1))/2)+(z*zero);
            i=nxt;

        }
        else
        {
            while((pos<n && arr[pos]==0)|| (pos<n && (sum+arr[pos])==(x^arr[pos])))
            {
                z++;
                sum+=arr[pos];
                x^=arr[pos];
                pos++;
            }
            ans+=z;
        }

    }
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 4432
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

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

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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    string ans = "second";
    for (i64 i = 0; i < n; i++) {
        i64 a;
        cin >> a;
        if (a % 2 != 0) ans = "first";
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
package main

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

func solve() {
	n := getInt()
	vs := getIntSlice(n)

	m0, m1 := make(map[int]int), make(map[int]int)
	for i, v := range vs {
		if i%2 == 0 {
			m0[v]++
		} else {
			m1[v]++
		}
	}

	f := func(m map[int]int) (int, int, int) {
		var fNum, fCnt, sCnt int
		for k, v := range m {
			switch {
			case v > fCnt:
				sCnt = fCnt
				fNum = k
				fCnt = v
			case v > sCnt:
				sCnt = v
			}
		}
		return fNum, fCnt, sCnt
	}

	fNum0, fCnt0, sCnt0 := f(m0)
	fNum1, fCnt1, sCnt1 := f(m1)

	ans := n - (fCnt0 + fCnt1)
	if fNum0 == fNum1 {
		ans = n - max(fCnt0+sCnt1, sCnt0+fCnt1)
	}
	fmt.Fprintln(wr, ans)
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 7296
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        NotsoDiverse solver = new NotsoDiverse();
        solver.solve(1, in, out);
        out.close();
    }

    static class NotsoDiverse {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();

            int[] a = new int[n + 1];
            for (int i = 0; i < n; i++) {
                int aa = in.nextInt();
                a[aa]++;
            }

            int total = 0;
            PriorityQueue<Integer> pq = new PriorityQueue<>(n, Integer::compare);
            for (int i = 1; i <= n; i++) {
                if (a[i] > 0) {
                    pq.add(a[i]);
                    total++;
                }
            }
            int diff = total - k;
            if (diff <= 0) {
                out.print(0);
                return;
            }
            long result = 0;
            while (diff > 0) {
                Integer count = pq.poll();
                diff--;
                result += count;
            }
            out.print(result);

        }

    }
}



Measured memory_bytes: 60552
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1 << 30;
vector<int> to[2020];
int n,x,y;
int ans[2020];

void bfs(int i){
    vector<int> dist(n,INF);
    dist[i] = 0;
    queue<int> q;
    q.push(i);
    while(!q.empty()){
        int v = q.front(); q.pop();
        for(auto tv : to[v]){
            if(dist[tv]!=INF) continue;
            dist[tv] = dist[v]+1;
            ans[dist[tv]]++;
            q.push(tv);
        }
    }
    
}

int main(){
    cin >> n >> x >> y;
    x--; y--;
    rep(i,n-1) {
        to[i].push_back(i+1);
        to[i+1].push_back(i);
    }
    to[x].push_back(y);
    to[y].push_back(x);
    rep(i,n){
        bfs(i);
    }
    for(int i=1; i<=n-1; i++){
        cout << ans[i]/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

ll calc(int x, int y)
{
    ll ans = INF;

    reple(i, 1, x - 1)
    {
        {
            ll h = ((ll)x - (ll)i);
            vll v(3);
            v[0] = (ll)y * (ll)i;
            v[1] = (ll)y * (h / 2);
            v[2] = (ll)y * (h / 2 + h % 2);
            chmin(ans, *max_element(all(v)) - *min_element(all(v)));
        }

        {
            ll h = ((ll)x - (ll)i);
            vll v(3);
            v[0] = (ll)i * (ll)y;
            v[1] = (ll)h * ((ll)y / 2);
            v[2] = (ll)h * ((ll)y / 2 + (ll)y % 2);
            chmin(ans, *max_element(all(v)) - *min_element(all(v)));
        }
    }

    return ans;
}

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

    int H, W;
    cin >> H >> W;

    ll ans = INF;
    chmin(ans, calc(H, W));
    chmin(ans, calc(W, H));

    cout << ans << endl;

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long int lli;
typedef long long ll;


int main(){
  int n; cin >> n;
  vector<string> w(n); rep(i,n) cin >> w[i];

  map<string,int> exist;

  vector<string> out = {"Yes","No"};
  int ans = 0;
  char c;
  rep(i,n){
    if(exist[w[i]] == 0){
      exist[w[i]]++;
      if(i == 0) c = w[i].back();
      else if(w[i].front() == c) c = w[i].back();
      else{
        ans = 1;
        break;
      }
    }
    else{
      ans = 1;
      break;
    }
  }

  cout << out[ans] << endl;
}


Measured memory_bytes: 256
table = [0] * (10**5 + 100)

for i in range(2,10**5 + 100):
    if i != 1:
        for j in range(i * 2,10**5 + 100,i):
            table[j] = 1

n = int(input())

while True:
    if table[n] == 0:
        break
    else:
        n += 1

print(n)

Measured memory_bytes: 9500
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

bool p[100001];
int main()
{
	ll n; cin >> n;

	ll maxV = 100000;
	rep(i, 0, maxV)p[i] = true;
	p[0] = false;
	p[1] = false;

	for (int i = 2; i*i <= maxV; i++) {
		if (!p[i])continue;
		for (int j = 2; i*j <= maxV; j++) {
			if (i*j <= maxV) {
				p[i*j] = false;
			}
		}
	}

	rep(i, 0, maxV) {
		if (p[i] && i % 10 == 1) {
			cout << i;
			n--;

			if (n != 0)cout << " ";

			if (n == 0) {
				break;
			}
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	long long N,M;
	cin>>N>>M;
	
	if(N>=2&&M>=2){
		cout<<(N-2)*(M-2)<<endl;
	}
	else{
		if(N==1&&M==1){
			cout<<1<<endl;
		}
		else{
			cout<<max(N,M)-2<<endl;
		}
	}
		
    return 0;
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N =int(input())

div = make_divisors(N)
L = len(div)

if L % 2 == 0:
    if div[L//2] - div[L//2-1] == 1:
        print(sum(div[L//2+1:])-L//2+1)
    else:
        print(sum(div[L//2:])-L//2)
else:
    print(sum(div[L//2+1:])-L//2)


Measured memory_bytes: 3316
class PERM_COMB_MOD():
    # http://drken1215.hatenablog.com/entry/2018/06/08/210000
    def __init__(self, max_n=510000, mod=10**9+7):
        self.fac = [0]*max_n
        self.finv = [0]*max_n
        self.inv = [0]*max_n
        self.fac[0] = self.fac[1] = 1
        self.finv[0] = self.finv[1] = 1
        self.inv[1] = 1
        self.max = max_n
        self.mod = mod
        self._maesyori()

    def _maesyori(self):
        for i in range(2,self.max):
            self.fac[i] = self.fac[i-1] * i % self.mod
            self.inv[i] = self.mod - self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.finv[i] = self.finv[i-1] * self.inv[i] % self.mod

    def comb(self, n, k):
        if n < k : return 0
        if n < 0 or k < 0:return 0
        return self.fac[n] * (self.finv[k] * self.finv[n-k] % self.mod) % self.mod

mod = 10**9+7
n,a,b,c = map(int, input().split())

a,b = a*pow(a+b, mod-2, mod)%mod, b*pow(a+b, mod-2, mod)%mod
pc = 100*pow(100-c, mod-2, mod)%mod

comb_mod = PERM_COMB_MOD()

ans = 0
for k in range(n, 2*n):
    ans += comb_mod.comb(k-1, n-1) * (pow(a,n,mod)*pow(b,k-n,mod) + pow(a,k-n,mod)*pow(b,n,mod)) * k * pc
    ans %= mod
print(ans)

Measured memory_bytes: 53100
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
int dcnt[2000009],mcnt[2000009],ccnt[2000009],qu[100];
int main(){
	int n,q;
	string s;
	cin>>n;
	cin>>s;
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>qu[i];
	}
	for(int i=1;i<=2*n;i++){
		dcnt[i]=dcnt[i-1];
		mcnt[i]=mcnt[i-1];
		ccnt[i]=ccnt[i-1];
		if(i<n && s[i-1]=='D')dcnt[i]++;
		if(i<n && s[i-1]=='M')mcnt[i]++;
		if(i<n && s[i-1]=='C')ccnt[i]++;
	}
	for(int i=0;i<q;i++){
		ll k = qu[i];
		ll ans = 0;
		ll dmcn = 0;
		for(int j=0;j<n;j++){
			if(j>=k && s[(j-k)]=='D'){
				dmcn -= mcnt[j]-mcnt[j-k+1];
			}
			if(s[j]=='M'){
				dmcn += dcnt[max((ll)j,(ll)0)]-dcnt[max((ll)(j-k+1),(ll)0)];
				//cout<<dcnt[max((ll)j,(ll)0)]-dcnt[max((ll)(j-k),(ll)0)]<<endl;
			}
			if(s[j]=='C'){
				ans += dmcn;
				//cout<<k<<":"<<dmcn<<endl;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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


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

	vector<int> p;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		p.push_back(a);
	}
	sort(p.begin(), p.end());
	cout << p[(p.size()-1)/2+1] - p[(p.size()-1)/2] << endl;

	return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;

int main(void){
  ll K,n=100000,ans=0;
  scanf("%lld",&K);
  ll q[n];
  for(ll i=0;i<=8;i++) q[i]=i+1;
  ll head=0,tail=8,tmp=0,flag=0;
  while(K>0){
    ans=q[head];
    head=(head+1)%n;
    tmp=ans%10;
    if(flag==0){
    if(tmp>0){
      tail=(tail+1)%n;
      q[tail]=10*ans+tmp-1;
    }
    tail=(tail+1)%n;
    q[tail]=10*ans+tmp;
    if(tmp<9){
      tail=(tail+1)%n;
      q[tail]=10*ans+tmp+1;
    }
    if(tail<8) flag=1;
    }
    K--;
  }
  printf("%lld",ans);
  
}

Measured memory_bytes: 896
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define rg register
#define f(i,a,b) for(rg int i=a;i<=b;++i)
#define df(i,a,b) for(rg int i=a;i>=b;++i)
#define F(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
using namespace std;
template <typename T> inline void cmax(T &a,T b) {a=a>b?a:b;}
template <typename T> inline void cmin(T &a,T b) {a=a<b?a:b;}
template <typename T> inline void read(T &n) {
	n=0;rg char ch;while(!isdigit(ch=getchar()));
	for(n=ch^48;isdigit(ch=getchar());n=n*10+(ch^48));
}
typedef long long ll;
ll n,ans,m,t=5;
int yy(int x) {int s=0;while(x){if(x%10)x=0;else ++s,x/=10;}return s;}
signed main() {
	cin>>n;
	if(n&1) cout<<0;
	else {
		ans=n/=10;
		while(n) {
			ans+=n/5;
			n/=5;
		}
		cout<<ans;
	}
}


Measured memory_bytes: 256
w[25],i;main(d){for(;i<9;i++){if(i&1)for(d=0;d<5;d++)getchar()-48?w[i/2*5+d]|=2,w[i/2*5+d+5]|=8:0;else for(d=0;d<4;d++)getchar()-48?w[i/2*5+d]|=1,w[i/2*5-~d]|=4:0;getchar();}d=!putchar(82);for(i=1;d|i;d&=3)w[i]&1<<d?i+="GKEA"[d]-70,putchar("RDLU"[d]),w[i]&1<<(d+3&3)&&--d:++d;i=!puts("");}

Measured memory_bytes: 0
#include <cstdio>
#include <cmath>
using namespace std;
#define PI 3.141592653

double to_radian(int angle) {
  return double(angle) * PI / 180.0;
}

int main() {
  int len,angle;
  double x,y,rad;
  x = y = 0.0;
  rad = to_radian(90);
  while(scanf("%d,%d",&len,&angle)) {
    if((len | angle) == 0) break;
    x += len * cos(rad);
    y += len * sin(rad);
    rad = rad - to_radian(angle);
  }
  printf("%d\n%d\n",int(x),int(y));
}

Measured memory_bytes: 1032
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		ll n;
		cin >> n;
		ll x = ceil((double)n/(double)1000);
		//cerr << imie(x);
		ll res = (1000*x)-n;
		cout << res << endl;
		return 0;  
}  


Measured memory_bytes: 3784
/*
  GOOD is not Enough
  You've got to be GREAT.
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define pii pair<int,int>
#define dbg(x) cout << (#x) << " is " << (x) << '\n' 
#define F first
#define S second
#define all(a) a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

vector<int> v[100005];
int vis[100005],d[100005];

void bfs(int x)
{
  queue<int> q;
  vis[x]=1;
  q.push(x);
  while(!q.empty())
  {
    int p=q.front();
    q.pop();
    for(auto u:v[p])
      if(!vis[u])
      {
        d[u]=p;
        q.push(u);vis[u]=1;
      }
  }
}

void solve()
{
  int n,m;
  cin >> n >> m;
  fp(i,2,n)
    d[i]=mod;
  while(m--)
  {
    int x,y;
    cin >> x >> y;
    v[x].pb(y);
    v[y].pb(x);
  }
  bfs(1);
  fp(i,2,n)
  {
    if(d[i]==mod)
      {
        cout << "No\n";return;
      }
  }
  cout << "Yes\n";
  fp(i,2,n)
    cout << d[i] << '\n';
  return;
} 

signed main()
{
  FAST
  int T=1;
  // cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 13808
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int main(){
    ll s; cin >> s;
    ll div = 1e9;
    ll y2 = (s + div - 1) / div;
    ll y1 = div * y2 - s;
    cout << 0 << " " << 0 << " " << div << " " << y1 << " " << 1 << " " << y2 << endl;
}

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

using namespace std;

typedef long long ll;

struct P {
  int T, X, Y, W, H;
  P(int T=0, int X=0, int Y=0, int W=0, int H=0) : T(T), X(X), Y(Y), W(W), H(H) {}
  bool operator<(const P& p) const {
    if (T != p.T) return T < p.T;
    return W * H < p.W * p.H;
  }
  pair<P, P> cut(int s, int t){
    T = t;
    s %= 2 * W + 2 * H;
    assert(s != 0);
    assert(s != W);
    assert(s != W + H);
    assert(s != W + W + H);
    if (s < W) {
      return make_pair(P(t, X, Y, s, H), P(t, X + s, Y, W - s, H));
    }
    if (s < W + H){
      s -= W;
      return make_pair(P(t, X, Y, W, s), P(t, X, Y + s, W, H - s));
    }
    if (s < W + W + H){
      s = W - (s - (W + H));
      return make_pair(P(t, X, Y, s, H), P(t, X + s, Y, W - s, H));
    }
    if (s < W + W + H + H){
      s = H - (s - (W + W + H));
      return make_pair(P(t, X, Y, W, s), P(t, X, Y + s, W, H - s));
    }
    assert(0);
  }
};

int main()
{
  int N, W, D;
  while (cin >> N >> W >> D, W){
    vector<P> V;
    V.push_back(P(0, 0, 0, W, D));
    for (int i = 0; i < N; i++){
      int p, s;
      cin >> p >> s;
      p--;
      pair<P, P> npp = V[p].cut(s, i + 1);
      V[p] = npp.first;
      V.push_back(npp.second);
      sort(V.begin(), V.end());
    }
    sort(V.begin(), V.end(), [](const P& a, const P& b){ return a.W * a.H < b.W * b.H; });
    for (int i = 0; i <= N; i++){
      if (i) printf(" ");
      printf("%d", V[i].W * V[i].H);
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
//#define pdd pair<double,double>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-8
#define mii map<int,int>
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define N 500005
//#define M 1000005
#define pi 3.14159265359
#define cpdd const pdd
#define hash Hash
#define list List
using namespace std;
typedef long long LL;
using namespace std;
char c[200005];
int main(){
	scanf("%s",c+1);
	int n=strlen(c+1);
	LL ans=(LL)n*(n+1)/2;
	int cnt[30];
	MEM(cnt);
	for(int i=1;c[i]!=0;i++){
		cnt[c[i]-'a']++;
	} 
//	printf("%lld\n",ans);
	for(int i=0;i<26;i++){
		ans-=(LL)cnt[i]*(cnt[i]+1)/2;
	}
	printf("%lld\n",ans+1);
}

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

void solve(){
	
	int n ;
	cin>>n ;

	int arr[n][3] ;

	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin>>arr[i][j] ;
		}
	}


	int dp[n][3] ;

	memset(dp,0,sizeof(dp)) ;

	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){

			if(i==0)
				dp[i][j]=arr[i][j] ;
			else{

				if(j==0)
					dp[i][j]=max(dp[i-1][j+1],dp[i-1][j+2])+arr[i][j] ;
				else if(j==1)
					dp[i][j]=max(dp[i-1][j-1],dp[i-1][j+1])+arr[i][j] ;
				else
					dp[i][j]=max(dp[i-1][j-2],dp[i-1][j-1])+arr[i][j] ;

			}
		}
	}

	int mx=-1 ;
	for(int i=0;i<3;i++){
		mx=max(mx,dp[n-1][i]) ;
	} 	
	
	cout<<mx ;
}

int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

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

}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    string s;
    cin >> s;
    ll n;
    cin >> n;
    repi(i, n, 0)
    {
        string op;
        cin >> op;
        if (op == "print")
        {
            ll a, b;
            cin >> a >> b;
            cout << s.substr(a, b - a + 1) << endl;
        }
        else if (op == "reverse")
        {
            ll a, b;
            cin >> a >> b;
            reverse(s.begin() + a, s.begin() + b + 1);
        }
        else if (op == "replace")
        {
            ll a, b;
            string tmp;
            cin >> a >> b >> tmp;
            repi(i, b + 1, a)
            {
                s.at(i) = tmp.at(i - a);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3236
X=int(input())
sut=9-7
fri=9-1-7  
thu=9-2-7
wed=9-3
tue=9-4
mon=9-5
sun=9-6
if X==sut or X==sut+7 or X==sut+7*2 or X==sut+7*3 or X==sut+7*4:
  print("sat")
if X==fri or X==fri+7 or X==fri+7*2 or X==fri+7*3 or X==fri+7*4:
  print("fri")
if X==thu+7 or X==thu+7*2 or X==thu+7*3 or X==thu+7*4:
  print("thu")
if X==wed or X==wed+7 or X==wed+7*2 or X==wed+7*3:
  print("wed")
if X==tue or X==tue+7 or X==tue+7*2 or X==tue+7*3:
  print("tue")
if X==mon or X==mon+7 or X==mon+7*2 or X==mon+7*3:
  print("mon")
if X==sun or X==sun+7 or X==sun+7*2 or X==sun+7*3:
  print("sun")


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int A[2][2000];
    
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < N; j++) {
            cin >> A[i][j];
        }
    }

    int dp[2][N];
    dp[0][0] = A[0][0];
    dp[1][0] = A[0][0] +A[1][0];

    for (int i = 1; i < N; i++) {
        dp[0][i] = dp[0][i-1] + A[0][i];
        dp[1][i] = max(dp[1][i-1], dp[0][i]) + A[1][i];
    }
    
    cout << dp[1][N-1] << endl;
}

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

using namespace std;

// input
int a,b;

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

    cin >> a >> b;

    if(a%3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
        cout << "Possible" << "\n";
    }
    else{
        cout << "Impossible" << "\n";
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
  	ll a;
	double b;
	cin >> a >> b;
  	ll temp = b*100+0.1;
	ll ans = a*temp/100;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

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

    vector<int> H;

    for (int i = 0; i < N; i++)
    {
        int h;
        cin >> h;
        H.push_back(h);
    }

    int count = 0;
    int tmp = 0;

    for (int i = 0; i < N; i++)
    {
        if (tmp <= H[i])
        {
            count += 1;
        }
        tmp = max(tmp, H[i]);
    }
    cout << count << endl;
}

Measured memory_bytes: 256
from sys import stdin


def main():
    stdin.readline()
    *A, = map(int, stdin.readline().split())
    *B, = map(int, stdin.readline().split())
    pre = A[0]
    ans = 0
    for a, b in zip(A[1:], B):
        tmp1 = pre if pre < b else b
        b -= tmp1
        tmp2 = a if a < b else b
        ans += tmp1 + tmp2
        pre = a - tmp2
    print(ans)
    return


main()


Measured memory_bytes: 19228
import numpy as np

N, M = map(int, input().split(' '))
store_list = []
for i in range(N):
    a, b = map(int, input().split(' '))
    store_list.append((a, b))

store_list = sorted(store_list, key=lambda x: x[0])

ans = 0
cnt = 0
for a, b in store_list:
    if (M - cnt) > b:
        ans += a * b
        cnt += b
    else:
        ans += a * (M - cnt)
        cnt += (M - cnt)

print(ans)


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

int main() {
int N;
  cin >> N;
vector<int64_t> L(N+1);
L.at(0)=2;
  L.at(1)=1;
  for(int i=2;i<N+1;i++){
 L.at(i)=L.at(i-1)+L.at(i-2);
  }
  cout <<L.at(N)<<endl;
}
  

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

int main() {
	int a, b;
	cin >> a >> b;
	if ((a+b)%2 == 0) {
		cout << (a+b)/2 << endl;
	} else {
		cout << (a+b)/2+1 << endl;
	}
	return 0;
}

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

using namespace std;



int main() {


  int n;
  cin >> n;

  long sum = 0;
  for(int i=1; i<=n ; i++){
    if(i%3!=0 && i%5!=0){
      sum += i;
    }
  }

  cout << sum << endl;

 

  

  
  
  return 0;
}



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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<int> h, c;
  Solver(LL n) : n(n), h(n + 1), c(n + 1){};

  void solve() {
    for (int i = 0; i < n; ++i) {
      cin >> h[i + 1];
    }
    for (int i = 2; i <= n; ++i) {
      c[i] = c[i - 1] + abs(h[i] - h[i - 1]);
      if (i >= 3) {
        c[i] = min(c[i], c[i - 2] + abs(h[i] - h[i - 2]));
      }
    }
    cout << c[n] << endl;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


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

int main(){
  long long int n;
  cin >> n;
  string N = to_string(n);
  long long int rui = 1;
  
  for(int i=0; i<N.size()-1; i++){
    rui *= 10;
  }
  
  bool flag=false;
  if(n >= 10){
    if((n+1)%rui==0){
      flag = true;
    }
  }else{
    cout << n << endl;
    return 0;
  }
  
  int ma;
  int a = N.at(0) - '0';
  if(flag == false){
    ma = a-1 + (N.size() - 1)*9;
  }else{
    ma = a + (N.size() - 1)*9;
  }
  cout << ma << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end();
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	ll w, h, x, y;
	cin >> w >> h >> x >> y;
	double area = (w*h)/2.0;
	int res = 0;
	ll k = x*h;
	if(w%2 == 0 and h%2 == 0 and x==w/2 and y == h/2 ) ++res;
	cout << fixed << setprecision(20) << area << " " << res << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
c=0;b=1;i=0
while b:
 b=0
 for j in range(0,n-i-1):
  if a[j]>a[j+1]:a[j],a[j+1]=a[j+1],a[j];b=1;c+=1
 i+=1
print(*a)
print(c)


Measured memory_bytes: 5604
S = input()
def runlength(str):
    res = []
    data,count = str[0],1
    for i in range(1,len(str)):
        if str[i] == data:
            count += 1
        else:
            res.append((data,count))
            data,count = str[i],1
    res.append((data,count))
    return res
ans = [0]*len(S)
ind = -1
for rl in runlength(S):
    if rl[0] == "R":
        ind += rl[1]
        ans[ind] += rl[1] - rl[1]//2
        ans[ind+1] += rl[1]//2
    else:
        ans[ind] += rl[1]//2
        ans[ind+1] += rl[1] - rl[1]//2
        ind += rl[1]
print(*ans)

Measured memory_bytes: 11132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

bool maze[50][50];


int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll h, w;
	cin >> h >> w;
	memset(maze, 0, sizeof(maze));
	
	rep(i, 1, h){
		string buf;
		cin >> buf;
		//cout << buf << endl;
		rep(j, 1, w){
			if(buf[j-1] == '.'){
				maze[i][j] = true;
			}
		}
	}
	
	//rep(i, 1, h){rep(j, 1, w){cout << maze[i][j];}cout << endl;}
	ll ans = 0;
	rep(i, 1, h){
		rep(j, 1, w){
			//cout << maze[i][j] << i << j << endl;
			if(maze[i][j]){
				ll cost[50][50];
				memset(cost, -1, sizeof(cost));
				cost[i][j] = 0;
				queue<P> q;
				q.push(P(i, j));
				while(!q.empty()){
					ll x = q.front().first;
					ll y = q.front().second; q.pop();
					//cout << x << y << endl;
					if(maze[x+1][y] && cost[x+1][y] == -1){
						cost[x+1][y] = cost[x][y]+1;
						ans = max(cost[x+1][y], ans);
						q.push(P(x+1, y));
					}
					if(maze[x-1][y] && cost[x-1][y] == -1){
						cost[x-1][y] = cost[x][y]+1;
						ans = max(cost[x-1][y], ans);
						q.push(P(x-1, y));
					}
					if(maze[x][y+1] && cost[x][y+1] == -1){
						cost[x][y+1] = cost[x][y]+1;
						ans = max(cost[x][y+1], ans);
						q.push(P(x, y+1));
					}
					if(maze[x][y-1] && cost[x][y-1] == -1){
						cost[x][y-1] = cost[x][y]+1;
						ans = max(cost[x][y-1], ans);
						q.push(P(x, y-1));
					}
				}
				//rep(i, 1, h){rep(j, 1, w){cout << cost[i][j];}cout << endl;}cout << endl;
			}
			//cout << i << j << ans << endl;
		}
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
#include<set>
#include<stack>
#define inf 0x3f3f3f
#define mem(i,a) memset(i,a,sizeof(i))
using namespace std;
typedef long long ll;
typedef double db;
const int mod = 1e9;
const int maxn = 2e5+5;
int n;
string s;
set<string> st;
int main(){
	scanf("%d",&n);
	while(n--){
		cin >> s;
		st.insert(s);
	}
	cout << st.size() << endl;
	return 0;
}


Measured memory_bytes: 15796
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N, L;
    cin >> N >> L;
    vector<int> data(N);
    rep(i, N) data.at(i) = L + i;

    int min_t = 1000000;
    int pos = 0;
    rep(i, N) {
        int t = data.at(i);
        if(abs(t) < abs(min_t)) {
            min_t = t;
            pos = i;
        }
    }

    int sum = 0;
    rep(i, N) {
        if(i != pos) sum += data.at(i);
    }

    cout << sum << endl;
}

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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

char mp[22][22];
bool ok[22];
int used[22];
int h,w;

bool check(){
	//cout << "in check()" << endl;
	REP(i,22)ok[i] = false;
	for(int i = 0;i < w;i++){
		for(int j = i + 1;j < w;j++){
			if(ok[i] || ok[j])continue;
			bool flag = true;
			REP(k,h){
				if(mp[k][i] != mp[h-k-1][j])flag = false;
			}
			if(flag){
				ok[i] = true;ok[j] = true;
				break;
			}
		}
	}
	
	bool kai = true;
	REP(i,w){
		if(!ok[i] && kai){
			REP(j,h)if(mp[j][i] != mp[h-j-1][i])kai = false;
			ok[i] = kai;
			kai = false;
		}
	}
	
	REP(i,w)if(!ok[i])return false;
	return true;
}

bool dfs(int depth){
	if(depth == -1){
		if(h % 2 == 0){
			return dfs(0);
		}
		else{
			REP(i,h){
				if(i != (h+1)/2){
					REP(j,w){
						swap(mp[i][j],mp[(h+1)/2][j]);
					}
					if(dfs(0))return true;
					REP(j,w){
						swap(mp[i][j],mp[(h+1)/2][j]);
					}
				}
			}
		}
		return false;
	}		
	//cout << "dfs " << depth << endl;
	if(depth == h - depth - 1 || depth + 1 == h - depth - 1){
		return check();
	}
	for(int i = depth;i < h - depth;i++){
	//cout << i << endl;
		if(i != h-depth-1)REP(k,w){
			swap(mp[h-depth-1][k],mp[i][k]);
		}
		if(dfs(depth+1))return true;
		if(i != h-depth-1)REP(k,w){
			swap(mp[h-depth-1][k],mp[i][k]);
		}
	}
	return false;
}

int main()		
{
	cin >> h >> w;
	REP(i,h)REP(j,w)cin >> mp[i][j];
	if(dfs(-1))cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 384
#include <cmath>
#include <iostream>
#include <string>
#include <time.h>
#include <stdio.h>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <stack>
#define LEN 100005
using namespace std;

int main()
{
    stack<int> S1;
    stack<pair<int, int> > S2;
    char ch;
    int sum = 0;
    for (int i = 0; cin >> ch; i++){
        if(ch == '\\') S1.push(i);
        else if (ch == '/' && S1.size() > 0){
            int j = S1.top();
            S1.pop();
            sum += i - j;
            int a = i -j;
            while(S2.size() > 0 && S2.top().first > j){
                a += S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j, a));
        }
    }

    vector<int> ans;
    while(S2.size() > 0) {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for(int i = 0; i < ans.size(); i++){
        cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i=0; i<(int)(n); i++)
#define REP2(i,x,n) for(int i=x; i<(int)(n); i++)
#define VSORT(v) sort(v.begin(), v.end());
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
int main(){
    ll a, b;
    cin >> a >> b;
    ll c = a * b;
    ll d = c % 2;
    if (d == 0) {
        cout << "Even" << endl;
    }
    else {
        cout << "Odd" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        ArrayList<Integer> V = new ArrayList<Integer>();
        ArrayList<Integer> C = new ArrayList<Integer>();
        
        for (int i=0; i<A; i++){
            V.add(sc.nextInt());
        }
        for (int i=0; i<A; i++){
            C.add(sc.nextInt());
        }
        
        int ans = 0;
        for (int i=0;i<A;i++){
            int t = V.get(i)-C.get(i);
            if(t>0){
                ans += t;
            }
        }
        
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 22868
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 文字列の入力
		String s = sc.next();
       
        if (s.length() == 2) {
          // 出力
		  System.out.println(s);
        } else {
          String[] list = s.split("");
          System.out.println(list[2] + list[1] + list[0]);
        }
	}
}

Measured memory_bytes: 21844
A, B = map(int, input().split())

def factorize(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

D = gcd(A,B)
factors = factorize(D)
if factors[0][0]==1:
    print(1)
else:
    print(len(factors)+1)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++)
		cout << 'x';
	cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
  
  int l[n];
  for (int i = 0; i < n; i++)
    cin >> l[i];
  
  sort(l, l+n);
  reverse(l, l+n);
  
  int ans = 0;
  for (int i = 0; i < k; i++)
    ans += l[i];
  
  cout << ans;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll a[7];
ll solve0(){
  ll ans=0,tmp;
  ans += a[1];
  ans += (a[0]/2)*2;
  ans += (a[3]/2)*2;
  ans += (a[4]/2)*2;
  return ans;
}
ll solve1(){
  ll ans=0,tmp;
  if(a[0]>=1&&a[3]>=1&&a[4]>=1){
    ans += 3;
    a[0]--;
    a[3]--;
    a[4]--;
  }
  ans += a[1];
  ans += (a[0]/2)*2;
  ans += (a[3]/2)*2;
  ans += (a[4]/2)*2;
  return ans;
}
signed main(){
  for(int i=0;i<7;i++){
    cin >> a[i];
  }
  cout << max(solve1(),solve0()) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll =double;
map <int ,int> mpa,mpb;

int main (void) {
  int N;
  int a;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a;
    mpa[a]++;
  }
  int M;
  int b;
  int B[10000007];
  cin >> M;
  for(int i=0;i<M;i++){
    cin >> b;
    B[i]=b;
    mpb[b]++;
  }
  int x;
  for(int i=0;i<M;i++){
    x=B[i];
    if(mpa[x]<mpb[x]){
      cout <<"NO";
      return 0;
    }
  }
  cout  << "YES";
}

Measured memory_bytes: 19840