akhauriyash/Code-Regression huggingface dataset:
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#define lFF long double 

int main()
{
 double PI = acos(-1); 
 
 int A , B , H , M ;
 scanf("%d %d %d %d",&A,&B,&H,&M);
 
 double MinuteGrad = M * 6 ;
 
 double HourGrad = H * 30 + (double)((M*30))/60;

 double Angle = 360 - (HourGrad - MinuteGrad);
 double Ang  = (Angle * PI )/ 180;
 

 double AlKashi = sqrt(pow(A,2) + pow(B,2)- (2*A*B)*cos(Ang));
 
 printf("%.11lf",AlKashi); 
 
 
  return 0;
}
 



Measured memory_bytes: 2592
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String today = sc.next();
        ArrayList l = new ArrayList(7);
        l.add("SAT");
        l.add("FRI");
        l.add("THU");
        l.add("WED");
        l.add("TUE");
        l.add("MON");
        l.add("SUN");
        System.out.println(l.indexOf(today)+1);
    }
}

Measured memory_bytes: 22356
package main

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

func Solve(stdin io.Reader, stdout io.Writer) {
	sc := bufio.NewScanner(stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	// a_i = 1/2(x_i + x_(i+1))

	// n = 5のとき
	// sumEvens = [0, a_0, a_0 + a_2, a_0 + a_2 + a_4]
	// sumOdds  = [0, a_1, a_1 + a_3]
	// sum = a_0 + a_1 + ... + a_4 = sumEvens[3] + sumOdds[2] = sumEvens[5/2+1] + sumOdds[5/2]
	sumEvens := make([]int, n/2+2)
	sumOdds := make([]int, n/2+1)
	// それぞれの0番目は番兵
	sumEvens[0] = 0
	sumOdds[0] = 0

	for i := 0; i < n; i++ {
		sc.Scan()
		a, err := strconv.Atoi(sc.Text())
		if err != nil {
			panic(err)
		}

		// 偶奇で分けて累積和を取る
		if i%2 == 0 {
			sumEvens[i/2+1] = sumEvens[i/2] + a
		} else {
			sumOdds[i/2+1] = sumOdds[i/2] + a
		}
	}

	sum := sumEvens[n/2+1] + sumOdds[n/2]

	for i := 0; i < n; i++ {
		if i%2 == 1 {
			others := 2 * (sumOdds[i/2] + sumEvens[n/2+1] - sumEvens[i/2+1])
			_, _ = fmt.Fprintf(stdout, "%d ", sum-others)
		} else if i != n-1 {
			others := 2 * (sumEvens[i/2] + sumOdds[n/2] - sumOdds[i/2])
			_, _ = fmt.Fprintf(stdout, "%d ", sum-others)
		} else {
			// 出力のために場合分け
			// i = n - 1, iは偶数なので n/2 = i/2
			// そのため sumOdds[n/2] - sumOdds[i/2] = 0
			// others := 2 * (sumEvens[i/2] + sumOdds[n/2] - sumOdds[i/2])
			others := 2 * sumEvens[i/2]
			_, _ = fmt.Fprintf(stdout, "%d\n", sum-others)
		}
	}

	return
}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};


using Graph = vector<vector<int>>;


Graph G(1000010);
vector<int> val(1000010);

void dfs(int nord, int p = -1) {
//    cout << nord << endl;
    for(auto itr : G[nord]) {
	if(itr == p) continue;
	val[itr] += val[nord];
	dfs(itr,nord); 
    }
}


int main(){
    int N,Q;
    cin >> N >> Q;
    G.resize(N);
    val.resize(N);
    rep(i,N-1) {
	int a,b;
	cin >> a >> b;
	a--;b--;
	G[a].push_back(b);
	G[b].push_back(a);
    }
    rep(i,Q) {
	int p,x;
	cin >> p >> x;
	p--;
	val[p] += x;
    }



    dfs(0);

    rep(i,N) {
	cout << val[i] << " ";
    }
    cout << endl;
    
    return 0;
}



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

int main() {
  std::string s, t;
  std::cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < 3; ++i) {
    if (s[i] == t[i]) ++ans;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for i in range(N+1)]

