akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <cstring>
#include <tuple>
#include <vector>
#include <map>
#include <iterator>
#include <cmath>

using namespace std;
using lint = long long int;


int main() {
	int n;
	cin >> n;

	double *a;
	a = new double[n];

	double sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += 1.0 / a[i];
	}

	cout << 1.0 / sum; 

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    
    if( a < b && b < c)
    {
        cout << "Yes" << endl;
        return 0;
    }
    
    cout << "No" << endl;
    return 0;
}

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

namespace B
{
    class Program
    {
        public struct Rest
        {
            public int index;
            public string city;
            public int point;
        }
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var R = new Rest[n];
            for(int i = 0; i < n; i++)
            {
                string[] In = Console.ReadLine().Split(' ');
                R[i].index = i + 1;
                R[i].city = In[0];
                R[i].point = int.Parse(In[1]);
            }
            var SR=R.OrderBy(x => x.city).ThenByDescending(x => x.point).ToArray();
            for(int i = 0; i < n; i++)
            {
                Console.WriteLine(SR[i].index);
            }
        }
    }
}


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

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

int main(void) {
    int n, ans = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;

    vector<int> v(n), c(n);
    REP(i, n) {
        cin >> v[i];
    }
    REP(i, n) {
        cin >> c[i];
    }
    REP(i, n) {
        if (v[i] > c[i]) {
            ans += v[i] - c[i];
        }
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	a, b, c := readI(), readI(), readI()
	fmt.Println(c, a, b)
}

/*-----------Utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}


Measured memory_bytes: 1780
#include<iostream>

using namespace std;
int main(){
  char ch[2][3];
  for(int i=0;i<2;i++)
      for(int j=0;j<3;j++)
	cin>>ch[i][j];
  if(ch[0][0]==ch[1][2] && ch[0][1]==ch[1][1] && ch[0][2]==ch[1][0])
    cout<<"YES"<<endl;
  else     cout<<"NO"<<endl;
  
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n+1);
  rep(i,n) cin >> a[i];
  int ans = 0;
  rep(i,n) if(i % 2 == 1 && a[i] % 2 == 1) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 3608
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;
    auto B = N.iota.map!(i => tuple(i, A[i])).array;
    B.sort!"a[1] > b[1]";

    auto dp = new long[][](N+1, N+1);

    foreach (i; 0..N) foreach (j; 0..i+1) {
        int k = i - j;
        auto idx = B[i][0];
        long val = B[i][1];
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + abs(idx-j)*val);
        dp[i+1][j] = max(dp[i+1][j], dp[i][j] + abs(N-1-k-idx)*val);
    }

    dp[N].reduce!max.writeln;
}

Measured memory_bytes: 35212
#include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include<cstring>
#include <math.h>
#include <iomanip>
using namespace std;


void insertionSort(int* a,int n)
{
  int v;
  for(int j=0;j<n;j++){
    if(j)cout<<" ";
    cout<<a[j];
  }
  cout<<endl;
  for(int i=1;i<n;i++){
    v=a[i];
    int j=i-1;
    while(j>=0 && a[j]>v){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=v;
    for(int j=0;j<n;j++){
      if(j)cout<<" ";
      cout<<a[j];
    }
    cout<<endl;
  }
}

int main()
{
  int n;
  int a[1000];

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

  insertionSort(a,n);

  return 0;
}



Measured memory_bytes: 3084
#include<iostream>
using namespace std;
int main()
{
	int n=2;
	string s;
    cin>>s;
   for(int i=0;i<n;i++){
          if(s[0]==s[n]){
	     cout<<"Yes";
   			break;
		   }
		   else
		   cout<<"No";
		   	break;
    }
  	  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#define ll long long
#define mem(f, x) memset(f, x, sizeof(f))
#define INF 0x3f3f3f3f
using namespace std;
const int M = 15;
const int N = 10005;
char s1[N], s2[N];
int main( ){
    while( scanf( "%s %s", s1, s2 ) != EOF ){
        int len = strlen( s1 );
        bool flag = 0;
        for( int i = 0; i < len; i++ ){
            if( s1[i] != s2[i] ){
                printf( "No\n" );
                flag = 1;
                break;
            }
        }
        if( !flag )
            printf( "Yes\n" );
    }
    return 0;
}


Measured memory_bytes: 3764
#include<iostream>
using namespace std;
#define L109 1000000000
int main() {
    int A,B,K=0;
    cin >> A >> B;

    if (A==0 || B==0) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    for (; K<L109; K++) {
        if (abs(A-K) == abs(B-K)) break;
    }
    if (K==L109)
        cout << "IMPOSSIBLE" << endl;
    else
        cout << K << endl;
    
    return 0;
}


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

int main()
{
    int a,b;

    cin >> a;
    cin >> b;

    if(a >= 13) {
        cout << b << endl;
    }else if(6 <= a && a <= 12) {
        cout << b/2 << endl;
    }else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(_,a,b) for(int _=a;_<b;_++)
#define per(_,a,b) for(int _=b-1;_>=a;_--)
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;

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


Measured memory_bytes: 3624
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n = I()

        a = [I() for _ in range(n)]
        e = collections.defaultdict(list)
        for i in range(n):
            if a[i] == 0:
                for j in range(1,7):
                    e[i].append((i+j, 1))
            else:
                e[i].append((i+a[i], 0))

        def search(s):
            d = collections.defaultdict(lambda: inf)
            d[s] = 0
            q = []
            heapq.heappush(q, (0, s))
            v = collections.defaultdict(bool)
            while len(q):
                k, u = heapq.heappop(q)
                if v[u]:
                    continue
                v[u] = True
                if u == n-1:
                    return k

                for uv, ud in e[u]:
                    if v[uv]:
                        continue
                    vd = k + ud
                    if d[uv] > vd:
                        d[uv] = vd
                        heapq.heappush(q, (vd, uv))

            return -1

        rr.append(search(0))
        break

    return '\n'.join(map(str, rr))



print(main())



Measured memory_bytes: 72116
operand = ["+", "-", "*"]
src = [x if x in operand else int(x) for x in  input().split(" ")]
stack = []

for s in src:
    if isinstance(s, int):
        stack.append(s)
        continue

    b, a = stack.pop(), stack.pop()

    if s == "+":
       stack.append(a+b)
    elif s == "-":
        stack.append(a-b)
    elif s == "*":
        stack.append(a*b)

print(stack[0])

Measured memory_bytes: 7696
X, K, D = map(int, input().split())

X = abs(X)

if K - (X // D) < 0:
        X -= K * D
        print(X)
else:
        K = K - (X // D)
        X -= D * (X // D)
        if K % 2 == 0:
                print(abs(X))
        else:
                print(abs(X-D))

Measured memory_bytes: 9132
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		
		int ans = Integer.MAX_VALUE;
		for (int i = 0; i <= s.length() - 3; i++) {
			String s2 = s.substring(i, i + 3);
			int n = Integer.valueOf(s2);
			if (ans > Math.abs(753 - n)) {
				ans = Math.abs(753 - n);
			}
		}
		
		System.out.println(ans);
	}
}

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

int main() {
  int n;
  cin >>n;
  vector<bool>a(n,0);
  long long wa=0;
  long long saidai=0;
  for(int i=1;i<=n;i++){
    wa+=i;
    if(wa>n){
      a[wa-n]=1;
      saidai=i;
      break;
    }else if(wa==n){
      saidai=i;
      break;
    }
  }
  for(int i=1;i<=saidai;i++){
    if(a[i]!=1)cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 4584
n = int(input())
a = [int(k) for k in input().split()]
cnt = [0]*(10**5+1)
for i in a:
  cnt[i] += 1
s = cnt[0] + cnt[1] + cnt[2]
ans = 1
for i in range(1,10**5):
  s = cnt[i-1] + cnt[i] + cnt[i+1]
  #print(s)
  ans = max(s,ans)
print(ans)
  

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


int main()
{
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif

    string s;
    cin>>s;
    if(s.length()<6 || s[2]!=s[3] || s[4]!=s[5])cout<<"No";
    else cout<<"Yes";

	return 0;
} 

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
using namespace std;
struct st{int x[4];};
int h, w, k, a[505][505];
int b[250005], c[250005], d[250005],e[250005];
int main() {
	int i, j;
	scanf("%d%d", &h, &w);
	for(i=1; i<=h; i++) for(j=1; j<=w; j++) scanf("%d", &a[i][j]);
	for(i=1; i<=h; i++) {
		for(j=1; j<w; j++) if(a[i][j]%2) {
			a[i][j+1]++, b[k]=i, c[k]=j, d[k]=i, e[k]=j+1, k++;
		}
		if(i<h && a[i][w]%2) {
			a[i+1][j]++, b[k]=i, c[k]=j, d[k]=i+1, e[k]=j, k++;
		}
	}
	printf("%d\n", k);
	for(i=0; i<k; i++) printf("%d %d %d %d\n", b[i], c[i], d[i], e[i]);
	return 0;
}

Measured memory_bytes: 6016
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 100100100100100100
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

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

int main() 
{
    int n,t;
    cin >> n >> t;

    int ans = 100100;

    rep(i,n) {
        int a,b;
        cin >> a >> b;
        if(b<=t) {
            ans = min(a,ans);
        }
    }

    if(ans == 100100) {
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import itertools
H, W, K = map(int, input().split())

c_list = []
for i in range(H):
    c_list.append(str(input()))

case_list = []

for i in range(2 ** (H + W)):
    case_list.append(format(i, "#0" + str(H + W + 2) + "b")[2:])

ans = 0
for i in range(2 ** (H + W)):
#     temp_c_list = c_list.copy()
    counter = 0
    for j in range(H):
        for k in range(W):
            if case_list[i][j] == "0" and case_list[i][H + k] == "0" and c_list[j][k] == "#":
                counter += 1
    if counter == K:
        ans += 1

print(ans)

Measured memory_bytes: 9348
<?php
while (1) {
    list($height, $width) = getSpacesByExplodeTrimInput();
    
    if ($height == 0 && $width == 0) {
        break;
    }
    
    $outputWidth = str_repeat('#', $width).PHP_EOL;
    echo str_repeat($outputWidth, $height).PHP_EOL;
}
  
function getSpacesByExplodeTrimInput()
{
    return explode(' ', trim(fgets(STDIN)));
}

Measured memory_bytes: 15288
n, t = map(int, input().split())
schedule = list(map(int, input().split()))

result = 0
for i, s in enumerate(schedule):
  if (i + 1) > len(schedule) - 1:
    continue
  a = schedule[i + 1] - s
  if a > t:
    a = t
  result += a
result += t

print(result)
  

Measured memory_bytes: 26708
import sys
N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    A[i] -= 1

visited = [1] + [0] * (N-1)
first_dist = [0] * N
turn = 0
pos = 0

for i in range(N+1):
    if i == K:
        print(pos+1)
        sys.exit()
    turn += 1
    pos = A[pos]
    if visited[pos] :
        loop = turn - first_dist[pos]
        break
    else:
        visited[pos] = 1
        first_dist[pos] = turn

loop_path = [pos]
for i in range(loop):
    pos = A[pos]
    loop_path.append(pos)
pos = loop_path.pop()
print(loop_path[(K - first_dist[pos])%loop] + 1)

Measured memory_bytes: 32336
from collections import Counter
n = int(input())
tmp = n
d = []
for i in range(2, int(n ** 0.5) + 1):
    if tmp % i == 0:
        while tmp % i == 0:
            d.append(i)
            tmp //= i
if tmp != 1:
    d.append(tmp)

dv = Counter(d)

cnt = 0
for p in dv.keys():
    for e in range(1, dv[p]+1):
        z = p ** e
        if n % z == 0:
            cnt += 1
            n //= z

print(cnt)


Measured memory_bytes: 9724
import sys


def main():

    N = int(sys.stdin.readline().rstrip())
    A = [int(x) for x in sys.stdin.readline().rstrip().split()]

    ans = 0
    for i in range(N):
        if (i + 1) % 2 == 1 and A[i] % 2 == 1:
            ans += 1

    print(ans)


main()


Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
void fail() { puts("IMPOSSIBLE"); exit(0); }
// const int INF  = 1<<30;
// const ll INFll = 1ll<<62;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;




int main() {
  int n; cin >> n;
  VV G(n);
  rep2(i, 1, n) {
    int u; cin >> u;
    --u;
    G[u].push_back(i);
  }
  V x(n); cin >> x;


  auto dfs = [&] (auto &&self, int u) -> P {
    bitset<5001> dp;
    dp[0] = 1;
    int sum = 0;
    for (int v : G[u]) {
      auto [a, b] = self(self, v);
      dp = dp<<a | dp<<b;
      sum += a + b;
    }
    int c = -1;
    drep(i, x[u]+1) if (dp[i]) {
      c = i;
      break;
    }
    if (c == -1) fail();
    return P{x[u], sum - c};
  };

  dfs(dfs, 0);
  cout << "POSSIBLE\n";
  return 0;
}


Measured memory_bytes: 4696
package main

import (
	"fmt"
)

const n = 7

var (
	b2i = map[bool]int{false: 0, true: 1}
	seq = []int{}
	flg bool
)

func dfs(left, i int, ops []bool) {
	if i == len(seq) {
		if left == 0 && !flg {
			for i := range seq {
				if i != 0 {
					fmt.Print([...]string{"-", "+"}[b2i[ops[i]]])
				}
				fmt.Print(seq[i])
			}
			fmt.Printf("=%d\n", n)
			flg = true
		}
		return
	}
	dfs(left-seq[i], i+1, append(ops, true))
	if i != 0 {
		dfs(left+seq[i], i+1, append(ops, false))
	}
}

func main() {
	var abcd string
	fmt.Scan(&abcd)

	for _, c := range abcd {
		seq = append(seq, int(c)-'0')
	}
	dfs(n, 0, []bool{})
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N;
int h[100010];
int dp[100010];

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

  cin >> N;
  REP(i,N) cin >> h[i];
  MINF(dp);
  dp[0] = 0;
  for (int i = 1; i < N; i++) {
    if (i-1 >= 0) CHMIN(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
    if (i-2 >= 0) CHMIN(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout << dp[N-1] << endl;

  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>

using namespace std;

int main(){
  int distance, angle, _angle=0;
  double x=0, y=0, radian;
  char c;

  while(1){
    cin >> distance >> c >> angle;
    if(distance == 0 && angle == 0) break;

    radian = _angle * M_PI / 180;
    _angle += angle;

    x += distance * sin(radian);
    y += distance * cos(radian);
  }

  cout << (int)x << endl;
  cout << (int)y << endl;
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <math.h>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

int main()
{
	int x;
	cin >> x;

	if (x < 1200)
	{
		cout << "ABC" << endl;
	}
	else
	{
		cout << "ARC" << endl;
	}
}


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

int main() {
  int h, w, n; cin >> h >> w >> n;
  bool ok = true;

  int sr, sc; cin >> sr >> sc;
  string s, t; cin >> s >> t;
  int ss[4], tt[4]; fill(ss, ss+4, 0); fill(tt, tt+4, 0);

  for(int i=0; i<n && ok; i++) {
    switch (s[i]) {
      case 'L': ss[0]++; break;
      case 'R': ss[1]++; break;
      case 'U': ss[2]++; break;
      case 'D': ss[3]++; break;
    }
    //for(int x:ss) cout << x << " "; cout << endl;
    
    int s1 = sc + tt[1] - ss[0], // attempt to go lef
    s2 = sc - tt[0] + ss[1], // r
    s3 = sr + tt[3] - ss[2], // u
    s4 = sr - tt[2] + ss[3]; // d

    if (s1 < 1 || s2 > w ||  s3 < 1 || s4 > h) {
      //cout << i << endl;
      /*
      cout << (s1 < 1) << " "\
        << (s2 > w) << " "\
        << (s3 < 1) << " "\
        << (s4 > h) << " "\
        << endl;*/
      ok = false;
    }
    
    switch (t[i]) {
      case 'L': if (s2-1 >=1) tt[0]++; break;
      case 'R': if (s1+1 <=w) tt[1]++; break;
      case 'U': if (s4-1 >=1) tt[2]++; break;
      case 'D': if (s3+1 <=h) tt[3]++; break;
    }
    //for(int x:tt) cout << x << " "; cout << endl;
  }
  cout << (ok?"YES":"NO") << endl;
}

