akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    static int N;
    static int[] A;
    static int[] X;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        A = new int[N];
        X = new int[N+1];
        X[0] = -1;
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            X[A[i]] = i;
        }
        System.out.println( solve() );
    }

    private static long solve() {
        TreeSet<Integer> indice = new TreeSet<>();
        long sum = 0;
        for (int a = 1; a <= N; a++) {
            int ai = X[a];

            Integer left = indice.lower(ai);
            Integer right = indice.higher(ai);

            int l;
            if( left == null ) {
                l = ai + 1;

            } else {
                l = ai - left;
            }

            int r;
            if( right == null) {
                r = N - ai;

            } else {
                r = right - ai;
            }

            sum += (long)a * l * r;

            indice.add(ai);
        }
        return sum;
    }

    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 54636
using System;
namespace ConsoleApplication1{
    class Program{
        static void Main(string[] args){
            int n = int.Parse(Console.ReadLine());
            double px,py,r;
            for(int i=0;i<n;i++){
                String[] str = Console.ReadLine().Split();
                double x1 = double.Parse(str[0]);
                double y1 = double.Parse(str[1]);
                double x2 = double.Parse(str[2]);
                double y2 = double.Parse(str[3]);
                double x3 = double.Parse(str[4]);
                double y3 = double.Parse(str[5]);
                px=((2*(y2-y1))*(x1*x1-x3*x3+y1*y1-y3*y3)-(2*(y3-y1))*(x1*x1-x2*x2+y1*y1-y2*y2))/((2*(x2-x1))*(2*(y3-y1))-(2*(x3-x1))*(2*(y2-y1)));
                py=((x1*x1-x2*x2+y1*y1-y2*y2)*(2*(x3-x1))-(x1*x1-x3*x3+y1*y1-y3*y3)*(2*(x2-x1)))/((2*(x2-x1))*(2*(y3-y1))-(2*(x3-x1))*(2*(y2-y1)));
                r=Math.Sqrt((x1-px)*(x1-px)+(y1-py)*(y1-py));
                Console.WriteLine("{0:f3} {1:f3} {2:f3}",px,py,r);
            }
        }
    }
}

Measured memory_bytes: 19984
#include <iostream>

using namespace std;

char tile[101][101];
bool visited[101][101];

