akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#define ll long long
using namespace std;

#include <math.h> 

double Abs(double a){
	if(a<0){
		return a*(-1);
	}else{
		return a;
	}
}
ll tri(ll x1,ll y1,ll x2,ll y2){
	return ((y1-y2)*x2+(x2-x1)*y2)/2;
}
int main(){
	long long s=0;
	cin>>s;
	long long def=sqrt(s);
	long long x1=0,y1=0;
	long long x2=0,y2=0;
	long long x3=0,y3=0;
	if(def*def!=s){
		def++;
		x2=1;
		y3=def*def-s;
	}
	y2=def;
	x3=def;
	cout<<x1<<' ';//x1
	cout<<y1<<' ';//y1
	cout<<x2<<' ';//x2
	cout<<y2<<' ';//y2
	cout<<x3<<' ';//x3
	cout<<y3<<endl;//y3
	//printf("%lld",tri(x2,y2,x3,y3));
	return 0;
}

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

int main() {
  int n, k;
  string word;
  cin >> n >> k >> word;
  if(word.at(k-1) == 'A') {
    word.at(k-1) = 'a';
  } else if(word.at(k-1) == 'B') {
    word.at(k-1) = 'b';
  } else {
    word.at(k-1) = 'c';
  }
  
  cout << word << endl;
}


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

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

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

  int d = a[0];
  int profit = -1000000000;
  for (int i = 0; i < N; i++) {
    profit = max(profit, a[i] - d);
    d = min(d, a[i]);
  }

  int cost = 0;
  int u = -1000000000;
  d = a[0];
  for (int i = 0; i < N; i++) {
    u = max(u, a[i] - d);
    d = min(d, a[i]);
    if (profit == u) {
      cost++;
      u = -1000000000;
      if (i < N - 1) d = a[i + 1];
    }
  }

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


Measured memory_bytes: 768
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args){
    	Scanner input = new Scanner(System.in);
    	String[] st = input.nextLine().split(" ");
    	int longest = 0;
    	Map<String,Integer> map = new HashMap<String,Integer>();
    	for(int i = 0 ; i < st.length ; i++){
    		longest = Math.max(longest, st[i].length());
    		if(!map.containsKey(st[i])){
    			map.put(st[i], 1);
    		}else{
    			int num = map.get(st[i])+1;
    			map.remove(st[i]);
    			map.put(st[i], num);
    		}
    	}
    	
    	Set<Map.Entry<String, Integer>> entrySet = map.entrySet();
    	Iterator<Map.Entry<String, Integer>> it = entrySet.iterator();
    	int most = 0;
    	String str = "";
    	String str2 = "";
    	while(it.hasNext()){
    		Map.Entry<String, Integer> entry = it.next();
    		String key = entry.getKey();
    		Integer value = entry.getValue();
    		if(most < value){
    			most = value;
    			str = key;
    		}
    		if(key.length() == longest)str2 = key;
    	}
    	System.out.println(str+" "+str2);
    }
}

Measured memory_bytes: 17208
N=int(input())
l=[[[0 for i in range(10)]for j in range(3)]for k in range(4)]
for i in range(N):
    b, f, r, v = map(lambda x: int(x)-1, input().split())
    l[b][f][r]+=v+1
for j in range(4):
    for k in l[j]:
        print(" "+" ".join(map(str, k)))
    if j < 3:
        print("####################")

Measured memory_bytes: 7724
#include <stdio.h>
int main(){
    int H,W;
    for(;;){
        scanf("%d%d", &H,&W);
        if(H == 0 && W == 0){
            break;
        }
        for(int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

using namespace std;

int bucket[10];
int a[4], b, hit, blow;

int main()
{
	
	while(1)
	{
		
		memset(bucket, 0, sizeof(bucket));
		hit = 0; blow = 0;
		
		for(int i = 0; i < 4; i++)
		{
			cin >> a[i];
			
			if( cin.eof() )
				return 0;
			
			bucket[a[i]] = 1;
		}
		
		for(int i = 0; i < 4; i++)
		{
			cin >> b;
			if( b == a[i] )
				hit++;
			else if( bucket[b] )
				blow++;
		}
		
		cout << hit << " " << blow << endl;	
		
	}
	
	return 0;
}

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

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve(){
        int n = in.nextInt();
        int m = in.nextInt();

        int mod = (int)1e9+7;

        long[] a = new long[n+1];
        long[] b = new long[m+1];

        for(int i=1;i<=n;i++){
            a[i] = in.nextLong();
        }

        for(int i=1;i<=m;i++){
            b[i] = in.nextLong();
        }

        long areax = 0;
        for(int i=1;i<=n;i++){
            areax+= (i-1)*a[i]- (n-i)*a[i];
            areax%= mod;
        }

        long areay = 0;
        for(int i=1;i<=m;i++){
            areay+= (i-1)*b[i]- (m-i)*b[i];
            areay%= mod;
        }
        
        long area = (areax*areay)%mod;
        if(area < 0){
            area+=mod;
        }
        out.print(area);


    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }
    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private long nextLong() {
            return Long.parseLong(next());
        }

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}


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

using namespace std;

int a,b,ok,i;
long long n,min1,d;
int main()
{
    cin>>n;
min1=-1;
for(d=2;d*d<=n;d++)
{
    if(n%d==0)
    {
        if(min1==-1)
            min1=d+n/d-2;
        else
            if(d+n/d-2<min1)
            min1=d+n/d-2;
    }
}
if(min1==-1)
    cout<<n-1;
else
    cout<<min1;

    return 0;
}


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

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

  return 0;
}

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

lint S, n;
lint res = 0;


lint binary_pow(lint a, lint n, lint m){
    lint res = 1;
    /*以降,nの2進数表記で考える...aもそれに合わせる*/
    while(n > 0){
        if(n & 1) res = (res * a) % m;  //奇数分は別
        a = (a * a) % m;
        n >>= 1; 
    }
    return res;
}

lint mod_inv(int x, int y){
    lint alpha = x, beta = y, u = 1, v = 0;
    lint d;
    while(beta){
        d = alpha / beta;
        alpha -= beta * d; swap(alpha, beta);
        u -= v * d; swap(u, v);
    }

    u %= y;
    if(u < 0) u += y;  //法を加えて正に
    return u;
}



lint mod_Comb(lint n, lint k, lint m){
    lint val = 1, inv = 1;
    for(int i = n-k+1; i <= n; i++){ val *= i; val %= m; }
    for(int i = 1; i <= k; i++){ inv *= i; inv %= m; }
    inv = mod_inv(inv, m);
    return (val * inv) % m;
}


int main(){
    cin >> S;
    
    lint L = S/3;  //数列の最大長
    for(lint l = 1; l <= L; l++){
        n = S - 3 * l;
        res += mod_Comb(n+l-1, l-1, MOD);
        res %= MOD;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
long long n,a[200001],b[200001],d=0;
void INP()
{
	cin >> n>>d;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i]>> b[i];
	}
}
void SOLVE()
{
	int dem=0;
	for(int i=1;i<=n;i++)
	{
		if(sqrt(a[i]*a[i]+b[i]*b[i])<=d) dem++;
	}
	cout << dem;
}
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   INP();
   SOLVE();
   return 0;
}