Measured memory_bytes: 776
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int black = 0;
  int white = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == '#')
      black++;
    else
      white++;
  }
  debug(black, white);
  int left_black = 0;
  int left_white = 0;
  int ans = min(black, white);
  for (int i = 0; i < N; i++) {
    if (i != 0) {
      if (S[i - 1] == '.' && S[i] == '#') {
        int tmp = left_black + (white - left_white);
        debug(left_black, left_white, tmp);
        ans = min(ans, tmp);
      }
    }
    if (S[i] == '#')
      left_black++;
    else
      left_white++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int toStr(long long x){
  string str;
  str=to_string(x);
  return str.size();
}
int main(){
  int ans=0;
  long long N;
  cin >> N;  
  for(long long i=1 ; i<=sqrt(N) ; i++)
    if(N%i==0)
      ans=max(toStr(i), toStr(N/i));  
  cout << ans;
}

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

const int mod = 1000000007;
int n, m, sa[1000010], sb[1000010];
long long ans = 1;
bool a[1000010], b[1000010];

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++)
    {
        int x;
        scanf("%d", &x);
        if (a[x])
        {
            puts("0");
            return 0;
        }
        a[x] = 1;
    }
    for (int i = 1; i <= m; i++)
    {
        int x;
        scanf("%d", &x);
        if (b[x])
        {
            puts("0");
            return 0;
        }
        b[x] = 1;
    }
    for (int i = n * m; i > 0; i--)
    {
        sa[i] = sa[i + 1] + a[i];
        sb[i] = sb[i + 1] + b[i];
    }
    for (int i = 1; i <= n * m; i++)
    {
        if (a[i] && b[i])
            continue;
        else if (a[i])
        {
            ans = ans * sb[i] % mod;
        }
        else if (b[i])
        {
            ans = ans * sa[i] % mod;
        }
        else
        {
            ans = ans * ((sa[i] * sb[i] - n * m + i) % mod) % mod;
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 8064
<?php

    list($V,$E)=array_map('intval',explode(" ",trim(fgets(STDIN))));
    //無限を作る
    $inf=10**10;
    //連結表をとりあえず無限で埋める
    for($i=0;$i<$V;$i++){
        for($j=0;$j<$V;$j++){
            $TD[$i][$j]=INF;
            $DT[$i][$j]=INF;
        }
    }
    //有効グラフのデータを標準入力から取り込む
    while($array = trim(fgets(STDIN))){
        list($S,$T,$D) = array_map('intval',explode(" ",$array));
        $TD[$S][$T] = $D;
    }
    //同じ頂点から同じ頂点へ動くときは距離は当然0となる。
    for($i=0;$i<$V;$i++){
        $TD[$i][$i] = 0;
    }
    for($x=0;$x<$V;$x++){
        for($y=0;$y<$V;$y++){
            for($z=0;$z<$V;$z++){
                $TD[$y][$z] = min($TD[$y][$z],$TD[$y][$x]+$TD[$x][$z]);
            }
        }
    }
    //頂点地震から頂点自身の経路が負の場合は負の経路が存在する。
    for($i=0;$i<$V;$i++){
        if($TD[$i][$i]<0){
          echo "NEGATIVE CYCLE\n";
          exit;
        }
    }
    for($i=0;$i<$V;$i++){
        for($j=0;$j<$V;$j++){
            if($TD[$i][$j]==10**10){
                echo "INF";
            }else{
                echo $TD[$i][$j];
            }
            if($j==$V-1){
                
            }else{
                echo " ";
            }
        }
            echo "\n";
    }
?>


Measured memory_bytes: 12300
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var k = int.Parse(Console.ReadLine());
        var x = int.Parse(Console.ReadLine());
        var y = int.Parse(Console.ReadLine());

        Console.Write(n <= k ? n * x : k * x + (n - k) * y);

    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

struct union_find{
    vector<ll> parent;
    vector<ll> nums;
    union_find(ll n){
        parent.resize(n);
        nums.resize(n, 1LL);
        rep(i, 0, n) parent[i] = i;
    }

    ll root(ll x){
        if(parent[x] == x) return x;
        parent[x] = root(parent[x]);
        return parent[x];
    }

    void unite(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx != ry){
            parent[rx] = ry;
            nums[ry] += nums[rx];
        }
    }

    bool same(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx == ry) return true;
        return false;
    }

    ll size(ll x){
        return nums[root(x)];
    }
};  

