akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>

using namespace std;

const long long mod = 1e9 + 7;

struct Foo {
  long long v0;
  long long v1;
  long long v2;

  Foo() : v0(0), v1(0), v2(0) {}
  Foo(long long v0, long long v1, long long v2) : v0(v0), v1(v1), v2(v2) {}
};

long long modpow(long long a, long long b) {
  long long ret = 1;
  while (b > 0) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  n++;
  vector<int> p(n, -1);
  vector<int> depth(n);
  vector< vector<int> > g(n);
  vector<int> cnt(n);
  for (int i = 1; i < n; i++) {
    cin >> p[i];
    depth[i] = depth[ p[i] ] + 1;
    g[ p[i] ].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    cnt[ depth[i] ]++;
  }

  //                  depth, val
  vector< deque< pair<int,   Foo> > > dp(n);

  for (int i = n - 1; i >= 0; i--) {
    dp[i].emplace_back(depth[i], Foo(1, 1, 0));

    int mx = 1;

    for (int j : g[i]) {
      dp[j].emplace_front(depth[i], Foo(1, 0, 0));
      // merge
      if (dp[i].size() < dp[j].size()) swap(dp[i], dp[j]);

      mx = max<int>(mx, dp[j].size());

      for (int k = 0; k < dp[j].size(); k++) {
        if (dp[i][k].first != dp[j][k].first) {
          cout << "ERR" << endl;
        }
        Foo a = dp[i][k].second;
        Foo b = dp[j][k].second;

        Foo c;
        c.v0 = a.v0*b.v0 % mod;
        c.v1 = (a.v1*b.v0 + a.v0*b.v1) % mod;
        c.v2 = (a.v2*b.v0 + a.v1*b.v1 + a.v0*b.v2 + a.v1*b.v2 + a.v2*b.v1 + a.v2*b.v2) % mod;
        dp[i][k].second = c;
      }
    }

    for (int k = 0; k < mx; k++) {
      (dp[i][k].second.v0 += dp[i][k].second.v2) %= mod;
      dp[i][k].second.v2 = 0;
    }
  }

  long long ret = 0;
  for (auto p : dp[0]) {
    ret += modpow(2, n - cnt[p.first]) * p.second.v1;
    ret %= mod;
  }

  cout << ret << endl;
}


Measured memory_bytes: 245620
#N = gets.to_i
DBG = false

def check(n)
    if (n <= N && n.to_s <= N.to_s) || (n > N && n.to_s > N.to_s)
        ret = 'Y'
    else
        ret = 'N'
    end
    p [n, ret]
    ret
end

ns = ''
ZEROS = '00000000000'
NINES = '99999999999'
loop do
    exit if ns.length > 10
    lb = ns.length == 0 ? 0 : -1
    ub = 10
    while ub - lb > 1
        mid = (ub+lb)/2
        query = (ns.to_s + mid.to_s + ZEROS)[0, 17]
        puts '? ' + query
        $stdout.flush
        ans = DBG ? check(query.to_i) : gets.chomp
        if ans == 'Y'
            ub = mid
        else
            lb = mid
        end
    end
    if lb == -1
        if ns[-1] == '9'
            query = ns[0, ns.length-1] + '80'
            puts '? ' + query
            $stdout.flush
            ans = DBG ? check(query.to_i) : gets.chomp
            if ans == 'N'
                puts '! ' + ns
                exit
            end
        else
            query = ns[0, ns.length-1] + (ns[-1].to_i+1).to_s
            puts '? ' + query
            $stdout.flush
            ans = DBG ? check(query.to_i) : gets.chomp
            if ans == 'Y'
                puts '! ' + ns
                exit
            end
        end
        ns << '0'
    elsif lb != 9
        query = ns + (lb.to_i+1).to_s
        puts '? ' + query
        $stdout.flush
        ans = DBG ? check(query.to_i) : gets.chomp
        if ans == 'Y'
            ns << (lb.to_i+1).to_s
        else
            ns << lb.to_s
        end
    else
        query = (ns + '8' + NINES)[0, 17]
        puts '? ' + query
        $stdout.flush
        ans = DBG ? check(query.to_i) : gets.chomp
        if ans == 'Y'
            ns << '8'
        else
            ns << '9'
        end
    end
end


Measured memory_bytes: 2252
# input
A, B, C, K = map(int, input().split())

# check
result_score = 0
for score, i in [(1, A), (0, B), (-1, C)]:
        if K <= 0:
               continue

        if K >= i:
            result_score += score * i
            K -= i
        else:
            result_score += score * K
            K = 0

print(result_score)

Measured memory_bytes: 9132
// ABC112_A
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    ll N, A, B;
    cin >> N;
    // vector<ll> vec(N);
    // REP(i, N) cin >> vec[i];
    
    // calculation
    if (N == 1) {
        cout << "Hello World" << "\n";
    } else {
        cin >> A >> B;
        cout << A+B << "\n";
    }
    
    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;
typedef long long ll;
const int INF = (1<<30);
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
struct edge {
    int to;
    ll cost;
};
 
