akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define lli long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// int const mod = 7340033;
int const mod = 1e9+7;
int power(int a,int b,int m){
    a %= mod;
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}
 
int inverse(int x){
    return power(x,mod-2,mod);
}

int const N = 2e5+5;
int const inf = 1e15;
int a[22][22];
int dist[22][22];
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

void solve(){
    int i,j,l;
    int n,k,m;
    cin>>n>>m;
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            char c;
            cin>>c;
            if(c == '.') a[i][j] = 0;
            else a[i][j] = 1;
        }
    }

    int ans = 0;

    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            if(a[i][j] == 0){
                queue<pii> q;
                q.push({i,j});

                for(int i1 = 0;i1<=n;i1++) {
                    for(int j1=0;j1<=m;j1++){
                        dist[i1][j1] = -1;
                    }
                }

                dist[i][j] = 0;

                while(!q.empty()){
                    int x,y;
                    x = q.front().first;
                    y = q.front().second;
                    q.pop();
                    for(int i1 = 0;i1<4;i1++){
                        int nx = x + dx[i1];
                        int ny = y + dy[i1];

                        if(nx >= 1 && nx <= n && ny >= 1 && ny <= m){
                            if(dist[nx][ny] == -1 && a[nx][ny] == 0){
                                dist[nx][ny] = dist[x][y] + 1;
                                q.push({nx,ny});
                            }
                        }
                    }
                }

                for(int i1=1;i1<=n;i1++){
                    for(int j1=1;j1<=m;j1++){
                        ans = max(ans , dist[i1][j1]);
                    }
                }
            }
        }
    }

    cout<<ans<<endl;
}

int32_t main(){
    IOS;
    int t;
    t = 1;  
    // pre();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

/*

*/

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

#define PI 3.14159265358979323846264338327950L

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

  long double A, B, H, M;
  cin >> A >> B >> H >> M;

  long double rad = PI * 2 * ((H / 12.0) + M / 60.0 / 12.0 - M / 60.0);
  long double ans = (A * A + B * B) - 2 * A * B * cosl(rad);

  cout << setprecision(20) << sqrt(ans) << endl;

  return 0;
}


Measured memory_bytes: 4160
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cmath>
#define endl "\n"
typedef long long int ll;
typedef unsigned long long int ull;
typedef float fl;
typedef short int si;
using namespace std;
void solve()
{   int a,b,c,k; cin >> a >> b >> c >> k;
    if(k-a<=0) cout << k;
    else
    {
        if(k-a-b<=0) cout << a;
        else cout << a-(k-a-b);
    }
}

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


Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>


#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

//A

int main(void) {
	int n;
	cin >> n;
	cout << (n - 2) * 180 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath> 
using namespace std;
long long n,ans,s;
int main(){
	cin>>n;
	for(int i=sqrt(n);i;i--)  
		if(n%i==0){
			ans=n/i;
			break;
		}
	while(ans){ 
		s++;
		ans/=10;
	}
	cout<<s<<endl;
}//jjd

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


public class Main {



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];

		for (int i=0;i<n;i++) {
			h[i] = sc.nextInt();
		}
		Arrays.sort(h);
		
		long ans = 0;
		for (int i=0;i<n-k;i++) {
			ans+=h[i];
		}
		System.out.println(ans);
	}

}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = 2*(int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
//const int dc[4] = {1, -1, 0,  0};
//const int dr[4] = {0,  0, 1, -1};
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T, typename U, typename V> inline
ostream& operator<<(ostream &o, tuple<T,U,V> &p)
{
    return o << "{" << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

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

ll solve(ll n, ll m)
{
    if(m==0) { return 0; }

    if(n%m == n/m) {
        return m;
    } else {
        return 0;
    }
}

ll getSum(ll n) 
{
    ll ans = 0;

    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ans += solve(n, i-1);     
            if(i * i != n) ans += solve(n, n/i-1);
        }
    }
    return ans;
}

int main(void)
{
    ll n;
    cin >> n;
    
    cout << getSum(n) << endl;
    return 0;
}

/*atcoder*/


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

