akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; i++)
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#ifdef _DEBUG
#define PRE_COMMAND             \
    std::cin.rdbuf(in.rdbuf()); \
    std::cout << fixed << setprecision(15);
#else
#define PRE_COMMAND cout << fixed << setprecision(15);
#endif
const double EPS = 1e-10, PI = acos(-1.0);
template <class T> auto MAX(T& seq) {
    return *max_element(seq.begin(), seq.end());
}
template <class T> auto MIN(T& seq) {
    return *min_element(seq.begin(), seq.end());
}
template <class T> auto SUM(T& seq) {
    T temp{0};
    auto& temp2 = temp[0];
    return accumulate(seq.begin(), seq.end(), temp2);
}
template <class T> void SORT(T& seq) { sort(seq.begin(), seq.end()); }
template <class T, class S> void SORT(T& seq, S& sort_order) {
    sort(seq.begin(), seq.end(), sort_order);
}
template <class T> void SORTR(vector<T>& seq) {
    sort(seq.begin(), seq.end(), greater<T>());
}
template <class T, class S, class R> long long pow(T n_0, S k_0, R mod_0) {
    long long n = n_0 % mod_0, k = k_0, mod = mod_0, now = 1;
    while (k) {
        if (k & 1) now = (now * n) % mod;
        n = (n * n) % mod;
        k >>= 1;
    }
    return now;
}
template <typename T> istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}

int main() {
    PRE_COMMAND
    int a;
    cin >> a;
    REP(i, a) cout << "ACL";
    cout << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
	os << "{";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << *it;
	}
	return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin()) os << ", ";
		os << *it;
	}
	return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << it -> first << " = " << it -> second ;
	}
	return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
	for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
	cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
	FASTIO
	///*
// #ifndef ONLINE_JUDGE
// 	freopen("in.txt", "r", stdin);
// 	freopen("out.txt", "w", stdout);
// 	freopen("error.txt", "w", stderr);
// #endif
//*/
	int a;
	cin >> a;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i * j == a) {
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n";
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BNotFound {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string s;
	    in >> s;
	    map<char, int> mp;
	    for(int i=0; i<s.length(); i++){
	        mp[s[i]] = 1;
	    }

	    char res = '0';
	    for(int i=0; i<26; i++){
	        if(!mp[i + 'a']){
	            res = i+'a';
	            break;
	        }
	    }

	    if(res == '0') out << "None" << endl;
	    else out << res << endl;
	}
};


int main() {
	BNotFound solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

char data[99][50];

int max(int x, int y)
{
	if (x > y){
		return (x);
	}
	
	return (y);
}

int judge(int n)
{
	int i, j;
	int dp[100][50];
	
	for (i = 1; i <= n; i++){
		for (j = 1; j <= i; j++){
			if (i <= n / 2 + 1){
				dp[i][j] = data[i][j] + max(dp[i - 1][j], dp[i - 1][j - 1]);
			}
			else {
				if (j > (n / 2 + 1) * 2 - i){
					break;
				}
				dp[i][j] = data[i][j] + max(dp[i - 1][j], dp[i - 1][j + 1]);
			}
		}
	}
	
	return (dp[n][1]);
}

int main(void)
{
	int i, j;
	char g;
	
	g = 0;
	i = j = 1;
	while (scanf("%d%c", &data[i][j], &g) != EOF){
		if (g == ','){
			j++;
			g = 0;
		}
		else {
			data[i][j + 1] = 0;
			i++;
			data[i][0] = 0;
			j = 1;
		}
	}
	
	printf("%d\n", judge(i - 1));
	
	return (0);
}

Measured memory_bytes: 620
#include<iostream>
#include<algorithm>
#include <vector>
#include <cmath>
#include<string>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
    string s;
    cin>>s;
    int ans=0;
    int n= s.size();
    int s_n=atoi(s.c_str());
    REP(i,n){
        ans+=s[i]-'0';
    }
    if (s_n % ans){
       cout<<"No"<<endl; 
    }else{
        cout<<"Yes"<<endl;
    }
       
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	int a;
	deque<int>data;
	rep(i,n){
		cin>>a;
		if(i%2==0){
			data.push_back(a);
		}else{
			data.push_front(a);
		}
	}
	while(!data.empty()){
		if(n%2==0){
			a=data.front();	
			data.pop_front();
		}else{
			a=data.back();
			data.pop_back();
		}

		cout<<a;
		if(data.empty()){
			cout<<endl;
		}else{
			cout<<" ";
		}
	}
}

