akhauriyash/Code-Regression huggingface dataset:
n = int(input())
m = [0]
s1 = list(input())
s2 = list(input())
for i in range(n):
    if s1[i] == s2[i]:
        m.append(1)
    else:
        if i % 2 == 0:
            m.append(2)

p = 10 ** 9 + 7
ans = 1
for i in range(1, len(m)):
    if m[i - 1] == 0:
        if m[i] == 1:
            ans *= 3
        else:
            ans *= 6
    elif m[i - 1] == 1:
        ans *= 2
    else:
        if m[i] == 2:
            ans *= 3
    if ans >= p:
        ans %= p
print(ans)

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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V)   \
    for (auto v : (V)) \
        cout << v << ' ';
const int MOD = 1000000007;
#define PI 3.14159265359
/* cout << fixed << setprecision(10) << decimal << endl; */

int main()
{
    /* code */
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double H_degree = (2.0 * PI) / (60.0 * 12.0) * (60 * H + M);
    double M_degree = (2.0 * PI) / 60.0 * (M);
    double kaku = abs(H_degree - M_degree);

    cout << fixed << setprecision(10) << sqrt((A * A) + (B * B) - (2.0 * A * B * cos(kaku))) << endl;

    return 0;
}

Measured memory_bytes: 4228
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

using namespace std;

set<int> mths{ 1,2,3,4,5,6,7,8,9,10, 11, 12 };

int main()
{
	int a, b, x;
	cin >> x;
	a = x / 100;
	b = x % 100;

	auto m_a = mths.count(a);
	auto m_b = mths.count(b);


	if (m_a && m_b)
	{
		cout << "AMBIGUOUS" << endl;
		return 0;
	}

	if (m_a)
	{
		cout << "MMYY" << endl;
		return 0;
	}

	if (m_b)
	{
		cout << "YYMM" << endl;
		return 0;
	}

	cout << "NA" << endl;
}


Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                    cerr<<#x<<": "<<x<<endl
#define trace2(x, y)                 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)                 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)             cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)         cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

ll n;
ll h[M];
ll cache[M];
ll k;

ll dp(ll x){
    if(x>n) return inf;
    if(x==n) return 0;
    ll &ans=cache[x];
    if(ans!=-1) return ans;
    ans=inf;
    for(ll i=x+1; i<=x+k && i<=n; i++){
        ans=min(ans,dp(i)+abs(h[i]-h[x]));
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    mst(cache,-1);
    rep(i,1,n+1){
        cin >> h[i];
    }
    ll answer=dp(1);
    cout << answer;
    return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 4480
n = int(input())
h = tuple(map(int,input().split()))

cnt = 0
mcnt = 0

for i in range(n):
  j = i + 1
  try:
    if h[j] <= h[i]:
      cnt += 1
    else:
      cnt = 0
    if mcnt < cnt:
        mcnt = cnt
  except IndexError:
    continue
      
print(mcnt)

Measured memory_bytes: 14352
#include<bits/stdc++.h>
using namespace std;
int main(){
       int a,b,c[1000],m=1000;
       cin>>a>>b;
       int d=b,f;
       for(int i=0;i<a;i++){
        cin>>c[i];
        d=d-c[i];
        if(c[i]<m) m=c[i];
        f++;
       }
       d=d/m;
       cout<<f+d;
}


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int N;
    cin >> N;
    vector<string> S (N, "");
    REP (i, N) cin >> S[i];
    vector<string> judge {"AC", "WA", "TLE", "RE"};
    string mul = " x ";
    vector<int> C (judge.size(), 0);
    REP (i, N) C[ALL (find, judge, S[i]) - begin (judge)]++;
    REP (i, judge.size()) cout << judge[i] + mul + to_string (C[i]) << endl;
    return 0;
}

Measured memory_bytes: 6408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 998244353
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,l[100005],r[100005],m[100005];
P q[100005],a[100005],b[100005];
bool ok;
int main(void){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].F;
		a[i].S=i;
	}
	for(int i=1;i<=n;i++){
		cin>>b[i].F;
		b[i].S=i;
	}
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	/*
	for(int i=1;i<=n;i++)cout<<a[i].F<<' '<<a[i].S<<endl;
	cout<<endl;
	for(int i=1;i<=n;i++)cout<<b[i].F<<' '<<b[i].S<<endl;
	cout<<endl;
	*/
	for(int i=1;i<=n;i++){
		q[a[i].S].F=i;
		q[b[i].S].S=i;
	}
	//for(int i=1;i<=n;i++)cout<<q[i].F<<' '<<q[i].S<<endl;
	for(int i=1;i<=n;i++){
		if(a[i].F>b[i].F)m[i]++;
		if(i>1&&a[i-1].F>b[i].F)l[i]++;
		if(i<n&&a[i+1].F>b[i].F)r[i]++;
		l[i+1]+=l[i];
		r[i+1]+=r[i];
		m[i+1]+=m[i];
	}
	/*
	for(int i=1;i<=n;i++){
		int x=q[i].F,y=q[i].S;
		if(a[x]>b[y])continue;
		if(x<=y){
			if(r[y-1]-r[x-1]==0&&m[x-1]==0&&m[n]-m[y]==0)ok=true;
		}else if(l[x]-l[y]==0&&m[y-1]==0&&m[n]-m[x]==0)ok=true;
	}
	*/
	int s=1,t=1,cnt=0;
	while(1){
		s=q[b[s].S].F;
		cnt++;
		if(s==t)break;
	}
	ok=true;
	if(m[n]!=0)ok=false;
	if(cnt==n&&r[n]==n-1)ok=false;
	if(ok)cout<<"Yes\n";
	else cout<<"No\n";
}