def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i-1], t[i] = t[i], t[i-1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True

def dfs(cur, last3):
    # print((cur, last3))
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in 'ACGT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret

print(dfs(0, 'TTT'))


Measured memory_bytes: 3872
N,M = map(int,input().split())
l = [None]*N
for i in range(N):
    x,y,z = map(int,input().split())
    l[i] = (x,y,z)
ans = 0
for i in range(4):
    x,y,z = 0,0,0
    if i==0:
        l.sort(key=lambda x:x[0]+x[1]+x[2])
    elif i==1:
        l.sort(key=lambda x:x[0]+x[1]-x[2])
    elif i==2:
        l.sort(key=lambda x:x[0]-x[1]+x[2])
    else:
        l.sort(key=lambda x:x[0]-x[1]-x[2])
    for i in range(M):
        x += l[i][0]
        y += l[i][1]
        z += l[i][2]
    ans = max(abs(x)+abs(y)+abs(z),ans)
    l.reverse()
    x,y,z = 0,0,0
    for i in range(M):
        x += l[i][0]
        y += l[i][1]
        z += l[i][2]
    ans = max(abs(x)+abs(y)+abs(z),ans)
print(ans)


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

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  string S;
  cin >> S;
  if(S == "AAA" || S == "BBB")
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  int x[] = new int[3000];
  int y[] = new int[3000];

for(int i = 0;i<3000;i++){
  x[i] = sc.nextInt();
  y[i] = sc.nextInt();

  if((x[i] == 0) && (y[i]==0)) break;

  if(x[i] > y[i]){
    System.out.println(y[i]+" "+x[i]);
} else /*if(x[i]<y[i])*/{
  System.out.println(x[i]+" "+y[i]);
}
}

}

}


Measured memory_bytes: 36060
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _005_A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string x = Read();
            int tCnt = 0;
            int sCnt = 0;
            for(int i = x.Length - 1; i >= 0; i--)
            {
                if (x[i] == 'T') tCnt++;
                else if (tCnt>0)
                {
                    sCnt++;
                    tCnt--;
                }
            }
            Console.WriteLine(x.Length - sCnt * 2);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int main()
{
    string s,t,u;
    int a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(s==u)cout<<a-1<<" "<<b<<endl;
    else if(u==t) cout<<a<<" "<<b-1<<endl;
    else if(s==u && s==t)cout<<a-1<<" "<<b-1<<endl;

    return 0;
}


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

