akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll N,A,B;
  cin >> N >> A >> B;
  if(abs(B-A)%2==0) {
    cout << abs(B-A)/2 << endl;
  } else {
    if(B<A) swap(A,B);
    // A < B
    ll x = (A-1) + 1 + (B-A-1)/2;
    ll y = (N-B) + 1 + (B-A-1)/2;
    cout << min(x,y) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Face Produces Unhappiness
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int K = sc.nextInt();
            char[] S = sc.next().toCharArray();

            int r = 1;
            char pre = S[0];
            for (int i = 1; i < N; i++) {
                if (pre != S[i]) {
                    r++;
                    pre = S[i];
                }
            }

            int ans = N - Math.max(r - K * 2, 1);

            System.out.println(ans);
        }
    }

}


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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(12);
    ll n;
    string s;
    cin >> n >> s;
    for(auto c: s){
        cout << (char)((c-'A'+n)%26+'A');
    }
    cout << endl;

    return 0;
}


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

//x -> "ABC"
string operate(string s, char x) {
	string t;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == x) { t += "ABC"; }
		else { t += s[i]; }
	}
	return t;
}

//"ABC" -> x
string inverse(string &s, char x) {
	string t;
	for (int i = 0; i < s.length(); ) {
		if (i + 2 < s.length() && s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
			t += x;
			i += 3;
		}
		else {
			t += s[i];
			i++;
		}
	}
	return t;
}

//is all char appeared?
bool check(string &s) {
	int cnt[3] = {0};
	for (int i = 0; i < s.length(); i++) {
		cnt[s[i] - 'A']++;
	}
	return (cnt[0] > 0 && cnt[1] > 0 && cnt[2] > 0);
}

int main() {
	string s;
	cin >> s;
	
	while (true) {
		if (!check(s)) { break; }
		if (s == "ABC") { cout << "Yes" << endl; return 0; }
		
		char last = 'z';
		for (char x = 'A'; x <= 'C'; x++) {
			if (operate(inverse(s, x), x) == s) {
				last = x;
				break;
			}
		}
		if (last == 'z') break;
		
		s = inverse(s, last);
	}
	
	cout << "No" << endl;
	return 0;
}

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


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


Measured memory_bytes: 256
N, X, Y=map(int, input().split())

answer=[0]*(N-1)
#i, j from 1 to N
for i in range(1, N):
    for j in range(i+1, N+1):
        temp=min(abs(j-i), abs(j-Y)+1+abs(X-i)) #, abs(j-X)+1+abs(Y-i)
        #print(i, j, temp)
        answer[temp-1]+=1
for val in answer:
    print(val)