int main() {
    int N;
    scanf("%d", &N);
    vector<edge> tree[N];
    rep(i, N-1){
        int a,b,c;
        scanf("%d%d%d", &a, &b, &c);
        a--; b--;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }
    int Q, K;
    scanf("%d%d", &Q, &K);
    K--;
    stack<edge> s;
    s.push({K, 0});
    ll depth[N];
    rep(i, N) depth[i] = -1;
    while(!s.empty()){
        edge from = s.top();
        s.pop();
        depth[from.to] = from.cost;
        for(const edge &to : tree[from.to]){
            if(depth[to.to] == -1) s.push({to.to, to.cost + from.cost});
        }
    }
    rep(i, Q){
        int x, y;
        scanf("%d%d", &x, &y);
        x--, y--;
        printf("%lld\n", depth[x] + depth[y]);
    }
 
    return 0;
}


Measured memory_bytes: 10736
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mp make_pair
using namespace std;

using ll = long long;
using ii = pair<int, int>;
const int INF = (int)10e9;
int N, K;
vector<int> v;
vector<int> dp;

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

    cin >> N >> K;
    v.resize(N);
    dp.resize(N);
    fill(all(dp), 0);

    for(int i = 0; i < N; i++) {
        cin >> v[i];
    }

    for(int i = 1; i < N; i++) {
        dp[i] = INF;
        for(int j = 1; j <= K; j++) {
            if(i - j >= 0) dp[i] = min(dp[i], abs(v[i] - v[i-j]) + dp[i-j]);
        }
    }

    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
bord = Array.new(50){Array.new(100){'.'}} + Array.new(50){Array.new(100){'#'}}
a, b = gets.chomp.split.map(&:to_i)

(a - 1).times do |i|
  bord[51 + (i / 50) * 2][(i % 50) * 2] = '.'
end

(b - 1).times do |i|
  bord[(i / 50) * 2][(i % 50) * 2] = '#'
end

puts '100 100'
puts bord.map(&:join)

Measured memory_bytes: 2172
// フェルマーの小定理
package main

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

const (
	m = 998244353
)

func mpow(x, y int) int {
	result := 1
	for y != 0 {
		if y&1 == 1 {
			result *= x
			result %= m
		}
		x *= x
		x %= m
		y >>= 1
	}
	return result
}

var (
	fac []int
)

func mcomb(n, k int) int {
	if n == 0 && k == 0 {
		return 1
	}
	if n < k || k < 0 {
		return 0
	}
	return (fac[n] * mpow(fac[n-k], m-2) % m) * mpow(fac[k], m-2) % m
}

func main() {
	defer flush()

	N := readInt()
	M := readInt()
	K := readInt()

	fac = make([]int, N+1)
	fac[0] = 1
	for i := 0; i < N; i++ {
		fac[i+1] = fac[i] * (i + 1) % m
	}

	result := 0
	for i := 0; i < K+1; i++ {
		t := M * mcomb(N-1, i)
		t %= m
		t *= mpow(M-1, N-1-i)
		t %= m
		result += t
		result %= m
	}
	println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdoutWriter, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 3448
#include<iostream>
using namespace std;
int main()
{
    int n,n1,n2,n3;
    scanf("%d",&n);


    n1 = n % 100;
    n2 = n /100;
    n3 = n2 % 100;
    //printf("%d %d",n3,n1);
    if((n3==0 && n1 == 0) || (n3>12 && n1==0) || (n3==0 && n1>12) || (n3>12 && n1 > 12))
    {
        printf("NA");
    }
    else if(n3!=0 && n1!=0 )
    {
        if(n3<=12 && n1 <= 12)
            printf("AMBIGUOUS");
        else if(n3<=12 && n1>12)
        printf("MMYY");
        else if(n3>12 && n1<=12)
        printf("YYMM");
    }
    else if((n1==0 || n3==0))
    {
        if(n3==0)
            printf("YYMM");
        else if(n1==0)
            printf("MMYY");

    }


}

Measured memory_bytes: 3736
local read = io.read
local min = math.min

local n, k = read("n", "n")
local a_t = {}
local min_num = math.maxinteger
for i = 1, n do
	local a_i = read("n")
	a_t[i] = a_i
	min_num = min(min_num, a_i)
end

local not_min_amount = 0
for i = 1, n do
	if a_t[i] ~= min_num then
		not_min_amount = not_min_amount + 1
	end
end

print(math.ceil(not_min_amount / (k - 1)))


Measured memory_bytes: 4248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m,k;
    cin >> n >> m >> k;
    int a[m];
    int b[m];
    int c[k];
    int d[k];

    rep(i,m) cin >> a[i] >> b[i];
    rep(i,m) a[i]--;
    rep(i,m) b[i]--;
    rep(i,k) cin >> c[i] >> d[i];
    rep(i, k) c[i]--;
    rep(i, k) d[i]--;

    UnionFind uf(n);
    int cnt[n];
    rep(i,n) cnt[i]=0;
    rep(i,m)
    {
        uf.unite(a[i], b[i]);
        cnt[a[i]]++;
        cnt[b[i]]++;
    }

    int blockcount[n];
    rep(i,n) blockcount[i]=0;
    rep(i,k)
    {
        if (uf.find(c[i]) == uf.find(d[i]))
        {
            blockcount[c[i]]++;
            blockcount[d[i]]++;
        }
    }
    rep(i,n)
    {
        cout << uf.size(i) - cnt[i] - blockcount[i] -1;
        if (i!=n-1)
        {
            cout << " ";
        }
    }
    cout << endl;

    
}




