akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
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; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  vector<int>k(10),w(10);
  rep(i,10) cin >> w[i];
  rep(i,10) cin >> k[i];
  sort(w.begin(),w.end(),greater<int>());
  sort(k.begin(),k.end(),greater<int>());
  cout << w[0]+w[1]+w[2]<< " " <<k[0]+k[1]+k[2] << endl;
}



Measured memory_bytes: 3236
N = int(input())
S = list(map(int, input().split()))
L = 0;  R = N-1
ans = 0
for i in range(1, (N+1)//2):
    r = R
    l = L
    j = 1
    a = 0
    Closed = set()
    while True:
        l += i
        Closed.add(l)
        r -= i
        if r in Closed:
            break
        Closed.add(r)
        if r < i:
            break
        a += S[l] + S[r]
        ans = max(ans, a)
        j += 1
print(ans)


Measured memory_bytes: 17384
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    //int ans=0;
    bool ans=false;
    int N,M;
    
    cin>>N>>M;
    if(M==N){
        ans=true;
    }
    
    //cout<<ans<<endl;

   if(ans){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

    return 0;
}

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

int calc(vector<vector<int>> &v, vector<int> &dp, vector<int> &next, int now = 0){
	if(now == dp.size()) return 1;
	if(dp.size() < now) return 0;
	if(dp[now] != 1 << 30) return dp[now];
	for(int i = 0; i < 26; i++){
		int length = calc(v, dp, next, *lower_bound(v[i].begin(), v[i].end(), now) + 1) + 1;
		if(length < dp[now]){
			dp[now] = length;
			next[now] = i;
		}
	}
	return dp[now];
}

int main(){
	string s;
	cin >> s;
	vector<vector<int>> v(26);
	for(int i = 0; i < s.size(); i++){
		v[s[i] - 'a'].emplace_back(i);
	}
	for(auto &vv:v) vv.emplace_back(s.size());
	vector<int> dp(s.size(), 1 << 30), next(s.size(), -1);
	calc(v, dp, next);
	for(int i = 0; i < next.size(); i = *lower_bound(v[next[i]].begin(), v[next[i]].end(), i) + 1){
		cout << char('a' + next[i]);
	}
	cout << endl;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e10;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 




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

////////////////////////////////////////////////////////////////////
int n;int a[210000];
signed main(){
  cin>>n;rep(i,n)cin>>a[i];
  int c = 0, ans = 0;
  rep(i,n){
    if(c + 1 == a[i])c++;
    else ans++;
  }
  cout << (c == 0 ? -1 : ans) << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

const int infI=1e9+5;
const long long infL=1e16;
const int MOD=1e9+7;
const int MAX=2e5+5;

#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ll long long
#define pll pair<ll,ll>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define popb pop_back()
#define se second
#define fi first
#define test(t) int t;cin>>t;while(t--)
#define debug(x) cerr<<"=>"<<#x<<" = "<<x<<endl

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    if(b==1){
        return a;
    }
    ll temp=power(a,b/2);
    temp=(temp*temp)%MOD;
    if(b%2){
        temp=(temp*a)%MOD;
    }
    return temp;
}

//only use if mod is prime
ll mod_inv(ll a,ll mod){
    a%=mod;
    return power(a,mod-2);
}

void extended_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return;
    }
    ll x1,y1;
    extended_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-((a/b)*y1);
    return;
}

//TLE can also occur if vectors are not passed by reference, debug statements can also cause TLE.
//priority_queue implements max heap by default

int n,m,k;
char temp[10][10];