Measured memory_bytes: 2944
while True:
    n,x=map(int,input().split())
    if n+x==0:
        break

    cnt=0
    for i in range(1,n+1):
        for j in range(1+i,n+1):
            for k in range(j+1,n+1):
                if i+j+k==x:
                    cnt+=1
    print(cnt)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX
#include <iomanip>

using namespace std;
int MOD = 998244353;
const int mxN = 2e5 + 9;

ll ar[mxN];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
    int N,K;
    cin >> N >> K;
    for(int i=1; i <= N; i++) ar[i] = (ll)i + ar[i-1];
    ll ans = 0;
    for(int nselect = K; nselect <= N; nselect++){
        ll start = ar[nselect-1];
        ll endd = ar[N] - ar[N-nselect];
        //cout << start << " " << endd << endl;
        ans += endd-start+1;
    }
    cout << (ans + 1)% 1000000007 << "\n";
    //for(int i=0; i <= N; i++) cout << ar[i] << " ";



}


Measured memory_bytes: 5168
#include <iostream>
#include <map>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s;
  map<string,int> m{};
  for(int i=0;i<n;i++){
    cin >> s;
    m.insert(make_pair(s,1));
  }
  cout << m.size() << endl;
  return 0;
}

Measured memory_bytes: 19152
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        static void Main(){
            long[] kx = ILongs();

            for(long i=kx[1]-kx[0]+1;i<kx[1]+kx[0];i++){
                if(i>-1000000+1 && i<1000000+1){
                    Console.WriteLine(i);
                }
            }
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 11092
from sys import stdin

num_dishes = 5
dishes = []
for i in range(5):
    dishes.append(int(stdin.readline()))
for i in range(0, num_dishes - 1):
    for j in range(i + 1, num_dishes):
        if (dishes[i] % 10 > dishes[j] % 10):
            dishes[i], dishes[j] = dishes[j], dishes[i]
dishes.sort(key=lambda d: d % 10)
got = False
ans = 0
for dish in dishes:
    if dish % 10 == 0:
        ans += dish
        continue
    else:
        if got:
            ans += dish + (10 - dish % 10)
        else:
            got = True
            ans += dish
print(ans)


Measured memory_bytes: 3064
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int[] h = new int[a];
        int[] h2 = new int[a];
        int ans = 0;
        for(int i=0;i<a;i++){
            h[i] = scan.nextInt();
        }
        for(int i=0;i<b;i++){
            int A = scan.nextInt();
            int B = scan.nextInt();
            h2[A-1]=Math.max(h2[A-1], h[B-1]);
            h2[B-1]=Math.max(h2[B-1], h[A-1]);
        }
        for(int i=0;i<a;i++){
            ans+=(h[i]>h2[i])?1:0;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 60048
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int num[]=new int[51];
		for (int i = 0; i <= 9; i++) {
			for (int j = 0; j <= 9; j++) {
				for (int k = 0; k <= 9; k++) {
					for (int l = 0; l <= 9; l++)
						num[i+j+k+l]++;
				}
			}
		}
		while (null != (str = in.readLine())) {
			System.out.println(num[Integer.parseInt(str)]);
		}
	}
}