int main(){
	int w,h;
	while(1){
		int x,y;
		cin >> h >> w;
		for(int i=0;i < h;i++)
			for(int j=0;j < w;j++)
				visited[i][j] = false;
		if(!(w|h)) break;
		for(int i=0;i < h;i++)
			for(int j=0;j < w;j++)
			 cin >> tile[i][j];
		x = y = 0;
		while(1){
			if(visited[x][y] == false) visited[x][y] = true;
			else {
				x = y = 10000;break;
			}
			if(tile[x][y] == '>') y++;
			else if(tile[x][y] == 'v') x++;
			else if(tile[x][y] == '^') x--;
			else if(tile[x][y] == '<') y--;
			else if(tile[x][y] == '.') break;
		}
		if(x == 10000){
			cout << "LOOP" << endl;
	    }
		else cout << y << ' ' << x << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
#define INF 1e9;


int main()
{
	string str;
	int n;
	cin>>n;
	cin>>str;
	int *westLeft = new int [n+2];
	int *eastRight = new int [n+2];
	for(int i = 0; i < n+2; i++){
		westLeft[i] = 0;
		eastRight[i] = 0;
	}
	for(int i = 0; i < n; i++){
		if(str[i] == 'W'){
			westLeft[i+2] = westLeft[i+1] + 1;
		}else{
			westLeft[i+2] = westLeft[i+1];
		}
	}
	for(int i = n-1; i >= 0; i--){
		if(str[i] == 'E'){
			eastRight[i] = eastRight[i+1] + 1;
		}else{
			eastRight[i] = eastRight[i+1];
		}
	}
	/*for(int i = 0; i < n + 2; i++){
		cout<<eastRight[i]<<" ";
	}
	cout<<endl;*/
	int ans = INF;
	for(int i = 1; i <= n+1; i++){
		ans = min(ans, westLeft[i] + eastRight[i]);
	}
	cout<<ans<<endl;
	return 0;
}



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

#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)


int main(){
  FIN;
  string pal;
  cin >> pal;
  long long ans=0, cont=0;
  for(long i=0; i<pal.size(); i++)
  {
    if(pal[i]=='B') cont++;
    if(pal[i]=='W') ans+=cont;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s, t;
	int x = 0;
	cin >> s;
	cin >> t;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i])
			x++;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 3896
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
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

H, W = MAP()
sy, sx = MAP()
gy, gx = MAP()
sx += 1
sy += 1
gx += 1
gy += 1
S = ["#"*(W+4)]*2+["##"+input()+"##" for _ in range(H)]+["#"*(W+4)]*2
dist = [[10**6]*(W+4) for _ in range(H+4)]
dist[sy][sx] = 0
q = deque()
q.append((sy, sx, 0))

while q:
    y, x, cnt = q.popleft()
    if dist[y][x] != cnt:
        continue
    for dx in range(-2, 3):
        for dy in range(-2, 3):
            ny = y+dy
            nx = x+dx
            if abs(dx)+abs(dy) > 1:
                if S[ny][nx] == "." and dist[ny][nx] >  dist[y][x]+1:
                    dist[ny][nx] = cnt + 1
                    q.append((ny, nx, cnt+1))
            else:
                if S[ny][nx] == "." and dist[ny][nx] > dist[y][x]:
                    dist[ny][nx] = cnt
                    q.appendleft((ny, nx, cnt))
# print(*dist, sep="\n")
print(dist[gy][gx] if dist[gy][gx] != 10**6 else -1)


Measured memory_bytes: 99664
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = int(arr_data[0][0])
a = int(arr_data[0][1])
b = int(arr_data[0][2])

print(n*a if n*a < b else b)

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i,m,n) for(ll i=m ; i<n ; i++)
#define forr(i,m,n) for(ll i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N =1e5+5;
using namespace std;
int main()
{
    int n,mx=0; cin>>n;
    map<string,int>mp;
    rep(i,0,n){
    string s; cin>>s;
    mp[s]++;
    }
    for(auto i:mp){
        mx=max(mx,i.second);
    }

    for(auto i:mp){
        if(i.second==mx)
            cout<<i.first<<endl;

    }





}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(std::chrono::duration_cast<std::chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=100005;
#define M 1000000007
#define double long double
#define BINF 10000000000000000
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;


#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);
 


    int a, b;
    cin >> a >> b;
    a ^= b;
    
    cout << a << endl;



return 0;
}




Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

class Data{
    public:
    ll a;
    ll b;
    ll eval;
};

bool comp(const Data& f, Data& s){
    return f.eval > s.eval;
}

int main(void){
    ll n;
    cin >> n;

    vector<Data> l(n);
    

    for(int i = 0; i < n; i++){
        Data tmp;
        cin >> tmp.a >> tmp.b;
        tmp.eval = tmp.a + tmp.b;
        l[i] = tmp;
    }

    sort(l.begin(), l.end(), comp);

    ll tak = 0;
    ll aok = 0;

    for(int i = 0; i < n; i++){
        if(i % 2 == 0){
            tak += l[i].a;
        } else {
            aok += l[i].b;
        }
    }

    cout << tak - aok << endl;
    
}

Measured memory_bytes: 2560
#include<cstdio>
using namespace std;
int n,m,num;
int a[210][210];
void findnex(int &x,int &y){
	if(x&1){
		if(y==m)
			x++;
		else
			y++;
	}
	else{
		if(y==1)
			x++;
		else
			y--;
	}
}
int main()
{
//	freopen("B.in","r",stdin);
	scanf("%d%d%d",&n,&m,&num);
	int cnt;
	int x=1,y=1;
	for(int i=1;i<=num;i++)
	{
		scanf("%d",&cnt);
		while(cnt--)
		{
			a[x][y]=i;
			findnex(x,y);
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			printf("%d ",a[i][j]);
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 256
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);

	int N;
	cin>>N;
	switch(N%10)
	{
		case 2:
		case 4:
		case 5:
		case 7:
		case 9: cout<<"hon"<<endl;
				break;
		case 0:
		case 1:
		case 6:
		case 8: cout<<"pon"<<endl;
				break;
		default: cout<<"bon"<<endl;
				 break;
	}
	return 0;
}


Measured memory_bytes: 3612
#pragma GCC optimize("O3")

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

#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rep2(i,a,n) for(ll i=a;i<(n);++i)
#define repr(i,n) for(ll i=n;i>=0; --i)
#define repr2(i,a,n) for(ll i=n;i>=a; --i)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define VEC(v) vector<v >

#define INT(...) int __VA_ARGS__;IN(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;IN(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;IN(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;IN(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;IN(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;IN(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;IN(__VA_ARGS__)

int scan(){ return getchar(); }
void scan(int& a){ cin>>a; }
void scan(long long& a){ cin>>a; }
void scan(char &a){cin>>a;}
void scan(double &a){ cin>>a; }
void scan(long double& a){ cin>>a; }
void scan(char a[]){ scanf("%s", a); }
void scan(string& a){ cin >> a; }
template<class T> void scan(vector<T>&);
template<class T, size_t size> void scan(array<T, size>&);
template<class T, class L> void scan(pair<T, L>&);
template<class T, size_t size> void scan(T(&)[size]);
template<class T> void scan(vector<T>& a){ for(auto& i : a) scan(i); }
template<class T> void scan(deque<T>& a){ for(auto& i : a) scan(i); }
template<class T, size_t size> void scan(array<T, size>& a){ for(auto& i : a) scan(i); }
template<class T, class L> void scan(pair<T, L>& p){ scan(p.first); scan(p.second); }
template<class T, size_t size> void scan(T (&a)[size]){ for(auto& i : a) scan(i); }
template<class T> void scan(T& a){ cin >> a; }

void IN(){}
template <class Head, class... Tail> void IN(Head& head, Tail&... tail){ scan(head); IN(tail...); }

int in() {int x;cin>>x;return x;}
ll llin() {unsigned long long x;cin>>x;return x;}

#define ios cin.tie(NULL), ios_base::sync_with_stdio(false)
#define cfs(n) cout<<fixed<<setprecision((n))
#define endl '\n'
#define ret return 0

constexpr ll mod=998244353;
constexpr ll mod2=10e9+7;
const double PI = 3.1415926535897932384626433832795028841971; //acos(-1)

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
// endmacro

int main(){
  ios; cfs(15);
  INT(n);
  int x = n/1000;
  if(n%1000>0) cout<<((x+1)*1000)-n<<endl;
  else cout << 0 << endl;
  ret;
}


Measured memory_bytes: 3692
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int n,k;
map<ll,ll> m;

int main(){
    
	cin >> n >> k;
	set<ll> s;
	
	rep(i,0,n){
        int a;
        cin >> a;
        m[a]++;
	}
	
    vector<pair<ll,ll>> v;
    for(auto i:m){
        v.pb(make_pair(i.sd,i.ft));
    }
    vsort(v);

    ll del = sz(m) - k;
    ll ans = 0;
    
    for(auto i : v){
        if(del <= 0)break;
        ans += i.ft;
        del--;
       // cout << i.ft << " " << i.sd << endl;
    }

	
	P(ans);
	return  0;
}

Measured memory_bytes: 18800
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<utility>
#include<algorithm>
using namespace std;

vector < vector<pair<int, int>>> g;
vector<int> ans;

void dfs(int node, int from = -1, int fromColor = -1) {
    int color = 1;
    for (int i = 0; i < (int)g[node].size(); i++) {
        int to = g[node][i].first;
        int id = g[node][i].second;

        if (to == from)
            continue;

        if (color == fromColor)
            color++;

        ans[id] = color;
        dfs(to, node, color);
        color++;
    }
}

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

    vector<int> a(N - 1), b(N - 1);
    for (int i = 0; i < N-1; i++)
        cin >> a[i] >> b[i];

    g.resize(N);
    for (int i = 0; i < N-1; i++) {
        a[i]--;
        b[i]--;

        g[a[i]].push_back(make_pair(b[i], i));
        g[b[i]].push_back(make_pair(a[i], i));
    }

    ans = vector<int>(N - 1);
    dfs(0);

    cout << *max_element(ans.begin(), ans.end()) << endl;
    for (int i = 0; i < (int)ans.size(); i++)
        cout << ans[i] << endl;


    return 0;
}


Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
大きい順に置くのが最適
*/

ll n,a[200010],ans=0;

int main(void){
	cin>>n;
	rep(i,n)cin>>a[i];
	sort(a,a+n,std::greater<>());
	ans=a[0];
	reg(i,1,n/2-1)ans+=a[i]*2;
	if(n%2==1)ans+=a[n/2];
	cout<<ans<<endl;
	return 0;
}

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

int n;
int a[3];

int main(){
	int r;
	fill(a, a + 2, 0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> r;
		switch (r % 3) {
		case 0:a[0]++; break;
		case 1:a[1]++; break;
		case 2:a[2]++; break;
		default:break;
		}
	}
	int m = a[1] > a[2] ? a[2] : a[1];
	if (a[1] == 0 && a[2] == 0) {
		cout << 1 << endl;
		return 0;
	}
	if (abs(a[1]-a[2]) <= 3 ) {
		cout << n << endl;
	}
	else {
		cout << m * 2 + a[0] + 3 << endl;
	}

	return 0;
}

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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, A, B;
long long H[100000];

bool f(long long X) {
  long long c = 0;
  rep(i, N) {
    long long h = H[i] - 1LL*X*B;
    if (h > 0) c += (h+(A-B)-1)/(A-B);
  }
  return c <= X;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> A >> B;
  rep(i, N) cin >> H[i];

  int lo = 0, hi = MOD;
  while (hi - lo > 1) {
    int mid = (lo + hi) / 2;
    if (f(mid)) hi = mid;
    else lo = mid;
  }
  cout << hi << "\n";
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        int A;
        int B;
        Scanner sc = new Scanner(System.in);

        A = sc.nextInt();
        B = sc.nextInt();

        if (A > 8 || B > 8) {
            System.out.println(":(");
        } else {
            System.out.println("Yay!");
        }
    }
}