int main() {
  int N, i, x=1;
  cin >> N;
  vector<int> mochi(N);
  for(i=0; i<N; i++){
    cin >> mochi.at(i);
  }
  sort(mochi.begin(), mochi.end());
  for(i=0; i<N-1; i++){
    if(mochi.at(i) < mochi.at(i+1)) x++;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std; 
 
inline void solve(){ 
    int x1,y1,x2,y2; 
    cin>>x1>>y1>>x2>>y2;
    int r=x2-x1,u=y2-y1,l=r,d=u;
    for (int i=0;i<r;i++) cout << 'R';
    for (int i=0;i<u;i++) cout << 'U';
    for (int i=0;i<l;i++) cout << 'L';
    for (int i=0;i<d;i++) cout << 'D';
    cout << 'D';
    for (int i=0;i<=r;i++) cout << 'R';
    for (int i=0;i<=u;i++) cout << 'U';
    cout << 'L';
    cout << 'U';
    for (int i=0;i<=l;i++) cout << 'L';
    for (int i=0;i<=d;i++) cout << 'D';
    cout << 'R' << endl;

}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

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

  int dice[N][2];
  int count=0;
  for(int i=0; i<N ;i++){
    cin>>dice[i][0]>>dice[i][1];

    if(dice[i][0]==dice[i][1]){
      count++;
    }else if(count<=2){
      count=0;
    }

  }

  if(count>=3){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;

}


Measured memory_bytes: 3096
S = input()
N = len(S)
n_1 = (N - 1) // 2
n_2 = (N + 3) // 2

s_1 = S[:n_1]
s_2 = S[n_2 - 1:]

ans = "Yes"

for i in range(len(S)):
    if S[i] != S[-i - 1]:
        ans = "No"

for i in range(len(s_1)):
    if s_1[i] != s_1[-i - 1]:
        ans = "No"

for i in range(len(s_2)):
    if s_2[i] != s_2[-i - 1]:
        ans = "No"

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
string s;
vector<int> x(2);
vector<vector<int> > vec(2);
 
int main()
{
    cin >> s;
    cin >> x[0] >> x[1];
    int mode = 0;
    int len = 0;
    vec[1].push_back(0);
    for (auto c : s)
    {
        if (c == 'F')
        {
            len++;
        }
        else
        {
            vec[mode].push_back(len);
            len = 0;
            mode = 1 - mode;
        }
    }
    vec[mode].push_back(len);
    
    for (int dim=0; dim<2; dim++)
    {
        vector<bool> dp_now(32001, false);
        dp_now[16000] = true;
        for (int i=0; i<vec[dim].size(); i++)
        {
            vector<bool> dp_next = vector<bool>(32001, false);
            if (i==0) dp_next[16000+vec[dim][0]] = true;
            else
            {
                for (int j=8000; j<=24000; j++)
                {
                    if (dp_now[j-vec[dim][i]] || dp_now[j+vec[dim][i]]) dp_next[j] = true;
                }
            }
            dp_now = dp_next;
        }
        if (!dp_now[16000+x[dim]])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import { readFileSync } from 'fs'

const mapWithPrev = <T, U>(list: T[], fn: (prev: U, value: T) => U, init: U) => {
  const result = [] as U[]
  let prev = init
  for (const value of list) {
    result.push(prev = fn(prev, value))
  }
  return result
}

const zip = <T>(a: T[], b: T[]) =>
  a.map((v, i) => [v, b[i]] as [T, T])

function main(input: string) {
  const [[N], list] = input.split('\n').map(v => v.split(' ').map(Number))

  const left = mapWithPrev(list, (prev, value) => prev + value, 0)
  const sum = left[N - 1]
  const right = mapWithPrev(list, (prev, value) => prev - value, sum)

  const diffList = zip(left, right).map(([a, b]) => Math.abs(a - b))
  const result = Math.min(...diffList)

  console.log(result)
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 7372
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int dy[] = {0, 1, -1, 0};
int dx[] = {-1, 0, 0, 1};

int main()
{
    int h, w;
    cin >> w >> h;
    vector<string> s(h);
    for(int i=0; i<h; ++i)
        cin >> s[i];

    int n;
    cin >> n;
    vector<vector<int> > open(h, vector<int>(w, -1));
    for(int i=0; i<n; ++i){
        int x, y;
        cin >> x >> y;
        open[y][x] = i+1;
    }

    vector<vector<bool> > check(h, vector<bool>(w, false));
    check[0][0] = true;
    vector<queue<pair<int, int> > > q(n+1);
    q[0].push(make_pair(0, 0));

    for(int i=0; i<=n; ++i){
        while(!q[i].empty()){
            int y0 = q[i].front().first;
            int x0 = q[i].front().second;
            q[i].pop();

            if(s[y0][x0] == 't'){
                cout << i << endl;
                return 0;
            }

            for(int j=0; j<4; ++j){
                int t = i;
                int y = y0 + dy[j];
                int x = x0 + dx[j];
                if(y < 0 || y >= h || x < 0 || x >= w || check[y][x])
                    continue;
                if(s[y][x] == '#'){
                    if(open[y][x] == -1)
                        continue;
                    t = max(t, open[y][x]);
                }
                check[y][x] = true;
                q[t].push(make_pair(y, x));
            }
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 7076
# ABC131D - Megalomania
from itertools import accumulate as acc
from operator import itemgetter as gt


def main():
    N, *AB = map(int, open(0).read().split())
    T, D = zip(*sorted([(i, j) for i, j in zip(*[iter(AB)] * 2)], key=gt(1)))
    flg = all(t <= d for t, d in zip(acc(T), D))  # all tasks finish within a deadline?
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 48700
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,y;
    cin>>x>>y;
    cout<<ceil(log2((ld)(y+1)/(ld)x))<<'\n';
}

Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main(){

  int n;
  long long in,max=-100000000,min=100000000,sum=0;

  cin>>n;

  for(int i=0;i<n;i++){
    cin>>in;
    if(in>max) max=in;
    if(in<min) min=in;
    sum+=in;
  }

  cout<<min<<" "<<max<<" "<<sum<<endl;
}

Measured memory_bytes: 1168
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, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto V = s[1];
    auto X = readln.split.map!(to!int).array;

    int[] NS = [V];

    while (NS.back > 0) {
        NS ~= NS.back / 2;
    }

    int K = NS.length.to!int;
    int[][] L = new int[][](K);
    int[][] R = new int[][](K);

    foreach (i, n; NS.enumerate) {
        int l = -1;
        int r = -1;
        foreach (j; 0..N) {
            if (l == -1) {
                l = j;
                r = j;
            } else if (X[j] - X[j-1] <= n) {
                r = j;
            } else {
                L[i] ~= l;
                R[i] ~= r;
                l = j;
                r = j;
            }
        }

        L[i] ~= l;
        R[i] ~= r;
    }


    auto dp1 = new int[](1 << K);
    auto dp2 = new int[](1 << K);
    dp1.fill(-1);
    dp2.fill(N);

    foreach (mask; 0..(1 << K)) {
        foreach (i; 0..K) {
            if (mask & (1 << i)) continue;
            auto next1 = R[i].assumeSorted.upperBound(dp1[mask]);
            auto next2 = L[i].assumeSorted.lowerBound(dp2[mask]);
            dp1[mask|(1<<i)] = max(dp1[mask|(1<<i)], dp1[mask]);
            dp2[mask|(1<<i)] = min(dp2[mask|(1<<i)], dp2[mask]);
            if (!next1.empty) dp1[mask|(1<<i)] = max(dp1[mask|(1<<i)], next1.front);
            if (!next2.empty) dp2[mask|(1<<i)] = min(dp2[mask|(1<<i)], next2.back);
        } 
    }

    auto ok = new bool[](L[0].length);
    
    foreach (mask1; 0..(1<<K)) {
        if (mask1 & 1) continue;
        int mask2 = (1 << K) - 1;
        mask2 ^= mask1;
        mask2 &= ~1;
        foreach (i; 0..L[0].length) {
            if (dp1[mask1] + 1 >= dp2[mask2]) {
                ok[i] = true;
            } else if (L[0][i] <= dp1[mask1] + 1 && dp2[mask2] - 1 <= R[0][i]) {
                ok[i] = true;
            }
            
        }
    }

    
    foreach (i; 0..L[0].length) {
        foreach (j; L[0][i]..R[0][i]+1) {
            writeln(ok[i] ? "Possible" : "Impossible");
        }
    }
}



Measured memory_bytes: 21396
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
// 階乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
//int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};


int main(){
    int N, M;
    cin >> N >> M;
    vector<int>A(N, 0);
    REP(i, M){
        int a, b;
        cin >> a >> b;
        a--;
        if(N != 1 && a == 0 && b == 0){
            print(-1);
            return 0;
        }
        if(A.at(a) == 0) {
            if(b == 0) A.at(a) = -1;
            A.at(a) = b;
        }else if(A.at(a) == b) A.at(a) = b;
        else{
            print(-1);
            return 0;
        }

    }
    if(N != 1 && A.at(0) == 0) A.at(0) = 1;
    int ans = 0;
    int tmp  = pow(10, N - 1);

    REP(i, N) {
       if(A.at(i) == - 1) A.at(i) = 0;
       ans += A.at(i) * tmp;
        tmp /= 10;
    }
    print(ans);
    return 0;

}


Measured memory_bytes: 256
/* ex 7_3
   yumizmiz */

#include <stdio.h>
#include <stdlib.h>

int main(void){
    //縦幅，横幅
    int height, width;
    scanf("%d %d ", &height, &width);

    //grid:マスの情報，line_ptr:出力する行，rows_ptr:出力する列を動的に確保
    char **grid_ptr;
    int *lines_ptr, *rows_ptr;
    //縦幅分の領域確保
    grid_ptr = (char**)calloc(height, sizeof(char*));
    if(grid_ptr == NULL){
        fprintf(stderr, "memory allocation error.\n");
        exit(1);
    }

    //横幅分の領域確保
    for(int i = 0;i < height; ++i){
        grid_ptr[i] = (char*)calloc(width, sizeof(char));
        if(grid_ptr[i] == NULL){
            fprintf(stderr, "memory allocation error.\n");
            exit(1);
        }
    }

    //行の領域確保
    lines_ptr = (int*)calloc(height, sizeof(int));
    if(lines_ptr == NULL){
        fprintf(stderr, "memory allocation error.\n");
        exit(1);
    }
    //列の領域確保
    rows_ptr = (int*)calloc(width, sizeof(int));
    if(rows_ptr == NULL){
        fprintf(stderr, "memory allocation error.\n");
        exit(1);
    }

    //　マスの情報を読み込む
    for(int i = 0;i < height; ++i){
        for(int j = 0;j < width; ++j){
            scanf(" %c", &grid_ptr[i][j]);
        }
    }
    //行，列の出力情報を初期化
    for(int i = 0;i < height; ++i){
        lines_ptr[i]=1;
    }
    for(int j = 0;j < width; ++j){
        rows_ptr[j]=1;
    }

    //行ごとに，圧縮できるか判定．
    for(int i = 0;i < height; ++i){
        int is_white_line = 1;
        for(int j = 0;j < width; ++j){
            if(grid_ptr[i][j] != '.'){
                is_white_line = 0;
                break;
            }
        }
        //圧縮できるなら出力しない．
        if(is_white_line == 1){
            lines_ptr[i] = 0;
        }
    }
    //列ごとに，圧縮できるか判定．
    for(int j = 0;j < width; ++j){
        int is_white_row = 1;
        for(int i = 0;i < height; ++i){
            if(grid_ptr[i][j] != '.'){
                is_white_row = 0;
                break;
            }
        }
        //圧縮できるなら出力しない．
        if(is_white_row == 1){
            rows_ptr[j] = 0;
        }
    }

    // 出力：どちらかの出力情報が0なら出力しない．
    for(int i = 0;i < height; ++i){
        
        //行については改行しないようにcontinue;
        if(lines_ptr[i] != 1)
            continue;
        for(int j = 0;j < width; ++j){
            if(rows_ptr[j] == 1){
                printf("%c",grid_ptr[i][j]);
            }
        }
        printf("\n");
    }

    // 配列の開放，逆順に
    free(lines_ptr);
    free(rows_ptr);
    for(int i = 0;i < height; ++i){
        free(grid_ptr[i]);
    }
    free(grid_ptr);
    
    return 0;
}

Measured memory_bytes: 1636
//#include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef int64_t ll;

#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+6;

ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}

// using namespace __gnu_pbds;
// #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set


int32_t main()
{
IOS

    int a,b;
    cin>>a>>b;
    if(500*a>=b)
    {
        cout<<"Yes";
    }
    else
        cout<<"No";

}    

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll K = 0;
ll t;
ll ret = 0;
string s;

void input() {
  IN(s);
  N = s.length();
}

bool rec(string str, ll n) {
  bool ok = true;
  REP(i,(n+1)/2) {
    if (s[i] != s[n-i-1]) {
      ok = false;
    }
  }
  return ok;
}

void solve() {
  bool ok = true;
  ok &= rec(s, N);
  // DEBUG(ok);
  ok &= rec(s, (N-1)/2);
  // DEBUG(ok);
  PRINT(ok?"Yes":"No");
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-8L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()
#define int ll
int costs(int now) {
    for (int i = 0; i < 62; ++i) {
        if (now < (1 << i)) {
            return i + 1;
        }
    }
}

int secret_d = 10;
int n;

int interact(int a) {
    int ans = 0;
    cout << "? " << a << endl;
    if (true) {
        int r = 1;
        for (int i = 0; i < 60; ++i) {
            if ((secret_d & (1LL << i))) {
                ans += costs(r) * costs(a);
                r = r * a % n;                
            }
            ans += costs(a) * costs(a);
            a = a * a % n;
        }
    }
    else {
        cin >> ans;
    }
    return ans;
}

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}

long double comb(int a, int b) {
    ld ans = 1;
    for (int q = 0; q < b; ++q) {
        ans *= (ld)(a - q);
        ans /= (ld)(q + 1);
    }
    return ans;
}

void solve(){
    int n;
    cin >> n;
    vector<int> inputs;
    int ans = 0;
    REP(i, n) {
        int a;
        cin >> a;
        inputs.push_back(a);
    }
    if (inputs[0] != 0) {
        cout << -1 << endl;
        return;
    }
    for (int q = 1; q < n; ++q) {
        if (inputs[q] > inputs[q - 1] + 1) {
            cout << -1 << endl;
            return;
        }
        if (inputs[q] == inputs[q - 1] + 1) {
            ans++;
        }
        else {
            ans += inputs[q];
        }
    }
    cout << ans << endl;
}

#undef int
int main() {
    init();
    solve();
}

Measured memory_bytes: 5384
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		long a=sc.nextLong();
		System.out.println(a+a*a+a*a*a);
	}

	void tr(Object...o) {System.out.println(Arrays.deepToString(o));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
        	ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 32564
#include <iostream>
#include <map>
using namespace std;
using ll = long long int;

map<ll, ll> db;

ll kougeki(ll h, ll c) {
    if (h <= 1) return c + 1;
    h = h / 2;
    c += 1;

    if (db.count(h) == 1) {
        c += db[h];
    } else {
        db.insert(make_pair(h, kougeki(h, c) - c));
        c += db[h];
    }

    if (db.count(h) == 1) {
        c += db[h];
    } else {
        db.insert(make_pair(h, kougeki(h, c) - c));
        c += db[h];
    }


    return c;
}

int main() {
    ll h;
    cin >> h;

    ll c = 0;
    c = kougeki(h, c);

    cout << c << endl;

    return 0;
}

Measured memory_bytes: 256
#include  <iostream>
#include  <algorithm>
#define INF 10000000
using namespace std;

int main(void){
	int e;
	while( cin >> e ,e){
		int m=INF;
		for(int y=0;y*y<=e;y++)
			for(int z=0;z*z*z<=e;z++){
				int x=e-y*y-z*z*z;
				if(x>=0)
					m=min(m,x+y+z);
			}
		cout << m << endl;
	}	
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		--a[i];
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	int pos = 0;
	while (pos + 1 < n && pos + 1 <= a[pos + 1]) pos++;
	int dis1 = a[pos] - pos;
	int dis2 = 0;
	for (int i = pos + 1; i < n; ++i)
		if (a[i] >= pos)
			++dis2;
	if (dis1 % 2 || dis2 % 2) cout << "First";
	else cout << "Second";
}


Measured memory_bytes: 640
import numpy as np
a,b,x=map(float,input().split())
k=2*(a*a*b-x)*1.0/(1.0*a*a*a)
l=2*x/(1.0*a*b*b)
if a*a*b/2.0<x:
    print(np.rad2deg(np.arctan(k)))
else:
    print(90.0-np.rad2deg(np.arctan(l)))

Measured memory_bytes: 12500
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Set as S

main :: IO ()
main = do
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  ss <- sequence . replicate n $ T.getLine :: IO [T.Text]
  print . count $ ss

count :: [T.Text] -> Int
count = fst . foldl step (0, S.empty)
  where
    step ls@(l, s) t | S.member t s = ls
                     | otherwise    = (succ l, S.insert t s)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 80408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	int N, M, X;
	int a;
	int left = 0, right = 0;
	cin >> N >> M >> X;

	vector<int> table(N + 1, 0);
	for (int i = 0; i < M; i++)
	{
		cin >> a;

		table[a] = 1;
	}

	for (int i = 0; i < X; i++)
	{
		left += table[i];
	}

	for (int i = X + 1; i <= N; i++)
	{
		right += table[i];
	}

	cout << min(left, right) << endl;

	return 0;
}

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

public class Main {
    static boolean loop(int a) {
        String str = Integer.toString(a);
        int tmp =0;
        if(str.length()%2==0){
            tmp = str.length()/2;
        }
        else {
            tmp = (str.length()- 1) / 2;
        }
        boolean isLoop = true;
        for (int i = 0; i < tmp; i++) {
            if (str.charAt(i) != str.charAt(str.length() - i - 1)) {
                isLoop = false;
                break;
            }
        }
        return isLoop;
}
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int cnt = 0;
        for (int i = a; i <= b; i++) {
            if (loop(i))
                cnt++;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 25684
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll M; cin >> M;
  ll d, c;
  ll ans = 0;
  vector<ll> cntd(10, 0);
  rep(i,M){
    cin >> d >> c;
    if(d==0) ans += c;
    else cntd[d] += c;
  }
  bool flag = true;
  while(flag){
    vector<ll> cnt_(10,0);
    rep(i,10) ans += cntd[i]/2;
    cnt_[2] += cntd[1]/2; cnt_[1] += cntd[1]%2;
    cnt_[4] += cntd[2]/2; cnt_[2] += cntd[2]%2;
    cnt_[6] += cntd[3]/2; cnt_[3] += cntd[3]%2;
    cnt_[8] += cntd[4]/2; cnt_[4] += cntd[4]%2;
    cnt_[1] += cntd[5]/2; cnt_[0] += cntd[5]/2; cnt_[5] += cntd[5]%2;
    cnt_[1] += cntd[6]/2; cnt_[2] += cntd[6]/2; cnt_[6] += cntd[6]%2;
    cnt_[1] += cntd[7]/2; cnt_[4] += cntd[7]/2; cnt_[7] += cntd[7]%2;
    cnt_[1] += cntd[8]/2; cnt_[6] += cntd[8]/2; cnt_[8] += cntd[8]%2;
    cnt_[1] += cntd[9]/2; cnt_[8] += cntd[9]/2; cnt_[9] += cntd[9]%2;
    ans += cnt_[0]; cnt_[0]=0;
    ans += 10*(cnt_[1]/10); cnt_[1] = cnt_[1]/10+cnt_[1]%10;
    cntd = cnt_;
    rep(i,10){
      if(cntd[i] >= 2) break;
      if(i==9) flag = false;
    }
  }
  bool flag2 = true;
  vector<ll> cntt_ = cntd;
  while(flag2){
    rep(x,10){
      rep(y,10){
        if(cntt_[x]>0 && cntt_[y]>0){
          if(x==y){
            if(cntt_[x]>=2){
              if(x+y>=10) cntt_[1]++;
              cntt_[(x+y)%10]++;
              cntt_[x]--;
              cntt_[y]--;
              ans++;
            }
          }
          else{
            if(x+y>=10) cntt_[1]++;
            cntt_[(x+y)%10]++;
            cntt_[x]--;
            cntt_[y]--;
            ans++;
          }
        }
      }
    }
    ll s=0;
    rep(i,10){
      s+=cntt_[i];
    }
    if(s<=1) flag2 = false;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// ABC067B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
#include<algorithm>
int main()
{
	int N, K;
	cin >> N >> K;
	int l[50];
	for (int i = 1; i <= N; i++)cin >> l[i];
	//for (int i = 1; i <= N; i++) cout << l[i];
	sort(l+1, l + N+1, greater<int>());
	int sum=0;
	for (int i = 1; i <= K; i++) sum+=l[i];
	cout << sum << endl;
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します



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

using namespace std;

const int N = 1e2+7;

int n;
string s;

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> s;
    int res = 0, l = 0, r = (int)s.length()-1;
    while (l < r) {
        res += s[l] != s[r];
        ++l; --r;
    }
    cout << res << endl;
    return 0;
}



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

ll A, B;

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

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

int main(){
    cin >> A >> B;
    cout << lcm(A, B) << endl;
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
 #include<functional>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	std::string str;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif

#if INPUT_FROM_FILE
	std::getline(ifs, str);
#else
	std::getline(std::cin, str);
#endif

	for(int i = 0; i < str.size(); i++){
		char c = str[i];
		if(c >= 'a' && c <= 'z'){
			str[i] = c - 'a' + 'A';
		}
	}
	std::cout << str << std::endl;
	return 0;
}


Measured memory_bytes: 2976
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  int n;
  double x[110], y[110], d[4]={};

  cin>>n;
  for(int i=0;i<n;i++) cin>>x[i];
  for(int i=0;i<n;i++) cin>>y[i];

  for(int i=0;i<n;i++){
    d[0]+=fabs(x[i]-y[i]);
    d[1]+=pow(fabs(x[i]-y[i]), 2);
    d[2]+=pow(fabs(x[i]-y[i]), 3);
    d[3]=max(d[3], fabs(x[i]-y[i]));
  }

  printf("%f\n%f\n%f\n%f\n", d[0], sqrt(d[1]), cbrt(d[2]), d[3]);
  return 0;
}

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

vector<string>adj;
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};

int bfs(int rotx,int roty,int tox,int toy){
	vector<vector<int>>dist(h,vector<int>(w,1e7));
	dist[rotx][roty]=0;

	using pii =pair<int,int>;
	auto comp=[&](const pii& a,const pii& b){
		return dist[a.first][a.second]>dist[b.first][b.second];
	};

	priority_queue<pii,vector<pii>,decltype(comp)>pq(comp);
	pq.push({rotx,roty});

	while(!pq.empty()){
		int x = pq.top().first;
		int y = pq.top().second;
		pq.pop();
		for(int i=0;i<4;i++){
			int nx=x+dx[i];
			int ny=y+dy[i];
			if(nx>=0&&ny>=0&&nx<h&&ny<w && adj[nx][ny]=='.'){
				if(dist[nx][ny]>dist[x][y]){
					dist[nx][ny]=dist[x][y];
					pq.push({nx,ny});
				}
			}
		}
		for(int i=x-2;i<=x+2;i++){
			for(int j=y-2;j<=y+2;j++){
				if(i>=0&&j>=0&&i<h&&j<w &&adj[i][j]=='.'){
					if(dist[i][j]>dist[x][y]+1){
						dist[i][j]=dist[x][y]+1;
						pq.push({i,j});
					}
				}
			}
		}
	}

	return dist[tox][toy];
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>h>>w;
	int ch,cw,dh,dw;
	cin>>ch>>cw>>dh>>dw;
	ch--;cw--;dh--;dw--;
	for(int i=0;i<h;i++){
		string s;
		cin>>s;
		adj.push_back(s);
	}
	int ans = bfs(ch,cw,dh,dw);
	if(ans>=1e7)ans=-1;
	
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 8492
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int N; cin >> N;
    vector<double> A(N);
    double sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += 1.0/A[i];
    }
    printf("%.12f\n", 1.0/sum);
    
}

Measured memory_bytes: 256
import unittest


class TestA(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(3, 5), 0)

    def test_2(self):
        self.assertEqual(think(7, 5), 10)

    def test_3(self):
        self.assertEqual(think(6, 6), 10)


def solve():
    x, a = read()
    result = think(x, a)
    write(result)


def read():
    return read_int(2)


def read_int(n):
    return read_type(int, n)


def read_float(n):
    return read_type(float, n)


def read_type(t, n):
    return list(map(lambda x: t(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(x, a):
    return 0 if x < a else 10


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 5644
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define mdn 1000000007
#define N 2010
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
int f[N][N],suf[N];
void upd(int &x,int y){x+=x+y>=mdn?y-mdn:y;} 
int main()
{
	int n=read(),k=read(),res=1; f[0][n+1]=1;
	for(int i=1;i<=n-k-1;i++)	res=(res<<1)%mdn;
	for(int i=1;i<=k;i++)
	{
		for(int j=n+1;j;j--)	suf[j]=(suf[j+1]+f[i-1][j])%mdn;
		for(int j=n+1,val;j;j--)
		{
			f[i][j]=suf[j+1];
			if(n+2-j-i>0)	upd(f[i][j],f[i-1][j]);
		}
	}
	printf("%d\n",1ll*(f[k][1]-f[k-1][1]+mdn)%mdn*res%mdn);
	return 0;
}


Measured memory_bytes: 15872
using System;
using System.Linq;

namespace AOJ_Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var inputs = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
                if (inputs.All(x => x == 0))
                {
                    goto Finish;
                }

                var height = inputs[0];
                var width = inputs[1];

                for (int i = 0; i < height; i++)
                {
                    var firstChar = i % 2 == 0 ? '#' : '.';
                    var secondChar = i % 2 == 0 ? '.' : '#';
                    for (int j = 0; j < width; j++)
                    {
                        Console.Write(j % 2 == 0 ? firstChar : secondChar);
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }

            Finish:
            return;
        }
    }
}



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

int main() {
    int N; cin >> N;
    vector<int> S(N);
    for(int i = 0; i < N; i++) cin >> S.at(i);
    
    int maxv = S.at(1) - S.at(0);
    int minv = S.at(0);

        for(int i = 1; i < N; i++){
        maxv = max(maxv, S.at(i)-minv);
        minv = min(minv, S.at(i));
        }
    
    cout << maxv << endl;
}


Measured memory_bytes: 3524
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: i64 = read();
    let m: i64 = read();
    let mut i = 1;
    let mut ans = 1;
    while i * i <= m {
        if m % i == 0 {
            if m / i >= n {
                ans = std::cmp::max(ans, i);
            }
            let j = m / i;
            if m / j >= n {
                ans = std::cmp::max(ans, j);
            }
        }
        i += 1;
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#define MAX_N 1000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

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

static const double eps = 1e-8;

struct FOOD{
	string name;
	int w;
	int s;
};

bool checkWeight(const struct FOOD* food,const int* table,int n){
	
	int sum=0;
	for(int i=n-1,j=n-2;i>=1,j>=0;i--,j--){
		sum += food[table[i]].w;
		if(food[table[j]].s < sum) return false;
	}

	return true;
}

double getG(const struct FOOD* food,const int* table,int n){

	double G=0;
	double sum=0;
	for(int i=0;i<n;i++){
		G += (double)food[table[i]].w * (i+1);
		sum += (double)food[table[i]].w;
	}
	return G / sum;
}

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		struct FOOD* food = new struct FOOD[n];

		for(int i=0;i<n;i++){
			char buf[64];
			int w,s;
			scanf("%s %d %d",buf,&w,&s);
			food[i].name = buf;
			food[i].s = s;
			food[i].w = w;
		}

		int* table = new int[n];
		for(int i=0;i<n;i++) table[i] = i;

		int* res = new int[n]();
		double minG = 1000000.0;

		do{
			double tmpG;
			if(checkWeight(food,table,n) &&
				minG > (tmpG = getG(food,table,n))){
					copy(table,table+n,res);
					minG = tmpG;
			}
		}while(next_permutation(table,table+n));

		for(int i=0;i<n;i++){
			printf("%s\n",food[res[i]].name.c_str());
		}

		delete[] food;
		delete[] table;
	}
}

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

int main()
{
    int N, Q;
    cin >> N >> Q;

    vector<vector<int>> tree(N);
    int ai, bi;
    for (int i = 0; i < N - 1; i++)
    {
        cin >> ai >> bi;
        ai--;
        bi--;
        tree.at(ai).push_back(bi);
        tree.at(bi).push_back(ai);
    }

    vector<int> x(N, 0);
    int pi, xi;
    for (int i = 0; i < Q; i++)
    {
        cin >> pi >> xi;
        pi--;
        x.at(pi) += xi;
    }

    vector<int> res(N, -1);
    stack<pair<int, int>> s;
    s.push(make_pair(0, 0));
    while (!s.empty())
    {
        int i = s.top().first, acc = s.top().second;
        s.pop();

        acc += x.at(i);
        res.at(i) = acc;

        for (auto &&j : tree.at(i))
        {
            if (res.at(j) < 0)
            {
                s.push(make_pair(j, acc));
            }
        }
    }

    for (int i = 0; i < N; i++)
    {
        cout << res.at(i) << " ";
    }
    cout << endl;
}

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int K, N;
    cin >> K >> N;

    vector<int> xs(N);

    for (int i = 0; i < N; ++i)
        cin >> xs[i];

    auto ans = K;

    for (int i = 1; i < N; ++i)
        ans = min(ans, K - abs(xs[i] - xs[i - 1]));

    ans = min(ans, K - (K - xs.back() + xs.front()));

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4028