Measured memory_bytes: 7296
#include <iostream>

using namespace std;

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3, y3, x4, y4;
    int sa1 = x2 - x1;
    int sa2 = y2 - y1;
    x3 = x2 - sa2;
    y3 = y2 + sa1;
    x4 = x3 - sa1;
    y4 = y3 - sa2;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
#define contains(s, x) (s.find(x) != s.end())
int main() {
    int n, r = 0;
    cin >> n;
    if (n == 1) return cout << 1, 0;
    vector<int> a(n);
    for (int& i : a) cin >> i;
    sort(a.begin(), a.end());
    if (a[1] == 1) return cout << 0, 0;
    if (a[0] == 1) return cout << 1, 0;
    set<int> s;
    for (int i = 0; i < n; ++i) {
        if ((i + 1 < n && a[i + 1] == a[i]) || contains(s, a[i]))
            ++r;
        else {
            int m = a[i];
            bool found = false;
            for (int j = 2; j * j <= m; ++j) {
                if(m%j==0){
                    if (contains(s, j))
                        found = true;
                    else if (m % (m / j) == 0 && contains(s, m / j))
                        found = true;
                }
                if (found) {
                    ++r;
                    break;
                }
            }
        }
        s.insert(a[i]);
    }
    cout << n - r;
    return 0;
}


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[105][105];
int n,m,sum=0;
int main() {
	cin>>n>>m;
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)
			cin>>a[i][j];
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++) {
			sum=0;
			if(a[i][j]=='#')
				cout<<'#';
			else {
				if(a[i-1][j-1]=='#')
					sum++;
				if(a[i-1][j]=='#')
					sum++;
				if(a[i-1][j+1]=='#')
					sum++;
				if(a[i][j-1]=='#')
					sum++;
				if(a[i][j+1]=='#')
					sum++;
				if(a[i+1][j-1]=='#')
					sum++;
				if(a[i+1][j]=='#')
					sum++;
				if(a[i+1][j+1]=='#')
					sum++;
				cout<<sum;
			}
		}
		cout<<endl;
	}
	return 0;
}

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

int main(){

    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    string out;

    out += s1[0]-32;
    out += s2[0]-32;
    out += s3[0]-32;

    cout << out << endl;

    return 0;

}

Measured memory_bytes: 256
import sys
from collections import deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k = map(int,readline().split())
lst1 = list(map(int,readline().split()))

dic1 = dict()

for i in lst1:
    if i in dic1:
        dic1[i] += 1
    else:
        dic1[i] = 1

values = list(dic1.values())

values.sort()

values = deque(values)

ans = 0
while k < len(values):
    ans += values.popleft()

print(ans)


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

#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;

int main(){
	//freopen("stl.gir", "r", stdin);
	
	ll a, b;
	cin >> a >> b;
	if (abs(a-b) < 2) cout << "Brown" << endl;
	else cout << "Alice" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  string S,T;
  cin>>S>>T;
  int ans=0;
  
  REP(i,S.size()){
    if(S[i]!=T[i]) ans++;
  }
  
  co(ans);
}

Measured memory_bytes: 3844
#include <iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		ll n;
		cin >> n;
		ll arr[n];
		for (ll i = 0; i < n; i++) cin >> arr[i];
		ll a = 0;
		for (ll i = 1; i < n; i++)
		{
			if (arr[i - 1] > arr[i])
			{
				a += (arr[i - 1] - arr[i]);
				arr[i] += (arr[i - 1] - arr[i]);
			}
		}
		cout << a << endl;
	}
	return 0;
}


Measured memory_bytes: 5212
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int ans = 1;
		while (N / 2 > 0) {
			ans*=2;
			N/=2;
		}
		System.out.println(ans);


		reader.close();
	}


}





Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES  // M_PI等のフラグ
#define MOD 1000000007
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;


void solve(){
    int N;
    cin >> N;

    int count = 0;
    for (int i=0; i<N; i++) {
        int d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2) count++;
        else count = 0;

        if (count == 3) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
    return;
}


int main(int argc, char const *argv[]){
    solve();
    return 0;
}

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

#define NIL -1