int main(){
int i,n,x;
i=1;
cin>>n;
while(i<=n){
x=i;
 if(x%3==0){
  cout<<" "<<i;
 }else {
 for(x=i;x;x/= 10){
  if (x%10==3){ cout<<" "<<i;
  break;}
 }
 }
i++;
}
cout<<endl;
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>

using namespace std;
int N;
int main(){
    cin>>N;
   long int pn[N],en=0,j=1,ans= 1000000000,sum=0;
    for(int i=0;i<N;i++){
        cin>> pn[i];
    }
    while(j<=100){
     for(int i=0;i<N;i++){
         sum=(pn[i]-j)*(pn[i]-j);
         en +=sum;
     }
        ans=min(ans,en);
        j++;
        en=0;
     }
cout<<ans<<endl;
    return 0;
}

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

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;

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

const ll INF = 1e9;
/////////////////////////////////////////////////////////////////////////////////////////

int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    for (int i = 0;i < n;i++){
        cin >> a[i] >> b[i] >> c[i];
    }

    vector<vector<ll>> dp(n+1,vector<ll>(3,0));
    dp[0][0] = 0;

    for (int i = 0;i < n;i++){
        dp[i+1][0] = max(dp[i][1] + b[i],dp[i][2] + c[i]);
        dp[i+1][1] = max(dp[i][0] + a[i],dp[i][2] + c[i]);
        dp[i+1][2] = max(dp[i][0] + a[i],dp[i][1] + b[i]);
    }

    ll ans = 0;
    for (int i = 0;i < 3;i++) ans = max(dp[n][i],ans);
    
    cout << ans << endl;
}

Measured memory_bytes: 6912
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

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

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

		if x==y:
			return

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

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

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

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

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

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

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

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

s = readChar()

ans = float('inf')

for i in range(len(s)):
	for j in range(i,len(s)-2):
		ans = min(ans,abs(753-int(s[i:i+3])))

print(ans)

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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 100 * 1000 + 9;

int n, f[maxN];
ll h[maxN];

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

	for(int i = 1; i <= n; i++){
		cin >> h[i];
	}
	
	int ans = 0;
	h[n + 1] = BIG;
	for(int i = n; i > 0; i--){
		if(h[i] >= h[i + 1]){
			f[i] = 1 + f[i + 1];
		} else {
			f[i] = 1;
		}
		
		ans = max(ans, f[i]);
	}

	cout << ans - 1 << '\n';
	return 0;
}

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

namespace Beg124C
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().ToArray();
            var changeStart0 = 0;
            var changeStart1 = 0;

            for(int i=0;i<S.Length;i++)
            {
                if(i%2 == 0)
                {
                    changeStart0 += S[i] == '1' ? 1 : 0;
                    changeStart1 += S[i] == '1' ? 0 : 1;
                }
                else
                {
                    changeStart0 += S[i] == '0' ? 1 : 0;
                    changeStart1 += S[i] == '0' ? 0 : 1;
                }
            }
            Console.WriteLine(Math.Min(changeStart0, changeStart1));
        }
    }
}