Measured memory_bytes: 3584
/* ex4_2
   YSK722 */

#include <math.h>
#include <stdio.h>

int main(void){
    double short_hand, long_hand, hour, minute, ans, angle_diff;
    scanf("%lf %lf %lf %lf", &short_hand, &long_hand, &hour, &minute);
    // 短針と長針の角度の差を求める
    angle_diff = 2 * M_PI * ((hour + minute/60.0) / 12 - minute / 60);
    /* 余弦定理を用いる
       cos(-x) = cos(x)より、回転角の大小は考えない */
    ans = sqrt(
              pow(short_hand, 2) + pow(long_hand, 2) \
              - 2 * short_hand * long_hand * cos(angle_diff)
          );
    printf("%.9lf\n", ans);
    return 0;
}

Measured memory_bytes: 2580
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
	int n; cin >> n;
	vector<string> s(n);
	vector<int> t(n);
	for (int i = 0; i < n; ++i) cin >> s[i] >> t[i];
	string x; cin >> x;
	bool flag = false;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (flag) ans += t[i];
		if (s[i] == x) flag = true;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		char[] s = new Scanner(System.in).next().toCharArray();
		Arrays.sort(s);
		System.out.println(s[0] == s[1] && s[2] == s[3] && s[1] != s[2] ? "Yes" : "No");
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
            #include<iostream>
            #include<cstdio>
            #include<vector>
            #include<queue>
            #include<map>
            #include<cstring>
            #include<string>
            #include <math.h>
            #include<algorithm>
        //    #include <boost/multiprecision/cpp_int.hpp>
            #include<functional>
          #define int long long
            #define mod  1000000007
            #define pa pair<int,int>
    #define ll long long
            #define pal pair<double,int>
            #define ppa pair<int,pa>
             #define ssa pair<string,int>
            #define  mp make_pair
            #define  pb push_back
            #define EPS (1e-10)
            #define equals(a,b) (fabs((a)-(b))<EPS)
     
            using namespace std;
     
            class Point{
            	public:
            	double x,y;
            	Point(double x=0,double y=0):x(x),y(y) {}
            	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
            	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
            	Point operator * (double a) {return Point(x*a,y*a);}
            	Point operator / (double a) {return Point(x/a,y/a);}
            	double absv() {return sqrt(norm());}
            	double norm() {return x*x+y*y;}
            	bool operator < (const Point &p) const{
            		return x != p.x ? x<p.x: y<p.y;
            	}
            	bool operator == (const Point &p) const{
            		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
            	}
            };
            typedef Point Vector;
     
            struct Segment{
            Point p1,p2;
            };
     
        double hen(Vector a){
        if(fabs(a.x)<EPS && a.y>0) return acos(0);
        else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
        else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
        else if(fabs(a.y)<EPS && a.x>0) return 0.0;
        else if(a.y>0) return acos(a.x/a.absv());
        else return 2*acos(0)+acos(-a.x/a.absv());
     
        }
     
int gcd(int v,int b){
	if(v>b) return gcd(b,v);
	if(v==b) return b;
	if(b%v==0) return v;
	return gcd(v,b%v);
}
            double dot(Vector a,Vector b){
            	return a.x*b.x+a.y*b.y;
            }
            double cross(Vector a,Vector b){
            	return a.x*b.y-a.y*b.x;
            }
        
            //----------------kokomade tenpure------------
int n,k;


int veki (int z, int r){
	if (r==1) return z%mod;
	if(r==0) return 1ll;
	if(r%2==1) return (z*veki(z,r-1))%mod;
	int y=veki(z,r/2);
	return (y*y)%mod;
}
    signed  main(){
int a,b,c;
    	cin>>a>>b>>c;
    	if(a>0)	cout<<b/c-(a-1)/c<<endl;
    	else cout<<b/c+1<<endl;
    //	printf("%.10f\n",ky[n+1]);
    	return 0;
    }

Measured memory_bytes: 384
'use strict';

