akhauriyash/Code-Regression huggingface dataset:
// 🐋💭 Walk on Multiplication Table
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}
// https://melheaven.hatenadiary.jp/entry/atcoder144
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

func main() {
    let n = readInt()
    let ary = makeDivisors(n)
    print(ary.min()! - 2)
}
main()




Measured memory_bytes: 13128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();

		// 角度計算M
		double angleM = ((double)M / 60) * 360;
//		System.out.println("M is " + angleM);

		// 角度計算H
		double tmpM = ((double)M / 60) * 30;;
		double angleH = (double)(H*30 + tmpM);

//		System.out.println("H is " + angleH);
//		System.out.println();

		// 角度計算
		double theta = angleH - angleM;
		if (theta > 180)
			theta = angleM - angleH;

//		System.out.println(theta);

		// 計算
		double ans = A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(theta));
		double r_ans = Math.sqrt(ans);

		System.out.println(r_ans);

	}

}


Measured memory_bytes: 35996
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

typedef struct _Block{
    llong a;
    llong b;
    llong c;
    llong d;
}Block; 

llong dfs(vector<Block> &Table, vector<llong> &A, llong value, llong M, llong N){
    llong maxv = 0;
    if(A.size()==N){
        llong ans = 0;
        for(int i=0; i<Table.size(); i++){
            if((A[Table[i].b]-A[Table[i].a])==Table[i].c){
                ans = ans + Table[i].d;
            }
        }
        return ans;
    }
    for(int i=value; i<=M; i++){
        A.push_back(i);
        maxv = max(maxv, dfs(Table, A, i, M, N));
        A.pop_back();
    }
    return maxv;
}

int main(){
    llong N, M, Q;
    cin >> N >> M >> Q;
    vector<llong> A;
    vector<Block> Table(Q);
    for(int i=0; i<Q; i++){
        cin >> Table[i].a >> Table[i].b >> Table[i].c >> Table[i].d;
        Table[i].a--;
        Table[i].b--; 
    }
    cout << dfs(Table, A, 1, M, N) << endl;
    return 0;
}


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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

int a[MAXN];

int solve(int casi){
	cin>>n;
	ll s = 0;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		s += a[i];
	}
	ll st = 1ll * n * (n + 1) / 2;
	if (s % st != 0)
		return 0;
	s /= st;
	int cnt = 0;
	a[n+1] = a[1];
	for(int i = 1; i <= n; i++){
		ll t = s - (a[i+1] - a[i]);
		if (t % n != 0 || t < 0) return 0;
		cnt += t / n;
	}
	return cnt == s;
}

void printans(){

}


int main(){
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		puts(solve(i) ? "YES" : "NO");
		printans();
	}
	return 0;
}




Measured memory_bytes: 768
#include <iostream>

