akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int x;
    cin>>x;
    vi a;
    a.PB(1);
    for(int i=2;i*i<=x;++i){
        int m=i*i;
        while(m<x){
            m*=i;
        }
        if(m>x)m/=i;
        a.PB(m);
    }
    sort(all(a));
    cout<<a[a.size()-1]<<endl;
}

Measured memory_bytes: 256
from itertools import combinations


n = int(input())
ball = []
for i in range(n):
    ball.append(list(map(int, input().split())))


pq_list = [(a - c, b - d) for (a, b), (c, d) in list(combinations(ball, 2))]
max_cnt = 0
for p, q in pq_list:
    cnt = 0
    for x, y in ball:
        if [x+p, y+q] in ball:
            cnt += 1
    max_cnt = max(cnt, max_cnt)
print(n - max_cnt)

Measured memory_bytes: 42908
#include <algorithm>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

#ifdef __APPLE__
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...)
#endif

const int N = (int)1e6 + 123;
const int MOD = (int)1e9 + 7;
const int inf = (int)5e8;
const long long infll = (long long)1e17;


int p[N];

void solve() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &p[i]);
        --p[i];
    }
    int ans = 0;
    for (int i = 0; i < n - 1; ++i) {
        if (p[i] == i) {
            ++ans;
            swap(p[i], p[i + 1]);
        }
    }
    if (p[n - 1] == n - 1)  {
        ++ans;
    }
    printf("%d\n", ans);
}

int main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

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

int main() {
  
  	int N,K,x;
  	cin >> N >> K;

  	x=1;
  	for(int i=0;i<N;i++){
    	if(!(x>K)){
        	x +=x;
        }
      	else{
        	x +=K;
        }
    }
  
  	cout << x << endl;
}

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

#define rep(i, k, n) for(int i = (k); i < (n); i++)
#define irep(i, k, n) for(int i = (k); i > (n); i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void){
  int n;
  cin >> n;
  vector<P> a(n);
  rep(i, 0, n){
    int t;
    cin >> t;
    a[i] = P(t, i);
  }
  sort(a.begin(), a.end());

  rep(i, 0, n) cout << a[i].second + 1 << endl;


  return 0;
}

Measured memory_bytes: 1664
package main

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

func main() {
	log.SetFlags(log.Lshortfile)
	H := nextInt()
	W := nextInt()
	K := nextInt()
	dp := make([][]int, H+1)
	for i := 0; i < H+1; i++ {
		dp[i] = make([]int, W)
	}
	mod := 1000000007
	dp[0][0] = 1
	var i, j uint64
	for i = 0; i < uint64(H); i++ {
		for j = 0; j < uint64(W); j++ {
			var k uint64
			for k = 0; k < 1<<(uint64(W)-1); k++ {
				ok := true
				var l uint64
				for l = 0; int(l) < W-2; l++ {
					if UtoB((k>>l)&1) && UtoB((k>>(l+1))&1) {
						ok = false
					}
				}
				if ok {
					if j >= 1 && UtoB((k>>(j-1))&1) {
						dp[i+1][j-1] += dp[i][j]
						dp[i+1][j-1] %= mod
					} else if j <= uint64(W-2) && UtoB((k>>j)&1) {
						dp[i+1][j+1] += dp[i][j]
						dp[i+1][j+1] %= mod
					} else {
						dp[i+1][j] += dp[i][j]
						dp[i+1][j] %= mod
					}
				}
			}
		}
	}
	fmt.Println(dp[H][K-1] % mod)
}

func Max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func Min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func Sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func UtoB(u uint64) bool {
	if u == 0 {
		return false
	}
	return true
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	long long n;
	scanf("%lld",&n);
	long long x=100,y,cnt=0;
	while(1)
	{
		y=x/100;
		x=x+y;
		cnt++;
		if(x>=n)
		break;
	}
	printf("%lld",cnt);
}

Measured memory_bytes: 1728
let n, m = Scanf.scanf "%d %d\n" (fun n m -> (n, m))

let hash = Hashtbl.create m

let rec init_hash m =
  if m = 0 then ()
  else
    let a, b = Scanf.scanf "%d %d\n" (fun a b -> (a, b)) in
    let ls = b :: (try Hashtbl.find hash a with Not_found -> []) in
    Hashtbl.replace hash a ls ;
    init_hash (m - 1)


