akhauriyash/Code-Regression huggingface dataset:
// overkill sol to https://atcoder.jp/contests/abc097/tasks/arc097_a
// more functions https://github.com/bqi343/USACO/blob/master/Implementations/content/strings%20(14)/Heavy/SuffixAutomaton.h

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

struct state {
    int len, link;
    map<char, int> adj;
};
const int MAXLEN = 100002;
state a[MAXLEN * 2];
int sz, last;

void sa_init() {
    a[0].len = 0;
    a[0].link = -1;
    sz++;
    last = 0;
}

void sa_extend(char c) {
    int cur = sz++;
    a[cur].len = a[last].len + 1;
    int p = last;
    while (p != -1 && !a[p].adj.count(c)) {
        a[p].adj[c] = cur;
        p = a[p].link;
    }
    if (p == -1) {
        a[cur].link = 0;
    } else {
        int q = a[p].adj[c];
        if (a[p].len + 1 == a[q].len) {
            a[cur].link = q;
        } else {
            int clone = sz++;
            a[clone].len = a[p].len + 1;
            a[clone].adj = a[q].adj;
            a[clone].link = a[q].link;
            while (p != -1 && a[p].adj[c] == q) {
                a[p].adj[c] = clone;
                p = a[p].link;
            }
            a[q].link = a[cur].link = clone;
        }
    }
    last = cur;
}

ll cnt[MAXLEN];

ll getsize(int x) {
    if (cnt[x]) return cnt[x];
    cnt[x] = 1;
    for(auto i: a[x].adj){
        cnt[x] += getsize(i.second);
    }
    return cnt[x];
}

string kth(int cur, int k){
    assert(k < cnt[cur]);
    if(!k) return "";
    k--;
    for(auto i: a[cur].adj){
        if(k < cnt[i.second])
            return i.first+kth(i.second, k);
        k -= cnt[i.second];
    }
    assert(0);
    return "";
}

int main(){
    string s; int k;
    cin >> s >> k;
    sa_init();
    for(auto c: s)
        sa_extend(c);
    getsize(0);
    cout << kth(0, k);
    
    return 0;
}

Measured memory_bytes: 11904
#include <stdio.h>
int main()
{
	int a,b;
	char op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		if(op=='+')
			printf("%d\n",a+b);
		else if(op=='-')
			printf("%d\n",a-b);
		else if(op=='*')
			printf("%d\n",a*b);
		else if(op=='/')
			printf("%d\n",a/b);
		else
			break;
	}
	return 0;
}

Measured memory_bytes: 1028
#include<iostream>

using namespace std;

int main() {
	int m = 100000;
	int n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		m = m * 1.05;
		if (m % 1000 != 0) {
			int work = m % 1000;
			m = m - work + 1000;
		}
	}

	cout << m << endl;

	return 0;

}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;


