akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ra[100000],fa[100000],a[100000],b[100000];
vector<ll>v;
ll find(ll x){
    if(fa[x]==x)return x;
    return fa[x]=find(fa[x]);
}
void uni(ll x,ll y){
    x=find(x),y=find(y);
    if(x==y)return ;
    if(ra[x]<ra[y]){swap(x,y);}
    fa[y]=x;
    //ra[x]++;
    ra[x]+=1LL+ra[y];
    //if(ra[x]==ra[y])ra[x]++;
}
int main(void){
    ll n,m,c,d;
    cin>>n>>m;
    for(ll i=0LL;i<100000;i++){
        fa[i]=i;
        //ra[i]=1LL;
    }
    for(ll i=0;i<m;i++){
        cin>>c>>d;
        c--,d--;
        a[i]=c,b[i]=d;
    }
    reverse(a,a+m);
    reverse(b,b+m);
    for(ll i=0;i<m;i++){
        if(find(a[i])==find(b[i])){
            v.push_back(0LL);
        }
        else{
            v.push_back((1LL+ra[find(a[i])])*(1LL+ra[find(b[i])]));
            uni(a[i],b[i]);
        }
    }
    reverse(v.begin(),v.end());
    ll ans=0LL;
    for(ll i=0LL;i<m;i++){
        ans+=v[i];
        cout<<ans<<endl;
    }
}


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

int main(){
    int H, W, i, j;
    while(1){
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        i = 1;
        while(i <= H){
            j = 1;
            while(j <= W){
                if ((i + j) % 2 == 0) cout << "#";
                else cout << ".";
                j++;
                }
            cout << endl;
            i++;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3068
#include <stdio.h>
#define MAX 100005

int n,A[MAX];
int  partition(void){
  int i,j,x,c,b;
  x=A[n-1];
  i=-1;
  for(j=0;j<n-1;j++){
    if(A[j]<=x){
      i=i+1;
      c=A[i];
      A[i]=A[j];
      A[j]=c;
    }
  }
    b=A[i+1];
    A[i+1]=A[n-1];
    A[n-1]=b;
    return i+1;
}
int main(){
  int i,z;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
 z=partition();
  for(i=0;i<n-1;i++){
    if(z==i)printf("[");
    printf("%d",A[i]);
    if(z==i)printf("]");
    printf(" ");
  }
  printf("%d\n",A[n-1]);
  return 0;
}





Measured memory_bytes: 2072
#include <iostream>
#include <string>
#include <vector>

using lint = long long;

void solve() {
    int n;
    std::string s;
    std::cin >> n >> s;

    std::vector<lint> cnt(3, 0);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (s[i] == "RGB"[j]) ++cnt[j];
        }
    }

    lint ans = cnt[0] * cnt[1] * cnt[2];
    for (int i = 0; i < n; ++i) {
        for (int l = 1; i + l * 2 < n; ++l) {
            int j = i + l * 1,
                k = i + l * 2;
            if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
                --ans;
            }
        }
    }

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

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

    solve();

    return 0;
}


Measured memory_bytes: 3664
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = do
  n <- readLn
  cs <- replicateM n $ readLn :: IO [Int]
  print $ solve n cs

solve :: Int -> [Int] -> Integer
solve n cs = (dp ! n) + 1
  where
    carr :: Array Int Int
    carr = listArray (1, n) cs
    dp :: Array Int Integer
    dp = runSTArray $ do
      sums <- newArray (0, 200000) 0 :: ST s (STArray s Int Integer)
      dp <- newArray (1, n) 0 :: ST s (STArray s Int Integer)
      forM_ [2..n] $ \i -> do
        prev <- readArray dp (i-1)
        increment <- readArray sums (carr!i)
        writeArray dp i $ if carr!(i-1) /= carr!i
          then prev `modadd` increment
          else prev
        
        if carr!(i-1) /= carr!i
          then writeArray sums (carr!(i-1)) (prev `modadd` 1)
          else return ()
      return dp

divConst = 10^9 + 7 :: Integer
modadd x y = (x + y) `mod` divConst
modsub x y = (x - y) `mod` divConst
modmul x y = ((x `mod` divConst) * (y `mod` divConst)) `mod` divConst
  