let rec iter_search = function
  | [] -> "IMPOSSIBLE"
  | from_first :: rest ->
    let to_n = (try Hashtbl.find hash from_first with Not_found -> []) in 
    if List.exists (( = ) n)  to_n then "POSSIBLE"
    else iter_search rest


let () =
  let () = init_hash m in
  Hashtbl.find hash 1 |> iter_search |> Printf.printf "%s\n"

Measured memory_bytes: 15232
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;

map<string, int> memo;

using P=pair<int, int>;
/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (ll j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}



int main() {
	int n, i;
	cin >> n >> i;
	cout << n - i + 1 << endl;
	return 0;
}













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

int main(void){
    int n,y;cin>>n>>y;
    int cnt=0;
    for(int i=0;i<=n;i++)for(int j=0;j<=n-i;j++)if(10000*i+5000*j+1000*(n-i-j)==y){cout<<i<<" "<<j<<" "<<n-i-j<<endl;return 0;}
    cout<<"-1 -1 -1"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define mp make_pair
#define endl "\n"
#define N 998244353
#define INF 1e9

 
ll power(ll x, ll y, ll m) { 
    if (y == 0) return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 
int main(){
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    
    ll n , i , p  ;
    cin >> p >> n ;
    ll a[n] , m=0 ;
    for(i=0 ; i<n ; i++){
        cin >> a[i] ;
    }
    m = p-a[n-1]+a[0] ;
    if(n==2)cout << min(m ,p-m) ;
    else{
    for(i=1 ; i<n ; i++){
        m = max(a[i]-a[i-1] , m) ;
    }
    cout << p-m ;
    }

    return 0 ;
    
}


Measured memory_bytes: 1792
n=int(input())
s=input()
m=0
for i in range(n):
  s1=s[:i]
  a1=set()
  for j in s1:
    a1.add(j)
  s2=s[i:]
  a2=set()
  for j in s2:
    a2.add(j)
  uni=a1 & a2
  if m<len(uni):
    m=len(uni)
print(m)

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

int main()
{
    while (1)
    {
        int a, b;
        string o;
        cin >> a >> o >> b;

        if (o == "?")
            break;
        if (o == "+")
        {
            cout << a + b << endl;
        }
        else if (o == "-")
        {
            cout << a - b << endl;
        }
        else if (o == "*")
        {
            cout << a * b << endl;
        }
        else if (o == "/")
        {
            cout << a / b << endl;
        }
    }
}


Measured memory_bytes: 3152
#include <iostream>
#include <string>

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

  int H, W;
  std::cin >> H >> W;

  std::cout << std::string(W+2, '#') << '\n';
  for (int i=0; i<H; ++i) {
    std::string a;
    std::cin >> a;
    std::cout << '#' << a << "#\n";
  }
  std::cout << std::string(W+2, '#') << '\n';
  return 0;
}


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

using namespace std;

int main(void){
    int N, K;
    cin >> N >> K;
    if(K > (N - 1) * (N - 2) / 2){
        cout << -1 << endl;
        return 0;
    }
    cout << (N - 1) + (N - 1) * (N - 2) / 2 - K << endl;
    for(int i = 2; i <= N; i++){
        cout << 1 << " " << i << endl;
    }
    int l = 2;
    int r = 3;
    for(int k = 0; k < (N - 1) * (N - 2) / 2 - K; k++){
        cout << l << " " << r << endl;
        r++;
        if(r > N){
            l++;
            r = l + 1;
        }
    }
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var K = parseInt(input[0].split(" ")[1]);
  var S = parseInt(input[0].split(" ")[2]);
  if(S!=Math.pow(10,9)){
    var SS = S+1;
  }else{
    var SS = 1;
  }
  var anssub=new Array(N).fill(SS);
  for(var i=0;i<K;i++){
    anssub[i]=S;
  }
  var ans=anssub.join(" ");

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22344
n, m = map(int,input().split())
s = []
c = []
for _ in range(m):
  x, y = map(int,input().split())
  s.append(x)
  c.append(y)

for i in range(10 ** (n + 1)):
    Str = str(i)

    if len(Str) == n and all([Str[s[j] - 1] == str(c[j]) for j in range(m)]):
        print(Str)
        exit()

print(-1)

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

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(t => int.Parse(t)).ToArray();
        int a = inpt[0];
        int b = inpt[1];
        int kaku = inpt[2];
        double rad = kaku * (Math.PI / 180);
        double menseki = 0;
		double gaisyu = 0;
        double takasa = b * Math.Sin(rad);
        menseki = a * takasa / 2;
        gaisyu = a + b + Math.Sqrt(Math.Pow(a, 2) + Math.Pow(b, 2) - (a * b * Math.Cos(rad)*2));
        Console.WriteLine(menseki);
        Console.WriteLine(gaisyu);
        Console.WriteLine(takasa);
    }


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"






100 80 54



";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

Measured memory_bytes: 9628
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
int  long long i,a=1,b=1,z=0,m = 1000000007;
cin>>i;
for(int j=0;j<i;j++)
{
    z=(a*b)%m;
    b++;
    a=z;
}
cout<<z;

    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream> 
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define  all(x) (x).begin(),(x).end()
typedef long long ll;

int A[105][105];

int main(){
    int n;
    cin >> n; cin.ignore();
    for(int i = 1; i <= n; i++){
        string s;
        getline(cin, s);
        istringstream ss(s);
        int u, k, v;
        ss >> u >> k;
        for(int j = 0; j < k; j++){
            ss >> v;
            A[u][v] = 1;
        }
    }
    for(int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            cout << A[i][j];
            if (j != n) cout << " ";
        }
        cout << endl;
    }
}


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

