akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

ll binpow(ll a, ll b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

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

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2];
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
int main(){
    string s;
    ll k;
    cin>>s>>k;
    int count=0;
    for(int i=0;i<s.size();i++){
        if(s.at(i)!='1')break;
        count++;
    }
    if(k<=count){
        cout<<'1'<<endl;
    }
    else {
        ll x=0;
        while(x<s.size()&&s.at(x)=='1'){
            x++;
        }
        cout<<s.at(x)<<endl;
    }
}

Measured memory_bytes: 384
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int a[100];
vector<int> b;
int main()
{
	int i,j,k,n,m,x,y,l,sum,ans=0;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<=min(n,k);i++)
	{
		for(j=0;j<=min(n,k);j++)
		{
			if(i+j>n||i+j>k)
			{
				break;
			}
			b.clear();
			for(l=0;l<i;l++)
			{
				b.push_back(a[l]);
			}
			for(l=0;l<j;l++)
			{
				b.push_back(a[n-1-l]);
			}
			sort(b.rbegin(),b.rend());
			sum=0;
			for(l=0;l<i+j;l++)
			{
				sum+=b[l];
			}
			ans=max(ans,sum);
			x=k-i-j;
			y=i+j-1;
			while(x>0&&b.size()>0&&b[y]<0)
			{
				sum-=b[y];
				y--;
				x--;
			}
			ans=max(ans,sum);
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int a[3] = {0,0,0};
	int check5 = 0, check7 = 0;

	for (int i = 0; i < 3; i++) {
		scanf("%d", &a[i]);
	}
	for (int i=0; i < 3; i++)
	{
		if (a[i] == 5)
		{
			check5 += 1;
		}

		if (a[i] == 7)
		{
			check7 += 1;
		}
	}

	if (check5 == 2 && check7 == 1) 
	{
		printf("YES");
	}
	else {
		printf("NO");
	}
	



	return 0;
}

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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    clock_t clk = clock();

    int n; cin >> n; string s; cin>>s;

    int res = 0;
    FOR(i, 0, n - 2) {
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') res++;
    }
    cout<<res;
    cerr << endl << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	
	int x;
	
	public void solve(){
    Scanner sc=new Scanner(System.in);
		
		x=sc.nextInt();
		
		System.out.println(x*x*x);
	}
	public static void main(String[] args){
        Main obj =new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17296
#include <cstdio>

using namespace std;

int main(){
    int n;
    int a[212345];
    scanf("%d", &n);
    for(int i=0; i < n; i++){
        scanf("%d", a+i);
    }

    int searching = 1;
    int cnt = 0;
    for(int i=0; i < n; i++){
        if(a[i] == searching){
            searching++;
        }else{
            cnt++;
        }
    }
    if(searching == 1){
        printf("-1\n");
    }else{
        printf("%d\n", cnt);
    }
    return 0;
}

Measured memory_bytes: 896
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int x = sc.nextInt();
    int[] a = new int[N];
    int[] b = new int[N];

    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
      b[i] = a[i];
    }

    sc.close();
    
    for (int i = 0; i < N - 1; i++) {
      
      if (b[i] > x) {
        b[i] = x;
      }

      if (b[i] + b[i + 1] > x) {
        b[i + 1] = b[i + 1] - (b[i] + b[i + 1] - x);  
      }

    }

    long min = 0;

    for (int i = 0; i < N; i++) {
      min += a[i] - b[i];
    }    

    System.out.println(min);

  }

}

Measured memory_bytes: 51908
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int H, W, N;
	cin >> H >> W >> N;
	int m=max(H, W);
	cout << (N+m-1)/m << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int i,n,v[20],c[20];
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%d",&v[i]);
  }
  for(i=0;i<n;i++) {
    scanf("%d",&c[i]);
  }
  int r=0;
  for(i=0;i<n;i++) {
    if(v[i]>c[i] )r+=v[i]-c[i];
  }
  printf("%d\n",r);
  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