void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
template<typename T>
T argument(const pair<T, T> &a, const pair<T, T> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

/* 注意 

    1LL<<60 * N とかのオーバーフローに気を付けろ
    制約がヒントになる、ちゃんと全ての制約を見ろ

*/

int const MAX = 2000000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

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

    COMinit();
    int n, k; std::cin >> n >> k;
    std::vector<std::vector<ll>> p(1010, std::vector<ll>(1010, 0));
    rep(j, 1010) p[0][j] = 1;
    repr(i, 1, 1010) repr(j, 1, 1010) {
        p[i][j] = p[i][j-1];
        if (i-j>=0) p[i][j] += p[i-j][j];
        chmod(p[i][j]);
    }
    std::cout << p[n][k] << std::endl;
    
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int min = 31;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    
    int j = 0;
    for (; A % 2 == 0; j++) {
      A /= 2;
    }
    if (j < min) {
      min = j;
    }
  }
  
  cout << min << endl;
  
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> N(n);
    for(int i=0;i<n;i++){
        cin >> N.at(i);
    }
    int c=n;
    
    for(int i=0;i<n;i++){
        for(int j=2;j*j<=N.at(i);j++){
            bool flag =false;
            if(N.at(i)%j==0&&N.at(i)!=j){
                c--;
                flag=true;
            }
            if(flag==true) break;
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 3052
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container, std.typecons;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	string s;
	s = readln().chomp;
	int n = s.length.to!int;
	if (s[n-1] == '1') {
		writeln(-1);
		return;
	}
	if (s[0] == '0') {
		writeln(-1);
		return;
	}
	foreach (i; 0..n-1) {
		if (s[i] != s[n-2-i]) {
			writeln(-1);
			return;
		}
	}
	int v = 2, front = 2;
	writeln(1,' ',2);
	foreach (i; 1..n-1) {
		v++;
		writeln(front,' ',v);
		if (s[i] == '1') {
			front = v;
		}
	}
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	private static Scanner sc;
	private static int n;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		n=sc.nextInt();
		PrimeFactorize(n);
	}
	static void PrimeFactorize(int x){
		System.out.print(x+":");
		if(!isPrime(x)){
			int i=2;
			while(x!=1){
				while(x%i==0){
					System.out.print(" "+i);
					x/=i;
				}
				i++;
				while(!isPrime(i)){
					i++;
				}
			}
		}else{
			System.out.print(" "+x);
		}
		System.out.println();
	}
    static boolean isPrime(int n) {
        if (n <= 1) {
            return false;
        }
        if (n == 2) {
            return true;
        }
        for (int i = 2; i <= Math.sqrt(n)+1; i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }
}

Measured memory_bytes: 26476
from itertools import product


def main():
    """
    1 <= N <= 500
    3 <= C <= 30
    (i!=j): 1 <= D(i,j) <= 1000
    (i==j): 0  = D(i,j)
    1 <= c(i,j) <= C
    """
    N, C = map(int, input().split())
    D = [
        list(map(int, input().split()))
        for _ in range(C)
    ]
    c = [
        list(map(int, input().split()))
        for _ in range(N)
    ]
    ans = f(N, C, c, D)
    ans1 = fast_f(N, C, c, D)
    assert ans == ans1
    if N <= 30:
        ans2 = TLE(N, C, c, D)
        assert ans == ans2

    print(ans)


def WA(N, C, c, D):
    for i in range(N):
        for j in range(N):
            for x in range(N):
                for y in range(N):
                    same_type = (i + j) % 3 == (x + y) % 3
                    c1 = c[i][j]
                    same_color = c1 == c[x][y]
                    if same_type != same_color:
                        D[c1-1]

    return


def TLE(N, C, c, D):
    """
    3色に割り当てるので C^3
    """
    ans = float("inf")
    for i, j, k in product(range(C), repeat=3):
        if i == j or i == k or j == k:
            continue

        tmp = 0
        for x, y in product(range(N), repeat=2):
            rem = (x + y) % 3
            bef = c[x][y] - 1
            aft = [i, j, k][rem]
            tmp += D[bef][aft]

        ans = min(ans, tmp)

    return ans


def f(N, C, c, D):
    """
    """
    t = [[0] * C for _ in range(3)]
    ans = float("inf")
    for i in range(N):
        for j in range(N):
            # 余りのパターンごとに色の数を集計して圧縮
            rem = (i + j) % 3
            color = c[i][j]
            t[rem][color - 1] += 1

    for i in range(C):
        for j in range(C):
            if i == j:
                continue
            for k in range(C):
                if i == k or j == k:
                    continue
                # 余りのパターン[0,1,2]について、変更後の色の組合せを全列挙[i,j,k]
                # パターンが違うなら、色も異なるので同色にならないように考慮

                tmp = 0
                for bef in range(C):
                    for aft, rem in zip((i, j, k), range(3)):
                        # 違和感 × 対象個数
                        tmp += D[bef][aft] * t[rem][bef]

                ans = min(ans, tmp)

    return ans


def fast_f(N, C, c, D):
    t = [[0] * C for _ in range(3)]
    ans = float("inf")
    for i, j in product(range(N), repeat=2):
        for aft in range(C):
            rem = (i + j) % 3
            color = c[i][j]
            # 個数だけでなく、違和感も前処理に含める
            t[rem][aft] += D[color - 1][aft]

    for i, j, k in product(range(C), repeat=3):
        if i == j or i == k or j == k:
            continue

        tmp = 0
        for aft, rem in zip((i, j, k), range(3)):
            tmp += t[rem][aft]

        ans = min(ans, tmp)

    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 48988
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

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

		int sum=0;
		
		for(int i=1;i<=N;i++) {
				int num=i;
				int subSum= num % 10;
				while(num >= 10) {
					num=num / 10;
					subSum=subSum + num % 10;
				}
				if(A <= subSum && subSum <= B)sum = sum +i;
		}
		
		
		
		System.out.println(sum);
	}
}


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

typedef long long ll;
typedef pair <int, int> pii;

const int N = 1e5 + 5, inf = 1e9;

int n, m, dist[N], par[N];
vector <int> adj[N];