Measured memory_bytes: 94588
// ?????????single source shortest path
// Bellman-Ford
#include <iostream>
#define INF 1001001000
#define BIG 500100
#define rep(i,p) for(int i=0;i<p;i++)
#define rep1(i,p) for(int i=1;i<=p;i++)
#define pb push_back
using namespace std;
int V,E,r,s,t,w;
int S[BIG];
int T[BIG];
int W[BIG];
int D[BIG];
int main(){
  // init
  rep(i,BIG) D[i] = INF;
  // r is source of graph
  cin >> V >> E >> r;
  rep(i,E) {
    cin >> s >> t >> w;
    S[i] = s;
    T[i] = t;
    W[i] = w;
  }
  D[r] = 0;
  rep(i,V) {
    bool update = false;
    rep(j,E) {
      // s,t ??? edge j ??? vartex
      s = S[j];
      t = T[j];
      w = W[j];
      if (D[t] > D[s]+w) {
        D[t] = D[s]+w;
        update = true;
      }
    }
    if (!update) break;
  }
  rep(i,V) {
    if (D[i] == INF) cout << "INF" << endl;
    else cout << D[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 8936
#include<bits/stdc++.h>
using namespace std;
#define fi 			first
#define se 			second
#define pb 			push_back
#define pf 			push_front
#define mod 		1000000007
//#define mod 998244353
//#define mod 1000000009
#define Pi 			3.14159265359
#define eps 		1e-9
#define all(v) 		v.begin(),v.end()
#define sz(v) 		((int)(v).size())
#define each(x, v)  for (auto &x : v)
using pii    =    pair<int,int>;
using vi     =    vector<int>;
using vvi    =    vector<vi>;
using vii    =    vector<pii>;
using mi     =    map<int,int>;
using mii    =    map<pii,int>;
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)

using ll = long long;
ll pow(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
void solve();

int main(){
    int T = 1;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    cin>>T;
    while(T--){
        solve();
    }

    return 0;
}

void solve(){
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}

Measured memory_bytes: 3692
import java.util.Scanner;
public class Main {

		static void solve() {
			Scanner sc = new Scanner(System.in);
			double n = sc.nextDouble();
			double d = sc.nextDouble();
			System.out.println((int)Math.ceil(n/(d*2+1)));
			sc.close();
		}
	public static void main(String[] args) {
	solve();

	}

}


Measured memory_bytes: 23892
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}
};

typedef vector<set<Edge>> Graph;


signed main(void) {

	int n, q;
	cin >> n >> q;

	string s;
	cin >> s;

	vector<pair<char,int>> que(q);

	REP(i, q) {
		string t, d;
		cin >> t >> d;

		que[i] = { t[0],d[0] == 'R' ? 1 : -1 };

	}

	auto sim = [&](int x) {
		REP(i, q) {
			if (que[i].first == s[x]) {
				x += que[i].second;
			}
			if (x == n) return 2;
			if (x == -1) return 1;
		}

		return 0;
	};
	int death = 0;
	int l = -1, r = n;
	while (r - l > 1) {
		int mid = (l + r) / 2;

		if (sim(mid) == 1) {
			l = mid;
		}
		else
		{
			r = mid;
		}

	}
	death += l + 1;

	l = n, r = -1;
	while (l - r > 1) {
		int mid = (l + r) / 2;

		if (sim(mid) == 2) {
			l = mid;
		}
		else
		{
			r = mid;
		}

	}

	death += n - l;

	cout << n - death << endl;
	return 0;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))


int main(){
    ll n;   cin >> n;
    vector<vector<int>> v(10, vector<int>(10, 0));
    REP(i, n+1){
        string obj = to_string(i);
        //st[{obj[0], obj.back()}] += 1;
        //cout << obj[0] << ' ' << obj.back() << endl;
        if(obj[0]=='0' || obj.back()=='0') continue;
        v[obj[0]-'1'][obj.back()-'1'] += 1;
    }
    ll ans=0;
    REP(i, 10)  REP(j, 10) ans += v[i][j]*v[j][i];
    
    cout << ans << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! { n: usize, m: usize };
    println!("{}", if n == m { "Yes" } else { "No"} );
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        string answer = s == "ABC" ? "ARC" : "ABC";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);

  ll ans = 0;
  rep(i, K + 1, N + 1) {
    ans += (N / i) * (i - K);
    ans += max((N % i) - K + 1, 0LL);
    if (K == 0) ans--;
  }

  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 256
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce
from itertools import groupby
from heapq import heapify, heappush, heappop

# sys.setrecursionlimit(5000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return map(lambda x: x + d, A)
def ldec(A, d=1): return map(lambda x: x - d, A)


N, X, T = nn()