Measured memory_bytes: 6828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
ll n;
cin >> n;
ll a[n+2];
a[0] = 0;
a[n + 1] = 0;
for (ll i = 1; i < n + 1; i++) cin >> a[i];
ll alcost = 0;
for (ll i = 0; i < n + 1;i++){
    alcost += abs(a[i + 1] - a[i]);
}
for (ll i = 1; i < n + 1;i++){
    ll res = alcost;
    res -= (abs(a[i + 1] - a[i]) + abs(a[i] - a[i - 1]));
    res += abs(a[i + 1] - a[i - 1]);
    cout << res << endl;
}
}

Measured memory_bytes: 4400
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

typedef unsigned long long ull;

int main()
{
  int x, ans = 1;
  cin>>x;

  for (int i = 2; x / i >= i; i++) {
    int tmp = i;
    while (tmp <= x) {
      //cout<<tmp<<" ";
      ans = max(ans, tmp);
      tmp *= i;
      //cout<<tmp<<endl;;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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;}

int main()
{   
    int n; string s;
    cin >> n >> s;
    for(int i=0;i<s.size();i++){
        int c = 'Z';
        if(s[i]+n > c)
        printf("%c",s[i]+n-26);
        else 
        printf("%c",s[i]+n);
    }
    cout << endl;
}

Measured memory_bytes: 256
/*/ Author: KaySeeKay /*/

#include<bits/stdc++.h>
using namespace std;	

/*/---------------------------Defines-----------------------------------------/*/

#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)	
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;	
const int INF = 1e18L;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/*/-----------------------------Debug begins----------------------------------/*/
vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    if(n>0)
    s << arr[n - 1] ;
    s<< "]";
    return s.str();
}
#define trace(args...) {__trace_begin(__LINE__); __trace(split(#args, ',').begin(), args);}
inline void __trace_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __trace_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __trace_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __trace_out_var(T val) { cerr << val; }
inline void __trace(vector<string>::iterator it) { cerr << endl; }
 
template<typename T, typename... Args>
inline void __trace(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __trace_out_var(a);
    cerr << "; ";
    __trace(++it, args...);
}
/*/-----------------------------Code begins----------------------------------/*/
int ar[N];
int dp[N];

signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		fn{
			cout <<"ACL";
		}
		
	
	}
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int64_t MOD=1000000007;

int main() {
  int N,K;
  cin>>N>>K;
  K--;
  N--;
  if(N%K==0)cout<<N/K;
  else cout<<(N/K)+1;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())
S.append("a")
n = list(map(str,range(0,10)))
ans = 0
for i in n:
    for j in n:
        for k in n:
            num = i+j+k
            now = 0

            for l in range(N+1):
                if now == 3:
                    ans += 1
                    break
                if num[now] == S[l]:
                    now += 1
print(ans)

Measured memory_bytes: 75220
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    ll A, B, C;
    cin >> A >> B >> C;
    if(A % 2 == 0 or B % 2 == 0 or C % 2 == 0) {
        cout << 0 << endl;
    } else {
        cout << min(A * B, min(B * C, A * C)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
function main(input) {
    // 入力値の分離
    param = input.split(" ");
    var hour = param[2] - param[0];
    var min = param[3] - param[1];
    if(min < 0 ){
      hour -= 1;
      min = min * (-1);
      min = 60 - min;
    }
    const limit = (hour * 60) + min
    var result = limit - param[4];
    console.log(result);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29460
#include <stdio.h>
#include <math.h>

int main(){

    int n,i;
    double m,bunsan,hensa,sum;
    double s[1001];

    while(1){
        bunsan = 0;
        m = 0;
        hensa = 0;
        sum = 0;

        scanf("%d",&n);
        if(n == 0){break;}
        for(i = 0; i < n; i++){
            scanf("%lf",&s[i]);
        }
        for (i = 0; i < n; i++) {
            sum = sum + s[i];
        }
        m = sum / n;
        sum = 0;
        for(i = 0; i < n; i++){
            sum = (s[i] - m)*(s[i] - m) + sum;
        }
        bunsan = sum / n;
        hensa = sqrt(bunsan);
        printf("%lf\n", hensa);
    }
    return 0;
}



Measured memory_bytes: 2064
#include <bits/stdc++.h>
#define mdsaqib std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
using namespace std;

signed main(){
    mdsaqib;
    int n,x,t;
    cin >> n >> x >> t;
    int ans=(n+x-1)/x;
    ans*=t;
    cout << ans;
    
}

Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int main() {

    int masu;
    int masu_square;
    int siro;
    int kuro;

    do {
        cin >> masu;
    } while (masu < 1 || masu > 100);

    masu_square = masu * masu;

    do {
        cin >> siro;
    } while ( siro < 0 || siro > masu_square);

    kuro = masu_square - siro;

    // print
    cout << kuro << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define fr(i,a,b) for(int i=(a);i<(b);i++)
#define frd(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll;
#define int long long
#define pii pair<int,int>
#define mp make_pair
#define IOS cin.tie(NULL),ios_base::sync_with_stdio(false),cout.tie(NULL);
#define pb push_back
#define sz(a) a.size()
#define all(x) x.begin(),x.end()
#define endl '\n'
#define fi first
#define se second


vector <int> adj[100001];
vector <int> h (100001,0);
int cnt=0;

int dfs(int start){
  for(int i : adj[start]){
    if(h[i]>=h[start]){
      return 0;
    }
  }
  return 1;
}

void solve(){
  int n,m;
  cin >> n >> m;
  rep(i,n){
    cin >> h[i];
  }
  while(m--){
    int a,b;
    cin >> a >>b;

    --a;--b;
    adj[a].pb(b);
    adj[b].pb(a);
  }

  for(int i=0;i<n;i++){
    cnt+=dfs(i);
    // if(dfs(i)==1) cout << i<<endl;
  }

  cout << cnt << endl;

}





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


Measured memory_bytes: 9748
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll H;
    cin >> H;
    ll W;
    cin >> W;
    ll M;
    cin >> M;
    vector<ll> a(M,0);
    vector<ll> b(M,0);
    for(ll i=0;i<M;++i){cin>>a[i]>>b[i];a[i]--;b[i]--;}
    um M2;
    for(auto p: a)M2[p]++;
    um D;
    for(auto p: b)D[p]++;
    ll MM=0;
    ll DD=0;
    for(auto p: M2)chmax(MM,p.second);
    for(auto p: D)chmax(DD,p.second);
    set<ll> MMM;
    set<ll> DDD;
    for(auto p: M2){
        if(p.second==MM)MMM.emplace(p.first);
    }
    for(auto p: D){
        if(p.second==DD)DDD.emplace(p.first);
    }
    int minus=0;ll count=0;
    for(ll i=0;i<M;++i){
        if((MMM.find(a[i])!=MMM.end())&&(DDD.find(b[i])!=DDD.end()))count++;
    }
    if(count==MMM.size()*DDD.size())minus=1;
    if(minus)prt(MM+DD-1);
    else prt(MM+DD);


    return 0;
}



Measured memory_bytes: 62892
#include<stdio.h>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<math.h>
#include<map>
#include<algorithm>
#include<queue>
#include<string>
#include<climits>
#include<bitset>
#include<set>
#include<functional>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
 
#ifdef _WIN32
    #define gx getchar
    #define px putchar
    #define ps putchar(' ')
    #define pn putchar('\n')
    #define DEBUG 1
#else
    #define gx getchar_unlocked
    #define px putchar_unlocked
    #define ps putchar_unlocked(' ')
    #define pn putchar_unlocked('\n')
    #define DEBUG 0
#endif
 
//input
void scan(int &n)
{
    int sign = 1;
    n = 0;
    char c = gx();
    while( c < '0' || c > '9' )
    {
        if( c == '-' ) sign = -1;
        c = gx();
    }
    while( c >= '0' && c <= '9' ) n = (n<<3) + (n<<1) + c - '0', c = gx();  n = n * sign;
}
void lscan(ll &n)
{
    int sign = 1;
    n = 0;
    char c = gx();
    while( c < '0' || c > '9' )
    {
        if( c == '-' )
        sign = -1;
        c = gx();
    }
    while( c >= '0' && c <= '9' ) n = (n<<3) + (n<<1) + c - '0', c = gx();  n = n * (ll)(sign);
}
int sscan(char a[])
{
    char c = gx();
    while(c==' ' || c=='\n') c=gx();
    int i=0;
    while(c!='\n')a[i++] = c,c=gx();
    a[i]=0;
    return i;
}
int wscan(char a[])
{
    char c = gx();
    while(c==' ' || c=='\n') c=gx();
    int i=0;
    while(c!='\n' && c!=' ')a[i++] = c,c=gx();
    a[i]=0;
    return i;
}
 
//output
void print(int n)
{
    if(n<0)
    {
        n=-n;
        px('-');
    }
    int i=10;
    char o[10];
    do{o[--i] = (n%10) + '0'; n/=10;}while(n);
    do{px(o[i]);}while(++i<10);
}
void lprint(ll n)
{
    if(n<0LL)
    {
        n=-n;
        px('-');
    }
    int i=21;
    char o[21];
    do{o[--i] = (n%10LL) + '0'; n/=10LL;}while(n);
    do{px(o[i]);}while(++i<21);
}
void sprint(const char a[])
{
    const char *p=a;
    while(*p)px(*p++);
}
 
 
ll po(ll a, ll b, ll m)
{
	ll x=1,y=a;
	while(b > 0)
	{
		if(b%2 == 1)
		{
			x=(x*y);
			if(x>m) x%=m;
		}
		y = (y*y);
		if(y>m) y%=m;
		b /= 2;
	}
	return x;
}
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main()
{
	ll a,b;
	cin>>a>>b;
	if(a<=0&&b>=0)
		cout<<"Zero"<<endl;
	else if(b>0&&a>0)
		cout<<"Positive"<<endl;
	else if((b-a+1)%2==0)
		cout<<"Positive"<<endl;
	else
		cout<<"Negative"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (b < a){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
   
// g++ -std=c++11 prac.cpp
ll Max=-1e9,Min=1e9+1;

int main(){
    int d,n,x,y=0,z,m,k,w,l_sum=0,r_sum=0,ans=0;
    string s,t;
    bool count=false,ok=false;
    cin >> n;
    VI a(n);
    VI b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    sort(ALL(a));
    sort(ALL(b));
    ans += (a[n-1] + b[0]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, X, M = LI()
    A = [X]
    seen = set()
    seen.add(X)
    while True:
        an = A[-1]
        an1 = ((an % M) * (an % M)) % M
        if an1 in seen:
            break
        else:
            A.append(an1)
            seen.add(an1)
    start_loop_i = 0
    for i, a in enumerate(A):
        if an1 == a:
            start_loop_i = i
            break
    loop_len = len(A) - start_loop_i
    loop_sum = sum(A[start_loop_i:])

    end = False
    ans = 0
    for i in range(start_loop_i):
        N -= 1
        ans += A[i]
        if N == 0:
            end = True
            break
    if end:
        print(ans)
        return

    ans += loop_sum * (N // loop_len)
    
    if N % loop_len > 0:
        N %= loop_len
        for i in range(N):
            ans += A[start_loop_i + i]
    print(ans)






main()



Measured memory_bytes: 93516
import sys
from math import ceil,floor
N=int(input())
b=3501

for h in range(ceil(3*N/4),b):
  for w in range(1,floor(3*N/4)+1):
    if 4*h*w-N*h-N*w>0:
      if N*h*w % (4*h*w-N*h-N*w)==0:
        n=N*h*w//(4*h*w-N*h-N*w)
        print(h,n,w)
        sys.exit()
      

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

int main()
{
  string s;
  int64_t k;
  cin>>s>>k;
  if(s.at(0)!=49)
  {
    cout<<s.at(0)-48<<endl;
  }
  else
  {
    int one=0;
    int x;
    for(int i=0;i<s.size();i++)
    {
      if(s.at(i)==49)
        one++;
      else
        {
          x=s.at(i)-48;
          break;
        }
    }
    if(one>=k)
      cout<<1<<endl;
    else
      cout<<x<<endl;
  }
}

Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  
  int eveneven = N * (N - 1) / 2;
  int oddodd = M * (M - 1) / 2;
  
  cout << (eveneven + oddodd) << endl;
  
  return 0;
}


Measured memory_bytes: 256
import math 
a,b,h,m=map(int,input().split())
short=30*h
long=m*6
short=short+m*0.5

short=short%360
long=long%360

kakudo=abs(long-short)
ans=a*a+b*b-2*a*b*math.cos(math.radians(kakudo))
print(math.sqrt(ans))


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

int main(){
	string s,t;
	cin >> s >> t;
	char a[26] = {};
	REP(i,s.length()){
		if(a[s[i] - 'a'] == '\0') a[s[i] - 'a'] = t[i];
		else if(a[s[i] - 'a'] != t[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	char b[26] = {};
	REP(i,t.length()){
		if(b[t[i] - 'a'] == '\0') b[t[i] - 'a'] = s[i];
		else if(b[t[i] - 'a'] != s[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

ull modpow(ull a, ull n) {
  ull res = 1;
  while (n > 0) {
    if (n & 1) {
      res *= a;
      res %= MOD;
    }
    a *= a;
    a %= MOD;
    n >>= 1;
  }
  return res;
}

int main() {
  int n;
  cin>>n;
  int exr = 0;
  map<pair<ll, ll>, pair<int, int>> sar;
  rep(i, n) {
    ll a,b;
    cin>>a>>b;
    if (a == 0 && b == 0) exr++;
    else {
      ll g = gcd(a,b);
      a /= g;
      b /= g;
      if (b < 0 || (b == 0 && a < 0)) {
        a *= -1;
        b *= -1;
      }
      if (a <= 0) {
        ll t = a;
        a = b;
        b = -t;
        sar[make_pair(a,b)].first++;
      } else {
        sar[make_pair(a,b)].second++;
      }
    }
  }
  ll ans = 1;
  for(auto x : sar) {
    ll a = x.second.first;
    ll b = x.second.second;
    ans *= (MOD + 1 + ((MOD + modpow(2, a) - 1) % MOD) + ((MOD + modpow(2, b) - 1) % MOD)) % MOD;
    ans %= MOD;
  }
  ans = (MOD + ans - 1 + exr) % MOD;
  cout << ans;
}



Measured memory_bytes: 16052
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N, Y = gets_i_list

(0..N).each do |i|
  (0..(N-i)).each do |j|
    k = N - i - j
    if Y == 10000 * i + 5000 * j + 1000 * k
      puts [i,j,k].join(" ")
      exit
    end
  end
end

puts [-1, -1, -1].join(" ")


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

int main() {
    int N,D;
    cin >> N >> D;
    vector<vector<int>>X(N,vector<int>(D));
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < D; j++) {
            cin >> X[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            if(i == j) {
                continue;
            }
            int x = 0;
            for(int k = 0; k < D; k++) {
                x+=abs(X[i][k]-X[j][k])*abs(X[i][k]-X[j][k]);
            }
            for(int k = 0; k*k <= x; k++) {
                if(k*k == x) {
                    ans++;
                }
            }
        }
    }
    cout << ans/2 << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int par[200020];
int root(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = root(par[x]);
	}
}
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n + m; i++) {
		par[i] = i;
	}
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int l;
			cin >> l;
			int x, y;
			x = root(i);
			y = root(l + n - 1);
			if (x != y) {
				par[x] = y;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (root(0) != root(i)) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 5404
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),count=0;
    for(int i=0;i<n;i++) {
    	if(sc.nextLong()%2!=0)count++;
    }
    if(count%2==0) {
    	System.out.println("YES");
    }else {
    	System.out.println("NO");
    }
  }
}


Measured memory_bytes: 48856
from collections import Counter

def solve(n, m, a):
    b = [0] * n
    b[0] = a[0] % m
    for i in range(1, n):
        b[i] = (b[i-1] + a[i]) % m
    c = Counter(b)
    t = filter(lambda _:_>1, c.values())
    t = map(lambda _:_*(_-1), t)
    return c[0] + sum(t) // 2

n, m = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, m, a))

Measured memory_bytes: 16548
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
    multiset<int>s;
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    s.insert(a[n-1]);
    for(int i=n-2;i>=0;i--){
        auto it=s.lower_bound(a[i]+1);
        if(it==s.end()){
            // cout<<"coming\n";
            s.insert(a[i]);
            continue;
        }
        s.erase(it);
        s.insert(a[i]);
    }
    cout<<s.size()<<"\n";
}

Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main()
{
	char correctS[17] = "CODEFESTIVAL2016";
	char inputS[17];
	int num=0;
	cin>>inputS;
	for(int i = 0;i<16;i++)
	{
		if (correctS[i]!=inputS[i])
		{num++;}
	}
	cout<<num<<endl;
	return 0;
}

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

int main(void)
{
    int n;
    cin >> n;
    
    int coin500  = n / 500;
    int coin5 = (n - coin500 * 500) / 5;
    
    cout << coin500 * 1000 + coin5 * 5 << endl;

    return 0;
}


Measured memory_bytes: 256
a=input()

if a[-1]=='3':
    print('bon')
elif a[-1]=='0' or a[-1]=='1' or a[-1]=='6' or a[-1]=='8':
    print('pon')
elif a[-1]=='2' or a[-1]=='4' or a[-1]=='5' or a[-1]=='7' or a[-1]=='9':
    print('hon')



Measured memory_bytes: 9116
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
L_A = [0] * (N+1)
R_A = [0] * (N+1)#
for i in range(N):
    L_A[1+i] = gcd(L_A[i], A[i])
for i in reversed(range(N)):
    R_A[i] = gcd(R_A[i+1], A[i])
print(max(gcd(L_A[i], R_A[i+1]) for i in range(N)))


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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    // 0 0 0
    // 0 1 1
    // 1 1 0
    // 1 0 1
    //
    // if you start with a pair of hats, that fixes the rest of the sequence
    //
    // n = 3
    // a, b, a ^ b
    //
    // n = 4
    // a, b, a^b, a
    //
    // a ^ b == a
    // only poss if b = 0
    //
    // n = 5
    // a, b, a ^ b, a, 0
    //
    int n;
    cin >> n;
    vi a(n);

    bool all_zero = true;
    for (auto& x : a) {
        cin >> x;
        if (x > 0) {
            all_zero = false;
        }
    }

    if (all_zero) {
        cout << "Yes\n";
        return 0;
    }

    if (n % 3 != 0) {
        cout << "No\n";
        return 0;
    }

    // each bit has to have a repeated form: 
    // 000, 011, 101, 110
    // count # of bits for each?
    vi freq(30, 0);
    for (auto& x : a) {
        for (int j = 0; j < 30; ++j) {
            if (x & (1 << j)) {
                ++freq[j];
            }
        }
    }

    for (int j = 0; j < 30; ++j) {
        if (!freq[j]) continue;

        if (freq[j] % 2 != 0 or (freq[j] / 2) * 3 != n) {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";
    return 0;
}


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

int pow(int b, int p) {
    int tmp = 1;
    for (int c = 0; c < p; c++) {
        tmp *= b;
    }
    return tmp;
}

int main(){
    int x;
    cin >> x;
    if (x == 1) {
        cout << x << endl;
        return 0;
    }
    int ans = -1;
    for (int e = 2; e <= x; e++) {
        for (int k = 2; pow(e, k) <= x; k++) {
            ans = max(ans, pow(e, k));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
local k=io.read("n")
if k%2==0 or k%5==0 then
    print(-1)
else
    local mod=10
    local i=1
    local div=(k%7==0 and 9*k//7 or 9*k)
    while mod%div~=1 do
        mod=mod*10%div
        i=i+1
    end
    print(i)
end

Measured memory_bytes: 2756
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<climits>
#include<deque>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX 1010
#define pow2(a) ((a)*(a))

using namespace std;

struct Point{
  int x,y;
  Point(int x=IINF,int y=IINF):x(x),y(y){}
};

struct Data{
  int cur,cost;
  Data(int cur=IINF,int cost=IINF):cur(cur),cost(cost){}
};

inline double dist(Point a,Point b){
  return sqrt(pow2(abs(a.x-b.x))+pow2(abs(a.y-b.y)));
}

int N,X,Y;
vector<int> G[MAX];

int main()
{
  int T;
  cin >> T;
  while(T--){
    cin >> N >> X >> Y;

    rep(i,N)G[i].clear();

    deque<Data> deq;
    bool used[N+1];
    Point ps[N+1];
    rep(i,N+1){
      used[i] = false;
      cin >> ps[i].x >> ps[i].y;
    }

    REP(i,1,N+1){
      if(dist(ps[0],ps[i]) <= 10.0){
	deq.push_back(Data(i-1,1));
	used[i-1] = true;
      }
      REP(j,i+1,N+1){
	if(dist(ps[i],ps[j]) <= 50.0){
	  G[i-1].push_back(j-1);
	  G[j-1].push_back(i-1);
	}
      }
    }

    if(deq.empty()){
      cout << 0 << endl;
      continue;
    }

    int maxcost = 1;
    while(!deq.empty()){
      Data data = deq.front(); deq.pop_front();

      for(int next : G[data.cur]){
	if(used[next])continue;
	used[next] = true;
	maxcost = max(maxcost,data.cost+1);
	deq.push_back(Data(next,data.cost+1));
      }

    }

    if( X > Y && maxcost == 1){
      cout << X << endl;
      continue;
    }

    if( X > Y ){
      cout << "You're always welcome!" << endl;
    } else {
      cout << X*maxcost << endl;
    }

  }
  return 0;
}

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

int main(){
	int h,i,j,n,k,b,*p,y[81][5],u=0;
	queue<int> q,w,e,r,t;
	
	cin >> n >> k;
	p = new int[n+4];
	
	for(i=0; i<n+4; i++){
		p[i] = 0;
	}
	
	for(i=0; i<k; i++){
		cin >> b;
		cin >> p[b+1];
	}
	
	q.push(1);
	w.push(0);
	e.push(0);
	r.push((p[3])?p[3]:0);
	t.push((p[4])?p[4]:0);
	
	for(i=2; i<n+2; i++){
		b=0;
		for(; !q.empty(); ){
			for(h=1; h<4; h++){
				if(p[i]){
					y[b][0] = q.front();
					y[b][1] = e.front();
					y[b][2] = p[i];
					y[b][3] = t.front();
					y[b++][4] = (p[i+3])?p[i+3]:0;
					break;
				}else if(!((w.front() == h && e.front() == h) || (e.front() == h && h == r.front()) || (h == r.front() && h == t.front()))){
					y[b][0] = q.front();
					y[b][1] = e.front();
					y[b][2] = h;
					y[b][3] = t.front();
					y[b++][4] = (p[i+3])?p[i+3]:0;
				}
			}
			q.pop();
			w.pop();
			e.pop();
			r.pop();
			t.pop();
		}
		for(j=0; j<b; j++){
			if(y[j][0] != -1){
				for(h=0; h<b; h++){
					if((j != h)&&(y[j][1] == y[h][1])&&(y[j][2] == y[h][2])&&(y[j][3] == y[h][3])&&(y[j][4] == y[h][4])){
						y[j][0] += y[h][0];
						y[j][0] %= 10000;
						y[h][0] = -1;
					}
				}
				q.push(y[j][0]);
				w.push(y[j][1]);
				e.push(y[j][2]);
				r.push(y[j][3]);
				t.push(y[j][4]);
			}
		}
	}
	
	for(; !q.empty(); ){
		u += q.front();
		q.pop();
	}
	
	cout << u%10000 << endl;
	return 0;
}

Measured memory_bytes: 1204
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
long long int dp[100020] = {};
long long int ds[100020] = {};
int main() {
	int n;
	cin >> n;
	vector<int> a;
	vector<int> b;
	vector<int> c;
	for (int i = 0; i < n; i++) {
		int d;
		cin >> d;
		a.push_back(d);
	}
	for (int i = 0; i < n; i++) {
		int d;
		cin >> d;
		b.push_back(d);
	}
	for (int i = 0; i < n; i++) {
		int d;
		cin >> d;
		c.push_back(d);
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	int k = 0;
	for (int i = 0; i < b.size(); i++) {
		int f = 0;
		for (int j = k; j < c.size(); j++) {
			if (c[j] > b[i]) {
				dp[i] = n - j;
				k = j;
				break;
			}
			if (j == c.size() - 1) {
				f = 1;
			}
		}
		if (f == 1) {
			break;
		}
	}
	for (int i = 1; i <= n; i++) {
		ds[i] = ds[i - 1] + dp[i - 1];
	}
	k = 0;
	long long int sum = 0;

	for (int i = 0; i < a.size(); i++) {
		int f = 0;
		for (int j = k; j < b.size(); j++) {
			if (b[j] > a[i]) {
				sum = sum + ds[n] - ds[j];
			    k = j;
				break;
			}
			if (j == c.size() - 1) {
				f = 1;
			}
		}
		if (f == 1) {
			break;
		}
	}
	cout << sum;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
string s;
int n,f1[100005],f2[100005];
pair < int , int > res1,res2,res3,res4;
main () {
	cin>>n;
	
	for (int i=1; i<=n; i++) {
		int x;
		cin>>x;
		if (i%2) f1[x]++;
			else f2[x]++;
	}
	
	for (int i=1; i<=100000; i++) 
		if (f1[i]>res1.F) res2=res1,res1.F=f1[i],res1.S=i;
			else
		if (f1[i]>res2.F) res2.F=f1[i],res2.S=i;
	
	for (int i=1; i<=100000; i++)
		if (f2[i]>res3.F) res4=res3,res3.F=f2[i],res3.S=i;
			else
		if (f2[i]>res4.F) res4.F=f2[i],res4.S=i;
	
	if (res1.S!=res3.S) cout<<n-res1.F-res3.F<<endl;
				   else cout<<min(n-res2.F-res3.F,n-res1.F-res4.F)<<endl;
}

Measured memory_bytes: 1024
K = int(input())
A, B = map(int, input().split())

if A//K < B//K:
  print("OK")
elif A//K == B//K:
  if A%K == 0 or B%K == 0:
	  print("OK")
  else:
    print("NG")
else:
  print("NG")

Measured memory_bytes: 9180
#include <set>
#include <map>
#include <ctime>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define tl(x) (x<<1)
#define tr(x) (x<<1|1)
#define PII pair<int,int>
#define fi first
#define se second
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,b,a) for (int i=(b);i>=(a);--i)
typedef long long LL;
inline int read(){
	int x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}

const int MAXN=300005,Mo=1000000007,INF=2147483647;
PII c[MAXN];
struct heap{
	int tot,a[MAXN];
	void clear(){ tot=0; }
	void push(int x){
		a[++tot]=x; x=tot;
		int y=x>>1;
		while (y) {
			if (c[a[y]]>c[a[x]]) swap(a[x],a[y]),x=y,y=x>>1;
			else break;
		}
	}
	void pop(){
		swap(a[1],a[tot]); tot--;
		int x=1,y=2;
		while (y<=tot) {
			if (y<tot&&c[a[y]]>c[a[y+1]]) y++;
			if (c[a[x]]>c[a[y]]) swap(a[x],a[y]),x=y,y=x<<1;
			else break;
		}
	}
	int empty(){ return tot==0; }
	int top(){ return a[1]; }
}Q;
int n,tot,a[MAXN],b[MAXN],m[MAXN<<2][2];
struct list{
	int l,lt[MAXN],nt[MAXN<<1],x[MAXN<<1];
	void clear(){ l=0; memset(lt,0,sizeof(lt)); }
	void addedge(int a,int b){ l++; nt[l]=lt[a]; lt[a]=l; x[l]=b; }
}E;
void build(int x,int l,int r){
	if (l>r) return;
	if (l==r) { m[x][0]=a[l]; return; }
	int mid=(l+r)>>1;
	build(tl(x),l,mid);
	build(tr(x),mid+1,r);
	m[x][0]=m[tl(x)][0],m[x][1]=m[tl(x)][1];
	if ((mid-l+1)&1) m[x][0]=min(m[x][0],m[tr(x)][1]),m[x][1]=min(m[x][1],m[tr(x)][0]);
	else m[x][0]=min(m[x][0],m[tr(x)][0]),m[x][1]=min(m[x][1],m[tr(x)][1]);
}
int query(int x,int l,int r,int ll,int rr,int k){
	if (l>r) return INF;
	if (ll<=l&&r<=rr) return m[x][k^((l-ll)&1)];
	int mid=(l+r)>>1,t1=INF,t2=INF;
	if (ll<=mid) t1=min(t1,query(tl(x),l,mid,ll,rr,k));
	if (rr>mid) t2=min(t2,query(tr(x),mid+1,r,ll,rr,k));
	return min(t1,t2);
}
void dfs(int l,int r,int fa){
	if (l>r) return;
	int i=query(1,1,n,l,r,0);
	int j=query(1,1,n,b[i],r,1);
	c[++tot]=make_pair(i,j);
	if (fa) E.addedge(fa,tot);
	else Q.push(tot);
	dfs(b[i]+1,b[j]-1,tot);
	dfs(l,b[i]-1,fa);
	dfs(b[j]+1,r,fa);
}
int main(){
	n=read();
	FOR(i,1,n) a[i]=read();
	FOR(i,1,n) b[a[i]]=i;
	memset(m,0x7f,sizeof(m));
	build(1,1,n);
	//int x,y;
	//while (scanf("%d%d",&x,&y)!=EOF)
	//	cout<<query(1,1,n,x,y,0)<<' '<<query(1,1,n,x,y,1)<<endl;
	tot=0; E.clear(); Q.clear(); dfs(1,n,0);
	/*FOR(i,1,tot) cout<<i<<':'<<c[i].fi<<' '<<c[i].se<<endl;
	FOR(x,1,tot) {
		printf("%d ->{",x);
		for (int i=E.lt[x];i;i=E.nt[i]) printf("%d,",E.x[i]);
		printf("}\n");
	}*/
	while (!Q.empty()) {
		int x=Q.top(); PII C=c[x]; Q.pop();
		for (int i=E.lt[x];i;i=E.nt[i]) Q.push(E.x[i]);
		printf("%d %d%c",C.fi,C.se," \n"[Q.empty()]);
	}
	
	return 0;
}

/*
8
4 6 3 2 8 5 7 1

*/


Measured memory_bytes: 29312
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long LL;
const int mo=1e9+7;
const int K=87;
int q;
LL fib[K+10],cfib[K+10][K+10];
int Sum(int x,int y) {
    x+=y;
    return (x>=mo)?x-mo:x;
}
int Sub(int x,int y) {
    x-=y;
    return (x<0)?x+mo:x;
}
int Mul(int x,int y) {
    return (LL)x*y%mo;
}
void Prework() {
    fib[0]=0;
    fib[1]=1;
    fib[2]=2;
    for (int i=3;i<=K;i++)
        fib[i]=fib[i-1]+fib[i-2];
    for (int i=1;i<=K;i++) cfib[1][i]=fib[i];
    for (int i=2;i<=K;i++) {
        for (int j=1;j<i;j++) cfib[i][j]=fib[j];
        cfib[i][i]=cfib[i][i-1]*2+cfib[i][i-2];
        if (i==2) cfib[i][i]=cfib[i][i-1]*3;
        for (int j=i+1;j<=K;j++)
            cfib[i][j]=cfib[i][j-1]+cfib[i][j-2];
    }
}
void Calc(LL l1,LL l2) {
    if (l1>l2) swap(l1,l2);
    if (l1==1&&l2==1) {
        printf("1 1\n");
        return;
    }
    int cnt=0;
    for (int i=2;i<=K;i++)
        if (fib[i-1]<=l1&&fib[i]<=l2) cnt++;
    if (cnt==1) {
        printf("1 %d\n",Mul(l1%mo,l2%mo));
        return;
    }
    int sum=0;
    for (int i=1;i<=cnt;i++) {
        if (cfib[i][cnt]>l1||cfib[i][cnt+1]>l2) continue;
        sum=Sum(sum,((l2-cfib[i][cnt+1])/cfib[i][cnt]+1)%mo);
        if (cfib[i][cnt+1]>l1||cfib[i][cnt]>l2) continue;
        sum=Sum(sum,((l1-cfib[i][cnt+1])/cfib[i][cnt]+1)%mo);
    }
    printf("%d %d\n",cnt,sum);
}
int main() {
    Prework();
    scanf("%d",&q);
    while (q--) {
        LL l1,l2;
        scanf("%lld%lld",&l1,&l2);
        Calc(l1,l2);
    }
    return 0;
}

Measured memory_bytes: 4096
n = int(input())
P =[]
s = 0
for i in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for i in range(n):
    j = i+1
    s += P[i][0]*P[j][1] - P[i][1]*P[j][0]
print(abs(s)*0.5)

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

class AFrog1 {
public:
	void solve(std::istream& in, std::ostream& out) {
	    long long int n , i;
	    in >> n;
	    vector<long long int> a(n+1) , dp(n+1 , 0);
	    for(i = 1 ; i <= n ; i++) {
            in >> a[i];
        }
	    dp[2] = abs(a[1] - a[2]);
	    for(i = 3 ; i <= n ; i++) {
	        dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]) , dp[i-2] + abs(a[i] - a[i-2]));
	    }
	    out << dp[n] << "\n";
	}
};


int main() {
	AFrog1 solver;
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline

def li():
    return [int(x) for x in input().split()]

N = int(input())
A = li()

A.sort(reverse=True)

B = [A[i] for i in range(N) if i < N//2]

# 9 8 7 6 5
# 9 1 8 2 7 3 6 4 5
# 9 6 8 7
# 9+8+8+7+7+6+6+5

# 8 7 6 5
# 8 1 7 2 6 3 5 4
# 8+7+6+5+5+6+7

if N % 2 == 1:
    B = [A[i] for i in range(N) if i < N // 2 + 1]
    sm = B[0] + B[-1] + sum(B[i]*2 for i in range(N//2) if 0 < i)
    print(sm)
else:
    sm = B[0] + sum(B[i]*2 for i in range(N//2) if 0 < i)
    print(sm)

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

using namespace std;

int main(void){
    int n;
    cin >> n;
    
    vector<vector<int>> a(2,vector<int>(n));
    
    for (int i = 0; i < 2; i++){
        for (int j = 0; j < n; j++) cin >> a[i][j];
    
    }
    
    
    /*
    dp[i][j] : 上からi行目, 左からj列目(0-index)にいるときの
    回収できるアメの最大値を表す
    */
    vector<vector<int>> dp(2,vector<int>(n));
    
    dp[0][0] = a[0][0];
    
    for (int i = 1; i < n; i++) dp[0][i] = dp[0][i-1] + a[0][i];
    
    dp[1][0] = dp[0][0] + a[1][0];
    
    for (int i = 1; i < n; i++) dp[1][i] = max(dp[0][i], dp[1][i-1]) + a[1][i];
    
    cout << dp[1][n-1] << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] h = new long[n];
        for (int i = 0; i < n; i++ ) {
          h[i] = sc.nextLong();
        }
        Arrays.sort(h);
        long f = 1000000000;
        //
        for ( int m = 0; m < n - k + 1; m++ ) {
          long t = h[m+k-1] - h[m];
          if (t<f) {
             f = t;
          }
        }
        System.out.println(f);
    }
}



Measured memory_bytes: 49932