void bfs() {
	for (int i = 1; i < n; i++)
		dist[i] = inf;
	queue <int> q;
	q.push(0);
	while(!q.empty()) {
		int v = q.front();
		q.pop();
		for (auto u : adj[v]) {
			if(dist[u] > dist[v] + 1)
				dist[u] = dist[v] + 1, q.push(u), par[u] = v;
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int v, u;
		cin >> v >> u;
		v--, u--;
		adj[v].push_back(u);
		adj[u].push_back(v);
	}
	bfs();
	for (int i = 0; i < n; i++)
		if(dist[i] == inf)
			return cout << "No\n", 0;
	cout << "Yes\n";
	for (int i = 1; i < n; i++)
		cout << par[i] + 1 << "\n";
}


Measured memory_bytes: 10844
N = int(input())
s = []
for i in range(N):
  S=input()
  s.append(S)
print('AC x {}'.format(s.count('AC')))
print('WA x {}'.format(s.count('WA')))
print('TLE x {}'.format(s.count('TLE')))
print('RE x {}'.format(s.count('RE')))

Measured memory_bytes: 16296
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Atcoder_Answer
{
    class Program
    {
        const int mod = 1000000007;

        static void Main(string[] args)
        {
            string[] READ0 = ReadLine().Split(' ');
            int H = int.Parse(READ0[0]);
            int N = int.Parse(READ0[1]);
            string[] READ1 = ReadLine().Split(' ');
            List<int> SpellDamages = new List<int>();
            for (int loop = 0; loop < N; loop++) SpellDamages.Add(int.Parse(READ1[loop]));
            long SpellDamage_SUM = SpellDamages.ToArray().Sum();

            if (SpellDamage_SUM >= H) WriteLine("Yes");
            else WriteLine("No");
            ReadKey();
        }
    }

    public static class Extension
    {
        #region 拡張:bool
        #region キャスト関連
        public static int ToInt(this bool Bool)
        {
            if (Bool) return 1;
            else return 0;
        }

        public static string ToString(this bool Bool, string TrueStr, string FalseStr)
        {
            if (Bool) return TrueStr;
            else return FalseStr;
        }
        #endregion
        #endregion

        #region 拡張:int
        #region キャスト関連
        public static char ToAlphaBets(this int Base) => (char)Base;
        #endregion
        #endregion

        #region 拡張:char
        #region 変換関連
        public static char NextAlpha(this char Char) => (char)((Char) + 1); //次の文字を取得
        #endregion
        #endregion

        #region 拡張:int[]
        public static long Sum(this int[] Array) 
        {
            int Ret = 0;
            for (int loop = 0; loop < Array.Length; loop++) Ret += Array[loop];
            return Ret;
        }
        #endregion
    }
}


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

int main(){
    string s,t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(s == u){
        a = a-1;
    } else {
        b = b-1;
    }
    cout << a;
    cout << " ";
    cout << b;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main() {
	int ans[N];
	int s[N];
	vector<pair<int, int> >e[N];
	vector<int>st;
	f(i, N) {
		s[i] = 0;
		ans[i] = 1;
	}
	ans[0] = 2;
	int n, k, m, t;
	int x, y, z;
	scanf("%d %d %d", &n, &m, &t);
	f(tt, m) {
		scanf("%d %d %d", &x, &y, &z);
		y--;
		if (z == 1) {
			f(i, st.size()) {
				k = st[i];
				e[k].push_back(make_pair(y, -x));
				e[y].push_back(make_pair(k, -x));
			}
			st.push_back(y);
		}
		else {
			f(i, st.size()) {
				if (st[i] == y) {
					st.erase(st.begin() + i);
					break;
				}
			}
			f(i, st.size()) {
				k = st[i];
				e[k].push_back(make_pair(y, x));
				e[y].push_back(make_pair(k, x));
			}
		}
	}
	int k2;
	f(i, st.size()) {
		k = st[i];
		f(j, i) {
			k2 = st[j];
			e[k].push_back(make_pair(k2, t));
			e[k2].push_back(make_pair(k, t));
		}
	}
	f(i, n) {
		sort(e[i].begin(), e[i].end());
		z = 0;
		while (z < e[i].size()) {
			x = 0;
			y = 0;
			while (e[i][z + y].first == e[i][z].first) {
				x += e[i][z + y].second;
				y++;
				if (y+z >= e[i].size())break;
			}
			if (x > s[i]) {
				s[i] = x;
				ans[i] = e[i][z].first+1;
			}
			z += y;
		}
	}
	f(i, n)printf("%d\n", ans[i]);


	return 0;
}


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

char s[201000];
int l,p1,p2,p3; long long ans;

struct Bit{
	int c[201000],t;
	int add(int x,int v){
		for (t+=v;x<=l;x+=x&-x) c[x]+=v;
	}
	int cal(int x){
		return x? c[x]+cal(x-=x&-x): 0;
	}
	int que(int y){
		int res=0;
		for (int i=18;~i;--i) if ((res|1<<i)<=l&&y>c[res|1<<i]){
			res|=1<<i, y-=c[res];
		}
		return res+1;
	}
}b[26],a;


int main(){
	cin>>s+1; l=strlen(s+1);
	for (int i=1;i<=l;++i) a.add(i,1), b[s[i]-='a'].add(i,1);
	for (int i=l;i>1;i-=2){
		p1=a.que(1), p2=a.que(a.t);
		if (b[s[p1]].t>1){
			p3=b[s[p1]].que(b[s[p1]].t);
			ans+=i-a.cal(p2=p3);
		}else{
			p3=b[s[p2]].que(1);
			ans+=a.cal(p1=p3)-1;
		}
		if (p1==p2) return 0*puts("-1");
		a.add(p1,-1), b[s[p1]].add(p1,-1);
		a.add(p2,-1), b[s[p2]].add(p2,-1);
	}
	cout<<ans;
}

Measured memory_bytes: 21632
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>
#include <set>
#include <iomanip>
using namespace std;
 
 
int main(){
    long long N;
    vector<char> A;
    char c;
    cin >> N;
    while (true){
        N = N - 1;
        c = 'a' + (N % 26);
        A.push_back(c);
        N = N / 26;
        if (N == 0){
            break;
        }
    }
    reverse(A.begin(), A.end());
    //for (auto x; A) cout << x;
    for (int i=0; i<A.size(); i++){
        cout << A[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3592
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <cassert>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <complex>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 500;

string S[MAX];

int main()
{
	//freopen("in.txt","r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n, m;
	cin>>n>>m;
	FOR (i, 0, n)
	{
		cin>>S[i];
	}

	FOR (it, 0, 2)
	{
		if (it == 0) cout<<string(m, '#')<<endl;
		else cout<<string(m, '.')<<endl;

		FOR (i, 1, n-1)
		{
			FOR (j, 0, m)
			{
				if (S[i][j] == '#') cout<<'#';
				else
				{
					cout<<"#."[(it ^ j) & 1];
				}
			}
			cout<<endl;
		}
		if (it == 1) cout<<string(m, '#')<<endl;
		else cout<<string(m, '.')<<endl;

		if (it == 0) cout<<endl;
	}


}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine().ToInt();
            var x = Console.ReadLine().Split(' ');
            var target = new List<int>();
            for (int i = 0; i < x.Length; i++)
            {
                target.Add(x[i].ToInt());
            }

            double minValue = double.MaxValue;
            for (int i = 0; i <= 100; i++)
            {
                double calcValue = 0;
                for (int j = 0; j < target.Count; j++)
                {
                    calcValue += Math.Pow(target[j] - i + 1, 2);
                }
                if (minValue > calcValue)
                {
                    minValue = calcValue;
                }
            }
            Console.WriteLine(minValue);
            Console.ReadLine();
        }


    }
}

public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll h,a;
  cin >> h >> a;
  pr((ll)ceil((double)h/a));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int x;
    cin >> x;
    if (x % 2 == 1 && x >= 3 && x <= 7) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
//g++  5.4.0
 
#include<bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define int long long
#define pb push_back
#define pii pair< int,int >
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
#define L(p) 2*p+1
#define R(p) 2*p+2

struct seg_tree
{
    vector<int> jt ;
    int n;
    seg_tree(int n) : n(n)
    {
        jt.resize( 4*n );
    }
    int fun( int a,int b )
    {
        return max(a,b); // whetever u want
    }
    void build(int l , int h , int p )
    {
        if(l == h)
        {
            cin >> jt[p];
            return;
        }
        int m = (l+h)>>1;
        build(l , m , L(p));
        build(m+1 , h , R(p));
        jt[p] = fun(jt[L(p)],jt[R(p)]);
        return;
    }
    void update(int l ,int h , int p, int q,int v) // point-update
    {
        if( l==h )
        {
            jt[p] = v;
            return ;
        }
        int m = (l + h )>> 1;
        if( m>=q ) update( l , m , L(p) ,q , v);
        else        update(m+1 , h , R(p) , q , v);
	
	    jt[p] = fun(jt[L(p)],jt[R(p)]);
	    return;
    }
    int query(int l,int h, int p, int ql ,int qh) // range_query
    {
        if(l > qh || h < ql)
            return 0;
        else if(l >= ql && h <= qh)
            return jt[p] ;
        int m = (l + h )>> 1;
        int p1 = query( l , m , L(p) ,ql ,qh);
        int p2 = query(m+1 , h , R(p) , ql ,qh);
        return fun(p1,p2);
    }
    void up( int p, int v)
    {
        update( 1,n,0,p,v );
        return ;
    }
    int qr( int ql,int qh )
    {
       return query( 1,n,0,ql,qh ); 
    }
};

signed main()
{
    fast;
    int n;
    cin >> n;
    seg_tree st(n);
    vector<int> h(n),a(n);
    for(int i=0;i<n;i++) cin>>h[i];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++)
    {
        int mx = st.qr( 1,h[i] );
        st.up( h[i] , a[i]+mx );
    }
    cout << st.qr(1,n) << "\n";
}


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

using namespace std;
using namespace __gnu_pbds;

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define F first
#define S second
#define FBO find_by_order
#define OOK order_of_key
#define MSET(m,v) memset((m),(v),sizeof(m))
#define UB(c,v) (upper_bound((c).begin(),(c).end(),(v)))
#define LB(c,v) (lower_bound((c).begin(),(c).end(),(v)))
#define INREP int TC;cin>>TC;while(TC--)
#define CPPIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PI 3.1415926535897932384626433832795028841971693993751
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);
}
#else
#define trace(...)
#endif

typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

// SOLUTION

int main () {
	CPPIO;
    ll a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c) cout << "Yes";
    else cout << "No";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static boolean solve(int d, int t, int s) {
		
		if(s * t >= d)
			return true;
		else 
			return false;
	}

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

		int d, t, s;
		d = stdIn.nextInt();
		t = stdIn.nextInt();
		s = stdIn.nextInt();
		boolean result = solve(d, t, s);
		if(result)
			System.out.println("Yes");
		else
			System.out.println("No");

		stdIn.close();
	}
}


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

using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;

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

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main() {
  ll n;
  cin >> n;
  ll g = 0;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    g = gcd(g, a);
  }
  cout << g << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include <vector>
#include<cmath>
#include<iomanip>
#include<queue>
using namespace std;
typedef long long int lint;
int main() {
	int N, M;
	cin >> N >> M;
	vector<int>vec(2 * M);
	for (int ia = 0; ia < 2 * M; ia++) {
		cin >> vec.at(ia);
	}
	vector<int>veca(N);
	for (int ib = 0; ib < 2 * M; ib++) {
		for (int ic = 1; ic <= N; ic++) {
			if (vec.at(ib) == ic) {
				veca.at(ic-1)++;
			}
		}
	}
	for (int id = 0; id < N; id++) {
		cout << veca.at(id) << endl;
	}
}



	