// Inserted snippets: euclid, io, modint, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
ll euclid(ll a, ll b, ll &x, ll &y) {
	if (b) { ll d = euclid(b, a % b, y, x);
		return y -= a/b * x, d; }
	return x = 1, y = 0, a;
}
template<ll MOD = 1'000'000'007>
struct Mod {
	ll val;
	Mod() : val(0) {}
	Mod(ll xx) {
		if (0 <= xx && xx < MOD) val = xx;
		else val = (xx % MOD + MOD) % MOD;
	}
	Mod operator+=(Mod b) { if ((val += b.val) >= MOD) val -= MOD; return *this; }
	Mod operator-=(Mod b) { if ((val += MOD - b.val) >= MOD) val -= MOD; return *this; }
	Mod operator*=(Mod b) { (val *= b.val) %= MOD; return *this; }
	Mod operator/=(Mod b) { (val *= b.inv().val) %= MOD; return *this; }
	Mod operator+(Mod b) const { Mod<MOD> tmp(*this); return tmp += b; }
	Mod operator-(Mod b) const { Mod<MOD> tmp(*this); return tmp -= b; }
	Mod operator*(Mod b) const { Mod<MOD> tmp(*this); return tmp *= b; }
	Mod operator/(Mod b) const { Mod<MOD> tmp(*this); return tmp /= b; }
	Mod& operator++() { *this += 1; return *this; }
	Mod& operator--() { *this -= 1; return *this; }
	Mod operator++(int) { Mod<MOD> tmp(*this); operator++(); return tmp; }
	Mod operator--(int) { Mod<MOD> tmp(*this); operator--(); return tmp; }
	Mod inv() const {
		ll v, y, g = euclid(val, MOD, v, y);
		assert(g == 1); return Mod((v + MOD) % MOD);
	}
	Mod operator^(ll p) const {
		ll r = 1, b = val;
		for (; p; p >>= 1, b = b * b % MOD) if (p & 1) r = r * b % MOD;
		return Mod(r);
	}
	friend istream& operator>>(istream &is, Mod& mod) {
		ll tmp; is >> tmp;
		mod = Mod<MOD>(tmp);
		return is;
	}
	friend ostream& operator<<(ostream &os, const Mod& mod) {
		return os << mod.val;
	}
};
// End snippets

typedef Mod<998244353> modint;

int a, b, c, d;
int dp[3005][3005];

modint solve(ll i, ll j) {
	if (i < a || j < b) return 0;
	if (dp[i][j] != -1) return modint(dp[i][j]);
	return dp[i][j] = (solve(i - 1, j) * j + solve(i, j - 1) * i - solve(i - 1, j - 1) * (i * j - i - j + 1)).val;
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	rep(i, 0, 3005) rep(j, 0, 3005) dp[i][j] = -1;

	int a, b, c, d; read(a, b, c, d);
	dp[a][b] = 1;
	write(solve(c, d));
}


Measured memory_bytes: 39124
#include <bits/stdc++.h>
#define len(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define chmax(x, v) x = max((x), (v))
#define chmin(x, v) x = min((x), (v))
using namespace std;
#define ll long long

/*string mycmp(string a,string b)
{
    string p=a,q=b;
    string x=p.append(q),y=b.append(a);
    //cout<<p<<"p "<<x<<"x "<<q<<"q "<<y<<endl;
    if(x.compare(y)>0)
        return x;
    else
        return y;
}

string largestNumber(const vector<int> &A) {
    vector<int>v;
    if(A.size()==0)
        return "";
    int t=-1;
    for(int i=0;i<A.size();i++){
        t+=A[i];
        v.push_back(to_string(A[i]));
    }
    t+=1;
    if(t==0)
        return "0";
    sort(v.begin(),v.end());
}

*/
int main() {
	/*ios::sync_with_stdio(false);
	cin.tie(0);*/
    int n,x,t;
    cin>>n>>x>>t;
    int ans=(int)ceil(n/double(x));
    cout<<(ans*t)<<endl;
    //largestNumber(const vector<int> &A) {
    return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int, int> PII;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
int mod = 1000000007;

/*FUNCs=================================================*/
vi move1 = {0,0,1,-1};
vi move2 = {1,-1,0,0};

/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    string s; cin >> s;
    vi a(s.size());
    for(int i = 0; i < s.size()-1; ++i) {
        if(s[i]=='R'&&s[i+1]=='L') {
            int cnt = 0;
            for(int j = i; j >= 0; --j) {
                if(s[j]!='R') break;
                cnt++;
            }
            a[i] += (cnt+1)/2;
            a[i+1] += cnt/2;
            cnt = 0;
            for(int j = i+1; j < s.size(); ++j) {
                if(s[j]!='L') break;
                cnt++;
            }
            a[i+1] += (cnt+1)/2;
            a[i] += cnt/2;
        }
    }

    rep(i,s.size()) cout << a[i] << (i==s.size()-1? '\n' :' ');
}


Measured memory_bytes: 1104
#include <stdio.h>

int main(void){
    
    int h,m,s,S = 0;
    scanf("%d",&S);
    
    h = S / 3600;
    m = S % 3600 / 60;
    s = S % 60;
    printf("%d:%d:%d\n",h,m,s);

    return 0;

    }


