akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    string s;
    cin >> s;

    int count = 0;
    int score = 0;

    for (auto x : s)
    {
        char myhand;
        if (count > 0)
        {
            myhand = 'p';
            count--;
        }
        else
        {
            myhand = 'g';
            count++;
        }

        if (myhand == 'p')
        {
            if (x == 'g') score++;
        }
        else
        {
            if (x == 'p') score--;
        }
    }

    cout << score << endl;

    return 0;
}

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

class node;
node *root, *NIL;

class node{
public:
  node *p = NIL, *l = NIL, *r = NIL;
  int key = 0;

  node(int x) : key(x){}
};


void insert(int key){
  node *x = root, *y = NIL;
  while(x != NIL){
      y = x;
      if(key >= x->key) x = x->r;
      else x = x->l;
  }

  if(y == NIL) root = new node(key);
  else if(key >= y->key) y->r = new node(key);
  else y->l = new node(key);
}

void preorder(node* n){
  if(n == NIL) return;
  cout << " " << n->key;
  preorder(n->l);
  preorder(n->r);
}

void inorder(node* n){
  if(n == NIL) return;
  inorder(n->l);
  cout << " " << n->key;
  inorder(n->r);
}

void print(){
  inorder(root);
  cout << endl;
  preorder(root);
  cout << endl;
}

int main(){
  root = NIL;

  int n; cin >> n;
  while(n--){
    string s; cin >> s;

    if(s == "insert"){
      int x; cin >> x;
      insert(x);
    }else{
      print();
    }
  }
}



Measured memory_bytes: 26600
#include <bits/stdc++.h>
using namespace std;
#define pii             pair<int , int >
#define inf             1000000011
#define in(a)           scanf("%d", &a)
#define ins(a)          scanf("%s", a)
#define in2(a, b)       scanf("%d%d", &a, &b)
#define in3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pn              printf("\n")
#define pr(a)           printf("%d\n", a)
#define prs(a)          printf("%d ", a)
#define pr2(a, b)       printf("%d %d\n", a, b)
#define pr3(a, b, c)    printf("%d %d %d\n", a, b, c)
#define pcs(a)          printf("Case %d: ", a)
#define mp              make_pair
#define vi              vector<int >
#define _ceil(n, a)     ((n)%(a)==0?((n)/(a)):((n)/(a)+1))
#define sz              size()
#define pb              push_back
#define mem(a, b)       memset((a), (b), sizeof(a))
#define all(X)          (X).begin(), (X).end ()
#define lg2(n)          (31-__builtin_clz(n))
#define ext(a)          {printf("%s\n", a); return 0;}
#define oka(x, y)       ((x)>=0&&(x)<row&&(y)>=0&&(y)<col)
#define x               first
#define y               second
#define lc              (2*i)
#define rc              (2*i+1)

typedef long long LL;
//int  dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int  dx[]={1,1,0,-1,-1,-1,0,1,0};int dy[]={0,1,1,1,0,-1,-1,-1,0};//8 direction
//int  dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//bool check(int n, int pos) {return (n & (1<<pos))>>pos;} //typecast 1 in case of int
//int  on(int n, int pos) {return n | (1<<pos);} //typecast 1 in case of int
//int  off(int n, int pos) {return n & ~(1<<pos);} //typecast 1 in case of int
//bool operator < (const data &d) const{return cost<d.cost;} //reverse in priority queue

const int M = 500010, mod = 1000000007;

int main()
{
//#ifndef ONLINE_JUDGE
//    freopen("/home/lochness/Documents/in.txt", "r", stdin);
////    freopen("/home/lochness/Documents/in.txt", "w", stdout);
//#endif
//    ios_base::sync_with_stdio(false);

    int a, b, c, d;

    in2(a, b);
    in2(c, d);

    int l = max(a, c);
    int r = min(b, d);

    printf("%d\n", max(r-l, 0));


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

const int s = 251;

int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }

// MAIN FUNCTION
int main(int argc, char** argv)
{
	int heap[s];
	// Input
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> heap[i];
	}

	// Output
	for (int i = 1; i <= n; i++) {
		cout << "node " << i << ":";
		cout << " key = " << heap[i] << ", ";
		if (parent(i) >= 1) cout << "parent key = " << heap[parent(i)] << ", ";
		if (left(i) <= n) cout << "left key = " << heap[left(i)] << ", ";
		if (right(i) <= n) cout << "right key = " << heap[right(i)] << ", ";
		cout << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	ll n;
	cin>>n;
	map<ll,ll> mp;
	FOR(i,0,n)
	{
		ll a;
		cin>>a;
		mp[a]++;
	}
	itll it;
	forn(mp,it)
	{
		if(it->se>1)
		{
			cout<<"NO"<<Endl;
			return 0;
		}
	}
	cout<<"YES"<<Endl;
	return 0;
}


Measured memory_bytes: 16100
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        int cnt = input.nextInt();
        int[] num = new int[cnt];
        for(int i = 0; i < cnt; i ++)
            num[i] = input.nextInt();
        for(int j = cnt - 1; j > 0; j --)
            System.out.print(num[j] + " ");
        System.out.println(num[0]);
    }
}