int main(int argc, char const *argv[]) {
  int X, r;
  std::cin >> X;
  if (X >= 400 && X < 600) r = 8;
  else if (X < 800) r = 7;
  else if (X < 1000) r = 6;
  else if (X < 1200) r = 5;
  else if (X < 1400) r = 4;
  else if (X < 1600) r = 3;
  else if (X < 1800) r = 2;
  else r = 1;

  std::cout << r << std::endl;

  return 0;
}


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int s[110000];
signed main() {
    cin >> N;
    rep(i, N) { cin >> s[i]; }
    int ans = 0;
    for (int i = 1; i < N - 1; i++) {
        int lcum = 0, rcum = 0;
        for (int j = i; j < N - 1; j += i) {
            if (j >= N - j - 1 && (N - 1) % i == 0) { break; }
            if (i >= N - j - 1) { break; }
            lcum += s[j], rcum += s[N - j - 1];
            chmax(ans, lcum + rcum);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    int N,K;
    cin >> N >> K;
    vector<int> fruit(N);
    for(int i=0;i<N;i++){
        cin >> fruit.at(i);
    }
    sort(fruit.begin(),fruit.end());
    int money=0;
    for(int i=0;i<K;i++){
        money+=fruit.at(i);
    }
    cout << money << endl;
}

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

#define F first
#define S second

using namespace std;

const int N = 1e5;

int n;

int a[N + 20];

pair <int,int> p[N + 20];

int main () {
	cin >> n;
	for (int i = 1;i <= n;i ++) {
		cin >> p[i].F;
		p[i].S = i;
	}sort (p + 1, p + n + 1);
	for (int i = 1;i <= n;i ++) {
		cout << p[i].S << ' ';
	}
}


Measured memory_bytes: 1664
//
//  main.cpp
//  simCity
//  Copyright © 2019 ITOOKASHIKI. All
#define vv(t) vector<vector<t>>
#define v(t) vector<t>
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for(int i=0; i<n; ++i)
#define FOR(i, m, n) for(int i=m; i<n; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#include <iostream>
#include <algorithm>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
//cin.tie(0);
//sync_with_stdio(false);
template <class T = int>    T in(){ T x;  cin >> x;   return (x); }
template <class T>          void printn(T& x){ cout << x << '\n'; }
template <class T>          void print(T& x){ cout << x; }

int main(int argc, const char * argv[]) {
    int sum = 0, minMod10 = 10;
    rep(i,5){
        int tmp = in();
        minMod10 = min(minMod10, (tmp-1) % 10);
        while(tmp % 10){    ++tmp;  }
        sum += tmp;
    }
    cout << sum - 10 + minMod10 + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
int N;
std::vector<int> A;
int ans;
int main() {
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		int tmp;
		std::cin >> tmp;
		A.push_back(tmp);
	}
	std::sort(A.begin(), A.end());
	int be = A[0];
	int sum = 1;
	for (int i = 1; i < N; i++) {
		if (A[i - 1] != A[i]) {
			A[i - 1] <= sum ? ans += sum - A[i - 1] : ans += sum;
			sum = 1;
		}
		else {
			sum++;
		}
	}
	A[N - 1] <= sum ? ans += sum - A[N - 1] : ans += sum;
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
	char ch=getchar();int f=0,x=1;
	while(ch<'0'||ch>'9'){if(ch=='-') x=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f*x;
}
int maxx,minn,a[99];
int main()
{
	int n=read();
	cout<<2*n-1<<endl;
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++)
	{
		if(a[i]>0) maxx=max(maxx,a[i]);
		else minn=max(minn,-a[i]);
	}
	if(maxx>minn)
	{
		int maxpla;
		for(int i=1;i<=n;i++)
		{
			if(a[i]==maxx)
			{
				maxpla=i;
				break;
			}
		}
		for(int i=1;i<=n;i++)
		printf("%d %d\n",maxpla,i);
		for(int i=1;i<=n;i++)
		a[i]+=maxx;
		for(int i=1;i<n;i++)
		printf("%d %d\n",i,i+1);
	}
	else
	{
		int maxpla;
		for(int i=1;i<=n;i++)
		{
			if(a[i]==-minn)
			{
				maxpla=i;
				break;
			}
		}
		for(int i=1;i<=n;i++)
		printf("%d %d\n",maxpla,i);
		for(int i=1;i<=n;i++)
		a[i]-=minn;
		for(int i=n;i>1;i--) cout<<i<<" "<<i-1<<endl;
	}
}


Measured memory_bytes: 256
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
ll po(ll a, ll x,ll m){ if(x==0){return 1;}ll ans=1;ll k=1;  while(k<=x) {if(x&k){ans=((ans*a)%m);} k<<=1; a*=a; a%=m; }return ans; }
int main() {
 
 int a,b;
 cin>>a>>b;
 cout<<max(a+b,max(a-b,a*b)); 
return 0;
}

Measured memory_bytes: 256
x, k, d = map(int,input().split())

x = abs(x)

a = x//d

y = x - a*d
b = k - a

if k >= a:
    if b % 2 == 0:
        print(abs(y))
    elif abs(y - d) > abs(y - 2*d):
        print(abs(y-2*d))
    else:
        print(abs(y-d))
else:
    print(abs(x - k*d))

Measured memory_bytes: 9128
mod = int(1e9 + 7)
N = int(input())
C = [0] + sorted(list(map(int, input().split())), reverse=True)
ans = 0
for i in range(1, N+1):
    ans = (ans + C[i] * (i+1)) % mod
ans = ans * pow(2, 2*N-2, mod) % mod
print(ans)


Measured memory_bytes: 27108
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);
    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


ll dp[3030][3030];

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

    int N; cin >> N;
    string s; cin >> s;
    s = '0' + s;

    rep(j, N) dp[1][j] = 1;
    repr(i, 2, N+1){
        vector<ll> cum(N+5, 0);
        cum[0] = dp[i-1][0];
        repr(j, 1, N+1) { cum[j] = cum[j-1] + dp[i-1][j]; chmod(cum[j]); }
        rep(j, N-i+1){
            if(s[i-1] == '<') dp[i][j] = cum[N]-cum[j];
            else dp[i][j] = cum[j];
            chmod(dp[i][j]);
        }
    }

    

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

Measured memory_bytes: 71936
/**
        	C++14 (GCC 5.4.1)
**/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main(){
    string s;
    cin >> s;
    int count = 0;
    for(int i = 0; i < s.size();i++){
        if (s[i] == 'o'){
            count++;
        }
    }   
    count += 15 - s.size();

    if(count >= 8){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int nibai(int n,int m){
  for(int i = 0; m > i; i++){
    n *= 2;
  }
  return n;
}
int main(){
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  cout << nibai(max(max(A,B),C),K) + A+B+C-max(max(A,B),C) << endl;
}

Measured memory_bytes: 256
def mod_fact(N,p):
    mod=1
    for n in range(1,N+1):
        mod = (mod*(n%p))%p
        
    mod = mod%p
    
    return mod

X,Y = list(map(int,input().split()))

Z = X+Y

ans=0

if Z%3 != 0:
    ans=0
    
elif min(X,Y) >= Z//3:
    b=0
    for z in range(Z//3,((Z//3)*2)+1):
        if z == X:
            break
        b+=1
    a = Z//3 - b 
    
    p=(10**9)+7

    Z_= mod_fact(Z//3 , p)
    a_= mod_fact(a , p)
    b_= mod_fact(b , p)

    a_= pow(a_,p-2,p)
    b_= pow(b_,p-2,p)

    ans=(Z_*(a_*b_))%p
    
print(ans)


Measured memory_bytes: 63432
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
typedef long long ll;
#define pri(n) printf("%d\n",n)
#define lpri(n) printf("%lld\n",n);
#define rep(i,st,ed) for(int i=st;i<ed;i++)
#define var(n) int n; scn(n)
#define F first
#define S second 
#define pb(n) push_back(n)
const int N=55;
const ll M=1e9+7;
const ll inf=1e18;

void add(int& a,int b)
{
	a+=b;
	a%=M;
}

int main()
{



	ios;
	string s;
	int n;
	cin>>s>>n;
	int len = s.size();

	vector<vector<int>> dp(n,vector<int> (2));

	// the dp states are 
	// sum,flag  if(flag==1) 
	//				then we can put any digit 
	// 				at the current position
	// 			else the number is = k upto the current pos
	
	dp[0][0]=1; // indicates the formation of 0 but at POSITION -1
	for(int i=0;i<len;i++)
	{
		vector<vector<int>> temp(n,vector<int>(2));
		for(int sum = 0;sum<n;sum++)
		{
			// for strictly = k so far
			bool already = false;
			for(int dig = 0;dig<s[i]-48;dig++)
			{
				add(temp[(sum+dig)%n][1],dp[sum][0]);
			}
			add(temp[(sum+s[i]-48)%n][0],dp[sum][0]);

			already = true;

			for(int dig = 0;dig<10;dig++)
			{
				add(temp[(sum+dig)%n][1],dp[sum][1]);
			}
		}

		dp = temp;
	}

	int answer = (dp[0][0]+dp[0][1])%M;
	answer--;
	if(answer<0)
		answer+=M;
	cout<<answer<<endl;

}

Measured memory_bytes: 256
h,w= [int(i) for i in input().split()]
x=[[int(0)for i in range(w)]for j in range(h)]
z=[int(0 ) for i in range(w)]
for i in range(h):
    y=[int(k) for k in input().split()]
    for s in range(w):
        x[i][s]=y[s]
for s in range(w):
    z[s]=int(input())
for i in range(h):
    count=0
    for s in range(w):
        count=count+x[i][s]*z[s]
    print(count)

Measured memory_bytes: 7892
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	string s;
	cin>>s;
	bool flag=0;
	rep(i,s.size())
		if(s[i]=='7')flag=1;
	if(flag)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    in_arr(int, a, n);
    sort(a.begin(), a.end());
    cout << a[n - 1] - a[0] << endl;
    return 0;
}


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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}



int main()
{
    init();
    int n;
    cin >>n;
    if(n%1000 == 0){
        cout<<'0';
    }
    else {
        cout<<1000-(n%1000);
    }


}

Measured memory_bytes: 3600
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   998244353
#define PI 2*acos(0.0)
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

ll bigmod(ll x, ll p)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}

//=============================================ASIFAZAD==============================================//

int32_t main()
{
    io;
    int n, k;
    cin>>n>>k;
    vi inp(n);
    for(auto& x: inp) cin>>x;
    int dp[n+1];
    for(int i = 0; i< n; i++)
        dp[i] = INT_MAX;
    dp[n-1] = 0;
    for(int i = n-2; i>= 0;i--)
        for(int j = i+1; j <= min(i+k, n-1); j++)
            dp[i] = min(dp[i], dp[j] + abs(inp[i] - inp[j]));
    cout<<dp[0];
    return 0;
}


Measured memory_bytes: 4052
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

int main() {
  ll N;

  cin >> N;

  deque<ll> deq;
  for (int i = 1; i <= N; i++) {
    ll tmp;
    cin >> tmp;
    if (i % 2 == 1) {
      deq.emplace_back(tmp);
    } else {
      deq.emplace_front(tmp);
    }
  }

  string ans;
  if (N % 2 == 0) {
    for (int i = 0; i < N; i++) {
      ans += to_string(deq[i]);
      if (i < N - 1) ans += " ";
    }
  } else {
    for (int i = 0; i < N; i++) {
      ans += to_string(deq[N - 1 - i]);
      if (i < N - 1) ans += " ";
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5892
from sys import stdin
N,M=[int(x) for x in stdin.readline().rstrip().split()]
data=[ [] for _ in range(N)]
for i in range(M):
    P,Y=[int(x) for x in stdin.readline().rstrip().split()]
    data[P-1].append((Y,i))
ans=[0]*(M)
for ind_pre,j in enumerate(data):
    for ind_cit,k in enumerate(sorted(j)):
        ans[k[1]] = str(ind_pre+1).zfill(6) + str(ind_cit+1).zfill(6)
for l in ans:
  print(l)

Measured memory_bytes: 35888
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;

struct CHT{
	using D = ll;
	typedef pair<D,D> P;
	vector<P> deq;
	int s,sd,t;
	void init(int N){
		deq.resize(N);
		s=0,sd=0,t=0;
	}
	void add(D a,D b){		//add ax+b     a:(広義)単調減少!!!
		b=-b;
		P p(a,b);
		while(s+1<t&&check(deq[t-2],deq[t-1],p)) t--;
		deq[t++]=p;
	}
	D incr_query(D x){		//x:単調増加の時,これを繰り返し呼ぶ(間にaddが挟まるのはOK)
		while(s+1<t&&f(deq[s],x)>=f(deq[s+1],x)) s++;
		return f(deq[s],x);
	}
	D decr_query(D x){		//x:単調減少の時,これを繰り返し呼ぶ(間にaddが挟まるのはOK)
		x=-x;
		if(sd>=t) sd=t-1;
		while(sd+1<t&&f(deq[sd],x)>=f(deq[sd+1],x)) sd++;
		while(sd>0&&f(deq[sd],x)>f(deq[sd-1],x)) sd--;
		return -f(deq[sd],x);
	}
	D query(D x){
		x=-x;
		int lb=s-1,ub=t-1;
		while(ub-lb>1){
			int m=(lb+ub)/2;
			if(isright(deq[m],deq[m+1],x)) lb=m;
			else ub=m;
		}
		return -f(deq[ub],x);
	}

	bool isright(P& a,P& b,D x){
		return f(a,x)>=f(b,x);
	}
	bool check(P& a,P& b,P& c){
		return (b.fs-a.fs)*(c.sc-b.sc)>=(b.sc-a.sc)*(c.fs-b.fs);
	}
	D f(P &p,int x){
		return p.fs*x+p.sc;
	}
}cht;

ll inf=1e18;
const int MN=300000;
int N;
ll T[MN];

ll le[MN+1],ri[MN+1];

ll notuse[MN];
ll use[MN];

void calc(int L,int R){
	if(L==R) return;
	int m=(L+R)/2;
	
	//L<=j<=m<=p<i<=R
	cht.init(m-L+1);
	for(ll j=L;j<=m;j++) cht.add(-j,le[j]+(j*j-j)/2);
	ll mx=-inf;
	for(ll i=R;i>=m+1;i--){
		ll val=cht.query(i)+(i*i+i)/2+ri[N-i];
		chmax(mx,val);
		chmax(use[i-1],mx);
	}

	//L<=j<=p<m<i<=R
	cht.init(R-m);
	for(ll i=m+1;i<=R;i++) cht.add(-i,ri[N-i]+(i*i+i)/2);
	mx=-inf;
	for(ll j=L;j<m;j++){
		ll val=cht.query(j)+(j*j-j)/2+le[j];
		chmax(mx,val);
		chmax(use[j],mx);
	}

	calc(L,m);
	calc(m+1,R);
}
int main(){
	cin>>N;
	rep(i,N) cin>>T[i];

	cht.init(N);
	le[0]=0;
	for(ll i=0;i<N;i++){
		cht.add(-i,le[i]+(i*i-i)/2);
		le[i+1]=max(le[i]+T[i],cht.decr_query(i+1)+(i+1)*(i+2)/2);
	}
	cht.init(N);
	ri[0]=0;
	for(ll i=0;i<N;i++){
		cht.add(-i,ri[i]+(i*i-i)/2);
		ri[i+1]=max(ri[i]+T[N-1-i],cht.decr_query(i+1)+(i+1)*(i+2)/2);
	}
	
	rep(i,N) notuse[i]=le[i]+T[i]+ri[N-1-i];

	ll sum=0;
	rep(i,N) sum+=T[i];

	calc(0,N);

//	rep(i,N) printf("use[%d]=%lld\n",i,use[i]);
//	rep(i,N) printf("notuse[%d]=%lld\n",i,notuse[i]);
	

	int M;
	cin>>M;
	rep(i,M){
		int p;
		ll x;
		cin>>p>>x;
		p--;
		ll ans=max(use[p],notuse[p]-T[p]+x);
		cout<<ans-(sum-T[p]+x)<<endl;
	}
}


Measured memory_bytes: 18944
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

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

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class AOddsOfOddness {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      int r = (n+1)/2;
      cout << setprecision(10) << fixed << (double)r/n << endl;
    }
};

signed main() {
  AOddsOfOddness solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String input1 = sc.nextLine();
		String[] input2 = sc.nextLine().split(" ");

		int count = 0;

		for (int i = 0; i < input2.length; i++) {
			if((i+1)%2 != 0) {
				if (Integer.parseInt(input2[i]) %2 != 0) {
					count++;
				}
			}
		}

		System.out.println(count);


//
//		int num1 = Integer.parseInt(input[0]);
//		int num2 = Integer.parseInt(input[1]);
//		int num3 = Integer.parseInt(input[2]);
//
//		int count = 0;
//
//		for (int i = num1 ; i < num2+1; i++) {
//			if(i % num3 == 0) {
//				count++;
//			}
//		}
//
//		System.out.println(count);



	}

}


Measured memory_bytes: 35724
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define ALL(v) (v).begin(), (v).end()
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(void){
    // Your code here!
    int N;
    cin >> N;
    vector<pair<int,int>> ans(N);
    
    int a;
    for(int i = 0; i < N ; i++){
        cin >> a;
        ans[i]=make_pair(i+1,a);
    }
    sort(ALL(ans), compare_by_b);
    for(int i = 0; i < N-1 ; i++){
        cout << ans[i].first << " ";
    }
    cout <<ans[N-1].first<< endl;
}


Measured memory_bytes: 1664
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int m = parseInt(sc.next());
		int q = parseInt(sc.next());
		int[] a = new int[q];
		int[] b = new int[q];
		int[] c = new int[q];
		int[] d = new int[q];
		for (i = 0; i < q; i++) {
			a[i] = parseInt(sc.next());
			b[i] = parseInt(sc.next());
			c[i] = parseInt(sc.next());
			d[i] = parseInt(sc.next());
		}
		sc.close();
		int[] aa = new int[10+1];
		Arrays.fill(aa, 1);
		int max=0;
		for (aa[1] = 1; aa[1] <= m; aa[1]++) {
			for (aa[2] = aa[1]; aa[2] <= m; aa[2]++) {
				for (aa[3] = n<3?m:aa[2]; aa[3] <= m; aa[3]++) {
					for (aa[4] = n<4?m:aa[3]; aa[4] <= m; aa[4]++) {
						for (aa[5] = n<5?m:aa[4]; aa[5] <= m; aa[5]++) {
							for (aa[6] = n<6?m:aa[5]; aa[6] <= m; aa[6]++) {
								for (aa[7] = n<7?m:aa[6]; aa[7] <= m; aa[7]++) {
									for (aa[8] = n<8?m:aa[7]; aa[8] <= m; aa[8]++) {
										for (aa[9] = n<9?m:aa[8]; aa[9] <= m; aa[9]++) {
											for (aa[10] = n<10?m:aa[9]; aa[10] <= m; aa[10]++) {
												int tmp=0;
												for (j = 0; j < q; j++) {
													if(aa[b[j]]-aa[a[j]]==c[j])tmp+=d[j];
												}
												//				out.println(Arrays.toString(aa));
												//				out.println(tmp);
												if(max<tmp)max=tmp;
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		out.println(max);
	}
}


Measured memory_bytes: 28508
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (A, B, K) = read!(usize, usize, usize);
    let M = max(A, B) + 1;

    let mut ds = vec![false; M];
    for d in 1..M {
        if A % d == 0 && B % d == 0 {
            ds[d] = true;
        }
    }

    let mut k = K;
    let mut d = 0;
    for i in (0..M).rev() {
        if ds[i] {
            d = i;
            k -= 1;
            if k == 0 {
                break;
            }
        }
    }

    println!("{}", d)
}


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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define for1(i, a, b) for (int i = (int)a; i < (int)(b); ++i)
#define rfor1(i, a, b) for (int i=(int)b-1;i>=(int)a;i--)
#define for2(i, a, b) for (int i = (int)a; i <= (int)(b); ++i)
#define for3(i, a, b) for (int i = (int)a; i < (int)(b); i=i+2)
#define for4(i, a, b) for (int i = (int)a; i <= (int)(b); i=i+2)
#define tc(t) int t; cin>>t; while(t--)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    cout << (e - a <= k ? "Yay!" : ":(") << "\n";
}









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

void solve() {
  int d, t, s; cin >> d >> t >> s;
  cout << (d <= t * s ? "Yes" : "No") << endl;
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 3620
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
template<typename T>
T minch(T& l, T r) {
    return l = min(l, r);
}
template<typename T>
T maxch(T& l, T r) {
    return l = max(l, r);
}
template<typename T>
void output(const T& val) {
    cout << val << endl;
}
template<typename T>
void output(const vector<T>& vec, const bool newline = false) {
    for (const T& val : vec)cout << val << (newline ? '\n' : ' '); cout << endl;
}
template<typename T>
void output(const vector<vector<T>>& mat) {
    for (const auto& row : mat)output(row);
}
// ============ template finished ============

vector<vector<int>> solve(vector<string> s) {
    const int H = s.size(), W = s.front().size();
    vector<vector<int>> dp(H, vector<int>(W, INF));
    dp[0][0] = s[0][0] == '#' ? 1 : 0;
    rep(h, H)rep(w, W) {
        if (h > 0) {
            minch(dp[h][w], dp[h - 1][w] + (s[h - 1][w] == '.'&&s[h][w] == '#' ? 1 : 0));
        }
        if (w > 0) {
            minch(dp[h][w], dp[h][w - 1] + (s[h][w - 1] == '.'&&s[h][w] == '#' ? 1 : 0));
        }
    }
    return dp;
}

vector<vector<int>> solve2(vector<string> s) {
    const int H = s.size(), W = s.front().size();
    vector<vector<int>> dp(H, vector<int>(W, INF));
    dp[H - 1][W - 1] = s[H - 1][W - 1] == '#' ? 1 : 0;
    for (int h = H - 1; h >= 0; h--)for (int w = W - 1; w >= 0; w--) {
        if (h < H - 1) {
            minch(dp[h][w], dp[h + 1][w] + (s[h + 1][w] == '.'&&s[h][w] == '#' ? 1 : 0));
        }
        if (w < W - 1) {
            minch(dp[h][w], dp[h][w + 1] + (s[h][w + 1] == '.'&&s[h][w] == '#' ? 1 : 0));
        }
    }
    return dp;
}

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    rep(h, H)cin >> s[h];
    auto t = s;
    auto dp1 = solve(s);
    auto dp1rev = solve2(s);
    for (auto& row : t)for (auto& col : row) {
        col = col == '#' ? '.' : '#';
    }
    auto dp2 = solve(t);
    auto dp2rev = solve2(t);


    int res = min(dp1.back().back(), dp2.back().back() + 1);
    rep(h, H)rep(w, W) {
        if (h < H - 1) {
            int gap1 = s[h][w] == '#' && t[h + 1][w] == '#' ? -1 : 0;
            int gap2 = t[h][w] == '#' && s[h + 1][w] == '#' ? -1 : 0;
            minch(res, dp1[h][w] + dp2rev[h + 1][w] + 1 + gap1);
            minch(res, dp2[h][w] + dp1rev[h + 1][w] + 1 + gap2);
        }
        if (w < W - 1) {
            int gap1 = s[h][w] == '#' && t[h][w + 1] == '#' ? -1 : 0;
            int gap2 = t[h][w] == '#' && s[h][w + 1] == '#' ? -1 : 0;
            minch(res, dp1[h][w] + dp2rev[h][w + 1] + 1 + gap1);
            minch(res, dp2[h][w] + dp1rev[h][w + 1] + 1 + gap2);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 512
n=int(input())
ts = list(map(int,input().split()))
As = list(map(int,input().split()))
tr = [0]*n
ar = [0]*n
ct = 0
ca = 0
for i in range(n):
    if ct!=ts[i]:
        tr[i]=(ts[i],ts[i])
        ct=ts[i]
    else:
        tr[i]=(1,ts[i])
    if ca!=As[n-i-1]:
        ar[n-i-1]=(As[n-i-1],As[n-i-1])
        ca=As[n-i-1]
    else:
        ar[n-i-1]=(1,As[n-i-1])
#print(tr)
#print(ar)
ans=1
for i in range(n):
    if tr[i][0]==1 and ar[i][0]==1:
        ans=(ans*min(tr[i][1],ar[i][1]))%1000000007
    elif tr[i][0]==1 and ar[i][0]>1:
        if tr[i][1]<ar[i][1]:
            print(0)
            break
    elif tr[i][0]>1 and ar[i][0]==1:
        if tr[i][1]>ar[i][1]:
            print(0)
            break
    else:
        if tr[i][0]!=ar[i][0]:
            print(0)
            break
else:
    print(ans%1000000007)


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

int main(){
    int s,a,b;
    cin >> s;

    a = s % 100;
    s -= a;
    b = s / 100;

    if(0 < a && a < 13 && 0 < b && b < 13){
        cout << "AMBIGUOUS" << endl;
    }else if(0 < a && a < 13){
        cout << "YYMM" << endl;
    }else if(0 < b && b < 13){
        cout << "MMYY" << endl;
    }else{
        cout << "NA" << endl;
    }
}

Measured memory_bytes: 256
from math import gcd
def lcm(x,y):
    return x*y//gcd(x,y)
def cnt(x):
    i = 0
    while x%2 == 0:
        x = x//2
        i += 1
    return i 
n,m = map(int,input().split())
a = list(map(int,input().split()))
memo = cnt(a[0])
for i in range(n):
    if cnt(a[i]) != memo:
        print(0)
        quit()
    a[i] = a[i]//2

t = 1
for i in range(n):
    t = lcm(t,a[i])
print(m//t-m//(2*t))

Measured memory_bytes: 20448
#include<bits/stdc++.h>
using namespace std;
int cost[20], A[20][20];
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m, x;
	cin >> n >> m >> x;
	for (int i = 0; i < n; ++i) {
		cin >> cost[i];
		for (int j = 0; j < m; ++j) {
			cin >> A[i][j];
		}
	}
	int answer = 2e9;
	for (int i = 0; i <= (1 << n) - 1; ++i) {
		int B[20] = {};
		int C = 0;
		for (int j = 0; j < n; ++j) {
			if ((i & (1 << j)) == (1 << j)) {
				C += cost[j];
				for (int k = 0; k < m; ++k) {
					B[k] += A[j][k];
					//cout << B[k] << " ";
				}
				//cout << '\n';
			}
		}
		bool yes = true;
		//cout << i << '\n';
		for (int j = 0; j < m; ++j) {
			if (B[j] < x) {
				yes = false;
			}
		//	cout << B[j] << " " ;
		}
		//cout << '\n';
		if (yes == true) {
			answer = min(answer, C);
			//cout << i << '\n';
		}
	}
	if (answer == 2e9) {
		answer = -1;
	}
	cout << answer;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

int PRECISION = 7;

vector<pair<int,int>> points;

double dis (pair<int,int> a, pair<int, int> b) {
    double x = abs(a.first-b.first);
    double y = abs(a.second-b.second);

    return sqrt(x*x+y*y);
}


double len(vector<int> path) {
    double len = 0;
    for (int i = 0; i < points.size()-1; i++)
        len += dis(points[path[i]], points[path[i+1]]);
    return len;
}

double permute(int idx, vector<bool> visited, vector<int> records) {

    if (idx == visited.size()) {
        return len(records);
    }

    double total = 0;

    for (int i = 0; i < visited.size(); i++) {
        if (!visited[i]) {
            records.push_back(i);
            visited[i] = true;
            total += permute(idx+1, visited, records);
        
            records.pop_back();
            visited[i] = false;
        }
    }

    return total;
}

int sum(int num) {
    int nums = 1;
    for (int i = 1; i <= num; i++)
        nums *= i;
    return nums;
}

int main(){

    int N;
    cin >> N;

    points = vector<pair<int,int>>(N);

    for (int i = 0; i < N; i++)
        cin >> points[i].first >> points[i].second;
   
    vector<bool> visited(N, false);

    double total = permute(0, visited, vector<int>());
 
    double avg = total / sum(N);

    cout << setprecision(PRECISION) << fixed << avg << "\n"; 

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static List<int[]> list = new ArrayList<>();
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int Q = sc.nextInt();
        List<int[]> arList = new ArrayList<>();
        for (int i = 0; i < Q; i++) {
            int[] ar = new int[4];
            for (int j = 0; j < ar.length; j++) {
                ar[j] = sc.nextInt();
            }
            arList.add(ar);
        }
        createP(N, M, 0, new int[N], 1);
        long ans = 0;
        for (int i = 0; i < list.size(); i++) {
            int[] A  = list.get(i);
            long count = 0;
            for (int[] ar : arList) {
                int ai = ar[0];
                int bi = ar[1];
                if ((A[bi-1] - A[ai-1]) == ar[2]) {
                    count += ar[3];
                }
            }
            if (ans < count) {
                ans = count;
            }
        }
        System.out.println(ans);
    }
    
    private static void createP(int N, int M,int index, int[] ptn ,int min) {
        int[] clone = ptn.clone();
        if (N == index) {
            list.add(clone);
            return;
        } else {
            for (int i = min; i <= M; i++) {
                clone[index] = i;
                createP(N, M, index+1, clone, i);
            }
        }
    }
}

Measured memory_bytes: 57804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
      a = a * a % mod;
      n >>= 1;
    }
        return res;
}

long long modinv(long long a,long long mod){
  return modpow(a,mod-2,mod);
}

long long int modfact(long long int n,long long int mod){
  if(n){
    return n*modfact(n-1,mod)%mod;
    }else{
      return 1;
    }
}
int main() {
  cout << fixed << setprecision(10);
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll ans = 0;
  rep(i,60){
    ll p = 0;
    rep(j,n){
      if(a[j]&(1LL<<i)){
        p++;
      }
    }
    ans+=p*(n-p)%MOD*modpow(2,i,MOD)%MOD;
    
    ans%=MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std ;
map < string , bool > mp ;
int n , ans ; string x ;
signed main () {
    cin >> n ;
    for ( int i = 1 ; i <= n ; i ++ ) {
        cin >> x ;
        if ( mp[ x ] ) continue ;
        ans ++ ;
        mp[ x ] = 1 ;
    }
    cout << ans << endl ;
    return 0 ;
}

Measured memory_bytes: 19224
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <memory>
#include <vector>
#include <string>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <cmath>
#include <deque>
#include <map>
#include <set>
#include <ios>

#if __cplusplus >= 201103L
#include <random>
#include <thread>
#include <mutex>
#include <array>
#include <tuple>
#endif

using namespace std;

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

    int N;
    cin >> N;
    vector<int> stones(N);
    for (int i = 0; i < N; ++i) {
        cin >> stones[i];
    }
    vector<int> dp(N);
    dp[0] = 0;
    dp[1] = abs(stones[1] - stones[0]);
    for (int i = 2; i < N; ++i) {
        dp[i] = min(
            dp[i - 1] + abs(stones[i] - stones[i - 1]),
            dp[i - 2] + abs(stones[i] - stones[i - 2])
        );
    }
    cout << dp[N - 1] << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
    string a,b,c;
    cin >> a >> b >> c;

    char tmp = a[0];
    int aaa = 0,bbb = 0,ccc = 0;
    for(int i = 0; i <= 300; i++){
        if(tmp == 'a'){
            tmp = a[aaa];
            aaa++;
            if(aaa > a.size()){
                cout << 'A' << endl;
                return 0;
            }
        }
        else if(tmp == 'b'){
            tmp = b[bbb];
            bbb++;
            if(bbb > b.size()){
                cout << 'B' << endl;
                return 0;
            }
        }
        else if(tmp == 'c'){
            tmp = c[ccc];
            ccc++;
            if(ccc > c.size()){
                cout << 'C' << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 888
a,b,x=list(map(int,input().split()))
import math
import sys
if a*a*b==x:
  print(0.0000000000)
  sys.exit()

if a*a*b/2<=x:
  kakudo=a*a*a/2/(a*a*b-x)
  print(90-math.degrees(math.atan(kakudo)))
else:
  kakudo=2*x/(a*b*b)
  print(90-math.degrees(math.atan(kakudo)))



Measured memory_bytes: 3188
#include<stdio.h>
int main(){
	int n= 0;//??\???
	int i= 0, j= 0,k= 0,l= 0;//?????????
	int b= 0;//?£? 
	int f= 0;//???
	int r= 0;//??????
	int v= 0;//?????°
	int a[4][3][10] = {0}; // [b?£?][f???][r??¨?±?] [={0}]?????????
	
	
	
	scanf("%d",&n);
	
	for(i= 0; i < n; i++){
	scanf("%d %d %d %d",&b ,&f ,&r ,&v);
	a[b-1][f-1][r-1]+= v;
	
	}
	
	for(j= 0; j< 4; j++){
		for(k = 0; k< 3; k++){
			for(l= 0; l< 10;l++){
				printf(" %d",a[j][k][l]);
			}
			printf("\n");
		}
		
	if(j != 3){
		printf("####################\n");
		}
	}
	
	
	/*for(h = 1; h <= 15; h++){
			if(h%4 == 0){
				for(w = 0; w < 20; w++){
					printf("#");
				}
				printf("\n");
			}else{
				for(w = 0; w < 10; w++){
					printf( " %d",0);
				}
				printf("\n");
			}
	}*/
	
	
	
  return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, i, j, k, a, b, best = 0;
	cin >> n;
	vector<pair<long long, long long>> p(n);
	for (i = 0; i < n; i++) cin >> p[i].first >> p[i].second;
	sort(p.begin(), p.end());
	vector<long long> x(n), y(n);
	for (i = 0; i < n; i++) {
		x[i] = p[i].first;
		y[i] = p[i].second;
	}
	set<pair<long long, long long>> lx, rx, ly, ry;
	for (i = 0; i < n; i++) {
		rx.insert({ x[i], i });
		ry.insert({ y[i], i });
	}

	for (i = 0; i < n - 1; i++) {
		rx.erase({ x[i], i });
		ry.erase({ y[i], i });
		lx.insert({ x[i], i });
		ly.insert({ y[i], i });

		a = max(0LL, ly.begin()->first - lx.rbegin()->first + 1);
		b = max(0LL, ry.begin()->first - rx.rbegin()->first + 1);
		best = max(best, a + b);
	}

	rx.clear(); 
	ry.clear();
	for (i = 0; i < n; i++) {
		rx.insert({ x[i], i });
		ry.insert({ y[i], i });
	}

	for (i = 0; i < n; i++) {
		rx.erase({ x[i], i });
		ry.erase({ y[i], i });

		a = max(0LL, y[i] + 1 - x[i]);
		b = max(0LL, ry.begin()->first - rx.rbegin()->first + 1);
		best = max(best, a + b);

		rx.insert({ x[i], i });
		ry.insert({ y[i], i });
	}


	cout << best << "\n";

	return 0;
}


Measured memory_bytes: 28416
#include <iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
int main(void){
    
    int n,m;
    cin >>n>>m;
    int L[n+1],R[n+1];
    for(int i=0;i<n+1;i++){
        L[i]=0;
        R[i]=0;
    }
    for (int i=0;i<m;i++){
        int l,r;
        cin >>l>>r;
        L[l]++;
        R[r]++;
    }
    
    for(int i=1;i<n+1;i++){
        L[i]+=L[i-1];
    }
    for(int i=n-1;i>=0;i--){
        R[i]+=R[i+1];
    }
    int idxl=n,idxr=0;
    for(int i=1;i<n+1;i++){
        if(L[i]==m){
            idxl=i;
            // cout << "l:"<<idxl<<endl;
            break;
        }
    }
    for(int i=n;i>=0;i--){
        if(R[i]==m){
            idxr=i;
            // cout << "r:"<<idxr<<endl;
            break;
        }
    }    
    int ans = idxr-idxl+1;
    if(ans<=0){
        cout <<0<<endl;
    }else{
        
        cout<<idxr-idxl+1<<endl;
    }
}


Measured memory_bytes: 1024