struct Node {
    int key;
    struct Node *parent, *left, *right;
};

struct Node *root = NULL;

void freeNode(struct Node *target) {
    if (target == NULL) return;
    if (target->left != NULL) freeNode(target->left);
    if (target->right != NULL) freeNode(target->right);
    free(target);
}

int findNode(int key, struct Node *target) {
    if (target == NULL) return 0;

    if (key == target->key) {
        return 1;

    } else if (key < target->key) {
        return findNode(key, target->left);

    } else {
        return findNode(key, target->right);
    }
}

void insertNode(struct Node *insertTarget, struct Node *insertedTarget) {
    if (insertedTarget->key > insertTarget->key) {
        if (insertedTarget->left == NULL) {
            insertedTarget->left = insertTarget;
            insertedTarget->parent = insertedTarget;
        } else {
            insertNode(insertTarget, insertedTarget->left);
        }

    } else {
        if (insertedTarget->right == NULL) {
            insertedTarget->right = insertTarget;
            insertedTarget->parent = insertedTarget;
        } else {
            insertNode(insertTarget, insertedTarget->right);
        }
    }
}

void insertTree(struct Node *target) {
    if (root == NULL) root = target;
    else insertNode(target, root);
}

void printInOrderTree(struct Node *target) {
    if (target->left != NULL) printInOrderTree(target->left);
    printf(" %d", target->key);
    if (target->right != NULL) printInOrderTree(target->right);
}

void printPreOrderTree(struct Node *target) {
    printf(" %d", target->key);
    if (target->left != NULL) printPreOrderTree(target->left);
    if (target->right != NULL) printPreOrderTree(target->right);
}

struct Node* createNode(int key) {
    struct Node *node = (struct Node *)malloc(sizeof(struct Node));
    node->key = key;
    node->parent = NULL;
    node->left = NULL;
    node->right = NULL;
    return node;
}

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

    char command[10];
    int key;
    for (int i = 0; i < n; i++) {
        scanf("%s", command);
        // printf("%s\n", command);

        if (command[0] == 'i') {
            scanf("%d", &key);
            insertTree(createNode(key));

        } else if (command[0] == 'f') {
            scanf("%d", &key);
            if (findNode(key, root)) printf("yes\n");
            else printf("no\n");

        } else {
            printInOrderTree(root);
            printf("\n");
            printPreOrderTree(root);
            printf("\n");
        }
    }

    //freeNode(root);

    return 0;
}



Measured memory_bytes: 20516
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int n,max_num = -1000001,min_num = 1000001,tmp;
	long long int sum = 0;
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d",&tmp);
		sum += tmp;
		max_num = max(max_num,tmp);
		min_num = min(min_num,tmp);
	}
	printf("%d %d %lld\n",min_num,max_num,sum);
}


Measured memory_bytes: 2760
#include<stdio.h>
int main(){
    int L,R;
    scanf("%d %d",&L,&R);
    long int k,l;
    int min=2018;
    int M;
    if(R-L>=2018){
        printf("%d\n",0);
    }
    else{
    for(k=L;k<R;k++){
        for(l=k+1;l<=R;l++){
            M = (k*l)%2019;
            if(M<min){
                min=M;
            }
            
        }
        
    }
    printf("%d\n",min);
    }
    return 0;
}

Measured memory_bytes: 128
n = int(input())
s = [int(input()) for _ in range(n)]
s.sort()
summ = sum(s)
used = []
if str(summ)[-1] != '0':
  print(summ)
  exit()
for j in range(n):
  for i in range(n):
    if s[i] in used:
      continue
    if str(summ - s[i])[-1] != '0':
      print(summ - s[i])
      exit()
  used.append(s[j])
  summ -= s[j]
print(0)


Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    static long counter = 0;

    public static void main(String[] args) {
        int total;

        Scanner inp = new Scanner(System.in);
        total = inp.nextInt();

        long[] a = new long[total];

        for (int k = 0; k < total; k++) {
            a[k] = inp.nextInt();
        }

        merge_sort(a, 0, a.length);

        System.out.println(counter);
    }

    public static void merge(long[] a, int left, int mid, int right) {
        int n1 = mid - left;
        int n2 = right - mid;
        long[] l = new long[n1+1];
        long[] r = new long[n2+1];

        for (int i = 0; i < n1; i++) {
            l[i] = a[left + i];
        }

        for (int i = 0; i < n2; i++) {
            r[i] = a[mid + i];
        }

        l[n1] = Integer.MAX_VALUE;
        r[n2] = Integer.MAX_VALUE;

        int i = 0;
        int j = 0;

        for (int k = left; k < right; k++) {
            if (l[i] <= r[j]) {
                a[k] = l[i++];
            } else {
                a[k] = r[j++];
                counter += n1-i;
            }
        }
    }

    public static void merge_sort(long[] a, int left, int right) {
        if (left + 1 < right) {
            int mid = (left + right) / 2;
            merge_sort(a, left, mid);
            merge_sort(a, mid, right);
            merge(a, left, mid, right);
        }
    }
}