Measured memory_bytes: 26188
#include "bits/stdc++.h"

long long COM(long long n, long long r){

    int v[n+1][n+1];
    for (int i = 0; i < n+1; i++) {
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for (int j = 1; j < n+1; j++) {
        for (int k = 1; k < j; k++) {
        v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
        }
    }
    return v[n][r];
}

using namespace std;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
//  --------------------------------------
    
    int N, M, L, R;
    int min_id, max_id;

    min_id = 0;
    max_id = 100010;

    cin >> N >> M;

    for (int i = 0; i < M; i++)
    {
        cin >> L >> R;
        if (min_id < L)
        {
            min_id = L;
        }

        if (max_id > R)
        {
            max_id = R;
        }
        
    }
    
    if (max_id - min_id + 1 < 1)
    {
        cout << 0 << "\n";
    }else{
        cout << max_id - min_id + 1 << "\n";
    }
    

}


Measured memory_bytes: 384
n,t = map(int,input().split())
a = list(map(int,input().split()))
p = 0
m = 10**9+7
ans = 0
for i in range(n):
    if p < a[i]-m:
        p = a[i]-m
        ans = 1
    elif p == a[i]-m:
        ans += 1
    m = min(m,a[i])
print(ans)


Measured memory_bytes: 14252
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	s := readString()
	fmt.Println(s[0:3])
}

var (
	scanner *bufio.Scanner
)

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

func readString() string {
	var t string

	if scanner.Scan() {
		t = scanner.Text()
	}

	return t

}


Measured memory_bytes: 1760
/*
螺旋本 p371

circumcenter:
    https://ja.wikipedia.org/wiki/%E5%A4%96%E6%8E%A5%E5%86%86#%E5%A4%96%E5%BF%83%E3%81%AE%E4%BD%8D%E7%BD%AE
    https://mathtrain.jp/goshin
*/
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 55
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

int C[110];

signed main(){
    int N;
    cin>>N;
    int maxA=0;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        C[a]++;
        chmax(maxA,a);
    }
    int minA=110;
    for(int i=0;i<=maxA;i++){
        C[max(maxA-i,i)]--;
        if(C[max(maxA-i,i)]<0){
            cout<<"Impossible"<<endl;
            return 0;
        }
        chmin(minA,max(maxA-i,i));
    }
    for(int i=0;i<110;i++){
        if(C[i] && i<=minA){
            cout<<"Impossible"<<endl;
            return 0;
        }
    }
    cout<<"Possible"<<endl;



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
using namespace std; 
#define ll  long long int
#define dbl double
#define si set<ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vi>
#define vll vector<ll>
#define vdbl vector<dbl>
#define mii map<int,int>
#define pii pair<int,int>
#define pff pair<double,double>
#define fr(i,n) for(int i=0;i<n;i++)
int mymin(vll v)
{
    return *min_element(v.begin(),v.end());
}
ll mymax(vll v)
{
    return *max_element(v.begin(),v.end());
}
ll power(ll a, ll b, ll p)
{
    ll res = 1;
    a %= p;
    while(b!=0)
    {
        if(b%2)
            res = (res%p*a%p)%p;
        b /= 2;
        a = (a%p*a%p)%p;
    }
    return res;
}
vector<string> split(string str,char delimeter)
{
    vector<string> res;
    istringstream iss(str);
    string token;
    while(getline(iss,token,delimeter))
    {
        if(token.length()>0)
        res.push_back(token);
    }
    return res;
}
void randomize (vi &arr)
{
    srand (time(NULL));
    for (int i = arr.size()-1; i > 0; i--)
    {
        int j = rand() % (i+1);
        swap(arr[i], arr[j]);
    }
}
ll mgcd(ll a, ll b)
{
    if(a==0)
        return b;
    return mgcd(b%a,a);
}
#define mxx 300001
#define sqmxx 708
#define mmm INT_MAX
#define mymod 1000000009
#define pcal 1e-19
#define pi 3.1415926535897932384
vii adj;
int val[mxx];
bool is_cycle;
int frequency[26];
bool is_Cyclic_Util(int ind,bool is_visited[],bool *rec_stack)
{
    frequency[val[ind]]++;
    if(is_visited[ind] == 0)
    {
        is_visited[ind] = 1;
        rec_stack[ind] = 1;
        fr(i,adj[ind].size())
        {
            int k = adj[ind][i];
            frequency[val[ind]]--;
            if ( !is_visited[k] && is_Cyclic_Util(k, is_visited, rec_stack) )
                return 1;
            else if (rec_stack[k])
                return 1;
        }
    }
    frequency[val[ind]]--;
    rec_stack[ind] = 0;
    return 0;
}
int main()
{
    clock_t tstart = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cout<<fixed<<setprecision(17);
    //srand ( time(NULL) );
    int a,b;
    cin>>a>>b;
    if((a*b)%2)
        cout<<"Odd";
    else
        cout<<"Even";
    //cout<<"\n\nTotal Time Taken : "<<(double)(-tstart + clock())/CLOCKS_PER_SEC<<"sec\n\n";
    return 0;
}