Measured memory_bytes: 13664
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
double dmax(double a,double b){
    return a>b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct

int main(void){
    int n,m,a,h[1000],p[1000],q[1000],i,j;
    while(1){
        n=in(),m=in(),a=in();
        if(!n)break;
        rep(i,m){
            h[i]=in(),p[i]=in(),q[i]=in();
        }
        for(i=0;i<m-1;i++){
            for(j=m-1;j>i;j--){
                if(h[j-1]<h[j]){
                    swap(&h[j],&h[j-1]);
                    swap(&p[j],&p[j-1]);
                    swap(&q[j],&q[j-1]);
                }
            }
        }
        rep(i,m){
            if(p[i]==a)a=q[i];
            else if(q[i]==a)a=p[i];
        }
        print(a);
    }
    return 0;
}


Measured memory_bytes: 2024
import java.util.*;

public class Main{
	public static void main(String[]args){
		
		Scanner sc=new Scanner(System.in);
		
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int d=sc.nextInt();
		
		if(a>b){
			a=b;
		}
		if(c>d){
			c=d;
		}
		
		System.out.println(a+c);
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n, k; cin >> n >> k;
  	int x[n];
  	int d=0;
  
  	for (int i=0; i<n; i++) {
      cin >> x[i];
  		if (x[i] <= k-x[i]) d += x[i];
      	else d += k - x[i];
    }
  	cout <<  d*2 << endl;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] A = new int[3][3];
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		int N = sc.nextInt();
		for(int i = 0; i < N; i++) {
			int b = sc.nextInt();
			for(int j = 0; j < 3; j++) {
				for(int k = 0; k < 3; k++) {
					if(A[j][k] == b)
						A[j][k] = 0;
				}
			}
		}
		boolean ok = false;
		for(int i = 0; i < 3; i++) {
			if(A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0)
				ok = true;
			if(A[0][i] == 0 && A[1][i] == 0 && A[2][i] == 0)
				ok = true;
		}
		if(A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0)
			ok = true;
		if(A[2][0] == 0 && A[1][1] == 0 && A[0][2] == 0)
			ok = true;
		System.out.println(ok ? "Yes" : "No");

	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    if ( a < b && b < c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3076
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<list>
#include <cstring>
#include <functional>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF ((Int)1<<60)
#define EPS (1e-10)
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define RREP(i,n) for(int i=1; i<=(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long Int;
typedef pair<Int, Int> PI;
typedef pair<int, int> P;
typedef vector<double> vec;
typedef vector<vec> mat;
const int N = 100005;
//////////////////////////////

int R, C, K;
Int g[3300][3300];
Int dp[3300][3300][4];

void solve()
{
	cin >> R >> C >> K;
	REP(i, K) {
		Int r, c, v;
		cin >> r >> c >> v;
		g[r][c] = v;
	}

	RREP(i, R) RREP(j, C) {
		Int up = 0; REP(t, 4) up = max(up, dp[i - 1][j][t]);
		dp[i][j][0] = max(up, dp[i][j - 1][0]);
		dp[i][j][1] = dp[i][j - 1][1]; if (g[i][j]) dp[i][j][1] = max(dp[i][j][1], max(up + g[i][j], dp[i][j - 1][0] + g[i][j]));
		dp[i][j][2] = dp[i][j - 1][2]; if (g[i][j]) dp[i][j][2] = max(dp[i][j][2], dp[i][j - 1][1] + g[i][j]);
		dp[i][j][3] = dp[i][j - 1][3]; if (g[i][j]) dp[i][j][3] = max(dp[i][j][3], dp[i][j - 1][2] + g[i][j]);
	}

	Int ans = 0;
	REP(i, 4) ans = max(ans, dp[R][C][i]);
	cout << ans << endl;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(13);
	solve();
	return 0;
}


Measured memory_bytes: 373740
from math import ceil
ans = 0
n = int(input())
for a in range(1, n + 1):
    for b in range(a+1, n + 1):
        c = n - a * b
        if c > 0:
            ans += 2
        else:
            break
for a in range(1, ceil(n**0.5) + 1):
        c = n - a * a
        if c > 0:
            ans += 1
        else:
            break
print(ans)

Measured memory_bytes: 73888
#include<stdio.h>
int main(void)
{
  int a,b,c,d,sum=0;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  if(a<b) sum=sum+a;
  else sum=sum+b;
  if(c<d) sum=sum+c;
  else sum=sum+d;
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    long long int n,x,y,t,i;
    scanf("%lld",&n);
    t = n;
    for(i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            x=i;
            y=n/i;
            if(t>x+y-2)
                t=x+y-2;
        }
    }
    if(t==n)
        printf("%lld",n-1);
    else
        printf("%lld",t);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
#define llx(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;
long long n,m,q,i,j,k,num[2005],vis[2005],ans=1ll<<60;
vector<long long> seq,seq2,all,pos[2005];
int main()
{
	ios_base::sync_with_stdio(0);
	cin>>n>>m>>q;
	for (i=1;i<=n;i++)
	{
		cin>>num[i];
		all.push_back(num[i]);
	}
	sort(all.begin(),all.end());
	all.resize(unique(all.begin(),all.end())-all.begin());
	for (i=1;i<=n;i++)
	{
		num[i]=upper_bound(all.begin(),all.end(),num[i])-all.begin();
		pos[num[i]].push_back(i);
	}
	for (i=0;i<=all.size();i++)
	{
		llx(pos[i],it) vis[*it]=1;
		seq.clear();seq2.clear();
		for (j=1;j<=n;j++)
		{
			if (!vis[j])
			{
				seq.push_back(num[j]);
			}
			else
			{
				sort(seq.begin(),seq.end());
				for (k=0;k<=((int)seq.size())-m;k++)
				{
					seq2.push_back(seq[k]);
				}
				seq.clear();
			}
		}
		sort(seq.begin(),seq.end());
		for (k=0;k<=((int)seq.size())-m;k++)
		{
			seq2.push_back(seq[k]);
		}
		sort(seq2.begin(),seq2.end());
		if (seq2.size()>=q)
		{
			ans=min(ans,all[seq2[q-1]-1]-all[seq2[0]-1]);
		}
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)


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

 ll n;
  cin >> n;
  
  ll x=(n*25)/27;
  
  if((x*27)/25==n) cout << x << endl;
  else if(((x+1)*27)/25==n) cout << x+1 << endl;
  else if(((x-1)*27)/25==n) cout << x-1 << endl;
  else cout << ":(" << endl;
 
  
}

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

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

const int INF = 1001001001001001001LL;

const int DX[4] = {0, 1, 0, -1};
const int DY[4] = {-1, 0, 1, 0};

signed main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<int> one(61), zero(61);
    for (int i = 0; i < 61; i++) {
        for (int j = 0; j < N; j++) {
            if (A[j] >> i & 1) {
                one[i]++;
            } else {
                zero[i]++;
            }
        }
    }

    vector<vector<int>> dp(61, vector<int>(2, INF));
    auto rec = [&](auto fun, int i, bool less) -> int {
        if (i == -1) return 0;
        auto &DP = dp[i][less];
        if (DP != INF) return DP;
        int ret = 0;
#define update_zero(l) chmax(ret, fun(fun, ((i) - 1), l) + (1LL << (i)) * one[i])
#define update_one(l) chmax(ret, fun(fun, ((i) - 1), l) + (1LL << (i)) * zero[i])
        if (less) {
            // 1
            update_one(true);
            // 0
            update_zero(true);
        } else {
            if (K >> i & 1) {
                // 1
                update_one(false);
                // 0
                update_zero(true);
            } else {
                // 0
                update_zero(false);
            }
        }
#undef update_zero
#undef update_one
        return DP = ret;
    };
    cout << rec(rec, 60, false) << endl;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))


count=0
for i in range(n):
    if b[i] - a[i] > 0:
        if a[i+1] - (b[i] - a[i]) > 0:
            a[i+1] = a[i+1] - (b[i] - a[i])
            count += b[i]
        else:
            count += a[i] + a[i+1]
            a[i+1] = 0
    else:
        count += b[i]
print(count)

Measured memory_bytes: 18624
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
typedef long long ll;
int main(){
  int N;
  cin >> N;
  ll H;
  cin >> H;
  vector<ll> a(N);
  vector<ll> b(N);

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

  sort(a.begin(),a.end());
  sort(b.begin(),b.end(),greater<ll>());

  ll ans = 0;
  for(int i = 0;i < N;i++){
    if(upper_bound(a.begin(),a.end(),b[i]) == a.end()){
      H -= b[i];
      ans++;
    }
    else{
      ans += (H + a[N-1] - 1)/a[N-1];
      H = 0;
    }

    if(H <= 0)break;

  }

  if(H > 0)ans += (H + a[N-1] - 1)/a[N-1];

  cout << ans << endl;
}


Measured memory_bytes: 1792
S = input()
ans = 0
 
for i in range(2**(len(S)-1)):
  temp = S
  for j in range(len(S)-1):
    if(i >> j) & 1:
      temp = temp[:j - len(S) + 1]+'+'+temp[j-len(S)+1:]
  ans += eval(temp)
 
print(ans)

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

int main(void){
	int N,A,B;
	string s;
	cin>>N>>A>>B>>s;
	rep(i,N){
		if(s[i]=='c' || A+B==0)cout<<"No"<<endl;
		else if(s[i]=='a'){
			if(A>0)A--;
			else B--;
			cout<<"Yes"<<endl;

		}else if(s[i]=='b' && B>0){
			B--;
			cout<<"Yes"<<endl;
		}else cout<<"No"<<endl;
	}

	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 5e5 + 5;
const int MOD = 1e9 + 7;

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int fact[N], invfact[N];

int modinv(int k)
{
	return pow(k, MOD-2, MOD);
}

void precompute()
{
	fact[0]=fact[1]=1;
	for(int i=2;i<N;i++)
	{
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	invfact[N-1]=modinv(fact[N-1]);
	for(int i=N-2;i>=0;i--)
	{
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=MOD;
	}
}

int nCr(int x, int y)
{
	if(y>x)
		return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=MOD;
	num*=invfact[x-y];
	num%=MOD;
	return num;
}

int n, m;
int suf[N];

int32_t main()
{
	IOS;
	precompute();
	cin >> n >> m;
	suf[n] = 1;
	for(int i = n - 1; i >= 0; i--)
	{
		suf[i] = m - i;
		suf[i] *= suf[i + 1];
		suf[i] %= MOD;
 	}
	int ans = nCr(m, n) * fact[n];
	ans %= MOD;
	int ways = 0;
	for(int i = 0; i <= n; i++)
	{
		int cur = suf[i];
		cur *= nCr(n, i);
		cur %= MOD;
		if(i % 2 == 0)
			ways += cur;
		else
			ways -= cur;
		ways %= MOD;
		ways += MOD;
		ways %= MOD;
	}
	ans *= ways;
	ans %= MOD;
	cout << ans;
	return 0;
}

Measured memory_bytes: 15200
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int x;
  cin >> x;
  if (x < 1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	long long int N,M,a,b;
	cin >> N >>M;
	if (N >= M / 2) {
		cout << M / 2 << endl;
		return 0;
	}
	else {
		a = M - 2 * N;
		b = a / 4;
		cout << b + N << endl;
	}
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

# strategy 1: buy only AB                                                                                                                                                                                   

a1 = 2 * C * max(X, Y)

# strategy 2: buy only A and B                                                                                                                                                                              
a2 = A * X + B * Y

# strategy 3: buy AB until one is satisfied                                                                                                                                                                 
a3 = 2 * C * min(X, Y) + A * (X-min(X, Y)) + B * (Y-min(X, Y))

print(min(a1, a2, a3))



Measured memory_bytes: 9100
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  string s;
  cin >> s;
  int n = s.size();
  for(int i = 0; i < n / 2; i++){
    if(s[i] != s[n - i - 1]){
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i = 0; i < n / 2; i++){
    if(s[n / 2 + i + 1] != s[n - i - 1]){
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i = 0; i < n / 2; i++){
    if(s[i] != s[n - i - 1]){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	int cur = 0;
	int ans = 0;
	int n;
	string S;
	cin >> n >> S;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] == 'I') cur++;
		else cur--;
		if (cur > ans) ans = cur;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <unordered_map>
//#include <bits/stdc++.h>
#include <cassert>
#include <map>
#include <bitset>
using namespace std;

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int maxn = 1e5+1;
int n, m;
int cnt[maxn];
bool has[maxn];
int main()
{

  int n, m;
  scanf("%d %d", &n, &m);
  fill(cnt+1, cnt+n+1, 1);
  has[1] = 1;
  for (int i = 0; i < m; ++i)
    {
      int x, y;
      scanf("%d %d", &x, &y);
      if (has[x])
    has[y] = true;
      --cnt[x];
      ++cnt[y];
      if (cnt[x] == 0)
    has[x] = 0;
    }
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    ans += has[i];
  printf("%d\n", ans);
}

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

int main() {
  int n,x;
  cin >> n>> x;
  vector<int> L(n);
  for(int i=0;i<n;i++){
    cin >> L.at(i);
  }
  int D,ans;
  D=0;
  ans=1;
  for(int i=0;i<n;i++){
    D += L.at(i);
    if(D<=x){
      ans +=1;
    }
  }
  cout << ans;
}

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		Set<String> hs = new HashSet<>();
		String[] w = new String[n];
		for (int i = 0; i < n; i++) {
			w[i] = sc.next();
			
			if (hs.contains(w[i])) {
				pr.println("No");
				return;
			}

			hs.add(w[i]);
		}
		
		for (int i = 1; i < n; i++) {
			if (w[i - 1].charAt(w[i - 1].length() - 1) != w[i].charAt(0)) {
				pr.println("No");
				return;
			}
		}

		pr.println("Yes");
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


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

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int apple=0;
  
  string slime;
  while(apple<S.size()){
    char s=S.at(apple);
    slime=slime+s;
    for(int i=apple;i<S.size() && S.at(i)==s;++i){
      ++apple;
    }
  }
  cout<<slime.size()<<endl;
}

Measured memory_bytes: 696
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(int i=(int)(x);i<(int)(y);i++)
#define RREP(i,x,y) for(int i=(int)(x);i>(int)(y);i--)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

const int MAX_N = 100000;
const ll MOD = pow(10,9) + 7;
int A[MAX_N];
int N;

int solve() {
    ll ans = 1;
    sort(A, A + N);
    if(N % 2 == 1){
        REP(i,0,N){
            eprintf("i=%d,A[i]=%d\n",i,A[i]);
            if(A[i] != ((i + 1) / 2) * 2) return 0;
        }
    }else{
        REP(i,0,N){
            eprintf("i=%d,A[i]=%d\n",i,A[i]);
            if(A[i] != (i / 2) * 2 + 1) return 0;
        }
    }
    REP(i,0,N/2){
        ans *= 2;
        ans %= MOD;
    }
    return ans;
}

int main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    REP(i, 0, N) cin >> A[i];
    cout << solve() << "\n";
    return 0;
}


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

int main()
{
  int h, w;
  cin >> h >> w;

  char grid[h][w];
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      cin >> grid[y][x];
    }
  }

  int m_distance[h][w];
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      m_distance[y][x] = 2000;
    }
  }

  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      if (grid[y][x] == '#') {
        m_distance[y][x] = 0;
      } else if (x > 0 && m_distance[y][x - 1] < m_distance[y][x]) {
        m_distance[y][x] = m_distance[y][x - 1] + 1;
      }
    }
    for (int x = w - 1; x > 0; x--) {
      if (m_distance[y][x - 1] > m_distance[y][x]) {
        m_distance[y][x - 1] = m_distance[y][x] + 1;
      }
    }
  }

  for (int x = 0; x < w; x++) {
    for (int y = 1; y < h; y++) {
      if (m_distance[y - 1][x] < m_distance[y][x]) {
        m_distance[y][x] = m_distance[y - 1][x] + 1;
      }
    }
    for (int y = h - 1; y > 0; y--) {
      if (m_distance[y - 1][x] > m_distance[y][x]) {
        m_distance[y - 1][x] = m_distance[y][x] + 1;
      }
    }
  }

  int ans(0);
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      ans = max(ans, m_distance[y][x]);
    }
  }

  cout << ans << endl;
}


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

 int main() {
     string s;
     cin >> s;
     int ansA =0;
     int ansZ =0;
     for (int i=0; i<s.size();i++){
         if(s.at(i) =='A'){
             ansA =i+1;
             break;
         }
     }
    for(int i=s.size();i>=0;i--){
        if(s.at(i-1)=='Z'){
            ansZ =i;
            break;
        }
    }
        cout << ansZ - ansA +1 << endl;
     }


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;


