akhauriyash/Code-Regression huggingface dataset:
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Data{
    int A;
    string S;
    
    bool operator<( const Data& right ) const {
        return A == right.A ? S < right.S : A < right.A;
        //return A < right.A;
    }
};

int Func(){
    int x = 0;
    return x;
}

int main(){
    int A, B, C;
    
    cin >> A >> B >> C;
    
    cout << A*B/2 << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 

int main() {
    int d[3][3]; 
    rep(i, 3) { 
        rep(j, 3) {
            cin >> d[i][j]; 
        }
    } 

    rep(j, 2) {
        rep(i, 2) {
            if (d[i+1][j]-d[i+1][j+1] 
            != d[0][j] - d[0][j+1]) {
                cout << "No" << endl;
                return 0;    
            } 
        }
    }
    
    rep(i, 2) {
        rep(j, 2) {
            if (d[i+1][0]-d[i][0] 
            != d[i+1][j+1] - d[i][j+1]) {
                cout << "No" << endl;
                return 0;    
            } 
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long int numlist[100000]={},sum=0,sum1,a;
    int n=0,i=0,j=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>numlist[i];
        sum+=numlist[i];
    }
    sum1=sum;
    for(i=1;i<n-1;i+=2)
    {
        sum1=sum1-2*numlist[i];
    }
    a=sum1;
    for(i=0;i<n;i++)
    {
        cout<<a<<" ";
        a=2*numlist[i]-a;
    }
    return 0;
}


Measured memory_bytes: 2048
#空リスト作成
kei = []
ko = []

#EOFErrorが出た場合終わる
try:
    while True:
        
        #標準入力し、金額と個数をリストに加える
        a,b = map(int,input().split(","))
        kei.append(a * b)
        ko.append(b)
except EOFError:
    
    #金額の合計を出力する
    print(sum(kei))
    
    #平均値を出力する
    i = int(sum(ko) / len(ko) * 10)
    if i % 10 <= 4:print(i // 10)
    else:print(i // 10 + 1)


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

void solve()
{
    int n, Y;
    cin >> n >> Y;
    rep(x, n + 1) rep(y, n + 1)
    {
        int z = n - x - y;
        if (z < 0)
            continue;
        if (Y == 10000 * x + 5000 * y + 1000 * z)
        {
            printf("%d %d %d\n", x, y, z);
            return;
        }
    }
    printf("-1 -1 -1\n");
}

int main()
{
    solve();
    return 0;
}

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

int main(){
  int N,M;
  cin>>N>>M;
  std::vector<int> P(M),Y(M);
  for(int i=0;i<M;i++){
    cin>>P[i]>>Y[i];
    P[i]--;
  }
  std::vector<map<int,int>> m(N);
  for(int i=0;i<M;i++)m[P[i]][Y[i]]=0;
  for(int i=0;i<N;i++){
    int k=1;
    for(auto &p:m[i])p.second=k++;
  }
  for(int i=0;i<M;i++){
    cout<<setfill('0')<<right<<setw(6)<<P[i]+1;
    cout<<setfill('0')<<right<<setw(6)<<m[P[i]][Y[i]]<<endl;
  }
}


Measured memory_bytes: 11648
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
typedef unsigned long long ull;
const ull INF = 1e18;
using namespace std;

int main(){
    ll ans=0;
    int n;
    cin>>n;
    map<int,int> data;
    rep(i,0,n){
        int tmp;
        cin>>tmp;
        if(data.count(tmp)){
            data[tmp]++;
        } else{
            data[tmp]=1;
        }
        ans+=tmp;
    }
    cin>>n;
    rep(i,0,n){
        int tmp,tmp2;
        cin>>tmp>>tmp2;
        if(data.count(tmp)){
            ans+=(tmp2-tmp)*data[tmp];
            if(data.count(tmp2)){
                data[tmp2]+=data[tmp];                
            }else{
                data[tmp2]=data[tmp];
            }
            data[tmp]=0;
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

int main() {
  string s;

  cin >> s;

  if (s.substr(0, 2) == "00") {
    if (stoi(s.substr(2, 2)) < 1 or stoi(s.substr(2, 2)) > 12) cout << "NA" << endl;
    else cout << "YYMM" << endl;
  }
  else if (s.substr(2, 2) == "00") {
    if (stoi(s.substr(0, 2)) < 1 or stoi(s.substr(0, 2)) > 12) cout << "NA" << endl;
    else cout << "MMYY" << endl;
  }
  else if (stoi(s.substr(0, 2)) > 12 and stoi(s.substr(2, 2)) > 12) cout << "NA" << endl;
  else if (stoi(s.substr(0, 2)) > 12) {
    cout << "YYMM" << endl;
  }
  else if (stoi(s.substr(2, 2)) > 12) {
    cout << "MMYY" << endl;
  }
  else cout << "AMBIGUOUS" << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

const int AL = 26;
int r[AL];

int main(){
    fastIO;
    for(int i = 0 ; i < AL; i ++ )
        r[i] = (int)1e9;
    int n;
    cin >> n;
    string t;
    int cnt = 0;
    for(int i = 0 ; i < n ; i ++ ){
        cin >> t;
        for(int j = 0 ; j < AL; j ++ ){
            cnt = 0;
            for(auto p : t){
                if(p == char('a' + j)){
                    cnt ++ ;
                }
            }   
            r[j] = min(r[j], cnt);
        }
    }
    for(int i = 0 ; i < AL; i ++ )
        for(int j = 0 ; j < r[i]; j ++ )
            cout << char('a' + i);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define ll  long long int
    #define N 100000
    #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
    #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
    #define po pop_back
    #define pb push_back
    #define lb lower_bound
    #define fi first
    #define se second
    #define debug(x) cout << #x << " = " << x << endl
    #define ub upper_bound
    #define ibs ios_base::sync_with_stdio(false)
    #define cti cin.tie(0)
    #define all(x) x.begin(),x.end()
    #define PI 3.14159265
    #define cot cout.tie(0)
    using namespace std;
      /**
        * @author :: Sawlani
        *
        */
        int main()
        {
            //freopen("input.txt","r",stdin);
            ll n,k;
            cin >> n >> k;

            ll a[n+1],dp[n+1];



            f(i,1,n) cin >> a[i],dp[i]=LONG_MAX;


              dp[1]=0LL;


            f(i,2,n)
            {
                rf(j,i-1,max(1LL,i-k))
                {
                    dp[i]=min(dp[i],abs(a[i]-a[j])+dp[j]);

                }


            }

           // f(i,1,n) cout << dp[i] << endl;

             cout << dp[n];


        }


Measured memory_bytes: 1792
#include <stdio.h>

int main() {
    int n, x, i, cnt = 0, dist = 0;
    scanf("%d%d", &n, &x);
    int l[n];
    for ( i = 0; i < n; i++ ) {
        scanf("%d", &l[i]);
    }
    while ( dist <= x ) {
        dist += l[cnt];
        cnt++;
        if ( cnt == n + 1 ) {
            break;
        }
    }
    printf("%d\n", cnt);
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  string S;
  int iAC = 0;
  int iWA = 0;
  int iTLE = 0;
  int iRE = 0;
  for(int i = 0; i < N; i++){
    cin >> S;
    if(S == "AC") iAC++;
    if(S == "WA") iWA++;
    if(S == "TLE") iTLE++;
    if(S == "RE") iRE++;
  }
  cout << "AC x " << iAC << endl;
  cout << "WA x " << iWA << endl;
  cout << "TLE x " << iTLE << endl;
  cout << "RE x " << iRE << endl;
}


Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include<map>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
using namespace std;


int main() {
	long long int count;
	long long int a,b,x;
	cin >> a >> b >> x;
	if (a % x == 0) {
		count = b / x - a / x+1;
	}
	else {
		count = b / x - a / x;
	}
	cout << count;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdio.h>
using namespace std;
#define ll long long
const int pmax = 100005;
const int emax = 400005;
struct node { int to; int w; int next; } edge[emax];
int head[pmax], id = 0, vis[pmax];
int dis[pmax];
inline void add(int x, int y, int w) {
    edge[id].to = y;
    edge[id].w = w;
    edge[id].next = head[x];
    head[x] = id++;
}

bool dfs(int u) {
    vis[u] = 1;
    for (int i = head[u]; ~i; i = edge[i].next) {
        int v = edge[i].to;
        if (!vis[v]) {
            dis[v] = dis[u]+edge[i].w;
            if (!dfs(v)) return false;
        } else if (dis[u]+edge[i].w != dis[v]) return false;
    }
    return true;
}
int main(int argc, char const *argv[])
{
    int n, m;
    int a, b, c;
    memset(head, -1, sizeof head);
    memset(vis, 0, sizeof vis);
    memset(dis, 0, sizeof dis);
    cin >> n >> m;
    while (m--) {
        cin >> a >> b >> c;
        add(a, b, c); add(b, a, -c);
    }
    for (int i = 1; i <= n; i++)
        if (!vis[i]) {
            if (!dfs(i)) return 0*printf("No\n");
        }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 8576
#include <stdio.h>

int main(void)
{
	int l=0,a=0,b=0,c=0,d=0,jpday=0,mday=0;
	scanf("%d%d%d%d%d",&l,&a,&b,&c,&d);
	jpday=a/c;
	mday=b/d;
	
	if (a%c!=0)
		jpday++;
	if (b%d!=0)
		mday++;
		
	if (jpday<=mday)
		printf("%d\n",l-mday);
	else printf("%d\n",l-jpday);
	
	return 0;
}

Measured memory_bytes: 596
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()

for h in range(1, 3501):
	for n in range(1, 3501):
		if 4*h*n - N*n - N*h != 0:
			w = N*h*n/(4*h*n - N*n - N*h)
			if 0 < w and w%1 == 0:
				print(h, n, int(w))
				exit()

Measured memory_bytes: 78924
using System;

namespace abc90_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string Line1 = Console.ReadLine();
            string Line2 = Console.ReadLine();
            string Line3 = Console.ReadLine();
            string word1 = Line1[0].ToString();
            string word2 = Line2[1].ToString();
            string word3 = Line3[2].ToString();

            Console.WriteLine(word1 + word2 + word3);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define N 51
using namespace std;
int h,w,p=0;
string A,mp[N];
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
int x,y,dir;
void start();

void Forward(){
  int nx = x+dx[dir],ny = y+dy[dir];
  if(nx>=0&&ny>=0&&nx<w&&ny<h&&mp[ny][nx]!='#') x=nx,y=ny;
}
 
void Back(){
  int nx = x+dx[(dir+2)%4],ny = y+dy[(dir+2)%4];
  if(nx>=0&&ny>=0&&nx<w&&ny<h&&mp[ny][nx]!='#') x=nx,y=ny;
}
 
void getIdx(){
  char ch = A[p];
  int cnt=0;
  while(1){
    if(ch=='{')cnt+=(A[p]=='{')-(A[p]=='}');
    if(ch=='[')cnt+=(A[p]=='[')-(A[p]==']');
    p++;
    if(cnt==0) return;
  } 
}

bool kabe(){
  int nx = x+dx[dir],ny = y+dy[dir];
  if(nx<0||ny<0||nx>=w||ny>=h) return 1;
  return mp[ny][nx] == '#';
}
 
int getCheck(){
  char P = A[p];
  if(P=='N')return dir == 0;
  if(P=='E')return dir == 1;
  if(P=='S')return dir == 2;
  if(P=='W')return dir == 3;
  if(P=='C')return kabe();
  if(P=='T')return 1;
}

void While(){
  int sp = p;
  int f = A[++p]=='~';p+=f;
  int l = p;
  while(1){
    bool con = getCheck();p++;
    if(f) con = !con;
    if(con==0) break;
    start();
    p = l;
  }
  p = sp;
  getIdx();
}
 
void If(){
  assert(A[p]=='[');
  int sp = p;
  int f = A[++p]=='~';p+=f;
  bool con = getCheck();p++;
  if(f) con = !con;
  if(con) start();
  p = sp;
  getIdx();
}
 
int ans,cnt;
void start(){
  while(1){
    if(cnt++>1e7)cout<<-1<<endl,exit(0);
    char P = A[p];
    if(P == '{') While();      
    else if(P == '[')If();
    else if(P =='^'||P=='v'){
      (P=='^')? Forward():Back(),ans++,p++;
      if(mp[y][x] == 'g')cout<<ans<<endl,exit(0);
    }
    else if(P=='<'||P=='>') dir=(P=='>')?(dir+1)%4:(dir+3)%4,ans++,p++;
    else break;
  }
}
 
int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++)cin>>mp[i];
  cin>>A;

  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++) if(mp[i][j] == 's')y = i,x = j;

  start();
  cout<<-1<<endl;
  return 0;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	ll n, l;
	cin >> n >> l;
	vector<ll> a(n);
	rep(i, n)cin>>a[i];
	ll M = 0;
	int index = 0;
	rep(i,n-1){
		if(chmax(M, a[i]+a[i+1])) index = i;
	}
	if(M < l){
		cout << "Impossible" << endl;
		return 0;
	}
	cout << "Possible" << endl;
	rep(i,index){
		cout << i + 1 << endl;
	}
	for(int i = n - 1; i > index; i--){
		cout << i << endl;
	}
}


Measured memory_bytes: 1664
//#include <bits/stdc++.h>
#include <iostream> // cout, cin
#include <string> // string
#include <vector> // vector
#include <cstdint> // uintN_t
#include <iomanip> // setprecision()
#include <bitset> // bitset

using namespace std;

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

int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int ans=0;
    int h,w,k;cin>>h>>w>>k;
    vector<string> str(h);

    rep(i, h){
        cin >> str[i];
    }

    for (int y = 0; y < (1<<h); y++){
        for(int x = 0; x < (1<<w); x++){
            int black = 0;
            rep(i,h){
                rep(j,w){
                    if(str[i][j] == '#' && (y>>i)&1 && (x>>j)&1){
                        black++;
                    }
                }
            }
            if(black == k) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
int n, m;
int t[maxn];
struct data {
	int l, r, len;
	bool friend operator < (const data &a, const data &b) {
		return a.len < b.len;
	}
} a[maxn];
void add(int p, int d) {
	for(; p <= m; p += p & -p) {
		t[p] += d; 
	}
}
int query(int p) {
	int ret = 0;
	for(; p; p -= p & -p) {
		ret += t[p];
	}
	return ret;
}
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++i) {
		scanf("%d%d", &a[i].l, &a[i].r);
		a[i].len = a[i].r - a[i].l + 1;
	}
	sort(a + 1, a + n + 1);
	for(int i = 1, j = 1; i <= m; ++i) {
		while(j <= n && a[j].len < i) {
			add(a[j].l, 1);
			add(a[j].r + 1, -1);
			++j;
		}
		int ans = n - j + 1;
		for(int j = i; j <= m; j += i) {
			ans += query(j);
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int d[500010], e[500010], f[500010], ans[500010];
pair<int, int> g[500010];
int bit[500010]={};

void bitAdd(int n, int a){
	for(int i=n; i<500010; i += i&(-i)){
		bit[i] += a;
	}
}

int bitSum(int n){
	int res=0;
	for(int i=n; i>0; i -= i&(-i)){
		res += bit[i];
	}
	return res;
}

int main() {
	int N, Q;
	cin >> N >> Q;
	for(int i=1; i<=N; ++i){
		cin >> d[i];
		e[i]=f[i]=-1;
	}
	for(int i=1; i<=N; ++i){
		if(f[d[i]]>=0) e[f[d[i]]]=i;
		f[d[i]]=i;
	}
	for(int i=1; i<=N; ++i){
		if(e[i]<0) e[i]=N+1;
		g[i-1]=make_pair(e[i], i);
	}
	sort(g, g+N);
	vector<pair<pair<int, int>, int>> v(Q);
	for(int i=0; i<Q; ++i){
		int l, r;
		cin >> l >> r;
		v[i]=make_pair(make_pair(r, l-1), i);
	}
	sort(v.begin(), v.end());
	int now=0;
	for(int i=0; i<Q; ++i){
		while(now<N){
			if(g[now].first>v[i].first.first) break;
			bitAdd(g[now].second, 1);
			++now;
		}
		ans[v[i].second]=v[i].first.first-v[i].first.second;
		ans[v[i].second] -= bitSum(v[i].first.first)-bitSum(v[i].first.second);
	}
	for(int i=0; i<Q; ++i) cout << ans[i] << endl;
	return 0;
}

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

#define nax 100009
#define FOR(i,n,m) for(int i =(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back

typedef long long ll;

int main(){
	ll dp[nax];
	int n,k;
	ll h[nax];
	cin>>n>>k;
	REP(i,n) cin>>h[i];

	//dp: min costo para llegar a i
	REP(i,nax) dp[i] = 1000000000000LL;
	dp[0] = 0;
	REP(i,n){
		FOR(j,i+1,min(i+k+1,n)){
			if(dp[i]+abs(h[i]-h[j])<dp[j])
				dp[j] = dp[i]+abs(h[i]-h[j]);
		}
	}

	cout<<dp[n-1];

	return 0;
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    ll n;
    cin>>n;
    if(n%2)
    {
        cout<<"0";
        return 0;
    }
    n=n/2;
    ll ans=0;
    ll c=5;
    while(n/c>0)
    {
    	ans+=n/c;
    	c=c*5;
    }
    cout<<ans;
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

ll dp[252521][3];
constexpr ll INF=1e18;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n;
  ll a[252521];
  cin>>n;
  REP(i, n){
    cin>>a[i];
  }
  int d=1+(n&1);
  REP(i, n+3){
    REP(j, d+1){
      dp[i][j]=-INF;
    }
  }
  dp[0][0]=0;
  REP(i, n+d){
    REP(j, d+1){
      if(i<n){
        CHMAX(dp[i+2][j], dp[i][j]+a[i]);
      }
      if(j<d){
        CHMAX(dp[i+1][j+1], dp[i][j]);
      }
    }
  }
  ll ans=-INF;
  REP(i, 3){
    CHMAX(ans, dp[n+i][d]);
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 9824
using System;
using System.Linq;
using System.Collections.Generic;

class Test
{
    static void Main()
    {
        string[] r = Console.ReadLine().Split();
        int n = int.Parse(r[0]);
        int q = int.Parse(r[1]);

        Stack<int>[] A = new Stack<int>[n];
        for (int i = 0; i < n; i++)
        {
            A[i] = new Stack<int>();;
        }

        for (int i = 0; i < q; i++)
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();

            switch (array[0])
            {
                case 0:
                    A[array[1]].Push(array[2]);
                    break;
                case 1:
                    if (A[array[1]].Count != 0) Console.WriteLine(A[array[1]].Peek());
                    break;
                case 2:
                    if (A[array[1]].Count != 0) A[array[1]].Pop();
                    break;
            }
        }
    }
}



Measured memory_bytes: 23640
import java.math.*;
import java.text.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			int d = in.nextInt();
			int ret = 0;
			for(int i=d; i<=600-d; i += d){
				ret += sq(i);
			}
			System.out.println(ret*d);
		}
	}

	private static int sq(int x){
		return x*x;
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> s(H);
  for (int i=0; i<H; i++) cin >> s[i];
  vector<vector<int>> dp(H, vector<int>(W, INT_MAX));
  if (s[0][0]=='#') dp[0][0] = 1;
  else dp[0][0] = 0;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      for (int dir = 0; dir<2; dir++) {
        int ni = i+dx[dir], nj = j+dy[dir];
        if (ni>=H||nj>=W) continue;
        int add = 0;
        if (s[ni][nj]=='#'&&s[i][j]=='.') add = 1;
        dp[ni][nj] = min(dp[ni][nj], dp[i][j]+add);
      }
    }
  }
  cout << dp[H-1][W-1] << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
mod = 10**9+7
ans = 0
for i in range(60):
    b1 = np.count_nonzero(A>>i&1)
    ans += 2**i*b1*(N-b1)
    ans %= mod
print (ans)

Measured memory_bytes: 48852
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     ll           long long int
#define     int          ll
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     makep        make_pair
#define     maket        make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const ld pi=acos(-1);
const int inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n,m;
    cin>>n>>m;

    int ans=(n*(n-1))/2+(m*(m-1))/2;
    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 256
def choose(n, r, M):
    x = 1
    y = 1
 
    for i in range(r):
        x = x * (n - i) % M
        y = y * (i + 1) % M
    res = x * pow(y, M-2, M) % M
    return res
 
n, a, b = map(int, input().split())
M = 10 ** 9 + 7
 
print((pow(2, n, M) - 1 - choose(n, a, M) - choose(n, b, M)) % M)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> s(n);
  int sum = 0;
  for(auto& x:s){
    cin >> x;
    sum += x;
  }

  sort(s.begin(), s.end());

  if(sum % 10 != 0){
    cout << sum << endl;
  }else{
    int m = -1;
    for(int i = 0; i < n; i++){
      if(s[i] % 10 != 0){
        m = s[i];
        break;
      }
    }
    if(m == -1){
      cout << 0 << endl;
    }else{
      cout << sum - m << endl;
    }
  }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		arr[i] = tmp
	}
	sum := 0
	for _, k := range arr {
		sum += k - 1
	}
	fmt.Println(sum)
}

Measured memory_bytes: 768
#include<cstdio>
#include<iostream>
using namespace std;
int k[7],s[10];
int main()
{
	int i,j,n,p=0;
	for(i=1;i<=3;i++)
	{
		for(j=1;j<=6;j++)
		{
			cin>>k[j];
		}
	    for(j=3;j>=1;j--)
	    {
	    	if(k[j+3]-k[j]>=0)
	    	{
	    		p++;
	    		s[p]=k[j+3]-k[j];
			}
			else 
			{
				p++;
				k[j+2]--;
				k[j+3]+=60;
				s[p]=k[j+3]-k[j];
			}
		}
	}
	for(i=3;i>=1;i--)
	{
		if(i!=1)cout<<s[i]<<" ";
		else cout<<s[i];
	}
	cout<<endl;
	for(i=6;i>=4;i--)
	{
		if(i!=4)cout<<s[i]<<" ";
		else cout<<s[i];
	}
	cout<<endl;
	for(i=9;i>=7;i--)
	{
		if(i!=7)cout<<s[i]<<" ";
		else cout<<s[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3084
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for (auto &&e : a)
        cin >> e;
    sort(a.begin(), a.end());
    int ans = 0;
    for (const auto e : a) {
        if (x >= e) {
            ++ans;
            x -= e;
        } else
            break;
    }
    if (ans == n && x != 0)
        --ans;
    cout << ans << '\n';
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class S
{

    private const long DP_INIT_MINUS1 = -1;
    private const double DP_INIT_DOUBLE_MINUS1 = -1.0;
	private const long MOD = 1000000007;


    //s
    private const int FIRST_WIN = 1;
    private const int SECOND_WIN = 0;

    private static long[,] dp;
    private static long[] cSum;


    public static void Main()
	{
		/*
        var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        var N = input[0];
        var M = input[1];
        */

        var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        var N = input[0];
        solver(N);
        //solver(N,Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse));
    }

    public static void solver(long N){

        /*
            ABC 139 D "ModSum"
            え、何これ
        
         */
        var a = N-1;
        Console.WriteLine((a + (a*a)) / 2);

        


    }

}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
//long long…2^64-1 = 9223372036854775807まで

void _main() {
	int N;
	cin >> N;
	int count = 0;
	int num;
	int digit;

	rep(i, 1, N+1) {

		digit = log10(i) + 1;
		if (digit % 2 != 0) count++; //奇数→count
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int n;
long long int a[100001];
long long int result[100001][2];
long long int INIT = (long long int)mod * 100000;

long long int solve(int i, int j)
{
	if(i == n - 1) return a[n - 1] * (long long int)pow(-1, j);
	if(result[i][j] != INIT) return result[i][j];
	return result[i][j] = max(a[i] * (long long int)pow(-1, j) + solve(i + 1, 0), a[i] * (long long int)pow(-1, j + 1) + solve(i + 1, 1));
}

int main()
{
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		result[i][0] = result[i][1] = INIT;
	}
	cout << solve(0, 0) << endl;
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int n; cin>>n;
  vector<int> k(9,0);
  rep(i,n){
    int a; cin>>a;
    if(a<400) k[0]++;
    else if(a<800) k[1]++;
    else if(a<1200) k[2]++;
    else if(a<1600) k[3]++;
    else if(a<2000) k[4]++;
    else if(a<2400) k[5]++;
    else if(a<2800) k[6]++;
    else if(a<3200) k[7]++;
    else k[8]++;
  }
  int m=0;
  rep(i,8){
    if(k[i]!=0) m++;
  }
  // if(m==0) cout<<1<<" ";
  // else cout<<m<<" ";
  // if(m+k[8]>8) cout<<8<<endl;
  // else cout<<m+k[8]<<endl;
  int d=max(m,1);
   m+=k[8];
   cout<<d<<" "<<m<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <stdio.h>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cassert>
#include <random>
#include <time.h>
#define fi first
#define se second
#define pb emplace_back
#define all(x) x.begin(),x.end()
#define re return
#define mp make_pair

using namespace std;

typedef long long ll;

const double pi = 3.14159265;
const ll mod = 1e9 + 7;
const ll INF = 1e18;
const ll N = 1e4 + 5;
const ll P0 = 281;
const ll P1 = 257;

multiset <int> s;

ll Pow (ll a, ll p)
{
    if(p == 0)
        return 1;
    if(p % 2 == 0)
    {
        ll an = Pow(a, p / 2);
        return an * an % mod;
    }
    else
    {
        ll an = Pow(a, p - 1);
        return an * a % mod;
    }
}

int main()
{
    //freopen("ladder.in ", "r", stdin);
    //freopen("OMOMOMMG.txt", "w", stdout);
    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        int q = a[i];
        vector <int> s1;
        for (int j = 2; j * j <= q; j++)
        {
            while(q % j == 0)
            {
                q /= j;
                s1.pb(j);
            }
        }
        if(q > 1)
            s1.pb(q);
        if(i == 0)
        {
            for (int x : s1)
                s.insert(x);
            continue;
        }
        vector <int> ins;
        for (int x : s1)
        {
            if(s.find(x) != s.end())
            {
                s.erase(s.find(x));
                ins.pb(x);
            }
            else
                ins.pb(x);
        }
        for (int x : ins)
            s.insert(x);
    }
    ll q = 1;
    for (int x : s){
        q = (q * x) % mod;
    }

    ll sum = 0;
    for (int i = 0; i < n; i++)
        sum = (sum + q * Pow(a[i], mod - 2)) % mod;

    cout << sum;
}


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

using namespace std;

#define INF INT_MAX
#define F first
#define S second

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

int main(){
  int h,w,m;
  int ans=0;
  char mp[10][10];
  scanf("%d %d %d",&h,&w,&m);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      scanf(" %c",&mp[i][j]);
    }
  }
  for(int i=0;i<(1<<h);i++){
    for(int j=0;j<(1<<w);j++){
      int cnt=0;
      for(int k=0;k<h;k++){
	for(int l=0;l<w;l++){
	  if(mp[k][l]=='#'&&(i>>k&1)==0&&(j>>l&1)==0) cnt++;
	}
      }
      if(cnt==m) ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int r[1000005];
int main()
{
    int a,b,c,d,e,f,g,h,i,j,k;

    while(cin>>a)
    {

       b=a*100;
       c=a*10;
       d=b+c+a;
      j=0;

       for(g=111;g<=d;g++)
       {


           h=g;
           k=1;
           while(h!=0)
           {
               i=h%10;
               if(i!=0&&i>=1&&i<=a)
               {

               }
               else
               {
                   k=0;
               }
               h/=10;
           }
           if(k==1)
           {
               j++;
           }
       }
       cout<<j<<endl;




    }







    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF (lo)(1e9 + 7)
#define MOD (lo)(1e9 + 7)
#define mp make_pair
#define pb push_back
#define pp pop_back
using namespace std;
typedef long long int lo;
typedef pair<lo,lo> pii;
lo a,b,c;
map<string,lo> mep;

int main(){
    lo n;
    cin >> n;
    lo maxim = -1;
    string arr[n+1];
    for(lo i = 1;i <= n;i++){
        string x;
        cin >> x;
        arr[i] = x;
        mep[x]++;
        maxim = max(maxim,mep[x]);
    }
    vector<string> ans;
    for(map<string,lo> :: iterator it = mep.begin();it != mep.end();it++){
        pair <string,lo> p = *it;
        lo str = p.second;
        if(str == maxim){
            ans.pb(p.first);
        }
    }
    sort(ans.begin(),ans.end());
    for(lo i = 0;i < ans.size();i++) cout << ans[i] << endl;
}




Measured memory_bytes: 30324
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main() {
    int h, w, d, a;
    vector<pair<int, int>> c;
    
    cin >> h >> w >> d;
    c.resize(h * w);
    REP(i, h){
        REP(j, w){
            cin >> a;
            a--;
            c[a] = {i + 1, j + 1};
        }
    }
    
    int cost[90000] = {};
    for(int i = 0; i < d; i++){
        pair<int, int> p, s;
        p = c[i];
        for(int j = i + d; j < h * w; j += d){
            s = c[j];
            cost[j] = cost[j - d] + abs(p.first - s.first) + abs(p.second - s.second);
            p = s;
        }
    }
    
    int q, l, r;
    cin >> q;
    REP(i, q){
        cin >> l >> r;
        l--;r--;
        cout << cost[r] - cost[l] << endl;
    }
}


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

int binpow(int a, int b)
{
    int ans = 1;
    if (b == 0)
        return 1;
    while (b)
    {
        if (b & 1)
            ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}

//read question carefully!

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int a[n];
        for (int i = 0; i < n; ++i)
            cin >> a[i];
        int ct = 0;
        sort(a, a + n);
        for (int i = 0; i < n; ++i)
        {
            for (int j = i + 1; j < n; ++j)
            {
                for (int k = j + 1; k < n; ++k)
                {
                    if (a[i] != a[j])
                    {
                        if (a[j] != a[k])
                        {
                            if (a[i] + a[j] > a[k])
                                ct++;
                        }
                    }
                }
            }
        }
        cout << ct << "\n";
    }
}

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

using namespace std;

typedef long long ll;

//#include<ext/pb_ds/assoc_container.hpp>
//#nclude<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define pii pair<int,ll>
#define pi pair<int,ll>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define eps 10E-10
#define mod 1000000007
#define pai acos(-1)
//#define mx 1000000000
#define N 200005

ll ar[N];

int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k,n;
    cin>>k>>n;
    for(int i=1;i<=n;i++) cin>>ar[i];
    vector<ll>vc;
    vc.pb(0);
    for(int i=1;i<n;i++) vc.pb(ar[i+1]-ar[i]);
    ll mx=0;
    int id=1;
    ll s1,s2;
    s1=s2=0;
    for(int i=1;i<vc.size();i++){
        if(vc[i]>mx){
            mx=vc[i];
            id=i;
        }
        s1+=vc[i];
    }
    if(mx<(ar[1]+k-ar[n])) cout<<s1<<endl;
    else cout<<s1-mx+ar[1]+k-ar[n]<<endl;
    return 0;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long a,b,q=1;
    cin>>a>>b;
    for(int i=2;i<100000;i++){
        if(a%i==0&&b%i==0){
            q=i;
        }
    }
    cout<<(a*b)/q<<endl;
    
}


Measured memory_bytes: 3600
N, M, X = map(int, input().split())
A_list = list(map(int, input().split()))
cost_r = 0
cost_l = 0
for i in range(M):
	if A_list[i] < X:
		cost_l += 1
	if A_list[i] > X:
		cost_r += 1
print(min(cost_r, cost_l))

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n, m;
vector<P> g[100010];
int a[100010], b[100010];
bool deg[100010];
bool used[100010];
bool rev[100010];
void dfs(int x){
    used[x]=1;
    for(auto p:g[x]){
        int y=p.first;
        if(used[y]) continue;
        dfs(y);
        if(deg[y]){
            deg[y]^=1;
            deg[x]^=1;
            rev[p.second]=1;
        }
    }
}
int main()
{
    cin>>n>>m;
    for(int i=0; i<m; i++){
        cin>>a[i]>>b[i];
        g[a[i]].push_back({b[i], i});
        g[b[i]].push_back({a[i], i});
        deg[a[i]]^=1;
    }
    if(m&1){
        cout<<-1<<endl;
        return 0;
    }
    dfs(1);
    for(int i=0; i<m; i++){
        if(rev[i]) cout<<b[i]<<" "<<a[i]<<endl;
        else cout<<a[i]<<" "<<b[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 12672
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;


int main(int argc, char **argv) {
    i64 n;
    cin >> n;

    vector<pair<i64, i64>> engines;
    vector<pair<double, i64>> rads;

    for (int i=0; i<n; ++i) {
        i64 x, y;
        cin >> x >> y;
        engines.push_back(make_pair(x, y));
        double r = atan2((double)y, (double)x);
        rads.push_back(make_pair(r, i));
    }

    for (int i=0; i<n; ++i) {
        rads.push_back(make_pair(rads[i].first + 2*M_PI, rads[i].second));
    }

    sort(rads.begin(), rads.end());

    double ans{0};
    for (int left=0; left<n; ++left) {
        i64 l_idx = rads[left].second;
        double sum_x=engines[l_idx].first, sum_y=engines[l_idx].second;
        ans = max(ans, sqrt(pow(sum_x,2) + pow(sum_y, 2)));
        for (int right=left+1; right<left+n; ++right) {
            i64 idx = rads[right].second;
            //if (l_rad + M_PI/2 < r_rad) break;
            sum_x += engines[idx].first; sum_y += engines[idx].second;

            ans = max(ans, sqrt(pow(sum_x,2) + pow(sum_y, 2)));
        }
    }

    cout << setprecision(15) << ans << endl;

    return 0;
}


Measured memory_bytes: 4196
import math
def A():
    r = int(input())
    print(math.pi*(r)*2)

def B():
    N, M = map(int, input().split())
    A = [int(i) for i in input().split()]
    ans = N-sum(A)
    if ans >= 0:
        print(ans)
    else:
        print(-1)

B()

Measured memory_bytes: 9880
type triangle = {a : float; b: float; theta : float} ;;

let rad theta =
  let pi = acos ~-.1. in
  theta *. pi /. 180. ;;

let sin_theta theta = sin (rad theta) ;;
let cos_theta theta = cos (rad theta) ;;

let area a b theta = a *. b *. (sin_theta theta) /. 2. ;;
let perimeter a b theta = a +. b +. sqrt( a *. a +. b *. b -. 2. *. a *. b *. (cos_theta theta)) ;;
let height b theta = b *. sin_theta theta ;;

let () =
  let a, b, theta = Scanf.scanf "%f %f %f\n" (fun x y z -> x, y, z) in
  Printf.printf "%10f\n" (area a b theta);
  Printf.printf "%10f\n" (perimeter a b theta);
  Printf.printf "%10f\n" (height b theta);;


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

int main(void) {
    string S;
    cin>>S;
    // 0から始まるパタン
    int start_0 = 0;
    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 0) {
            if (S[i] == '1') start_0++;
        } else {
            if (S[i] == '0') start_0++;
        }
    }

    // 1から始まるパタン
    int start_1 = 0;
    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 0) {
            if (S[i] == '0') start_1++;
        } else {
            if (S[i] == '1') start_1++;
        }
    }

    cout << min(start_0, start_1) << endl;
    return 0;
}

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

int main(){
int a, b;
char op;
while(true){
    cin >> a >> op >> b;
    if(op == '?')
    break;
    int sum = 0;
    switch(op){
        case '+':
        sum = a + b;
        break;
        case '-':
        sum = a - b;
        break;
        case '*':
        sum = a * b;
        break;
        case '/':
        sum = a / b;
        break;
        case '?':
        break;
    }
    cout << sum << endl;
}
}


Measured memory_bytes: 3004
#include<iostream>
#include<algorithm>
using namespace std;
int main () {
    int c[2];
    for(int i=0;i<2;i++){
        cin>>c[i];
    }
    if((c[0]+c[1])%3==0||c[0]%3==0||c[1]%3==0){
        cout<<"Possible"<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }
    return 0;
}


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



int main(){
	
	int n;
	cin >> n;
	vector<long long> first(5,0);
	string s = "MARCH";
	for(int i = 0; i < n; i++)
	{
		string k;
		cin >> k;
		for(int j = 0; j < 5; j++)
		{
			if(k[0] == s[j]){
				first[j]++;
				break;
			}
		}
	}

	long long ans = 0;
	for(int i = 0; i < 5; i++)
	{
		for(int j = i+1; j < 5; j++)
		{
			for(int k = j+1; k < 5; k++)
			{
				ans += first[i] * first[j] * first[k];
			}
			
		}
		
		
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	string a;
	cin>>a;
	char b,c;
	b=a[0];c=a[a.size()-1];
	int d;
	d=a.size()-2;
	cout<<b<<d<<c<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
ll mod=998244353;
int inf=1000000000;
ll INF=10000000000000000;


int main(){
    int n,k;
    cin >> n >> k;
    vector<ll> a(n);
    ll sum=0;
    rep(i,n) {cin >> a.at(i);sum+=a.at(i);}
    int t=1;
    vector<ll> b(0);
    while (true){
        if (t*t>sum) break;
        if (sum%t==0) {
            b.push_back(t);
            b.push_back(sum/t);
        }
        t++;
    }
    sort(b.begin(),b.end());
    for (int i=b.size()-1;i>-1;i--){
        vector<ll> u(n);
        rep(j,n){
            u.at(j)=a.at(j)%b.at(i);
        }
        sort(u.begin(),u.end());
        ll q=k;
        int r=0,o=0,oo=n-1,mm=0;
        while (true){
            //cout << o << endl;
            if (o==oo) {cout << b.at(i) << endl;return 0;}
            if (mm==0){
                r+=u.at(o);
                o++;
                q-=u.at(o-1);
                if (q<0) break;
                mm=1;
            }
            else {
            if (r>=b.at(i)-u.at(oo)){
                r-=b.at(i)-u.at(oo);
                oo--;
            }
            else mm=0;
            }
        }
    }
}


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

int main(){
	long long n0,n1,n2;
	long long step;
	long long k;
	long long temp,wa;
	double dtmp0,dtmp1,dtmp2;
	

	cin >> k;
	int i=1;
	while(k>0 && i<10){
		cout << i <<endl;
		i++;
		k--;
	}
	if(k>0){
		cout << 19 << endl;
		k--;
	}
	
	step = 10;
	n0=19;
	n1=29;
	//dtmp1=
	dtmp0=1.9;
	dtmp1=29./11.;
	while(k>0){
		n2 = n1 + step;
		
		temp = n2;
		wa=0;
		while (temp>0){
			wa += temp%10;
			temp /= 10;
		}
		dtmp2 = (double)n2/(double)wa;
		// cout <<n0<<" "<<dtmp0<<" "<< n1 << " " << dtmp1 << " " << n2 << " "<<dtmp2<< " "<<step<<endl;
		if(dtmp2>=dtmp1){
			k--;
			cout << n1 << endl;
			step = n1 - n0;
			n0 = n1;
			dtmp0=dtmp1;
			n1 += step;
			temp = n1;
			wa=0;
			while (temp>0){
				wa += temp%10;
				temp /= 10;
			}
			dtmp1 = (double)n1/(double)wa;
		}else{
			//cout << "else"<<endl;
		
			n1 = n2;
			dtmp1=dtmp2;
		}
		
		
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int n;
  double ans=0.0, a;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    ans= ans+(1/a);
    
  }
  ans=(1/ans);
  cout << fixed << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String a = sc.next();
		String b = sc.next();
		
		if (a.length() == b.length()) {
			for (int i = 0; i < a.length(); i++) {
				int ai = Character.getNumericValue(a.charAt(i));
				int bi = Character.getNumericValue(b.charAt(i));
				if (ai != bi) {
					System.out.println(ai > bi ? "GREATER" : "LESS");
					return;
				}
			}
		} else {
			System.out.println(a.length() > b.length() ? "GREATER" : "LESS");
			return;
		}
		
		System.out.println("EQUAL");
	}
	
	
}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner scanner = new Scanner(System.in);
    try {
      int N = scanner.nextInt();
      int K = scanner.nextInt();
      int ans = 0;
      for (int i = 0; i < N; i++) {
        int h = scanner.nextInt();
        if (h >= K) ans++;
      }
      System.out.println(ans);
    }
    finally {
      scanner.close();
    }
  }
}

Measured memory_bytes: 48384