function Main(input) {
    let tmp = input.split("\n");
    const N = parseInt(tmp[0], 10);
    let ary = tmp[1].split(" ");
    let alice = 0;
    let bob = 0;

    for (let i = 0; i < N; i++) {
        let max = Math.max(...ary);
        let id = ary.indexOf(`${max  }`);
        ary.splice(id, 1);

        if (i % 2 == 0) {
            alice += max;
        } else {
            bob += max;
        }
    }

    console.log(alice - bob);
}
//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(int argc, char const *argv[])
{
	int in;
	while(~scanf("%d",&in)){
		int ans=1;
		map<int,int> m;
		m[in]=1;
		while(1){
			ans++;
			if (in%2)
				in=in*3+1;
			else
				in/=2;
			if (m[in])
			{
				printf("%d\n",ans );
				break;
			}
			else{
				m[in]=1;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n;
int A[2000005];
int B[2000005];
int C[10005];
int m = 10000;
void print(int arr[],int l) {
	cout << arr[0];
	for (int i = 1; i < l; i++) {
		cout << " ";
		cout << arr[i];
	}
	cout << endl;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}

	//step1 统计个数
	for (int i = 0; i < n; i++) {
		C[A[i]]++;
	}

	//step2 求和
	for (int i = 1; i <= m; i++) {
		C[i] += C[i - 1];
	}

	//step3 对应
	for (int i = n-1; i >= 0; i--) {
		int pos = C[A[i]];
		B[pos-1] = A[i];
		C[A[i]]--;
	}

	//step4 输出
	cout << B[0];
	for (int i = 1; i < n; i++) {
		cout << " ";
		cout << B[i];
	}
	cout << endl;
}


Measured memory_bytes: 18684
#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int isRotNum(int N)
{
    int res = 1;

    string nstr = to_string(N);

    for (int i = 0; i <= (nstr.length() / 2); i++)
    {
        if (nstr[i] != nstr[nstr.length() - i - 1])
        {
            res--;
            break;
        }
    }

    return res;
}

int main()
{
    int A, B, i, cnt = 0;

    scanf("%d %d", &A, &B);

    FOR(i, A, B + 1)
    {
        if (isRotNum(i))
            cnt++;
    }

    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int n, i=0, x=0;
  cin >> n;

  while(++i <= n) {
    x = i;
    if ( x % 3 == 0 ){
      cout << " " << i;
      continue;
    }

    while(x) {
      if ( x % 10 == 3 ){
        cout << " " << i;
        break;
      }
      x /= 10;
    }
  }
  cout << "\n";
  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
#include <iomanip>
// #include <regex> //正規表現
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// グリッドグラフの移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int N; cin >> N;

if (N % 2 == 0) cout << 0.5 << "\n";
else cout << (N + 1.0) / 2.0 / N << "\n";


}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define S(x) (int) x.size()
#define LB lower_bound
#define UB upper_bound
#define fp(x, y) fixed<<setprecision(y)<<x
#define PI 3.141592653589793238462643383279502884
using namespace std;

const int M = (int)1e5;
const int mod = (int)1e9+7;

void solve()
{
    int n;
    cin>>n;
    cout<<n + (n*n) + (n*n*n)<<endl;
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < m; ++i) cin >> b[i];

    for (int ai = 0; ai < n - m + 1; ++ai) {
        for (int aj = 0; aj < n - m + 1; ++aj) {
            bool ok = true;
            for (int bi = 0; bi < m; ++bi) {
                for (int bj = 0; bj < m; ++bj) {
                    ok = ok && a[ai + bi][aj + bj] == b[bi][bj];
                }
            }
            if (ok) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
    return 0;
}

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

class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        System.out.println(fun(n));
    }
    
    static long fun(int n){
         return (n==0) ? 1:n*fun(n-1);
    }
}

Measured memory_bytes: 24112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int k;
		cin>>k;
		a[k]++;
	}
	for(int i=1;i<=n;i++){
		cout<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 4356
#include<cstdio>
#include<iostream>
#include<bits/stdc++.h>


using namespace std;
int main()
{
  int n; long  double d;
  cin>>n>>d;
  long  double x, y;int c=0;
  for(int i =0; i < n ;i++)
  {
      cin>>x>>y;
     long  double s = x*x + y* y;
      long  double p = ceil(sqrt(s));

      if(p<=d)
        c++;
  }cout<<c<<endl;
  return 0;}


Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(x, y) pb(mp(x, y))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(VECTOR) (VECTOR).begin(), (VECTOR).end()

int main(){

	ll x, y;
	cin >> x >> y;
	ll ans = 3000000000;
	int tmp;
	if(y - x >= 0)ans = min(ans, y - x);//cout << "1 " << ans << endl;
	if(y + x >= 0)ans = min(ans, y + x + 1);//cout << "2 " << ans << endl;
	if(- y - x >= 0)ans = min(ans, - y - x + 1);//cout << "3 " << ans << endl;
	if(- y + x >= 0)ans = min(ans, - y + x + 2);//cout << "4 " << ans << endl;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	S := ReadString()
	l := 0
	r := len(S) - 1
	c := 0
	for l < r {
		if S[l] != S[r] {
			c++
		}
		l++
		r--
	}
	fmt.Println(c)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
sum = 0
count = []
while(True):
    try:
        n = map(int, raw_input().split(","))
        sum += n[0] * n[1]
        count.append(n[1])
    except Exception:
        break
print(sum)
countSum = 0
for i in range(len(count)):
    countSum += count[i]
print(int(float(countSum) / len(count) + 0.5))

Measured memory_bytes: 4240
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for i in range(M)]
ans=0
count=0
for i in range(N):
  count=s.count(s[i])
  count-=t.count(s[i])
  ans=max(ans,count)
print(ans)

Measured memory_bytes: 3064
import itertools

N, A, B, C = map(int, input().strip().split())
ans_kadomatsu = [A, B, C]
l = []
for i in range(N):
    l.append(int(input()))

index_list = list(itertools.product(range(4), repeat=N))

min_mp_used = 100000000
for i in range(len(index_list)):
    tmp_index = index_list[i]
    kadomatsu = [0] * 3
    count_stick = 0
    for m in range(N):
        for j in range(3):
            if tmp_index[m] == j:
                kadomatsu[j] += l[m]
                count_stick += 1
    if kadomatsu.count(0):
        continue
    mp_used = 0
    for k in range(3):
        mp_used += abs(ans_kadomatsu[k] - kadomatsu[k])
    mp_used += 10 * (count_stick - 3)
    if min_mp_used > mp_used:
        min_mp_used = mp_used
print(min_mp_used)


Measured memory_bytes: 13044
import scala.collection.mutable.ListBuffer

object Main extends App {
  import scala.io.StdIn.readLine

  val n = readLine().toInt
  var list : ListBuffer[String] = ListBuffer.empty[String]
  var end : Char = '\0'
  var result = "Yes"
  for (i <- 1 to n) {
    var str = readLine()
    var start = str.charAt(0)
    if (i == 1) end = str.charAt(0)

    if (start != end || list.contains(str)) {
      result = "No"
    }

    list += str
    end = str.charAt(str.length - 1)
  }

  print(result)

}


Measured memory_bytes: 27304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    rep(i,n) a[i]-=(i+1);
    sort(all(a));
    ll av = a[n/2];
    ll ans = 0;
    rep(i,n) ans+=abs(av-a[i]);
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
std::string s[3];
int a,x[3];
main(){
  std::cin>>s[0]>>s[1]>>s[2];
  for(;x[a]-s[a].size();)a=s[a][x[a]++]-'a';
  std::cout<<char('A'+a)<<'\n';
}


Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN           PIC X(5).
01 A            PIC 9(1).
01 B            PIC 9(1).
01 C            PIC 9(1).
01 flg          PIC 9(1) VALUE ZERO.
01 ans          PIC X(3).

PROCEDURE DIVISION.
ACCEPT LN.
UNSTRING LN DELIMITED BY SPACE INTO A B C.
IF A = B AND B NOT = C
    MOVE 1 TO flg
END-IF.
IF B = C AND C NOT = A
    MOVE 1 TO flg
END-IF.
IF C = A AND A NOT = B
    MOVE 1 TO flg
END-IF.
IF flg = 1
    DISPLAY "Yes"
ELSE
    DISPLAY "No"
END-IF.
STOP RUN.


Measured memory_bytes: 764
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n;
	int[] a, b;

	void run(){
		n=sc.nextInt();
		a=new int[n];
		b=new int[n];
		for(int i=0; i<n; i++){
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
		}
		solve();
	}

	void solve(){
		int[][] dp=new int[n][n];
		// dp[i][j]=iツつゥツづァjツづーツづ慊づづ淞つスツづつォツづ個催渉ャ
		// dp[i][i]=0
		// dp[i][j]=min_k{dp[i][k]+dp[k+1][j]+a[i]*b[k]*a[k+1]*b[j]}

		for(int i=0; i<n; i++){
			Arrays.fill(dp[i], INF);
			dp[i][i]=0;
		}

		for(int m=1; m<n; m++){
			for(int i=0, j=m; j<n; i++, j++){
				for(int k=i; k<j; k++){
					dp[i][j]=Math.min(dp[i][j], dp[i][k]+dp[k+1][j]+a[i]*b[k]
							*a[k+1]*b[j]);
				}
			}
		}

		println(""+dp[0][n-1]);

	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
 
sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9 + 7
 
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
 
 
def main():
    c = collections.Counter(S())
    for k in string.ascii_lowercase:
        if c[k] == 0:
            return k
    return 'None'
 
print(main())

Measured memory_bytes: 5588
// in case of multiple test cases and N=1e5 don't intialize arrays as global except for graph vector-array
// always check whether or not you are doing mod of a negative number
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e5 + 5;
const int MOD=1e9 + 7;

int32_t main()
{
	IOS;
	int T=1;
	//cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		int a,b,c;
		cin >> a >> b >> c;
		int k;
		cin >> k;
		int cur = 0;
		while(b<=a)
		{
			b = b*2;
			cur++;
		}
		while(c<=b)
		{
			c = c*2;
			cur++;
		}
		if(cur<=k)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

Measured memory_bytes: 3648
N = int(input())
A = [int(a) for a in input().split()]
over = 10 ** 18
isOver = False
is0 = False
ans = 1
for a in A:
    ans *= a
    if ans > over:
        isOver = True
        ans = 1
    elif ans == 0:
        is0 = True
if is0:
    print(0)
elif isOver:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 84828
using System;

namespace _064
{
    class Program
    {
        static void Main()
        {
        string secretNumberMemoText = string.Empty;
        string input = string.Empty;
        while ((input = Console.ReadLine()) != null)
            {
            secretNumberMemoText += input;
            }
            var secretNumber = GetSecretNumber(secretNumberMemoText);
            Console.WriteLine(secretNumber);
        }

        internal static int GetSecretNumber(string secretNumberMemoText)
        {
            var secretNumber = 0;
            var secretNumberMemoChars = secretNumberMemoText.ToCharArray();
            var order = 1;
            for (var i = secretNumberMemoChars.Length - 1; i > 0; i--)
            {
                var secretNumberMemoChar = secretNumberMemoChars[i];
                if (!char.IsNumber(secretNumberMemoChar))
                {
                    order = 1;
                    continue;
                }

                secretNumber += order * (secretNumberMemoChar - '0');
                order *= 10;
            }

            return secretNumber;
        }
    }
}

Measured memory_bytes: 5624
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = [list(map(int, input().split())) for _ in range(M)]
for p in P:
    copy_p = T.copy()
    copy_p[p[0] - 1] = p[1]
    print(sum(copy_p))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    cout << (n+1)/2<<endl;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  bool ok=false;
  for(int i=1;i<10;i++){
    if(n%i==0&&n/i<10)
      ok=true;
  }
  cout << (ok?"Yes":"No") << endl;
  return 0;
}

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

int main(){
	long long int n,k,sum=0;
	std::cin>>k>>n;

	std::vector<int> v(n);
	std::vector<int> g;
	for (int& x : v) {
		std::cin >> x;
	}

	g.push_back(v[0] + (k - v[n - 1]));

	for (int i = 0; i < n-1; i++) {
		g.push_back(v[i + 1] - v[i]);
	}

	std::sort(g.begin(), g.end());

	std::cout<<k-g[g.size()-1]<<std::endl;
	return 0;
}

Measured memory_bytes: 2168
Scanf.scanf "%d %d" (fun a b ->
    let w = 50 in
    let width = w * 2 in
    let fill len c1 c2 =
        let bar = String.make width c1 in
        let rec loop rest h acc =
            if rest = 0 then h, acc else (
                let rep = min w rest in
                let s = String.init width (fun k ->
                    if k mod 2 = 0 then c1 else
                        if k < rep * 2 then c2 else c1
                )
                in
                loop (rest - rep) (h + 2) (bar :: s :: acc)
            )
        in
        loop len 1 [ bar ]
    in
    let h, l =
        match a, b with
        | 1, _ -> fill b '.' '#'
        | _, 1 -> fill a '#' '.'
        | _    -> let h1, l1 = fill (b - 1) '.' '#' in
                  let h2, l2 = fill (a - 1) '#' '.' in
                  h1 + h2, l1 @ l2
    in
    Printf.printf "%d %d\n" h width;
    List.iter print_endline l
)

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a) for(auto &i:a)

using namespace std;
int H, W;
string A[101];

string solve() {
    map<char, int> cnt;
    rep(y, 0, H) rep(x, 0, W) cnt[A[y][x]]++;

    if (H % 2 == 0 && W % 2 == 0) {
        fore(p, cnt) if (p.second % 4) return "No";
        return "Yes";
    }

    if (H % 2 && W % 2) {
        map<int, int> c;
        fore(p, cnt) c[p.second % 4]++;
        if (c[3]) return "No";
        if (c[1] != 1) return "No";
        if (c[2] > (H - 1) / 2 + (W - 1) / 2) return "No";
        return "Yes";
    }

    if (W % 2) swap(H, W);

    map<int, int> c;
    fore(p, cnt) c[p.second % 4]++;
    if (c[1] || c[3]) return "No";
    if (c[2] > W / 2) return "No";
    return "Yes";
}

int main() {
    cin >> H >> W;
    rep(y, 0, H) cin >> A[y];
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
#include <string>
#include <iomanip>

using namespace std;




int main() {
  double N, K;
  cin >> N >> K;
  
  double top = N;
  double ratio = 0;
  for (int i = 0; i <= 20; i++) {
    int boarder = (K+ pow(2, i) -1 ) /pow(2, i);
    ratio += max(top-boarder+1,0.0)/N * pow(0.5, i);
	if(top > boarder-1) top = boarder-1;
    
    if (top <= 0) break;
  }
  

  cout <<fixed<<setprecision(9)<< ratio << endl;

  return 0;
}


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

int main() {
  ll h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  cout << (h2 - h1) * 60 + (m2 - m1) - k << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>

//ユークリッドの互除法
int GCD(int x, int y){
    if( x % y == 0 ){
        return y;
    }
    return GCD( y , x % y );
}

//O(A+N)解
int main(){
    using namespace std;
    int MAX_A = 1000000;
    vector<int> lowerst_prime(MAX_A + 1, 0);//最小の素因数をいれる(2以上をみていけばいい)
    vector<int> primes;//MAX_A以下の素数の集合
    vector<int> count(MAX_A + 1, 0);//約数として出てくる回数を数える
    for(int i = 2; i <= MAX_A; i++){//線形時間で処理してくれる
        if(lowerst_prime[i] == 0){
            lowerst_prime[i] = i;
            primes.push_back(i);
        }
        for(int j = 0; j < primes.size()&& primes[j] <= lowerst_prime[i]&& i * primes[j] <= MAX_A; j++){
            lowerst_prime[i * primes[j]] = primes[j];//primes[j]がi * primes[j]のもっとも小さな素因数となるときのみ更新されるので、線形時間アルゴリズムとなる
        }
    }
    //入力
    int N;
    cin >> N;
    vector<int> A(N);
    int setwise_gcd = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        //setwise判定
        setwise_gcd = GCD(setwise_gcd, A[i]);//定義から、i == 0 ではA[0]を返す
    }
    if(setwise_gcd != 1){
        cout << "not coprime" << endl;
        return 0;
    }
    for(int i = 0; i < N; i++){
        while(A[i] > 1){
            int divide = lowerst_prime[A[i]];
            if(count[divide]){
                //A[x] % i == A[y] % i == 0 となるx != yが存在するので、i | gcd(x, y)となる
                cout << "setwise coprime" << endl;
                return 0;
            }
            count[divide]++;
            while(A[i] % divide == 0){//割れるだけ割る
                A[i] /= divide;
            }
        }
    }
    cout << "pairwise coprime" << endl;
}

Measured memory_bytes: 15488
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, -1, 0, 1};
 
#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
 
using namespace std;

struct Info {
	int depth;
	int x, y;
	Info() {
	}
	Info(int x, int y, int depth) {
		this->x = x;
		this->y = y;
		this->depth = depth;
	}
};

bool visited[100][100];

signed main() {
	int H, W;
	cin >> H >> W;

	vector<string> board(H);
	rep(i, H) cin >> board[i];

	int white = 0;
	rep(y, H) rep(x, W) white += board[y][x] == '.';

	queue<Info> q;
	q.push(Info(0, 0, 1));
	visited[0][0] = true;
	while (!q.empty()) {
		Info now = q.front(); q.pop();
		if (now.x == W - 1 && now.y == H - 1) {
			cout << white - now.depth << endl;
			return 0;
		}
		rep(dir, 4) {
			int nx = now.x + dx[dir];
			int ny = now.y + dy[dir];
			if (nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
			if (visited[ny][nx]) continue;
			if (board[ny][nx] == '#') continue;
			visited[ny][nx] = true;
			q.push(Info(nx, ny, now.depth+1));
		}
	}

	cout << -1 << endl;

	return 0;
}


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

int main(){
    int a, b;
    while(cin >> a >> b, a != 0 || b != 0){
        int dp[17][17] = {0};
        int n;
        cin >> n;
        dp[1][1] = 1;
        for(int i=1; i<=n; i++){
            int x, y;
            cin >> x >> y;
            dp[x][y] = -1;
        }
        for(int i=1; i<=a; i++){
            for(int j=1; j<=b; j++){
                if(dp[i][j] != -1){
                    if(j != 1 && dp[i][j-1] != -1){
                        dp[i][j] += dp[i][j-1];
                    }
                    if(i != 1 && dp[i-1][j] != -1){
                        dp[i][j] += dp[i-1][j];
                    }
                }
            }
        }
        cout << dp[a][b] << endl;
    }
    return 0;
}

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

int main(){

    int n,d;
    cin>>n>>d;
    int ans=0;

    vector<vector<int>> x(n,vector<int>(d));

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

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            double sum=0;
            for(int k=0;k<d;k++){
                sum+=(x[j][k]-x[i][k])*(x[j][k]-x[i][k]);
            }
            double root=pow(sum,0.5);
            if(root-(int)root==0) ans++;

        }
    }

    cout<<ans<<endl;

    return 0;
}

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

int main(){
  
  int A , B , C;
  int ab , bc , ca;
  
  cin >> ab >> bc >> ca;
  vector<int> timeSum(6);
  int t = 0;
  int a = 0;
    int b = 0;
    int sumtime = 0;
  for(int i=0;i<3;i++){
    int a = 0;
    int b = 0;
    int sumtime = 0;
    if(i == 0){
      a = bc;
      b = ca;
      sumtime = ab;
    } else if(i == 1){
      a= ca;
      b= ab;
      sumtime = bc;
    } else if(i == 2){
      a= ab;
      b= bc;
      sumtime = ca;
    }
    for(int i=0;i<2;i++){
      if(i==0){
        sumtime += a;
      } else if(i==1){
        sumtime += b;
      }
      timeSum.at(t) = sumtime;
     
      t++;
    }
  }
  
  int mint = 99999999;
  for(int i = 0;i<6;i++){
    if(mint > timeSum.at(i)){
      mint = timeSum.at(i);
    }
  }
 
  cout << mint << endl;
}


Measured memory_bytes: 256
X, Y, Z, K = map(int, input().split())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
ab=sorted(s+t for t in B for s in A)[-1:-K-1:-1]
abc=sorted(i+x for i in ab for x in C)[-1:-K-1:-1]
print("\n".join(map(str,abc)))

Measured memory_bytes: 160820
n=int(input())
a=[[0,0] for i in range(n)]
for i in range(n):
    a[i][0],a[i][1]=map(int,input().split())
a.sort(key=lambda x:x[1])
sa=0
sb=0
count=0
for i in range(n):
    sa+=a[i][0]
    sb=a[i][1]
    if sa>sb:
        print("No")
        break
    else:
        count+=1
if count==n:
    print("Yes")

Measured memory_bytes: 38040
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    print(min(s.count('0'), s.count('1'))*2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 39152
let rec fix f x = f (fix f) x
module Mi = Map.Make(struct type t = int let compare = (-) end)
module Mii = Map.Make(struct type t = int * int let compare = compare end)

let () =
  Scanf.scanf "%d" @@ fun n ->
  let gr, em = (1, Mi.empty, Mii.empty) |> fix @@ fun f (i, gr, em) ->
    if i >= n then (gr, em) else 
    Scanf.scanf " %d %d" @@ fun a b ->
      let gr = gr |> Mi.add a (b :: (try Mi.find a gr with _ -> []))
                  |> Mi.add b (a :: (try Mi.find b gr with _ -> []))
      and em = em |> Mii.add (a, b) i
      in f (i+1, gr, em)
  in
  let em = (1, 0, 0, Mi.empty) |> fix @@ fun f (u, c, p, a) ->
    Mi.find u gr |> List.fold_left (fun (i, a) v ->
      if v = p then (i, a) else
      let i = if i = c then i+1 else i in
      let k = min u v, max u v in
      let a = Mi.add (Mii.find k em) i a in
      (i+1, f (v, i, u, a))) (1, a)
    |> snd
  in
  Printf.printf "%d\n" (Mi.fold (fun _ v a -> max v a) em 0);
  Mi.iter (fun _ -> Printf.printf "%d\n") em



Measured memory_bytes: 41724
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pii;
vector<pii>pat[200000];
vector<pii>dat[100000][2];
ll d[200000];
#define INF 2000000000000000000LL
bool flag[200000];
bool isok=true;
ll mix=INF,miy=INF;
void dfs(int node,ll now)
{
	if(flag[node])
	{
		if(now!=d[node])isok=false;
		return;
	}
	flag[node]=true;
	d[node]=now;
	if(node%2==0)mix=min(mix,now);
	else miy=min(miy,now);
	for(int i=0;i<pat[node].size();i++)
	{
		if(node%2==pat[node][i].first%2)dfs(pat[node][i].first,pat[node][i].second+now);
		else dfs(pat[node][i].first,pat[node][i].second-now);
	}
}
int main()
{
	int mx,my,num;
	scanf("%d%d%d",&mx,&my,&num);
	for(int i=0;i<num;i++)
	{
		int za,zb,zc;
		scanf("%d%d%d",&za,&zb,&zc);
		za--,zb--;
		pat[za*2].push_back(make_pair(zb*2+1,zc));
		pat[zb*2+1].push_back(make_pair(za*2,zc));
		dat[za][0].push_back(make_pair(zb,zc));
		dat[zb][1].push_back(make_pair(za,zc));
	}
	for(int i=0;i<100000;i++)
	{
		for(int j=1;j<dat[i][0].size();j++)
		{
			pat[dat[i][0][j-1].first*2+1].push_back(make_pair(dat[i][0][j].first*2+1,dat[i][0][j].second-dat[i][0][j-1].second));
			pat[dat[i][0][j].first*2+1].push_back(make_pair(dat[i][0][j-1].first*2+1,dat[i][0][j-1].second-dat[i][0][j].second));
		}
		for(int j=1;j<dat[i][1].size();j++)
		{
			pat[dat[i][1][j-1].first*2].push_back(make_pair(dat[i][1][j].first*2,dat[i][1][j].second-dat[i][1][j-1].second));
			pat[dat[i][1][j].first*2].push_back(make_pair(dat[i][1][j-1].first*2,dat[i][1][j-1].second-dat[i][1][j].second));
		}
	}
	/*for(int i=0;i<4;i++)
	{
		for(int j=0;j<pat[i].size();j++)printf("%d %lld   %lld\n",i,pat[i][j].first,pat[i][j].second);
	}*/
	fill(flag,flag+200000,false);
	fill(d,d+200000,0);
	for(int i=0;i<200000;i++)
	{
		if(!flag[i])
		{
			mix=miy=INF;
			dfs(i,0);
			if(mix+miy<0)isok=false;
		}
		//if(i<=6)printf("%d %lld\n",i,d[i]);
	}
	if(isok)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 31104
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		Set<String> T=new HashSet<>();
		int n=cin.nextInt();
		
		PrintWriter out=new PrintWriter(System.out);
		for(int i=0;i<n;i++) {
			String odr=cin.next(),key=cin.next();
			if(odr.equals("insert"))T.add(key);
			else if(odr.equals("find") && T.contains(key))out.println("yes");
			else if(odr.equals("find") && !T.contains(key))out.println("no");
		}
		out.flush();
	}

}



Measured memory_bytes: 216056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100005];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int mx = 1, len = 1;
  for (int i = 1; i < n; i++) {
    if (a[i] <= a[i - 1])
      len++;
    else {
      mx = max(mx, len);
      len = 1;
    }
  }
  mx = max(mx, len);
  cout << mx - 1 << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int h,w;
    cin>>h>>w;
    long long int l[h+1][w+1];
    string g[h];
    for(int i=0;i<h;i++) cin>>g[i];
    long long int mod=1000000007;
    for(int i=0;i<=h;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(i==0 || j==0 || g[i-1][j-1]=='#') {l[i][j]=0;continue;}
            if(i==1 && j==1) {l[i][j]=1;continue;}
            l[i][j]=(l[i-1][j]+l[i][j-1])%mod;
        }
    }
    cout<<l[h][w]<<endl;
    return 0;
}

Measured memory_bytes: 9088