Measured memory_bytes: 2724
#include <iostream>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    int n , a , b , s ;
    cin >> n >> a >> b ;
    s = n * a ;
    if (s > b){
        cout << b ;
    }
    else {
        cout << s ;
    }
    return 0;
}


Measured memory_bytes: 3532
import java.util.*;

public class Main{
	static public void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String str=sc.next();
		char ch1=str.charAt(0),ch2=str.charAt(1),ch3=str.charAt(2);
		
		if(ch1==ch2&&ch2==ch3&&ch1=='S'){
			System.out.println(0);
			return;
		}
		if(ch1==ch2&&ch2==ch3&&ch1=='R')System.out.println(3);
		else if(ch1=='R'){
			if(ch1==ch2)System.out.println(2);
			else System.out.println(1);
		}
		else if(ch3=='R'){
			if(ch2==ch3)System.out.println(2);
			else System.out.println(1);
		}
		else System.out.println(1);
		sc.close();
		return;
	}
}

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

using namespace std;


int main() {
  
     vector<pair<long int ,long int > > v;
     long int n,m,sum=0;
     scanf("%ld%ld",&n,&m);
     long int a[n],b[n],i;
     for(i=0;i<n;++i)
       {
           scanf("%ld%ld",&a[i],&b[i]);
           
           
           v.push_back(make_pair(a[i],b[i]));
           
       }
       
       sort(v.begin(),v.end());
       
       for(i=0;i<v.size();++i)
         {
             if(v[i].second<=m)
               {
                   sum+=v[i].first*v[i].second;
                   m-=v[i].second;
               }
               
              else
               {
                   sum+=v[i].first*m;
                   m=0;
               }
         }
         
         printf("%ld",sum);
    
   
    	return 0;
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin >> s >> t;
    bool jud=true;
    for(int i = 0; i < s.size(); i++) {
        if(s[i]!=t[i]) jud=false;
    }
    if(jud) cout << "Yes" << "\n";
    else    cout << "No" << "\n";
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int MaxN = 200003;
#define x0 Fuck_the_GCC_header_x0
#define y0 Fuck_the_GCC_header_y0
#define x1 Fuck_the_GCC_header_x1
#define y1 Fuck_the_GCC_header_y1
#define X first
#define Y second
int x0,x1,y0,y1,n,cnt;
#define M_PI 3.14159265358979323846
const double len=M_PI*20,len2=M_PI*10,len4=M_PI*5;
PII e[MaxN];
int a[MaxN],mn[MaxN];
 
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	cin >> x0 >> y0 >> x1 >> y1 >> n;
	if (x0>x1) {swap(x0,x1);swap(y0,y1);}
	cout << fixed << setprecision(15);
	cnt=0;
	for (int i=1;i<=n;++i) {
		int x,y;
		cin >> x >> y;
		if (x<min(x0,x1) || x>max(x0,x1) || y<min(y0,y1) || y>max(y0,y1)) continue;
		cnt++;
		e[cnt].first=x,e[cnt].second=y;
	}
	if (x1==x0) {
		double ans=(long long)abs(y1-y0)*100LL;
		for (int i=1;i<=cnt;++i) if (e[cnt].X==x1) ans=ans-20LL+len2;
		cout << ans << endl;
		return 0;
	}
	if (y1==y0) {
		double ans=(long long)abs(x1-x0)*100LL;
		for (int i=1;i<=cnt;++i) if (e[cnt].Y==y1) ans=ans-20LL+len2;
		cout << ans << endl;
		return 0;
	}
	sort(e+1,e+cnt+1);
	//if (x1<x0) reverse(e+1,e+cnt+1);
	if (y1<y0) for (int i=1;i<=cnt;++i) e[i].Y=2LL*y0-e[i].Y;
	for (int i=1;i<=cnt;++i) a[i]=e[i].Y;
	for (int i=1;i<=cnt;++i) mn[i]=0x7fffffff;
	mn[0]=0x80000000;
	int sum=0;
	for (int i=1;i<=cnt;++i) {
		int x=lower_bound(mn,mn+cnt+1,a[i])-mn;
		mn[x]=a[i];
		sum=max(sum,x);
	}
	double ans=100LL*(abs(x0-x1)+abs(y0-y1));
	ans=ans-20*sum+len4*sum;
 	if (sum==abs(x0-x1)+1||sum==abs(y0-y1)+1)
		ans=ans+len4;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
// Ala be zekrellah tatmaenolgholoob ...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F first
#define S second
#define MP make_pair
const int maxn = 1e6+9;
const ll mod = 1e9+7;

ll dp[maxn];

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	dp[0] = dp[1] = 1;
	ll sum = dp[0] + dp[1];
	for (int i = 2; i < maxn; i++) {
		dp[i] = (sum - dp[i - 2] + mod) % mod;
		sum = (sum + dp[i]) % mod;
	}
	ll n, res = 0;
	cin >> n;
	for (ll i = 1; i < n; i++) {
		res = (res + dp[i - 1] * min(i + 1, n - 1) % mod) % mod;
		res = (res + dp[i - 1] * (n - 1) % mod * (n - 1) % mod) % mod;
	}
	res = (res + dp[n - 1] * n % mod) % mod;
	cout << res << "\n";
}



