akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,m=MI()
    if n==m:print("Yes")
    else:print("No")
main()

Measured memory_bytes: 3064
// Learn more about F# at http://fsharp.org

open System

let Input f =
    stdin.ReadLine() |> f

let InputArray f =
    stdin.ReadLine().Split(' ') |> Array.map f

[<EntryPoint>]  
let main argv =

    Input string
    |> Seq.sumBy(fun x -> if x = '1' then 1 else 0)
    |> printfn "%d"

    0 // return an integer exit code


Measured memory_bytes: 11996
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  string s; cin >> s;
  string t; cin >> t;
  int res=0;
  rep(i,3) res+=s[i]==t[i];
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

#define SENTINEL 1000000000000000000

void merge(long long A[], long long left, long long mid, long long right){
  long long n1, n2, i, j, k;
  long long *L,*R;
  
  n1 = mid-left;
  n2 = right-mid;
  
  L = (long long*)malloc(sizeof(long long) *(n1 + 1));
  R = (long long*)malloc(sizeof(long long) *(n2 + 1));
  
  for(i = 0; i <= n1 - 1; i++){
    L[i] = A[left + i];
  }
  for(j = 0; j <= n2 - 1; j++){
    R[j] = A[mid + j];
  }
  
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  
  i = 0;
  j = 0;
  
  for(k = left; k <= right - 1; k++){
   if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
  free(L);
  free(R);
}

void mergeSort(long long A[], long long left, long long right){
  long long mid;
  
  if(left + 1 < right){
    mid=(left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(void){

    int N;

    scanf("%d", &N);

    long long A[N];

    for(int i = 0; i < N; i++){
        scanf("%lld", &A[i]);
    }

    mergeSort(A, 0, N);

    long long x = -1, y = -1;
    int c = 1;

    for(int i = 1; i < N; i++){
        if(A[i] == A[i-1]){
            c++;
            if(c % 2 == 0){
                y = x;
                x = A[i];
            }
        }else{
            c = 1;
        }
    }

    if(y == -1){
        printf("0\n");
    }else{
        printf("%lld\n", x * y);
    }

    return 0;
}

Measured memory_bytes: 2932
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i){cin >> a[i];}
    int res = 0;
    for(int i=0; i<n; ++i){
        if(i%2==0 && a[i]%2==1){res++;}
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

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

int main(void){
  int k;
  cin >> k;
  int sum = 0;
  for (int a = 1; a < k + 1; a++) {
  for (int b = 1; b < k + 1; b++) {
    int p = gcd(a, b);
    for (int c = 1; c < k + 1; c++) {
      sum += gcd(p, c);
    }
  }
  }

  cout << sum << endl;

  return 0;
}


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

int main() {
    string S;
    cin >> S;

    int N = (int)S.size();
    int cnt_1 = 0 , cnt_2 = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0 && S[i] != '0') cnt_1++;
        if (i % 2 == 1 && S[i] != '1') cnt_1++;
    }
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0 && S[i] != '1') cnt_2++;
        if (i % 2 == 1 && S[i] != '0') cnt_2++;
    }
    cout << min(cnt_1, cnt_2) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
using namespace std;

int n;
string str[1001];
int plu[1001];
int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		memset(plu,-1,sizeof(plu));
		for(int i=0;i<n;i++){
			cin >> str[i];
			for(int j=str[i].size()-1;j>=0;j--){
				if(str[i][j]=='.'){
					plu[i]=j;
					str[i][j]='+';
					break;
				}
			}
		}
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(plu[i]>plu[j])break;
				if(plu[i]==plu[j]){
					for(int k=i+1;k<j;k++){
						if(str[k][plu[i]]=='.')str[k][plu[i]]='|';
					}
					break;
				}
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<str[i].size();j++){
				if(str[i][j]=='.')str[i][j]=' ';
			}
		}
		for(int i=0;i<n;i++){
			cout << str[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2016
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());

        System.out.println(x + y / 2);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

int main(){
    int n,m ;
    cin >> n >> m ;
    int ans = n*(n-1)/2 + m*(m-1)/2 ;
    cout << ans << endl ;
}

Measured memory_bytes: 256
N = int(input())
n = ("7","5","3")
def dfs(a):
    global ans
    if int(a) > N:
        return 0
    if set(n) == set(a):
        ans += 1
    for i in range(3):
        dfs(a+n[i])

ans = 0
for i in range(3):
    dfs(n[i])
print(ans)

Measured memory_bytes: 3060
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i, _ := range as {
		fmt.Scan(&as[i])
	}

	min := math.MaxInt64
	max := 0
	for _, a := range as {
		if a < min {
			min = a
		}
		if a > max {
			max = a
		}
	}
	fmt.Println(max - min)
}