Measured memory_bytes: 22868
#include <iostream>

using namespace std;
typedef long long ll;

ll sub(ll x){
    if(x <= 0){
        return 0;
    }else if(x % 2){
        if((x + 1) / 2 % 2){
            return 1;
        }else{
            return 0;
        }
    }else{
        return sub(x - 1) ^ x;
    }
}

int main(){
    ll a, b;
    cin >> a >> b;
    cout << (sub(a - 1) ^ sub(b)) << endl;
    return 0;
}


Measured memory_bytes: 256
nums = input().split(' ')
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])
d = int(nums[3])

multi = []
multi.append(a * c)
multi.append(a * d)
multi.append(b * c)
multi.append(b * d)

ans = - 10 ** 18
for i in range(4):
    if multi[i] > ans:
        ans = multi[i]

print(ans)

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

const ll MOD = 1e9 + 7;

const int MAX = 1e5 + 10;

ll a[MAX],b[MAX],c[MAX]={0},orig[MAX];

bool cmp(int l,int r){
	return (orig[l]-a[l]) <= (orig[r]-a[r]);
}

int main()
{
	int n; cin>>n;
	 bool ok=true;

	for(int i=0;i<n;i++) {cin>>a[i]; orig[i]=a[i];}
	for(int i=0;i<n;i++) cin>>b[i];
	
	ll d=0;

	for(int i=0;i<n;i++){
		if(a[i]-b[i]>0){
			ll r = a[i]-b[i];
			d += r ; a[i] -= r; c[i]=1;
		}
	}

	for(int i=0;i<n;i++){
		if(c[i]==0){
			ll req = b[i]-a[i];
			a[i] += req;
			d -= req;
			if(d < 0){
				ok=false; break;
			}
		}
	}

	if(!ok) {cout<<"-1"; return 0;}

	vector<ll> dd;

	for(int i=0;i<n;i++){
		if(c[i]==1) dd.push_back(i);
	}	
	
	sort(dd.begin(), dd.end(),cmp);

	for(ll x:dd){
		ll req = orig[x]-a[x];
		if(req > d) break;
		else {
			d -= req; a[x] += req;
		}
	}
	ll ans=0;
	for(int i=0;i<n;i++) if(a[i] != orig[i]) ans++;

	cout<<ans;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n;
  cin >> n;
  map<int,int> a;
  rep(i,n){
    int tmp;
    cin >> tmp;
    a[tmp]++;
  }
  
  int ans = 0;
  for(auto b:a){
    if(b.second%2) ans++;
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 4992
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n,k=MI()
	A=LI()

	for i in range(n-k):
		if A[i]<A[k+i]:
			print("Yes")
		else:
			print("No")



if __name__ == "__main__":
	main()


Measured memory_bytes: 92844
use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::cmp::*;
use std::collections::*;
use std::iter::Iterator;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
  input! {
  mut a: i64,
  mut b: i64,
  mut c: i64,
  mut k: i64,
  }

  let mut cnt = 0;
  let mut success = true;
  while b <= a {
    b = b * 2;
    cnt += 1;
    if cnt > k {
      success = false;
      break;
    }
  }


  if success {
    while c <= b {
      c = c * 2;
      cnt += 1;
      if cnt > k {
        success = false;
        break;
      }
    }
  }


  if success {
    println!("{}", "Yes");
  } else {
    println!("{}", "No");
  }
}


Measured memory_bytes: 2168
import math
N, M = map(int, input().split())

if abs(N-M) >= 2:
  print(0)
  exit()

if N == M:
  print((math.factorial(N) * math.factorial(M)) * 2 % (10**9 + 7))
else:
  print((math.factorial(N) * math.factorial(M)) % (10**9 + 7))

Measured memory_bytes: 5176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		long[] maxr = new long[n];
		long[] minl = new long[n];
		
		long cap = sc.nextLong();
		
		long curma = 9999999999999l;
		for(int i = 0; i < n; i++)
		{
			a[i] = sc.nextLong();
			curma = Math.min(curma, a[i]);
			minl[i] = curma;
		}
		curma = 0;
		for(int i = n-1; i >= 0; i--)
		{
			curma = Math.max(curma, a[i]);
			maxr[i] = curma;
		}
		
		
		long maxdif = 0;
		for(int i = 0; i < n-1; i++)
		{
			maxdif = Math.max(maxdif, maxr[i+1] - a[i]);
		}
		
//		System.out.println("Init maxdif; " + maxdif);
		int[] role = new int[n];
		
		int ls = 0;
		int rs = 0;
		for(int i = 0; i < n; i++)
		{
//			System.out.println("now " + a[i]);
			if(i<n-1)
			{
//				System.out.println("maxr " + maxr[i+1]);
			}
			if(i>0)
			{
//				System.out.println("minl " + minl[i-1]);
				
			}
			if(i < n-1 && maxr[i+1]-a[i] == maxdif)
			{
				role[i] = 1; //role L.
				ls++;
			}
			if(i > 0 && a[i] - minl[i-1] == maxdif)
			{
//				if(role[i] == 1)System.out.println("ERROR!");
				role[i] = 2;
				rs++;
			}
			
		}
//		System.out.println(ls + " " + rs);
		System.out.println(Math.min(ls, rs));
	}

}