int main() {
	int n,k;
	cin >> n >> k;
	vector<int> x(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}

	x.emplace_back(0);
	sort(x.begin(), x.end());
	int pos0 = n;
	for (int i = 0; i <= n; i++) {
		if (x[i] == 0) {
			pos0 = i;
			break;
		}
	}
	
	int ans = 1000000000;
	for (int i = max(pos0 - k, 0); i <= min(pos0+k,n); i++) {
		
		if (i == pos0) {
			continue;
		}
		int sig;
		if (i > pos0) {
			sig = 1;
		}
		else {
			sig = -1;
		}
		int t = sig * x[i];
		
		int res = k - abs(i - pos0);
		if (res > 0) {
			int next = pos0 - sig * res;
			if (next < 0 || next > n) {
				continue;
			}
			t -= sig *(x[pos0 -sig *res] - x[i]);
		}

		
		if (ans > t) {
			ans = t;
		}
	}

	cout << ans << endl;


}

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

int main() {
	int w, h, x, y, r; // 幅ｗ、高さｈ、座標ｘ, ｙ、半径ｒ
	cin >> w >> h >> x >> y >> r;

	int a = 0;
	if (x + r > w) {
		cout << "No" << endl;
		return 0;
	}
	else if (x - r < 0) {
		cout << "No" << endl;
		return 0;
	}
	else a++;

	if (y + r > h) {
		cout << "No" << endl;
		return 0;
	}
	else if (y - r < 0) {
		cout << "No" << endl;
		return 0;
	}
	else a++;

	if (a == 2) cout << "Yes" << endl;


	return 0;
}


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