Measured memory_bytes: 256
program q_3
  implicit none
  integer(8) :: n,i,j,mo,seki,sum,tmp
  integer(8),allocatable :: A(:)

  mo = 10**9+7
  read(*,*) n
  allocate(A(n))
  read(*,*) A
  seki = 0
  sum = 0
  do i =1,n
     sum = sum + A(i)
  end do
!  write(*,*)sum                                                                                                                                                                                                  
  tmp = sum
  do i =1,n-1
     tmp = tmp - A(i)
 !    write(*,*)tmp                                                                                                                                                                                               
     seki = seki + mod(A(i)*mod(tmp,mo),mo)
!     do j = i+1,n                                                                                                                                                                                                
!        seki = seki + mod(A(i)*A(j),mo)                                                                                                                                                                          
!     end do                                                                                                                                                                                                      
  enddo
!  write(*,*) seki                                                                                                                                                                                                
  write(*,*) mod(seki,mo)

end program q_3

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

int seq[100000];
int n,k;

int req(int rem, int i)
{
	rem -= seq[i];
	rem += seq[i+k];
	return rem;
}
int main()
{
	while(cin >> n >> k){
		if(n==0&&k==0)
			break;
		for(int i=0;i<n;i++){
			cin >> seq[i];
		}
		int rem=0;
		for(int i=0;i<k;i++){
			rem+=seq[i];
		}
		int remm = rem;
		for(int i=0;i<n-k;i++){
			rem = req(rem,i);
			remm = max(remm,rem);
		}
		cout << remm << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define fori(i,a,n) for(i=a;i<=n;i++)
#define ford(i,n,a) for(i=n;i>=a;i--)
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
ll n,i,j,k,sum,ans;
ll gcd(ll x,ll y)
{
	if (y==0) return x;
	else return gcd(y,x%y); 
}
int main()
{
	cin>>n;
	fori(i,1,n)
	 fori(j,1,n)
	 {
	 	sum=gcd(i,j);
	 	fori(k,1,n)
	 	ans+=gcd(k,sum);
	 }
	 cout<<ans<<endl;
}

Measured memory_bytes: 3636
def divisors(n):
    lst = []; i = 1
    while i * i <= n:
        q, r = divmod(n, i)
        if r == 0:
            lst.append(i)
            if i != q: lst.append(q)
        i += 1
    return lst

N = int(input())
ans = len(divisors(N-1)) - 1
divs = divisors(N)
for k in divs:
    if k == 1: continue
    temp = N
    while temp % k == 0: temp //= k
    if temp % k == 1: ans += 1
print(ans)

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

int main() {
  string S;
  int y=0;
  char A;
  vector<int> vec(4);
  
  while (y<100) {
    cin >> A;
    y++;
    if(A=='N') vec.at(0)++;
    if(A=='W') vec.at(1)++;
    if(A=='S') vec.at(2)++;
    if(A=='E') vec.at(3)++;
  }
  if (vec.at(0) == 0) {
    if(vec.at(2) != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  if (vec.at(1) == 0) {
    if(vec.at(3) != 0) {
      cout << "No" << endl;
      return 0;
    }
  }  
  if (vec.at(2) == 0) {
    if(vec.at(0) != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  if (vec.at(3) == 0) {
    if(vec.at(1) != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(s...)  fprintf(stderr, s)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }

int N, A[100111];
int main() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);

    int last = 1;
    LL ans = 0;
    REP (i, N) {
	if (A[i] == last) {
	    last++;
	} else if (A[i] > last) {
	    int k = (A[i] - 1) / last;
	    ans += k;
	}

	if (i == 0) last = 2;
    }

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


    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    while(A>=B){
        B*=2;
        K--;
    }
    while(B>=C){
        C*=2;
        K--;
    }

    if(K>=0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

template <typename tn> void read (tn & a) {
	tn x = 0, f = 1; char c = getchar();
	while (c < '0' || c > '9'){ if (c == '-') f = -1; c = getchar(); }
	while (c >= '0' && c <= '9'){ x = x * 10 + c - '0'; c = getchar(); }
	a = f == 1 ? x : -x;
}

const int MAXN = 101000;
pair<ll, ll> x[MAXN];
ll n, ans, c;
ll sl[MAXN], sr[MAXN];
ll lm[MAXN], rm[MAXN];

int main() {
	read(n);
	read(c);
	rep(i, 1, n) read(x[i].first), read(x[i].second);
	sort(x + 1, x + 1 + n);
//	ll s = 0;
	ans = 0;
	rep(i, 1, n) {
		sl[i] = sl[i - 1] + x[i - 1].first - x[i].first + x[i].second;
		ans = max(ans, sl[i]);
		lm[i] = max(lm[i - 1], sl[i] - x[i].first);
	}
	sr[n + 1] = -c;
	for (int i = n; i >= 1; --i) {
		sr[i] = sr[i + 1] - x[i + 1].first + x[i].first + x[i].second;
		ans = max(ans, sr[i]);
		rm[i] = max(rm[i + 1], sr[i] - c + x[i].first);
		ans = max(ans, sr[i] + lm[i - 1]);
	}
	rep(i, 1, n) {
		ans = max(ans, sl[i] + rm[i + 1]);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 4992
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

from collections import Counter

n = ii()
A = iil()
s = sum(A)
d = Counter(A)

q = ii()

for i in range(q):
    b,c = iim()
    m = d.pop(b,0)
    d[c] = d.get(c,0)+m
    s += (c-b)*m
    print(s)


Measured memory_bytes: 24148
//
//  main.c
//  ITP1_8_B
//
//  Created by k16031kk on 2018/05/26.
//  Copyright © 2018年 AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int x;
    char input[1000];
    while(1) {
        x=0;
        for(int i=0; i<=1000; i++) {
            scanf("%c", &input[i]);
            if(input[0]=='0') break;
            if(input[i]=='\n') {
                printf("%d\n", x);
                break;
            }
            x+=input[i]-'0';
        }
        if(x==0) break;
    }
    return 0;
}



Measured memory_bytes: 2040
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	L := 1
	R := 100000
	for i:=0; i<m; i++ {
		var l, r int
		fmt.Scan(&l, &r)
		if L < l {
			L = l
		}
		if r < R {
			R =r
		}
	}
	r := 0
	for i := L; i<= R; i++ {
		r++
	}
	fmt.Println(r)
}

Measured memory_bytes: 5504
n = int(input())
l = []
ans = 1
for _ in range(n) :
	l.append(int(input()))
if l[0] == 2 :
	print(1)
else :
    i = l[0] - 1
    while True :
        if l[i] == 2 :
            ans += 1
            break
        i = l[i] - 1
        ans += 1
        if ans == n+1 :
            print(-1)
            exit()
    print(ans)

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

double euclidnorm(vector<int> a, vector<int> b){
    int d = a.size();
    int ssum = 0;
    for(int i=0; i<d; i++){
        ssum += pow(a[i]-b[i],2);
    }
    return pow(ssum,0.5);
}


int main(){
    int n;
    cin >> n;
    vector<vector<int>> za(n,vector<int>(2));
    for(int i=0; i<n; i++){
        cin >> za[i][0] >> za[i][1];
    }
    double ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            ans += euclidnorm(za[i],za[j]);
        }
    }
    ans = ans*2/n;
    cout << setprecision(10) << ans << endl;
}

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

int main(){
  int N;
  cin>>N;
  
  int ans = 1;
  for(int i=2;i*i<=N;i++){
    int work = i*i;
    ans = max(ans,work);
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main(){
    int a, b ,n;
    cin >> a >>b;
    n=0;

    for (int i=a; i<=b; i++){
         int b, c, d, e, f;
         b=i%10;
         c=i-b;
         c/=10;
         c%=10;
         d=i-b-c*10;
         d/=100;
         d%=10;
         e=i-b-c*10-d*100;
         e/=1000;
         e%=10;
         f=i-b-c*10-d*100-e*1000;
         f/=10000;
         f%=10;

         if (b==f && c==e){
             n++;
         }
    }

    cout << n << endl;
}

Measured memory_bytes: 256
def main():
	s = input()
	t = input()

	for i in reversed(range(len(s) - len(t) + 1)):
		if checker(s[i:(i + len(t))], t):
			s = s.replace("?", "a")
			print(s[:i] + t + s[i+len(t):])
			return
	print("UNRESTORABLE")

def checker(s, t):
	for i in range(len(s)):
		if s[i] != "?" and s[i] != t[i]:
			return False
	return True

if __name__ == '__main__':
	main()
 

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

using namespace std;

long long int gcddd(long long int x, long long int y) {
  if (y == 0) return x;
  return gcddd(y, x%y);
}

int main(){
    int K;
    long long int ans = 0,now;
    cin >> K;
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            for(int k=1;k<=K;k++){
                now = gcddd(i,j);
                ans += gcddd(now,k);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
def hdeg(h, m):
	return h * 360 / 12. + m * 360 / (12. * 60.)
def mdeg(h):
	return m * 360 / 60
for i in xrange(input()):
	h, m = map(int, raw_input().split(":"))
	d = hdeg(h, m) - mdeg(m)
	if d < 0:
		d += 360
	if d > 180:
		d = 360 - d
	if d < 30:
		print "alert"
	elif 90 <= d <= 180:
		print "safe"
	else:
		print "warning"

Measured memory_bytes: 4248
# -*- coding: utf-8 -*-
import math
import datetime

# 入力
#N = int(input())
#S = str(input())
#N, A, B = map(int, input().split())
A, B, C = map(int, input().split())

if (A-B) >= C :
  print (0)
else :
  print (C - (A-B))

Measured memory_bytes: 3312
n = int(input())
f=list()

for i in range(1,n+1):
  b=2
  while b*b <= i:
    while i%b==0:
      i //= b
      f.append(b)
    b += 1
  if i > 1:
    f.append(i)

o2=o3=o4=o14=o24=o74=0

for i in range(2,n+1):
  d=f.count(i)
  if d>=2:
    o2 += 1
  if d>=4:
    o4 += 1
  if d>=14:
    o14 += 1
  if d>=24:
    o24 += 1
  if d>=74:
    o74 += 1

print(o4*(o4-1)//2*(o2-2)+o14*(o4-1)+o24*(o2-1)+o74)

Measured memory_bytes: 3064
# solution

data=int(input())

abc=[list(map(int,input().split())) for _ in [0]*(data-1)]

q,k=map(int,input().split())

array1=[list(map(int,input().split())) for _ in [0]*q]

k-=1

tree=[[] for _ in [0]*data]

dist=[-1]*data

dist[k]=0

[tree[a-1].append([b-1,c]) for a,b,c in abc]

[tree[b-1].append([a-1,c]) for a,b,c in abc]

q=[k]

while(q):
	qq=[]
	for i in q:
		for j,k in tree[i]:
			if dist[j]<0:
				dist[j]=dist[i]+k
				qq.append(j)
	q=qq

for x,y in array1:
	print(dist[x-1]+dist[y-1])

Measured memory_bytes: 91044
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;


vecl res(1000001);

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    int N;
    cin >> N;
    vecl A(N);
    REP(i,N) cin >> A[i];
    sort(A.begin(),A.end());
    REP(i,N) res[A[i]]++;
    int ans = 0;
    REP(i,N) {
        res[A[i]]--;
        vecl e = enum_divisors(A[i]);
        bool ok = true;
        for(auto p : e) {
            if(res[p] > 0) ok = false;
        }
        if(ok) ans++;
        res[A[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12760
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll INF = 1LL << 60;

int main() {
  int N, M;
  cin >> N >> M;
  vector <int> P(M), Y(M);
  rep(i,M){
    cin >> P[i] >> Y[i];
    P[i]--;
  }

  vector<vector<int>> ans(N);
  rep(i,M){
    ans[P[i]].push_back(Y[i]);
  }

  rep(i,N){
  	sort(ans[i].begin(),ans[i].end());
  }

  rep(i,M){
    cout<< setfill('0') << setw(6) << P[i]+1;
    int num = lower_bound(ans[P[i]].begin(),ans[P[i]].end(),Y[i])-ans[P[i]].begin();
    cout<< setfill('0') << setw(6) << num+1 <<endl;
  }
}

 


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
int r,g,b;
int main()
{
    scanf("%d%d%d",&r,&g,&b);
    int tot=r*100+g*10+b;
    if(tot%4)printf("NO\n");
    else printf("YES\n");
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
using namespace std;
long long f(long long n)
{
	long long a;
	if (n==0)
	return 2;
	a=f(n-1)*2+2;
	return a;
}
int main()
{
	long long a;
	cin>>a;
	cout<<f(a)<<endl;
    return 0;
}

Measured memory_bytes: 256
ac = 0
wa = 0
tle = 0
re = 0
 
n = int(input())
 
for i in range(n):
  s = str(input())
  if s == 'AC':
    ac += 1
  elif s == 'WA':
    wa += 1
  elif s == 'TLE':
    tle += 1
  elif s == 'RE':
    re += 1

print('AC','x',ac)
print('WA','x',wa)
print('TLE','x',tle)
print('RE','x',re)


Measured memory_bytes: 9204
a = input()
b = input()
if len(a) > len(b):
    ans = 'GREATER'
elif len(b) > len(a):
    ans = 'LESS'
elif a > b:
    ans = 'GREATER'
elif b > a:
    ans = 'LESS'
else:
    ans = 'EQUAL'
print(ans)

Measured memory_bytes: 2940
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long;
#ifndef int
#define INF (0x7fffffff)
#else
#define INF (0x7fffffffffffffff)
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

#define MAX_V 112345

struct edge
{
  int to;
  int cap;
  int rev;
};

vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

// from??????to????????????cap?????????????????????
void add_edge(int from,int to,int cap)
{
  G[from].push_back((edge){to,cap,(int)G[to].size()});
  G[to].push_back((edge){from,0,(int)G[from].size()-1});
}

void bfs(int s)
{
  memset(level,-1,sizeof(level));
  queue<int> que;
  level[s]=0;
  que.push(s);
  while(!que.empty())
    {
      int v=que.front();
      que.pop();
      for(int i=0;i<(int)G[v].size();i++)
	{
	  edge &e=G[v][i];
	  if(e.cap>0&&level[e.to]<0)
	    {
	      level[e.to]=level[v]+1;
	      que.push(e.to);
	    }
	}
    }
}
  
int dfs(int v,int t,int f)
{
  if(v==t) return f;
  for(int &i=iter[v];i<(int)G[v].size();i++)
    {
      edge &e=G[v][i];
      if(e.cap>0&&level[v]<level[e.to])
	{
	  int d=dfs(e.to,t,min(f,e.cap));
	  if(d>0)
	    {
	      e.cap-=d;
	      G[e.to][e.rev].cap+=d;
	      return d;
	    }
	}
    }
  return 0;
}

// s??????t???????????§???????±???????
int dinic(int s,int t)
{
  int flow=0;
  for(;;)
    {
      bfs(s);
      if(level[t]<0)
	return flow;
      memset(iter,0,sizeof(iter));
      int f;
      while((f=dfs(s,t,INF))>0)
	flow+=f;
    }
}

signed main(void)
{
  in(int,V,E);
  int u,v,c;
  int i;
  rep(i,E)
    {
      cin>>u>>v>>c;
      add_edge(u,v,c);
    }
  putv(dinic(0,V-1));
  return 0;
}

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

int main(){

    int n, k, j;
    long int sum=0, a=0, b=0, mod=1e9+7, i;
    cin >> n >> k;
    
    for(i=k;i<=n+1;i++){
        a = (i-1)*i/2;
        b = ((2*n+(1-i))*i)/2;
        sum += b-a+1;
    }

    cout << sum%mod << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#define min(x, y) (x < y ? x : y)
int main()
{
  int N, K;
  scanf("%d %d", &N, &K);

  int array[N];
  int copy[N];

  for (int i = 0; i < N; i++)
    scanf("%d", &array[i]);

  int pos = 0;

  int sum[N - K + 1];
  int minim = INT_MAX;
  int Magic = 0;
  
  
  for (int i = 0; i < N - K + 1; i++)
  { 
    
    sum[i] = abs(array[i] - array[i + K - 1]) + min(abs(array[i]), abs(array[i + K - 1]));

  }
   
  for (int i = 0 ;i <N-K+1;i++)
  {
     if (minim>sum[i])minim=sum[i];
  }

  if (minim == INT_MAX)
    minim = 0;
  printf("%d", minim);


  return 0;
}


Measured memory_bytes: 768
import           Control.Monad
import           Data.Array.IO
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Maybe
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

main = do
  n <- getInt
  as <- getIntVec n

  cs <- VM.new 61
  forM_ [0..60] $ \i -> VM.write cs i (0::Int)

  forM_ [0..n-1] $ \i -> do
    let a = as V.! i
    forM_ [0..60] $ \j ->
      when (testBit a j) $ do
        c <- VM.read cs j
        VM.write cs j (c+1)

  let calc i x | i == -1 = return $ x `mod` 1000000007
               | otherwise = do
                   c <- VM.read cs i
                   let c1 = fromIntegral c :: Integer
                       c2 = fromIntegral (n-c) :: Integer
                       x' = c1 * c2 * bit i
                   calc (i-1) (x+x')
  ans <- calc 60 0
  print ans

Measured memory_bytes: 15996
H,W=map(int,input().split())
N=int(input())
A=[int(i) for i in input().split()]
table=[[-1]*W for i in range(H) ]
u=0
v=0
t=0
for i in range(N):
    s=A[i]
    while s>0:
        if t==0 and (u<W-1):
            table[v][u]=i+1
            u+=1
            s-=1
        elif t==0 and u==W-1:
            table[v][u]=i+1
            #u-=1
            v+=1
            t=(t+1)%2
            s-=1
        elif t==1 and u>0:
            table[v][u]=i+1
            u-=1
            s-=1
        elif t==1 and u==0:
            table[v][u]=i+1
            #u-=1
            v+=1
            t=(t+1)%2
            s-=1 
for i in range(H):
    print(' '.join(map(str,table[i])))

Measured memory_bytes: 40816
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
 



int main()
{
    fastio
    ll t,i,j,x;
    
    string s;
    cin>>s;
    
    for(i=0;i<3;i++)
    cout<<s[i];
}


Measured memory_bytes: 3604
N = int(input())
K = int(input())
X = input().split(' ')
X = [int(X[i]) for i in range(len(X)) ]
distance = 0
for i in range(N):
  if abs(X[i]) - abs(X[i]-K) > 0:
    distance += abs(X[i]-K)*2
  else:
    distance += abs(X[i])*2
print(distance)

Measured memory_bytes: 9136
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int px = sc.nextInt();
      int py = sc.nextInt();
      int[] x = new int[n];
      int[] y = new int[m];
      int maxX = -1000;
      int minY = 1000;
      boolean count = false;
      for(int i = 0;i < n;i++){
      	x[i] = sc.nextInt();
        maxX = Math.max(maxX,x[i]);
      }
      for(int i = 0;i < m;i++){
      	y[i] = sc.nextInt();
        minY = Math.min(minY,y[i]);
      }
      for(int i = py;i>px;i--){
      	if(maxX<i && i<=minY) count |= true;
      }
      if(count)System.out.println("No War");
      else System.out.println("War");
    }
}


Measured memory_bytes: 23764
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v){
    if(v.empty()){
        os<<"{ }";
        return os;
    }
    os<<"{"<<v.front();
    for(auto itr=++v.begin();itr!=v.end();itr++){
        os<<", "<<*itr;
    }
    os<<"}";
    return os;
}

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
 
//辺edge->e : 逆辺edge->path[e.to][e.rev]
struct edge{
    int to,cap,rev;
};
 
vector<vector<edge>> path;
vector<int> visited;

void add_edge(int from,int to,int cap){
    path[from].push_back((edge){to,cap,(int)path[to].size()});
    path[to].push_back((edge){from,0,(int)path[from].size()-1});
}

int dfs(int v,int t,int f){
	if (v==t)
		return f;
	visited[v]=1;
	for(edge &e:path[v]){
		if (visited[e.to]==0 && e.cap>0){
			int d=dfs(e.to,t,min(f,e.cap));
			if (d>0){
				e.cap-=d;
				path[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int flow=0;
	while(1){
		visited.assign(visited.size(),0);
		int f=dfs(s,t,inf);
		if (f==0){
			return flow;
		}
		flow+=f;
	}
}

int main(){
    int n,m; cin>>n>>m;
    vector<string> s(n);
    rep(i,n) cin>>s[i];
    path.assign(n*m+2,vector<edge>(0));
    visited.assign(n*m+2,false);
    rep(i,n)rep(j,m){
        if((i+j)%2){
            if(s[i][j]=='.')
            add_edge(i*m+j+1,n*m+1,1);
            continue;
        }
        if(i>0 && s[i-1][j]=='.' && s[i][j]=='.')
        add_edge(i*m+j+1,(i-1)*m+j+1,1);
        if(i<n-1 && s[i+1][j]=='.' && s[i][j]=='.')
        add_edge(i*m+j+1,(i+1)*m+j+1,1);
        if(j>0 && s[i][j-1]=='.' && s[i][j]=='.')
        add_edge(i*m+j+1,i*m+j,1);
        if(j<m-1 && s[i][j+1]=='.' && s[i][j]=='.')
        add_edge(i*m+j+1,i*m+j+2,1);

        if(s[i][j]=='.')
        add_edge(0,i*m+j+1,1);
    }
    cout<<max_flow(0,n*m+1)<<endl;
    int xi,yi;
    rep(i,n)rep(j,m){
        if((i+j)%2) continue;
        for(auto e:path[i*m+j+1]){
            if(e.to>0 && e.cap==0){
                xi=(e.to-1)/m;
                yi=(e.to-1)%m;
                if(xi-i==1 && yi-j==0){
                    s[i][j]='v';
                    s[xi][yi]='^';
                }
                if(xi-i==-1 && yi-j==0){
                    s[i][j]='^';
                    s[xi][yi]='v';
                }
                if(xi-i==0 && yi-j==1){
                    s[i][j]='>';
                    s[xi][yi]='<';
                }
                if(xi-i==0 && yi-j==-1){
                    s[i][j]='<';
                    s[xi][yi]='>';
                }
                break;
            }
        }
    }
    rep(i,n) cout<<s[i]<<endl;
}

Measured memory_bytes: 4808
n, W, H = [int(i) for i in input().split()]
X = [[int(i) for i in input().split()] for j in range(n)]

imos_h = [0] * (H + 2)
imos_w = [0] * (W + 2)

for x, y, w in X:
  imos_h[max(0, y - w)] += 1
  imos_h[min(H + 1, y + w)] -= 1
  imos_w[max(0, x - w)] += 1
  imos_w[min(W + 1, x + w)] -= 1
  
for h in range(H):
  imos_h[h + 1] += imos_h[h]
  
for w in range(W):
  imos_w[w + 1] += imos_w[w]

is_w = all(imos_w[w] >= 1 for w in range(W))
is_h = all(imos_h[h] >= 1 for h in range(H))

if is_h or is_w:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 33368
# https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_b

"""
   A(V)             B(W)
---------------------------------

"""

A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if V < W:
    print("NO")
else:
    if abs(B - A) <= abs(W - V) * T:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 61804
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifndef ONLINE_JUDGE
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}


char s[200005];
int cnt[30];
int main(){
#ifdef LOCAL_REDIR
  freopen("/home/hog/Dropbox/pg/working/in.txt","r",stdin);
#endif
  cin>>s;
  int n=strlen(s);
  REP(i,n) ++cnt[s[i]-'a'];

  lint res=0;
  REP(i,26){
    res+=cnt[i]*(lint)(n-cnt[i]);
  }
  assert(res%2==0);
  res/=2;
  cout<<res+1<<endl;

  return 0;
}






Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
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; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    cin >> A;
    bool flag = false;
    auto operation = [&]() {
        vector<int> plus(N), minus(N), ret(N);
        for (int i = 0; i < N; i++) {
            plus[max(0, i - A[i])]++;
            minus[min(N - 1, i + A[i])]++;
        }
        int now = 0;
        int check = 0;
        for (int i = 0; i < N; i++) {
            now += plus[i];
            ret[i] = now;
            if (ret[i] == N) check++;
            now -= minus[i];
        }
        if (check == N) flag = true;
        A = ret;
    };
    while (K--) {
        operation();
        if (flag) break;
    }
    for (int i = 0; i < N; i++) {
        cout << A[i] << (i == N - 1 ? '\n' : ' ');
    }
}

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

int main(){
	int n, W; cin >> n >> W;
	int v[n], w[n];
	for(int i=0; i<n; i++){
		cin >> v[i] >> w[i];
	}
	vector<vector<int>> dp = vector<vector<int>>(n+1, vector<int>(W+1, -1));
	dp[0][0] = 0;
	for(int i=0; i<n; i++)for(int j=0; j<=W; j++)if(dp[i][j] >= 0){
		dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
		if(j + w[i] <= W){
		    dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]], dp[i][j] + v[i]);
		    dp[i][j+w[i]] = max(dp[i][j+w[i]], dp[i][j] + v[i]);
		}
	}
	int ans = 0;
	for(int j=0; j<=W; j++){
		ans = max(ans, dp[n][j]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 6824
n,*z=`dd`.split.map &:to_i;t=*0...n;*e=t;a=z.shift n+1;n.downto(1){|i|a[i]-=a[i-1]};k,*z=z;z.map{|x|t[x-2,2]=t[x-1],t[x-2]};60.times{|i|k[i]>0&&e.map!{|q|t[q]};t=t.map{|q|t[q]}};k,*a=a
#e.map{|q|p k;k+=a[q]}
n.times{|i|p k;k+=a[e[i]]}

Measured memory_bytes: 57184
#include <iostream>
#include <cstdlib>
#include <string>
#include <stack>
using namespace std;

int main() {
	stack<int> S;
	int a, b;
	string s;

	while (cin >> s) {
		if (s[0] == '+') {
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(a + b);
		}
		else if (s[0] == '-') {
			b = S.top();
			S.pop();
			a = S.top();
			S.pop();
			S.push(a - b);
		}
		else if (s[0] == '*') {
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(a*b);
		}
		else {
			S.push(atoi(s.c_str()));
		}
	}

	cout << S.top() << endl;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

template<uint32_t mod>
struct ModInt{
	uint32_t a;
	ModInt& s(uint32_t vv){
		a=vv<mod?vv:vv-mod;
		return *this;
	}

	ModInt(int64_t x=0){s(x%mod+mod);}

	ModInt& operator+=(const ModInt &x){return s(a+x.a);}
	ModInt& operator-=(const ModInt &x){return s(a+mod-x.a);}
	ModInt& operator*=(const ModInt &x){
		a=uint64_t(a)*x.a%mod;
		return *this;
	}
	ModInt& operator/=(const ModInt &x){
		*this*=x.inv();
		return *this;
	}

	ModInt operator+(const ModInt &x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt &x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt &x)const{return ModInt(*this)*=x;}
	ModInt operator/(const ModInt &x)const{return ModInt(*this)/=x;}
	bool operator==(const ModInt &x)const{return a==x.a;}
	bool operator!=(const ModInt &x)const{return a!=x.a;}
	bool operator<(const ModInt &x)const{return a<x.a;}

	ModInt operator-()const{return ModInt()-*this;}
	ModInt pow(int64_t n)const{
		ModInt res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}

	ModInt inv()const{return pow(mod-2);}
};

template<uint32_t mod>
istream& operator>>(istream& in,ModInt<mod>& a){
	return (in>>a.a);
}
template<uint32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
	return (out<<a.a);
}
using mint=ModInt<1000000007>;
//using mint=ModInt<998244353>;

template<class Mint,int32_t lg>
struct ModIntTable{
	int N;
	vector<Mint>facts,finvs,invs;
	ModIntTable():N(1<<lg),facts(N),finvs(N),invs(N){
		const uint32_t mod=Mint(-1).a+1;
		invs[1]=1;
		for(int i=2;i<N;i++)invs[i]=invs[mod%i]*(mod-mod/i);

		facts[0]=1;
		finvs[0]=1;
		for(int i=1;i<N;i++){
			facts[i]=facts[i-1]*i;
			finvs[i]=finvs[i-1]*invs[i];
		}
	}
	inline Mint fact(int n)const{return facts[n];}
	inline Mint finv(int n)const{return finvs[n];}
	inline Mint inv(int n)const{return invs[n];}
	inline Mint binom(int n,int k)const{return facts[n]*finvs[k]*finvs[n-k];}
	inline Mint perm(int n,int k)const{return facts[n]*finvs[n-k];} 
};
ModIntTable<mint,21>mtable;

signed main(){
	int X,Y;
	cin>>X>>Y;

	int s=X-2*Y;
	int t=-2*X+Y;

	if(s%3||t%3){
		cout<<0<<endl;
		return 0;
	}
	s/=-3;
	t/=-3;
	if(s<0||t<0){
		cout<<0<<endl;
		return 0;
	}

	cout<<mtable.binom(s+t,s)<<endl;
	return 0;
}

Measured memory_bytes: 24832
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){
	ll N; cin >> N;
	vl b(N);
	FOR(i, 0, N) cin >> b[i];

	vl res;
	while (sz(b)) {
		ll nxt = -1;

		FOR(i, 0, sz(b)) {
			if (b[i] == i+1) nxt = i;
		}

		if (nxt == -1) {
			cout << -1 << endl;
			return 0;
		} else {
			res.pb(nxt+1);
			b.erase(b.begin()+nxt);
		}
	}

	FORD(i, 0, sz(res)) {
		cout << res[i] << endl;
	}

	
} //cin.tie(0) bei schnellem Wechseln


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 18 10:08:18 2020

@author: liang
"""
N = int(input())
A = [int(x) for x in input().split()]
ans = 0
for a in A:
    while a%2 == 0:
        a //= 2
        ans += 1
print(ans)

Measured memory_bytes: 10036