Measured memory_bytes: 60704
#include <iostream>
#include <tuple>
#include <queue>

using namespace std;

using T3=tuple<int,int,int>;

int main(){
    int H,W;
    cin>>H>>W;
    char M[H][W];
    int dist[H][W];
    queue<T3> Q;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>M[i][j];
            if(M[i][j]=='%'){
                dist[i][j]=0;
                Q.push(T3(i,j,0));
            }else{
                dist[i][j]=1000000;
            }
        }
    }
    int dist_p = 1000000, dist_s=1000000;
    while(!Q.empty()){
        int i,j,d;
        tie(i,j,d)=Q.front();
        Q.pop();
        if(M[i][j]=='@') dist_p=d;
        if(M[i][j]=='$') dist_s=min(dist_s,d);
        int diff[5]={0,-1,0,1,0};
        for(int k=0;k<4;k++){
            if(i+diff[k]<0||i+diff[k]>=H||j+diff[k+1]<0||j+diff[k+1]>=W) continue;
            if(M[i+diff[k]][j+diff[k+1]]!='#'&&dist[i+diff[k]][j+diff[k+1]]==1000000){
                dist[i+diff[k]][j+diff[k+1]]=d+1;
                Q.push(T3(i+diff[k],j+diff[k+1],d+1));
            }
        }
    }
    if(dist_p<dist_s){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define multis          multiset <int, greater <int> > gquiz1;
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

void ayushmehta651()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
}