if N % X != 0:
    print((((N // X) + 1) * T))
else:
    print(N // X * T)

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

Measured memory_bytes: 3612
import sys
import math

def input(): return sys.stdin.readline().rstrip("\r\n")
def List(): return list(map(int, input().split()))
def Num(): return int(input())


n = Num()
seven = 7
for I in range(n):
    if seven % n == 0:
        print(I + 1)
        break
    seven = seven * 10 + 7
    seven %= n
else:
    print(-1)



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

int main(){
    int n,k;
    cin>>n>>k;
    vector<ll> a(n+1);
    REP(i,n){
        cin>>a[i];
    }

    for(int i=k+1;i<=n;i++){
        if(a[i]>a[i-k]){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }

    return 0;
}

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

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

    vector<long long int> A(N + 1);
    for(long long int i = 0; i < N + 1; i++)
    {
        cin >> A[i];
    }

    vector<long long int> B(N);
    for(int i = 0; i < N; i++)
    {
        cin >> B[i];
    }

    long long int l = 0;
    long long int r = N - 1;
    long long int ans = 0;
    while(1)
    {
        if(l != 0 && B[l - 1] != 0)
        {
            if(B[l - 1] >= A[l])
            {
                ans += A[l];
                A[l] = 0;
            }

            else
            {
                A[l] -= B[l - 1];
                ans += B[l - 1];
            }
        }

        if(r != N - 1 && B[r + 1] != 0)
        {
            if(B[r + 1] >= A[r + 1])
            {
                ans += A[r + 1];
                A[r + 1] = 0;
            }

            else
            {
                A[r + 1] -= B[r + 1];
                ans += B[r + 1];
            }
        }

        if(B[l] >= A[l])
        {
            ans += A[l];
            B[l] -= A[l];
        }

        else
        {
            ans += B[l];
            B[l] = 0;
        }

        if(B[r] >= A[r + 1])
        {
            ans += A[r + 1];
            B[r] -= A[r + 1];
        }

        else
        {
            ans += B[r];
            B[r] = 0;
        }
        
        l++;
        r--;

        if(l >= r)
        {
            break;
        }
    }

    if(l > r)
    {
        if(B[l - 1] + B[r + 1] >= A[l])
        {
            ans += A[l];
        }

        else
        {
            ans += B[l - 1] + B[r + 1];
        }
    }

    else if(l == r)
    {
                if(l != 0 && B[l - 1] != 0)
        {
            if(B[l - 1] >= A[l])
            {
                ans += A[l];
                A[l] = 0;
            }

            else
            {
                A[l] -= B[l - 1];
                ans += B[l - 1];
            }
        }

        if(r != N - 1 && B[r + 1] != 0)
        {
            if(B[r + 1] >= A[r + 1])
            {
                ans += A[r + 1];
                A[r + 1] = 0;
            }

            else
            {
                A[r + 1] -= B[r + 1];
                ans += B[r + 1];
            }
        }
        
        if(A[l] + A[l + 1] >= B[l])
        {
            ans += B[l];
        }

        else
        {
            ans += A[l] + A[l + 1];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <stack>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#define pb push_back
#define sp " "
#define sl "\n"
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())

using namespace std;

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

const int N=1e6+5,mod=1000000007;
ll n,q,w;
int main() {
	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);
	cin>>n;
	for (ll i=-1000;i<=1000;i++) for (ll j=-1000;j<=1000;j++) {
		q=i*i*i*i*i; w=j*j*j*j*j;
		if (q-w==n) {cout<<i<<sp<<j; return 0; }
	}
	return 0;
}


Measured memory_bytes: 3668
def judge(lst):
	for i in range(0, 26):
		if lst[i] == 0: return str(chr(i+97))
	return('None')

S = input()
countlist = []
for i in range(0, 26):
	countlist.append(0)
for i in range(0, len(S)):
	countlist[ord(S[i])-97] += 1
print(judge(countlist))

Measured memory_bytes: 39280
# include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    string str; cin>>str;
    int len=str.length(); bool found =false ;
    for (int i = 0; (i < len-1 && found==false); ++i)
    {
        if(str[i]=='A' && str[i+1]=='C'){   found=true;  }
    }

    if(found==true){cout<<"Yes";}
    else {cout<<"No";}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <random>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	for(int i=0;i<n;i++){
		int a,b; cin >> a >> b;
		cout << (a%b==0?b:a%b) << endl;
	}
}


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

#define int long long

main()
{
	int n,cap,i,j;
	cin >> n >> cap;
	vector<int> v(n),w(n);
	for(i=0;i<n;i++)
		cin >> w[i] >> v[i];

	int t[n+1][cap+1];
	for(i=0;i<=n;i++) // value and wt.
	{
		for(j=0;j<=cap;j++) // capacity
		{
			if(i==0 or j==0)
				t[i][j]=0;

			else if(w[i-1]>j)
				t[i][j] = t[i-1][j];
			else
				t[i][j] = max(v[i-1]+t[i-1][j-w[i-1]],t[i-1][j]);
		}
	}
	// for(i=0;i<=n;i++)
	// {
	// 	for(j=0;j<=cap;j++)
	// 		cout << t[i][j] <<" ";
	// 	cout << endl;
	// }
	cout << t[n][cap] << endl;	
}

Measured memory_bytes: 82352
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
using namespace std;
main(){
  int m,n;
  while(cin>>m>>n,n){
    int a1[n][n],a2[n][n],q,w,e,r;
    r(i,n)r(j,n){
      if(i==j)a2[i][j]=a1[i][j]=0;
      else a2[i][j]=a1[i][j]=INF;
    }
    while(m--){
      scanf("%d%d%d%d",&q,&w,&e,&r);q--;w--;
      a1[q][w]=a1[w][q]=e;
      a2[q][w]=a2[w][q]=r;
    }
    r(k,n)r(i,n)if(a1[i][k]!=INF||a2[i][k]!=INF)r(j,n){
      a1[i][j]=min(a1[i][j],a1[i][k]+a1[k][j]);
      a2[i][j]=min(a2[i][j],a2[i][k]+a2[k][j]);
    }
    cin>>e;
    while(e--){
      scanf("%d%d%d",&q,&w,&r);q--;w--;
      if(r)cout<<a2[q][w]<<endl;
      else cout<<a1[q][w]<<endl;
    }
  }
}

Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0;
  long long int a;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    while(a%2==0){
      ans++;
      a/=2;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;

int main(void) {

  int n;
  cin >> n;
  while(n != 0){
    n--;
    int l = 0;
    int r = 0;
    int tmp;
    bool f = true;
    for(int i=0; i<10; i++){
      cin >> tmp;
      if( l < tmp ) l = tmp;
      else if( r < tmp ) r = tmp;
      else f = false;
    }
    cout << ( f ? "YES" : "NO" ) << endl;
  }


  return 0;
}


// EOF

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define VI vector<int>
#define PII pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
#define out(x) cout<<(#x)<<" = "<<x<<endl
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x){return mrand()%x;}
clock_t ac; double TLE(){return (double)(clock()-ac)/CLOCKS_PER_SEC;}

int main(){
 ios::sync_with_stdio(0);
 cin.tie(0);
 int n;
 cin>>n;
 int a[n];
 int c=0;
 for(int i=0;i<n;i++){
 	cin>>a[i];
    if((i+1)%2==1&&a[i]%2==1)c++;
 }
 cout<<c<<"\n";
}

Measured memory_bytes: 3576
#include<stdio.h>

int main(void){
  int h[3] ;
  int height;
  int temp ;
  int i;

  for(i=0; i<10; i++){
    scanf("%d",&height);

    if(height >= h[0]){
      temp = h[1];
      h[2] = temp;
      temp = h[0];
      h[1] = temp;
      h[0] = height;
    }else if(height >= h[1]){
      temp = h[1];
      h[2] = temp;
      h[1] = height;
    }else if(height >= h[2])
      h[2] = height;
  }

  int j;
  for(j=0; j<3; j++){
    printf("%d\n",h[j]);
  }  
  
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int si=s.size();
    for(int i=0; i<si; i++)
    {
        if(i%2==0)
        {
            if(s[i]=='R'||s[i]=='U'||s[i]=='D') ;
            
            else{
            cout << "No";
            return 0;
            }
        }
        else
        {
            if(s[i]=='L'||s[i]=='U'||s[i]=='D') ;
            else{ 
            cout << "No";
            return 0;}
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 256
[n, m] = list(map(int, input().split()))
votes = list(map(int, input().split()))
sumOfVotes = 0
largest = [0 for i in range(m)]

for v in votes:
  sumOfVotes += v
  if (largest[0] < v):
    largest[0] = v
    largest.sort()

if largest[0] * 4 * m < sumOfVotes:
  print("No")
else:
  print("Yes")

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

using namespace std;

using ll = long long;

vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i != n / i) res.emplace_back(n / i);
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll K;
    cin >> n >> K;

    ll sum = 0;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    vector<ll> ds = divisor(sum);
    sort(ds.begin(), ds.end(), greater<>());
    for (ll d : ds) {
        vector<ll> b(n);
        ll sum2 = 0;
        for (int i = 0; i < n; i++) {
            b[i] = a[i] % d;
            sum2 += b[i];
        }
        sort(b.begin(), b.end());

        ll x = sum2 / d;

        if (x >= n) continue;

        ll sum3 = 0;
        for (ll i = 0; i < (ll)n - x; i++) {
            sum3 += b[i];
        }

        if (sum3 <= K) {
            cout << d << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}
ll at[30][30];
ll bt[30][30];
ll ar[30];
ll upt[30][30][30];
ll mid(ll x, ll y, ll z) {
	if (x <= y && y <= z) {
		return y;
	}
	else if (y <= x && x <= z) {
		return x;
	}
	else return z;
}
int c[30];
ll ggd(ll x, ll v) {

	if (v == 0) return 0;
	ll rem = x % v;
	ll di = ((x / v) * v) * 2;
	ll r = di + x;
	return r + ggd(v, rem) - rem;

}
void solv() {
	ll n, x;
	cin >> n >> x;
	cout << ggd(max(x, n - x),min(x, n - x) ) << endl;

}


int main() {
	solv();

	return 0;
}


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

int main() {
  int H, W;
  std::cin >> H >> W;

  std::vector<std::vector<int>> A(H, std::vector<int>(W));
  std::vector<std::pair<int, int>> answer;

  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      std::cin >> A[y][x];
    }
  }

  int x = 0, y = 0;
  while (true) {
    int ny = (y % 2 == 0 ? y + (x + 1 == W) : y + (x == 0));
    int nx = (y % 2 == 0 ? (x + 1 == W ? x : x + 1) : (x == 0 ? x : x - 1));

    if (ny >= H) {
      break;
    }

    if (A[y][x] % 2 == 1) {
      A[ny][nx] += 1;

      answer.push_back(std::make_pair(y, x));
    }

    x = nx;
    y = ny;
  }

  std::cout << answer.size() << std::endl;

  for (int i = 0; i < answer.size(); i++) {
    int y = answer[i].first;
    int x = answer[i].second;
    int ny = (y % 2 == 0 ? y + (x + 1 == W) : y + (x == 0));
    int nx = (y % 2 == 0 ? (x + 1 == W ? x : x + 1) : (x == 0 ? x : x - 1));

    std::cout << y + 1 << " " << x + 1 << " " << ny + 1 << " " << nx + 1 << std::endl;
  }
}


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

template < unsigned mod >
class Modint
{
	public:
		using uint = unsigned;
		using u64 = uint64_t;
		using i64 = int64_t;

		Modint (const i64 dat = 0) : dat(dat >= 0 ? dat % mod : (mod - (-dat) % mod) % mod) {}

		constexpr Modint operator + (const Modint &v) const { return ( Modint(dat + v.dat) ); }
		constexpr Modint operator - () const { return ( Modint(-((i64)dat)) ); }
		constexpr Modint operator - (const Modint &v) const { return ( (*this) + -v ); }
		constexpr Modint operator * (const Modint &v) const { return ( Modint((u64)dat * v.dat) ); }

		constexpr Modint operator ~ () const
		{
			i64 a = dat, b = mod, x1 = 1, x2 = 0, t;

			while ( b > 0 ) {
				t = a / b;
				swap(a -= t * b, b);
				swap(x2 -= t * x1, x1);
			}

			return ( Modint(x1) );
		}

		constexpr Modint operator / (const Modint &v) const { return ( (*this) * ~v ); }

		Modint &operator = (const i64 &v) { return ( (*this) = Modint < mod > (v) ); }
		Modint &operator += (const Modint &v) { return ( (*this) = (*this) + v ); }
		Modint &operator -= (const Modint &v) { return ( (*this) = (*this) - v ); }
		Modint &operator *= (const Modint &v) { return ( (*this) = (*this) * v ); }
		Modint &operator /= (const Modint &v) { return ( (*this) = (*this) / v ); }

		constexpr Modint operator ^ (u64 n) const
		{
			Modint < mod > ret(1), mul(dat);
			while ( n > 0 ) {
				if ( n & 1 ) ret *= mul;
				mul *= mul;
				n >>= 1;
			}
			return ( ret );
		}

		bool operator == (const Modint &v) { return ( dat == v.dat ); }
		bool operator != (const Modint &v) { return ( dat != v.dat ); }

		friend ostream& operator << (ostream &os, const Modint &p )
		{
			return ( os << p.dat );
		}

		friend istream& operator >> (istream &is, Modint &p )
		{
			i64 data;
			is >> data;
			p = Modint < mod >(data);
			return ( is );
		}

	private:
		uint dat;
};

int N, K;
vector < int > G[100005];
bool flag[100005] = {};
constexpr int MOD = 1000000007;

Modint < MOD > dfs(int u, int remain, int depth = 0)
{
	Modint < MOD > ret(1);
	flag[u] = true;
	int cnt = 0;
	for ( int v : G[u] ) {
		if ( !flag[v] ) {
			int c = 0;
			if ( depth > 0 ) c = 1;
			ret *= dfs(v, max(0, K - c - 1 - cnt), depth + 1);
			cnt++;
		}
	}

	return (ret * Modint < MOD > (remain));
}

int main()
{
	cin >> N >> K;
	for ( int i = 0; i < N - 1; i++ ) {
		int a, b;
		cin >> a >> b; --a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	cout << dfs(0, K) << endl;

	return ( 0 );
}


Measured memory_bytes: 11648
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 

using namespace std;

int main() {
	int  i, j;
	string str1, str2;

	cin >> str1 >> str2;

	if (str1[0] == str2[2] && str1[1] == str2[1] && str1[2] == str2[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}










	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace  std;
int main()
{
    string a, b;
    cin >> a >> b;
    int dp[a.size()+1][b.size()+1] = {0};
    for(int i = 0; i <= a.size(); i++){
        for(int j = 0; j <= b.size(); j++){dp[i][j] = 0;}}
    for(int i = 1; i <= a.size(); i++){
        for(int j = 1; j <= b.size(); j++){
            if(a[i-1] == b[j-1])dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    string out = "";
    int i = a.size(), j = b.size();
    while(i != 0 and j != 0){
        if(a[i-1] == b[j-1])out.push_back(a[i-1]), i--, j--;
        else if(dp[i-1][j] > dp[i][j-1])i--;
        else j--;
    }
    reverse(out.begin(), out.end());
    cout << out;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define f(i,n)   for(int i=0;i<n;i++)
#define tsolve() int t; cin>>t; while(t--) solve();
#define all(s)  s.begin(),s.end()
#define ff first
#define ss second
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>  
int main(){
    int n,t;
    cin>>n>>t;
    map<int,int> m;
    f(i,n){
        int a,b;
        cin>>a>>b;
        m[a]=b;
    }
    for(auto i:m){
        if(i.ss>t)  m.erase(i.ff);
    }
    if(!m.size())    cout<<"TLE";
    else    cout<<m.begin()->ff;
    return 0;
}

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

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

using namespace std;


int main()
{
	int N;
	cin>>N;
	
	long long L[N+10];
	
	L[0]=2;
	L[1]=1;
	
	for(int i=2;i<N+1;++i){
		L[i]=L[i-1]+L[i-2];
	}
	
	cout<<L[N]<<endl;
	
	
	
	
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 500005;
const int B = 700;

int mp[N];

bool cmp(pair<pii,int> a, pair<pii,int> b)
{
    return (a.ff.ff/B < b.ff.ff/B) || (a.ff.ff/B == b.ff.ff/B && a.ff.ss < b.ff.ss);
}

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n,q;
        cin>>n>>q;
        int a[n];
        for(int i=0;i<n;i++)cin>>a[i];
        vector<pair<pii,int>> queries(q);
        int ans[q];
        for(int i=0;i<q;i++)
        {
            int l,r;
            cin>>l>>r;
            l--;
            r--;
            queries[i] = {{l,r},i};
        }
        sort(all(queries),cmp);
        int L = queries[0].ff.ff;
        int R = queries[0].ff.ss;
        int cnt = 0;
        for(int i=L;i<=R;i++)
        {
            mp[a[i]]++;
            if(mp[a[i]] == 1)cnt++;
        }
        ans[queries[0].ss] = cnt;
        for(int i=1;i<q;i++)
        {
            int l = queries[i].ff.ff;
            int r = queries[i].ff.ss;
            int ind = queries[i].ss;
            while(L < l)
            {
                mp[a[L]]--;
                if(!mp[a[L]])cnt--;
                L++;
            }
            while(L > l)
            {
                L--;
                mp[a[L]]++;
                if(mp[a[L]] == 1)cnt++;
            }
            while(R > r)
            {
                mp[a[R]]--;
                if(!mp[a[R]])cnt--;
                R--;
            }
            while(R < r)
            {
                R++;
                mp[a[R]]++;
                if(mp[a[R]] == 1)cnt++;
            }
            ans[ind] = cnt;
        }
        for(int i=0;i<q;i++)cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 27224
fn main(){
  let n: usize = read();
  let mut m: usize = 0;

  for _ in 0 .. n {
    let s: u32 = read();
    let mut x: u32 = 1;
    
    loop {
      if 2 * x * x + 2 * x > s { break; }

      if (s - x) % (2 * x + 1) == 0 {
        m += 1;
        break;
      }
      x += 1;
    }
  }

  println!("{}", n - m);
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}



Measured memory_bytes: 5044
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,D,c=0;cin>>N>>D;
  vector<vector<int>> X(N,vector<int>(D));
  for(int i=0; i<N; i++){
    for(int j=0; j<D; j++){
      cin >> X[i][j];
    }
  }
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N; j++){
      float len=0;
      for(int a=0; a<D; a++){
        len+=(X[i][a]-X[j][a])*(X[i][a]-X[j][a]);
      } 
      len=sqrt(len);
      if(len==int(len))c++;
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
    int x=0,p=1;char c=getchar();
    while (c<=32)c=getchar();
    if(c==45)p=-p,c=getchar();
    while (c>32)x=x*10+c-48,c=getchar();
    return x*p;
}
using namespace std;
//ruogu
const int N=505;
int n,k,sum,b[N],a[N],res;
//
bool check(int x){
	rep(i,n){
		b[i]=a[i]%x;
		if(b[i]<0)b[i]+=x;
	}
	sort(b,b+n);
	int p0=0,q0=n-1,cnt=0;
	while(p0<q0){
		int mn=min(b[p0],x-b[q0]);
		b[p0]-=mn;
		b[q0]+=mn;
		cnt+=mn;
		if(cnt>k)return false;
		if(!b[p0])p0++;
		if(b[q0]==x)q0--;
	}
	return true;
}
int main(){
	n=getint();k=getint();
	rep(i,n){
		a[i]=getint();
		sum+=a[i];
	}
	sum=abs(sum);
	for(int i=1;i*i<=sum;i++)if(sum%i==0){
		if(check(i))res=max(res,i);
		if(check(sum/i))res=max(res,sum/i);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
L,R = map(int,input().split())
l = L%2019
r = R%2019
ans = 2019
if R-L >= 2019-l:
    print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = min(ans,(i*j)%2019)
    print(ans)

Measured memory_bytes: 40812
let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init (n + 2) @@ fun i -> if i = 0 || i > n then 0 else Scanf.scanf " %d" (+) 0
let s = Array.fold_left (fun (s, p) a -> s + abs (p - a), a) (0, 0) a_s |> fst
let g i j = abs @@ a_s.(i) - a_s.(j)
let f i = s - g (i - 1) i - g i (i + 1) + g (i - 1) (i + 1)
let _ = for i = 1 to n do Printf.printf "%d\n" @@ f i done

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int N;
  cin >> N;
  vector <pair <int, int> > A;
  for(int i=0; i<N; i++) {
    int x, y;
    cin >> x >> y;
    A.emplace_back(y, x);
  }
  sort(A.begin(), A.end());
  long long sofar = 0;
  bool ok = true;
  for(auto a : A) {
    sofar += a.second;
    if(a.first < sofar) ok = false;
  }
  cout << (ok ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 2420
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int maxn = 100 + 10;
	static int a[];
	public static void main(String[] args) 
	{
		Scanner cin = new Scanner(System.in);
		int n=cin.nextInt();
		a=new int[maxn];
		int sum=0;
		for(int i=1;i<=n;i++)
		{
			a[i]=cin.nextInt();
			sum+=a[i];
		}
		int ans1=0;
		int temp=sum/n;
		for(int i=1;i<=n;i++)
		{
			ans1+=(temp-a[i])*(temp-a[i]);
		}
		
		
		int ans=ans1;
		temp=sum/n-1;
		ans1=0;
		for(int i=1;i<=n;i++)
		{
			ans1+=(temp-a[i])*(temp-a[i]);
		}
		ans=Math.min(ans, ans1);
		
		temp=sum/n+1;
		ans1=0;
		for(int i=1;i<=n;i++)
		{
			ans1+=(temp-a[i])*(temp-a[i]);
		}
		ans=Math.min(ans, ans1);
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>

using namespace std;
int main(void){
 int x1,y1;
 int x2,y2;
 int x3,y3;
 int x4,y4;

 cin>>x1>>y1;
 cin>>x2>>y2;

 std::cout<<x2-(y2-y1)<<" "<<y2+(x2-x1)<<" "<<x1-(y2-y1)<<" "<<y1+(x2-x1)<<std::endl;

 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n, m;
  cin >> n >> m;
  vector<ll> x(n), y(m);
  for(ll i = 0; i < n; i++) cin >> x[i];
  for(ll i = 0; i < m; i++) cin >> y[i];


  ll X = 0;
  for(ll i = 1; i < n; i++){
    X = (X + (x[i]-x[i-1]) * i * (n-i)) % mod;
  }

  ll Y = 0;
  for(ll i = 1; i < m; i++){
    Y = (Y + (y[i]-y[i-1]) * i * (m-i)) % mod;
  }
  cout << (X * Y) % mod << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)(j);i <= (int)(k);i ++)
#define debug(x) cerr<<#x<<":"<<(x)<<endl
#define fix cout<<fixed<<setprecision(20);
#define int long long
const int maxn=(int)1e6+5;
typedef pair<int,int> pii;

#define X first
#define Y second
typedef long long ll;
int MOD = (ll)1e9+7;
inline ll qpow(ll a, ll b) {return b? ((b&1)? a*qpow(a*a%MOD,b>>1)%MOD: qpow(a*a%MOD,b>>1))%MOD: 1;}
inline ll gcd(ll a, ll b) {return b? gcd(b, a%b): a;}
signed main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    map<pii,int> mp;
    int flag=0;
    rep(i,1,n){
        int a,b;cin>>a>>b;
        if(a==0&&b==0){flag++;continue;}
        int g=gcd(a,b);debug(g);
        a/=g,b/=g;
        if(a<0)a=-a,b=-b;
        mp[{a,b}]++;
    }
    int ans=1;
    for(auto p:mp){
        auto cur=p.X;
        int cnt1=p.Y;
        int cnt2=mp.count({cur.Y,-cur.X})?mp[{cur.Y,-cur.X}]:0;
        if(cur.Y<=0){
            //debug(cnt1);
            if(!mp.count({-cur.Y,cur.X}))ans*=(qpow(2,cnt1))%MOD;
        }
        else 
        ans*=(qpow(2,cnt1)+qpow(2,cnt2)-1+MOD)%MOD;
        ans%=MOD;
        //debug(cur.X),debug(cur.Y),debug(ans);
    }
    ans+=flag-1;ans+=MOD,ans%=MOD;
    cout<<ans<<endl;
}
/* 
ai*aj+bi*bj = 0
按照向量垂直分组，
每组只能取同一方向的，所有组的取法相乘即为答案
special case:
0 只能选一个
考虑和两个向量都垂直的情况，分成两组会重算，将向量都放到一四象限即可。

wr
1.p.Y cur.Y
2. 枚举p时处理算重
3. 都不取算两次
 */

Measured memory_bytes: 16004
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

string A[60], B[60];
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < M; i++) cin >> B[i];
	for (int i = 0; i <= N - M; i++) {
		for (int j = 0; j <= N - M; j++) {
			//cout << i << " " << j << endl;
			bool ok = true;
			for (int k = 0; k < M; k++) {
				if (A[i + k].substr(j, M) != B[k].substr(0, M)) {
					ok = false;
					break;
				}
			}
			if (ok) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VI a(n); cin >> a;
    bool up = true, down = true;
    int ans = 1;
    FOR(i, 1, n) {
        up &= a[i - 1] <= a[i];
        down &= a[i - 1] >= a[i];
        if (!(up | down)) {
            ++ans;
            up = down = true;
        }
    }
    cout << ans << "\n";
}

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

int main(){

    int a, b ;
    string s ;
    cin >> s ;
    a = (s[0]-'0')*10+(s[1]-'0') ;
    b = (s[2]-'0')*10+(s[3]-'0') ;
    if (a <= 12 && a != 0 && b <= 12 && b != 0){
        cout << "AMBIGUOUS" ;
        return 0 ;
    }
    if ((a > 12 || a == 0) && (b > 12 || b == 0)){
        cout << "NA" ;
        return 0 ;
    }
    if (a <= 12 && a != 0){
        cout << "MMYY" ;
        return 0 ;
    }
    cout << "YYMM" ;
    return 0 ;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using pll = pair<ll,ll>;
using vll = vector<pll>;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() {
    string s; cin >> s;
    if (s[0]=='7' or s[1]=='7' or s[2]=='7') {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3580
package main

import (
	"fmt"
)

func main() {
	var s string
	var N int
	fmt.Scanf("%d", &N)
	fmt.Scanf("%s", &s)
	t := []rune(s)
	for i, r := range t {
		t[i] = (r-'A'+rune(N))%26 + 'A'
	}
	res := string(t)
	fmt.Println(res)

}


Measured memory_bytes: 768