Measured memory_bytes: 46044
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	lint n,m,answa=0,ac=0;
	cin>>n>>m;
	vector<bool>f(n,false);
	vector<lint>wa(n,0);
	rep(i,m){
		lint p;
		string s;
		cin>>p>>s;
		p-=1;
		if(f.at(p)==false){
			if(s=="AC"){
				f.at(p)=true;
				ac++;
			}
			if(s=="WA")wa.at(p)++;
		}
	}
	rep(i,n)if(f.at(i))answa+=wa.at(i);
	cout<<ac<<" "<<answa<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b, c, d; cin >> a >> b;
	if ((a * b) % 2 == 0) cout << "Even";
	else cout << "Odd";
	
	


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
int main( void )
{
  ios::sync_with_stdio(false);
  while( 1 ){
    int N, M, a;
    int d[2048];
    map<int,int> h,v;
    cin >> N >> M;
    if( N == 0 && M == 0 ) break;
    d[0] = 0;
    for( int i=0; i<N; i++ ){
      cin >> a;
      d[i+1] = d[i] + a;
    }
    for( int i=0; i<=N; i++ ){
      for( int j=i+1; j<=N; j++ ){
        h[d[j]-d[i]]++;
      }
    }
    d[0] = 0;
    for( int i=0; i<M; i++ ){
      cin >> a;
      d[i+1] = d[i] + a;
    }
    for( int i=0; i<=M; i++ ){
      for( int j=i+1; j<=M; j++ ){
        v[d[j]-d[i]]++;
      }
    }
    int ret = 0;
    for( map<int,int>::iterator it = h.begin(); it != h.end(); ++it ){
      ret += it->second * v[it->first];
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 32468
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    
    const ab = arg.slice(1, M + 1).map(n=>n.split(" ").map(l=>parseInt(l)));
    
    let map = [...Array(N)].fill(0);
    let answer = "IMPOSSIBLE";
    
    for(let i=0; i<M; i++) {
        let from = ab[i][0];
        let to   = ab[i][1];
        
        if(from === 1) {
            if(map[to] === 1) {
                answer = "POSSIBLE";
                break;
            } else {
                map[to]++;
            }
        }
        
        if(to === N) {
            if(map[from] === 1) {
                answer = "POSSIBLE";
                break;
            } else {
                map[from]++;
            }
        }
    }
        
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 74412
#![allow(unused_imports)]
use itertools::Itertools;
use itertools::MinMaxResult::{MinMax, OneElement};
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize,
        aa: [usize; n]
    };
    match aa.iter().minmax() {
        OneElement(_) => println!("0"),
        MinMax(left, right) => println!("{}", right - left),
        _ => unreachable!(),
    };
}


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

int main() {
  string A, B;
  cin >> A >> B;
  if (A.size() > B.size()) cout << "GREATER" << endl;
  else if (B.size() > A.size()) cout << "LESS" << endl;
  else {
    bool is_equal = true;
    for (int i=0; i<A.size(); i++) {
      if (A.at(i)-0x30 > B.at(i)-0x30) {
        cout << "GREATER" << endl;
        is_equal = false;
        break;
      } else if (B.at(i)-0x30 > A.at(i)-0x30) {
        cout << "LESS" << endl;
        is_equal = false;
        break;
      }
    }
    if (is_equal) cout << "EQUAL" << endl;
  }
}

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


int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;++i) cin >> A[i];
    long cnt=0,i=0;

    while(i<N){
        cnt += A[i]/2;
        if(A[i]%2==1 && i<N-1 && A[i+1]>0){
            ++cnt;
            --A[i+1];
        }
        ++i;
    }

    cout << cnt << endl;

    }




Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N=205;
int n,a,b,ans;
int p(int x){
    if(x<b)
		return 0;
    if(x%b==0)
		return x/b;
    int t1=x/b+1,t2=x%b;
    if(t1>=t2)
		return p(x-t1);
    else
		return p(x-t2/t1*t1);
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a>>b;
        ans^=p(a);
    }
    if(ans)
		cout<<"Takahashi\n";
    else cout<<"Aoki\n";
    return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
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);
        BDigitSums solver = new BDigitSums();
        solver.solve(1, in, out);
        out.close();
    }

    static class BDigitSums {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int max = (int) Math.sqrt(N) + 1;
            int sn = 0;
            String s = "" + N;
            for (int i = 0; i < s.length(); i++) {
                sn += Integer.parseInt("" + s.charAt(i));
            }
            out.println(N % sn == 0 ? "Yes" : "No");
        }

    }
}



Measured memory_bytes: 22736
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	// init
	results := make(map[string]int)
	for i := 0; i < 26; i++ {
		results[string('a'+i)] = 0
	}

	// scan
	var inputs string
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		hoge := scanner.Text()
		inputs = inputs + hoge
	}

	// exec
	for _, v := range inputs {
		str := strings.ToLower(string(v))
		if str == " " {
			continue
		}
		results[str] = results[str] + 1
	}
	for i := 0; i < 26; i++ {
		fmt.Printf("%s : %d\n", string('a'+i), results[string('a'+i)])
	}
}



Measured memory_bytes: 1120
#include <stdio.h>