Measured memory_bytes: 256
def main():
    n = int(input())
    monsters = list(map(int,input().split()))
    heroes = list(map(int,input().split()))
    total = 0
    
    for i in range(n):
        if heroes[i] >= monsters[i]:
            total += monsters[i]
            heroes[i] -= monsters[i]
        else:
            total += heroes[i]
            heroes[i] = 0

        if heroes[i] >= monsters[i+1]:
            total += monsters[i+1]
            heroes[i] -= monsters[i+1]
            monsters[i+1] = 0
        else:
            total += heroes[i]
            monsters[i+1] -= heroes[i]
            heroes[i] = 0

    print(total)

main()


Measured memory_bytes: 19004
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
//#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 505;
const int K = 20;
int s, k, fx, fy, x, y;
void finish(vector < pair < int, int > > ans){
    int px = 0;
    int py = 0;
    for (auto i: ans){
        if (s){
            if (abs(i.S * fy - px) + abs(i.F * fx - py) != k) cout << "BAD" << endl;
            px = i.S * fy;
            py = i.F * fx;
        } else{
            if (abs(i.S * fy - py) + abs(i.F * fx - px) != k) cout << "BAD" << endl;
            py = i.S * fy;
            px = i.F * fx;
        }
    }
    cout << ans.size() << endl;
    for (auto i: ans){
        if (s){
            cout << i.S * fy << " " << i.F * fx << endl;
        } else{
            cout << i.F * fx << " " << i.S * fy << endl;
        }
    }
    exit(0);
}
void go(int sx, int sy, int fx, int fy, int d){
    vector < pair < int, int > > ans;
    if (d) ans.pb({sx, sy});
    if (abs(sx - fx) + abs(sy - fy) == k){
        ans.pb({fx, fy});
        finish(ans);
    }
    while(sx + k <= fx){
        sx += k;
        ans.pb({sx, sy});
    }
    if (sx != fx){
        int d = fx - sx;
        sx += d;
        sy += k - d;
        ans.pb({sx, sy});
    }
    while(sy + k <= fy){
        sy += k;
        ans.pb({sx, sy});
    }
    if (fy == sy){
        finish(ans);
    }
    if ((fy - sy) % 2 == 0){
        int z = (fy - sy) / 2;
        ans.pb({sx + k - abs(z), sy + z});
        ans.pb({fx, fy});
        finish(ans);
    }
    sy += k;
    ans.pb({sx, sy});
    int z = (sy - fy) / 2;
    ans.pb({sx + k - z, sy - z});
    ans.pb({fx, fy});
    finish(ans);
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    vector < pair < int, int > > ans;
    cin >> k;
    cin >> x >> y;
    if (x < 0){
        fx = -1;
        x = -x;
    } else{
        fx = 1;
        x = x;
    }
    if (y < 0){
        fy = -1;
        y = -y;
    } else{
        fy = 1;
        y = y;
    }
    if (x > y){
        s = 1;
        swap(x, y);
        swap(fx, fy);
    }
    if (k % 2 == 0 && (x + y) % 2){
        cout << -1;
        return 0;
    }
    if ((x + y) % k == 0) go(0, 0, x, y, 0);
    if (x + y < k && ((k % 2 && (x + y) % 2 == 0) || k % 2 == 0)){
        vector < pair < int, int > > ans;
        ans.pb({-(k - (x + y) / 2), (x + y) / 2});
        ans.pb({x, y});
        finish(ans);
    }
    if (x + y < k) go(0, 0, x, y, 0);
    int z = (x + y) / k + 1;
    int d = z * k - x - y;
    if (d % 2 == 0){
        go(-d / 2, k - (d / 2), x, y, 1);
    } else go(0, 0, x, y, 0);
}