Measured memory_bytes: 103572
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-7
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int mod = 998244353;
long double PI = acosl(-1);
const ll infl = 1e18+100;
const int inf = 2e9+100;
const int nmax = 2e5+2;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;


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

//    freopen("bajeces.txt", "r", stdin);
//    freopen("mara.txt", "w", stdout);

    int n,m;
    cin>>n>>m;
    int shuru = m-((m%2)^1);
    for(int i=shuru, j=1; i>=1; i-=2, j++){
        cout<<j<<" "<<j+i<<"\n";
    }
    for(int j=shuru+2, i=m-(m%2); i>=1; i-=2, j++){
        cout<<j<<" "<<j+i<<"\n";
    }

}
/*

*/


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long LLINF = 1LL<<60;
const int INF = 1e9;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    vector<string> s(n);
    vector<int> t(n);

    rep(i,n) {
        cin >> s[i] >> t[i];
    }
    
    string x; cin >> x;

    bool flag = false;
    int ans = 0;

    rep(i,n) {
        if(flag) ans += t[i];
        if(s[i]==x) flag = true;
    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin>>s;
  int len=s.size();
  int ans=0;
  for(int i=0;i<len;i++){
    ans+=s[i]-'0';
  }
  if(ans%9==0)cout<<"Yes"<<endl;
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3728
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.IntMap ((!))
import qualified Data.IntMap as M
import Data.Maybe
import qualified Data.Set as S
import qualified Data.Tuple as T

dijkstra graph source = dijkstra' graph (S.singleton (0, source)) (M.singleton source 0)

dijkstra' graph pq res
    | S.null pq = res
    | otherwise = dijkstra' graph pq'' res'
    where
      ((d,v), pq') = S.deleteFindMin pq
      pq''= foldl' (\acc (x,e) -> S.insert (d+e,x) acc) pq' update
      res' = foldl' (\acc (x,e) -> M.insert x (d+e) acc) res update
      update = filter (\(x,e) -> M.notMember x res || d+e < res!x) (M.findWithDefault [] v graph)

buildGraph edges =
 let g = groupBy (\ (x, _, _) (y, _, _) -> x == y) edges
 in M.fromDistinctAscList (map (\x -> (f1 $ head x, map (\ (_, y, z) -> (y, z)) x)) g)

readInt = fst . fromJust . B.readInt
f1 (x, _, _) = x
f3 (_, _, x) = x

main = do
  ((nv,_,r):edges) <- map (\[x,y,z]->(x,y,z)) . map (map readInt . B.words) . B.lines <$> B.getContents
  let g = buildGraph (sort edges)
  let res = dijkstra g r
  mapM_ (putStrLn . maybe "INF" show . flip M.lookup res) [0..nv-1]

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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int n;
	cin>>n;

	for(int i=0; i<n; i++){
		int tmp=0;
		cin>>tmp;

		if(tmp%2==0){
			if((tmp%3 !=0) && (tmp%5 !=0)){
				writeln("DENIED");
				return 0;
			}
		}
	}
	writeln("APPROVED");


}


Measured memory_bytes: 256
let readIntArray _ =
    stdin.ReadLine().Split(" ") |> Array.map int

let judge a b n =
    n
    |> string
    |> fun x -> x.ToCharArray()
    |> Array.map string
    |> Array.map int
    |> Array.sum
    |> fun x -> a <= x && x <= b

()
|> readIntArray
|> fun [| n; a; b |] ->
    Array.init n (fun i -> i + 1)
    |> Array.filter (judge a b)
    |> Array.sum
|> printfn "%d"


Measured memory_bytes: 34340
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

const ll MOD = 998244353;

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

    ll ret = 0;
    vector<ll> dp(s + 1);
    for (int i = 0; i < n; i++) {
        if (a[i] <= s) {
            dp[a[i]] += i + 1;
            for (int j = s; j >= a[i]; j--) {
                dp[j] += dp[j - a[i]];
                if (j - a[i] == a[i])dp[j] -= i + 1;
                dp[j] += MOD, dp[j] %= MOD;
            }
        }
        ret += dp[s] % MOD, ret %= MOD;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define li long int
#define ld long double
using namespace std;
const ll mod = 1e9 + 7;
using namespace std;
int max(int a, int b, int c) { return max(max(a, b), c); } 
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	ll A, B; cin >> A >> B;
    char C; cin >> C;
    int D; cin >> D;
    B *= 100; B += D;
    ll X = A*B; X /= 100;
    cout << X << endl;
	
	
	
	return 0;
}


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

int main(){
    rep(i,5){
        int a;
        cin >> a;
        if(a ==0) cout << i+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String a = sc.next();
		int b = 0;
		int c, d;
		int cnt = 0;
		
		for(int i=0;i<a.length();i++){
			if(a.substring(i, i+1).compareTo("0")!=0){
				if(i!=0) b = Integer.valueOf(a.substring(0, i));
				c = Integer.valueOf(a.substring(i, a.length()));				
				d = b+c;
				if(d%2==0 && (d/2-b)>=0) cnt++;
			}
		}
		System.out.println(cnt);
	}	
}

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

int n, a;
deque<int> dq;
int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(i % 2 == 0) dq.push_back(a);
        else dq.push_front(a);
    }
    if(n % 2 == 1) reverse(dq.begin(), dq.end());
    for(auto it : dq) cout << it << " ";
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n;
	cin >> n;
	vector<pair<int,int>>v;
	for(int i = 0; i < n; i++){
		int a,b;
		cin >> a >> b;
		v.push_back({b,a});
	}
	sort(all(v));
	int sum = 0;
	for(int i = 0; i < n; i++){
		sum += v[i].ss;
		if(sum > v[i].ff){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 7396
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; 
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int ll;
#define ull unsigned long long int
#define all(a) a.begin(),a.end()s
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define hell 1000000007
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define pb push_back
#define MAX 10000001
int main()
{
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<pair<ll,char>>v;
    for(ll i=0;i<a;i++)
    {
        ll h;
        cin>>h;
        v.pb(mp(h,'r'));
    }
    for(ll i=0;i<b;i++)
    {
        ll h;
        cin>>h;
        v.pb(mp(h,'g'));
    }
    for(ll i=0;i<c;i++)
    {
        ll h;
        cin>>h;
        v.pb(mp(h,'c'));
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    ll ra =0,ga=0,ca=0,sum=0;
    for(ll i=0;i<v.size()&&ra+ga+ca<x+y;i++)
    {
        if(v[i].second=='r')
        {
            if(ra<x)
            {
                ra++;
                sum+=v[i].first;
            }
        }
        if(v[i].second=='g')
        {
            if(ga<y)
            {
                ga++;
                sum+=v[i].first;
            }
        }
        if(v[i].second=='c')
        {
                ca++;
                sum+=v[i].first;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 10220
#include <cstdio>
#include <cstring>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;

int main(void) {
  int n;
  int a;
  scanf("%d%d", &n, &a);

  bool ok = false;
  REP(i, n/500+2) {
    REP(j, a+1) {
      ok = ok || (i*500+j == n);
    }
  }
  puts(ok ? "Yes" : "No");

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,ti,a,b;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>ti>>a>>b;
        if(!(a+b<=ti&&(ti-a-b)%2==0))
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#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
using ll = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;

int main() {
  int a,b; cin>>a>>b; cout<<a*b;
}


Measured memory_bytes: 3540
#include <iostream>
#define ll long long
using namespace std;

const int maxn = 1e5+10;
int a[maxn];
int main(){
  ll k,n,x,ans=0;
  cin>>n>>x;
  for(int i=0;i<n;i++)
    cin>>a[i];
  if(a[0]>x){
    ans=a[0]-x;
    a[0]=x;
  }
  for(int i=1;i<n;i++){
    k=a[i]+a[i-1]-x;
    if(k>0){
      ans+=k;
      a[i]-=k;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 768
#include<stdio.h>

int main(void){
	int n;
	int a[200000];
	int num[200000]={0};
	
	scanf("%d",&n);
	
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		num[a[i]-1]++;
	}
	
	unsigned long long int sum=0;
	
	for(int i=0;i<n;i++){
		sum+=(unsigned long long int)num[i]*(unsigned long long int)(num[i]-1)/2;
	}
	
	for(int i=0;i<n;i++){
		printf("%lld\n",sum-num[a[i]-1]+1);
	}
}

Measured memory_bytes: 4096
from collections import defaultdict
def main():
    N = int(input())
    A = [ a for a in input().split()]
    pair = defaultdict(int)
    for i in range(N):
        pair[A[i]] += 1

    total = 0
    for k, v in pair.items():
        total += v*(v-1)//2

    for i in range(len(A)):
        v = pair[A[i]]
        ans = total - (v*(v-1)//2) + (v-1)*(v-2)//2
        print(ans)

if __name__ == "__main__":
    main()

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, a[100];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  reverse(a, a + n);
  for (int i = 0; i < n; i++) {
    cout << a[i] << (i == n - 1 ? '\n' : ' ');
  }
  return 0;
}



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

using namespace std;

const int mod = 1000000007;
const int maxn = 100010;
int N;
int dp[2][maxn]; //0 means it is white, 1 means it is black
vector<int> adj[maxn];

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

int mult(int a, int b) {
	return a * 1LL * b % mod;
}

void godown(int u, int p = -1) {

	dp[0][u] = 1;
	dp[1][u] = 1;

	for (int v : adj[u]) {
		if (v == p) continue;
		godown(v, u);

		dp[0][u] = mult(dp[0][u], dp[0][v] + dp[1][v]);
		dp[1][u] = mult(dp[1][u], dp[0][v]);
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N;
	int x, y;
	for (int i = 0; i < N-1; i++) {
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	godown(1);
	add(dp[0][1], dp[1][1]);
	cout << dp[0][1] << endl;
}

Measured memory_bytes: 13440
import java.util.Scanner;
/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		long sum=0;
		String str,dam;
		char line;
		
		while(true){
			
			str = as.nextLine();
			
			if(str.equals("0")){
				break;
			}
			
			for(int i=0;i<str.length();i++){      //?????????????????????????????????????´???????
	             
	            line = str.charAt(i);
	            sum = sum + Character.getNumericValue(line);
	            
	             
	        }
			str = String.valueOf(sum);
			System.out.println(str);
			sum = 0;
			
		}
		
	}

}

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

int N, K;
int A[200010];
int cnt[200010];

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    cnt[A[i]]++;
  }
  vector<int> v;
  for (int i = 0; i < 200010; i++) {
    if (cnt[i]) v.emplace_back(cnt[i]);
  }
  sort(v.begin(), v.end());
  int ans = 0;
  for (int i = 0; i < max((int)v.size()-K, 0); i++) {
    ans += v[i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2936
#include<stdio.h>
#include<string.h>

static const int LEN=100005;

typedef struct pp{
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
    Q[tail]=x;
    tail=(tail+1) % LEN;
}

P dequeue(){
    P x = Q[head];
    head=(head+1) % LEN;
    return x;
}

int min(int a, int b){
    return a<b ? a:b;
}

int main(){
    int elaps=0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);
    
    for(i=0; i<=n; i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head=0;
    tail=n;
    
    while(head != tail){
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if(u.t>0){
            enqueue(u);
        }else{
            printf("%s %d\n", u.name, elaps);
        }
    }
    
    return 0;
}



Measured memory_bytes: 12916
#include<bits/stdc++.h>
using namespace std;
const int md=1e9+7;
int n,m,cc,a[10005],dp[10005],ans;
int pw(int x,int b){int res=1;for(;b;b>>=1,x=1ll*x*x%md)if(b&1)res=1ll*res*x%md;return res;}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i*i<=n;i++)if(n%i==0)
	{
		a[++cc]=i;
		if(i*i!=n)a[++cc]=n/i;
	}
	sort(a+1,a+cc+1);
	for(int i=1;i<=cc;i++)
	{
		dp[i]=pw(m,(a[i]+1)/2);
		for(int j=1;j<i;j++)if(a[i]%a[j]==0)dp[i]=(dp[i]-dp[j]+md)%md;
		if(a[i]&1)ans=(ans+1ll*dp[i]*a[i]%md)%md;else ans=(ans+1ll*dp[i]*(a[i]/2)%md)%md;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

#define WHITE 0
#define BRACK 1
#define GRAY 2
#define N 101

/*typedef struct pp{
  int x[N];
  int t;
  }P;*/

int color[N];
int d[N];
int f[N];
int e[N];
int time;
int A[N][N];
int v[N];
int B[N][N];
int n;
int Q[N];
int head, tail;

void enqueue(int x){
  Q[tail]=x;
  if(tail+1==N) tail=0;
  else tail=tail+1;
}

int dequeue(){
  int x;
  x=Q[head];
  if(head+1==N) head=0;
  else head=head+1;
  return x;
}

void BFS(int s){
  int i,u=v[s],v,j,k;

  for(i=1;i<=n;i++){
    color[u]=WHITE;
    d[u]=INT_MAX;
    color[s]=GRAY;
  }
  d[s]=0;
  
  for(i=0;i<N;i++)Q[i]=0;
  head=1;
  tail=1;
  enqueue(s);
  
  //while(head!=tail){
  for(j=1;Q[j]!=0;j++){
    u=dequeue();
    for(i=1;i<=e[u];i++){
      v=B[u][i];
      if(color[v]==WHITE){
	color[v]=GRAY;
	d[v]=d[u]+1;
	enqueue(v);
	//printf("%d %d\n",s,d[v]);
      }
      //printf("%d %d\n",s,d[v]);
    }
    color[u]=BRACK;
    //printf("%d %d\n",s,d[v]);
  }
  //printf("%d %d\n",s,d[v]);
  for(k=1;k<=n;k++){printf("%d %d\n",k,d[k]);}

}

main(){
  int i,j,v1;
  
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      A[i][j]=WHITE;
    }
  }

  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    scanf("%d%d",&v[i],&e[i]);
    for(j=1;j<=e[i];j++){
      scanf("%d",&v1);
      B[i][j]=v1;
      A[i][v1]= BRACK;
    }
  }

  /*for(i=1;i<=n;i++){
    BFS(v[i]);
    }*/
  for(i=0;i<N;i++)d[i]=-1;

  BFS(1);
  return 0;
}

Measured memory_bytes: 676
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		List<Integer> list = new ArrayList();
		for(int i=1; i<=5; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		int k = Integer.parseInt(sc.next());
		Collections.sort(list);
		Collections.reverse(list);
		for(Integer a:list) {
			if(a-list.get(4) > k) {
				System.out.println(":(");
				return;
			}
		}
		System.out.println("Yay!");
	}
}


Measured memory_bytes: 27008
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int array[] = new int[10001];

        for (int i = 1; i < 101; i++) {
            for (int j = 1; j < 101; j++) {
                for (int k = 1; k < 101; k++) {
                    int sum = i * i + j * j + k * k + i * j + j * k + k * i;
                    if (sum < 10001) {
                        array[sum]++;
                    }
                }
            }
        }

        for (int i = 1; i < n + 1; i++) {
            System.out.println(array[i]);
        }

        sc.close();

    }

}

Measured memory_bytes: 38904
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int N=105*2;
int n;
double pi=3.1415926535897,x[N],y[N],a[N];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%lf%lf",&x[i],&y[i]);
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++)
			a[j]=atan2(y[j]-y[i],x[j]-x[i])*180.0/pi;
		a[i]=1e9;
		sort(a+1,a+n+1);
		double Max=a[1]+360.0-a[n-1];
		for (int i=1;i<n-1;i++)
			Max=max(Max,a[i+1]-a[i]);
		double ans=0;
		if (Max>180){
			for (int j=n;j<=(n-1)*2;j++)
				a[j]=a[j-(n-1)]+360;
			int L=n,R=n;
			while (a[L]-a[L-1]<180)
				L--;
			while (R<(n-1)*2&&a[R+1]-a[R]<180)
				R++;
			ans=(180-(a[R]-a[L]))/360;
		}
		printf("%.8lf\n",ans);
	}
	return 0;
}

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

#define ll long long int

int main(){
	ios_base::sync_with_stdio(false);
  	
  	ll k, n;
  	cin>>k>>n;
  	vector<ll> a(n);
  	for(ll i=0; i<n; i++){
  	    cin>>a[i];
  	}
  	ll skip_len = a[0]+k-a[n-1];
  	for(ll i=1; i<n; i++){
  	    skip_len = max(skip_len, a[i]-a[i-1]);
  	}
  	cout<<k-skip_len<<"\n";
}

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

// for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

// abbreviati
#define PB(v) push_back(v)
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

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

// constant
const int INF = 1<<30;
const ll INFLL = 1LL << 60;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet***************************************************
ifelse, isprime, torad, todeg, lcm, bfs,chmin,chmax
**************************************************************/

// adjacency list
vector<int> to[100005];

// Graph
using Graph = vector<vector<int>>;

// Grid
int H,W;
vector<vector<int>> field;

// 4方向への移動ベクトル
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,l; cin >> n >> l;

    int taste=0;
    int ans=INF;
    int sum=0;
    int j=0;
    repe(i,1,n){
        taste=l+i-1;
        if(ans!=min(ans,abs(taste))){
            ans=abs(taste);
            j=i;
        }
        sum+=taste;
    }
    sum-=l+j-1;
    cout << sum ENDL;

    return 0;
}