int main() {
    int x, y;
    string str;
    for(x = 1; x < 10; x++){
        for(y = 1; y < 10; y++){
            str = to_string(x) + "x" + to_string(y) + "=" + to_string(x*y);
            cout << str << endl;
        }
    }
}

Measured memory_bytes: 3132
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){

    string S;
    cin >> S;

    if(S=="MON") cout << 6 << endl;
    if(S=="TUE") cout << 5 << endl;
    if(S=="WED") cout << 4 << endl;
    if(S=="THU") cout << 3 << endl;
    if(S=="FRI") cout << 2 << endl;
    if(S=="SAT") cout << 1 << endl;
    if(S=="SUN") cout << 7 << endl;
    
    return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) (a).begin(),(a).end()

template<typename T1, typename T2> inline void chkmin(T1 & x, const T2 & y) {if (y < x) x = y;}
template<typename T1, typename T2> inline void chkmax(T1 & x, const T2 & y) {if (x < y) x = y;}

int n;
string s;

void read() {
	cin >> n >> s;
}
const int N = 2e5 + 10;

int pref[N][2], suff[N][2];

int get(char x) {
	if (x == 'W') return 1;
	return 0;
}

void build() {
	for (int i = 1; i <= n; i++) {
		for (int it = 0; it < 2; it++) {
			pref[i][it] = pref[i - 1][it];
		}
		pref[i][get(s[i - 1])]++;
	}
	for (int i = n; i >= 1; i--) {
		for (int it = 0; it < 2; it++) {
			suff[i][it] = suff[i + 1][it];
		}
		suff[i][get(s[i - 1])]++;
	}
}

int calc(int posR) {
	int cntWL = pref[posR][1];
	int cntRR = suff[posR + 1][0];
	int ans = min(cntWL, cntRR);
	cntWL -= ans;
	cntRR -= ans;
	//cout << posR << " " << ans << ans + cntRR + cntWL << endl;
	return ans + cntRR + cntWL;
}

int ans;

void run() {
	build();
	ans = n;
	for (int i = 0; i <= n; i++) {
		chkmin(ans, calc(i));
	}
}

void write() {
	cout << ans << endl;
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(20), cout.setf(ios::fixed);
	read();
	run();
	write();
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    int dp[n + 1][m + 1];
    for (int i = 0;i <= n;i++) {
        for (int j = 0;j <= m;j++) {
            dp[i][j] = 0;
        }
    }
    for (int i = 0;i < n;i++) {
        for (int j = 0;j < m;j++) {
            if (s[i] == t[j]) {
                chkmax(dp[i + 1][j + 1], dp[i][j] + 1);
            }
            chkmax(dp[i + 1][j + 1], dp[i + 1][j]);
            chkmax(dp[i + 1][j + 1], dp[i][j + 1]);
        }
    }
    string ans = "";
    int x = n, y = m;
    while (true) {
        if (x == 0 || y == 0) {
            break;
        }
        if (dp[x - 1][y] == dp[x][y]) {
            x--;
            continue;
        }
        if (dp[x][y - 1] == dp[x][y]) {
            y--;
            continue;
        }
        ans += s[x - 1];
        x--;
        y--;
    }
    reverse(all(ans));
    cout << ans;
    return 0;
}