int main(){
    double gu[100];
    int N,i;
    
    scanf("%d",&N);

    for(i = 0; i < N; i++){
        scanf("%lf",&gu[i]);
    }

    

    int t,j;
    double min,tmp;

    for(t=0;t<N;t++){
        min = gu[t];

        for(j=t+1;j<N;j++){
            if(gu[j] < min){
                tmp = gu[t];
                gu[t] = gu[j];
                gu[j] = tmp;
                min = gu[t];
            }
        }
    }

    /*for(int i = 0; i < N; i++){
        printf("%lf",gu[i]);
    }*/


    int k = 0;
    for(k = 0; k < N-1; k++){
        gu[k+1] = (gu[k] + gu[k+1])/2;
    }
    printf("%lf",gu[N-1]);
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;
int main(){
    int N,X,Y;
    cin >> N >> X >> Y;
    vector<int> A(N,0);
    for(int i=1; i<N; i++){
        for(int j=i+1; j<=N; j++){
            int c;
            if(j<=X || i>=Y) A.at(j-i) += 1;
            if(i<=X && j>=Y) A.at(j-Y+X-i+1) += 1;
            if(i<=X && X<j && j<Y) A.at(min(j-i,X-i+1+Y-j)) +=1;
            if(X<i && i<Y && Y<=j) A.at(min(j-i, i-X+1+j-Y)) +=1;
            if(X<i && j<Y) A.at(min(j-i, i-X+1+Y-j)) +=1;
        }
    }
    for(int i=1; i<N; i++){
        cout << A.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
a=int(input())
def sei(a):
  v=list(map(int , a.split()))
  return v
buysell=[]
for i in range(2):
  buysell+=[sei(input())]
X=0
for i in range(a):
  if buysell[0][i]>buysell[1][i]:
    X+=buysell[0][i]-buysell[1][i]
print(X)



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

using namespace std;

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

int main(){
  //それまでの最低価格を保持して、最高価格との差も保持する
  //2*10^5なので計算量O(n)まで

  int64_t n;
  cin >> n;

  int64_t max_deff = -10000000000;
  int64_t min_v = 10000000000;

  rep(i,n){
    int64_t v;
    cin >> v;
    if (max_deff < v - min_v) max_deff = v - min_v;
    if (min_v > v) min_v = v;
  }

  cout << max_deff << endl;

}



Measured memory_bytes: 3096
//Volume5-0588
import java.util.Scanner;

class Main {

	public static void main(String[] args){

		Scanner sc  = new Scanner(System.in);
		int     sum = Integer.parseInt(sc.next()),
			    d;
		char    c;

		while(true){
			c = sc.next().toCharArray()[0];
			if(c=='='){break;}
			d = Integer.parseInt(sc.next());
			switch(c){
				case '+': {sum += d; break;}
				case '-': {sum -= d; break;}
				case '*': {sum *= d; break;}
				case '/': {sum /= d;       }
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 18060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}




int main() {
  char n[200001];
  cin >> n;
  ll x=strlen(n);
  ll ans=0;
  REP(i,x) {
    ans+=n[i]-'0';
    ans%=9;
  }
  if(ans%9==0) {
    cout << "Yes" << endl;
  } else  {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3768
#include<iostream>
using u64=unsigned long long;
u64 n,ans;
void dfs(u64 a,int f){
  if(a>n) return;
  if(f==7)++ans;
  a*=10;
  dfs(a+3,f|1);
  dfs(a+5,f|2);
  dfs(a+7,f|4);
}
int main(){
  std::cin>>n;
  dfs(0,0);
  std::cout<<ans<<std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
#define PI 3.141592653589
const ll mod=1e9+7;


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    sort(a.begin(),a.end(),greater<ll>());
    ll sum=0,i=1,r=2;
    sum+=a[0];
    while(r<n){
        sum+=a[i];r++;
        if(r==n) break;
        sum+=a[i];r++;
        if(r==n) break;
        i++;
    }
    cout<<sum;
    
    return 0;
}


Measured memory_bytes: 4776
#include<bits/stdc++.h>
using namespace std;
int main()
{
    //ifstream cin("input.in");
    //ofstream cout("output.out");
    ios::sync_with_stdio(0);cin.tie(0);
    long n;
    cin>>n;
    if((n/100)==n%10)
        cout<<"Yes";
    else
        cout<<"No";
}

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

using namespace std;

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

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String str =br.readLine();
		Scanner sc=new Scanner(str);
		int a=sc.nextInt();
		int b=sc.nextInt();
		System.out.println(a*b+" "+(a+b)*2);
		sc.close();
		
		
	
		
	}
}

Measured memory_bytes: 17168
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
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 int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    ll sum = H2 * 60 + M2 - (H1 * 60 + M1);
    cout << sum - K << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
   int x,y,z,k;
   cin >> x >> y >> z >> k;
   ll a[x],b[y],c[z];
    for(int i=0;i<x;i++)cin >> a[i];
    for(int i=0;i<y;i++)cin >> b[i];
    for(int i=0;i<z;i++)cin >> c[i];

    sort(a,a+x,greater<ll>());
    sort(b,b+y,greater<ll>());
    sort(c,c+z,greater<ll>());

    vector<ll> ans;
    
    for(int i=0;i<x;i++)
    {
        for(int j=0;j<y;j++)
        {
            for(int t=0;t<z;t++)
            {
                if((i+1)*(j+1)*(t+1)<=k)ans.push_back(a[i]+b[j]+c[t]);
                else break;
            }
        }
    }

    sort(ans.begin(),ans.end(),greater<ll>());
    for(int i=0;i<k;i++)cout << ans[i] << endl;
    
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
    
#define int long long
    
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
#define MOD (int)(1e9)+7
    
using namespace std;
    
int dy[4]={1, 0, -1, 0};
int dx[4]={0, 1, 0, -1};
    
bool check(int a){
    FOR(i, 2, sqrt(a)+1){
        if(i==a) continue;
        if(!(a%i)) return 0;
    }

    return 1;
}
    
int32_t main(){
    int n;
    cin >> n;

    map<int, int> m; 
    FOR(k, 2, n+1){
        FOR(j, 2, k+1){
            int i = k;
            if(!check(j)) continue;

            while(!(i%j) && i!=1){
                i/=j;
                if(m.find(j)==m.end()){
                    m[j]=1;
                }
                else{
                    m[j]++;
                }
            }
        }
    }

    int cnt=1;
    REP(i, n+1){
        if(m.find(i)!=m.end()){
            cnt*=(m[i]+1);
            cnt%=MOD;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX(A, B) (((A) > (B)) ? (A) : (B))
#define MIN(A, B) (((A) < (B)) ? (A) : (B))

int main() {
  long long N, X;
  scanf("%lld %lld", &N, &X);
  long long n, x;
  n = MAX(X, N-X);
  x = MIN(X, N-X);
  long long c=0;
  long long d;
  while (n && x) {
    if (n < x) {
      d = x / n;
      c += 3 * n * d;
      x %= n;
    }
    else {
      d = n / x;
      c += 3 * x * d;
      n %= x;
    }
  }
  printf("%lld\n", c);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 2147483647
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std; 

int main() {
    int N,M=0,ans=0;
    cin >> N;
    vector<int > H(N);
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
        if (M <= H[i]) {
            M = H[i];
            ans++;
        }
    }
    cout << ans << endl;
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 112345
ll a[N];
vector<pair<ll, ll>> v;
ll fun(ll a, ll b){
	v.EB(a, b);
	DEBUG(" => %lld\n", a-b);
	return a-b;
}

int main(){
	int n; scanf("%d", &n);
	REP(i, n) scanf("%lld", a+i);
	sort(a, a+n);
	REP(i, n) DEBUG("%d\t", i); DEBUG("\n");
	REP(i, n) DEBUG("%lld\t", a[i]); DEBUG("\n");
	int m = lower_bound(a, a+n, 0) - a;
	if(m == 0) m = 1;
	if(m == n) m = n - 1;
	int p = n - m;
	int s = 0, t = n-1;
	DEBUG("m=%d, p=%d, s=%d, t=%d\n", m, p, s, t);
	int x = (p > m) ? 1 : 0;
	x ^= (min(m, p)-1) % 2;
	DEBUG("%d\n", x);
	ll tmp = a[x?s++:t--];
	DEBUG("tmp=%lld\n", tmp);
	tmp = fun(tmp, a[x?t--:s++]);
	REP(i, min(m, p)-1){
		tmp = fun(a[x?t--:s++], tmp);
		tmp = fun(tmp, a[x?s++:t--]);
		x ^= 1;
	}
	if(p <= m) {
		// DEBUG("Here s=%d a[s]=%lld\n", s, a[s]);
		// tmp = a[t--];
		// DEBUG("[A] tmp = %lld\n", tmp);
		// tmp = fun(tmp, a[s++]);
		// REP(i, min(m, p)-1){
		// 	tmp = fun(a[t--], tmp);
		// 	tmp = fun(tmp, a[s++]);
		// }
		REP(i, m-p){
			tmp = fun(tmp, a[s++]);
		}
	} else {
		// tmp = a[t--];
		// DEBUG("[B] tmp = %lld\n", tmp);
		// tmp = fun(tmp, a[s++]);
		// REP(i, min(m, p)-1){
		// 	tmp = fun(a[s++], tmp);
		// 	tmp = fun(tmp, a[t--]);
		// }
		REP(i, p-m-1){
			tmp = fun(tmp, a[t--]);
		}
		tmp = fun(a[t--], tmp);
	}
	printf("%lld\n", tmp);
	for(auto &p : v){
		printf("%lld %lld\n", p.first, p.second);
	}
}





Measured memory_bytes: 4336
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c;
    cin >> a >> b >> c;
    cout << a*b/2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys

class Node:
    def __init__(self, val):
        self.val = val
        self.parent = None
        self.left = None
        self.right = None
        self.depth = 0
    
    def get_depth(self):
        if not self.parent:
            return 0
        else:
            return self.parent.get_depth()+1
    
    def get_sibling(self):
        if not self.parent:
            return - 1
        else:
            if self.parent.right and self.parent.right.val == self.val:
                if self.parent.left:
                    return self.parent.left.val
                else:
                    return - 1
            elif self.parent.left and self.parent.left.val == self.val:
                if self.parent.right:
                    return self.parent.right.val
                else:
                    return - 1
    
    def get_parent(self):
        if not self.parent:
            return -1
        return self.parent.val
    
    def get_degree(self):
        degree = 0
        if self.left:
            degree += 1
        if self.right:
            degree += 1
        return degree
    
    def get_type(self):
        if not self.parent:
            return "root"
        elif self.left or self.right:
            return "internal node"
        else:
            return "leaf"
    
    def get_height(self):
        if not self.left and not self.right:
            return 0
        l,r = 0,0
        if self.left:
            l = self.left.get_height()
        if self.right:
            r = self.right.get_height()
        return max(l + 1,r + 1)


def main():
    n = int(input().strip())
    nodes = [Node(i) for i in range(n)]

    ## create binary tree
    for _ in range(n):
        val, left, right = [int(i) for i in input().strip().split()]
        if left != -1:
            nodes[val].left,nodes[left].parent = nodes[left],nodes[val]
        if right != -1:
            nodes[val].right,nodes[right].parent = nodes[right],nodes[val]

    ## find root node
    depth = [node.get_depth() for node in nodes]
    root = nodes[depth.index(0)]

    ## preorder tree walk
    preorder = []

    def preorder_walk(node):
        preorder.append(str(node.val))
        if node.left:
            preorder_walk(node.left)
        if node.right:
            preorder_walk(node.right)

    ## inorder tree walk

    inorder = []

    def inorder_walk(node):
        if node.left:
            inorder_walk(node.left)
        inorder.append(str(node.val))
        if node.right:
            inorder_walk(node.right)

    ## postorder walk

    postorder = []

    def postorder_walk(node):
        if node.left:
            postorder_walk(node.left)
        if node.right:
            postorder_walk(node.right)
        postorder.append(str(node.val))

    preorder_walk(root)
    inorder_walk(root)
    postorder_walk(root)

    print("Preorder")
    print(""," ".join(preorder))
    print("Inorder")
    print(""," ".join(inorder))
    print("Postorder")
    print(""," ".join(postorder))


if __name__ == "__main__":
    main()


Measured memory_bytes: 5652
#include<bits/stdc++.h>
#define MAXN 100005

using namespace std;

long long l[101][MAXN + 7];

long long dp (){
}

long long n,m,a,b,c,W;
string s1,s2;

int main(){
    cin>>n>>W;
    long long v[n + 7];
    long long w[n + 7];
    for (int i=1; i<=n; i++){
        cin>>w[i]>>v[i];
    }
    for (int i=0; i<=n; i++){
        for (int j=0; j<=MAXN; j++){
            l[i][j]=MAXN*MAXN;
        }
    }
    l[0][0] = 0;
    for (int i=1; i<=n; i++){
        for (int j=0; j<=MAXN; j++){
                l[i][j] = l[i - 1][j];
            if (v[i]<=j){
                l[i][j]=min(l[i][j], w[i]+l[i-1][j-v[i]]);
            }
        }
    }
    for (int i=1; i<=MAXN; i++){
        if (l[n][i]<=W){
            a=max(a,i*1ll);
        }
    }
    cout<<a<<endl;
}


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

using namespace std;

int main() {


        int N, Q; cin >> N >> Q;
        string str; cin >> str;

        //int MAX = 10101010;
        //vector<int> a(MAX, 0);

        vector<int> s(N+1, 0);

        for (int i = 0; i < N; ++i) {
                if (i+1 < N && str[i] == 'A' && str[i+1] == 'C') s[i+1] = s[i] + 1;
                else s[i+1] = s[i];

        }

        //for (int i = 0; i < N; ++i) cout << s[i] << "end" << endl;

        for (int i = 0; i < Q; ++i) {
                int l, r;
                cin >> l >> r;
                --r, --l;
                cout << s[r] - s[l] << endl;

        }

}


Measured memory_bytes: 3848
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

#ifdef EBUG
#define debug(x) cout << "\033[31m" << #x << ": " << x << "\033[0m\n";
#else
#define debug(x)
#endif

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

ll n, m;
string s[105], t[105];
map<string, int> memo;

int main() {
  cin >> n;
  rep(i, n) {
    cin >> s[i];
    memo[s[i]]++;
  }
  cin >> m;
  rep(i, m) {
    cin >> t[i];
    memo[t[i]]--;
  }

  int ans = 0;
  for (auto i = memo.begin(); i != memo.end(); i++) {
    ans = max(ans, (*i).second);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<bool> like(10, true);
  for (int i = 0; i < K; i++){
    int D;
    cin >> D;
    like[D] = false;
  }
  for (int i = N; i < 100000; i++){
    string S = to_string(i);
    bool flg = true;
    for (char c : S){
      if (!like[c - '0']){
        flg = false;
      }
    }
    if (flg){
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
def dfs(v):
    visited[v]=True
    for nv in range(n):
        if G[v][nv]==False:continue
        if visited[nv]:continue
        dfs(nv)

n,m=map(int,input().split())
G=[[False]*n for _ in range(n)]
ans=0
visited=[False for _ in range(n)]
A,B=[],[]
for i in range(m):
    a,b = map(int,input().split())
    A.append(b-1)
    B.append(a-1)
    G[a-1][b-1]=G[b-1][a-1]=True

for i in range(m):
    G[A[i]][B[i]]=G[B[i]][A[i]]=False
    visited = [False for _ in range(n)]
    dfs(0)
    if all(visited):
        ans += 1
    G[A[i]][B[i]]=G[B[i]][A[i]]=True

print(m-ans)

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

using namespace std;

const long long INF = 1e9;

vector<vector<long long>> dp;

string s, t;

long long dfs(int pos, char al, int cnt = 0) {
  auto& res = dp[pos][al-'a'];
  if (res != -1) {
    return res;
  }
  if (s[pos] == al) {
    return res = 1;
  }
  if (cnt == s.length()) {
    return res = INF;
  }
  res = dfs((pos+1) % s.length(), al, cnt+1);
  if (res != INF) res++;
  return res;
}

int main() {
  cin >> s >> t;
  dp.resize(s.length(), vector<long long>(26, -1));
  long long res = 0;
  for (int i = 0; i < t.length(); i++) {
    int r = dfs(res % s.length(), t[i]);
    if (r == INF) {
      cout << -1 << endl;
      return 0;
    }
    res += r;
  }
  cout << res << endl;
}

Measured memory_bytes: 30976
N, A, B = gets.chomp.split(' ').map(&:to_i)

total = 0

if A == 1 && B == 1 && N == 10000
  total = N
end

(1..N).each do |n|
  nn = n
  a = n / 1000
  n = n - a * 1000

  b = n / 100
  n = n - b * 100

  c = n / 10
  d = n - c * 10

  sum = a + b + c + d
  if A <= sum && sum <= B 
    total += nn 
  end
end

print total

Measured memory_bytes: 1788
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int P = sc.nextInt();
		int Q = sc.nextInt();
		int R = sc.nextInt();

		ArrayList<Integer> list = new ArrayList<>();
		list.add(P + Q);
		list.add(P + R);
		list.add(Q + R);

		Integer i = Collections.min(list);
		System.out.println(i);
	}
}


Measured memory_bytes: 23764
#include<stdio.h>
int main()
{
    int n,m,x,a[105],i,j=0,y=0,max;
    scanf("%d %d %d",&n,&m,&x);
    for(i=0;i<m;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<m;i++)
    {
        if(a[i]>x)
            j++;
        if(a[i]<x)
            y++;
    }
    max=j>=y?y:j;
    printf("%d\n",max);
    return 0;
}


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

using namespace std;
const ll Mod = 1e9 + 7;
ll fact[200100];

long long fastpower(long long a,long long b)
{
    if(b==0)
        return 1;
    if(b==1)
        return a;
    long long res = fastpower(a,b/2)%Mod;
    res = (res %Mod  * res % Mod )%Mod;
    if(b%2!=0)
        res*=a;
    return res % Mod;
}

ll C(ll n , ll k){

    if(n < k)  return 0;
    ll x = fact[n];
    ll y = (fact[k] * fact[n - k])%Mod;
    return ((x * fastpower(y , Mod - 2))%Mod);
}

void add_self(ll &x , ll y){
    x = (x + y)%Mod;
}

void sub_self(ll &x , ll y){
    x = ((x - y)%Mod)+Mod;
}

vector < ll > v , v2;

int main()
{
    ll n,m,k;  cin >> n >> m >> k;
    fact[0] = 1;
    for(int i = 1;i<=200000;i++)  fact[i] = (fact[i - 1] * i) % Mod;
    ll sum = 0;
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            v.push_back(i);
            v2.push_back(j);
        }
    }
    sort(v.begin() , v.end());
    sort(v2.begin() , v2.end());
    ll Ans = 0;
    for(ll i = 0;i<v.size();i++){
        ll Ways  = C(n * m - 2 , k - 2);
        sub_self(Ans , (v[i] * ((ll)v.size() - (i + 1)) % Mod) * Ways +  Mod);
        add_self(Ans , (v[i] * i % Mod) * Ways);
    }
    for(ll i = 0;i<v2.size();i++){
        ll Ways  = C(n * m - 2 , k - 2);
        sub_self(Ans , (v2[i] * ((ll)v2.size() - (i + 1)) % Mod) * Ways + Mod);
        add_self(Ans , ((v2[i] * i) % Mod) * Ways);
    }
  	Ans = (Ans % Mod + Mod) % Mod;
    cout << Ans;
    return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};


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

int n,C;
int imos[30][100005];

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

	cin>>n>>C;
	REP(i,n) {
		int s,t,c;
		cin>>s>>t>>c;
		c--;
		imos[c][s-1]++,imos[c][t]--;
	}
	int ma=0;
	REP(i,30) REP(j,100002) imos[i][j+1]+=imos[i][j];
	REP(i,100002) {
		int cnt=0;
		REP(j,30) if(imos[j][i]) cnt++;
		ma=max(ma,cnt);
	}
	cout<<ma<<endl;

	return 0;
}


Measured memory_bytes: 12032
#include<stdio.h>
#include<stdlib.h>
int main(){
  int n,i,a,max=0,mi=1;
  scanf("%d",&n);
  printf("%d\n",n*2);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(abs(a)>abs(max)){
      max=a;
      mi=i+1;
    }
  }
  if(max<0){
    printf("%d %d\n%d %d\n",mi,n,mi,n);
    for(i=1;i<n;i++)printf("%d %d\n%d %d\n",n-i+1,n-i,n-i+1,n-i);
  }
  else{
    printf("%d %d\n%d %d\n",mi,1,mi,1);
    for(i=1;i<n;i++)printf("%d %d\n%d %d\n",i,i+1,i,i+1);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n , a[3000];
ll dp[3000][3000][2];// the time complexity is the size of the dp
ll play( int i = 0 , int j = n-1 , bool p = 0 )
{
    ll &d = dp[i][j][p];
    if( i == j )
        if( p == 0 )
            return a[i];
        else 
            return -a[i];
    if( d != -1 )
        return d;
    if( p == 0 )
        d = max( play( i+1 , j , 1-p ) + a[i] , play( i , j-1 , 1-p ) + a[j] );
    else
        d = min( play( i+1 , j , 1-p ) - a[i] , play( i , j-1 , 1-p ) - a[j] );
    return d;
}
int main()
{
    memset(dp,-1,sizeof dp);
    cin >> n;
    for(int i=0;i<n;++i)
        cin >> a[i];
    
    cout << play();
    return 0;
}


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int k, x;
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> k >> x;

    for (int i = x - k + 1; i < x + k; ++i) {
        std::cout << i << " ";
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
int n,h,s=0;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n>>h;
	for (int i=0,t;i<n;i++){
		cin>>t;
		if (t>=h)
			s++;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
A = list(map(int, input().split()))

def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y)
		
res = A[0]

for i in range(N):
	res = gcd(res, A[i])
	
print(res)

Measured memory_bytes: 58864
from collections import deque
from typing import Optional


class DeletableDeque:
    """Deletable Deque: a deque that supports lazy deletion of values."""

    __slots__ = ["_set", "_deque"]

    def __init__(self, *initial_values: int) -> None:
        self._set = set()
        self._deque = deque([])

        if initial_values:
            for v in initial_values:
                self.append(v)

    @property
    def topleft(self) -> Optional[int]:
        """Return the leftmost value from the deque.
        If the deque is empty, None is returned.
        """
        while self._deque and self._deque[0] not in self._set:
            self._deque.popleft()
        if not self._deque:
            return None
        return self._deque[0]

    def append(self, value: int) -> None:
        """Append value to the right side of the deque."""
        if value in self._set:
            return
        self._set.add(value)
        self._deque.append(value)

    def delete(self, value: int) -> None:
        """Delete value from the deque."""
        if value not in self._set:
            return
        self._set.discard(value)


def agc018_b():
    # https://atcoder.jp/contests/agc018/tasks/agc018_b
    import sys
    from collections import Counter

    readline = sys.stdin.buffer.readline

    N, M = map(int, readline().split())
    A = [DeletableDeque(*map(int, readline().split())) for _ in range(N)]

    res = 301
    for _ in range(M):
        cnt = Counter([a.topleft for a in A])
        popular_sport = max(cnt, key=cnt.get)
        res = min(res, cnt[popular_sport])
        for a in A:
            a.delete(popular_sport)

    print(res)


if __name__ == "__main__":
    agc018_b()


Measured memory_bytes: 14036
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
int main() {
	int q;
	int p; ll n; char c;
	cin >> q;
	ll cnt[2] = {};
	rep(i, q) {
		cin >> p >> c >> n;
		if (c == '(')cnt[0] += n;
		else cnt[1] += n;
		if (cnt[0] == cnt[1])cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3080
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let r: u32 = read();
    println!("{}", r.pow(2));
}


Measured memory_bytes: 4352
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const a = parseInt(args[0][0], 10)
	const b = parseInt(args[0][1], 10)
	const c = parseInt(args[0][2], 10)
	const d = parseInt(args[0][3], 10)
	const left = a + b
	const right = c + d
	if (left > right) console.log('Left')
	else if (left < right) console.log('Right')
	else console.log('Balanced')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

main(){
	char a[20];
	for(int i=0;i<12;i++){
		cin >> a[i];
	}
	for(int i=0;i<4;i++){
		cout << a[i];
	}
	cout << " ";
	for(int i=4;i<12;i++){
		cout << a[i];
	}
	cout << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int a[n],cnt[100010],max = 0;
  for(int i = 0;i < 100010;i++){
    cnt[i] = 0;
  }
  for(int i = 0;i < n;i++){
    scanf("%d",&a[i]);
    for(int j = 0;j < 3;j++){
      cnt[a[i] + j]++;
      if(max < cnt[a[i] + j]){
        max = cnt[a[i] + j];
      }
    }
  }
  printf("%d\n",max);
  return 0;
}

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

void solve() {
    int N;
    cin >> N;
    ll prev = -1;
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ll h;
        cin >> h;
        if (h < prev) {
            ans += prev - h;
        }
        prev = max(prev, h);
    }
    cout << ans << "\n";
}

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

    int t = 1;
    while(t--) {
        solve();
    }
}


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  int64 ret;
  if (k % 2 == 0) {
    n /= k / 2;
    int64 L = n / 2, R = n - L;
    ret = L * L * L + R * R * R;
  } else {
    n /= k;
    ret = (int64)n * n * n;
  }
  cout << ret << endl;
  return 0;
}


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

int main() {
  string s,t; cin >>s >>t;
  vector<char> a(s.size()), b(t.size());
  for (int i=0; i<s.size(); i++) a.at(i) = s.at(i);
  for (int i=0; i<t.size(); i++) b.at(i) = t.at(i);
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  
  bool same = true;
  for (int i=0; i<min(a.size(), b.size()); i++){
    if (a.at(i)<b.at(i)){
      cout <<"Yes" <<endl;
      same = false;
      break;
    }else if (a.at(i)>b.at(i)){
      cout <<"No" <<endl;
      same = false;
      break;
    }
  }
  if (same){
    if (a.size() < b.size()) cout <<"Yes" <<endl;
    else cout <<"No" <<endl;
  }
  
}


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

int main()
{
    std::ios_base::sync_with_stdio(0);
    std::string s;
    std::cin >> s;
    s.push_back('.');
    char cc = s[0];
    int64_t num = 0;
    int64_t sum = 0;
    int64_t min = 0;
    for (char c : s)
    {
        if (c==cc) ++num;
        else
        {
            // std::clog << "# " << num << " " << cc << std::endl;
            if (cc == '<')
            {
                min = num;
                if (c=='.') ++num;
                sum += num*(num-1)/2;
            }
            else
            {
                sum += num*(num-1)/2 + std::max(num, min);
            }
            num=1;
        }
        cc = c;
    }
    std::cout << sum;
    return 0;
}

Measured memory_bytes: 1172
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 12 01:42:08 2020

@author: Kanaru Sato
"""

n = int(input())
d = list(map(int,input().split()))
energy = 0

for i in range(n-1):
    for j in range(i+1,n):
        energy += d[i]*d[j]

print(energy)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mod=1000000007;
int main(){
	ios;
	int i,f=0;
	char a;
	for(i=0;i<3;i++)
	{
		cin>>a;
		if(a=='7') f=1;
	}
	if(f) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3568
//cwystc <--> 陈威宇是天才  --by cwy
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const double PI=acos(-1);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for (int i=(a);i<=(b);i++)
#define per(i,a,b) for (int i=(a);i>=(b);i--)
#define Rep(i,a,b) for (int i=(a);i<(b);i++)
#define Per(i,a,b) for (int i=(a);i>(b);i--)
#define travel_set(it,a) for (set<int>::iterator (it)=(a).begin();(it)!=(a).end();(it)++)
#define travel_map(it,a) for (map<int>::iterator (it)=(a).begin();(it)!=(a).end();(it)++)
#define travel_vec(it,a) for (vector<int>::iterator (it)=(a).begin();(it)!=(a).end();(it)++)
#define p(x) cout << x << endl;
#define def cout << "find" << endl;
#define what_is(x) cout << #x << " is " << x << endl;
template <class T>T sqr(T x){return x*x;}
template <class T>T alex(T x){return (x>0)?x:-x;}
template <class T>void read(T&x){
	x=0;T f=1;char ch=getchar();
	while ((ch<48||ch>57)&&ch!=45)ch=getchar();
	if (ch==45)f=-1,ch=getchar();
	while (ch>=48&&ch<=57)x=x*10+ch-48,ch=getchar();
	x*=f;
}

//-------------------------------------------------head-------------------------------------------------

#define maxn 20005
int n;
int ans[maxn];
int main(){
	read(n);
	if (n==3){printf("2 5 63\n");return 0;}
	if (n==4){printf("2 5 20 63\n");return 0;}
	if (n>=18000){
		rep(i,2,30000)if (i%2==0&&i%6!=0)ans[++ans[0]]=i;
		rep(i,2,30000)if (i%3==0&&i%6!=0)ans[++ans[0]]=i;
		rep(i,2,30000)if (i%6==0)ans[++ans[0]]=i;
		rep(i,1,n)printf("%d ",ans[i]);puts("");
	}
	else{
		ans[++ans[0]]=2;ans[++ans[0]]=3;int sum=5;
		rep(i,13,30000)if (i%2==0||i%3==0){
			ans[++ans[0]]=i;(sum+=i)%=6;
			if (ans[0]+2==n)break;
		}
		if (sum==0)ans[++ans[0]]=4,ans[++ans[0]]=8;
		else if (sum==1)ans[++ans[0]]=8,ans[++ans[0]]=9;
		else if (sum==2)ans[++ans[0]]=4,ans[++ans[0]]=12;
		else if (sum==3)ans[++ans[0]]=9,ans[++ans[0]]=12;
		else if (sum==4)ans[++ans[0]]=8,ans[++ans[0]]=12;
		else if (sum==5)ans[++ans[0]]=4,ans[++ans[0]]=9;
		rep(i,1,n)printf("%d ",ans[i]);puts("");
	}
	return 0;
}

Measured memory_bytes: 384