int main(){
    ll N, M;
    cin >> N >> M;
    VL A(M), B(M);
    rep(i, 0, M){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        A[i] = a;
        B[i] = b;
    }
    ll ans = 0;
    rep(m, 0, M){
        union_find T(N);
        rep(i, 0, M){
            if(i == m) continue;
            T.unite(A[i], B[i]);
        }
        if(T.root(A[m]) != T.root(B[m])) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int N, A, B;
int main() {
	cin >> N >> A >> B;
	cout << ((B - A) & 1 ? "Borys" : "Alice") << endl;
	return 0;
}

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

//  めぐる式二分探索

ll n, a, b;
vll h;

bool isOK(ll index) {
  ll tmp = 0;
  rep(i, n) {
    if (0 < h[i] - b * index)
      tmp += (h[i] - b * index + (a - b) - 1) / (a - b);
  }
  if (tmp <= index) return true;
  else return false;
}

ll binary_search(void){
  ll ng = -1, ok = 1e9;
  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if(isOK(mid)) ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin >> n >> a >> b;
  h = vll(n);
  rep(i, n) cin >> h[i];
  cout << binary_search() << endl;
  return 0;
}

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

int main()
{
	int N;
	cin >> N;
	priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> p;
	for (int i = 0; i < N; ++i)
	{
		int A, B;
		cin >> A >> B;
		p.push({B, A});
	}
	
	int time = 0;
	while (!p.empty())
	{
		auto job = p.top();
		p.pop();
		int due = job.first;
		time += job.second;
		if (time > due)
		{
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}


Measured memory_bytes: 2420
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
vector<string> s;
map<string,ll> as;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    s.resize(n);
    rep(i,n){
        cin>>s[i];
        as[s[i]]++;
    }
    sort(all(s));
    string pre="";
    vector<pair<ll,string>> v,ans;
    rep(i,n){
        if(pre==s[i])continue;
        pre = s[i];
        v.pb(mp(as[pre],pre));
    }
    Sort(v);
    ll max = 0;
    rep(i,v.size()){
        if(v[i].first<max)continue;
        ans.pb(v[i]);
        chmax(max,v[i].first);
    }
    sort(all(ans));
    rep(i,ans.size()){
        print(ans[i].second);
    }
    return 0;
}

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

int main() {
  int n, k, bad = 1;
  cin >> n >> k;
  
  if((n - 1) * (n - 2) / 2 < k){
    cout << -1 << endl;
    bad = 0;
  }
  
  if(bad){
    int m = n * (n - 1) / 2 - k, i, j, out = 0;
    cout << m << endl;
    
    for(i = 2; i <= n; i++){
      cout << 1 << " " << i << endl;
    }
    
    m -= n - 1;
    
    for(i = 2; i <= n - 1; i++){
      for(j = i + 1; j <= n; j++){
        if(m > 0){
          cout << i << " " << j << endl;
          m--;
        }
        else{
          out = 1;
          break;
        }
      }
      if(out) break;
    }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] f = new int [4];
		for(int i=0;i<n;i++) {
			String a = sc.next();
			if(a.equals("P"))f[0]=1;
			if(a.equals("W"))f[1]=1;
			if(a.equals("G"))f[2]=1;
			if(a.equals("Y"))f[3]=1;
		}
		sc.close();
		int cnt = 0;
		for(int i=0;i<4;i++)cnt += f[i];
		System.out.println(cnt==3?"Three":"Four");
	}
}



Measured memory_bytes: 23764
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
n, m  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

q = 2 ** m
#print(n, m, 3800 * q, (n - m) * q)
print((1900 * m) * q + 100 * (n - m) * q)


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

#define N 4
#define N2 16
#define LIMIT 80

typedef struct {
  int b[N2+1];
} Board;
Board board;
int minstep;
typedef enum { R, U, L, D } Direction;
typedef struct { int pos; Direction dir; } Motion;

//  0  1  2  3
//  4  5  6  7
//  8  9 10 11
// 12 13 14 15
 
const Motion motion[N2][5] =
  {{{1,L},{4,U},{-1}}, {{0,R},{2,L},{5,U},{-1}}, {{1,R},{3,L},{6,U},{-1}},{{2,R},{7,U},{-1}},
   {{0,D},{5,L},{8,U},{-1}}, {{1,D},{6,L},{9,U},{4,R},{-1}},  {{2,D},{7,L},{10,U},{5,R},{-1}}, {{3,D},{11,U},{6,R},{-1}},
   {{4,D},{9,L},{12,U},{-1}}, {{5,D},{10,L},{13,U},{8,R},{-1}},  {{6,D},{11,L},{14,U},{9,R},{-1}}, {{7,D},{15,U},{10,R},{-1}},
   {{8,D},{13,L},{-1}}, {{9,D},{14,L},{12,R},{-1}}, {{10,D},{15,L},{13,R},{-1}},{{11,D},{14,R},{-1}}};

const int rr[4][5] = {{0,0,1,0,0},{0,0,0,1,0},{1,0,0,0,0},{0,1,0,0,0}};

int dd[N2][N2];
int dist(int *b)
{
  int i, n, d = 0;
  for (i=0; i<N2; i++) {
    n = b[i]-1;
    if (n<0) {
      continue;
    }
    d += dd[n][i];
  }
  return d;
}

void search(int step, Motion prev)
{
  int i, d=0;
  d = dist(board.b);
  if (step+d>minstep) return;
  if (d==0) {
    printf("%d\n", step);
    exit(0);
  }
  Board board_bak = board;
  for (i=0; motion[prev.pos][i].pos>=0; i++) {
    Motion m = motion[prev.pos][i];
    if (rr[m.dir][prev.dir]) continue; //元に戻るのを防止
    board.b[prev.pos] = board.b[m.pos];
    board.b[m.pos] = 0;
    search(step+1, m);
    board = board_bak;
  }
}

int main()
{
  int i, j;
  for (i=0; i<N2; i++)
    for (j=0; j<N2; j++)
      dd[i][j] = abs(i%N-j%N) + abs(i/N-j/N);
  
  Board ini_board;
  fscanf(stdin, "%d %d %d %d\n", &ini_board.b[0],&ini_board.b[1],&ini_board.b[2],&ini_board.b[3]);
  fscanf(stdin, "%d %d %d %d\n", &ini_board.b[4],&ini_board.b[5],&ini_board.b[6],&ini_board.b[7]);
  fscanf(stdin, "%d %d %d %d\n", &ini_board.b[8],&ini_board.b[9],&ini_board.b[10],&ini_board.b[11]);
  fscanf(stdin, "%d %d %d %d\n", &ini_board.b[12],&ini_board.b[13],&ini_board.b[14],&ini_board.b[15]);
  
  ini_board.b[N2]=0;

  Motion m;
  m.dir = 4;
  for (i=0; i<N2; i++)
    if (ini_board.b[i]==0) {
      m.pos = i;
      break;
    }

  for (minstep=dist(ini_board.b); minstep<=LIMIT; minstep++) {
    board = ini_board;
    search(0, m);
  }
  puts("no result.");
  return 0;
}



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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define mod 998244353

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll power(ll x, ll y, ll p = MOD){  
  ll res = 1LL; 
  x = x % p;
  if (x == 0) return 0;
  while (y > 0){
    if (y & 1LL)  
      res = (res*x) % p;
    y = y>>1LL; 
    x = (x*x) % p;  
  }  
  return res;  
}  

int main(){
	// IO
	int n, k;
	cin >> n >> k;
	vector<pii> ranges;
	int l, r;
	rep(i, 0, k) {
		cin >> l >> r;
		ranges.push_back({l, r});
	}	

	vll dp(n + 1, 0LL), xx(n + 1, 0LL);

	dp[1] = 1LL;
	xx[1] = 1LL;

	for(int i = 2; i <= n; ++i) {
		for(auto range: ranges) {
			if(range.first <= i) {
				int R = i - range.first, L = i - min(range.second, i - 1);
				dp[i] = (dp[i]%mod + (xx[R] - xx[L - 1] + mod)%mod)%mod;
			}
		}
		xx[i] = (dp[i] +  xx[i - 1])%mod;
	}
	
	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 6424
use std::collections::HashSet;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        r: usize,
        g: usize,
        b: usize,
        n: usize
    }
    let mut vs = vec![r, g, b];
    vs.sort();
    let (b, g, r) = (vs[0], vs[1], vs[2]);
    let mut ns = HashSet::new();
    ns.insert(n);
    for i in 0 .. n / r {
        ns.insert(n - r * (i +1));
    }
    let mut cnt = 0;
    for gg in (0..(n / g) + 1).rev() {
        let gk = gg * g;
        let n_g = n - gk;
        for bb in (0..(n_g / b) + 1).rev() {
            let bk = bb * b;
            if ns.contains(&(gk + bk)) {
                cnt += 1;
            }
        }
    }
    // let mut cnt = 0;
    // for rr in (0..(n / r) + 1).rev() {
    //     let rk = rr * r;
    //     let n_r = n - rk;
    //     for gg in (0..(n_r / g) + 1).rev() {
    //         let gk = gg * g;
    //         let n_r_g = n_r - gk;
    //         for bb in (0..(n_r_g / b) + 1).rev() {
    //             let bk = bb * b;
    //             if rk + gk + bk == n {
    //                 cnt += 1;
    //             }
    //         }
    //     }
    // }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

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

	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}

	ll lo = 1;
	ll hi = MOD;
	while(lo<hi){
		ll mid = (lo+hi)/2;
		ll cnt = 0;
		for(int i=0;i<n;i++)
			cnt += (a[i]-1)/mid;

		if(cnt <= k)
			hi = mid;
		else
			lo = mid+1;
	}

	cout<<lo<<"\n";
}

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