enum {
  MAXN = 100000 + 5
};

char s[MAXN];

void exec() {
  int i;
  scanf("%s", s);
  i=0;
  while (s[i] != '\0') {
    if (strncmp("eraser", s+i, 6) == 0)
      i += 6;
    else if (strncmp("erase", s+i, 5) == 0)
      i += 5;
    else if (strncmp("dreamer", s+i, 7) == 0 && s[i+7] != 'a')
      i += 7;
    else if (strncmp("dream", s+i, 5) == 0)
      i += 5;
    else
      return (void) puts("NO");
  }
  puts("YES");
}

int main() {
  if (fopen("C.in", "r") != NULL) {
    freopen("C.in", "r", stdin);
    freopen("C.out", "w", stdout);
  }
  exec();
  return 0;
}




Measured memory_bytes: 384
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const double eps = 0.0000001;
const double PI = acos(-1.0);
const int MOD = 1e9+7;
const int N  = 1e5+5;

int a[N], dp[N];

signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    	cin >> a[i];
    for (int i = n-1; i >= 1; i--) {
    	dp[i] = inf;
    	for (int j = 1; j <= k; j++) {
    		if (i+j <= n) {
    			dp[i] = min(dp[i], dp[i+j] + abs(a[i+j]-a[i]));
    		}
    	}
    }
    cout << dp[1];
    return 0;
}