Measured memory_bytes: 16868
n=int(input())
arr=list(map(int,input().split()))
arr2=[0]*n
for i in range(0,2*n,2):
  arr2[i//2]=arr[i%n]
ans=[0]*n
s=sum(arr)//2
cum=[0]*n
start=sum(arr2[:n//2])
cum[0]=start
l=n//2
for i in range(n):
  start=start+arr2[(i+l)%n]-arr2[i]
  cum[(i+1)%n]=start
for i in range(n):
  ans[(n-1+i*2)%n]=(s-cum[i])*2
print(*ans)

Measured memory_bytes: 18680
import sys
input=sys.stdin.readline

n=int(input())
s=input().rstrip()
t=input().rstrip()

for i in range(n+1):
    check=True
    for j in range(n-i):
        if s[i+j]!=t[j]:
            check=False

    if check:
        ans=i+n
        print(ans)
        sys.exit()

Measured memory_bytes: 63384
#![allow(dead_code)]

// This file is a "Hello, world!" in Rust language for wandbox.
use std::process;


fn main()
{
    let nums: i32 = read(); // 10000, 5000, 1000
    
	let one = nums % 10;
  
	match one {
    	2|4|5|7|9 => 
    // do stuff here
          println!("hon"),
    
      0|1|6|8 => 
        println!("pon"),
    	_ => println!("bon"),
  }
}
    
// Rust language references:
//   https://www.rust-lang.org/
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_n<T: std::str::FromStr>(n: u32) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}


Measured memory_bytes: 2172
#include <stdio.h>

int main(void){
    int counter = 0;
    int N;
    scanf("%i", &N);
    int A[N];
    for (int i = 0; i < N; i++){
        scanf("%i", &A[i]);
    }
    int B[N];
    for (int i = 0; i < N; i++){
        scanf("%i", &B[i]);
        counter += B[i];
    }
    int C[N - 1];
    for (int i = 0; i < N - 1; i++){
        scanf("%i", &C[i]);
    }
    for (int i = 0; i < N - 1; i++){
        if (A[i] + 1 == A[i + 1]){
            counter += C[A[i] - 1];
        }
    }
    printf("%i\n", counter);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
struct mint {
    long long x;
    mint(long long _x=0):x((_x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint modpow(long long t) const {
        if (!t) return 1;
        mint a = modpow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return modpow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
    friend std::ostream& operator<<(std::ostream& os, const mint& a){
        os << a.x;
        return os;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, K;
    cin >> N >> K;
    vector<mint> v(K+1, 0);
    mint ans = 0;
    mint sum = 0;
    for(int i = K; i >= 2;i--){
        int cnt = 0;
        //iの倍数を列挙
        for(int j = i; j <= K;j+= i){
            cnt++;
            v[i] -= v[j];
        }
        v[i] += mint(cnt).modpow(N);
        sum += v[i];
        ans += v[i] * i;
    }
    v[1] = mint(K).modpow(N) - sum;
    ans += v[1];
    cout << ans << endl;
}

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

using namespace std;

int main()
{
	long long n, a, cnt=1, sum[200010], vp, ans=0;
	sum[0] = 0;
	cin >> n;
	for (int i=1; i<=n; i++)
	{
		cin >> a;
		sum[i] = sum[i - 1] + a;
	}
	sort(sum, sum + n + 1);
	vp = sum[0];
	for (int i = 1; i <= n; i++)
	{
		if (vp != sum[i])
		{
			ans += cnt*(cnt - 1) / 2;
			vp = sum[i];
			cnt = 1;
		}
		else cnt++;
	}
	ans += cnt*(cnt - 1) / 2;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

int max(int a, int b){
    if(a > b){
        return a;
    }else{
        return b;
    }
}



int main(){
    int r;
    scanf("%d", &r);
    
    

    printf("%d", r*r);
   
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	int l=0,r=s.length()-1;
	int cnt1=0;bool found =false;
	while(1)
	{
		if(l==r ) break;
		if (r-l==1)
		 {
		 	if(s[r]!=s[l])
		 	{
		 		if(s[r]=='x' || s[l]=='x')
		 		cnt1++;
		 		else
		 		found=true;
		 	}
		 
		 	break;
		 }
		 
			if(s[l]==s[r])
			{
				l++;r--;
			}
			else if(s[l]!=s[r])
			{
				if(s[l]=='x')
				{
					l++;
					cnt1++;
				}
				else if(s[r]=='x')
				{
					r--;
					cnt1++;
				}
				else
				{
					found=true;
					l++;r--;
				}
			}
	}
	if(found)
	 cout << "-1";
	 else
	  cout << cnt1;
	return 0;
}

Measured memory_bytes: 512
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;


void main(){
	auto msp = (){
		auto np = new bool[](400000);
		np[0] = true;
		np[1] = true;
		for(int i; i < np.length; ++i) {
			if((i%7 == 1 || i%7 == 6) && !np[i]) {
				for(int j = 2; j*i < np.length; ++j) {
					np[j*i] = true;
				}
			} else {
				np[i] = true;
			}
		}
		return zip(iota(np.length), np).filter!(a => !a[1]).map!(a => a[0]).array;
	}();
	while(true) {
		auto n = readInt();
		if(n == 1) return;

		writeln(n, ": ", msp.filter!(a => a <= n && n%a == 0).map!(to!string).join(" "));
	}
}

Measured memory_bytes: 3208
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from collections import Counter
def resolve():
    n = int(input())
    C = Counter()
    for _ in range(n):
        S = input()
        if '.' in S:
            a, b = S.split('.')
            two = five = -len(b)
            a = int(a + b)
        else:
            two = five = 0
            a = int(S)
        while a % 2 == 0:
            two += 1
            a //= 2
        while a % 5 == 0:
            five += 1
            a //= 5
        C[two, five] += 1

    ans = 0
    for key0, val0 in C.items():
        i0, j0 = key0
        for key1, val1 in C.items():
            i1, j1 = key1
            if i0 + i1 < 0 or j0 + j1 < 0:
                continue
            if key0 == key1:
                ans += val0 * (val0 - 1) // 2
            elif key0 < key1:
                ans += val0 * val1
    print(ans)
resolve()

Measured memory_bytes: 76076
/*input
5 3 5
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
set<char> st;
int main()
{
	IOS;
	ll a,b,c;
	cin>>a>>b>>c;
	if(a%2&&b%2&&c%2){
		cout<<min({a*b,a*c,b*c});
	}
	else cout<<0;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int a,b,x; cin>>a>>b>>x;
  if(a>x)
  cout<<"NO"<<endl;
  else{
    if(a+b<x)
    cout<<"NO"<<endl;
    else
    cout<<"YES"<<endl;
  }



  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n;
		cin >> n;
		double a[n+1];
		rep(i,0,n) cin >> a[i+1];
		double dp[n+1][n+1];
		rep(i,0,n+1){
			rep(j,0,n+1) dp[i][j] = 0;
		}
		dp[0][0] = 1.0;
		rep(i,1,n+1){
			for(int j=i; j>=0; j--){
				dp[i][j] = dp[i-1][j]*(1-a[i]);
				if(j) dp[i][j] += dp[i-1][j-1]*a[i];
			}
		}
		double ans = 0;
		rep(j,0,n+1){
			if(j>n-j) ans += dp[n][j];
		}
		cout<<fixed<<setprecision(10)<<ans;
	}
}

Measured memory_bytes: 70656
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = myconv(next(),4);
  var H = one[0];
  var W = one[1];
  var list = new Array(H);
  var visit = new Array(H);
  for(var i = 0; i < H; i++){
    list[i] = myconv(next(),6);
    visit[i] = new Array(W).fill(false);
  }
  visit[0][0] = true;
  var goal = 10000000;
  var queue = [[0,0,0]];
  while(queue.length > 0){
    var q = queue.shift();
    var y = q[0];
    var x = q[1];
    var count = q[2];
    if(y == H - 1 && x == W - 1){
       goal = Math.min(goal,count);
    }
    if(y != 0 && list[y - 1][x] == "." && !visit[y - 1][x]){
      visit[y - 1][x] = true;
      queue.push([y - 1, x, count + 1]);
    }
    if(x != 0 && list[y][x - 1] == "." && !visit[y][x - 1]){
      visit[y][x - 1] = true;
       queue.push([y, x - 1, count + 1]);
    }
    if(y != H - 1 && list[y + 1][x] == "." && !visit[y + 1][x]){
      visit[y + 1][x] = true;
       queue.push([y + 1, x, count + 1]);
    }
    if(x != W - 1 && list[y][x + 1] == "." && !visit[y][x + 1]){
      visit[y][x + 1] = true;
       queue.push([y, x + 1, count + 1]);
    }
  }
  //goal + 1以外の点はすべて変換化
  if(goal == 10000000){
     myout(-1);
  }else{
     var dot = 0;
     for(var i = 0; i < H; i++){
       for(var j = 0; j < W; j++){
         if(list[i][j] == "."){
            dot++;
         }
       }
     }
     dot -= (goal + 1);
    myout(dot);
  }
}


Measured memory_bytes: 7628
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

r=0
for i in range(0,n):
  if v[i] > c[i]:
    r=r+v[i]-c[i]
print(r)


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

using namespace std;
typedef long long ll;
const int MAXN = 5010;

int N;
ll M, MOD;
int L, R;

int dp[MAXN][MAXN]; // clast, ctot
int ndp[MAXN][MAXN];

ll sdp[MAXN][MAXN];
ll ps[MAXN][MAXN];

void process_dp()
{
    //return;
    for (int r = L - 2; r >= 0; r--)
    {
        /*for (int i = 0; i <= N; i++)
        {
            for (int j = 0; j <= N; j++)
                cout << dp[i][j] << " ";
            cout << "\n";
        }
        cout << "\n";*/

        int ihi = N / (r + 1) + 1;
        // first pass DP up
        for (int i = 0; i <= ihi; i++)
        {
            int nstop = N - r * i;
            for (int j = 0; j <= N; j++)
            {
                if (j <= nstop && dp[i][j])
                {
                    if (i < ihi)
                    {
                        dp[i+1][j] += dp[i][j];
                        if (dp[i+1][j] >= MOD) dp[i+1][j] -= MOD;
                    }

                    if (i + j <= N)
                    {
                        ndp[i][i+j] = dp[i][j];
                    }
                }
                dp[i][j] = ndp[i][j];
                ndp[i][j] = 0;
            }
        }
    }

    /*for (int i = 0; i <= N; i++)
    {
        for (int j = 0; j <= N; j++)
            cout << dp[i][j] << " ";
        cout << "\n";
    }
    cout << "\n";*/
}

int main()
{
    ios_base::sync_with_stdio(0);
    
    cin >> N >> M;
    MOD = M;

    if (N == 2)
    {
        cout << "3\n";
        return 0;
    }

    L = (N + 1) / 2;
    R = (N - 1) / 2;

    for (int i = 0; i <= N; i++)
        for (int j = 0; j <= N; j++)
            dp[i][j] = 0;
    dp[0][0] = 1;
    process_dp();

    for (int i = 0; i <= N; i++)
        for (int j = 0; j <= N; j++)
            sdp[i][j] = dp[i][j];


    for (int i = 0; i <= N; i++)
        for (int j = 0; j <= N; j++)
            dp[i][j] = 0;
    dp[0][0] = 1;
    if (N % 2 == 0)
    {
        int chi = N / R + 1;
        for (int i = 0; i <= chi; i++)
            dp[i][0] = 1;
    }
    process_dp();

    for (int i = 1; i <= N; i++)
    {
        for (int j = 0; j <= N; j++)
        {
            sdp[0][j] += sdp[i][j];
        }
    }
    for (int j = 0; j <= N; j++)
        sdp[0][j] %= MOD;

    for (int i = 0; i <= N; i++)
        ps[0][i] = dp[0][i];
    for (int i = 1; i <= N; i++)
    {
        for (int j = 0; j <= N; j++)
        {
            ps[i][j] = (ps[i-1][j] + dp[i][j]);
            if (ps[i][j] >= MOD) ps[i][j] -= MOD;
            dp[i][j] = (dp[i-1][j] + ps[i][j]);
            if (dp[i][j] >= MOD) dp[i][j] -= MOD;
        }
    }

    ll ans = 0;
    for (int j = 0; j <= N; j++)
    {
        for (int l = 0; l <= N; l++)
        {
            if (j + l < N)
            {
                int lo = j + l + 1;
                ans += sdp[0][j] * dp[N-lo][l];
                if ((l & 7) == 0) ans %= MOD;
            }
        }
    }
    cout << ans << "\n";
}

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  
  for(int i=0; i < N;i++){
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=n-1;i > m;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main() {
  lli A,B,C,D,E,F,N,M,K,sum=0,num=0,ans=0;
  cin >> N;
  vector<int>P(N,0);
  rep(i,0,N){
    cin >> A;
    P[i]=A-i+1;
  }
  Sort(P);
  K=N/2;
  M=P[K];
  rep(i,0,N)sum+=abs(P[i]-M);
  Out(sum);
}
  

Measured memory_bytes: 1024
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;
            string[] s = Console.ReadLine().Split(' ');

            int D = int.Parse(s[0]);
            int N = int.Parse(s[1]);

            int div = 1;
            int ndiv = 1;

            switch(D)
            {
                case 0:
                    div = 1;
                    ndiv = 100;
                    break;
                case 1:
                    div = 100;
                    ndiv = 10000;
                    break;
                case 2:
                    div = 10000;
                    ndiv = 1000000;
                    break;
            }

            for(int i=0;i<N;i++)
            {
                ans = ans + div;
                if (ans % ndiv == 0)
                    ans = ans + div;
            }

            Console.WriteLine(ans.ToString());
        }
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1 << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
struct cake {
	int x, y, z;
};

signed main() {
	cin >> N >> M;
	vector< vector< int > > C(N, vector< int >(3));
	rep(i, N) cin >> C[i][0] >> C[i][1] >> C[i][2];
	vector< int > A(N);
	int ans = -LINF;
	for (int b = 0; b < (1 << 3); b++) {
		bitset< 3 > bit(b);
		A.assign(N, 0);
		rep(i, N) {
			rep(j, 3) {
				if (bit[j])
					A[i] += C[i][j];
				else
					A[i] -= C[i][j];
			}
		}
		sort(A.rbegin(), A.rend());
		int tmp = 0;
		rep(i, M) {
			tmp += A[i];
		}
		chmax(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  ll ans = 1e15;
  for(ll i = 1; i*i <= n; ++i) {
    if(n % i != 0) continue;
    ll j = n / i;
    ans = min(ans, i+j-2);
  }
  cout << ans << endl;
  return 0;
}

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

#define LL long long
#define VI vector<int>
#define VB vector<bool>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

const std::string YES = "YES";
const std::string Yes = "Yes";
const std::string NO = "NO";
const std::string No = "No";

using namespace std;

LL simulation(vector<LL> &A) {
    LL ans = 0;
    LL N = A.size();
    while (true) {
        sort(RALL(A));
        if (A[0] <= N - 1) {
            break;
        }
        A[0] -= N;
        FOR(i, 1, A.size()) {
            A[i]++;
        }
        ans++;
    }
    return ans;
}

int solve(LL N, vector<LL> &A) {
    LL ans = 0;
    sort(RALL(A));

    bool change = true;
    while (change) {
        change = false;
        FOR(i, 0, A.size()) {
            LL n = A[i] / N;
            A[i] -= (n * N);
            FOR(j, 0, A.size()) {
                if (i != j) {
                    A[j] += n;
                }
            }
            ans += n;
            change = (n >= 1);
        }
    }

    cout << ans + simulation(A) << endl;

}


int main() {
    LL N;
    cin >> N;
    vector<LL> A(N);
    FOR(i, 0, N) {
        cin >> A[i];
    }
    solve(N, A);

    return 0;
}

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

using namespace std;

template <class T>inline T updmax(T &a, T b) { return a = max(a, b); }
template <class T>inline T updmin(T &a, T b) { return a = min(a, b); }

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> a(n, 0);
	for(int i=0; i<n; i++)cin >> a[i];
	int x = 0;
	vector<int> b(n, 0);
	for(int i=n-1; i >= 0; i--){
		int s = 0;
		for(int j = 2*i+1; j < n; j+=i+1){
			s ^= b[j];
		}
		if(s != a[i])b[i] = 1;
	}
	int s = 0;
	for(int i=0; i < n; i++)s += b[i];
	cout << s << "\n";
	for(int i=0; i < n; i++)if(b[i])cout << i+1 << "\n";
	return 0;
}

Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int N; cin >> N;
	vector<int> r(N);
	for (int i = 0; i < N; i++)
		cin >> r[i];
	sort(r.begin(), r.end());
	double ma = 0;
	for (int n = 3; n <= N; n++) {
		vector<int> a(r.end() - n, r.end());
		do {
			vector<double> x(n), y(n);
			for (int i = 0; i < n; i++) {
				x[i] = a[i] * cos(M_PI*2 / n * i);
				y[i] = a[i] * sin(M_PI*2 / n * i);
			}
			for (int t = 0; t < 0; t++) {
				int i = rand() % n;
				int j = (i + n - 1) % n, k = (i + 1) % n;
				double dx = x[k] - x[j], dy = y[k] - y[j];
				double _dx = dy, _dy = -dx;
				double r = sqrt(_dx * _dx + _dy * _dy);
				x[i] = _dx / r * a[i];
				y[i] = _dy / r * a[i];
			}
			double sum = 0;
			for (int i = 0; i < n; i++) {
				int j = (i + 1) % n;
				sum += x[i] * y[j] - y[i] * x[j];
			}
			ma = max(ma, sum);
		} while (next_permutation(a.begin() + 1, a.end()));
	}
	printf("%.15f\n", ma / 2);
}

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

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

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

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

struct UnionFind {
    vector<int> _ids; // 添字iが属する集合のID

    UnionFind(int n) {
        _ids.assign(n, -1);
    }

    int root(int x) {
        const auto rx               = _ids[x];
        return rx < 0 ? x : _ids[x] = root(rx);
    }

    // 要素xとyは同じ連結成分に属するか？
    bool connected(int x, int y) {
        return root(x) == root(y);
    }

    // 要素xが属する集合の要素数
    int size(int x) {
        return -_ids[root(x)];
    }

    // 要素xとyを連結
    bool unite(int x, int y) {
        auto rx = root(x), ry = root(y);
        if (rx == ry) return false;

        if (_ids[rx] > _ids[ry]) swap(rx, ry);
        _ids[rx] += _ids[ry];
        _ids[ry] = rx;
        return true;
    }
};
//---------------------------------------------------------------------------------------------------

signed main() {
    int N, Q;
    cin >> N >> Q;
    UnionFind uf(N);
    rep(i, 0, Q) {
        int a, b;
        cin >> a >> b;
        uf.unite(a, b);
    }
    cin >> Q;
    rep(i, 0, Q) {
        int a, b;
        cin >> a >> b;
        cout << (uf.connected(a, b) ? "yes" : "no") << "\n";
    }
}



Measured memory_bytes: 3364
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
int abs(int a) {return a < 0 ? (-a) : a;}
int costlist[362880][9][9];
int perm[362880][9];
int main() {
    int arr[] = {0,1,2,3,4,5,6,7,8};

    int index = 0;
    do {
        for (int row=0; row<3; row++) {
            for (int col=0; col<3; col++) {
                for (int t_row=0; t_row<3; t_row++) {
                    for (int t_col=0; t_col<3; t_col++) {
                        int distance = abs(row-t_row) + abs(col-t_col);
                        costlist[index][arr[row*3+col]][arr[t_row*3+t_col]] = distance;
                    }
                }
            }
        }
        for (int i=0; i<9; i++) perm[index][i] = arr[i] + 1;
        index++;
    } while (next_permutation(arr, arr+9));
    //cerr << "ready" << endl;

    int N;
    int move[9][9] = {0};
    cin >> N;
    int before;
    for (int i=0; i<N; i++) {
        char c;
        cin >> c;
        int s = c - 0x30 - 1;
        if (i > 0) {
            move[before][s]++;
        }
        before = s;
    }

    int mincost = -1;
    int min_index = 0;
    for (int index=0; index < 362880; index++) {
        int cost = 0;
        for (int i=0; i<9; i++) {
            for (int j=0; j<9; j++) {
                cost += costlist[index][i][j] * move[i][j];
            }
        }
        if (mincost == -1 || cost < mincost) {
            mincost = cost;
            min_index = index;
        }
    }

    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            cout << perm[min_index][i*3 + j];
        }
        cout << endl;
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int cnt = 1;
  int ans = 0;
  rep(i, n) {
    int a;
    cin >> a;
    if (cnt == a) {
      cnt++;
    }
    else {
      ans++;
    }
  }
  if (ans == n) ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int x[4] = { -1,0,1,0 };
int y[4] = { 0,1,0,-1 };
int g[4][4];
int m = 0;

bool solve(int depth, int t, int zx, int zy) {
	int c = 0;
	for (int i=0;i<4;i++) {
		for (int j=0;j<4;j++) {
			if (g[i][j] != 0) {
				int t = g[i][j]-1;
				c += abs(t / 4 - i) + abs(t % 4 - j);
			}
		}
	}

	if (c+depth>m) return false;
	if (c==0) return true;
	int dx,dy;
	for(int i=0;i<4;i++) {
		if (abs(i-t)!=2) {
			dx = zx+x[i];
			dy = zy+y[i];
			if (dx < 0 || dx == 4 || dy < 0 || dy == 4) continue;
            swap(g[dx][dy], g[zx][zy]);
            if (solve(depth + 1, i, dx, dy)) return true;
            swap(g[dx][dy], g[zx][zy]);

		}
	}
	return false;
}

int main() {
	int zx,zy;
	for (int i=0;i<4;i++) {
		for (int j=0;j<4;j++) {
			cin>>g[i][j];
			if (g[i][j]==0) {
				zx=i;zy=j;
			}
		}
	}
	for (m=0;m>=0;m++) {
		if (solve(0,9,zx,zy)) {
			cout<<m<<endl;
			return 0;
		}
	}

	
	return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(void){
    int N;
    cin>>N;
    if(N>=65&&N<=90)cout<<"1"<<endl;
    else if(N>=97&&N<=122)cout<<"2"<<endl;
    else cout<<"0"<<endl;
}


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

int main(){
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
  
  if(x-r<0||x+r>W||y-r<0||y+r>H){
    cout << "No" << endl;
    
  }else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3100
def main() -> None:
    n = int(input())
    h = [int(x) for x in input().split()]
    cnt = 0

    while len(h) > 0:
        i = len(h) - 1
        flg = False
        while i >= 0 and h[i] > 0:
            h[i] -= 1
            i -= 1
            flg = True

        if flg:
            cnt += 1
        if h[-1] == 0:
            h.pop(-1)

    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
n = int(input())
abc = [tuple(map(int, input().split())) for _ in range(n)]
dp_a = [0]*n
dp_b = [0]*n
dp_c = [0]*n

dp_a[0], dp_b[0], dp_c[0] = abc[0]

for i in range(1, n):
    dp_a[i] = max(dp_b[i-1], dp_c[i-1]) + abc[i][0]
    dp_b[i] = max(dp_c[i-1], dp_a[i-1]) + abc[i][1]
    dp_c[i] = max(dp_a[i-1], dp_b[i-1]) + abc[i][2]
    
print(max(dp_a[-1], dp_b[-1], dp_c[-1]))

Measured memory_bytes: 32448
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(void)
{
    long int a,b,c,d;
    char bb[7];
    while((scanf("%d %d",&a,&b))==2)
    {
        c= a+b;


     sprintf(bb, "%d", c);
       d = strlen(bb);
      printf("%d\n",d);
    }
    return 0;
}

Measured memory_bytes: 612