Measured memory_bytes: 512
N = int(input())

a_num = 97

def dfs(s, n): #s: 現在の文字列, n: 残りの文字数, cnt: 現在の文字列の最大の値
    if n == 0:
        print(s)
        return
    for i in range(ord("a"), ord(max(s))+2):
        dfs(s+chr(i), n-1)

dfs("a", N-1)


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

#define N 200005

long long n,a[N],k,sum,maxn=-0x7fffffff;
long long num[N];

int main()
{
	scanf("%lld",&n);
	
	for (int i=1 ; i<=n ; i++)
	{
	    scanf("%lld",&a[i]);
	    maxn=max(maxn,a[i]);
	    num[a[i]]++;
	}
	
	for (int i=1 ; i<=maxn ; i++)
	{
		if (num[i] == 0) continue;
		
		sum+=(num[i]*(num[i]-1))/2;
	}
	
	for (int i=1 ; i<=n ; i++)
	{
		printf("%lld\n",sum-num[a[i]]+1);
		
	}
	
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
  
using namespace std;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
ll n;
char z[26];
void solve(){
    cin >> n;
    string ans = "";
    while(n > 0) {
        ans = z[n % 26] + ans;
        if(n % 26 == 0)
            n --;
        n /= 26;
    }
    cout << ans;
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    z[0] = 'z';
    for(int i = 1; i < 26; ++i)
        z[i] = 'a' + i - 1;
    while(t--)solve();
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

signed main() {
	int n, k;
	
	cin >> n >> k;
	
	int ans = 0;
	while (n > 0) {
		n /= k;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    set<char> L = {'L', 'U', 'D'};
    set<char> R = {'R', 'U', 'D'};
    string s;
    cin >> s;
    bool ng = false;
    rep(i, 0, sz(s)) {
        if (i % 2) {
            if (!contains(L, s[i])) ng = true;
        } else {
            if (!contains(R, s[i])) ng = true;
        }
    }
    cout << (ng ? "No" : "Yes") << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5])
    cout<<"Yes";
  else 
    cout<<"No";
}

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

int main()
{
    LL n,k,ans;
    while(scanf("%lld%lld",&n,&k) == 2)
    {
        ans = 0;
        if(k)
        {
            for(int i = k + 1; i <= n; i++)
            {
                LL yu = n%i - k + 1;
                ans += n/i*(i-k) + (yu>0?yu:0);
            }
        }
        printf("%lld\n",k?ans:n*n);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

void Compute(ll n)
{
	KAKA
	vector<ll> v(n + 1);
	pragi(1,n + 1)
	{
		cin>>v[i];
	}
	ll cnt = 0;
	pragi(1,n + 1)
	{
		if((i & 1) and (v[i] & 1)) cnt++;
	}
	cout<<cnt<<"\n";
}
int main()
{
	KAKA
	ll n;
	cin>>n;
	Compute(n);
}

Measured memory_bytes: 3616
#include <iostream>
using namespace std;
#define LL long long
int main() {
	LL N;
	LL a[5];
	cin >> N;
	for (int i = 0; i < 5; ++i) {
		cin >> a[i];
	}
	LL min_a = 1e15;
	for (int i = 0 ; i < 5; ++i) {
		if (a[i] < min_a) {
			min_a = a[i];
		}
	}
	if (N % min_a == 0) {
		cout << (N / min_a) + 4 << endl;
	}
	else {
		cout << (N / min_a) + 5 << endl;
	}
	return 0;
}

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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    string s;
    cin >> s;
    i64 n = s.size();
    i64 l = 0, r = n - 1;
    i64 ans = 0;
    while (l < r) {
        if (s[l] == s[r]) {
            l++, r--;
            continue;
        }

        if (s[l] != 'x' && s[r] != 'x') {
            cout << -1 << endl;
            return;
        }

        ans++;
        if (s[l] == 'x') l++; else r--;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 512
import java.util.Scanner;
class Main{
    public static void main(String[]args){
        Scanner scan =new Scanner(System.in);
        int x = scan.nextInt();
        int h=0,m=0,s=0;
        boolean botan=false;
        
        while(botan==false){
            if(x-3600>=0){
                x-=3600;
                h+=1;
            }
            else botan=true;
        }
        botan=false;
        while(botan==false){
            if(x-60>=0){
                x-=60;
        		m+=1;
  			  }		
            else botan=true;
        }
            System.out.println(h+":"+m+":"+x);
    }
}


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

int main() {
	int a, b;
	while(1){
		cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		for(int y = 0 ; y < a ; y++){
			for (int x = 0 ; x < b ; x++){
				if ((x + y) % 2 == 0){
					cout << "#";
				}else{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3084
str_a,str_b = input().split()
num_a,num_b = map(int, input().split())
kye_str = input()
if str_a == kye_str:
  num_a = num_a - 1
else:
  num_b = num_b - 1
print(str(num_a) + " " +str(num_b))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

using namespace std;

int main() {
	long x1, x2, y1, y2;
	cin >> x1 >> y1;
	x2 = -x1; y2 = -y1;
	long big = abs(x1) + abs(y1) + 3;
	long cost = big;
	if (y1 - x1 >= 0) {
		cost = min(cost, y1 - x1);
	}
	if (y2 - x1 >= 0) {
		cost = min(cost, y2 - x1 + 1);
	}
	if (y1 - x2 >= 0) {
		cost = min(cost, y1 - x2 + 1);
	}
	if (y2 - x2 >= 0) {
		cost = min(cost, y2 - x2 + 2);
	}

	cout << cost << endl;
	return 0;
}

Measured memory_bytes: 256
#n=int(input())
a1,a2,a3=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

d1=abs(a2-a1)
d2=abs(a3-a2)
d3=abs(a3-a1)

l=[d1,d2,d3]

l.sort()

print(l[0]+l[1])


Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
long long int modpow(long long int a, long long int n, long long int p)
{
	if (n < 0)return 0;
	long long int res = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			res = res * a % p;
		a = a * a % p;
		n /= 2;
	}
	return res;
}
int main()
{
	char s[100005];
	scanf("%s", s);
	long long int i, n = strlen(s);
	long long int ca[100005], cha[100005];
	ca[0] = cha[0] = 0;
	for (i = 0; i < n; i++)
	{
		if (s[i] == 'A')
		{
			ca[i + 1] = ca[i] + 1;
			cha[i + 1] = cha[i];
		}
		else if (s[i] == '?')
		{
			ca[i + 1] = ca[i];
			cha[i + 1] = cha[i] + 1;
		}
		else
		{
			ca[i + 1] = ca[i];
			cha[i + 1] = cha[i];
		}
	}
	long long int cc[100005], chc[100005];
	cc[n] = chc[n] = 0;
	for (i = n - 1; i >= 0; i--)
	{
		if (s[i] == 'C')
		{
			cc[i] = cc[i + 1] + 1;
			chc[i] = chc[i + 1];
		}
		else if (s[i] == '?')
		{
			cc[i] = cc[i + 1];
			chc[i] = chc[i + 1] + 1;
		}
		else
		{
			cc[i] = cc[i + 1];
			chc[i] = chc[i + 1];
		}
	}
	long long int p = 1000000007;
	long long int ans = 0;
	for (i = 0; i < n; i++)
		if (s[i] == 'B' || s[i] == '?')
			ans = (ans + ((ca[i] * modpow(3, cha[i], p) % p + cha[i] * modpow(3, cha[i] - 1, p) % p) % p) * ((cc[i + 1] * modpow(3, chc[i + 1], p) % p + chc[i + 1] * modpow(3, chc[i + 1] - 1, p) % p) % p)) % p;
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    int counter = 0;
    for (int i = 0; i < S.size(); i++){
        if(S[i] == '2') counter++;
    }
    
    cout << counter << endl;
    return 0;
}

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


int main(){
    int n, k;   cin >> n >> k;
    vector<ll> x(n, 0);
    for(int i=0; i<n; i++) cin >> x.at(i);

    ll ans=1e+15;
    for(int i=0; i<n-k+1; i++){
        ll a = x.at(i), b=x.at(i+k-1), tmp;
        if(b<=0) tmp = abs(x.at(i));
        else if(0<=a)   tmp = x.at(i+k-1);
        else tmp = min(abs(x.at(i)*2)+x.at(i+k-1), abs(x.at(i))+2*x.at(i+k-1));

        ans = min(ans, tmp);
    }
    
    cout << ans << endl;

}

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

int main()
{
	int A, B;

	cin >> A >> B;

	long long socket = 1;
	long long count = 0;

	while (socket < B)
	{
		socket = socket - 1 + A;
		count++;
	}

	cout << count << endl;
}

//int main()
//{
//	string S, T;
//
//	cin >> S >> T;
//
//	int hit = 0;
//
//	for (long long iS = 0; iS < 3; iS++)
//	{
//		if (S[iS] == T[iS])
//		{
//			hit++;
//		}
//	}
//
//	cout << hit << endl;
//}


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

public class Main{
	private static Scanner scan;
	public static void main(String[] args) {
		scan = new Scanner(System.in);
		int a[] = new int[80];
		int b[] = new int[80];
		int c[] = new int[81];
		int n = Integer.parseInt(scan.next());
		for(int i = 0;i < n;i++){
			Arrays.fill(a,0);
			Arrays.fill(b,0);
			Arrays.fill(c,0);
			String as = scan.next();
			String bs = scan.next();
			int al = as.length();
			if(al > 80){
				System.out.println("overflow");
				continue;
			}
			int bl = bs.length();
			if(bl > 80){
				System.out.println("overflow");
				continue;
			}
			int cl = Math.max(al,bl);
			int m = 79;
			while(al > 0 || bl > 0){
				if(al > 0){
					al--;
					a[m] = Integer.parseInt("" + as.charAt(al));
				}
				if(bl > 0){
					bl--;
					b[m] = Integer.parseInt("" + bs.charAt(bl));
				}				
				m--;
			}
			for(int j = 79;j >= 79 - cl + 1;j--){
				c[j + 1] = c[j + 1] + a[j] + b[j];
				if(c[j + 1] >= 10){
					c[j] = c[j] + 1;
					c[j + 1] = c[j + 1] - 10;
				}
			}
			if(c[0] != 0){
				System.out.print("overflow");
			}else{
				int f = 80 - cl;
				if(c[f] != 0)f--;
				for(int j = f + 1;j <= 80;j++){
					System.out.print(c[j]);
				}
			}
			System.out.println();
		}
		System.exit(0);
	}

}

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

using namespace std;

int main(void){
    int N,Q;
    cin>>N>>Q;
    vector<char> S(N);
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    vector<int> l(Q),r(Q);
    for(int i=0;i<Q;i++){
        cin>>l[i]>>r[i];
    }
    vector<int> count(N);
    count[0]=0;
    for(int i=0;i<N-1;i++){
        count[i+1]=count[i];
        if(S[i]=='A'&&S[i+1]=='C'){
            count[i+1]++;
        }
    }
    
    for(int i=0;i<Q;i++){
        cout<<count[r[i]-1]-count[l[i]-1]<<endl;
    }
    return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define repvin(n) vint a(n);rep(i,n)cin>>a[i];
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define INf 1LL<<60
#define out(c) cout<<c<<endl;

vint sum;
int partsum(int a,int b){
  if(a>b)swap(a,b);
  if(a==0)return sum[b];
  return (sum[b]-sum[a-1]);
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
signed main(){
  int n;
  cin>>n;
  vint a(n);
  repi(n)cin>>a[i];
  sum.pb(a[0]);
  for(int i=1;i<n;++i)sum.pb(sum[i-1]+a[i]);
  int def=INf;
  for(int i=0;i<n-1;++i){
    int res=abs(partsum(0,i)-partsum(i+1,n-1));
    def=min(def,res);
  }
  out(def);
  
  return 0;
}


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

int main()
{
    int n, t;
    cin >> n >> t;
    vector<int> times(n);
    rep(i, 0, n) cin >> times[i];

    ll ans = 0;
    rep(i, 0, n - 1)
    {
        if (times[i + 1] - times[i] < t)
            ans += times[i + 1] - times[i];
        else
            ans += t;
    }
    ans += t;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
// scanf("%d %d %d %d",&w,&b,&d,&s); %lld
// printf("%d\n" ,points);
// const double PI=acos(-1);
int main(){
    ll x,k,d,aux,m;
    cin >> x >> k >> d;
    aux=abs(x)/d;
    m=abs(x)-d*min(k,aux);
    if(aux<k){
        k-=aux;
        if(k%2==1) cout << abs(m-d) << endl;
        else cout << m << endl;
    }
    else{
        cout << m << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
long ans = 0;
int main (){
    cin >> n;
    cin >> s;
    int rNum=0,gNum=0,bNum=0;
    long long allPatters = 0;
    long long complement = 0;

    for(int i = 0;i<n;i++){
        if(s[i]=='R')rNum++;
        if(s[i]=='G')gNum++;
        if(s[i]=='B')bNum++;
    }
    for(int i = 0; i<n; i++){
        for(int j = i+1;j<n;j++){
            int k = j+(j-i);
            if((k<n)&&(s[i]!=s[j])&&(s[j]!=s[k])&&(s[i]!=s[k])){
                complement++;
            }
        }
    }
    allPatters=(long long)rNum*(long long)gNum*(long long)bNum;
    ans = allPatters-complement;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define S set<int>
#define pb(v) push_back(v)
int main(){
    CIN(N);CIN(K);
    V vec;
    REP(A,N){
        CIN(b);
        vec.pb(b);
    }
    sort(ALL(vec),greater<int>());
    int ans=0;
    REP(a,K){
        ans += vec.at(a);
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
     Scanner sc = new Scanner(System.in);
     int h1,m1,h2,m2,k;
     h1=sc.nextInt();
     m1=sc.nextInt();
     h2=sc.nextInt();
     m2=sc.nextInt();
     k=sc.nextInt();
     System.out.println((60-m1)+m2+(h2-h1-1)*60-k);
  }
}

Measured memory_bytes: 35800
{-#LANGUAGE FlexibleContexts#-}
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V

getIn = read <$> getLine :: IO Int
getIns = map read . words <$> getLine :: IO [Int]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]

type Row = Integer
type Col = Integer
type Point = (Integer, Integer)

mmm = 1000000007
factorial 0 s = s
factorial n s = factorial (n - 1) (s * n)
fact' n = factorial n 1
fi = fromInteger

-- 
--
--
--
-- Xn = x^(n+1) - 3

burgurSize num = 2 ^ (num + 2) - 3
pattiNum num = 2 ^ (num + 1) - 1
eatableSize :: Integer -> Integer
eatableSize num = toInteger $ flip (-) 2 . truncate $ logBase 2 (fi num + 3) 

eat layer gabu
    | gabu < 1 = 0
    | layer == 1 = do
        if gabu > 5 then 3 + eat 1 (gabu - 6) + 1
        else if gabu < 2 then 0
        else min 3 $ gabu - 1
    | eatableSize gabu < layer = eat (layer - 1) (gabu - 1) -- gabuが-1なのは一番外側のバンズを食べないと内側のパティまで届かないから
    | otherwise = do
        let nokoriGabu = gabu - (burgurSize layer) - 1
        if nokoriGabu < 0 then pattiNum layer
        else pattiNum layer + eat layer nokoriGabu + 1 -- 最後の1はＮ−１バーガーの間に挟まるパティ

main = do
    [l, g] <- getInts
    putStrLn . show $ min (pattiNum l) (eat l g)


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 1e9+7;

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

  int A,B,M;
  cin >> A >> B >> M;
  vi a(A),b(B),x(M),y(M),c(M);
  rep(i,A)cin >> a[i];
  rep(i,B)cin >> b[i];
  rep(i,M){
    cin >> x[i] >> y[i] >> c[i];
    x[i]--;y[i]--;
  }

  int ret = a[0]+b[0];
  rep(i,M){
    ret = min(ret,a[x[i]] + b[y[i]] - c[i]);
  }

  sort(all(a));sort(all(b));
  ret = min(ret,a[0]+b[0]);
  cout << ret << endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int toTime(int, int, int);

int main() {
  int n;
  while(cin >> n, n) {
    vector<pair<int, bool> > ts; // *, true : start, *, false : end
    for(int i = 0; i < n; ++i) {
      int h, m, s;
      char c, d;
      cin >> h >> c >> m >> d >> s;
      int st = toTime(h, m, s);
      ts.push_back(make_pair(st, true));
      cin >> h >> c >> m >> d >> s;
      int et = toTime(h, m, s);
      ts.push_back(make_pair(et, false));
    }
    sort(begin(ts), end(ts));
    int nnt = 0, maxnnt = 0;
    for(int i = 0; i < ts.size(); ++i) {
      nnt += ts[i].second * 2 - 1;
      if(i == ts.size() - 1 || ts[i].first != ts[i + 1].first) maxnnt = max(maxnnt, nnt);
    }
    cout << maxnnt << endl;
  }
  return 0;
}

int toTime(int h, int m, int s) {
  return h * 60 * 60 + m * 60 + s;
}

Measured memory_bytes: 1452
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

// r がグーを出すことを、s のときはチョキを出すことを、p のときはパー



signed main() {
	int n, k, r, s, p;
	ll sum = 0;
	string t, str;

	cin >> n >> k >> r >> s >> p >> t;

	for (int i = 0; i < t.size(); i++) {
		str += 'a';
	}

	/*for (int i = 0; i < t.size(); i++) {
		if (t[i] == 'r') {
			if (i - k >= 0 && str[i - k] == 'p') {
				str += 'r';
			}
			else {
				str += 'p';
				sum += p;
			}
		}
		else if (t[i] == 's') {
			if (i - k >= 0 && str[i - k] == 'r') {
				str += 's';
			}
			else {
				str += 'r';
				sum += r;
			}
		}
		else if (t[i] == 'p') {
			if (i - k >= 0 && str[i - k] == 's') {
				str += 'p';
			}
			else {
				str += 's';
				sum += s;
			}
		}
	}*/

	for (int i = 0; i < t.size(); i++) {
		if (t[i] == 'r') {
			if (i + k < (int)t.size() && t[i + k] == 'r') {
				if (str[i] != 'b') {
					str[i] = 'p';
					sum += p;
					str[i + k] = 'b';
				}
			}
			else  if (str[i] != 'b') {
				str[i] = 'p';
				sum += p;
			}
		}
		else if (t[i] == 's') {
			if (i + k < (int)t.size() && t[i + k] == 's') {
				if (str[i] != 'b') {
					str[i] = 'r';
					sum += r;
					str[i + k] = 'b';
				}
			}
			else if (str[i] != 'b') {
				str[i] = 'r';
				sum += r;
			}
		}
		else if (t[i] == 'p') {
			if (i + k < (int)t.size() && t[i + k] == 'p') {
				if (str[i] != 'b') {
					str[i] = 's';
					sum += s;
					str[i + k] = 'b';
				}
			}
			else if(str[i]!='b') {
				str[i] = 's';
				sum += s;
			}
		}
	}

	//cout << str << endl;

	//for (int i = 0; i < t.size(); i++) {
	//	if (t[i] == 'r') {
	//		if (i+k < (int)t.size() && t[i + k] == 'r') {

	//		}
	//		else {
	//			sum += p;
	//		}
	//	}
	//	else if (t[i] == 's') {
	//		if (i + k < (int)t.size() && t[i + k] == 's') {

	//		}
	//		else {
	//			sum += r;
	//		}
	//	}
	//	else if (t[i] == 'p') {
	//		if (i + k < (int)t.size() && t[i + k] == 'p') {

	//		}
	//		else {
	//			sum += s;
	//		}
	//	}
	//}
	
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 640
# coding: utf-8
import math
a, b, x = map(int, input().split())
h = x / a ** 2
l = 2 * a * h / b
if l <= a:
    print(math.degrees(math.atan2(b, l)))
elif x == a ** 2 * b:
    print(0)
else:
    k = 2 * h - b
    m = a * b / (k - b)
    print(90 + math.degrees(math.atan2(m, b)))

Measured memory_bytes: 38256
#include <iostream>
using namespace std;
bool isInputOk(int v)
{
	return v>=1 && v<=100; 
}
bool isHWOk(int h,int w)
{
	return isInputOk(h)&&isInputOk(w); 
}
int main()
{
	int h,w;
	cin >> h>>w;
	if(isHWOk(h,w)) cout <<h*w <<" "<<(h+w)*2<<endl ;
	else cout <<"input error"<<endl;
	return 0;
} 

Measured memory_bytes: 3084
#include<bits/stdc++.h>
const int maxn = 100035;

int a[maxn],n,l,t,x,cnt;

int main()
{
    scanf("%d%d%d",&n,&l,&t);
    for (int i=1; i<=n; i++)
    {
        scanf("%d%d",&a[i],&x);
        a[i] += x==1?t:-t;
        cnt += a[i]/l;
        if (a[i]%l<0) cnt--;
        ((a[i]%=l)+=l)%=l;
    }
    std::sort(a+1, a+n+1);
    ((cnt%=n)+=n)%=n;
    for (int i=cnt+1; i<=n; i++) printf("%d\n",a[i]);
    for (int i=1; i<=cnt; i++) printf("%d\n",a[i]);
    return 0;
}

Measured memory_bytes: 1536
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
//		 static int mod =  (int) (Math.pow(10,9)+7);
		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        long N = sc.nextLong();
	        long X = sc.nextInt();
	        int M = sc.nextInt();
	        
	        int[] m = new int[M];
	        int[] v = new int[M];
	        int s=0;
	        int t=0;
	        long ans=0;
	        if(X==0) {
	        	System.out.println(0);
	        	return;
	        }
	        boolean flg=false;
	        for(int i=0;i<N;i++) {
	        	m[i]=(int)(X)%M;
	        	if(v[m[i]]==0) {
	        		v[(int)m[i]]=i;
	        	} else {
	        		s=v[m[i]];
	        		t=i;
	        		flg=true;
	        		break;
	        	}
	        	ans=ans+m[i];
	        	X=(X*X)%M;
	        }
	        
	        int d=0;
	        long w=0;
	        int x=0;
	        if(flg) {
		        N=N-t;
		        d=t-s;
		        if(d!=0)w=N/d;
		        else w=N;
		        if(d!=0)x=(int) (N%d);
		        else x=0;
	        }
	        X=m[s];
	        long sum=0;
	        long[] o = new long[M];
	        for(int i=0;i<d;i++) {
	        	o[i]=sum+(X)%M;
	        	X=(X*X)%M;
	        	sum=o[i];
	        }
	        
	        ans=ans+(w*sum);
	        if(x!=0) {
	        	ans=ans+o[x-1];
	        }
	        
	        
	        
	        System.out.println(ans);
		 }
	}

Measured memory_bytes: 37296
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll arr[ohara];//iから始めたときの列
ll last[ohara];
ll before[ohara];
V ans;
ll be;
ll first[ohara];
ll want;

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>n>>k;
    rep(i,n)cin>>a[i];
    rep(i,2*100000+100)first[i]=LINF;
    rep(i,n){
        first[a[i]]=min(first[a[i]],(ll)i);
    }
    
    last[n-1]=a[n-1];
    before[a[n-1]]=n-1;
    rrrep(i,n-2,0){
        if(before[a[i]]==0){
            last[i]=a[i];
            before[a[i]]=i;
        }
        else{
            if(before[a[i]]==n-1)last[i]=-1;
            else{
                last[i]=last[before[a[i]]+1];
            }
            before[a[i]]=i;
        }
    }
      
    be=last[0];
    cnt=1;
    if(be!=-1){
        while(1){
            ll st=first[be]+1;
            be=last[st];
            cnt++;
            if(be==-1)break;
            if(st==n)break;
            //Cout(be);
        }
    }
    k%=cnt;
    //(cntでわった余り)

    be=last[0];
    cnt=1;
    tmp=0;
    if(be!=-1){
        while(1){
            if(cnt==k)break;
            cnt++;
            if(be==-1)break;
            ll st=first[be]+1;
            if(st==n)break;
            tmp=st;
            be=last[st];
        }
    }

    //tmpからのが欲しい
    ll last2[ohara]={};//数字が最後にいつ出てきますか
    rep(i,n){
        last2[a[i]]=max(last2[a[i]],(ll)i);
    }
    want=-1;
    rrep(i,tmp,n){
        if(want==-1){
            if(last2[a[i]]==i)ans.push_back(a[i]);
            else{
                want=a[i];
            }
        }
        else{
            if(want==a[i]){
                want=-1;
            }
        }
    }
    rep(i,Size(ans)){
        if(i==Size(ans)-1)Cout(ans[i]);
        else cout<<ans[i]<<" ";
    }
    return 0;
}


Measured memory_bytes: 24816
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 3050
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
double dp[N][N];
int main(){
    int n;
    cin>>n;
    vector<double>p(n);
    REP(i,n)IN(p[i]);
    dp[0][0]=1;
    REP(i,n){
        REP(j,i+1){
            dp[i+1][j+1]+=dp[i][j]*p[i];
            dp[i+1][j]+=dp[i][j]*(1.0-p[i]);
        }
    }
    double ans=0;
    for(int i=n;i>=(n+1)/2;i--){
        ans+=dp[n][i];
    }
    printf("%.10lf\n",ans);
    return 0;
}

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

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

const int INF = 1 << 30;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    vector<int> dp(n + 1, INF);
    dp[0] = 0;
    rep(i, n + 1)
    {
        for (int j = i + 1; j <= min(n, i + k); j++)
        {
            chmin(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }
    // rep(i, n + 1) cout << dp[i] << endl;
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 4048
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
int main(void){
    double x,y,theta,Pi=3.1415926535;
    int n,i;
    
    while(1){
        scanf("%d",&n);
        if(n==-1)break;
        
        for(i=1;i<=n;i++){
            if(i==1){
                x=1;
                y=0;
                continue;
            }
            theta=atan2(y,x);
            theta+=Pi/2;
            x+=cos(theta);
            y+=sin(theta);
        }
        printf("%.2lf\n%.2lf\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 720
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,*ab = map(int, read().split())

    A, B = [], []
    for a, b in zip(*[iter(ab)]*2):
        A.append(a)
        B.append(b)

    A.sort()
    B.sort()

    if N % 2 == 0:
        a1, a2 = A[N // 2 - 1], A[N // 2]
        b1, b2 = B[N // 2 - 1], B[N // 2]

        ans = b1 + b2 - (a1 + a2) + 1
    
    else:
        a = A[N // 2]
        b = B[N // 2]
        
        ans = b - a + 1
    
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 54580
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll; //long longをllとして簡略

int main(){
  int h,n;
  cin >> h >> n;
  int a[n]={0};

  rep(i,n){
    cin >> a[i];
  }
  int temp=0;

  rep(i,n){
    temp=temp+a[i];
    if(h<=temp){
      cout << "Yes" << endl;
      return 0;
      }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
main()
{
	int x; /* 入力用 */
	int a; /* 合計 */
	int n; /* 入力個数 */
	scanf("%d %d" , &x,&a);/* 入力して、変数1 つに正しくセットできたか？*/
	
  if(x<a){
    n=0;
  }else{
    n=10;
  }
	printf("%d",n);
}

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

struct Edge {
    int to, id;
};
vector<vector<Edge>> tree;
vector<int> ans;

void dfs(int v, int c=-1, int p=-1) {
    int k = 1;
    for(int i=0;i<tree[v].size();i++){
        int u = tree[v][i].to; int ei = tree[v][i].id;
        if(u==p) continue;
        if(k==c) k++;
        ans[ei] = k; k++; 
        dfs(u, ans[ei], v);
    }
}
int main() {
    int n; 
    cin >> n;
    tree.resize(n);
    ans.resize(n-1);
    for(int i=0; i<n-1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back((Edge){b, i});
        tree[b].push_back((Edge){a, i});
    }
    dfs(0);
    //使った色の数
    int mx = 0;
    for(int i=0;i<n;i++) mx = max(mx, int(tree[i].size()));
    cout << mx << endl;

    //使った色列挙
    for(int i=0;i<n-1;i++) {
        cout << ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 8320
# N = map(int,input())
N = int(input())
rest_list = []
for i in range(N):
    S,P = input().split()
    P = int(P)
    temp_list =[S,P,i]
    rest_list.append(temp_list)

for i in range(N):
    for k in range(N-1):
        if rest_list[k][0] == rest_list[k+1][0]:
            if rest_list[k][1] < rest_list[k+1][1]:
                temp = rest_list[k]
                rest_list[k] = rest_list[k + 1]
                rest_list[k + 1] = temp
        elif rest_list[k][0] > rest_list[k+1][0]:
            temp = rest_list[k]
            rest_list[k] = rest_list[k+1]
            rest_list[k+1] = temp

for i in range(N):
    print(rest_list[i][2]+1)


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

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int N;
	string S;
	cin >> N >> S;
	vector<char> A(N);
	for(int i = 0; i < N; i++) A[i] = S[i]-'1';
	vector<int> e2_fac(N+1, 0);
	for(int i = 1; i <= N; i++) e2_fac[i] = e2_fac[i/2] + i/2;
	char p = 0;
	for(int i = 0; i < N; i++) if(e2_fac[N-1] == e2_fac[i] + e2_fac[N-1-i]) p ^= A[i];
	if(p&1) {
		cout << "1\n";
		return 0;
	}
	bool has_odd = false;
	for(int i = 0; i < N; i++) if(A[i]&1) has_odd = true;
	if(has_odd) {
		cout << "0\n";
		return 0;
	}
	if(p&2) cout << "2\n";
	else cout << "0\n";
}


Measured memory_bytes: 6300
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

ll dp[3][200010][20];
int main() {
    int N; scanf("%d", &N);
    vector<ll> A(N);
    for(int i=0; i<N; i++) {
        scanf("%lld", &A[i]);
    }
    
    for(int k=0; k<2; k++) {
        for(int j=0; j<=15; j++) dp[k][N-1][j] = 2*j;
        for(int i=N-2; i>=0; i--) {
            for(int j=0; j<=15; j++) {
                int x = 0;

                // X >= Y になってほしい
                ll X = A[i+1], Y = A[i] << (2*j);
                while(X < Y) X <<= 2, x++;

                if(x <= 15) {
                    dp[k][i][j] = dp[k][i+1][x] + 2*j;
                }
                else {
                    dp[k][i][j] = dp[k][i+1][15] + 2*j + 2*(N-1-i)*(x-15);
                }
            }
        }
        reverse(A.begin(), A.end());
    }

    ll ans = LONGINF;
    for(int i=0; i<=N; i++) {
        for(int j=0; j<=15; j++) {
            for(int k=0; k<=15; k++) {
                chmin(ans, i + dp[0][i][j] + dp[1][N-i][k]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  long double sum_p = 0.0;
  for (int i = 1; i <= N; i++) {
    int num = i;
    long double p = double(1.0) / double(N);
    for (; num < K; num *= 2) {
      p *= double(1.0) / double(2.0);
    }
    sum_p += p;
  }
  
  cout << setprecision(10);
  cout << sum_p << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
ll f(vector<pair<int,int> >a){
    ll ans=0;
    sort(a.begin(),a.end());
    priority_queue<int,vector<int>,greater<> >q;
    for(auto i:a){
        q.emplace(i.second);
        ans+=i.second;
        while(q.size()>i.first) ans-=q.top(),q.pop();
    }
    return ans;
}

int main(){
    int t,n,k,l,r;
    cin>>t;
    while(t--){
        cin>>n;
        ll sum=0;
        vector<pair<int,int> >L,R;
        for(int i=0;i<n;i++){
            cin>>k>>l>>r;
            if(l>r) L.emplace_back(k,l-r),sum+=r;
            else if(r>l) R.emplace_back(n-k,r-l),sum+=l;
            else sum+=l;
        }
        cout<<sum+f(L)+f(R)<<endl;
    }
	return 0;
}


Measured memory_bytes: 7200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
  int N,W; cin >> N >> W;
  vector<int> v(N),w(N);
  rep(i,N) cin >> v[i] >> w[i];

  vector<vector<int>> dp(N+1, vector<int>(W+1));

  rep(i,N) {
    rep(j,W+1) {
      if (j < w[i]) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = max(dp[i][j],dp[i+1][j-w[i]] + v[i]); 
    }
  }

  cout << dp[N][W] << endl;
}



Measured memory_bytes: 6756