Measured memory_bytes: 6004
#include <bits/stdc++.h>
#define N 100005

using namespace std;

const int mod = 1e9 + 7;

int n;
int x[N], d[N], g[N];
int fac[N], ifac[N];

inline int fpm(int x, int y) {
	int res = 1;
	while(y) {
		if(y & 1) res = 1LL * res * x % mod;
		x = 1LL * x * x % mod, y >>= 1;
	}
	return res;
}

inline int perm(int s, int r) { return 1LL * fac[s] * ifac[s - r] % mod; }
inline int comb(int s, int r) { return 1LL * perm(s, r) * ifac[r] % mod; }

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) {
		scanf("%d", &x[i]);
		if(i > 1) d[i - 1] = x[i] - x[i - 1];
	}
	
	fac[0] = 1;
	for(int i = 1; i <= n; ++i) fac[i] = 1LL * i * fac[i - 1] % mod;
	ifac[n] = fpm(fac[n], mod - 2);
	for(int i = n; i; --i) ifac[i - 1] = 1LL * i * ifac[i] % mod;
	
	--n;
	for(int i = 1; i <= n; ++i) {
		g[i] = 1LL * comb(n, i) * fac[n - i] % mod * fac[i - 1] % mod;
		g[i] = (g[i] + g[i - 1]) % mod;
	}
	
	int ans = 0;
	for(int i = 1; i <= n; ++i)
		ans = (ans + 1LL * d[i] * g[i]) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2176