int32_t main()
{
	ayushmehta651();
	char s;
	cin >> s;

	if (s >= 'A' && s <= 'Z')
		cout << "A" << '\n';
	else
		cout << 'a' << '\n';
	return 0;
}

Measured memory_bytes: 3648
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N = int(input())
A = list(map(int, input().split()))

cnt = 0
d = defaultdict(int)
for i, a in enu(A):
    l = (i+1) + a
    r = (i+1) - a
    cnt += d[r]
    d[l] += 1
print(cnt)

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

typedef long long ll;

ll n,k;
ll ans;

ll work(ll x,ll y){
    if(x==y) return x;
    if(x<y) swap(x,y);
    if(x%y==0) return 2ll*x-y;
    return work(y,x%y)+x/y*y*2ll;
}

int main(){

    scanf("%lld%lld",&n,&k);
    ans=n;
    ll a=k,b=n-k;
    ans+=work(a,b);
    printf("%lld",ans);

    fclose(stdin);
    fclose(stdout);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <limits>
#include <iostream>
#include <assert.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	int x,y,cost;
};
int main(){

	int n;
	cin>>n;
	string a;
	char c[101],t[101];
	rep(i,n){
		cin>>c[i];
	}
	rep(i,n){
		cin>>t[i];
		a+=c[i];
		a+=t[i];
	}
	cout<<a<<endl;
	return 0;

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans,n,a[111111];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		if(a[i]%2==0)
		{
			ans+=a[i]/2;
			a[i]=0;
			continue;
		}
		ans+=a[i]/2;
		a[i]=1;
		if(i!=n-1 && a[i+1])
		{
			a[i]--;
			a[i+1]--;
			ans++;
		}
		if(i && a[i-1])
		{
			a[i]--;
			a[i-1]--;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;
using System.Numerics;

public class C { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		var X = new BigInteger(GetLong());
		var K = new BigInteger(GetLong());
		var D = new BigInteger(GetLong());

		if(X < 0)
			X = -X;

		if(X >= K * D)
			WriteLine(X - K * D);
		else
		{
			var q = X / D;
			if((K - q) % 2 == 0)
				WriteLine(X % D);
			else
				WriteLine(BigInteger.Abs(X % D - D));
		}
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 27832
d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
    t=list(map(int,input().split()))
    s.append(t)

fuman=[]
for i in range(26):
    fuman.append(c[i]*66795)


for i in range(d):
    p=fuman.index(max(fuman))
    print(p+1)
    q=364-i
    fuman[p]=(q**2+q)*c[p]//2

Measured memory_bytes: 9300
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e18;

// union-find
vint par;
vint depth;

void init (int n) {
    rep(i,n) {
        par[i] = i;
        depth[i] = 0;
    }
}

int find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (depth[x] < depth[y]) par[x] = y;
    else {
        par[y] = x;
        if (depth[x] == depth[y]) depth[x]++;
    }
}

bool same(int x, int y) {return find(x) == find(y);}

// kruscal
struct edge {int u, v, cost;};

bool comp(const edge &e1, const edge &e2) {
    return e1.cost < e2.cost;
}

edge es[100005];
int V, E;

int kruskal() {
    sort(es,es+E,comp);
    init(V);
    int res = 0;
    rep(i,E) {
        edge e = es[i];
        if (!same(e.u,e.v)) {
            unite(e.u,e.v);
            res += e.cost;
        }
    }
    return res;
}

int main() {
    cin >> V >> E;
    par.resize(V);
    depth.resize(V);
    rep(i,E) {
        int s, t, w;
        cin >> s >> t >> w;
        es[i].u = s; es[i].v = t; es[i].cost = w;
    }
    cout << kruskal() << endl;
}


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

int S(vector<int> a,int N,int M){
  int S=0;
  for(int i=0;i<N;i++){
    S+=(a.at(i)-M)*(a.at(i)-M);
  }
  return S;
}

int main(){
  int N,V;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  V=S(a,N,-100);
  for(int i=0;i<201;i++){
    if(S(a,N,-100+i)<V) V=S(a,N,-100+i);
  }
  
  cout << V << endl;
}

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

int gcd(int a,int b){
    if(a<b) gcd(b,a);
    while(a%b){
        int r=a%b;
        a=b;b=r;
    }
    return b;
}

int main() {
  
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++){
    cin >> v.at(i);
  }
  
  int HP = v.at(0);
  for (int i = 0; i < N-1; i++){
    HP = gcd(HP, v.at(i+1));
  }

  cout << HP << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
 
inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}
 
int n,m,a[200005],sum[200005],suf[200005],ans;
 
int main()
{
	m=read();
	n=read();
	for ( int i=1;i<=n;i++ ) 
	{
		a[i]=read();
		if(i!=1) ans+=a[i]-a[i-1];
	}
	for ( int i=2;i<=n;i++ ) sum[i]=sum[i-1]+(a[i]-a[i-1]);
	for ( int i=n-1;i>=1;i-- ) suf[i]=suf[i+1]+(a[i+1]-a[i]);
	for ( int i=2;i<n;i++ ) 
		ans=min(ans,a[1]+sum[i]+m-a[n]+suf[i+1]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#                         author:  kagemeka 
#                         created: 2019-11-09 11:51:37(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():
    n = int(sys.stdin.readline().rstrip())
    
    for x in range(n // 7 + 1):
        if (n - 7 * x) % 4 == 0:
            print('Yes')
            exit()
    print('No')


if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define var auto
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
ll dp[100010];

int main() {
  int n, k;
  cin >> n >> k;
  ll h[100010];
  rep (i,n) cin >> h[i];
  // 最小化問題なので INF で埋める
  rep(i,100010) dp[i] = INF;

  dp[0] = 0;

  rep (i,n) {
    for (int j = 1; j <= k; ++j) {
      chmin(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
    }
  }
  cout << dp[n-1] << endl;
}


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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

ll MAX_V = 2e5 + 5;
vector<vector<ll>> G(MAX_V);//隣接リスト(添え字は始点、値は終点)
vector<ll>t(MAX_V,-1);
bool sw=false;
void dfs(ll k,ll x){
  t[k]=x;
  for(ll i=0;i<G[k].size();i++){
    if(t[G[k][i]]==-1){
      dfs(G[k][i],x^1); 
    }
    else if(x==t[G[k][i]])sw=true;
  }
}
int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  for(ll i=0;i<m;i++){
    ll p,q;
    cin>>p>>q;
    G[p-1].push_back(q-1);
    G[q-1].push_back(p-1);
  }
  dfs(0,0);
  if(sw)cout<<n*(n-1)/2-m<<endl;
  else{
    ll ret=0;
    rep(i,0,n)ret+=t[i];
    cout<<ret*(n-ret)-m;
  }
  return 0;
}

Measured memory_bytes: 11136
//:::: Alien :::://
// Muhammad Eid //
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define prINT pair<int, int>

const int N = 100 +5;
int ar[N];

void Mo35(){ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}

int main(){
Mo35();

    int n; cin>> n;
    for(int i=0; i<n;) cin>> ar[i++];
    int cost, mn = 1e9;
    for(int i=-1000; i<1005; ++i){
        cost = 0;
        for(int j=0; j<n; ++j) cost += (ar[j]-i)*(ar[j]-i);
        mn = min(mn, cost);
    }
    cout<< mn;  

return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
#include <deque>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll dp[100010];

int main() {

    int N, L;
    cin >> N >> L;

    vector<int> a(N);

    int ans = 500;
    int b;

    for (int i = 0; i < N; i++) {
        a[i] = L + i;
        if (abs(a[i]) < ans) {
            ans = abs(a[i]);
            b = i;
        }
    }
    
    int sum = 0;

    for (int i = 0; i < N; i++) {
        if (i != b) { 
            sum += a[i];
        }
    }
    
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <utility>
using std::printf;
using std::scanf;
using std::pair;
using std::vector;

typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)

// fenwick tree
const int N = 125252;
int dat[N+1];
void add(int x,int v){
  while(x<=N){
    dat[x]+=v;
    x+=x&-x;
  }
}
int sum(int x){
  int ret = 0;
  while(x){
    ret+=dat[x];
    x-=x&-x;
  }
  return ret;
}

int n,m;
vector<pii> lens[125252];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,n){
    int l,r;
    scanf("%d%d",&l,&r);
    r++;
    lens[r-l].push_back(pii(l,r));
  }
  printf("%d\n",n);
  int rest = n;
  FOR(d,2,m+1){
    // len==d-1
    for(pii P : lens[d-1]){
      add(P.first,1);
      add(P.second,-1);
      rest--;
    }
    int ans = rest;
    int it = d;
    while(it<=m){
      ans += sum(it);
      it += d;
    }
    printf("%d\n",ans);
  }
  return 0;
}


Measured memory_bytes: 8576
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt64() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt() int {
	return int(nextInt64())
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	return int(max64(int64(x), int64(y)))
}

func min64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func min(x, y int) int {
	return int(min64(int64(x), int64(y)))
}

func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func abs(x int) int {
	return int(abs64(int64(x)))
}

func joinInt64s(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func divUp64(x, y int64) int64 {
	return (x + y - 1) / y
}

func divUp(x, y int) int {
	return int(divUp64(int64(x), int64(y)))
}

func gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func gcd(x, y int) int {
	return int(gcd64(int64(x), int64(y)))
}

func lcm64(x, y int64) int64 {
	return x * y / gcd64(x, y)
}

func lcm(x, y int) int {
	return int(lcm64(int64(x), int64(y)))
}

func pow64(x, y int64) int64 {
	return int64(math.Pow(float64(x), float64(y)))
}

func pow(x, y int) int {
	return int(pow64(int64(x), int64(y)))
}

func main() {
	solve()
	writer.Flush()
}

type pair struct {
	i, j int
}

var a = []string{"dreamer", "dream", "eraser", "erase"}

func solve() {
	S := nextLine()
	T := ""
	for len(T) < len(S) {
		appended := false
		for _, s := range a {
			if strings.HasSuffix(S[:len(S)-len(T)], s) {
				T = s + T
				appended = true
				break
			}
		}
		if !appended {
			out("NO")
			return
		}
	}
	if T == S {
		out("YES")
	} else {
		out("NO")
	}
}


Measured memory_bytes: 10880
// At Corder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <algorithm>
#include <iostream>
using namespace std;
#include <vector>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using p = pair<int, int>;//<key,value>

int main()
{
double a,b,c,d;
cin>>a>>b>>c>>d;
rep(i,5000){
c=c-b;
if(c<=0){
	cout<<"Yes"<<endl;
return 0;}
a=a-d;
if(a<=0){
	cout<<"No"<<endl;
	return 0;
}
}
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント:
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 3720