Measured memory_bytes: 5488
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main() {
  int n;
  string str;
  getline(cin, str);
  n = atoi(str.c_str());

  for (int i = 0; i < n; ++i) {
    string str;
    getline(cin, str);

    int pos = -1;
    while (pos = str.find("Hoshino", pos + 1), pos != string::npos)
      str.replace(pos, 7, "Hoshina");
    cout << str << endl;
  }
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define at(a, b) get<b>(a)
typedef pair<int, int> PR;
typedef tuple<int, int, int> TP;
const int INF = 1 << 28;

int N, M, L, K, A, H;
vector<PR> g[100];
int dist[100][101];
bool ice[100];

void addEdge(int a, int b, int t)
{
	g[a].push_back(PR(b, t));
	g[b].push_back(PR(a, t));
}

void solve()
{
	fill_n(*dist, 100 * 101, INF);
	dist[A][M] = 0;
	priority_queue<TP, vector<TP>, greater<TP>> pq;
	pq.push(TP(0, A, M));
	while (pq.size()){
		TP t = pq.top(); pq.pop();
		int sum = at(t, 0);
		int pos = at(t, 1);
		int s = at(t, 2);
		if (dist[pos][s] < sum) continue;
		for (int i = 0; i < g[pos].size(); i++){
			int to = g[pos][i].first;
			int cost = g[pos][i].second;
			int ns = s - cost;
			if (ns < 0) continue;
			if (dist[to][ns] <= sum + cost) continue;
			dist[to][ns] = sum + cost;
			pq.push(TP(sum + cost, to, ns));
		}
		if (!ice[pos]) continue;
		for (int i = 1, ns; (ns = s + i) <= M; i++){
			if (dist[pos][ns] <= sum + i) continue;
			dist[pos][ns] = sum + i;
			pq.push(TP(sum + i, pos, ns));
		}
	}
	int res = INF;
	for (int i = 0; i <= M; i++){
		res = min(res, dist[H][i]);
	}
	if (res == INF) puts("Help!");
	else printf("%d\n", res);
}

int main()
{
	while (scanf("%d %d %d %d %d %d", &N, &M, &L, &K, &A, &H), N){
		fill_n(g, 100, vector<PR>());
		fill_n(ice, 100, false);
		ice[A] = ice[H] = true;
		for (int i = 0; i < L; i++){
			int a;
			scanf("%d", &a);
			ice[a] = true;
		}
		for (int i = 0; i < K; i++){
			int x, y, t;
			scanf("%d %d %d", &x, &y, &t);
			addEdge(x, y, t);
		}
		solve();
	}
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int a, b, h; cin >> a >> b >> h;
  cout << (a + b) * h / 2 << endl;
}


Measured memory_bytes: 256
/*Bismillahir Rahmanir Rahim*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,j,s=0;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> j;
        s = __gcd(s, j);
    }
    cout << s << endl;
}


Measured memory_bytes: 256
a = 2, 3, 5
 
def f(n):
  m = memo.get(n)
  if m is None:
    m = d * n
    for p, c in zip(a, b):
      k, r = divmod(n, p);
      m = min(m, f(k) + r * d + c, r  and f(k + 1) + (p - r) * d + c or m)
    memo[n] = m
  return m
 
t = int(input())
for _ in range(t):
  n, *b, d = map(int, input().split())
  memo = {0: 0, 1: d}
  print(f(n))


Measured memory_bytes: 10928
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 
int main()
{
    long N;
    std::cin >> N;
    long A[200000]={};
    for(long i=0; i<N; i++){
        std::cin >> A[i];
    }
    long B[200000]={};
    for(long i=0; i<N; i++){
        B[A[i]-1]++;
    }

    long sum=0;
    for(long i=0; i<N; i++){
        sum+=B[i]*(B[i]-1)/2;
    }

    for(long i=0; i<N; i++){
        if(B[A[i]-1]>0){
            std::cout << sum-(B[A[i]-1]*(B[A[i]-1]-1)/2)+(B[A[i]-1]-1)*(B[A[i]-1]-2)/2 << std::endl;
        }else{
            std::cout << sum << std::endl;
        }
    }
    return 0;
}

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

int main(){

int N;
cin >> N;

// vector<string> S(N);
// vector<int> P(N);
// for(int i = 0; i < N; i++){ 
//       cin >> S.at(i) >. P.at(i);
// }

// for(int i = 1; i <= N; i++){ 
//       for(int j = 0; j < N; j++){ 
//             if(S.at(i) > S.at(j)) break;
//             else if(S.at(i) == S.at(j) && P.at(i) < P.at(j)) break;
          
//            if(j == N -1){
//                 cout << i << endl;
//                 S.at(i) = "ZZZZZZZZZZZ";

//       }
// }


vector<tuple<string, int, int>> guide;

for(int i = 1; i <= N; i++){ 
      string S;
      int P;
      cin >> S >> P;
  		P = -P;
      guide.emplace_back(S, P, i);
}

sort(begin(guide), end(guide));

for(int i = 0; i < N; i++){ 
     cout << get<2>(guide.at(i)) << endl;
}


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll k;
    cin >> k;
    ll n = 50;
    vector<ll> ans(n, n-1+(k/n));
    k %= n;
    rep(i, k) {
        rep(j, n) {
            if (i==j) ans[j] += n;
            else ans[j] -= 1LL;
        }
    }
    cout << n << endl;
    rep(i, n) cout << ans[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

signed main(void) {
	int n;
	cin >> n;
	vector<pair<int, int>>ab(n);
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		ab[i] = make_pair(a, b);
	}
	sort(ab.begin(),ab.end(), compare_by_b);
	int time = 0;
	rep(i, n) {
		int a = ab[i].first;
		int b = ab[i].second;
		time += a;
		if (time > b) {
			print("No");
			return 0;
		}
	}
	print("Yes");
}

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

using namespace std;

string c;

int main()
{
	cin >> c;
	if (c == "SUN")
		cout << 7;
	else if (c == "MON")
		cout << 6;
	else if (c == "TUE")
		cout << 5;
	else if (c == "WED")
		cout << 4;
	else if (c == "THU")
		cout << 3;
	else if (c == "FRI")
		cout << 2;
	else
		cout << 1;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int n,m,x,y,i,j,c,s;
        scanf("%d%d%d%d",&n,&m,&x,&y);
        int a[n],b[m];
        for(i=0;i<n;i++)
                scanf("%d",&a[i]);
        for(i=0;i<m;i++)
                scanf("%d",&b[i]);

        for(i=x+1;i<=y;i++){
                c=0;s=0;
                for(j=0;j<n;j++)
                        if(a[j]<i)c++;
                for(j=0;j<m;j++)
                        if(b[j]>=i)s++;
                if(c==n && s==m){
                        printf("No War\n");
                        return 0;
                }
        }
        printf("War\n");
        return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const Y_MAX = 20000000;

int N;
ll Y;

int main() {
  scanf("%d %lld", &N, &Y);

  rep(i, N + 1) {
    rep(j, N - i + 1) {
      int k = N - i - j;

      if (i * 10000 + j * 5000 + k * 1000 == Y) {
        printf("%d %d %d\n", i, j, k);
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
}


Measured memory_bytes: 256
from collections import Counter
n,k,q = map(int,input().split())
if k>q:
  [print("Yes") for i in range(n)]
  exit()
  
a = [int(input()) for i in range(q)]
A = Counter(a)

ans = ['No']*n
for i in A:
    if k-q+A[i] > 0:
        ans[i-1] = 'Yes'
        
for i in ans:
    print(i)

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

int main() {
  int x , y;
  cin >> x >> y;
  
	vector<string> sample(x);	//サンプル文字を入れるための配列を作成
  
  for(int i = 0; i < x; i++)
  {
    cin >> sample.at(i);	//サンプル文字を配列に入れる
  }
  

  
  for(int i = 0; i < y+2; i++)
  {
    cout << "#";		//1行目の表示
  }
  cout << endl;
  
  for(int i = 0; i < x; i++)
  {
    cout << "#" << sample.at(i) << "#" << endl;	//2行目～の処理
  }
  
    for(int i = 0; i < y+2; i++)
  {
    cout << "#";		//最後の行の表示
  }
  cout << endl; 

}

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

int main()
{

	int n;
	//4棟 , 3階 , 10部屋
	int uni_room[4][3][10];
	for (int b = 0; b < 4; b++)
	{
		for (int f = 0; f < 3; f++)
		{
			for (int r = 0; r < 10; r++)
			{
				uni_room[b][f][r] = 0;
			}
		}
	}
	cin >> n;
	int b, f, r, v;
	for (int i = 0; i < n; i++)
	{
		cin >> b >> f >> r >> v;

		uni_room[b-1][f-1][r-1] += v;

	}

	for (int b = 0; b < 4; b++)
	{
		for (int f = 0; f < 3; f++)
		{
			for (int r = 0; r < 10; r++)
			{
				cout << " " << uni_room[b][f][r];
			}
			cout << endl;
		}
		if (b < 3)
		{
			for (int i = 0; i < 20; i++)
			{
				cout << "#";
			}
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3092
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X;
    for (int i = 0; i < N; i++) {
        vector<int> coor(D, 0);
        for (int j = 0; j < D; j++) {
            cin >> coor[j];
        }
        X.push_back(coor);
    }

    int ans = 0;
    for (int i = 0; i <= N-2; i++) {
        for (int j = i+1; j <= N-1; j++) {
            int temp = 0;
            for (int d = 0; d < D; d++)
                temp += pow(X[i][d] - X[j][d], 2);

            float f = sqrt(temp);
            if (temp == pow(f, 2)) {
                ans++;
            }
        }
    }

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


Measured memory_bytes: 256
from sys import stdin
from itertools import accumulate

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

lin = list(accumulate(li))
su = sum(li)
mi = 10**10

for i in range(n-1):
    mi = min(mi,abs(su-lin[i]*2))
print(mi)

Measured memory_bytes: 24172
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  ll a;
  double b;
  cin >> a >> b;
  cout << (a * (ll)(b * 100 + 0.5)) / 100 << endl;
  return 0;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int a,b,c,temp;
    cin>>a>>b;
    c=10;
    temp=log10(b)+1;
    for(int i=0;i<temp;i++)
    {
        a*=c;
    }
    a+=b;
   // cout<<a<<endl;
    temp=sqrt(a);
    if(temp*temp==a)
    {
       cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
//main();
}


Measured memory_bytes: 512
def cmb(n, r, mod):#コンビネーションの高速計算　
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N=int(input())

res=0
W=0
for k in range((N-1)//2+1,N):
    res+=(g1[N-1-k]*g1[k]*cmb(k-1,N-k-1,mod)-W)*k
    res%=mod
    W=cmb(k-1,N-k-1,mod)*g1[k]*g1[N-1-k]

print(res)


Measured memory_bytes: 127560
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int H, W;
    cin >> H >> W;

    if (H == 1 || W == 1) ans = 1;
    else {
        ans = (H*W+1)/2;
    }
    cout << ans << endl;
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/panasonic2020/panasonic2020_b && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/panasonic2020/panasonic2020_b && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/panasonic2020/panasonic2020_b && sh shellscripts/submit_cpp.sh
*/


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

const long long INF = 1LL << 60;

long long dp[100000];
long long  h[100000];

int rec(int N)
{
    if(dp[N] < INF)
        return dp[N];
    
    if(N == 0) //終了
        return 0;

    long long ans = INF;

    ans = min(ans,rec(N - 1) + abs(h[N] - h[N - 1]));
    if(N > 1)
        ans = min(ans,rec(N - 2) + abs(h[N] - h[N - 2]));
    
    dp[N] = ans;
    return ans;
}

int main()
{
    int N;
    cin >> N;
    for(int i = 0; i < N; ++i)
    {
        cin >> h[i];
        dp[i] = INF; 
    }
    cout << rec(N - 1) <<endl;
}

Measured memory_bytes: 4992
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
		for(int i = 0 ; i < N ; ++i){
			int ai = sc.nextInt();
			pq.add(- ai);
		}
		for(int i = 0 ; i < M ; ++i){
			int top = pq.poll();
			int discount = top / 2;
			pq.add(discount);
		}
		long S = 0;
		while(!pq.isEmpty()){
			int top = pq.poll();
			S += top;
		}
		System.out.println(-S);
	}
}


Measured memory_bytes: 60916
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	int sz; cin >> sz;
	string s, t; cin >> s >> t;
	for( int i = 0; i < sz; ++i ){
		cout << s[i] << t[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int ze(int a, int b) {
  int t = a - b;
  if(t < 0) return -t;
  return t;
}
int main () {
  int N;
  cin >> N;
  int we[102];
  int pre = 0;
  int aft = 0;
  for (int i = 0; i < N; i ++) {
    cin >> we[i];
    pre += we[i];
  }
  int ans = pre;
  for (int i = 0; i < N; i ++) {
    pre -= we[i];
    aft += we[i];
    int t = ze(pre, aft);
    if (ans > t) ans = t;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
current =0
cost =[]
a.append(0)
for i in range(n):
    cost.append(abs(a[i]-current))
    current=a[i]
cost.append(abs(current))
costTotal = sum(cost)
current =0
for i in range(n):
    print(costTotal-cost[i]-cost[i+1]+abs(a[i+1]-current))
    current=a[i]


Measured memory_bytes: 14044