Measured memory_bytes: 8192
from numpy import int64, searchsorted, count_nonzero

N, K, *A = map(int, open(0).read().split())
A = int64(A)

A.sort()

Minus, Zero, Plus = A[A < 0], A[A == 0], A[0 < A]

def is_ok(md):
    cnt = 0 if md < 0 else len(Zero) * N

    cnt += searchsorted(A, md // Plus, side='right').sum()
    cnt += (N - searchsorted(A, (-md - 1) // (-Minus), side='right')).sum()
    cnt -= count_nonzero(A * A <= md)

    return (cnt // 2 >= K)


ng, ok = -10 ** 18, 10 ** 18
while ok - ng > 1:
    md = (ok + ng) // 2
    if is_ok(md):
        ok = md
    else:
        ng = md

print(ok)

Measured memory_bytes: 32312
#define NAME "a"

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cctype>
#include <cassert>
#include <memory>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <iterator>

#define pb push_back
#define mp make_pair
#define frs first
#define snd second

using namespace std;

#ifdef WIN32
    #define lld "%I64d"
#else
    #define lld "%lld"
#endif

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 7;
const ll INFLONG = (ll) 1e18 + 7;
const double EPS = 1e-9;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<string> vs;

typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;

template <typename T>
T sqr(T a) {
    return a * a;
}

void solve() {
    ll n;
    scanf(lld, &n);
    string ans = "";

    while (n) {
        int k = (n - 1) % 26;
        ans += (char) ('a' + k);
        n = (n - 1) / 26;
    }

    reverse(ans.begin(), ans.end());
    puts(ans.c_str());
}

int main() {
    srand(time(0));

//    freopen(NAME".in", "r", stdin);
  //  freopen(NAME".out", "w", stdout);

    int T = 1;

    while (T--) {
        solve();
    }

//    printf("%.3lf\n", (double) clock() / CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 3688
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Takahashi Calendar
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int m, d;
  scanf("%d%d", &m, &d);

  int c = 0;
  for (int dd = 22; dd <= d; dd++) {
    int d1 = dd % 10, d10 = dd / 10;
    if (d1 >= 2 && d10 >= 2) {
      int p = d1 * d10;
      if (p >= 1 && p <= m) c++;
    }
  }

  printf("%d\n", c);
  return 0;
}


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

int main() {
	int a,b,k;
	
	cin>>a>>b>>k;
	
	vector <int> v;
	
	for(int i=1; i<=100; i++){
	    if(a%i==0 && b%i==0) v.push_back(i);
	}
// 	for(int i=0; i<v.size(); i++) cout<<v[i]<<" ";
	cout<<v[v.size()-k];
	return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
N = int(input())
a = list(map(int,input().split()))
import math
d = [[0] * W for _ in range(H)]

aidx = 0
didx = 0

while didx < H*W:
    idx = 0
    while idx < a[aidx]:
        d1 = math.ceil((didx+1)/W)-1
        if d1 % 2 == 1:
            d2 = W - 1 - didx % W
        else:
            d2 = didx % W
        d[d1][d2] = aidx+1
        idx += 1
        didx += 1
    aidx += 1
    
for i in range(H):
    print(' '.join(map(str,d[i])))

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

const int mod = 1e9+7;
const int INF = 2000000;

int main() {
    int a,b,H,M;
    double pi = acos(-1);
    cin >> a >> b >> H >> M;
    double bdig = 6*M;
    double adig = 30*H+30*(M/60.0);
    double dig = min(360-abs(adig-bdig),abs(adig-bdig));
    double ans = a*a+b*b-(2.0*a*b*cos(pi*dig/180.0));
    cout << fixed << setprecision(12) << sqrt(ans) << endl;
}


Measured memory_bytes: 4212
# frozen_string_literal: true

_n = gets.to_i
t = [0]
t << gets.split(' ').map!(&:to_i)
guess_t = t.flatten!.inject(:+)

drinks = []
gets.to_i.times do
  drinks << gets.split(' ').map!(&:to_i)
end

drinks.each do |p, x|
  boost = t[p] - x
  puts guess_t - boost
end


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

using namespace std;

#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, nQ;
int A[202020], B[202020], C[202020];

int uf[303030];

int root(int p)
{
	return uf[p] < 0 ? p : (uf[p] = root(uf[p]));
}
bool join(int p, int q)
{
	p = root(p);
	q = root(q);
	if (p == q) return false;
	uf[p] += uf[q];
	uf[q] = p;
	return true;
}

int main()
{
	scanf("%d%d", &N, &nQ);
	for (int i = 0; i < nQ; ++i) {
		scanf("%d%d%d", A + i, B + i, C + i);
	}
	for (int i = 0; i < N; ++i) uf[i] = -1;

	i64 ret = 0;
	priority_queue<pair<int, pair<int, int> > > Q;
	for (int i = 0; i < nQ; ++i) {
		Q.push({ -C[i],{ A[i], B[i] } });
		Q.push({ -C[i] - 1,{ B[i], (1 + A[i]) % N } });
	}
	while (!Q.empty()) {
		auto a = Q.top(); Q.pop();
		int cost = -a.first;
		int p = a.second.first, q = a.second.second;
		if (!join(p, q)) continue;
		ret += cost;
		Q.push({ -(cost + 2), {(p + 1) % N, (q + 1) % N} });

	}

	printf("%lld\n", ret);

	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector <int> p(n);
    int count=0;
    rep(i,n) cin>>p[i];
    sort(p.begin(),p.end());
    count=p[n/2]-p[n/2-1];
    cout<<count<<endl;
}


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

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

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> m(N);

    int sum = 0;
    int minv = 0;
    rep(i, N) {
        cin >> m.at(i);
        sum += m.at(i);
        if (i == 0) minv = m.at(i);
        else minv = min(minv, m.at(i));
    }

    int ans = X;
    int tmp;
    tmp = X - sum;
    tmp = tmp / minv;
    cout << N+tmp << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
 
int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x; cin >> x;
	for(ll i = -5e3; i <= 5e3; i++)
	{
		ll b5 = pow(i, 5);
		ll a = pow(x + b5, 0.2);
		if((ll) pow(a, 5) == x + b5)
		{
			cout << a << ' ' << i;
			return 0;
		}
	}
 
	return 0;
}

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

int main(){
	char s[1500];
	int data[26];
	int num;
	int i;
	char c;

	for(i=0; i< 26; i++)
		data[i] = 0;

	while(fgets(s, sizeof(s), stdin) != NULL){

		for(i=0; i< strlen(s); i++){
			if((s[i] >= 'a') && (s[i] <= 'z')){
				data[s[i] - 'a'] = data[s[i] - 'a'] + 1;
			}
			else if((s[i] >= 'A') && (s[i] <= 'Z')){
				data[s[i] - 'A'] = data[s[i] - 'A'] + 1;
			}
		}
	}
	for(i=0; i< 26; i++){
		printf("%c : %d\n", 'a' + i, data[i]);
	}


	return 0;

}


Measured memory_bytes: 2056
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <cmath>         // sqrt
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll, string> Tlls;

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b)
{
  // Eucledean algorithm
  while (a)
  {
    if (a < b)
    {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

// Least Common Multiple 最小公倍数
ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

// key: value of prime factor素因数分解
// value: number of prime factor
map<ll, ll> prime_factorization(ll n)
{
  map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

// 約数リスト約数の列挙
vector<ll> get_divisors(const ll n)
{
  vector<ll> divs;
  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++)
  {
    if (n % i == 0)
    {
      divs.push_back(i);
      if (i != n / i)
      {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

int main()
{
  ll N, K;
  cin >> N >> K;
  vector<ll> p(N);
  rep(i, N)
  {
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  ll ans = 0;
  rep(i, K)
  {
    ans += p.at(i);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    priority_queue<int, vector<int>, greater<int>> minpq;
    REP(i, 3){
        int a;
        cin >> a;
        minpq.push(a);
    }
    int top = minpq.top();
    minpq.pop();
    cout << minpq.top() + top << "\n";


    return 0;
}


Measured memory_bytes: 256
import itertools
import math

n = int(input())
towns = []
for _ in range(n):
    (x, y) = map(int, input().split())
    towns.append((x, y))

ave = 0
patterns = list(itertools.permutations(towns))
for path in patterns:
    distance = 0
    for i in range(1, len(path)):
        diff_x = path[i][0] - path[i-1][0]
        diff_y = path[i][1] - path[i-1][1]
        distance += math.sqrt(diff_x ** 2 + diff_y ** 2)
    ave += distance
print(ave / len(patterns))


Measured memory_bytes: 7972
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    use std::cmp::max;
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let a: i64 = scan(tokens);
    let b: i64 = scan(tokens);
    println!("{}", max(a + b, max(a - b, a * b)));
}


Measured memory_bytes: 4352
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <functional>
using namespace std;
using ll = long long;

int main() {
	ll X;
	cin >> X;
	ll t = 0;
	ll p = 0;

	while (X > p) {
		t++;
		p += t;

		if (X <= p) {
			cout << t << endl;
			break;
		}
	}
	return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

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

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll L; cin >> L;
	vll A(L); cin >> A;
	vvll dp(L+1, vll(5, LLINF));
	dp[0][0] = 0;
	for (int i = 0; i <= L; i++) {
		//0
		if (i < L) chmin(dp[i+1][0], dp[i][0]+A[i]);
		chmin(dp[i][1], dp[i][0]);
		//1
		if (i < L) chmin(dp[i+1][1], dp[i][1]+(A[i] ? (A[i]&1) : 2));
		chmin(dp[i][2], dp[i][1]);
		//2
		if (i < L) chmin(dp[i+1][2], dp[i][2]+ 1-(A[i]&1));
		chmin(dp[i][3], dp[i][2]);
		//3
		if (i < L) chmin(dp[i+1][3], dp[i][3]+(A[i] ? (A[i]&1) : 2));
		chmin(dp[i][4], dp[i][3]);
		//4
		if (i < L) chmin(dp[i+1][4], dp[i][4]+A[i]);
		/*
		for (int j = 0; j < 5; j++) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
		*/
	}
	cout << dp[L][4] << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 15872
import sys
readline = sys.stdin.readline

INF = 10**18+3

N, K = map(int, input().split())
X = list(map(int, readline().split())) + [INF]

left = [None]*N
r = 0

for i in range(N):
    while r < N and X[r+1] - X[i] < K:
        r += 1
    left[i] = (r, i)
left = [left]
nb = N.bit_length()
for _ in range(nb):
    res = [None]*N
    for idx in range(N):
        r, i = left[-1][idx]
        if r >= N-1:
            res[idx] = (N, None)
        else:
            r1, i1 = left[-1][r+1]
            if r1 == N:
                res[idx] = (N, None)
            else:    
                res[idx] = (r1, i+i1)
    left.append(res)

right = [None]*N
l = N-1

for i in range(N-1, -1, -1):
    while 0 < l and X[i] - X[l-1] < K:
        l -= 1
    right[i] = (l, i)
right = [right]
for _ in range(nb):
    res = [None]*N
    for idx in range(N):
        l, i = right[-1][idx]
        if l <= 0:
            res[idx] = (-1, None)
        else:
            l1, i1 = right[-1][l-1]
            if l1 == -1:
                res[idx] = (-1, None)
            else:    
                res[idx] = (l1, i+i1)
    right.append(res)


Q = int(readline())
Ans = [None]*Q
for qu in range(Q):
    l, r = map(int, readline().split())
    l -= 1

    vn = l
    li = 0
    ml = 0
    for j in range(nb-1, -1, -1):
        vf, ix = left[j][vn]
        if vf < r:
            vn = vf+1
            li += ix
            ml += 1<<j
        if vn >= r:
            break
    if vn < r:
        ml += 1
        li += vn
        
    
    
    l -= 1
    r -= 1
    vn = r
    ri = 0
    mr = 0
    for j in range(nb-1, -1, -1):
        vf, ix = right[j][vn]
        if l < vf:
            vn = vf-1
            ri += ix
            mr += 1<<j
        if vn <= l:
            break
    if l < vn:
        mr += 1
        ri += vn
        
    Ans[qu] = ri-li + ml

print('\n'.join(map(str, Ans)))

Measured memory_bytes: 329264
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
# define mp make_pair
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}

int main() {
  int n; cin >> n;
  vector<string> v(n);
  rep(i, n){
    cin >> v[i];
  }

  rep(i, n) sort(ALL(v[i]));
  sort(ALL(v));

  ll ans = 0, cnt = 1;
  rep(i, n-1){
    if(v[i]==v[i+1]) cnt++;
    else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  ans += cnt * (cnt - 1)/ 2;
  cout << ans << endl;
}


Measured memory_bytes: 6408
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;


bool is_ok(int64 N,int64 K){
    while(N%K==0){
        N/=K;
    }
    return N%K==1;
}

//約数列挙
vector<int64> divs(int64 n){
    int64 copy = n;
    vector<int64> res;
    for(int64 i=1;i*i<=copy;i++){
        if(n%i==0){
            res.push_back(i);
            if(i*i!=n) res.push_back(n/i);
        }
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 N;
    cin >> N;
    int ans = 1;
    set<int64> exist;
    for(int64 K=2;K*K<=N;K++){
        if(is_ok(N,K)){
            ans++;
            exist.insert(K);
        }
    }

    auto div = divs(N-1);
    for(auto d:div){
        if(d!=1 and exist.find(d) == exist.end() ){
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
s = [input() for _ in range(h)]
a = [[None] * w for _ in range(h)]
for i in range(h):
    p = 0
    while p < w:
        j = p
        while j < w and s[i][j] == '.':
            j += 1
        for k in range(p, j):
            a[i][k] = j - p
        p = j + 1
r = 0
for j in range(w):
    p = 0
    while p < h:
        i = p
        while i < h and s[i][j] == '.':
            i += 1
        for k in range(p, i):
            r = max(r, a[k][j] + i - p - 1)
        p = i + 1

print(r)


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

CNT = {}
S = 0

for a in map(int, input().split()):
    if not(a in CNT):
        CNT[a] = 0

    CNT[a] += 1
    S += a

Q = int(input())
for _ in range(Q):
    B,C = map(int, input().split())

    if B in CNT:
        cnt = CNT[B]
        del CNT[B]

        S -= B*cnt
        S += C*cnt
        
        if not(C in CNT):
            CNT[C] = 0

        CNT[C] += cnt
        
    print(S)



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

void function(int SUM,int* S){
  static int I=-1;
  int SUMSUM=SUM,SS=0;
  I++;
  if(SUMSUM%10!=0||SUMSUM==0)
    cout << SUMSUM << endl;
  else{
    for(int J=0;J<I;J++)SS+=S[J];
    SUMSUM-=min(S[I],SS);
    if(SUMSUM%10!=0||SUMSUM==0)
      cout << SUMSUM << endl;
    else function(SUM,S);
  }
}

int main (){
  int n;
  cin >> n;
  int s[n];
  for(int i=0;i<n;i++) cin >> s[i];
  long long int sum=0;
  for(int i=0;i<n;i++) sum+=s[i];
  sort(s,s+n);
  function(sum,s);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a, b, c, n, i;
    scanf("%d", &n);
    
    i=0;
    while(i<n){
        scanf("%d %d %d", &a, &b, &c);
        if(a*a == b*b + c*c || b*b == c*c + a*a || c*c == a*a + b*b){
        printf("YES\n");
        }
        else{
            printf("NO\n");
        }
        i++;
    }
    return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


double dp[3010][3010]={};

int main(){
  int n;
  cin >>n;
  double p[n];
  rep(i,n)cin>>p[i];

  dp[0][0]=1.000;

  rep(i,n){
    for(int r=0;r<=i;r++){
      dp[i+1][r+1]+=dp[i][r]*p[i];
      dp[i+1][r]+=dp[i][r]*(1-p[i]);
    }
  }

  double ans=0;
  for(int i=(n+1)/2;i<=n;i++){
    ans+=dp[n][i];
  }
  printf("%.12lf\n",ans);
}

Measured memory_bytes: 69120
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import collections


def process(commands):
    queue = collections.deque()
    for c in commands:
        if "insert" in c:
            queue.appendleft(int(c[7:]))
        elif "deleteFirst" in c:
            try:
                _ = queue.popleft()
            except IndexError as e:
                pass
        elif "deleteLast" in c:
            try:
                _ = queue.pop()
            except IndexError as e:
                pass
        elif "delete" in c:
            try:
                queue.remove(int(c[7:]))
            except ValueError as e:
                pass
    print(" ".join(list(map(str, queue))))


def main():
    n = int(input())
    process([input() for i in range(n)])


if __name__ == "__main__":
    main()

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int r = sc.nextInt();
			if (n == 0) {
				break;
			}
			
			ArrayList<Integer> cards = new ArrayList<Integer>();
			for (int i = n; i >= 1; i--) {
				cards.add(i);
			}
			
			for (int i = 0; i < r; i++) {
				int p = sc.nextInt();
				int c = sc.nextInt();
				
				for (int j = c; j >= 1; j--) {
					int k = cards.remove(p - 1 + c - 1);
					cards.add(0, k);
				}
			}
			System.out.println(cards.get(0));
		}
	}
}

Measured memory_bytes: 27768
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<vector>
using namespace std;
int  i,j,k,h,w,a,b,c,d,x,y,z,n=0,s,data[10000001];
int main(void){
  cin>>s;
  data[s]=1;
  for(i=2;;i++){
    if(s%2){
      s=3*s+1;
    }
    else{
      s/=2;
    }
    if(data[s]==1)break;
    data[s]=1;
  }
	cout<<i;
	return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())

if a > b:
	temp = b
	b = a
	a = temp

if b > c:
	temp = c
	c = b
	b = temp

if a > b:
	temp = b
	b = a
	a = temp

print(str(a) + " " + str(b) + " " + str(c))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  ll n;
  cin >> n;
  mint dp[n + 1][5][5][5] = {};
  vc v = {'A', 'C', 'G', 'T', ' '};
  dp[0][4][4][4] = 1;
  rep(i, n) rep(a, 5) rep(b, 5) rep(c, 5) rep(d, 4) {
    if(v[b] == 'A' && v[c] == 'G' && v[d] == 'C') continue;
    if(v[a] == 'A' && v[c] == 'G' && v[d] == 'C') continue;
    if(v[b] == 'G' && v[c] == 'A' && v[d] == 'C') continue;
    if(v[b] == 'A' && v[c] == 'C' && v[d] == 'G') continue;
    if(v[a] == 'A' && v[b] == 'G' && v[d] == 'C') continue;
    dp[i + 1][b][c][d] += dp[i][a][b][c];
  }
  mint ans = 0;
  rep(a, 5) rep(b, 5) rep(c, 5) ans += dp[n][a][b][c];
  cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i).first >> A.at(i).second;
  }
  double sum = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      double length = sqrt(pow(A.at(i).first - A.at(j).first, 2) + pow(A.at(i).second - A.at(j).second, 2));
      sum += length;
    }
  }
  sum *= (N-1);
  double res = sum / (N*(N-1));
  cout << fixed << setprecision(10);
  cout << res << endl;
}


Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<ll, ll>
#define pll pair<ll, ll>
#define pli pair<ll, ll> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;
ll power(ll x, ll y)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % mod; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % mod;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % mod;  
    }  
    return res;  
}

int main(){
    FASTIO
    int n, k;
    bool f = false;
    cin >> n >> k;
    ll a[n];
    rep(i, 0, n){
    	cin >> a[i];
    	if(a[i] == 0)
    		f = true;
    	}
    sort(a, a + n);
    ll p = 1;
	if(a[n-1] < 0 || n == k){
			if(k % 2 == 0)
				reverse(a, a + n);
			for(int j = n -1; j >= 0 && k > 0; j--, k--){
			p = (p * a[j]) % mod;
			p = (p + mod) % mod;
		}
			cout << p ;
			return 0;
	}
	vector<ll> pos, neg;
	rep(i, 0, n){
		if(a[i] < 0)
			neg.pb(-a[i]);
		else
			pos.pb(a[i]);
	}
	sort(neg.begin(), neg.end(), greater<ll>());
    sort(pos.begin(), pos.end(), greater<ll>());
    vector<ll> a1 = pos, a2 = neg;
    rep(i, 1, neg.size()){
    	neg[i] = (neg[i-1] * neg[i]) % mod;
	}
	rep(i, 1, pos.size()){
    	pos[i] = (pos[i-1] * pos[i]) % mod;
	}
	if((k&1)&&pos.empty()){
		
	reverse(a2.begin(), a2.end());
	neg=a2;
	ll tmp=1;
	rep(i,0,neg.size()){
		neg[i]*=tmp;
		neg[i]%=mod;
		tmp=neg[i];
	}
		cout<<mod-neg[k-1]<<endl;
		return 0; 
	}
	else{
		
		ll res;
		bool ok=0;
		rep(i,0,neg.size()+1){
			if(i&1) continue;
			if(k-i<=pos.size()){
			if(i&&ok)
			if(a2[i-1]*a2[i-2]<a1[k-i]*a1[k-i+1]) break;
			if(i==0){
				res=pos[k-1];
			}
			else
			if(k-i-1>=0){
				res=pos[k-i-1]*neg[i-1]%mod;
			}
			else{
				res=neg[i-1];
			}
				ok=1;
			} 
		} cout<<res<<endl;
	}
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int D[3][100000], A[100000], B[100000], C[100000];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N;
	cin>>N;
	for(int i=0;i<N;i++) cin>>A[i]>>B[i]>>C[i];
	D[0][0]=A[0];
	D[1][0]=B[0];
	D[2][0]=C[0];
	for(int i=1;i<N;i++) {
		D[0][i]=max(D[1][i-1],D[2][i-1])+A[i];
		D[1][i]=max(D[0][i-1],D[2][i-1])+B[i];
		D[2][i]=max(D[0][i-1],D[1][i-1])+C[i];
	}
	cout<<max(D[0][N-1],max(D[1][N-1],D[2][N-1]))<<'\n';
	return 0;
}

Measured memory_bytes: 2560