int main() { 
    int N;
    cin >> N;
    uint64_t ans = 1;
    vector<string> a(N);
    rep(i, N) cin >> a[i];

    rep(i, N) {
        if (a[i] == "0") {
            ans = 0;
            cout << ans << endl;
            return 0;
        }
    }
    rep(i, N) {
        if (a[i].size() > 18 && a[i] != "1000000000000000000") {
            cout << "-1" << endl;
            return 0;
        }
    }

    rep(i, N)
    {
        if (to_string(ans).size() + a[i].size() >= 20 && !(ans == 1000000000 && a[i] == "1000000000")) {
            cout << "-1" << endl;
            return 0;
        }
        ans *= stoull(a[i]);
    }
    if (ans > 1000000000000000000ULL){
        cout << "-1" << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int s1s2s3;
  cin>>s1s2s3;
  int e;
  int f;
  int g;
  e=s1s2s3/100;
  f=((s1s2s3)/10)-e*10;
  g=s1s2s3-e*100-f*10;
  int h;
  h=e+f+g;
  cout<<h<<endl;
  
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;

int main(){
    int N, K; cin >> N >> K;
    vector<ll> V(N); for(int i = 0; i < N; i++) cin >> V[i];
    sort(V.rbegin(), V.rend());
    ll ans = 1e9;
    for(int i = 0; i < N; i++){
        if(K-1+i == N) break;
        ans = min(V[i]- V[K-1+i], ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
def solve():
    seq1 = raw_input()
    seq2 = raw_input()
 
    x, y = len(seq1), len(seq2)
    a1 = [0 for i in range(y+1)]
    for i in range(x):
        e1 = seq1[i]
        a2 = a1+[]
        for j in range(y):
            if e1 == seq2[j]:
                a1[j+1] = a2[j] + 1
            elif a1[j+1] < a1[j]:
                a1[j+1] = a1[j]
    return a1[-1]
 
n = input()
for i2 in range(n):
    print solve()

Measured memory_bytes: 6512
//*******************************By Harry Singh From Phillaur.
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000006
#define MOD 1000000009
#define string_to_any_base(s,base) stoll(s, 0, base);
#define vc vector
// #define mp map<ll,ll> mp;
#define bt(M,value) bitset<M> b(value)
#define S set<ll> s;
#define ST set<string> s;
#define INF 1e15
using namespace std;
set<ll> primes;
vector<pair<ll,ll>> adj[MAX];
vector<ll> ad[MAX];
///******************************ALL important functions;
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b);} 
ll lcm(ll a, ll b)  {  return (a*b)/gcd(a, b);  } 
ll power(ll x,ll y){ ll res = 1;x = x % MOD; if (x == 0) return 0;while (y > 0){if (y & 1)  res = ((res%MOD)*(x%MOD)) % MOD;  y = y>>1; x = ((x%MOD)*(x%MOD)) % MOD;  }  return res;  }  
void Sieve(){ bool prime[MAX+1]; memset(prime, true, sizeof(prime)); for (int p=2; p*p<=MAX; p++) { if (prime[p] == true) {for (int i=p*p; i<=MAX; i += p) prime[i] = false; } } for(int i=2;i<=MAX;i++)if(prime[i]==true)primes.insert(i);} 

int main()
{
ll n;cin>>n;
ll a[n+1];
map<ll,ll> mp;
ll pre[200006]={0};
for(int i=1;i<=n;i++){cin>>a[i];}
ll count=0;
mp[0]=1;
ll sum=0;
for(int i=1;i<=n;i++)
{
sum+=a[i];
count+=mp[sum];
mp[sum]++;
	
}
cout<<count<<endl;






}

Measured memory_bytes: 61312
import statistics
n = int(input())
a_list = list(map(int, input().split()))

pro_list = [a_list[i-1] - i for i in range(1, n+1)]
ave = int(statistics.mean(pro_list))
med = int(statistics.median(pro_list))
b_list = [ave - 1 for i in range(10)] + [ave + i for i in range(10)]
b_list += [med - 1 for i in range(10)] + [med + i for i in range(10)]

ans = [sum([abs(pro-b)for pro in pro_list]) for b in b_list]
print(min(ans))

Measured memory_bytes: 29748
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;


//探索関数
Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key){
    return u;
  }
  if(k < u->key){
    return treeSearch(u->left, k);
  }
  else{
    return treeSearch(u->right, k);
  }
}


//データ削除関数
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

}

