akhauriyash/Code-Regression huggingface dataset:
// Problem : A - Password
// Contest : AtCoder Beginner Contest 140
// URL : https://atcoder.jp/contests/abc140/tasks/abc140_a
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcount(x)
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
cin>>n;
cout<<n*n*n;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t;
//cin>>t;
t=1;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
int main() {
    int a, b, c; cin >> a >> b >> c;
    if(c - (a - b) <= 0) cout << '0' << endl;
    else cout << c - (a - b) << endl;
    return 0;
}

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

vector<int> idy={1,0,-1,0};
vector<int> idx={0,1,0,-1};

pair<int,int> start;
bool check(vector<string> m, vector<vector<bool>> &dp) {
  for(int i=0;i<dp.size();i++) {
    for(int j=0;j<dp.at(0).size();j++) {
      if(!dp.at(i).at(j)&&m.at(i).at(j)=='.') {
        start=pair<int,int> (i,j);
        dp.at(i).at(j)=true;
        return true;
      }
    }
  }
  return false;
}

int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> maze(h);
  for (int i = 0; i < h; i++) {
    cin >> maze.at(i);
  }
  vector<vector<bool>> dp(h,vector<bool>(w,false));
  vector<vector<int>> dp1(h,vector<int>(w,-1));
  vector<vector<int>> dp2(h,vector<int>(w,-1));
  int ans=0;
  queue<pair<int,int>> q;
  
  while(check(maze,dp)) {
    pair<int,int> maxp;
    dp1.at(start.first).at(start.second)=0;
    q.push(start);
    while(q.size()) {
      pair<int,int> now=q.front();
      q.pop();
      for(int i=0;i<4;i++) {
        int ny=now.first+idy.at(i);
        int nx=now.second+idx.at(i);
        if(ny>-1&&nx>-1&&ny<h&&nx<w) {
          if(dp1.at(ny).at(nx)==-1&&maze.at(ny).at(nx)=='.') {
            dp1.at(ny).at(nx)=dp1.at(now.first).at(now.second)+1;
            maxp=pair<int,int>(ny,nx);
            q.push(pair<int,int>(ny,nx));
          }
        }
      }
    }
    
    dp2.at(maxp.first).at(maxp.second)=0;
    q.push(maxp);
    while(q.size()) {
      pair<int,int> now=q.front();
      q.pop();
      for(int i=0;i<4;i++) {
        int ny=now.first+idy.at(i);
        int nx=now.second+idx.at(i);
        if(ny>-1&&nx>-1&&ny<h&&nx<w) {
          if(dp2.at(ny).at(nx)==-1&&maze.at(ny).at(nx)=='.') {
            dp2.at(ny).at(nx)=dp2.at(now.first).at(now.second)+1;
            ans=max(ans,dp2.at(ny).at(nx));
            q.push(pair<int,int>(ny,nx));
          }
        }
      }
    }
    for(int i=0;i<h;i++) {
      for(int j=0;j<w;j++) {
        dp1.at(i).at(j)=-1;
        dp2.at(i).at(j)=-1;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


def solve(S: str):
    w = list(reversed(['Sunny', 'Cloudy', 'Rainy']))
    return w[w.index(S) - 1]


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print(f'{solve(S)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 70184
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
constexpr ll INF = 1LL << 60;

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, x; cin >> n >> x;
	vector<ll> a(n);
	rep(i, 0, n) cin >> a[i];


	vector<ll> min_table(n, INF);
	ll ans = INF;
	rep(i, 0, n) {
		rep(j, 0, n) min_table[j] = min(min_table[j], a[(n + j - i) % n]);
		ll tans = x * i;
		rep(j, 0, n)
			tans += min_table[j];

		ans = min(ans, tans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3696
//============================================================================
// Name        : template.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

// int main() {
// 	ios::sync_with_stdio(false);
//  cin.tie(0);
//  int n,x,t; cin >> n >> x >> t;
//  int ans = ((n + x -1) / x) * t;
//  cout << ans << "\n";
// return 0;
// }

// int main() {
// 	ios::sync_with_stdio(false);
// 	cin.tie(0);
// 	string s;
// 	ll sm = 0;
// 	cin >> s;
// 	forn(i, s.length()) {
// 		int c = s[i] - '0';
// 		sm += c;
// 	}
// 	if (sm % 9 == 0) cout << "Yes\n";
// 	else cout << "No\n";
// 	return 0;
// }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n; cin >> n;
	vi a(n);
	forn(i,n) cin >> a[i];
	ll ans = 0;
	REP(i, 1, n-1) {
		if(a[i-1] > a[i]) {
			ans += a[i-1] - a[i];
			a[i] = a[i-1];
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3968
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC007B {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int[] rank = new int[N];
            for (int i = 0; i < N; i++) {
                rank[input[i] - 1] = i;
            }
            int[] A = new int[N];
            int[] B = new int[N];
            A[0] = 1;
            B[0] = 1000000000;
            for (int i = 1; i < N; i++) {
                int pre = rank[i - 1];
                int nex = rank[i];
                if (pre < nex) {
                    A[i] = A[i - 1] + 1 + (nex - pre);
                    B[i] = B[i - 1] - 1;
                } else {
                    A[i] = A[i - 1] + 1;
                    B[i] = B[i - 1] - 1 - (pre - nex);
                }
            }
            Console.WriteLine(String.Join(" ", A));
            Console.WriteLine(String.Join(" ", B));
        }
    }
}


Measured memory_bytes: 19424
import java.util.Scanner;
import java.util.stream.IntStream;

import javax.script.ScriptException;

public class Main {

	/** 時間帯の数 */
	private static final Integer TIME = 10;

	public static void main(String[] args) throws ScriptException {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			scanner.nextLine();
			// 各店舗の営業時間帯の配列
			int[] f = new int[n];
			IntStream.range(0, n).forEach(i -> f[i] = Integer.parseInt(scanner.nextLine().replaceAll(" ", ""), 2));
			// 利益の配列
			int[][] p = new int[n][TIME + 1];
			IntStream.range(0, n)
					.forEach(i -> IntStream.rangeClosed(0, TIME).forEach(j -> p[i][j] = scanner.nextInt()));
			System.out.println(IntStream.range(1, 1 << TIME).map(i -> calcResult(i, n, f, p)).max().getAsInt());
		}
	}

	/**
	 * 現在の営業時間帯で得られる利益を計算する
	 * 
	 * @param t 現在の営業時間帯
	 * @param n 店舗の数
	 * @param f 各店舗の営業時間帯
	 * @param p 利益の配列
	 * @return 現在の営業時間帯で得られる利益
	 */
	private static int calcResult(int t, int n, int[] f, int[][] p) {
		return IntStream.range(0, n).map(i -> p[i][sameCount(t, f[i])]).sum();
	}

	/**
	 * 2つの店舗の営業時間帯が同じものカウントを計算する
	 * 
	 * @param t1 営業時間帯1
	 * @param t2 営業時間帯2
	 * @return 2つの店舗の営業時間帯が同じものカウント
	 */
	private static int sameCount(int t1, int t2) {
		return Integer.bitCount(t1 & t2);
	}
}


Measured memory_bytes: 30608
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	string o, e;
	cin >> o >> e;
	for (int i = 0; i < e.size(); i++) {
		cout << o[i] << e[i];
	}
	if (o.size() - e.size() == 1) {
		cout << o[o.size() - 1];
	}
	
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    if((B-A)%2==0){
        cout << (B-A)/2 << enld;
    }else{
        cout << (B-A+1)/2+min(A-1,N-B) << enld;
    }
    return 0;
}

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

Measured memory_bytes: 128
N, Q = map(int, input().split())
S = input()
ac_list = [0]*N
for i in range(N-1):
    if S[i] == 'A' and S[i + 1] == 'C':
        ac_list[i+1] = ac_list[i]+1
    else:
        ac_list[i+1] = ac_list[i]
for _ in range(Q):
    l, r = map(int, input().split())
    print(ac_list[r-1]-ac_list[l-1])

Measured memory_bytes: 6060
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int n; cin >> n;
  vector<double> v(n);
  for(int i =0; i < n; i++){
    double temp; cin >> temp;
    v[i] = temp;
  }

  sort(v.begin(), v.end());

  for(int i = 0; i < n-1; i++){
    v[i+1] = (v[i+1] + v[i])/2;
  }

  cout << setprecision(6) << v[n-1] << endl;

  return 0;
}

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

bool f(int n){
    if (n % 7 != 1 and n % 7 != 6)
        return false;
    for (int i = 2; i * i <= n; i++){
        if (n % i != 0)
            continue;
        if (i % 7 != 1 and i % 7 != 6)
            continue;
        return false;
    }
    return true;
}

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

    vector<bool> is_prime(300001);
    for (int i = 0; i <= 300000; i++){
        is_prime[i] = f(i);
    }
    is_prime[1] = false;

    while (true){
        int n;
        cin >> n;
        if (n == 1)
            return 0;
        vector<int> factors;
        for (int i = 1; i * i <= n; i++){
            if (n % i == 0){
                if (is_prime[i])
                    factors.push_back(i);
                if (is_prime[n / i] and i * i != n)
                    factors.push_back(n / i);
            }
        }
        sort(factors.begin(), factors.end());
        cout << n << ":";
        for (const auto &fact: factors)
            cout << " " << fact;
        cout << endl;
    }
}


Measured memory_bytes: 3180
//2019.7.7 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define eps 1e-12
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define gc getchar
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
//inline int read() {
//    res s=0,ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
inline int read() {
    res s=0,ch=gc(),w=1;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s*w;
}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
namespace MAIN{
    int n,d;
    struct P{
        int D[10+10];
        inline void init(){
            for(res i=1;i<=d;i++)D[i]=read();
        }
    }a[10+10];
    int ret;
    inline int get(const res &I,const res &J){
        res ret=0;
        for(res i=1;i<=d;i++)ret+=(a[I].D[i]-a[J].D[i])*(a[I].D[i]-a[J].D[i]);
        return ret;
    }
    inline void MAIN(){
        n=read(),d=read();
        for(res i=1;i<=n;i++)a[i].init();
        for(res i=1;i<=n;i++)
            for(res j=i+1;j<=n;j++){
                if(int(sqrt(get(i,j)))*int(sqrt(get(i,j)))==get(i,j))ret++;
            }
        printf("%d\n",ret);
    }
}
int main() {
//    srand((unsigned)time(NULL));
    // freopen("zao.in","r",stdin);
    // freopen("std.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int stricmp(char* ch1, char* ch2) {
	int ch1_length = 0, ch2_length = 0, div;
	for (int i = 0; ch1[i] != '\0'; i++) ch1_length++;
	for (int i = 0; ch2[i] != '\0'; i++) ch2_length++;
	if (ch1_length != ch2_length) return -1;
	for (int i = 0; ch1[i] != '\0'; i++)
	{
		div = ch1[i] - ch2[i];
		if (div != 0 && div != 32 && div != -32)
			return -1;
	}
	return 0;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	char w[11], t[1001];
	cin >> w;
	int counter = 0;
	for (int i = 0; i < 100000; i++) {
		cin >> t;
		if (strcmp("END_OF_TEXT", t) == 0) break;
		if (stricmp(t, w) == 0) counter++;
	}
	cout << counter << endl;
	return 0;
}


Measured memory_bytes: 3156
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 100005
#define NIL -1

typedef struct{
  int parent;
  int left;
  int right;
}Node;

Node T[MAX];
int n,D[MAX],H[MAX];

void preParse(int u){
  if(u==NIL)return ;
  cout<<" "<<u;
  preParse(T[u].left);
  preParse(T[u].right);
}

void inParse(int u){
  if(u==NIL) return;
  inParse(T[u].left);
  cout<<" "<<u;
  inParse(T[u].right);
}

void postParse(int u){
  if(u==NIL) return;
  postParse(T[u].left);
  postParse(T[u].right);
  cout<<" "<<u;
}

int main(){
  int n,id,left,right;
  int root=0;

  cin>>n;

  for(int i=0;i<n;i++) T[i].parent=NIL;

  for(int i=0;i<n;i++){
    cin>>id>>left>>right;
    T[id].left=left;
    T[id].right=right;
    if(left!=NIL) T[left].parent=id;
    if(right!=NIL)T[right].parent=id;
  }
  
  for(int i=0;i<n;i++)if(T[i].parent==NIL) root=i;
  
  cout<<"Preorder"<<endl;
  preParse(root);
  cout<<endl;
  cout<<"Inorder"<<endl;
  inParse(root);
  cout<<endl;
  cout<<"Postorder"<<endl;
  postParse(root);
  cout<<endl;

  return 0;
}

  

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

int main() {
  int a, b, c;
  int count = 1;
  cin >> a >> b >> c;
  if (a != b) count++;
  if (a != c) count++;
  if (b == c) count--;
  if (count == 0) count++;
  cout << count << endl;    
}


Measured memory_bytes: 3632
#include <cstdio>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    int ans;
    if((a + b) % 2 == 0){
        ans = (a + b) / 2;
    }else{
        ans = (a + b) / 2 + 1;
    }
    printf("%d\n",ans);

    return 0;
}

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

int main(void){
    int p, q, r;
    cin >> p >> q >> r;
    if(p >= q){
        if(p >= r) cout << q + r << endl;
        else cout << p + q << endl;
    }else if(q <= r){
        cout << p + q;
    }else{
        cout << p + r;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define DEBUG "::"
#define REPI(itei) for(long long int i = 0,iteii=itei;i < iteii;i++)
#define REPJ(itej) for(long long int j = 0,itejj=itej;j < itejj;j++)
#define REPK(itek) for(long long int k = 0,itekk=itek;k < itekk;k++)
using namespace std;
typedef long long int ll;
int main(){
    int N;
    cin >> N;
    vector<int>val;
    REPI(N){
        int x;
        cin >> x;
        val.push_back(x);
    }
    sort(val.begin(), val.end());
    int sum = 0;
    REPI(val.size()){
        if(i == iteii-1){
            sum+=(val[i]/2);
        }
        else{
            sum+=val[i];
        }
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <numeric>
#include <algorithm>
using namespace std;

const int N = 6;

int ns[N];

bool init(){
	for(int i=0; i<N; i++){
		scanf("%d", ns + i);
	}

	return accumulate(ns, ns + N, 0) > 0;
}

int solve(){
	int as[N/2] = {0};
	for(int i=0; i<N/2; i++){
		as[i] = ns[i] + ns[i+N/2];
	}

	int ret = 0;
	int mini = min(*min_element(as, as + N/2), 2);
	for(int b = 0; b<=mini; b++){
		int p = 0;
		for(int i=0; i<N/2; i++){
			p += (as[i] - b) / 3;
		}
		ret = max(ret, b + p);
	}

	return ret;
}

int main(){
	while(init()){
		printf("%d\n", solve());
	}

	return 0;
}

Measured memory_bytes: 764
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<vector<long long>> dp(n + 1, vector<long long>(2));
  dp[0][1] = -(1LL << 60);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    dp[i + 1][0] = max(dp[i][0] + x, dp[i][1] - x);
    dp[i + 1][1] = max(dp[i][0] - x, dp[i][1] + x);
  }
  cout << dp[n][0] << endl;
  return 0; 
}

Measured memory_bytes: 5760
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<map>

using namespace std;

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

typedef long long ll;
const int INF = 1e9+7;


int n;
vector<int> in;


void input(){
	cin>>n;
	rep(i,n){
		int t;
		cin>>t;
		in.push_back(t);
	}
}


ll getHash(vector<int>& a){
	ll ret=0, t=1;
	rep(i,a.size()){
		ret += a[i]*t;
		t*=11;
	}
	return ret;
}

void reverse(vector<int>& a, int b, int c){
	while(b<c){
		swap(a[b], a[c]);
		b++; c--;
	}
}

map<ll,int> memo;

int ans = INF;


void saiki(vector<int>& a, int mode, int depth, int limit){
	
	if(mode==0){
		bool ok = true;
		rep(i,a.size()){
			if(a[i]!=i+1)ok=false;
		}
		if(ok)ans = min(ans, depth);
	}

	if(mode==1){
		ll h = getHash(a);
		if(memo.find(h)!=memo.end()){
			int s = memo[h] + depth;
			ans = min(ans, s);
			return;
		}
	}

	if(depth==limit){
		if(mode==0)memo[getHash(a)] = depth;
		return;
	}


	rep(i,a.size()){
		reps(j,i+1,a.size()){
			reverse(a, i ,j);
			saiki(a, mode, depth+1, limit);
			reverse(a,i,j);
		}
	}
}

int solve(){
	vector<int> tmp;
	rep(i,in.size())tmp.push_back(i+1);

	ans = in.size()-1;

	int limit = (in.size()-1)/2;

	saiki(in, 0, 0, limit);
	saiki(tmp, 1, 0, limit);

	return ans;
}

int main(){
	input();
	cout<<solve()<<endl;
}

Measured memory_bytes: 17104
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int input, sum;
  cin >> input;
  // 各桁の数字を取る。
  sum += input / 100; //100の位
  input = input % 100;
  sum +=  input / 10;
  input = input % 10;
  sum += input;
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll vis[100005],col[100005];
void dfs(ll i,vector<vector<ll>> &v){
	vis[i]=1;
	for(ll j=0;j<sz(v[i]);j++)
		if(!vis[v[i][j]]){
			col[v[i][j]]=(col[i]^1);
			dfs(v[i][j],v);
		}
}
void solve(){
	ll n,m;
	cin>>n>>m;
	vector<vector<ll>> v(n+1);
	for(ll i=0;i<m;i++){
		ll x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1,v);
	for(ll i=1;i<=n;i++)
		for(ll j=0;j<sz(v[i]);j++)
			if(col[i]==col[v[i][j]]){
				cout<<(n*(n-1)/2)-m;
				exit(0);
			}
	ll res=0;
	for(ll i=1;i<=n;i++)
		if(col[i])
			res++;
	cout<<res*(n-res)-m;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 12092
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 1e5+5;
int dp[maxn];

int dfs(const int N)
{
    int& ans = dp[N];
    if (-1 == ans) {
        ans = N;
        if (N >= 9) {
            int x = 9;
            while (x*9 <= N)
                x *= 9;
            const int res = 1 + dfs(N-x);
            ans = min(ans,res);
        }
        if (N >= 6) {
            int x = 6;
            while (x*6 <= N)
                x *= 6;
            const int res = 1 + dfs(N-x);
            ans = min(ans,res);
        }
    }
    return ans;
}

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
    memset(dp,-1,sizeof(dp));
    int N;
    while (cin >> N) {
        const int ans = dfs(N);
        cout << ans << endl;
    }    
    return 0;
}


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

//ABC135
signed main(void){

    int n; cin >> n;
    vector<int> p(n);
    int cnt = 0;
    rep(i, n){
        cin>>p[i];
        if(p[i] != i+1)cnt++;
    }
    if(cnt<=2)cout << "YES" << endl;
    else cout << "NO" << endl;

}

Measured memory_bytes: 256
s = input()

n0 = 0
n1 = 0
ans = 0

for i in s:
    if i == "0":
        if n1 == 0:
            n0 += 1
        else:
            n1 -= 1
            ans += 2
    else:
        if n0 == 0:
            n1 += 1
        else:
            n0 -= 1
            ans += 2

print(ans)

Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct status{
	int id;
	int unite;
	int ac;
	int pena;
}status;

int cmp(const void* a,const void* b){
	status *s1 = (status *)a;
	status *s2 = (status *)b;
	if(s1->ac > s2->ac)
		return -1;
	else if(s1->ac < s2->ac)
		return 1;
	else{
		if(s1->pena > s2->pena)
			return 1;
		else if(s1->pena < s2->pena)
			return -1;
		else{
			if(s1->id > s2->id)
				return 1;
			else
				return -1;
		}
	}
}

int main(void){
	int i, n, uc[1000]/*unitecount*/,wc;
	status s[300];
	while(1){
		scanf("%d",&n);
		if(!n) break;
		for(i = 0;i < n;i++)
			scanf("%d%d%d%d",&s[i].id,&s[i].unite,&s[i].ac,&s[i].pena);
		memset(uc,0,sizeof(uc));
		qsort(s,n,sizeof(s[0]),cmp);
		wc = 0;
		for(i = 0;i < n;i++){
			if(wc < 10 && uc[s[i].unite] < 3){
				printf("%d\n",s[i].id);
				uc[s[i].unite]++;
				wc++;
			}
			else if(wc < 20 && uc[s[i].unite] < 2){
				printf("%d\n",s[i].id);
				uc[s[i].unite]++;
				wc++;
			}
			else if(wc < 26 && uc[s[i].unite] == 0){
				printf("%d\n",s[i].id);
				uc[s[i].unite]++;
				wc++;
			}
		}
	}
	return 0;
}

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

using namespace std;

int main(){
	int A, B;
	cin >> A >> B;
	
	if ((A % 2) != (B % 2)) {
		cout << "IMPOSSIBLE" << endl;
	} else {
		cout << (A + B) / 2 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define NIL (-1)
#define REP(i,N) for(int i=0;i<N;++i)

using namespace std;

struct BinaryTreeNode {
	int p;// parent
	int l;// left
	int r;// right
};

/// the root tree, left subtree and right subtree
void walk_by_preorder(int id, vector<BinaryTreeNode> &T) {
	if (id == NIL) {
		return;
	}
	cout << " " << id;
	walk_by_preorder(T[id].l, T);
	walk_by_preorder(T[id].r, T);
}

/// the left-subtree, the root and right subtree 
void walk_by_inorder(int id, vector<BinaryTreeNode> &T) {
	if (id == NIL) return;
	walk_by_inorder(T[id].l, T);
	cout << " " << id;
	walk_by_inorder(T[id].r, T);
}

/// the left-subtree, right subtree and root tree
void walk_by_postorder(int id, vector<BinaryTreeNode> &T) {
	if (id == NIL) return;
	walk_by_postorder(T[id].l, T);
	walk_by_postorder(T[id].r, T);
	cout << " " << id;
}

int main () {
	int n;
	cin >> n;
	vector<BinaryTreeNode> T(n);
	REP(i,n) {
		T[i].p = T[i].l = T[i].r = NIL;
	}

	REP(i,n) {
		int id, left, right;
		cin >> id >> left >> right;
		T[id].l = left;
		T[id].r = right;
		if (left != NIL) T[left].p = id;
		if (right!= NIL) T[right].p = id;
	}

	int root_id;
	REP(i,T.size()) {
		if (T[i].p == NIL) {
			root_id = i;
			break;
		}
	}
	cout << "Preorder" << endl;
	walk_by_preorder(root_id, T);
	cout << endl;
	cout << "Inorder" << endl;
	walk_by_inorder(root_id, T);
	cout << endl;
	cout << "Postorder" << endl;
	walk_by_postorder(root_id, T);
	cout << endl;
	return 0;
}



Measured memory_bytes: 3104
def get_neg2(n):
    if n == -2:
        return "10"
    if n == -1:
        return "11"
    if n == 0:
        return "0"
    if n == 1:
        return "1"
    if n % 4 == 0:
        return get_neg2(n // 4) + "00"
    if n % 4 == 1:
        return get_neg2((n - 1) // 4) + "01"
    if n % 4 == 2:
        return get_neg2((n + 2) // 4) + "10"
    if n % 4 == 3:
        return get_neg2((n + 1) // 4) + "11"


N = int(input())
print(get_neg2(N))


Measured memory_bytes: 3060
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;


#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;


void Main()
{
  int n, k;
  cin >> n >> k;
  if(k>=n){
    cout << 0 << endl;
    return; 
  }
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(), h.end());
  ll sum = 0;
  rep(i,n-k) sum += h[i];
  cout << sum << endl;
 return;
}


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


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

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


int main(){
  double l;
  cin >> l;
  double x = l/3.0;
  cout << fixed << setprecision(15) << x*x*x << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,x,cnt = 0;
    cin >> a >> b;
    
    c = b - a;
    for(int i = 1;i <= c;i++){
        cnt += i;
    }
    
    x = cnt - b;
    
    cout << x << endl;
    return 0;
}

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

#define pb push_back
#define mp make_pair

#define fi first
#define se second

typedef long long ll;
using namespace std;

int a[200500], n;
set<int> s;

int main(){

cin >> n;
for(int i=1;i<=n;i++){
    int x;
    cin >> x;
    a[x] = i;
}
s.insert(0);
s.insert(n + 1);
ll ans = 0;

for(int i=1;i<=n;i++){
    int p = a[i];
    set<int>::iterator it = s.upper_bound(p);
    int r = *it;
    int l = *(--it);
    ans += i * 1ll * (r - p) * 1ll * (p - l);
    s.insert(p);
}
cout << ans;
return 0;
}


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

using namespace std;

long long dp[101][100020];
vector<int> a(102);
vector<long long> pref(100050);
long long mod = 1e9 + 7;

int main()
{
    int N, K;

    cin >> N >> K;

    for(int i = 1; i <= N; i++)
        cin >> a[i];

    for(int i = 0; i <= K; i++)
        pref[i] = 0;

    for(int i = 0; i <= N; i++)
    {
        for(int j = 0; j <= K; j++)
        {
            dp[i][j] = 0;
        }
    }

    for(int j = 0; j <= a[N]; j++)
    {
        dp[N][j] = 1;
    }

    long long res = 0;



    for(int i = N-1; i >= 0; i--)
    {
        pref[0] = 1;

        for(int j = 1; j <= K; j++)
            pref[j] = (pref[j-1] + dp[i+1][j]) % mod;

        for(int j = 0; j <= K; j++)
        {
            if(j-1-a[i] < 0) dp[i][j] = pref[j];
            else dp[i][j] = (pref[j] - pref[j - 1 - a[i]] + mod) % mod;
        }
    }

    cout << dp[1][K] << endl;

    return 0;
}


Measured memory_bytes: 82852
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n;
 cin>>n;
 ll tmp=n;
 rep(i,1,n+1){
  if(0.5*i*(i+1)>=n){
   tmp=0.5*i*(i+1)-n;
   rep(j,1,i+1){
    if(j!=tmp)pr(j);
   }
  return 0;
  }
 }

return 0;}


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

int main( void ) {
    string s,end_s;

    cin >> s;
    end_s = s.back();

    if(end_s == "s"){
        s.push_back('e');
    }
    s.push_back('s');
    
    
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int v[20000];
int main(){
  int n; scanf("%d", &n);
  for(int i = 1; i < 105; i++){
    for(int j = 1; j < 105; j++){
      for(int k = 1; k < 105; k++){
        int t = i*i+j*j+k*k+i*j+j*k+k*i;
        if(t <10050) v[t]++;
      }
    }
  }
  for(int i = 1; i <= n; i++){
    printf("%d\n", v[i]);
  }
  return 0;
}

Measured memory_bytes: 3720
def cross(s):
    if s[0]==s[4]==s[8] and s[0]!="s":
        print(s[0])
        return True
    elif s[2]==s[4]==s[6] and s[2]!="s":
        print(s[2])
        return True
    else:
        return False

def side(s):
    for i in range(0,len(s),3):
        if s[i]==s[i+1]==s[i+2] and s[i]!="s":
            print(s[i])
            return True
    return False
def ver(s):
    for i in range(3):
        if s[i]==s[i+3]==s[i+6] and s[i]!="s":
            print(s[i])
            return True
    return False


while True:
    try:
        s=list(map(str,input()))               
    except EOFError:
        break
    if cross(s)==side(s)==ver(s)==False:
        print("d")

    


Measured memory_bytes: 5560
import kotlin.math.PI

fun main() {
//    println(solve())
    solve()
}

val solve: () -> Any = {
    val N = readInt()
    val list = MutableList(N) { 0 }
    val A = readIntList()
    val map = A.groupingBy { it-1 }.eachCount()
    repeat(N) {
        map.getOrDefault(it, 0).alsoPrintln()
    }
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun Any?.alsoPrintln() = also { println(this) }


Measured memory_bytes: 87320
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define hell 100000000
using namespace std;

int main()
{
  IOS
  ll n;
  vector< pair<ll,ll> > v;
  cin>>n;
  ll i,x,y;
  for(i=1;i<=n;i++)
  {
  	 cin>>x>>y;
  	 v.pb(mp(y,x));
  }
  sort(all(v));
  ll cur=0;
  for(i=0;i<n;i++)
  {
  	 if(cur+v[i].ss<=v[i].ff)
  	 	cur+=v[i].ss;
	 else
	 {
	 	// cout<<i<<" ";
	 	 cout<<"No";
	 	 return 0;
	 }
  }
  cout<<"Yes\n";
  return 0; 
}

Measured memory_bytes: 6512
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }



    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);


        var N = Read();
        if (N % 2 == 0)
            Console.WriteLine(0.5);
        else
            Console.WriteLine((double)((N - 1) / 2 + 1) / N);



        Console.Out.Flush();
    }
}

Measured memory_bytes: 13140
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;

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

    int ans = 0;

    rep(i1, h) {
        rep(j1, w) {
            if(s[i1][j1] == '#') continue;
            rep(i2, h) {
                rep(j2, w) {
                    if(s[i2][j2] == '#') continue;
                    if(i1==i2 && j1 == j2) continue;

                    queue<pair<int, int> > q;
                    q.push(make_pair(i1, j1));
                    vvi check(h, vi(w, -1));
                    check[i1][j1] = 0;
                    while(!q.empty()) {
                        int ni = q.front().first;
                        int nj = q.front().second;
                        q.pop();
                        if(ni>0 && s[ni-1][nj] == '.' && check[ni-1][nj] == -1) {
                            q.push(make_pair(ni-1, nj));
                            check[ni-1][nj] = check[ni][nj] + 1;
                            if(ni-1 == i2 && nj == j2) break;
                        }
                        if(nj>0 && s[ni][nj-1] == '.' && check[ni][nj-1] == -1) {
                            q.push(make_pair(ni, nj-1));
                            check[ni][nj-1] = check[ni][nj] + 1;
                            if(ni == i2 && nj-1 == j2) break;
                        }
                        if(ni<h-1 && s[ni+1][nj] == '.' && check[ni+1][nj] == -1) {
                            q.push(make_pair(ni+1, nj));
                            check[ni+1][nj] = check[ni][nj] + 1;
                            if(ni+1 == i2 && nj == j2) break;
                        }
                        if(nj<w-1 && s[ni][nj+1] == '.' && check[ni][nj+1] == -1) {
                            q.push(make_pair(ni, nj+1));
                            check[ni][nj+1] = check[ni][nj] + 1;
                            if(ni == i2 && nj+1 == j2) break;
                        }
                    }
                    ans = max(ans, check[i2][j2]);
                }
            }
        }
    }

    cout << ans << endl;
}

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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

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

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

	int n,w;
	cin >> n >> w;
	int a[101][2],tot=0;
	for (int i = 0; i< n; i++) cin >> a[i][0] >> a[i][1],tot+=a[i][1];
	ll dp[100005];
	for (int i = 1; i <= tot; i++) dp[i] = 1LL*1000000000000;
	dp[0]=0;
	for (int i = 0; i < n; i++) {
		for (int j = tot; j >= a[i][1]; j--) {
			dp[j]=min(dp[j],dp[j-a[i][1]]+a[i][0]);
		}
	}
	int ans;
	for (int i = 0; i <= tot; i++) {
		if (dp[i]<=w) ans = i;
	}
	cout << ans << "\n";
}

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

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

using namespace std;

int main(){
	int n,k,a[1000]; cin>>n>>k;
	rep(i,n) cin>>a[i];

	vector<long long> S;
	rep(i,n){
		long long s=0;
		for(int j=i;j<n;j++) s+=a[j], S.emplace_back(s);
	}

	for(int i=40;i>=0;i--){
		int m=S.size();
		vector<long long> T;
		rep(j,m) if(S[j]&(1LL<<i)) T.emplace_back(S[j]);

		if(T.size()>=k) S=T;
		else rep(j,m) S[j]&=~(1LL<<i);
	}
	cout<<S[0]<<endl;

	return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i = 0; i < n; i++)

int main(void)
{
    string a,b,c;
    ll n;
    cin >> a >> b ;
    c = a + b;
    n = stoi(c);
    for(int i = 0; i*i <=n; i++) {
        if(i*i==n) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	ll ans = 0;
	string s;
	vi v('z' - 'a' + 1, 0);
	cin >> s;
	ans = (s.size()*(s.size() - 1)) / 2;
	for(auto x: s) {
		v[x - 'a']++;
	}
	for (auto x : v) {
		if (x >= 2) {
			ans -= ((ll)x*(x - 1)) / 2;
		}
	}
	cout << ans+1 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd>> Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod


int main(){
    ll N; cin>>N;
    ll K=0, memo=1;
    while(true){
        if(memo>N) break;
        N-=memo;
        memo*=26;
        K++;
    }
    vec d;
    rep(i,K){
        d.pb(N%26);
        N/=26;
    }
    reverse(ALL(d));
    string ans;
    rep(i,d.size()) ans.pb('a'+d[i]);
    cout<<ans<<endl;

}

Measured memory_bytes: 3588
a,b=map(int,input().split())
n=0
sum=0
if b==1:
    print(0)
else:
    while sum<b:
        n +=1
        if n==1:
            sum = n * a
        else:
            sum=n*a -(n-1)
       # print("n:",n,"s:",sum)
    print(n)

Measured memory_bytes: 2940
#!/usr/bin/env python3


def main():
    s = input()
    if s in ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']:
        print('A')
    else:
        print('a')


if __name__ == "__main__":
    main()


Measured memory_bytes: 9120
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
n, k = map(int, input().split())
# 文字列の入力
s = input()
news = ""
for i in range(0, n):

    if i == k-1:
        news += s[i].lower()
    else:
        news += s[i]
print(news)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
map<int,int> c;
cin>>a;
for (int i=0;i<a;i++)
{
cin>>b;
c[b]++;
if (c[b]==2)
{
cout<<"NO"<<endl;
return 0;
}
}
cout<<"YES"<<endl;
return 0;
}

Measured memory_bytes: 9600
s = input()
n = len(s)

def solve():
  for i in range(1,n):
    if s[i-1] == s[i]:
      print(i,i+1)
      return
  for i in range(2,n):
    if s[i-2] == s[i-1] or s[i-1] == s[i] or s[i-2] == s[i]:
      print(i-1,i+1)
      return
  print(-1,-1)

if n==2:
  if s[0]==s[1]:
    print(1,2)
  else:
    print(-1,-1)    
else:
  solve()
    

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

int main() {
    string S;
    cin >> S;
    if(S.at(2)==S.at(3) && S.at(4)==S.at(5)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256