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

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

    int ac = 0, wa = 0, tle = 0, re = 0;
    int N, i = 0;
    cin >> N;
    string s;
    while (i < N) {
        ++i;
        cin >> s;
        if (s == "AC") {
            ac++;
        }
        else if (s == "WA") {
            wa ++;
        }
        else if (s == "TLE") {
            tle++;
        }
        else {
            re++;
        }   
    }
    cout << "AC x " << ac << "\n" << "WA x " << wa << "\n" << "TLE x " << tle << "\n" << "RE x " << re << "\n";
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a.at(i);
    map<ll, queue<int>> p;
    rep(i, n) {
        p[a.at(i) + (i+1)].push(i);
    }

    ll count = 0;
    rep(i, n) {
        ll key = i + 1 - a.at(i);
        if(p.count(key)) {
            int size = p.at(key).size();
            count += size;
        }
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 148660
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
typedef long long ll;
using namespace std;

bool compare_by_b(pair<string, int> a, pair<string, int> b) {
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main()
{
	ll N, S, G;
	vector<ll>vec;
	vector<ll>ANS;
	cin >> N;
	fore(i, 0, N) {
		ll t;
		cin >> t;
		vec.push_back(t);
	}
	sort(vec.begin(), vec.end());
	S = *(vec.begin());
	G = *(vec.end() - 1);
	if (S == G) {
		cout << "0" << endl;
	}
	else {
		for (ll i = S; i < G; i++) {
			ll t = 0;
			for (ll j = 0; j < vec.size(); j++) {
				t = t + pow(abs(i - vec[j]), 2);
			}
			ANS.push_back(t);
		}
		sort(ANS.begin(), ANS.end());
		cout << *ANS.begin() << endl;
	}
}

Measured memory_bytes: 256
while True:
    integers = list(map(int, input().split(" ")))
    H = integers[0]
    W = integers[1]
  
    
    if H != 0 and W != 0:
        for i in range(H):
            if i % 2 != 0:
                sharp_dot = []
                for j in range(W):
                    
                    if j % 2 != 0:
                        sharp_dot.append("#")
                    else:
                        sharp_dot.append(".")
                line = ''.join(sharp_dot)
                print(line)
            else:
                sharp_dot = []
                for k in range(W):
                    
                    if k % 2 != 0:
                        sharp_dot.append(".")
                    else:
                        sharp_dot.append("#")
                line = ''.join(sharp_dot)
                print(line)
        print("")
    else:
        break


Measured memory_bytes: 5620
// #define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
int main()
{
    int n, m;
    cin >> n >> m;
    int sum = 0;
    rep(i, 0, m)
    {
        int A;
        cin >> A;
        sum += A;
    }
    if (sum>n)
        cout << -1 << endl;
    else
        cout << n-sum << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
long ans=8e18;
pair<long,long>x[100];
int n,k;
main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>x[i].first>>x[i].second;
	sort(x,x+n);
	for(int i=0;i<=n-k;i++)
	{
		vector<long>P;
		for(int j=0;j<k-1;j++)
		{
			P.push_back(x[i+j].second);
		}
		for(int j=k-1;i+j<n;j++)
		{
			P.push_back(x[i+j].second);
			sort(P.begin(),P.end());
			for(int l=0;l<=P.size()-k;l++)
			{
				ans=min(ans,(P[l+k-1]-P[l])*(x[i+j].first-x[i].first));
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main(){
	var n int
	fmt.Scan((&n))
	li := make([]int, n)
	for i := range li {
		fmt.Scan(&li[i])
	}
	cnt := 0
	for i,_ := range li {
		if li[i] != i + 1 {
			cnt++
		}
	}
	if cnt == 0 || cnt == 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
const int mo=1e9+7;
int f[3050],fac[200050],inv[200050];
struct r{
	int x,y;
}a[3050];
int pow(int t,int k){
	int ret=1;
	while (k){
		if ((k&1))ret=ret*1ll*t%mo;
		t=t*1ll*t%mo;k>>=1;
	}
	return ret;
}
int C(int n,int m){return fac[n]*1ll*inv[m]%mo*inv[n-m]%mo;}
bool cmp(r a,r b){return a.x<b.x||(a.x==b.x&&a.y<b.y);}
int main(){
	int h,w,n;
	scanf("%d%d",&h,&w);
	scanf("%d",&n);
	fac[0]=inv[0]=1;
	for (int i=1;i<=h+w;i++)fac[i]=fac[i-1]*1ll*i%mo;
	inv[h+w]=pow(fac[h+w],mo-2);
	for (int i=h+w-1;i>=1;i--)inv[i]=inv[i+1]*1ll*(i+1)%mo;
	for (int i=1;i<=n;i++)scanf("%d%d",&a[i].x,&a[i].y);
	std::sort(a+1,a+n+1,cmp);
	for (int i=1;i<=n;i++){
		f[i]=C(a[i].y+a[i].x-2,a[i].x-1);
		for (int j=1;j<i;j++)if (a[i].y>=a[j].y)
		f[i]=(f[i]-f[j]*1ll*C(a[i].x-a[j].x+a[i].y-a[j].y,a[i].x-a[j].x)%mo+mo)%mo;
	}
	int ans=C(h+w-2,h-1);
	for (int i=1;i<=n;i++)ans=(ans-f[i]*1ll*C(h-a[i].x+w-a[i].y,h-a[i].x)%mo+mo)%mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 1792
def main():
  inp = []
  for i in range(5):
    x = int(input())
    if x % 10 == 0:
      inp.append([x, 0])
    else:
      inp.append([x, 10 - (x % 10)])
  inp = sorted(inp, key=lambda x: x[1]) 
  # print(inp)

  result = 0
  for i, n in enumerate(inp):
    # print(i, n[0], n[1], result)
    if (i+1) == len(inp):
      result += n[0]
      continue
    
    result += n[0] + n[1]

  print(result)
    
    
    
    
main()


Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
double PI=acos(-1);
double deg(double r){return 180*r/PI;};
double f(double a,double b,double x){return deg(atan(x*2/(a*b*b)));}
int main(){
  double a,b,c,x;
  scanf("%lf %lf %lf",&a,&b,&x);
  if(x*2<a*a*b)c=90-f(a,b,x);
  else         c=f(a,a,a*a*b-x);
  printf("%.10lf\n",c);
  return 0;
}


Measured memory_bytes: 128
import math
K=int(input())
S=0
T=0
for a in range(1,K-1):
    for b in range(a+1, K):
        for c in range(b+1, K + 1):
            d=math.gcd(a,b)
            e=math.gcd(d,c)
            S+=e
            if c==K:
                T+=d
for a in range(1,K):
    T+=math.gcd(a,K)
U=int(K*(K+1)/2)
print(6*S+6*T+U)


Measured memory_bytes: 9208
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1

n,k = readInts()

i = 1
while 1:
	if n<k:
		break
	n = n//k
	i+=1

print(i)

Measured memory_bytes: 3952
#include <stdio.h>
#define min(a,b) (((a)<(b))?(a):(b))

int main()
{
	int n, k;
	long int x[100100];
	long int l = 500000010;
	scanf("%d %d\n", &n, &k);
	for (int i = 0; i < n; i++)
	{
		scanf("%ld", &x[i]);
	}
	for (int i = 0; i + k <= n; i++)
	{
		int newl;
		newl = x[i + k - 1] - x[i];
		newl += min(abs(x[i + k - 1]), abs(x[i]));
		l = min(l,newl);
	}
	printf("%ld", l);
	return 0;
}

Measured memory_bytes: 896
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

int a, b, c;

int main() {
  init_ios();
  cin >> a >> b >> c;
  int cnt = min(c, a-b);
  cout<<c-cnt<<"\n";
}

Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)

long long gcd(long long int a,long long int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

long long  lcm(long long int a,long long int b)
{
   return a * b / gcd(a, b);
}
int main(){
  long long int a,b,c,d;cin>>a>>b>>c>>d;
  long long int e=b-a+1;
  long long int f=e-(b/c-a/c)-(b/d-a/d)+(b/lcm(c,d)-a/lcm(c,d));
  if(a%c==0||a%d==0)f--;
    cout<<f;
    }


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

using namespace std;

typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define si(n) scanf("%d", &n)
#define dout(n) printf("%d\n", n)
#define sll(n) scanf("%lld", &n)
#define lldout(n) printf("%lld\n", n)

#define TRACE

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

#define fast_io                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)

#define endl '\n'

double prob[200000 + 10];

int main() {
  fast_io;
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    prob[i] = 1 / (1.0L * n);
  }
  double multi = 1.0;
  double ans = 0;
  for (int j = 1; j <= 40; j++) {
    for (int i = k; i <= 200000; i++) {
      ans += multi * prob[i];
      prob[i] = 0;
    }
    for (int i = k - 1; i >= 1; i--) {
      prob[i * 2] = prob[i];
      prob[i] = 0;
    }
    multi /= 2;
  }
  cout << fixed << setprecision(20) << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  int xsm = 0;
  vector<int> ans(n, 0);
  int l = 0;
  rep(i, n){
    if((xsm & a.at(i)) == 0){
      xsm ^= a.at(i);
    }else{
      for(; l < n; l++){
        if((xsm & a.at(i)) == 0){
          xsm ^= a.at(i);
          break;
        }
        ans.at(l) = i - l;
        xsm ^= a.at(l);
      }
    }
  }
  rep2(i, l, n){
    ans.at(i) = n - i;
  }
  ll anss = 0;
  rep(i, n){
    // cerr << ans.at(i) << " ";
    anss += ans.at(i);
  }
  // cerr << endl;
  cout << anss << endl;
  // ll ans = 0;
  // ll sum = 0, xsm = 0;
  // int l = 0, r = 0;
  // ll add = 0;
  // for(; r < n; r++){
  //   cerr << ans << endl;
  //   sum += a.at(r);
  //   xsm ^= a.at(r);
  //   if(sum != xsm){
  //     add = (r - l);
  //     ans += add*(add+1)/2;
  //     for(; l < n; l++){
  //       if(sum == xsm){
  //         break;
  //       }
  //       cerr << sum << " " << xsm << endl;
  //       sum -= a.at(l);
  //       xsm ^= a.at(l);
  //     }
  //   }
  // }
  // add = (r - l);
  // ans += add * (add+1)/2;
  // cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4816
k, n = map(int, input().split())
a = list(map(int, input().split()))
kyori=[]

for i in range(len(a)-1):
    l = abs(a[i] - a[i+1])
    kyori.append(l)
kyori.append(k - abs(a[0]-a[n-1]))

saitann = k - max(kyori)
print(saitann)

Measured memory_bytes: 26420
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    for (int i = 1; i < 10; i++) {
      for (int j = 1; j < 10; j++) {
        System.out.println(i + "x" + j + "=" + i*j);
      }
    }
  }
}

Measured memory_bytes: 24148
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int m = scan.nextInt();
			if(n == 0 && m == 0){
				break;
			}
			int[] slide = new int[n];
			for(int i = 0;i < n;i++){
				slide[i] = scan.nextInt();
			}
			int now = 0;
			int[] step = new int[m];
			for(int i = 0;i < m;i++){
				step[i] = scan.nextInt();
			}
			for(int i = 0;i < m;i++){
				now += step[i];
				if(now >= n-1){
					System.out.println(i+1);
					break;
				}
				now += slide[now];
				if(now >= n-1){
					System.out.println(i+1);
					break;
				}
			}
		}
	}
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  int x; cin >> x;
  cout << 360 / gcd(x, 360) << endl;

}








Measured memory_bytes: 3604
#make only 2 same number part of {1...N}
import sys
N=int(input())
a=[s+1 for s in range(N)]
flag=0
if N==1:
    print("Yes")
    print("2")
    print("1 1")
    print("1 1")
    sys.exit()

for i in range(N+1):
    if i*(i-1)//2==N: #kC2
        flag=1
        print("Yes")
        print(i)
        b=[[] for t in range(i)]
        c=1
        u=0
        for s in reversed(range(0,i)):
            for t in range(s):
                b[i-s-1].append(c)
                b[i-s+c-u-1].append(c)
                c+=1
            u+=s
        for x in range(i):
            print(i-1,' '.join(map(str, b[x])))
if flag==0:
    print("No")
            
            

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

int main() {
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if(s=="abc"){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;

struct pt
{
	int x, y, i;
};

pt operator - (const pt &a, const pt &b)
{
	return {a.x - b.x, a.y - b.y, -1};
}

ll operator ^ (const pt &a, const pt &b)
{
	return a.x * (ll) b.y - a.y * (ll) b.x;
}

ll operator * (const pt &a, const pt &b)
{
	return a.x * (ll) b.x + a.y * (ll) b.y;
}

pt s;

bool operator < (const pt &a, const pt &b)
{
    if (((a - s) ^ (b - s)) != 0)
    {
	    return ((a - s) ^ (b - s)) < 0;
    }
    else
    {
        return (a - s) * (a - s) < (b - s) * (b - s);
    }
}

vector <pt> hull(vector <pt> e)
{
	sort(e.begin(), e.end(), [] (pt a, pt b)
	{
		if (a.x != b.x)
		{
			return a.x < b.x;
		}
		else
		{
			return a.y < b.y;
		}
	});
	s = e[0];
	sort(e.begin() + 1, e.end());
	vector <pt> h;
	for (auto c : e)
	{
		while (h.size() > 1)
		{
			pt a = h[(int) h.size() - 2];
			pt b = h[(int) h.size() - 1];
			if (((b - a) ^ (c - b)) >= 0)
			{
				h.pop_back();
			}
			else
			{
				break;
			}
		}
		h.push_back(c);
	}
	return h;
}

double dist(const pt &a, const pt &b)
{
    ll len = (a.x - b.x) * (ll) (a.x - b.x) + (a.y - b.y) * (ll) (a.y - b.y);
    return sqrt(len);
}

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
	int n;
    cin >> n;
	vector <pt> e;
	for (int i = 0; i < n; i++)
	{
		int x, y;
        cin >> x >> y;
		e.push_back({x, y, i});
	}
	vector <pt> cur = hull(e);
    e = cur;
    int m = (int) cur.size();
    double len = 0;
    for (int i = 0; i < m; i++)
    {
        len += dist(e[i], e[(i + 1) % m]); 
    }
    vector <double> ans(n);
    double pi = acos(-1);
    for (int i = 0; i < m; i++)
    {
        pt v1 = e[(i + m - 1) % m] - e[i];
        pt v2 = e[(i + 1) % m] - e[i];
        ans[e[i].i] = (atan2(v2 ^ v1, v2 * v1) + pi) / (2 * pi);
    }
    for (int i = 0; i < n; i++)
    {
        cout << fixed << setprecision(20) << ans[i] << '\n';
    }
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)
 
int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};
 
typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;
 
const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
 
// --------------------------------------
int n, k;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  cin >> n >> k;
 
  vector<P> vp;
  REP(i, n) {
    int t, d;
    cin >> t >> d;
    vp.push_back(P(d, t));
  }
 
  sort(vp.begin(), vp.end(), greater<P>());
 
  vector<bool> used(n + 1, false);
  priority_queue<int, vector<int>, greater<int>> que;
 
  ll kind = 0;
  ll sum = 0, ans = 0;
  REP(i, k) {
    sum += (ll)vp[i].first;
    if(!used[vp[i].second]) {
      used[vp[i].second] = true;
      kind++;
    } else {
      que.push(vp[i].first);
    }
  }
 
  ans = max(ans, kind * kind + sum);
  int j = k;
 
  while(!que.empty()) {
    sum -= que.top(); que.pop();
    while(j < n) {
      if(!used[vp[j].second]) {
        used[vp[j].second] = true;
        kind++;
        sum += (ll)vp[j].first;
        ans = max(ans, kind * kind + sum);
        break;
      }
      j++;
    }
    if(j >= n) break;
  }
 
  cout << ans << endl;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int D = sc.nextInt();

        int[][] arr1 = new int[N][D];

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < D; j++) {
                arr1[i][j] = sc.nextInt();
            }
        }

        int count = 0;
        int temp = 0;

        for (int i = 0; i < N-1; i++) {
            for (int k = 1; k < N - i; k++) {
                for (int j = 0; j < D; j++) {
                    temp += Math.pow(Math.abs(arr1[i][j] - arr1[i+k][j]), 2);
                }
                double temp_s = Math.sqrt(temp);
                    if (temp_s == (int)temp_s) {
                        count++;
                    }
                    temp = 0;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#define inf 1e9
using namespace std;

struct data{
    string day;
    int time;
    bool in;
    int id;
};

int main(void){
    int n;
    while (cin >> n && n) {
        vector<data> d(n);
        for (int i = 0; i < n; i++) {
            string a, b, c;
            cin >> d[i].day >> a >> b >> c;
            int t = stoi(a.substr(0,2))*60 + stoi(a.substr(3,2));
            d[i].time = t;
            if (b == "I") d[i].in = true;
            else d[i].in = false;
            d[i].id = stoi(c);
        }
    
        int idx = 0;
        vector<int> total(1000, 0);
        while (1) {
            string today = d[idx].day;
            vector<int> gio;
            vector<vector<int> > pio(1000);
        
            while (d[idx].day == today) {
                if (d[idx].id == 0) gio.push_back(d[idx].time);
                else pio[d[idx].id].push_back(d[idx].time);
                if (++idx == n) break;
            }
        
            for (int i = 0; i < 1000; i++) {
                if (pio[i].size() == 0) continue;
                for (int j = 0; j < pio[i].size(); j+=2) {
                    for (int k = 0; k < gio.size(); k+=2) {
                        if (pio[i][j] <= gio[k]) {
                            if (pio[i][j+1] <= gio[k]) continue;
                            else if (pio[i][j+1] <= gio[k+1]) total[i] += pio[i][j+1]-gio[k];
                            else total[i] += gio[k+1]-gio[k];
                        }
                        else if (pio[i][j] <= gio[k+1]) {
                            if (pio[i][j+1] <= gio[k+1]) total[i] += pio[i][j+1]-pio[i][j];
                            else total[i] += gio[k+1]-pio[i][j];
                        }
                    }
                }
            }
            if (idx == n) break;
        }
        int ans = 0;
        for (int i = 0; i < 1000; i++) ans = max(ans, total[i]);
        cout << ans << endl;
    }
}

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

int main()
{
    string L[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s;
    cin >> s;
    rep(i, 7)
    {
        if (s == L[i])
        {
            cout << (7 - i) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)


int main(int, char *[])
{
    //const int64_t OFFSET = 10000000000LL;
    const int64_t OFFSET = 10;
    vector<int64_t> cakes[8];
    int N, M;
    cin >> N >> M;
    for(int i = 0; i< N; ++i)
    {
        int64_t score[3];
        cin >> score[0] >> score[1] >> score[2];
        for(int j = 0; j < 8; ++j)
        {
            int64_t sum = 0;
            for(int k = 0; k < 3; ++k)
            {
                const bool assume_neg = j & (1 << k);
                const int64_t shifted =  score[k] + (assume_neg ? -OFFSET : OFFSET);
                sum += (assume_neg ? -1 : 1) * shifted;
            }
            cakes[j].push_back(sum);
        }
    }

    int64_t max_score = -1;
    for(int i = 0; i < 8; ++i)
    {
        partial_sort(cakes[i].begin(), cakes[i].begin() + M, cakes[i].end(), greater<int64_t>());
        int64_t tmp_score = accumulate(cakes[i].begin(), cakes[i].begin() + M, int64_t(0));
        tmp_score -= M * OFFSET * 3;
        dbg << "Score[" << i << "]:" << tmp_score << endl;
        max_score = max(max_score, tmp_score);
    }

    cout << max_score << endl;

    return 0;
}


Measured memory_bytes: 384
X,n = (int(x) for x in input().split())     
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

print(len(Base_10_to_n(X, n)))

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

void main_()
{
    stringstream ss;
    ss << 'L'; // 番兵
    {
        string s;
        cin >> s;
        ss << s;
    }
    ss << 'R'; // 番兵
    auto S = ss.str();

    vector<ll> ans(S.size() - 2);
    for (ll i = 1; i < (ll)S.size() - 1; ++i) {
        auto it = begin(S) + i;
        if (*it == 'R') {
            if (*(it + 1) == 'L') {
                ll cnt = 0;
                while (*it-- == 'R') {
                    cnt++;
                }
                ans[i - 1] += (cnt + 1) / 2;
                ans[i] += cnt / 2;
            }
        } else {
            if (*(it - 1) == 'R') {
                ll cnt = 0;
                while (*it++ == 'L') {
                    cnt++;
                }
                ans[i - 1] += (cnt + 1) / 2;
                ans[i - 2] += cnt / 2;
            }
        }
    }

    copy(begin(ans), end(ans), ostream_iterator<ll>(cout, " "));
    cout << "\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 1516
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#define ll long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FOR(i, stop) for(int i = 0; i < (stop); i++)
#define PI 3.141592653589793
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll d,t,s;
  cin >> d >> t >> s;

  double ans;
  ans = (double)d / (double)s;

  if (ans <= t) yes;
  else no;

  return 0;
}


Measured memory_bytes: 3644
from collections import Counter
n = int(input())
*v, = map(int, input().split())
a = Counter(v[0::2]).most_common()+[(0,0)]
b = Counter(v[1::2]).most_common()+[(0,0)]
if a[0][0] != b[0][0]:
    print(n-a[0][1]-b[0][1])
else:
    print(n-max(a[1][1]+b[0][1],a[0][1]+b[1][1]))

Measured memory_bytes: 20572
n,k = map(int,input().split())
al = list(map(int,input().split()))
al = sorted(al)

MOD = 10**9 + 7
N = 10**5

fact = [1]*(N+1)
rfact = [1]*(N+1)
r = 1
for i in range(1, N+1):
  fact[i] = r = r * i % MOD
rfact[N] = r = pow(fact[N], MOD-2, MOD)
for i in range(N, 0, -1):
  rfact[i-1] = r = r * i % MOD

# nPk (mod MOD) を求める
def perm(n, k):
  return fact[n] * rfact[n-k] % MOD

# nCk (mod MOD) を求める
def comb(n, k):
  return fact[n] * rfact[k] * rfact[n-k] % MOD


ans = 0
for i in range(n-k+1):
    ans += al[i+k-1] * comb(i+k-1, k-1)
    ans %= 10**9 + 7

for i in range(n-k+1):
    ans -= al[n - (i+k-1)-1] * comb(i+k-1, k-1)
    ans %= 10**9 + 7
print(ans)

Measured memory_bytes: 15064
(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

(setq *n* (read))
(setq *x* (read))
(setq *ls* (mapcar #'parse-integer (split " " (read-line))))

(defun accumulate (ls s)
  (if (equal (car ls) nil)
    nil
    (append (list (+ s (car ls))) (accumulate (cdr ls) (+ s (car ls))))
    ))

(defun cnt (ls x i)
  (if (or (equal (car ls) nil) (< x (car ls)))
    i
    (cnt (cdr ls) x (1+ i))
    )
  )

;(print (accumulate *ls* 0))
(print (cnt (accumulate *ls* 0) *x* 1))


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0 ; i<n ; i++)
    cin >> a.at(i);
  
  double sum = 0, plus;
  for (int i=0 ; i<n ; i++){
    plus = 1;
    plus /= a.at(i);
    sum += plus;
  }
  
  sum = 1/sum;
  
  cout << fixed << setprecision(10) << sum << endl;
}

Measured memory_bytes: 3820
#include<stdio.h>

int main(){
  int d, w, h, n, r, i, j, temp, list[3];
  while(scanf("%d%d%d", &d, &w, &h), d+w+h){
    list[0] = d;
    list[1] = w;
    list[2] = h;
    for(i=0; i<3; i++){
      for(j=i+1; j<3; j++){
        if(list[i] > list[j]){
          temp = list[i];
          list[i] = list[j];
          list[j] = temp;
        }
      }
    }
    scanf("%d", &n);
    for(i=0; i<n; i++){
      scanf("%d", &r);
      if(list[0]*list[0] + list[1]*list[1] < 4*r*r){
        printf("OK\n");
      }else{
        printf("NA\n");
      }
    }
  }
  return 0;
}

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

int main(void){
  double t,a,tmp,min=100000000.0;
  int num=0,n,i;
  scanf("%d",&n);
  scanf("%lf %lf",&t,&a);
  double h[n];
  for(i=0;i<n;i++){
    scanf("%lf",&h[i]);
  }
  for(i=0;i<n;i++){
    tmp=a-t+h[i]*0.006;
    if(tmp<0) tmp*=-1;
    //printf("%f\n",tmp);
    if(min>tmp){
      min=tmp;
      num=i;
    }
  }
  printf("%d\n",num+1);
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}


int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<int> a(26,0);
    REP(i,n){
        int c = s[i]-'a';
        a[c]++;
    }
    bool flag = false;
    REP(i,n){
      if(a[i]>1)flag=true;
    }
    if(flag){
      put("no");
    }else{
      put("yes");
    }
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    constexpr auto foo=(ll)(1e18);
    ll n=in();
    vector<ll>a(n);for(ll i=0;i<n;++i){if((a[i]=in())==0){cout<<0<<endl;return 0;}}
    ll p=1;
    for(ll i=0;i<n;++i){
        if(p>foo/a[i]){
            cout<<-1<<endl;
            return 0;
        }
        p*=a[i];
    }
    cout<<p<<endl;
}


Measured memory_bytes: 4056
class Array
	def selection_sort!
		(0..size-1).each{|i|
			minj = i
			(i..size-1).each{|j|
				if self[j] < self[minj]
					minj = j
				end
			}
			if i != minj
				self[i], self[minj] = self[minj], self[i]
				yield if block_given?
			end
		}
		self
	end
end

gets
a = gets.split.map(&:to_i)
cnt = 0
puts a.selection_sort!{cnt+=1}*" "
puts cnt

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

string s;
long long k, n = 0, t = 1;

int main()
{
	cin >> s >> k;

	for (int i = 0; i < s.size() - 1; i++) {
		if (s[i] == s[i + 1])
			t++;
		else {
			n += t / 2;
			t = 1;
		}
	}

	n += t / 2;
	n *= k;

	if (s[0] == s.back() && t % 2 == 1) {
		int j = 1;
		while (j < s.size() && s[j] == s[0])
			j++;

		if (j == s.size())
			n = s.size() * k / 2;
		else if(j % 2 == 1)
			n += k - 1;
	}

	cout << n << endl;

	return 0;
}


Measured memory_bytes: 256
a,b,c,k = map(int,input().split())
if k % 2 == 0:
    if a-b <= 10**18 and a-b >= -10**18:
        print(a-b)
    else:
        print('Unfair')
else:
    if b-a <= 10**18 and b-a >= -10**18:
        print(b-a)
    else:
        print('Unfair')

Measured memory_bytes: 2940
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int x = sc.nextInt();
        int a = sc.nextInt();
		if(x<a){
          System.out.println(0);
        }else{
          System.out.println(10);
        }
	}
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,k;
    cin >> a >> b >> k;
    set<int> s;
    for(int i = 0;i<k;i++){
        s.insert(min(a+i,b));
        s.insert(max(b-i,a));
    }
    for(auto i:s){
        cout << i << endl;
    }
}

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

int main() {
        int n, m;
        scanf("%d%d", &n, &m);
        vector<int> a(2 * n);
        rep(i, 2 * n) {
                scanf("%d", &a[i]);
        }
        sort(a.begin(), a.end());
        int lb = -1, ub = n;
        while (ub - lb > 1) {
                int mid = (ub + lb) / 2;
                bool ok = true;
                mid *= 2;
                for (int i = mid; i < mid + (2 * n - mid) / 2; i ++) {
                        if (a[i] + a[2 * n + mid - i - 1] < m) {
                                ok = false;
                                break;
                        }
                }
                if (ok) {
                        ub = mid / 2;
                } else {
                        lb = mid / 2;
                }
        }
        int b = ub * 2;
        int ma = 0;
        for (int i = 0; i < b / 2; i ++) ma = max(ma, a[i] + a[b - 1 - i]);
        for (int i = b; i < b + (2 * n - b) / 2; i ++) ma = max(ma, (a[i] + a[2 * n + b - i - 1]) % m);
        printf("%d\n", ma);
        return 0;
}


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);

vector<ll> sum(55, 0), p(55, 0);

ll f(ll n, ll x) {
    if(n == 0) {
        if(x <= 0) return 0;
        else return 1;
    }
    else if(x == 1) return 0;
    else if(x <= sum[n-1]+1) return f(n-1, x-1);
    else if(x == sum[n-1]+2) return p[n-1] + 1;
    else return p[n-1] + 1 + f(n-1, x-2-sum[n-1]);
}

int main() {
    ll n, x;
    cin >> n >> x;
    sum[0] = 1;
    p[0] = 1;
    frep(i, 1, n-1) {
        sum[i] = 2*sum[i-1] + 3;
        p[i] = 2*p[i-1] + 1;
    }

    cout << f(n, x) << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
	class Program
	{
		public static void Main()
		{
			var intArray = IO.ReadIntArray();
			var dayNum = intArray[0];
			var useDayNum = IO.ReadIntArray().Sum();
			var remainNum = dayNum - useDayNum;
			IO.Write((remainNum < 0) ? -1 : remainNum);
		}
	}

	public static class IO
	{
		public static string   Read()								 { return Console.ReadLine(); }
		public static string[] ReadArray(char iSplitter = ' ')		 { return Read().Split(iSplitter); }
		public static int	   ReadInt()							 { return int.Parse(Read()); }
		public static int[]	   ReadIntArray(char iSplitter = ' ')	 { return ReadArray().Select(iText => int.Parse(iText)).ToArray(); }
		public static long	   ReadLong()							 { return int.Parse(Read()); }
		public static long[]   ReadLongArray(char iSplitter = ' ')	 { return ReadArray().Select(iText => long.Parse(iText)).ToArray(); }
		public static double   ReadDouble()							 { return double.Parse(Read()); }
		public static double[] ReadDoubleArray(char iSplitter = ' ') { return ReadArray().Select(iText => double.Parse(iText)).ToArray(); }
		public static char[]   ReadCharArray()						 { return Read().ToCharArray(); }

		public static void Write(string iValue)									   { Console.WriteLine(iValue); }
		public static void Write(int iValue)									   { Console.WriteLine(iValue); }
		public static void Write(IEnumerable<int> iValue , string iJoinWord = " ") { Console.WriteLine(string.Join(iJoinWord , iValue)); }
		public static void Write(long iValue)									   { Console.WriteLine(iValue); }
		public static void Write(double iValue)									   { Console.WriteLine(iValue); }
		public static void Write(decimal iValue)								   { Console.WriteLine(iValue); }
		public static void Write(bool iValue)									   { Console.WriteLine(iValue ? "Yes" : "No"); }
	}

	public static class Util
	{
		public static long Gcd(long i0 , long i1) { return (i0 > i1) ? _Gcd(i0 , i1) : _Gcd(i1 , i0); }
		public static long Lcm(long i0 , long i1) { return (i0 * i1) / Gcd(i0 , i1); }
		public static long ModPow(long iBaseNumber , long iPow , long iModNumber)
		{
			var num = 1L;
			while(iPow != 0)
			{
				if((iPow & 0x1) != 0)
				{
					num = (num * iBaseNumber) % iModNumber;
				}
				iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber;
				iPow >>= 1;
			}
			return num;
		}

		private static long _Gcd(long i0 , long i1)	{ return (i1 == 0) ? i0 : _Gcd(i1 , i0 % i1); }
	}
}


Measured memory_bytes: 29112
def solve(n):
    # 1-origin
    dp = [None] * n
    ans = n
    for i in range(1, n // 2):
        rest = n - i
        if dp[i] is None:
            dp[i] = value_sum(i)
        if dp[rest] is None:
            dp[rest] = value_sum(rest)
        ans = min(ans, dp[i] + dp[rest])
    return ans


def value_sum(i):
    value = 0
    for v in str(i):
        value += int(v)
    return value


def main():
    n = int(input())
    ans = solve(n)
    print(ans)


main()

Measured memory_bytes: 3828
#include<cstdio>
#include<algorithm>
#include<functional>
#define MM 1000000007
using namespace std;
int main(void)
{
	int h,w,k1,i,j,b[7],pat[128][8],p2[8][3],wk,flg,k;
	long long dp[101][8];
	scanf("%d %d %d",&h,&w,&k1);
	for(i=0;i<w;i++)	{
		for(j=0;j<3;j++)	p2[i][j]=0;
	}
	if(w==1)	p2[0][1]=1;
	else {
		for(i=0;i<(1<<(w-1));i++)	{
			wk=i;
			for(j=0;j<w-1;j++)	{
				b[j]=wk%2;
				wk=wk/2;
			}
			flg=1;
			for(j=0;j<w-2;j++)	{
				if(b[j]==1 && b[j+1]==1)	{
					flg=0;	break;
				}
			}
			if(flg==1)	{
				if(b[0]==0)	p2[0][1]++;
				else p2[0][2]++;
				if(b[w-2]==0)	p2[w-1][1]++;
				else p2[w-1][0]++;
				for(j=1;j<w-1;j++)	{
					if(b[j-1]==1)	p2[j][0]++;
					else if(b[j]==1)	p2[j][2]++;
					else p2[j][1]++;
				}
			}
		}
	}
	for(i=0;i<=h;i++)	{
		for(j=0;j<w;j++)	dp[i][j]=0;
	}
	dp[0][0]=1;
	for(i=0;i<h;i++)	{
		for(j=0;j<w;j++)	{
			for(k=-1;k<=1;k++)	{
				wk=j+k;
				if(wk>=0 && wk<w)	{
					dp[i+1][wk]+=dp[i][j]*p2[j][k+1];
					dp[i+1][wk]%=MM;
				}
			}
		}
	}
	printf("%lld\n",dp[h][k1-1]);
	return 0;
}

Measured memory_bytes: 128
/* package codechef; // don't place package name! */

import javax.swing.*;
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        long H = s.nextLong();
        long count = 0;
        int i=0;
        while(H>0)
        {
            H/=2;
            count+=Math.pow(2,i);
            i++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21204
N, K = gets.split.map(&:to_i)
sum = 0
if K==0
  sum = N**2
else
  (K+1).upto(N){|b|
    sum += ((N-K)/b+1)*(b-K)
    over = ((N-K)/b)*b+K+(b-K-1)-N
    if over >= 0
      sum -= over
    end
  }
end
puts sum

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

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define VECCIN(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int A, B, C;
    cin >> A >> B >> C;
    if (A == B)cout << C << endl;
    else if (B == C)cout << A << endl;
    else cout << B << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int H, W;
	int n, i, j;
	while(n<1000000){
	scanf("%d %d",&H, &W);
	if(H == 0 && W == 0){
		break;
	}
		for(i=0; i<H; i++){
			for(j=0; j<W; j++){
				if((i+j)%2==0){
					printf("#");
				}
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2044
import sys
N,K=map(int,input().split())
a=list(map(int,input().split()))
def gcd(a,b):
  if a==b:
    return a
  else:
    a,b=max(a,b),min(a,b)
    if a%b==0:
      return b
    else:
      return gcd(b,a%b)
if N==1:
  if K==a[0]:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
  sys.exit()
          
for i in range(N-1):
  if i==0:
    tmp=gcd(a[i],a[i+1])
  else:
    tmp=gcd(tmp,a[i+1])
if tmp==1:
  if K<=max(a):
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
else:
  if K<=max(a):
    if K%tmp==0:
      print('POSSIBLE')
    else:
      print('IMPOSSIBLE')
  else:
    print('IMPOSSIBLE')

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

namespace A___Programming_Education
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
           
            N = int.Parse(Console.ReadLine());
            if (N > 0 && N < 2)
            {
                Console.WriteLine("Hello World");
            }
            else if (N>1&&N<3)
            {
             int A;
             int B;
             A = int.Parse(Console.ReadLine());
             B = int.Parse(Console.ReadLine());
             Console.WriteLine(A + B);
            }
        }
    }
}


Measured memory_bytes: 11092
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }

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

int n, ans, dist[400], degree[400];
vector<vector<edge> > es;

void dfs(int cur = 0, int sum = 0) {
	chmax(dist[cur], sum);

	--degree[cur];
	if(degree[cur])
		return;

	if(cur == n - 1) {
		ans = dist[n - 1];
		return;
	}

	for(int i = 0; i < es[cur].size(); ++i)
		dfs(es[cur][i].to, dist[cur] + es[cur][i].cost);
}

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

	int m;
	cin >> n >> m;

	es.resize(n);
	for(int i = 0; i < m; ++i) {
		int a, b, c;
		cin >> a >> b >> c;

		es[a].push_back(edge(b, c));
		++degree[b];
	}

	degree[0] = 1;
	dfs();
	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1228