akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

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;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
    
    
    vector<int> a(5);
    rep(i,5) cin >> a[i];
    rep(i,5){
        if(a[i]==0){
            cout<<i+1<<endl;
            return;
        }
    }
    
    
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 7768
use proconio::{input, fastout};
use proconio::marker::{Usize1};

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
    }
    let mut children = vec![1usize; n];

    for _ in 0..k {
        input! {
            d: usize,
            aaa: [Usize1; d],
        }
        for a in aaa { children[a] = 0; }
    }

    let ans: usize = children.iter().sum();
    println!("{}", ans);
}


Measured memory_bytes: 2188
#include <stdio.h>
#include <stdlib.h>

int solution(int n)
{
    int n_mod;
    
    n_mod = n % 1000;
    return n_mod != 0 ? 1000 - n_mod : 0;
}

int main()
{
    int n;
    scanf("%d", &n);
    printf("%d\n", solution(n));
    return 0;
}

Measured memory_bytes: 1736
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
 
import bisect
 
 
N, H = mi()
A = [0]*N
B = [0]*N
for i in range(N):
    A[i], B[i] = mi()
 
B = sorted(B)
a = max(A)
m = bisect.bisect_left(B, a)
'''
s = 1
e = N
m = (s+e)//2
pre_m = 0
while True:
    m = (s+e)//2
    if B[m-1] > a:
        e = m
    elif B[m-1] <= a:
        s = m
    if s==e:
        m -= 1
        break
    #else:
        #break
    if e-s==1 and pre_m==m:
        break
    pre_m = m
'''
rem = H - sum(B[m:])
if rem > 0:
    print((N-m)+rem//a+(rem%a!=0))
else:
    for i in range(m, N):
        rem += B[i]
        if rem>0:
            print(N-i)
            exit()

Measured memory_bytes: 12080
#include<stdio.h>

int main()
{
	int d, i;
	while (scanf("%d", &d) != EOF)
	{
		if (d == 0)break;
		long int total = 0;
		for (i = d; i < 600; i += d)
		{
			total = total + i*i*d;
		}
		printf("%ld\n", total);
	}
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int a,b;
	while(scanf("%d%d",&a,&b)!=EOF)
	{
		double c=a*1.0/b;
		printf("%d %d %.5lf\n",a/b,a%b,c);
	}
	return 0;
 } 

Measured memory_bytes: 1068
n=int(input())
d=[list(map(int,input().split())) for i in range(n)]
for i in range(2,n):
    if d[i-2][0]==d[i-2][1] and d[i-1][0]==d[i-1][1] and d[i][0]==d[i][1]:
        print('Yes')
        exit()
else:print('No')

Measured memory_bytes: 9180
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

void zenbubatsu(){}
char animals1[100000] = {};
char animals2[100000] = {};
char animals3[100000] = {};
char animals4[100000] = {};
string s;
int n;
bool ok[4] = {true,true,true,true};
string sw(char now, char adj, char ans){
    if(now == 'S'){
        if(ans == 'o'){
            return adj == 'S' ? "S" : "W";
        } else {
            return adj == 'S' ? "W" : "S";
        }
    } else {
        if(ans == 'x'){
            return adj == 'S' ? "S" : "W";
        } else {
            return adj == 'S' ? "W" : "S";
        }
    }
}
bool match(string sw){
    for(int i=0;i<n;i++){
        if((s[i] == 'o') != ((sw[(i+n-1)%n] == sw[(i+1) % n]) == (sw[i] == 'S'))){
            return false;
        }
    }
    return true;
}
bool trySW(string str){
    for(int i=2;i<n;i++){
        str += sw(str[i-1],str[i-2],s[i-1]);
    }
    if(match(str)){
        cout << str << endl;
        return true;
    }
    return false;
}
int main(){
    cin >> n >> s;
    string animals="SS";
    if(trySW("SS") || trySW("SW") || trySW("WS")||trySW("WW")){
        return 0;
    }
    cout << -1 << endl;
}


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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILL(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){

  string s;
  cin >> s;
  bool flag = true;
  REP(i,s.size()){
    if(!(i & 1)&& s[i] == 'L')flag = false;
    if((i & 1) && s[i] == 'R')flag = false;
  }
  if(flag)cout << "Yes";
  else cout << "No";

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int main(){
    int x, cnt=0;
    string s;
    cin >> s;
    x = s.size();
    REP(i, x/2){
        if(s[i]!=s[x-i-1]) cnt++;
    }
    cout << cnt << endl;
}

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

using namespace std;
typedef long long ll;

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

int main(){
    ll h, w, k;
    cin >> h >> w >> k;

    if(w == 1){
        cout << 1 << endl;
        return 0;
    }

    vector<mint> nh(w);
    nh.at(0) = 1; nh.at(1) = 2;
    for(int i = 2; i < w; ++i){
        nh.at(i) = nh.at(i - 1) + nh.at(i - 2);
    }

    vector<mint> num(w);
    num.at(k - 1) = 1;
    // for(int i = 0; i < w; ++i){ cout << num.at(i).v << ' '; }
    // cout << endl;

    for(ll i = 0; i < h; ++i){
        vector<mint> num2(w);
        for(ll j = 0; j < w; ++j){
            // そのまま伸ばす
            num2.at(j) += num.at(j) *
                nh.at(max(j - 1, 0LL)) * nh.at(max(w - j - 2, 0LL));

            // 左
            if(j > 0){
                num2.at(j - 1) += num.at(j) *
                    nh.at(max(j - 2, 0LL)) * nh.at(max(w - j - 2, 0LL));
            }

            // 右
            if(j < w - 1){
                num2.at(j + 1) += num.at(j) *
                    nh.at(max(j - 1, 0LL)) * nh.at(max(w - (j + 1) - 2, 0LL));
            }
        }
        num = num2;

        // for(int i = 0; i < w; ++i){ cout << num.at(i).v << ' '; }
        // cout << endl;
    }

    cout << num.at(0).v << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int n;
    cin >> n;
    vector <ll> w(n);
    int sum = 0;
    rep(i,0,n) {
        cin >> w[i];
        sum += w[i];
    }
    int tmp;
    int mi = pow (10,6);
    rep (i,0,n) {
        tmp += w[i];
        mi = min(mi,abs(tmp-(sum-tmp)));
    }
    cout << mi << endl;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

void solve(){
    int A,B;

    cin>>A>>B;
    if(A<=5){
        cout<<0<<endl;
        return;
    }else if(A<=12){
        out(B/2);
        return;
    }else{
        out(B);
    }
    return ;

}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

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

int main() {
	string name1,name2;
	cin >> name1;
	cin >> name2;

	bool not_Flag = false;
	
	for (int i = 0; i < name1.length(); i++) 
		if (name1[i] != name2[i])not_Flag = true;

	if ((name1.length() + 1 != name2.length()))
		not_Flag = true;
	if (not_Flag) cout << "No";
		
	else cout << "Yes"; 
		
	return 0;
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int VerticalLineNum = Integer.parseInt(br.readLine());
        int HorizontalLineNum = Integer.parseInt(br.readLine());
        int[][] HorizontalLine = new int[HorizontalLineNum][2];
        
        for(int i = 0; i < HorizontalLine.length; i++){
            String[] FromTo = br.readLine().split(",");
            HorizontalLine[i][0] = Integer.parseInt(FromTo[0]);
            HorizontalLine[i][1] = Integer.parseInt(FromTo[1]);
        }
        
        int[] ResultLineNum = new int[VerticalLineNum + 1];
        for(int i = 1; i < VerticalLineNum + 1; i++){
            int CurrentLineNum = i;
            for(int hl = 0; hl < HorizontalLine.length; hl++){
                if(CurrentLineNum == HorizontalLine[hl][0]){
                    CurrentLineNum = HorizontalLine[hl][1];
                }
                else if(CurrentLineNum == HorizontalLine[hl][1]){
                    CurrentLineNum = HorizontalLine[hl][0];
                }
            }
            ResultLineNum[CurrentLineNum] = i;
        }
        
        for(int i = 1; i < ResultLineNum.length; i++){
            System.out.println(ResultLineNum[i]);
        }
    }
}

Measured memory_bytes: 24328
import numpy as np
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a = np.array(a)
b = np.array(b)
d = a - b

d.sort()
m = 0

for i in range(n):
    if d[i] >= 0:
        k = i
        break
    m += d[i]



if sum(d) < 0:
    print(-1)
else:
    j = 0
    i = n - 1
    tt = 0
    while m < 0:
        j += 1
        m += d[i]
        tt += d[i]
        i -= 1

    print(j + k)

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int h, w, n; cin >> h >> w >> n;

    if (n % max(h, w) == 0) {
        cout << n / max(h, w) << endl;
    } else {
        cout << n / max(h, w) + 1 << endl;
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<bitset>

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

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int syo(int a, int b) {
	return (int)((float)a / b + 0.5);
}

int main() {
	int n, k, i, j;
	int id;
	vi a;

	cin >> n >> k;

	a.resize(n);
	rep(i, n) {
		cin >> a[i];
	}
	i = 1;
	j = k;
	while (j < n) {
		i++;
		j += k - 1;
	}

	cout << i;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstdio>
#include<iomanip>
#include<map>
#include<cstring>
using namespace std;
int a,b,k;
int main()
{
    cin>>a>>b;
    k=b*2-a;
    cout<<k<<endl;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 100000;
int n, m;
int d[MAX_N];
vec<pii> g[MAX_N];

void dfs(int u, int p, int c, vi& col, vec<vi>& g) {
    col[u] = c;

    for (int v : g[u]) {
        if (v == p) continue;
        dfs(v, u, 1 - c, col, g);
    }
}

int main() {
    fastio();

    cin >> n >> m;
    forn(i, n) cin >> d[i];

    forn(i, m) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].emplace_back(v, i);
        g[v].emplace_back(u, i);
    }

    bool ok = true;
    vec<pii> p(n);
    forn(i, n) {
        bool temp = false;
        int cur = INT_MAX;
        for (auto e : g[i]) {
            int v, j;
            tie(v, j) = e;
            temp |= d[i] >= d[v];
            if (cur > d[v] || (cur == d[v] && p[i].fst > v)) {
                p[i] = e;
                cur = d[v];
            }
        }
        ok &= temp;
    }

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

    vi col(n, -1);
    vi ans(m, TEN(9));
    vec<vi> g2(n);
    forn(i, n) {
        ans[p[i].snd] = d[i];
        g2[i].push_back(p[i].fst);
        g2[p[i].fst].push_back(i);
    }

    forn(i, n) {
        if (col[i] < 0)
            dfs(i, -1, 0, col, g2);
    }

    forn(i, n) {
        cout << (col[i] ? 'B' : 'W');
    }
    cout << endl;

    forn(i, m) {
        cout << ans[i] << '\n';
    }

    return 0;
}

Measured memory_bytes: 18304
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n, t = 0;
	string s;
	cin >> n >> s;
	for(int i = 0; i < sz(s); i++){
		t++;
		while(i < sz(s) - 1 && s[i] == s[i + 1])
			i++;
	}
	cout << t << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
//#define ll __int64
#define ll long long
int n;
string t[200000];
ll c[10];
int main(){
	cin>>n;
	rep(i,n){

		cin>>t[i];
		if(t[i][0]=='M')c[0]++;
		if(t[i][0]=='A')c[1]++;
		if(t[i][0]=='R')c[2]++;
		if(t[i][0]=='C')c[3]++;
		if(t[i][0]=='H')c[4]++;
		
	}
	ll ans=0;
	for(int i=0;i<5;i++){
		for(int j=i+1;j<5;j++){
			for(int k=j+1;k<5;k++)ans+=(c[i]*c[j]*c[k]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6912
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
-- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Monad.Primitive
import           Control.Applicative
import           Debug.Trace
import           Text.Printf

main = do
  n <- getInt
  as <- map read . words <$> getLine :: IO [Integer]
  -- print as
  print $ solve as

solve as = if 0 `elem` as
           then 0
           else loop as 1
  where
    loop [] n
      | 10^18 < n = -1
      | n == 0 = 0
      | otherwise = n
    loop (x:xs) n
      | x == 0 = 0
      | 10^18 < x = -1
      | 10^18 < n = -1
      | otherwise = trace (show n) $  loop xs (x*n)

readInt = BS.readInteger . BS.dropWhile isSpace
getVector f = V.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons
getInt = readLn :: IO Integer
getInt2Tuple = (\vec -> (vec V.! 0, vec V.! 1)) <$> getIntVector
-- getInt3Tuple = (\vec -> (vec V.! 0, vec V.! 1, vec VU.! 2)) <$> getIntVector


Measured memory_bytes: 64180
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int P[] = new int[N];
		int sum = 1;

		for (int i = 0; i < N; i++) {
			P[i] = sc.nextInt();
		}
		sc.close();

		int min = P[0];

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

		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 87288
#include <cstdio>
#include <algorithm>

using namespace std;

const int N = 1e5 + 500;

int n, s;

int main(){
	scanf("%d", &n);
	for(int i = 0;i < n;i++){
		int x; scanf("%d", &x);
		s += (x % 2);
	}
	printf(s % 2 ? "NO\n" : "YES\n");
}

Measured memory_bytes: 1688
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <utility>
#include <algorithm>
#include <stack>
#include <vector>

using namespace std;

template<typename T>
int partition(T ar[], int p, int r){
    T pivot = ar[r];
    int i = p - 1;
    for (int j = p; j <= r - 1; j++) {
        if(ar[j] <= pivot){
            i++;
            swap(ar[i], ar[j]);
        }
    }
    i++;
    swap(ar[i], ar[r]);
    return i;
}

template<typename T>
void quicksort(T ar[], int head, int last){
    stack<int, vector<int> > starg;
    starg.push(head);
    starg.push(last);

    while (!starg.empty()) {
        int p, r;
        r = starg.top();
        starg.pop();
        p = starg.top();
        starg.pop();

        if(p < r){
            int q = partition(ar, p, r);
            starg.push(q + 1);
            starg.push(r);

            starg.push(p);
            starg.push(q - 1);
        }
    }
}

class Card {
    public:
        char squit;
        int value;
        bool operator <=(const Card &c){
            return this->value <= c.value;
        }

        bool operator != (const Card &c){
            return this->value != c.value || squit != c.squit;
        }

        bool operator > (const Card &c){
            return this->value > c.value;
        }
};

Card qs[100000];
Card bs[100000];

int main(int argc, char const* argv[])
{
    int n;

    scanf("%d ", &n);
    
    for (int i = 0; i < n; i++) {
        char s;
        int v;
        scanf("%c %d ", &s, &v);
        qs[i].squit = s;
        qs[i].value = v;
        bs[i].squit = s;
        bs[i].value = v;
    }

    quicksort(qs, 0, n - 1);
    stable_sort(bs, bs+n,
        [](const Card &fst, const Card &snd) -> bool
        {
            if(fst.value < snd.value) return true;
            return false;
        });

    bool is_stable = true;
    for (int i = 0; i < n; i++) {
        if(qs[i] != bs[i]){
            is_stable = false;
            break;
        }
    }

    if (is_stable) {
        puts("Stable");
    } else {
        puts("Not stable");
    }

    for (int i = 0; i < n ; i++) {
        printf("%c %d\n", qs[i].squit, qs[i].value);
    }

    return 0;
}

Measured memory_bytes: 4244
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void) {
    int N;
    cin >> N;
    vector<int64_t> x(N);
    for(int i=0; i<N; i++) {
        cin >> x[i];
    }

    for(int i=0; i<N; i++) {
        x[i] = x[N-1] - x[i];
    }

    vector<int64_t> factorial(N);
    factorial[0] = 1;
    for(int i=1; i<N; i++) {
        factorial[i] = (factorial[i-1] * i) % MOD;
    }

    int64_t ans = 0;
    for(int i=0; i<N-1; i++) {
        ans = (ans + ((x[i] * factorial[N-1]) % MOD) * modinv(i+1, MOD)) % MOD;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import sys
h,w = map(int,input().split())
a = ["."*(w+2)]+['.'+input()+'.' for i in range(h)]+["."*(w+2)]
for i in range(h):
    for j,q in enumerate(a[i+1]):
        if q == "#":
            if a[i][j] != "#" and a[i+1][j-1] != "#" and a[i+1][j+1]  != "#" and a[i+2][j] != "#":
                print("No")
                sys.exit()
print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define F first
#define S second
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define p_b push_back
#define all(c)              c.begin(), c.end()
using namespace std;
typedef long long ll; //printf("%lld ", ll); to out put long
typedef pair <int , int> pii;
typedef pair <ll , ll> pll;
const double eps = 1e-6;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
bool ODD(ll O) {return (O % 2 != 0);}
ll gcd(ll a, ll b) {return __gcd(a , b);}
ll lcm(ll a, ll b) {return a * b / gcd(a , b);}
int dx[] = {1, 0, -1 ,0 , -1 , 0};
int dy[] = {0, 1, 0, -1 , -1 , 0};
ll power (ll x, ll y) {
    if(y == 0) return 1;
    if(ODD(y)) return x * power(x , y / 2) * power(x , y / 2);
    return power(x , y / 2) * power(x , y / 2);
}
/*------ never give up --------*/
int dp[MAXN][4], arr[MAXN][4];
int n, k;
int solve(int idx , int lst) {
    if(idx >= n) return 0;

    int &ret = dp[idx][lst];
    if(ret != -1) return ret;
    int sol_1 = 0, sol_2 = 0, sol_3 = 0;
    if(lst == 3) {
        sol_1 = solve(idx + 1 , 1) + arr[idx][1];
        sol_2 = solve(idx + 1 , 2) + arr[idx][2];
        sol_3 = solve(idx + 1 , 0) + arr[idx][0];

    }
    if(lst == 0) {
        sol_1 = solve(idx + 1 , 1) + arr[idx][1];
        sol_2 = solve(idx + 1 , 2) + arr[idx][2];
    }
    if(lst == 1) {
        sol_1 = solve(idx + 1 , 0) + arr[idx][0];
        sol_2 = solve(idx + 1 , 2) + arr[idx][2];
    }
    if(lst == 2) {
        sol_1 = solve(idx + 1 , 0) + arr[idx][0];
        sol_2 = solve(idx + 1 , 1) + arr[idx][1];
    }
    ret = max(max(sol_1 , sol_2) , sol_3);
    return ret;
}
int main () {
    int t = 1;
    //cin >> t;
    while(t--) {
        scanf("%d" , &n);
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < 3; j++) {
                cin >> arr[i][j];
            }
        }
        memset(dp , -1 , sizeof dp);
        printf("%d", solve(0 , 3));

    }

    return 0;
}


Measured memory_bytes: 13192
from collections import defaultdict

n, m = map(int, input().split())
h = list(map(int, input().split()))

to = defaultdict(set)
for i in range(m):
    aa, bb = map(int, input().split())
    aa -= 1
    bb -= 1
    to[aa].add(bb)
    to[bb].add(aa)

ans = 0
for i in range(n):
    f = True
    for t in to[i]:
        if h[i] <= h[t]:
            f = False
            break
    if f:
        ans += 1
print(ans)


Measured memory_bytes: 51512
zero_first = 0
one_first = 0
for i, c in enumerate(input()):
    if i % 2 == 0 and c == '0' or i % 2 == 1 and c == '1':
        zero_first += 1
    else:
        one_first += 1
print(min(zero_first, one_first))


Measured memory_bytes: 3240
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);//XLipÌÏ
    static double time_of_500m, time_of_1000m;//^Cði[·éÏ
    public static void main(String[] args) {
        while(read()){//Ìsª éÈçÇÝæèÆ»èðÀs
            slove();//»è
        }
    }
    static boolean read(){
    	if(!sc.hasNextDouble()) return false; 
        time_of_500m = sc.nextDouble();//ÇÝæè
        time_of_1000m = sc.nextDouble();//ÇÝæè
        return true;
    }
    static void slove(){
        //System.out.println(time_of_500m);fobOpÈÌÅCÉµÈ¢Å­¾³¢
        //System.out.println(time_of_1000m);fobOpÈÌÅCÉµÈ¢Å­¾³¢
        //±±©çÍüÍÉÎµÄif¶Åðð»èµÄ¢Ü·B
        if(time_of_500m < 35.5 && time_of_1000m < 71.0){
            System.out.println("AAA");
        }else if(time_of_500m < 37.5 && time_of_1000m < 77.0){
            System.out.println("AA");
        }else if(time_of_500m < 40.0 && time_of_1000m < 83.0){
            System.out.println("A");
        }else if(time_of_500m < 43.0 && time_of_1000m < 89.0){
            System.out.println("B");
        }else if(time_of_500m < 50.0 && time_of_1000m < 105.0){
            System.out.println("C");
        }else if(time_of_500m < 55.0 && time_of_1000m < 116.0){
            System.out.println("D");
        }else if(time_of_500m < 70.0 && time_of_1000m < 148.0){
            System.out.println("E");
        }else{
            System.out.println("NA");
        }
    }
}

Measured memory_bytes: 12000
//https://atcoder.jp/contests/agc024/tasks/agc024_a
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll a,b,c,k; cin>>a>>b>>c>>k;
    ll ans=(k%2==1)?b-a:a-b;
    cout<<ans<<endl;    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef std::string str;
#define sei set<int>
#define sell set<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vld vector<ld>
#define vstr vector<str>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(v) v.begin(),v.end()
#define foa(i,v) for(auto i : v)
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define deb(x)  cerr << #x << " = " << x << endl
#define pb push_back
#define pob pop_back
#define F first
#define S second
#define OK order_of_key
#define FO find_by_order
#define nmax 1000100
const ld PI = 3.141592653589793238462643383279;
const ll inf = std::numeric_limits<ll>::max();
const int infint = std::numeric_limits<int>::max();
const ll mod = 1e9+7;
using namespace __gnu_pbds;
using namespace std;
/*#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")*/
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m,a,b;
    cin >> n >> m >> a >> b;

    fo(i,0,b){
        fo(j,0,a) cout << 1;
        fo(j,a,m) cout << 0;
        cout << '\n';
    }
    fo(i,b,n){
        fo(j,0,a) cout << 0;
        fo(j,a,m) cout << 1;
        cout << '\n';
    }

    return 0;
}



Measured memory_bytes: 1280
from collections import deque

n = int(input())
ab = [[]for i in range(10**5)]
v=[0]*(10**5)
d=[float('INF')]*(10**5)
for i in range(n-1):
    a , b , c = map(int, input().split())
    ab[a-1].append((b-1,c))
    ab[b-1].append((a-1,c))
q , k = map(int, input().split())

k-=1
de=deque()
de.append((k,0))

d[k]=0
while de:
    now , dis = de.popleft()
    if dis > d[now]:
        continue

    for next , cost in ab[now]:
        if dis + cost < d[next]:
            d[next]= dis + cost
            de.append((next,dis+cost))

for i in range(q):
    x , y = map(int, input().split())
    x-=1
    y-=1
    print(d[x]+d[y])


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

int main(){
    int n,k;
    string s;
    cin >> n >> s >> k;
    char str = s[k-1];
    for(int i=0;i<n;i++){
        if(str!=s[i]) cout << '*';
        else cout << str;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int x, y;
	cin >> x >> y;
	vector <vector <char>> boxs(60,vector <char>(60,0)); //2次元表の作成・初期値に0を入力
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			cin >> boxs[i][j];						//表に値を代入
		}
	}
	for (int i = 0; i < x; i++) {					//縦
		for (int j = 0; j < y; j++) {				//横
			if (boxs[i][j] == '#') {
				cout << '#';						//配列の中身が#ならばそのまま#を入力し無視する。
			}
			else if(boxs[i][j] =='.'){				//空きマスかを確認（初期値を0としているため）
				int add=0;							//ボムの量をカウントするカウンターの作成
													//存在するなら値を１プラスする
				if (i != 0 && j != 0) {				//左上に配列が存在するならば左上が#か確認
					if (boxs[i - 1][j - 1] == '#') {
						add++;
					}
				}
				if (i != 0) {						//上に配列が存在するなら
					if (boxs[i - 1][j + 1] == '#') {//右上を確認
						add++;
					}
					if (boxs[i - 1][j] == '#') {	//上を確認
						add++;
					}
				}
				if (j !=0) {						//左が存在するならば
					if (boxs[i][j - 1]=='#') {		//左を確認
						add++;
					}
					if (boxs[i + 1][j - 1] == '#') {//左下を確認
						add++;
					}
				}
				if (boxs[i][j + 1] == '#') {		//右を確認
					add++;
				}
				if (boxs[i + 1][j] == '#') {		//下を確認
					add++;
				}
				if (boxs[i + 1][j+1] == '#') {		//右下を確認
					add++;
				}
				cout << add;						//値を出力

			}
		}
		cout << endl;								//改行を入力
	}
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define fill(a,val) memset(a,val,sizeof(a))
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define pb push_back
#define SQ(a) (a)*(a)

#define M 315
using namespace std;
 

int main()
{
    std::ios::sync_with_stdio(false);
    int T = 1;
    //cin>>T;
    while(T--)
    {
       char n;
       cin>>n;
        if(islower(n))
            cout<<"a";
        else
            cout<<"A";

    }   
    
    return 0;
}


Measured memory_bytes: 3684
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;


int main(void) {
    int n, m;
    Graph G;
    vector<int> h;
    cin >> n >> m;
    G.resize(n);
    h.resize(n);

    rep(i, n) cin >> h[i];

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int ans = 0;

    rep(i, n) {
        int value = h[i];
        bool flag = true;
        for(auto v : G[i]) {
            if(h[v] >= value) {
                flag = false;
                break;
            }
        }
        if(flag)  {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8800
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int H,W;
while(true){
cin>>H>>W;
	if(H==0&&W==0)break;
		for(int i=0;i<H;i++){
			if(W%2==0){
					if(i%2==0){
					for(int j=0;j<W/2;j++)cout<<"#.";
					}
					else{
					for(int j=0;j<W/2;j++)cout<<".#";
					}
				cout<<endl;	
			}
			
			else{
			if(i%2==0){
					for(int j=0;j<W/2;j++)cout<<"#.";
					cout<<"#";
					}
					else{
					for(int j=0;j<W/2;j++)cout<<".#";
					cout<<".";
					}
				cout<<endl;
			}
		
	}
	cout<<endl;
}
return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;
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 long long INF = 1LL << 60;
using pll = pair<long long, long long>;
typedef long long ll;
#define min(a, b) ((a) < (b) ? (a) : (b))
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数
long long gcd(long long a, long long b)
{
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	// cout << std::fixed << std::setprecision(15);

	vector<int> ABC(3);

	for (int i = 0; i < 3; i++) {
		cin >> ABC.at(i);
	}
	sort(ABC.begin(), ABC.end());
	int res = 0;
	while (ABC.at(0) != ABC.at(1) || ABC.at(1) != ABC.at(2) || ABC.at(2) != ABC.at(0)) {

		if (ABC.at(0) < ABC.at(2) && ABC.at(1) < ABC.at(2)) {
			ABC.at(0) += 1;
			ABC.at(1) += 1;
		}
		else if (ABC.at(0) < ABC.at(2) && ABC.at(1) == ABC.at(2)) {
			ABC.at(0) += 2;
		}
		++res;
		sort(ABC.begin(), ABC.end());
	}

	cout << res << endl;
}


Measured memory_bytes: 384
K=gets.chomp.to_i
S=gets.chomp.strip.to_s

s_len = S.length
s_array = []

if K >= s_len
  puts S
else
  s_array =  S.chars
  s_tmp = s_array[0..K-1].inject(:+)
  s_tmp << '...'
  puts s_tmp
end

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

int gcd(int x, int y){
  int r;
  while((r=x%y)!=0){x=y; y=r;}
  return y;
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++)cin >> A[i];
  sort(A.begin(),A.end());
  for(int i=A[1];i>=1;i--){
    int cnt=0; bool q=true;
    for(int j=0;j<N;j++){
      if(A[j]%i!=0){cnt++;}
      if(cnt>=2){q=false; break;}
    }
    if(q){cout << i << endl; return 0;}
  }
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const ll INF = 1e15;
int main(){

  int n,W;
  cin >> n >> W;
  ll dp[n+10][W+10];
  memset(dp,0,sizeof(dp));
  ll w,v;
  rep(i,n){
    cin >> w >> v;
    rep(j,W){
      if(j+w <= W) dp[i+1][j+w] = max<ll>(dp[i+1][j+w],dp[i][j] + v);
      dp[i+1][j] = max<ll>(dp[i+1][j],dp[i][j]);
    }
  }
  ll ans = 0;
  rep(i,W+1){
    ans = max<ll>(dp[n][i],ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 86144
#include <bits/stdc++.h>
using namespace std;
 
typedef long long               ll;
typedef long double             ld;
 
 
#define racecar          ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define si(a)            scanf("%d", &a)
#define si2(a,b)         scanf("%d %d", &a,&b)
#define sll(a)           scanf("%I64d",&a)
#define sll2(a,b)        scanf("%I64d %I64d",&a,&b)
#define pb               push_back
#define pi(a)            printf("%d",int(a))
#define pll(a)           printf("%I64d",ll(a))
#define all(x)           (x).begin(),(x).end()
#define rall(x)          (x).rbegin(),(x).rend()
#define ps               printf(" ")
#define nln              printf("\n")
#define ff               first
#define ss               second
#define vi               vector<int>
#define vll              vector<ll>
#define vstr             vector<string>
#define vc               vector<char>
#define pii              pair<int,int>
#define PLL              pair<ll,ll>
#define PI               acos(-1)
#define sq(x)            x*x
#define forr(i,a,b)      for(ll i=ll(a);i<ll(b);i++)
#define forn(i,a,b)      for(ll i=ll(a);i>ll(b);i--)
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(max3(a,b,c),d)
#define min3(a,b,c)      min(a,min(b,c))
#define mod              1000000007
#define inf              9223372036854775807
 
ll power(ll b,ll n)
{
    if(n==0) return 1;
    else if(n%2) return b*power(b,n/2)*power(b,n/2);
    else return power(b,n/2)*power(b,n/2);
} 
 
ld root(ll n,ll r)
{
    ld dif=0.0001;
    ld guess=n/2.0;
    while(abs(pow(guess,r)-n)>=dif)
    {
        ld temp=pow(guess,r)-n;
        ld tmp=r*pow(guess,r-1);
        guess-=temp/tmp;
    }
    return guess;
}
 
void fileio()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

bool persq(ll n)
{
	ll s=sqrt(n);
	if(sq(s)==n) return true;
	return false;
}
 
 
int solve()
{
	int n,d;
	si2(n,d);
	vi v[n+1];
	forr(i,0,n)
	{
		forr(j,0,d)
		{
			int x;
			si(x);
			v[i].pb(x);
		}
	}
	int tot=0;
	/*
	forr(i,0,n)
	{
		forr(j,0,d) pi(v[i][j]),ps;
		nln;
	}       */
	forr(i,0,n)
	{
		forr(j,i+1,n)
		{
			ll temp=0;
			forr(k,0,d)
			{
				ll tmp=(v[i][k]-v[j][k]);
				tmp*=tmp;
				temp+=tmp;
	//			pll(tmp),ps;
			}
			if(persq(temp)) tot++;
	//		cout<<temp;
	//		nln;
		}
	}
	pi(tot);
				
				
				
	
	
	return 0;
}
 
int main()
{   
 
//    racecar;
//    cout<<fixed<<setprecision(6);
//    fileio();
    solve();
}
 
 
 
///    Before submission=>
///    ***check for integer overflow,array bounds
///    ***check for n

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n , k;
	cin >> n >> k;
	
	int dp[n + 1][2];
	dp[0][0] = dp[0][1] = 1;
	rep(i , n){
		dp[i + 1][0] = k + min(dp[i][0] , dp[i][1]);
		dp[i + 1][1] = 2 * min(dp[i][0] , dp[i][1]);
	}
	cout << min(dp[n][0] , dp[n][1]);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    string n; cin >> n;

    for (char c : n) {
        cout << (char)('1' + '9' - c);
    }

    return 0;
}


Measured memory_bytes: 256
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	抓住数据范围哪里小
	dfs or bfs
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	树的直径:随便找一点再走到它最远的点A，再从A最远的点走到最远B的点。AB就是树的直径
	匹配括号 左减右>=0
	字符串赋值字符加单引号
	double> printf("%lf")输出小数点6位，%.16lf输出后十六位
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<ceil(log2(double(n)))
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define FIR first
#define SEC second
using namespace std;
const int MAX=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
LL n,a[3003];
LL flag[3003][3003],MP[3003][3003];
LL find_maximum(int l,int r){
	if(l<1||r>n) return 0;
	if(flag[l][r]){
	return MP[l][r];
	} 
	if(l==r) return a[l];
	flag[l][r]=1;
	return MP[l][r]=max(a[l]-find_maximum(l+1,r),a[r]-find_maximum(l,r-1));
}
int main(){
//	freopen("out.out","r",stdin);
	scanf("%lld",&n);
	rb(i,1,n)scanf("%lld",&a[i]);
	printf("%lld\n",find_maximum(1,n));
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextInt();
  vector<int> X(N);
  REP(i, N) X[i] = nextInt();

  int ans = 1001001001;
  for (int x = 0; x <= 100; x++) {
    int cost = 0;
    REP(i, N) {
      cost += (X[i] - x)*(X[i] - x);
    }
    chmin(ans, cost);
  }
  cout << ans << endl;

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def main():
    K, N = read_values()
    A = read_list()
    A += [K + A[0]]
    B = [A[i + 1] - A[i] for i in range(N)]
    print(K - max(B))


if __name__ == "__main__":
    main()


Measured memory_bytes: 25228