Measured memory_bytes: 70656
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 1010
using namespace std;
long long a,b,x,ans;
int main(){
	SF("%lld%lld",&a,&b);
	x=a;
	while(x<=b){
		ans++;
		x*=2ll;
	}
	PF("%lld",ans);
} 

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

int main() {
  char A,B;
  cin >> A;
  if(A=='A'){
   B='T';
  }
  else if(A=='C'){
   B='G';
  }
  else if(A=='T'){
    B='A';
  }
  else{
    B='C';
  }
  cout << B << endl;
}

Measured memory_bytes: 3620
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int a,b;
    cin>>a>>b;
    if(a<0&&b>0)return puts("Zero")*0;
    if(a<0&&b<0)if(!(abs(a-b-1)%2))return puts("Positive")*0;
    else return puts("Negative")*0;
    else if(a<0&&b>0)if(abs(a)%2)return puts("Negative")*0;
    else return puts("Positive")*0;
    else return puts("Positive")
        *0;    return 0;
    
}

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

int main() {
	int n;
	cin >> n;
	string s,t;
	cin >> s >>t;
	string shin;
	rep(i, n) {
		shin += (s.substr(i,1) + t.substr(i,1));
	}
	cout << shin << endl;

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main(){
int ac = 0;
int bc = 0;
int cc = 0;
bool cou = false;
string S;
cin >> S;
for(int i = 0;i < 3;i++){
if(S[i] == 'a')ac++;
if(S[i] == 'b')bc++;
if(S[i] == 'c')cc++;
}
if(ac == 1 && bc == 1 && cc == 1)cou = true;
if(cou)cout << "Yes" << endl;
else cout << "No" << endl;

        return 0;
}

Measured memory_bytes: 256
n=int(input())
xyh = [list(map(int,input().split())) for _ in range(n)]
def dis(a,b):
  return abs(a[0]-b[0])+abs(a[1]-b[1])
for i in range(101):
  for j in range(101):
    for k in range(n):
      if xyh[k][2]!=0:
        kari=dis(xyh[k],(i,j))+xyh[k][2]
        break
    f=1
    for k in range(n):
      if xyh[k][2]!=max(kari-dis(xyh[k],(i,j)),0):
        f=0
        break
    if f:
      print(i,j,kari)
      exit()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int N,M;
bool visited[100100];
int dp[100100]={0};
vector<int> G[100100],v;

void dfs(int s){
  visited[s]=1;
  for(int i=0;i<G[s].size();i++){
    if(!visited[G[s][i]]){
      dfs(G[s][i]);
    }
  }
  v.push_back(s);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll N,M;
  cin >> N >> M;
  int x,y;
  for(int i=0;i<M;i++){
    cin >> x >>y;
    x--;
    y--;
    G[x].push_back(y);
  }

  for(int i=0;i<N;i++){
    if(!visited[i]){
      dfs(i);
    }
  }
  reverse(v.begin(),v.end());

 int ans=0;
 for(int i=0;i<N;i++){
   for(int j=0;j<G[v[i]].size();j++){
     dp[G[v[i]][j]]=max(dp[G[v[i]][j]],dp[v[i]]+1);
   }
   ans=max(ans,dp[v[i]]);
 }
 cout << ans << endl;
 return 0;
}

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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <

// Output, Common Containers
template <typename T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const set<T> &v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const pair<T,S> &v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const map<T,S> &v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef SANYAM1101
	#define trace(args...) do{ cerr << "TRACE ON! (Line: " << __LINE__ << ")\n"; auto _stream = istringstream{string{#args}}; d_f(_stream, args); } while(0)
	void d_f(__attribute__((unused)) istringstream& _stream) {}
	template<typename Head, typename... Tails> void d_f(istringstream& _stream, Head H, Tails... T) { string _name; _stream >> _name; if(_name.back() == ',') _name.pop_back(); cerr << "\t" << _name << " <=> [" << H << "]\n"; d_f(_stream, T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

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

	cout << a + (a * a) + (a * a * a) << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3604
K = int(input())
a = ["1","2","3","4","5","6","7","8","9"]
for i in range(K):
    if  a[i][-1] == "9":
        a.append(a[i]+str(int(a[i][-1])-1))
        a.append(a[i]+str(int(a[i][-1])))
    elif a[i][-1] == "0":
        a.append(a[i]+str(int(a[i][-1])))
        a.append(a[i]+str(int(a[i][-1])+1))
    else:
        a.append(a[i]+str(int(a[i][-1])-1))
        a.append(a[i]+str(int(a[i][-1])))
        a.append(a[i]+str(int(a[i][-1])+1))
print(a[K-1])

Measured memory_bytes: 23724
N = input()
hon = [2, 4, 5, 7, 9]
pon = [0, 1, 6, 8]
bon = [3]
if int(N) % 10 in hon:
    print('hon')
elif int(N) % 10 in pon:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9168
#include <cstdio>

int main() {
    long long n, m;
    scanf("%lld%lld", &n, &m);
    
    if (m > 2 * n) {
        printf("%lld\n", n + (m - 2 * n) / 4);
    } else {
        printf("%lld\n", m / 2);
    }

    return 0;
}

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

int main() {
  int WeightA = 0, WeightB = 0, WeightC = 0, WeightD = 0;
  cin >> WeightA >> WeightB >> WeightC >> WeightD;
  if(WeightA + WeightB - WeightC - WeightD == 0){
    cout << "Balanced" << endl;
  }else if(WeightA + WeightB - WeightC - WeightD > 0){
    cout << "Left" << endl;
  }else{
    cout << "Right" <<endl;
  }
}

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

typedef long long ll;
typedef long double ld;

int MOD=1000000007;

int main(){
  ll N,sum=0;
  cin >> N;
  for(ll i=1; i<=N; i++){
    if(i%3==0 || i%5==0)
    sum+=0;
    else
    sum+=i;
  }
  cout << sum << endl;

}


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

int main(){
	int N,a[200],count=0;
  	cin>>N;
	while(1){for(int i=0;i<N;++i){
      cin>>a[i];
      if(a[i]%2!=0){cout<<count<<endl;return 0;}
      else a[i]/=2;
    }++count;
            }return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n,y  int
	fmt.Scan(&n, &y)

	for i := 0; i <= n; i++ {
		for j := 0; j <=(n - i); j++ {
			 k := n - i - j

			 if 10000*i+5000*j+1000*k == y {
				 fmt.Println( i, j, k)
				 return
			}
		 }
	 }
	 fmt.Println("-1 -1 -1")
}


Measured memory_bytes: 512
A,B,C,D = map(int,input().split())
amari = lambda x,y:0 if x%y == 0 else 1 
killaoki = C//B + amari(C,B)
killtakahashi = A//D + amari(A,D)
ans = lambda x,y:"Yes" if x<=y else "No"
print(ans(killaoki,killtakahashi))

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

int main() {
  ll n, m ;
  cin >> n >> m;
  if (n != m ) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ
 
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
 
typedef struct{
    int name;
    int prefecture;
    int year;
    int id;
}city;
 
//cityをprefecture昇順→yearの昇順に並び替え
int city_asc(const void* a, const void* b){
    city p=*(city*)a;
    city q=*(city*)b;
 
    if(p.prefecture-q.prefecture>0) return 1;
    else if(p.prefecture-q.prefecture<0) return -1;
    else{
        if(p.year-q.year>0) return 1;
        else if(p.year-q.year<0) return -1;
    }
    return 0;
}
 
int name_asc(const void* a, const void* b){
    city p=*(city*)a;
    city q=*(city*)b;
 
    return p.name-q.name;
}
 
void print_number(int N){
    int digit=1;
    while(N/10!=0){
        digit++;
        N=N/10;
    }
 
    for(int i=1;i<=(6-digit);i++){
        printf("0");
    }
    printf("%d",N);
 
    return;
}
 
int main(void){
    int N,M;
    scanf("%d%d",&N,&M);
 
    //C[0]~C[M-1]に格納→昇順ソート
    city* C;
    NEW(C,M);
    for(int i=0;i<M;i++){
        C[i].name=i;
        scanf("%d",&C[i].prefecture);
        scanf("%d",&C[i].year);
        C[i].id=0;
    }
    qsort(C,M,sizeof(city),city_asc);
 
    //認識番号をそれぞれidに格納
    C[0].id=1;
    for(int i=1;i<M;i++){
        if(C[i].prefecture==C[i-1].prefecture) C[i].id=C[i-1].id+1;
        else C[i].id=1;
    }
 
    //入力順に並び替え
    qsort(C,M,sizeof(city),name_asc);
 
    for(int i=0;i<M;i++){
        printf("%06d%06d\n",C[i].prefecture,C[i].id);
    }
 
    return 0;
}

Measured memory_bytes: 4588
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int tasks = 0;
        for(int i=0; i<M; i++) {
            tasks+=sc.nextInt();
        }
        if(tasks>N) {
            System.out.println(-1);
        } else {
            System.out.println(N-tasks);
        }
    }
}


Measured memory_bytes: 46336
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;
using namespace std;
 

int main(int argc, char* argv[])
{
    int n,m;
    scanf("%d%d", &n, &m);

    vector<vector<pair<int,ll> > > z(n);   // r->l,cost
    int i;
    for(i=0; i<m; i++) {
        int l,r; ll c;
        scanf("%d%d%lld", &l, &r, &c); l--; r--;
        z[r].push_back(make_pair(l,c));
    }

    set<pair<int,ll> > save;
    //vector<ll> dp(n,LINF);
    //dp[0]=0;
    save.insert(make_pair(0,0));
    ll ans=-1;
    for(i=1; i<n; i++) {
        int siz=(int)z[i].size();
        int k;
        ll dist=LINF;
        for(k=0; k<siz; k++) {
            int l=z[i][k].first;
            ll  c=z[i][k].second;
            auto it = save.lower_bound(make_pair(l,-1));
            if(it!=save.end()) {
                dist=MIN(dist,it->second+c);
            }
        }
        if(dist<LINF) {
            while(!save.empty()) {
                auto it=save.rbegin();
                ll tmp=(*it).second;
                if(tmp>dist) {
                    save.erase(*it);
                }
                else {
                    break;
                }
            }
            save.insert(make_pair(i,dist));
            if(i==n-1) {
                ans=dist;
            }
        }
    }
   
    printf("%lld\n", ans);


    return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
}

Measured memory_bytes: 3640
var
  s:string;
  location_c,location_f:longint;
  i:longint;
procedure judge(t:longint);
begin
  if t=0 then begin writeln('No');halt; end
end;
procedure print;
begin
  writeln('Yes');
  halt;
end;
begin
  readln(s);
  location_c:=pos('C',s);
  judge(location_c);
  for i:=length(s) downto 1 do
   if s[i]='F' then begin location_f:=i;break; end;
  judge(location_f);
  if location_c>=location_f then judge(0)
                            else print;
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int t[2];
long long a[2], b[2], c,d;
int main(){
	scanf("%d%d%lld%lld%lld%lld", t,t+1,a,a+1,b,b+1);
	c = (a[0]-b[0]) * t[0];
	d = c + (a[1]-b[1]) * t[1];
	if(c > 0) d = -d;
	else c = -c;
	if(d == 0) puts("infinity");
	else if(d < 0) printf("0\n");
	else printf("%lld\n", c/d*2+(c%d!=0));
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <bitset>
#include <set>
#include <chrono>
#include <string>

using namespace std;

#define endl '\n'

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

    int n, m;
    cin >> n >> m;

    vector<int> a(m);

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

    if (m == 1)
    {
        if (n == 1)
        {
            cout << 1 << endl
                 << 1 << endl
                 << 1 << endl;
        }
        else
        {
            cout << a[0] << endl
                 << 2 << endl
                 << a[0] - 1 << " " << 1 << endl;
        }
    }
    else
    {
        sort(a.begin(), a.end(), [&](int u, int v) {
            return (u & 1) < (v & 1);
        });

        if (m >= 3 && (a[m - 3] & 1))
        {
            cout << "Impossible" << endl;
        }
        else
        {
            swap(a[0], a[m - 2]);

            for (auto x : a)
                cout << x << " ";
            cout << endl;

            cout << a.size() - (a[0] == 1) << endl;

            if (a[0] > 1)
                cout << a[0] - 1 << " ";
            for (int i = 1; i + 1 < m; ++i)
            {
                cout << a[i] << " ";
            }

            cout << a[m - 1] + 1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
using System;

public class AtCoder{
	public static void Main(){
		string[] s;
		s = Console.ReadLine().Trim().Split(' ');
		
		int[] m = new int[3];
		m[0] = int.Parse(s[0]);
		m[1] = int.Parse(s[1]);
		m[2] = int.Parse(s[2]);
		
		Array.Sort(m);
		
		Console.WriteLine(m[2]*10+m[1]+m[0]);
	}
}


Measured memory_bytes: 11092
h,w=gets.split.map(&:to_i)
a=h.times.map{gets.chomp}
a.delete("."*w)
l=[false]*w
w.times do |j|
  a.each do |ai|
    if ai[j]=="#"
      l[j]=true
      break
    end
  end
end
b=[]
a.each do |ai|
  bb = []
  w.times do |j|
    bb << ai[j] if l[j]
  end
  b << bb.join
end
puts b

Measured memory_bytes: 1916
N, K = gets.split.map(&:to_i)
hs = Array.new(N) { gets.to_i }

min = nil

hs.sort!

(hs.length - K + 1).times do |i|

  diff = hs[i + K - 1] - hs[i]
  if min.nil?
    min = diff
  else
    min = diff if diff < min
  end
end


puts min


Measured memory_bytes: 3688
a,b,c = gets.split.map(&:to_f)

puts 1.0/2.0 * a * b*Math::sin(c/180*Math::PI)
puts a + b +Math::sqrt(a**2+b**2 - 2.0*a*b*Math::cos(c/180*Math::PI))
puts b * Math::sin(c/180*Math::PI)

Measured memory_bytes: 8924
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <cassert>
#include <random>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back
#define FOR(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

const int mod = 1e9 + 7;
const int mod2 = 998244353;

void fact_init(int n);
ll exp(ll taban, ll us, ll md);
ll ebob(ll a, ll b);
ll ekok(ll a, ll b);
ll komb(ll a, ll b);

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
    fact.resize(n+5);
    inv_fact.resize(n+5);
    fact[0] = inv_fact[0] = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % mod;
        inv_fact[i] = exp(fact[i], mod-2, mod);
    }
}
ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
    if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

ll komb(ll a, ll b){
    if(a < b) return 0;
    return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}
const int N = 1e6 + 5;

int main(){
    ios::sync_with_stdio(false); cin.tie(NULL);
	ll cnt[N] = {};
	for(int i = 1; i < N; i++){
		for(int j = i; j < N; j += i){
			cnt[j]++;
		}
	}
	ll res = 0;
	int n; cin>>n;
	for(int i = 1; i < n; i++){
		res += cnt[n-i];
	}
	cout<<res<<"\n";
}

Measured memory_bytes: 11476
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class Dice {
    int top;
    int bottom;
    int left;
    int right;
    int front;
    int back;

    static Dice of (int[] init) {
        Dice d = new Dice();
        // [top front right left back bottom]
        d.top = init[0];
        d.bottom = init[5];
        d.left = init[3];
        d.right = init[2];
        d.front = init[1];
        d.back = init[4];
        return d;
    }

    static Dice of (Dice copy) {
        Dice d = new Dice();
        d.top = copy.top;
        d.bottom = copy.bottom;
        d.left = copy.left;
        d.right = copy.right;
        d.front = copy.front;
        d.back = copy.back;
        return d;
    }

    // roll to right
    void E () {
        Dice copy = Dice.of(this);
        top = copy.left;
        bottom = copy.right;
        left = copy.bottom;
        right = copy.top;
    }

    // roll to back
    void N () {
        Dice c = Dice.of(this);
        top = c.front;
        bottom = c.back;
        front = c.bottom;
        back = c.top;
    }

    // roll to front
    void S () {
        Dice c = Dice.of(this);
        top = c.back;
        bottom = c.front;
        front = c.top;
        back = c.bottom;
    }

    // roll to left
    void W () {
        Dice c = Dice.of(this);
        top = c.right;
        bottom = c.left;
        left = c.top;
        right = c.bottom;
    }

    void toTop (int n) {
        if (n == bottom) {
            E();
            E();
        } else if (n == left) {
            E();
        } else if (n == right) {
            W();
        } else if (n == front) {
            N();
        } else if (n == back) {
            S();
        }
    }

    void toFront (int n) {
        if (n == top) {
            S();
        } else if (n == bottom) {
            N();
        } else if (n == left) {
            E();
            S();
        } else if (n == right) {
            W();
            S();
        } else if (n == back) {
            S();
            S();
        }
    }
}

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))){
            int[] arr = Arrays.stream(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            Dice dice = Dice.of(arr);

            int n = Integer.parseInt(in.readLine());
            for (int i = 0; i < n; i++) {
                String[] line = in.readLine().split(" ");
                int top = Integer.parseInt(line[0]);
                int front = Integer.parseInt(line[1]);
                while (true) {
                    if (dice.top == top && dice.front == front) break;
                    dice.toTop(top);
                    if (dice.top == top && dice.front == front) break;
                    dice.toFront(front);
                }
                System.out.println(dice.right);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 30856
//ΔAGC033E
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 222222;
const int MO = 1e9+7;
char ch[N];
int n,m,ans,f[N],s[N];
int main()
{
	int i,x,y,o;
	scanf("%d%d%s",&n,&m,ch+1);
	for(i=1;i<=m;i=i+1)
		if(ch[i]!=ch[1])
			break;
	if(i<=m){
		o=i-1;
		if(o%2==0)
			o++;
		x=1,y=0;
		for(i=i+1;i<=m;i=i+1){
			if(ch[i]==ch[i-1])
				x++;
			else{
				if(y&&x%2==1)
					o=min(o,x);
				y^=1;
				x=1;
			}
		}
	}
	else{
		f[1]=1;
		s[1]=1;
		for(i=2;i<=n;i=i+1){
			f[i]=s[i-2];
			s[i]=(s[i-1]+f[i])%MO;
		}
		x=1;
		for(i=1;i<n;i=i+1)
			x+=(LL)f[i]*(n-i+1)%MO,x%=MO;
		cout<<x;
		return 0;
	}
	if(n&1){
		cout<<0;
		return 0;
	}
	o++;
	o/=2;
	n/=2;
	if(o>n)
		o=n;
	f[1]=1;
	s[1]=1;
	for(i=2;i<=n;i=i+1){
		x=i-o-1;
		if(x<0)
			y=0;
		else
			y=s[x];
		f[i]=(s[i-1]-y+MO)%MO;
		s[i]=(s[i-1]+f[i])%MO;
	}
	x=0;
	for(i=n-o+1;i<=n;i=i+1)
		x+=(LL)f[i]*((n-i+1)*2)%MO,x%=MO;
	cout<<x;
	return 0;
}

Measured memory_bytes: 2048
x,n = map(int,input().split())
p = list(map(int,input().split()))
if not x in p:
    print(x)
else:
    y = x-1
    z = x+1
    while 1:
        if not y in p:
            print(y)
            break
        if not z in p:
            print(z)
            break
        y-=1
        z+=1



Measured memory_bytes: 9200
//not answered
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long int lli;
#define INF 11451419
#define N_MAX 8

int N,A,B,C;
vector<int> l(N_MAX);

int res(int cur, int a, int b, int c){
  if(cur == N){
    if(min(a,min(b,c)) > 0)
      return abs(A-a) + abs(B-b) + abs(C-c) - 30;
    else
      return INF;
  }

  int rin = res(cur+1, a, b, c);
  rin = min(rin, res(cur+1, a+l[cur], b, c) + 10);
  rin = min(rin, res(cur+1, a, b+l[cur], c) + 10);
  rin = min(rin, res(cur+1, a, b, c+l[cur]) + 10);
  return rin;
}

int main(){
  cin >> N >> A >> B >> C;
  l.resize(N);
  for(int i = 0; i < N; i++)
    cin >> l[i];
  
  cout <<  res(0,0,0,0) << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
n=int(input())
a=[[] for i in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    a[u-1].append((v-1,w))
    a[v-1].append((u-1,w))
b=[None for i in range(n)]
def k(v,dis):
    b[v]=dis
    for next_v,w in a[v]:
        if b[next_v]!=None:
            continue
        if w%2==0:
            k(next_v,dis)
        else:
            k(next_v,1-dis)
k(0,0)
for i in range(n):
    print(b[i])


Measured memory_bytes: 79488