//データ挿入関数
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;//親を設定
    if(z->key < x->key){
      x = x->left;//左の子へ移動
    }
    else{
      x = x->right;//右の子へ移動
    }
  }
  z->parent = y;

  if(y == NIL){//Tが空の場合
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;//zをyの左の子にする
  }
  else{
    y->right = z;//zをyの右の子にする
  }
}

//データ出力関数（中間順巡回）
void inorder(Node u){
  if(u == NIL){
    return;
  }
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right); 
}

//データ出力関数（先行順巡回）
void preorder(Node u){
  if(u == NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    //この後の操作を入力
    scanf("%s", com);
    //探索
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    //データの挿入
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    //データの出力（2パターン）
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}



Measured memory_bytes: 20456
#include <iostream>
#include <queue>
#include <tuple>
#include <functional>

using namespace std;

typedef tuple<int, int> Node;

class MyCmp
{
public:
  bool operator() ( const Node &lhs, const Node &rhs ) const
  {
	return get<1>( lhs ) > get<1>( rhs );
  }
};

int dijkstra( const int from, const int to, const vector<vector<Node>> &table )
{
  priority_queue<Node, vector<Node>, MyCmp> pq;
  vector<bool> visited( table.size() + 1, false );
  pq.push( Node( from, 0 ) );
  
  while ( not pq.empty() )
  {
	const Node n = pq.top();
	const int t = get<0>( n );
	const int cost = get<1>( n );
	pq.pop();
	if ( not visited[ t ] )
	{
	  visited[ t ] = true;
	  if ( t == to )
	  {
		return cost;
	  }
	  else
	  {
		for ( const auto v : table[ t ] )
		{
		  pq.push( Node( get<0>( v ), cost + get<1>( v ) ) );
		}
	  }
	}
  }
  return -1;
}

int main()
{
  while ( true )
  {
	int n, k;
	cin >> n >> k;
	vector<vector<Node>> table( n + 1 );
	if ( n == 0 and k == 0 ) break;
	
	for ( int i = 0; i < k; i++ )
	{
	  int a, from, to;
	  cin >> a >> from >> to;
	  if ( a == 0 )
	  {
		cout << dijkstra( from, to, table ) << endl;
	  }
	  else // if ( a == 1 )
	  {
		int cost;
		cin >> cost;
		table[ from ].push_back( Node( to, cost ) );
		table[ to ].push_back( Node( from, cost ) );
	  }
	}
  }  
}

Measured memory_bytes: 1260