bool check(int row,int col){
    int ans = 0;
    for(int i = 0;i<n;i++){
        int u = row&(1<<i);
        if(u){
            for(int j = 0;j<m;j++){
                temp[i][j] = '$';
            }
        }
    }
    for(int j = 0;j<m;j++){
        int u = col&(1<<j);
        if(u){
            for(int i = 0;i<n;i++){
                temp[i][j] = '$';
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(temp[i][j] == '#'){
                ++ans;
            }
        }
    }
    return (ans == k);
}

int main(){
    fastio;
    // think about edge cases like n=1(especially graph questions).
    cin>>n>>m>>k;
    char g[10][10];
    forn(i,0,n){
        forn(j,0,m){
            cin>>g[i][j];
        }
    }
    int m1 = 1<<n,m2 = 1<<m;
    int ans = 0;
    for(int row = 0;row<m1;++row){
        for(int col = 0;col<m2;++col){
            for(int i = 0;i<n;i++){
                for(int j = 0;j<m;j++){
                    temp[i][j] = g[i][j];
                }
            }
            if(check(row,col)){
                ++ans;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3656
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
#define maxn 200010
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-6;
inline int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-') f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}
int n;
char s[maxn];
int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	//cout.tie(0);
	scanf("%s", s + 1);
	n = strlen(s + 1);
	if (n == 1) printf("%d\n", 1);
	else {
		bool ok = 1;
		int k = n;
		for (int i = 1; i <= n; i++) {
			if (ok == 1 && s[i] == s[i - 1]) {
				i++;
				ok = 0;
				k--;
			}
			else ok = 1;
		}
		printf("%d\n", k);
	}
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    string s,t;
    cin>>s>>t;
    ll mini=10000000001,cnt=0;
    for(ll i=0;i<=s.length()-t.length();i++)
    {
        cnt=0;
        for(ll j=0;j<t.length();j++)
        {
            if(s[i+j]!=t[j])
            cnt++;
        }
        mini=min(mini,cnt);
    }
    cout<<mini;
}

Measured memory_bytes: 3560
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc018.contest.atcoder.jp/tasks/agc018_a>
問題文============================================================
 箱に N 個のボールが入っていて、i 番目のボールには整数 Ai が書かれています。
 すぬけ君は、次の操作を好きな回数だけ行うことができます。
 
 箱から二つのボールを取り出し、その二つのボールに書かれている数の差の絶対値を書いた新しいボールと一緒に箱に戻す。
 
 すぬけ君が、整数 K の書かれたボールが箱の中に入っている状態にできるかどうか判定してください。
=================================================================

解説=============================================================

 全ての要素の最大公約数をGCD , 最大値を Mとすれば
 
 K%GCD == 0 and K <= M
 がPOSSIBLEとなる答え
 
 難しいね
 
================================================================
*/

inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N,K; cin >> N >> K;
    vector<ll> A(N);
    for(auto &in:A){ cin >> in;}
    ll GCD = A[0];
    for(int i = 1; i < N;i++) GCD = gcd(GCD,A[i]);
    ll M = *max_element(A.begin(), A.end());
    if(K%GCD == 0 && K <= M){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;
const int N=2e5+10;
int a[N];
int main()
{
    int maxv=0;
    int k,n;
    cin>>k>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    a[n+1]=a[1];
    for(int i=1;i<=n;i++)
    {
        maxv=max(maxv,(a[i+1]-a[i]+k)%k);
    }
    cout<<(k-maxv)<<endl;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef vector<unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;
vll ans;

int main(){
  cin >> n;
  if(n == 3){
    cout << 2 << endl;
    cout << 5 << endl;
    cout << 63 << endl;
  }else if(n <= 15000){
    if(n%3 == 0){
      n -= 4;
      for(lli i = 1;i <= n;i++) cout << i*2 << endl;
      lli y = 3;
      for(lli i = 1;i <= 4;i++){
        cout << y << endl;
        y += 6;
      }
    }else if(n%3 == 1){
      n -= 2;
      for(lli i = 1;i <= n;i++) cout << i*2 << endl;
      cout << 3 << endl;
      cout << 9 << endl;
    }else if(n%3 == 2){
      n -= 2;
      for(lli i = 1;i <= n;i++) cout << i*2 << endl;
      cout << 3 << endl;
      cout << 9 << endl;
    }
  }else if(n%2 == 0){
    for(lli i = 1;i <= 15000;i++) cout << i*2 << endl;
    n -= 15000;
    lli y = 3;
    for(lli i = 1;i <= n;i++){
      cout << y << endl;
      y += 6;
    }
  }else if(n%2 == 1){
    for(lli i = 1;i <= 14999;i++) cout << i*2 << endl;
    n -= 14999;
    lli y = 3;
    for(lli i = 1;i <= n;i++){
      cout << y << endl;
      y += 6;
    }
  }
  return 0;
}


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

int main(){
    int H, W;
    cin >> H >> W;
    string S[1000];
    for(int i=0; i<H; i++) cin >> S[i];

    vector<pair<int, int>> cand;
    for(int i=0; i<H; i++){
        int l = -1, r = -1;
        for(int j=0; j<W; j++) if(S[i][j] == 'B'){
            if(l == -1) l = j;
            r = j;
        }
        if(l >= 0){
            cand.emplace_back(i, l);
            cand.emplace_back(i, r);
        }
    }

    int ans = 0;
    for(auto& p : cand) for(auto& q : cand){
        int res = abs(p.first-q.first) + abs(p.second-q.second);
        ans = max(ans, res);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3252
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll A, B; cin >> A >> B;
    if(A >= 13) cout << B << endstr;
    else if(A >= 6) cout << B/2 << endstr;
    else cout << 0 << endstr;
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int arr[n];
    int dp[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    int sum= 0;
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++){
        dp[i]=min((dp[i-1]+abs(arr[i-1]-arr[i])),(dp[i-2]+abs(arr[i-2]-arr[i])));
    }
    cout<<dp[n-1]<<endl;
}

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

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

    int a[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    sort(a, a+n);   // descend

    int half = a[n-1] / 2;
    int *pos;
    pos = lower_bound(a, a+n-2, half);

    int r;
    if (*pos == half || pos - a == 0) { r = a[pos-a]; }
    else { r = (half - a[pos-a-1] < a[pos-a] - half) ? a[pos-a-1] : a[pos-a]; } // nearer to n/2

    printf("%d %d\n", a[n-1], r);
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }
    Scanner sc;
    Main(){
        sc = new Scanner(System.in);
    }
    void debug(Object ... o) {
        System.out.println(Arrays.deepToString(o));
    }
    void run() {
        while (init()) {
            int ans = 0;
            for (int bit = 0; bit < (1<<R); bit++) {
                makeG(bit);
                int cans = 0; // current answer
                for (int i = 0; i < C; i++) {
                    cans += countMax(i);
                }
                ans = Math.max(ans, cans);
            }
            System.out.println(ans);
        }
    }
    int R, C;
    boolean [][] F;
    boolean [][] G;
    int countMax(int j) {
        int t = 0, f = 0;
        for (int i = 0; i < R; i++) {
            if (G[i][j]) {
                t++;
            } else {
                f++;
            }
        }
        return Math.max(t, f);
    }
    void makeG(int bit) {
        G = new boolean[R][C];
        for (int i = 0; i < R; i++) {
            if ((bit & (1 << i)) != 0) {
                for (int j = 0; j < C; j++) {
                    G[i][j] = !F[i][j];
                }
            } else {
                for (int j = 0; j < C; j++) {
                    G[i][j] = F[i][j];
                }
            }
        }
    }
    boolean init() {
        R = sc.nextInt();
        C = sc.nextInt();
        if (R == 0 && C == 0) return false;
        F = new boolean[R][C];
        for (int i = 0; i < R; i++) {
            for (int j = 0; j < C; j++) {
                int n = sc.nextInt();
                F[i][j] = (n == 1);
            }
        }
        return true;
    }
}

Measured memory_bytes: 94312
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;


int main(){
	int N,dx,dy;
	int x,y,z;
	int max[3];
	cin>>N;
	while(N--){
		x=y=z=max[0]=0;
		while(1){
			cin>>dx>>dy;
			if(dx==0&&dy==0)break;
			x+=dx,y+=dy;
			z=x*x+y*y;
			if(z>max[0]){//Û¶
				max[0]=z;
				max[1]=x;
				max[2]=y;
			}else if(z==max[0]){
				if(x>max[1]){//xÀWªå«¢
					max[1]=x;
					max[2]=y;
				}
			}
		}
		cout<<max[1]<<" "<<max[2]<<endl;
	}
}

Measured memory_bytes: 0
/*    Immediate gratification is a dream killer   */
#include<bits/stdc++.h>
using namespace std;
template <typename T>
void make_unique(vector<T>& vec) {
  sort(vec.begin(),vec.end());
  vec.erase(unique(vec.begin(),vec.end()), vec.end());
}
#define ll long long
#define ld long double
#define endl '\n'
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,n) for(i=1;i<=n;i++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end() 
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define rep(i, begin, end) for(i=begin;i<=end;i++)
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
bool isprime(ll n){ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; 
}
const ll mod = 1000000007;
const ld PI = 3.141592653589793;
const int cons=100001;
ll N,M;
int main() {
    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
    ll n=0,m=0,i=0,j=0,k=0,cnt=0,ans=0,sum=0,flag=0,pos=0,ind=0,mn=0,mx=0,res=0;
    cin>>n;
    fo(i,n){
        cout<<"ACL";
    }
        
        
        
    return 0;
}



Measured memory_bytes: 3652
pha = input()
li = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
if pha in li:
    print("a")
else:
    print("A")

Measured memory_bytes: 9040
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <map>
#include <numeric>
#include <cassert>
#include <iomanip>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr int INF = 1145141919810893;

//
struct Edge {
	int next;
	int w = 1;
};
template<class T>
struct Vertex {
	std::vector<Edge>edges;
	T val = {};
};
template<class T>
struct Graph {
	std::vector<Vertex<T>> vertex;
public:
	Graph(size_t n = 0) :vertex(n) {
	}
	void setArray(int u, int v, int w = 1) {
		vertex[u].edges.push_back(Edge{ v ,w });
	}
	void setConnect(int u, int v, int w = 1) {
		setArray(u, v, w);
		setArray(v, u, w);
	}
	T& val(int u) {
		return vertex[u].val;
	}
	void dfsImpl(int pos, int prev, std::function<void(int now, int next, int w)> func) {
		for (auto& e : vertex[pos].edges) {
			if (e.next == prev) continue;
			func(pos, e.next, e.w);
			dfsImpl(e.next, pos, func);
		}
	}
	void dfs(int pos, std::function<void(int now, int next, int w)> func) {
		dfsImpl(pos, -1, func);
	}
	//graph.dfs(0, [](Vertex<int>& now, Vertex<int>& next, int w) {});
	pair<int, int> radiusImpl(int pos) {
		int farestID = -1;
		int far = -1;
		val(pos) = 0;
		dfs(pos, [&](int now, int next, int w) {
			val(next) = 1 + val(now);
			if (val(next) > far) {
				far = val(next);
				farestID = next;
			}
			});
		return { farestID, far };
	}
	int radius() {
		if (vertex.size() <= 1)return 0;
		auto res = radiusImpl(0);
		res = radiusImpl(res.first);
		return res.second;
	}
};




#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOADVEC3(type,name0,name1,name2,N) std::vector<type>name0(N),name1(N),name2(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn];cin >> name2[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


void proc();

signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}

/*
--------------------------------------------------------
--------------------------------------------------------
---------------    template      ----------------------
--------------------------------------------------------
--------------------------------------------------------
*/

bool check() {
	LOAD(int, N);
	LOAD(int, A);
	LOAD(int, B);
	LOAD(int, C);
	LOAD(int, D);
	--N;
	if (!(A - N * D <= B && B <= A + N * D))return false;
	if (2 * C - 2 * (D - C) <= 0) {
		return true;
	}
	int X = (A + N * D - B) % (C + D);
	return X <= N * (D - C);
}

void proc() {
	if (check()) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


#endif



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int n, v[500000];
ll calc(bool neg) {
	ll cur = 0;
	ll cost = 0;
	for (int i = 0; i < n; ++i) {
		cur += v[i];
		if (neg) {
			if (cur >= 0) {
				ll need = cur + 1;
				cost += need;
				cur = -1;
			}
		}else {
			if (cur <= 0) {
				ll need = 1 - cur;
				cost += need;
				cur = 1;
			}
		}
		neg = !neg;
	}
	return cost;
}
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", &v[i]);
	printf("%lld\n", min(calc(0), calc(1)));
	return 0;
}

Measured memory_bytes: 640
n = int(input())

x = []
y = []

parity = -1
Have = True

for i in range(n):
    s = input().split(' ')
    x.append(int(s[0]))
    y.append(int(s[1]))

    p = (x[i] + y[i] + 10**10) % 2

    if (parity < 0):
        parity = p
    if (parity != p):
        Have = False

def Abs(v):
    if (v > 0): return  v
    else:       return -v

if (Have == False):
    print("-1")
else:
    arms = []

    for i in range(39):
        arms.append(2 ** (38 - i))

    if (parity == 0):
        arms.append(1)
        for i in range(n):
            x[i] -= 1

    print(len(arms))

    for v in arms:
        print(v,end = " ")

    print("")

    dx = [-1,0,1,0]
    dy = [0,-1,0,1]
    dir = ['L','D','R','U']

    for i in range(n):
        posX = 0
        posY = 0
        for j in range(39):
            for k in range(4):
                nxtX = posX + dx[k] * arms[j]
                nxtY = posY + dy[k] * arms[j]

                if (Abs(x[i] - nxtX) + Abs(y[i] - nxtY) < arms[j]):
                    print(dir[k],end = "")
                    posX = nxtX
                    posY = nxtY
                    break

        if (parity == 0):
            print("R")
        else:
            print("")


Measured memory_bytes: 4632
var
	N,i,j,ans,id,k:Longint;
	x,y:array[1..50]of Longint;
	s,t:array[1..2500]of Longint;
begin
	read(N);
	for i:=1 to N do read(x[i],y[i]);
	for i:=1 to N do for j:=1 to N do begin
		if i=j then continue;
		inc(id);
		s[id]:=x[i]-x[j];
		t[id]:=y[i]-y[j];
		for k:=id-1 downto 1 do begin
			if(s[k]>s[k+1])or((s[k]=s[k+1])and(t[k]>t[k+1]))then begin
				ans:=s[k];
				s[k]:=s[k+1];
				s[k+1]:=ans;
				ans:=t[k];
				t[k]:=t[k+1];
				t[k+1]:=ans;
			end else break;
		end;
	end;
	ans:=0;
	i:=1;
	while i<=id do begin
		k:=1;
		while(i+1<=id)and(s[i]=s[i+1])and(t[i]=t[i+1])do begin
			inc(k);
			inc(i);
		end;
		if ans<k then ans:=k;
		inc(i);
	end;
	writeln(N-ans);
end.


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    ll a,b;
    cin >> a >> b;
    cout << a*b / __gcd(a,b) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, M; char c; cin >> c >> M;
  N = (int)(c - '0'); //cout << N << " " << M << " " << c << endl;
  vector<vector<bool>> path(N, vector<bool> (N, false));
  for(int i = 0; i < M; i++) {
    int a, b; cin >> a >> b; a--; b--;
    path.at(a).at(b) = true;
    path.at(b).at(a) = true;
  }
  vector<string> paths(0), DFS(1, "1");
  bool judge = false;
  for(int i = 0; i < DFS.size(); i++) {
    for(char j = '2'; j <= c; j++) {
      string s = DFS.at(i);
      if(s.find(j) == string::npos) {
        s += j;
        DFS.push_back(s);
        if(s.size() == N) {
          paths.push_back(s);
        }
      }
    }
  }
  int count = 0;
  for(int i = 0; i < paths.size(); i++) {
    bool j2 = true;
    for(int j = 1; j < N; j++) {
      int x = (int)(paths.at(i).at(j - 1) - '1');
      int y = (int)(paths.at(i).at(j) - '1');
      if(path.at(x).at(y)) continue;
      else {
        j2 = false;
        break;
      }
    }
    if(j2) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <iomanip>
#include <math.h>
#include <fstream>

using namespace std;

class pqComp
{
public:
    bool operator()(pair<int, int> &a, pair<int, int> &b)
    {
        return a.second < b.second;
    }
};

bool sorting(pair<int, int> a, pair<int, int> b)
{
    return a.second < b.second;
}

int main()
{
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie();
    cout.tie();
    // ifstream cin("in.txt");
    // ofstream cout("out.txt");
    
    
    // int t;
    // cin >> t;
    // for (int qwe = 0; qwe < t; qwe++)
    // {
    //     cout << "Case #" << qwe + 1 << ": ";
    // }


    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double th = (h + m / 60.) / 12;
    double tm = m / 60.;
    pair<double, double> ph = { a * cos(2 * acos(-1) * th), a * sin(2 * acos(-1) * th) }, pm = { b * cos(2 * acos(-1) * tm), b * sin(2 * acos(-1) * tm) };
    cout << sqrt((ph.first - pm.first) * (ph.first - pm.first) + (ph.second - pm.second) * (ph.second - pm.second)) << '\n';


    return 0;
}


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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back

typedef long long LL;


template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

LL N;
const int maxn = 62;
int d[maxn];
LL dp[maxn][3];
const int mod = 1e9+7;

void init(){
    for(int i = maxn-1;i >= 1;i--){
        if((1LL<<(i-1))&N) d[i] = 1;
        else d[i] = 0;
    }
}

int add(LL a,LL b){
    return (int) ((a+b)%mod);
}

int solve(){
    for(int i = maxn-1;i >= 1;i--) _for(s,0,3){
        _for(ab,0,3){
            int num = dp[i][s];
            if(s == 2){
                dp[i-1][2] = add(dp[i-1][2],num);
            }
            else if(s == 1){
                if(ab == d[i]+2) dp[i-1][0] = add(dp[i-1][0],num);
                else if(ab == d[i]+1) dp[i-1][1] = add(dp[i-1][1],num);
                else dp[i-1][2] = add(dp[i-1][2],num);
            }
            else{
                if(ab == d[i]) dp[i-1][0] = add(dp[i-1][0],num);
                else if(ab < d[i]) dp[i-1][1] = add(dp[i-1][1],num);
            }
        }
    }
    int ans = dp[0][0];
    ans = add(ans,dp[0][1]);
    ans = add(ans,dp[0][2]);
    return ans;
}

int main()
{
    cin >> N;
    init();
    dp[60][0] = 1;
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    C = list(map(int, input().split()))
    INF = 10**10
    """
    使い回さない方
    dp = [[INF]*(N+1) for _ in range(M+1)]
    dp[0][0] = 0
    for i in range(M):
        for y in range(N+1):
            if C[i] > y:
                dp[i+1][y] = dp[i][y]
            else:
                dp[i+1][y] = min(dp[i][y], dp[i+1][y-C[i]]+1)
    print(min([dp[j][N] for j in range(1, M+1)]))
    """
    """ 使い回す方 """
    dp = [INF]*(N+1)
    dp[0] = 0
    for i in range(M):
        for y in range(N+1):
            if C[i] <= y:
                dp[y] = min(dp[y], dp[y-C[i]]+1)
    print(dp[N])


if __name__ == "__main__":
    main()


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


int main(){
    const long long INF = 1LL << 60;


    long long N;
    cin >> N;
    vector<int> h(N);
    for(int i = 0; i < N; i++){
        cin >> h.at(i);
    }

    // DP テーブル
    long long dp[100010];

    // DP テーブル全体を初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    dp[0] = 0;
    dp[1] = abs(h.at(1) - h.at(0));

    for(int i = 2; i < N; i++){
        dp[i] = min(dp[i-1] + abs(h.at(i) - h.at(i-1)), dp[i-2]+abs(h.at(i) - h.at(i-2)));
    }

    cout << dp[N-1] << endl;
}


Measured memory_bytes: 4584
import java.util.Scanner;

public class Main {

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

		String str=sc.next();
		String[] str2=str.split(""); //一文字ずつ取り出す
		int x=Integer.parseInt(str2[0])*10+Integer.parseInt(str2[1]);

		int y=Integer.parseInt(str2[2])*10+Integer.parseInt(str2[3]);
		//xがMMの時
		if(0<x&&x<13){
			if(0<y&&y<13)System.out.println("AMBIGUOUS");
			else System.out.println("MMYY");
		}else{
			if(0<y&&y<13)System.out.println("YYMM");
			else System.out.println("NA");
		}
	}

}

Measured memory_bytes: 23380
#include <iostream>
using namespace std;
const int MAX = 1000001;

int main(){
  //素数を作る
  int prime[MAX] = {0};
  for(int i = 0; i < MAX; i++) prime[i] = 1;
  prime[0] = 0;
  prime[1] = 0;
  for(int i = 2; i < MAX; i++){
    if(prime[i]){
      for(int j = i * 2; j < MAX; j += i){
	prime[j] = 0;
      }
    }
  }

  //数をもらってn番目を選ぶ
  int a, d, n;
  while(1){
    cin >> a >> d >> n;
    if(a == 0 || d == 0 || n == 0) break;
    int i = a;
    for(int j = 0; ; i += d){
      if(prime[i]) j++;
      if(j >= n) break;
    }

    //表示
    cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 5072
#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 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 pw(b,p)         pow(b,p) + 0.1


#ifndef ONLINE_JUDGE
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
						 stringstream _ss(_s); \
						 istream_iterator<string> _it(_ss); \
						 err(_it, args); }
#else
#define error(args...)		42
#endif


void err(istream_iterator<string> it) { cerr << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "; ";
	err(++it, args...);
}


void c_p_c()
{
	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);
	freopen("debug.txt", "w", stderr);
#endif
}

int ceil2(int a, int b){
    int c = a / b;
    if (c * b < a) c++;
    return c;
}

const int MXN = 2*100005+5;
int t[4*MXN];

// 0-based indexing; see striver video
// tl, tr: current node v segment; l,r :query segment
int query(int v, int tl, int tr, int l, int r)
{
	// current node seg completely lies inside query seg
	if(tl>=l && tr<=r)
		return t[v];

	// current node seg didn't overlap
	if(tl>r || tr<l)
		return -inf;

	// partially overlap
	int mid = (tl + tr)/2;
	int left = query(2*v+1, tl, mid, l, r);
	int right = query(2*v+2, mid+1, tr, l, r);

	return max(left, right);
}

void update(int v, int tl, int tr, int pos, int new_val)
{
	if(tl==tr)
	{
		t[v] = new_val;
		return;
	}

	int mid = (tl + tr)/2;

	if(pos <= mid)
		update(2*v+1, tl, mid, pos, new_val);
	else
		update(2*v+2, mid+1, tr, pos, new_val);

	t[v] = max(t[2*v+1], t[2*v+2]);
}

void init_t()
{
	for (int i = 0; i < 4*MXN; ++i)
	{
		t[i] = 0;
	}
}


int32_t main()
{
	c_p_c();

	init_t();

	int n; cin>>n;

	int h[n]; 

	for (int i = 0; i < n; ++i)
	{
		cin>>h[i];
	}

	int v[n];

	for (int i = 0; i < n; ++i)
	{
		cin>>v[i];
	}

	int dp[n];

	int ans = -inf;

	for (int i = 0; i < n; ++i)
	{
		int mx = query(0, 0, MXN-1, 0, h[i]-1);
		dp[i] = mx + v[i];
		error(mx, v[i]);
		update(0, 0, MXN-1, h[i], dp[i]);

		ans = max(ans, dp[i]);
	}

	// for (int i = 0; i < n; ++i)
	// {
	// 	cout << dp[i] << " ";
	// }

	cout << ans;

	return 0;
}

Measured memory_bytes: 14528
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <ext/random>
#include <ext/rope>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  os << '{';
  for (size_t i = 0; i < vec.size(); ++i) {
    os << vec[i];
    if (i != vec.size() - 1) os << ',';
  }
  os << '}';
  return os;
}
template<typename T, typename U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '{' << p.first << " " << p.second << '}';
}
// constant
constexpr int INF = std::numeric_limits<int>::max() / 2;  // 1.073741823e9
constexpr int64 INF64 = std::numeric_limits<int64>::max() / 2;  // 4.611686018427387903e18
constexpr int MOD = 1000000007;

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

  int n; cin >> n;
  string s; cin >> s;

  int cnt = 0;

  for (size_t i = 1; i < n; ++i) {
    cnt += s[i - 1] != s[i];
  }

  cout << cnt + 1 << endl;

  return 0;
}

Measured memory_bytes: 512
function spilitInput(input, to_int) {
  if (typeof to_int === 'undefined') to_int = false;
  var splited = [];
  var rows = input.split('\n');
  for (var i = 0; i < rows.length; i += 1) {
    if (to_int) {
      splited.push(rows[i].split(' ').map(function(d){return parseInt(d,10);}));
    } else {
      splited.push(rows[i].split(' '));
    }
  }
  return splited;
}

function Main(input) {
  var splited = spilitInput(input, true);
  var k = splited[0][0];
  var word = '';
  for (var i = 0; i < parseInt(k, 10); i += 1) {
    word += 'ACL';
  }
  console.log(word);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29660
n, m = map(int, input().split())

temp = list(['?'] * n)

# print(temp)
if (m == 0):
    if (n == 1):
        ans = 0
    else:
        ans = '1' + '0' * (n - 1)

else:
    for _ in range(m):
        s, c = map(int, input().split())
        if (s == 1 and c == 0 and n >= 2):
            print(-1)
            exit()
        else:
            pass

        if (temp[s-1] == '?'):
            temp[s - 1] = str(c)
        elif (temp[s - 1] == str(c)):
            pass
        else:
            print(-1)
            exit()

    if (temp[0] == '?'):
        temp[0] = '1'

    ans01 = ''.join(temp)
    ans = ans01.replace('?', '0')

print(ans)


Measured memory_bytes: 9196
#include <bits/stdc++.h>
using  namespace std;
#define endl '\n'
#define ll long long
#define ce(x) cout << x << endl;
using db = long double;
const db pi = acos(-1);
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

int main(){
ll t,i,j,y,z,k,a,b,x,n;
db th;

cin>>a>>b>>x;
if(x*2<a*b*a)	
// th=0;
th=atan((2.0*x)/(a*b*b));
else
th=atan( a/(2.0*(b-((x*1.0)/(a*a)))));
// ce(th)
th=180*th/pi;
th=90-th;
cout_p(th, 10);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
int main() {
  int n, m;
  cin >> n >> m;
  cout << m * (m - 1) / 2 + n * (n - 1) / 2 << endl;
}

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

#define PI 3.141592653589793

int main(void) {
	
	int n, k,a[1010];
	int i;
	int sum=0;
	int tmp;
	scanf("%d%d", &n, &k);

	for (i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}

	for (i = 0; i < n - 1; i++)
	{
		for (int j = i; j < n; j++)
		{
			if (a[i] > a[j])
			{
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	for (i = 0; i < k; i++)
	{
		sum += a[i];
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 1716
#include<stdio.h>
#include<string.h>
int main()
{
	int a[10],i,j,t;
	for(i=0;i<10;i++)
		scanf("%d",&a[i]);
	for(i=0;i<9;i++)
		for(j=0;j<9-i;j++)
			if(a[j]<a[j+1])
			{
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;		
			}
	printf("%d\n%d\n%d\n",a[0],a[1],a[2]);
	return 0;
}

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

int main(){
  while(1){
    ll A,B;
    cin>>A>>B;
    if(!A&&!B) break;

    ll sum = 1LL<<55;
    for(int i=1;i*i<=A;i++){
      for(int j=1;j*j<=B;j++){
	if(A%i||B%j) continue;
	vector<int> v(4);
	v[0] = i;
	v[1] = A/i;
	v[2] = j;
	v[3] = B/j;
	sort(v.begin(),v.end());
	ll t = 0;
	for(int i=1;i<4;i++)t+=(v[i]-v[i-1])*(v[i]-v[i-1]);
	sum = min(sum,t);
      }
    }
    cout<<sum<<endl;
  }
  
  return 0;
}

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

#define endl '\n'
#define int long long

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

	int h, w; cin >> h >> w;
	int ch, cw; cin >> ch >> cw;
	int dh, dw; cin >> dh >> dw;
	string s[h];
	for(string &str : s) cin >> str;
	vector< vector<int> > magic(h, vector<int>(w, -1));
	vector< vector<bool> > vis(h, vector<bool>(w, false));
	queue< pair<int, int> > q, reach;
	q.push({cw - 1, ch - 1});
	magic[ch - 1][cw - 1] = 0;
	vis[ch - 1][cw - 1] = true;
	function<bool(int, int)> valid = [&] (int x, int y) {
		return (x >= 0 and x < w and y >= 0 and y < h and s[y][x] == '.');
	};
	vector< pair<int, int> > moves = {{1, 0}, {0, 1}, {0, -1}, {-1, 0}};
	int total = 0;
	bool run = true;
	while(run) {
		int n_total = total;
		while(!q.empty()) {
			auto u = q.front();
			reach.push(u);	
			q.pop();
			for(int i = 0; i < 4; i ++) {
				int vx = u.first + moves[i].first;
				int vy = u.second + moves[i].second;
				if(valid(vx, vy) and !vis[vy][vx]) {
				vis[vy][vx] = true;
				q.push({vx, vy});
				magic[vy][vx] = magic[u.second][u.first];
				n_total ++;
				}
			}
		}
		while(!reach.empty()) {
			auto u = reach.front();
			reach.pop();
			for(int i = max(u.first - 2, 0LL); i <= min(u.first + 2, w - 1); i ++) {
				for(int j = max(u.second - 2, 0LL); j <= min(u.second + 2, h - 1); j ++) {
					if(valid(i, j) and !vis[j][i]) {
						vis[j][i] = true;
						magic[j][i] = magic[u.second][u.first] + 1;
						q.push({i, j});
						n_total ++;
					}
				}
			}
		}
		if(n_total == total) run = false;
		else total = n_total;
	}
	cout << magic[dh - 1][dw - 1] << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> num(120);

  for(int i = 0 ; i < N ; ++i){
    cin >> num.at(i);
  }

  int alice = 0;
  int bob = 0;
  sort(num.begin(),num.end());
  reverse(num.begin(),num.end());
  
  for(int i = 0 ; i < N  ; ++i){
    if(i % 2 == 0) alice += num.at(i);
    if(i % 2 == 1) bob += num.at(i);
  }
  
  cout << alice - bob << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			while(true){
				int n = sc.nextInt();
				if(n == 0){
					break;
				}
				int[] scores = new int[n];
				double average = 0;
				for(int i = 0;i < scores.length;i++){
					scores[i] = sc.nextInt();
					average += (double)scores[i];
				}
				average = average / scores.length;
				double variance = 0;
				for(int j = 0;j < scores.length;j++){
					variance += ((scores[j]-average)*(scores[j]-average));
				}
				System.out.println(Math.sqrt(variance/scores.length));
			}
		}
	}
}


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

using namespace std;
using ll = long long;

vector<ll> divisor(ll n){
    std::vector<ll> res;
    for(ll i = 1LL; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            ll j = n / i;
            if(i != j)res.push_back(j);
        }
    }
    std::sort(res.begin(),res.end(), greater<ll>());
    return res;
}


int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> div = divisor(m);
    for(auto i : div) {
        if(m / i >= n) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		sc.close();
		if(n%2==1) System.out.println(0);
		else {
			long count=0,div=10;
			while(div<=n) {
				count += n/div;
				div *= 5;
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
int main(){
   int a,b,c,x,y;
   long long s=0;
   scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
   if(a+b > c*2){
        if(x<y){
            s += x*c*2;
            y -= x;
            if(y*c*2 < y*b) s += y*c*2;
            else s += y*b;
        }else{
            s += y*c*2;
            x -= y;
            if(x*c*2 < x*a) s += x*c*2;
            else s += x*a;
        }
   }else{
       s+=x*a+y*b;
   }
   printf("%lld",s);
}

Measured memory_bytes: 256
Ss = input()

N = len(Ss)

dp = [[-float('inf')]*(2) for _ in range(N+1)]
dp[0] = [0, 0]
for i in range(1, N+1):
    for j in range(2):
        if i-j-1 >= 0:
            dp[i][j] = dp[i-j-1][1-j] + 1
            if Ss[i-2*j-2:i-j-1] != Ss[i-j-1:i]:
                dp[i][j] = max(dp[i][j], dp[i-j-1][j]+1)

print(max(dp[N]))


Measured memory_bytes: 36924
#include <bits/stdc++.h>
#define INF 1e+18
#define int long long
using namespace std;

signed main(){
	int n,a[100010],sum = 0,maminus = -INF,miplus = INF,minus = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		sum += abs(a[i]);
		if(a[i] <= 0) maminus = max(maminus,a[i]);
		if(a[i] >= 0) miplus = min(miplus,a[i]);
		if(a[i] < 0) minus++;
	}
	if(minus % 2 == 0) cout << sum << endl;
	else cout << sum - min(maminus * -2,miplus * 2) << endl;
	
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;
// ワーシャルフロイド
int n,m;// 頂点、辺
ll dist[333][333];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  m = n * n;
  ll A[n + 1][n + 1];
  CLR(A);
  FOR(i,1,n+1){
    FOR(j,1,n+1){
      if(i==j) dist[i][j] = 0;
      else dist[i][j] = 1e9;
    }
  }
  FOR(i, 1, n + 1)
  {
    FOR(j, 1, n + 1) {
      cin >> A[i][j];
      dist[i][j] = A[i][j];
    }
  }
  FOR(k,1,n+1) FOR(i,1,n+1) FOR(j,1,n+1) {
    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  }
  // 最短経路となっていない
  FOR(i,1,n+1) {
    FOR(j,i+1,n+1) {
      if(A[i][j] != dist[i][j]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  ll ans = 0;
  FOR(i, 1, n + 1)
  {
    FOR(j, i + 1, n + 1){
      bool use = true;
      FOR(k, 1, n + 1)
      {
        if(i == j || k == i || k == j) {
          continue;
        }
        if(dist[i][j] == dist[i][k] + dist[k][j]){
          use = false;
        }
      }
      if(use) ans += A[i][j];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

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

    cout<<"ABC"<<N<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
const int md=1e9+7;

int dp[1005][1005];
int n,m;
char arr[1005][1005];

int fun(int i,int j)
 {
   if(i==n&&j==m)
    return 1;
   if(i>n||j>m)
     return 0;
   if(dp[i][j]!=-1)
    return dp[i][j];
   int res=0;
   if((i!=n)&&arr[i+1][j]!='#')
   res=fun(i+1,j)%md;
   if(j!=m&&arr[i][j+1]!='#')
   res+=fun(i,j+1)%md;
  return dp[i][j]=res;
  }

int32_t main()
{
  memset(dp,-1,sizeof(dp));
   cin>>n>>m;
   for(int i=1;i<=n;i++)
   {
     for(int j=1;j<=m;j++)
     cin>>arr[i][j];
    }
   int res=fun(1,1)%md;
   cout<<res<<"\n";
   return 0;
}

Measured memory_bytes: 9216