/*
 * Author: FreeIdea
 * Created Time:  2011/8/24 16:34:09
 * File Name: E.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
const int maxint = -1u>>1;
template <class T> bool get_max(T& a, const T &b) {return b > a? a = b, 1: 0;}
template <class T> bool get_min(T& a, const T &b) {return b < a? a = b, 1: 0;}
#define MAX 100000
#define inf 0x7fffffff
struct node {
    int v, next, d;
}edge[2 * MAX + 5];
int p[MAX + 5], l, res, _max, cnt;
bool vis[MAX + 5];
#define mod 10007
void dfs(int u) {
    if (vis[u])
        return;
    vis[u] = true;
    for (int i = p[u]; i; i = edge[i].next) {
        int v = edge[i].v, d = edge[i].d;
        if (d > _max) {
            _max = d;
            cnt = 1;
        }
        else if(d == _max){
            cnt++;
        }
        //printf("v = %d u = %d _max = %d , cnt = %d\n", v, u, _max, cnt);
        if (vis[v] == false) {
            dfs(v);
        }
    }
}
int main() {
    int n;
    while(scanf("%d", &n), n) {
        memset(p, 0, sizeof(p[0]) * (n + 1));
        l = 1;
        int a, b;
        for (int i = 0; i < n; i++) {
            scanf("%d%d", &a, &b);
            edge[l].v = a; edge[l].d = b; edge[l].next = p[i]; p[i] = l++;
            scanf("%d%d", &a, &b);
            edge[l].v = a; edge[l].d = b; edge[l].next = p[i]; p[i] = l++;
        }
        res = 1;
        memset(vis, false, sizeof(vis[0]) * (n + 1));
        for (int i = 0; i < n; i++) {
            if (vis[i] == false) {
            _max = -inf; cnt = 0;
            dfs(i);
            res = res * (cnt / 2) % mod;
            }
        }
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cstdint>

int main() {
	std::string s;
	std::cin >> s;

	int64_t ans = 0;
	for (int i = 0; i < (1 << (s.size() - 1)); ++i) {
		int curIdx = 0;
		int64_t sum = 0;
		while (curIdx < s.size()) {
			for (int j = curIdx; j < s.size(); ++j) {
				if (((i >> j) & 1) == 1 || j == s.size() - 1) {
					sum += std::stoll(s.substr(curIdx, j - curIdx + 1));
					curIdx = j + 1;
					break;
				}
			}
		}
		ans += sum;
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).ok();
	s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().split_whitespace()
		.map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
	(0..n).map(|_| read_vec()).collect()
}

pub trait LexicalPermutation {
	/// Return `true` if the slice was permuted, `false` if it is already
	/// at the last ordered permutation.
	fn next_permutation(&mut self) -> bool;
}
impl<T> LexicalPermutation for [T] where T: Ord {
	/// Original author in Rust: Thomas Backman <serenity@exscape.org>
	fn next_permutation(&mut self) -> bool {
		// These cases only have 1 permutation each, so we can't do anything.
		if self.len() < 2 { return false; }

		// Step 1: Identify the longest, rightmost weakly decreasing part of the vector
		let mut i = self.len() - 1;
		while i > 0 && self[i-1] >= self[i] {
			i -= 1;
		}

		// If that is the entire vector, this is the last-ordered permutation.
		if i == 0 {
			return false;
		}

		// Step 2: Find the rightmost element larger than the pivot (i-1)
		let mut j = self.len() - 1;
		while j >= i && self[j] <= self[i-1]  {
			j -= 1;
		}

		// Step 3: Swap that element with the pivot
		self.swap(j, i-1);

		// Step 4: Reverse the (previously) weakly decreasing part
		self[i..].reverse();

		true
	}
}

fn main() {
	let n: usize = read();
	let h: Vec<usize> = read_vec();

	let mut now = h[0];
	let mut hop: usize = 0;
	let mut hops: Vec<usize> = Vec::new();

	for i in 1..n {
		if now < h[i] {
			hops.push(hop);
			hop = 0;
		} else {
			hop += 1;
		}
		now = h[i]
	}
	hops.push(hop);

	println!("{}", hops.iter().max().unwrap());
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,a,ret=0; cin>>n;
	for (int i=0; i<n; i++) {
		cin>>a;
		if(a%2)
			ret++;
	}
	cout << (ret%2==0 ? "YES" : "NO") << endl;
	return 0;
}


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


int main()
{
	int n;
	while(cin>>n){
		while(n<=999){
			if(n%10==n/100&&n%10==n%100/10){
				cout<<n<<endl;	break;
			}
			++n;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int A, B;

	scanf("%d %d", &A, &B);
	if((A+B)%3 == 0 || A%3 == 0 || B%3 == 0) {
		printf("Possible");
	} else {
		printf("Impossible");
	}

	return 0;
}


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

int main(){
    ll n, t;
    cin >> n >> t;
    vector<ll> v(n);
    rep(i,n) cin >> v.at(i);
    ll ans = 0;
    rep(i,n - 1){
        ans += min(v.at(i+1)-v.at(i), t);
    }
    ans += t;
    cout << ans << endl;
}

Measured memory_bytes: 1792