Measured memory_bytes: 1792
//Frogs-1
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
signed main()
{
    int n;
    cin>>n;
    int a[n+1],dp[n+1];
    for(int i=0;i<n;i++)
        cin>>a[i];
    
    dp[0]=0,dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <iostream> 
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>
#include <climits>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

using ll = long long int;

#define mp(a,b) make_pair(a,b)

const int MOD = 1000 * 1000 * 1000 + 7;

bool res() {
	int n;
	cin >> n;
	if (!cin) return false;
	cout << pow(n, 3) << '\n';

	return true;
}

int main() {
	while (res()) {}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define INF 1010001000
#define EPS 1e-10
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef pair<int, int> i_i;
typedef long long int llong;
typedef pair<llong, llong> ll_ll;
typedef struct edge {int f, t;}Edge;

int gcd(int a, int b);

int main()
{
    char input[1024];
    while (cin >> input, input[0] != '#') {
        int top = 0, bot = 1, ptr = 0, n = 0;
        vector<bool> dir;
        if (strcmp(input, "north") == 0) {
            cout << 0 << endl;
        } else if (strcmp(input, "west") == 0) {
            cout << 90 << endl;
        } else {
            while (ptr + 3 < strlen(input)) {
                if (strncmp(&input[ptr], "north", 5) == 0) {
                    ptr += 5;
                    dir.pb(true);
                    n++;
                } else if (strncmp(&input[ptr], "west", 4) == 0) {
                    ptr += 4;
                    dir.pb(false);
                    n++;
                }
            }
            if (!dir[n-1]) {
                top = 90;
            }
            for (int i = n-2; i >= 0; i--) {
                if (dir[i]) {
                    top *= 2;
                    bot *= 2;
                    top -= 90;
                } else {
                    top *= 2;
                    bot *= 2;
                    top += 90;
                }
            }
            int g = gcd(top, bot);
            top /= g;
            bot /= g;
            if (bot == 1) {
                cout << top << endl;
            } else {
                cout << top << "/" << bot << endl;
            }
        }
    }
    return 0;
}

int gcd(int a, int b)
{
    if (a == 0 || b == 0) {
        return 1;
    } else {
        while (a != b) {
            if (a < b) {
                b -= a;
            } else {
                a -= b;
            }
        }
        return a;
    }
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  
  sort(a.begin(), a.end());
  int am = a.back();
  a.pop_back();

  int diff = INF;
  int ah;
  rep(i,n-1) {
    if (diff > abs(a[i] - am/2)) {
      diff = abs(a[i] - dup(am,2));
      ah = a[i];
    }
  }

  printf("%d %d\n", am, ah);

  return 0;
}

Measured memory_bytes: 640
let () =
  let n, m, d = Scanf.scanf "%d %d %d" (fun n m d -> n, m, d) in
  (if d = 0 then
     1.0 /. float n *. float (m-1)
   else
     2.0 *. float (n - d) /. float (n * n) *. float (m-1))
  |> Printf.printf "%.7f\n" 
  

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n,w; cin >>n>>w;
    vector<ll> c(n); vector<ll> v(n);
    REP(i,n) cin >> c[i] >> v[i];

    vector<vector<ll> > dp(n+1, vector<ll>(100100, INFLL));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 100100; j++) {
            if (dp[i][j] != INFLL) {
                dp[i+1][j] = dp[i][j];
            } 
            if (j-v[i] >= 0 && dp[i][j-v[i]] != INFLL) {
                dp[i+1][j] = min(dp[i+1][j], dp[i][j-v[i]]+c[i]);
            } 
        }
    }

    int ans = 0;
    for (int j = 0; j < 100100; j++) {
        if(dp[n][j] <= w){
            ans = j;
        }
    }
    cout << ans << endl;
    return 0;
}



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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,x;cin >> n >> x;
	vector<ll> ban(n+1);
	vector<ll> sou(n+1);
	ban[0]=1;
	sou[0]=1;
	rep(i,n){
		ban[i+1]=ban[i]*2+1;
		sou[i+1]=sou[i]*2+3;
	}
	ll ans=0;
	for(int i=n;i>=0;--i){
		if(i==0){
			ans++;
			break;
		}
		if(x==1) break;
		if(x==sou[i]){
			ans+=ban[i];
			break;
		}
		if(sou[i-1]+2==x){
			ans+=ban[i-1]+1;
			break;
		}
		else if(sou[i-1]+2>x){
			x--;
		}
		else{
			ans+=ban[i-1]+1;
			x-=sou[i-1]+2;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
char N[200010];

//WA
//数値で扱おうとするとメモリが足りないので文字列として扱う
//わざわざ関数を用意しなくても各位の和を求めれば行ける
// int findSumOfDigits(ll n)
// {
//     ll sum = 0;
//     while (n > 0)
//     {
//         sum += n % 10;
//         n /= 10;
//     }
//     return sum;
// }

int main()
{
    cin >> N;
    int len = strlen(N);
    int sum = 0;
    for (int i = 0; i < len; i++)
    {
        sum += N[i] - '0';
    }

    if (sum % 9 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main(){
	int N;
	cin>>N;
	int t[N],x[N],y[N];
	for(int i=0;i<N;i++){
		cin>>t[i]>>x[i]>>y[i];
	}
	int flag=0;
	for(int i=0;i<N;i++){
		if(t[i]%2==(x[i]+y[i])%2){
			if(x[i]+y[i]<=t[i]){
				if(N%2==1&&x[i]==0&&y[i]==0){flag=0;}
				else{flag=1;}
			}else{
				flag=0;break;
			}
		}else{
			flag=0;break;
		}
	}

	if(flag)cout<<"Yes"<<endl;
	if(!flag)cout<<"No"<<endl;

}

Measured memory_bytes: 1408
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int n,m;cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}


Measured memory_bytes: 256