akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef double ld;

ll n;
ll a[110];
ll ans;

int main(void)
{
	scanf("%lld", &n);
	
	for(ll i = 0 ; i < n ; i++)
	{
		scanf("%lld", &a[i]);
		
		if(i % 2 == 0 && a[i] % 2 == 1)
			ans++;
	}
	
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 3812
import java.util.Scanner;

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

	/* 入力 */
	int n = scan.nextInt();
	int[] t = new int[n];
	for(int i = 0; i < n; i++){
	    t[i] = scan.nextInt();
	}
	int m = scan.nextInt();
	int[] p = new int[m];
	int[] x = new int[m];
	for(int i = 0; i < m; i++){
	    p[i] = scan.nextInt();
	    x[i] = scan.nextInt();
	}

	/* 合計時間を求める */
	int sum = 0;
	for(int i = 0; i < n; i++){
	    sum += t[i];
	}

	/* 出力 */
	for(int i = 0; i < m; i++){
	    System.out.println(sum-(t[p[i]-1]-x[i]));
	}
    }
}


Measured memory_bytes: 23124
main = do
    [a,b,h,m] <- map read <$> (words <$> getLine) :: IO [Double ]
    let angle = abs $ (h * 30) - (m * 6) + (0.5 * m)
    print $ sqrt ((a^2) + (b^2) - (2 * a * b * cos(angle * pi / 180.0)))

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

using namespace std;
int main(){
  int n;
   cin >>n;
  
  if(n<100) cout << min(n,9) << endl;
  else if(100<=n&& n<10000) cout << 9+min(n-99,900) << endl;
  else cout << 909+min(n-9999,90000) << endl;
 
  
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int N;
    cin >> N;
    double en = N / 2;
    printf("%.10f\n", 1.0 - en / (double)N);
    return 0;
}


Measured memory_bytes: 256
object Main{
  def main(args: Array[String]){
    if (sys.env.getOrElse("TEST", "")=="1"){

    }else{
      val input=io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim());
    }
  }


  def solve(input:String):String ={
    val nums = input.split("\n").map(_ .toInt)
    val limitRange = nums.last
    val aa = nums.dropRight(1)
	val ret= if ((aa.max - aa.min) <= limitRange){
    	"Yay!"
    } else {
      ":("
    }
    ret
  }
}

Measured memory_bytes: 27224
S = str(input())
front = int(S[:2])
back = int(S[2:])

if front > 12 or front == 0:
    if 0 < back <= 12 :
        print("YYMM")
    else:
        print("NA")
elif front <= 12 or front == 0:
    if 0 < back <= 12: 
        print("AMBIGUOUS")
    else:
        print("MMYY")

Measured memory_bytes: 9052
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.regex.Pattern;

public class Main {
    public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        long[] line = Pattern.compile(" ").splitAsStream(stdin.readLine()).mapToLong(Long::parseLong).toArray();
        long q = line[0] * 4; // 1L
        long h = line[1] * 2; // 1L
        long s = line[2];     // 1L
        long d = line[3];     // 2L
        long n = Long.parseLong(stdin.readLine());

        long min = Math.min(q, Math.min(h, s));
        long p1 = n * min;
        long p2 = (n / 2) * d + (n % 2) * min;
        long p = Math.min(p1, p2);
        stdout.println(p);
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }
}

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

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);

    int k;
    string s;
    cin >> k >> s;

    if(s.size() <= k) cout << s << endl;
    else {
        string t = "";

        for(int i = 0; i < k; i++) {
            t += s[i];
        }

        cout << t + "..." << endl;
    }
}


Measured memory_bytes: 3660
#include <iostream>
#define N 10000
using namespace std;
int a[10005];
int main()
{
    for(int i=1; i*i<=N+5; i++)
        for(int j=1; j*j<=N+5; j++)
            for(int k=1; k*k<N+5; k++)
            {
                if(i*i+j*j+k*k+i*j+j*k+k*i<N+5)
                    a[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
    int n;
    cin>>n;
    {
        for(int i=1; i<=n; i++)
            cout<<a[i]<<endl;
    }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const ll INF = 1e17;
const int MAX_V = 302;

vector<vector<ll>> d(MAX_V, vector<ll>(MAX_V,INF));
vector<vector<ll>> s(MAX_V, vector<ll>(MAX_V,INF));
int V;

void warshall_floyd1(){
  rep(k,V+1){
    rep(i,V+1){
      rep(j,V+1) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
  }
}

void warshall_floyd2(){
  rep(k,V+1){
    rep(i,V+1){
      rep(j,V+1) s[i][j] = min(s[i][j], s[i][k] + s[k][j]);
    }
  }
}

int main(){
  int m; ll l;
  cin >> V >> m >> l;
  rep(i,m) {
    int a, b; ll c;
    cin >> a >> b >> c;
    if(c <= l){
      d[a][b] = c;
      d[b][a] = c;
    }
  }
  warshall_floyd1();
  rep(i,V+1) {
    rep(j,V+1) {
      if(d[i][j] <= l) s[i][j] = 1;
    }
  }
  warshall_floyd2();
  int q;
  cin >> q;
  int ans[q];
  rep(i,q) {
    int x, y;
    cin >> x >> y;
    if(s[x][y] == INF) ans[i] = -1;
    else ans[i] = s[x][y]-1;
  }
  for(auto k : ans) cout << k << endl;
  return 0;
}

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

int n, a, b, c, d; char s[1005];
int main () {
	scanf("%s", s), n = strlen(s);
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'N') ++a; else
		if (s[i] == 'S') ++b; else
		if (s[i] == 'W') ++c; else
		if (s[i] == 'E') ++d;
	}
	if (a && b && !c && !d || !a && !b && c && d || a && b && c && d) puts("Yes"); else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
  int k;
  cin >> k;
  vector<ll> a;
  for (int i = 1; i <= 9; i++) a.push_back(i);
  while (true) {
    if (k <= a.size()) {
      cout << a[k-1] << endl;
      return 0;
    }
    k -= a.size();
    vector<ll> old;
    swap(old, a);
    for (ll x : old) {
      for (int i = -1; i <= 1; i++) {
        int d = x%10 + i;
        if (d < 0 || d > 9) continue;
        ll nx = x*10 +d;
        a.push_back(nx);
      }
    }
  }
}

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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};




int a,b,c;

signed main(){
    cin>>a>>b>>c;
    
    if(a%2||b%2||c%2){
            cout<<'0'<<endl;
            return 0;
        }
    rep(i,0,100010){
        
        int x=a,y=b,z=c;
        a=(y+z)/2;
        b=(x+z)/2;
        c=(x+y)/2;
        if(a%2||b%2||c%2){
            cout<<i+1<<endl;
            return 0;
        }
    }
    puts("-1");
    
    
    
    
    
    
    
    return 0;
}

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

int N, M;

bool vis[1001][1001];
int dist[1001][1001];

typedef pair<int, int> point;
#define x first
#define y second

inline bool ok(int u, int v){
    return 0 <= u && u < N && 0 <= v && v < M;
}

queue<point> Q;

int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, 1, -1};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> N >> M;
    for (int i=0; i<N; i++){
        for (int j=0; j<M; j++){
            char c;
            cin >> c;
            if (c == '#'){
                Q.push({i, j});
                vis[i][j] = true;
            }
        }
    }
    int ans = 0;
    while (Q.size()){
        int i, j;
        i = Q.front().x, j = Q.front().y;
        Q.pop();
        ans = max(ans, dist[i][j]);
        for (int d=0; d<4; d++){
            int u = i+dx[d];
            int v = j+dy[d];
            if (!ok(u, v)) continue;
            if (!vis[u][v]){
                vis[u][v] = true;
                Q.push({u, v});
                dist[u][v] = dist[i][j] + 1;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 11280
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

int H, W, K;
vector<string>A;
vector<vector<int>>field;
int sx, sy;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 };
auto within = [&](int x, int y) {
	return 0 <= x&&x < H && 0 <= y&&y < W;
};
struct point {
	int x, y, v;
	point(int a, int b, int c) :x(a), y(b), v(c) {};
	bool operator<(const point &other) const {
		return v < other.v;
	}
	bool operator>(const point &other) {
		return v > other.v;
	}
};
void bfs(int x = sx, int y = sy, int c = K + 1) {
	priority_queue<point>pq;
	pq.push(point(x, y, c));
	while (!pq.empty()) {
		auto u = pq.top(); pq.pop();
		if (field[u.x][u.y] != -1)continue;
		field[u.x][u.y] = u.v;
		rep(i, 0, 4) {
			int a = u.x + dx[i], b = u.y + dy[i];
			if (within(a, b) && A[a][b] == '.')pq.push(point(a, b, u.v - 1));
		}
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> H >> W >> K;
	A = vector<string>(H);
	field = vector<vector<int>>(H, vector<int>(W, -1));

	rep(i, 0, H)cin >> A[i];
	rep(i, 0, H)rep(j, 0, W)if (A[i][j] == 'S') {
		A[i][j] = '.';
		sx = i; sy = j; break;
	}
	dump(sx, sy);

	bfs();

	int m(INF);
	rep(i, 0, H)rep(j, 0, W) {
		//cout << field[i][j] << (j == W - 1 ? '\n' : ' ');
		if (field[i][j] > 0) {
			int l = min(i, j);
			int r = min(H - 1 - i, W - 1 - j);
			chmin(m, min(l, r));
		}
	}
	dump(m);

	cout << 1 + (m + K - 1) / K << endl;
	//int ans(1);

	//while (m) {
	//	dump(m);
	//	m = max(0, m - K);
	//	ans++;
	//}
	//cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3712
def main():
    N = int(input())
    a = list(map(int,input().split()))
    allxor = a[0]
    for i in range(N):
        if i == 0:
            continue

        allxor = allxor ^ a[i]

    ans = [0]*N
    for i in range(N):
        ans[i] = allxor ^ a[i]

    return(ans)

ans = main()
ans = map(str,ans)
print(' '.join(ans))


Measured memory_bytes: 31880
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>0){
		printf("Positive\n");
	}
	else if(b<0 && (b-a+1)%2==0){
    	printf("Positive\n");
	}
    else if(b<0 && (b-a+1)%2==1){
   		printf("Negative\n");
	}
   	else{
   		printf("Zero\n");
    }
	return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		int q=scanner.nextInt();
		String s=scanner.next();
		int[] l=new int[q];
		int[] r=new int[q];
		for(int i=0;i<q;i++) {
			l[i]=scanner.nextInt()-1;
			r[i]=scanner.nextInt()-1;
		}
		int[] p=new int[s.length()];
		char pre=s.charAt(0);
		for(int i=1;i<s.length();i++) {
			char now=s.charAt(i);
			if(pre=='A'&&now=='C') {
				p[i]=1;
			}
			pre=now;
		}
		for(int i=1;i<s.length();i++) {
			p[i]+=p[i-1];
		}
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<q;i++) {
			if(l[i]==0) {
				int ans=p[r[i]];
				sb.append(ans+"\n");
				continue;
			}
			int ans=p[r[i]]-p[l[i]];
			sb.append(ans+"\n");
		}
		System.out.println(sb);
	}
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 44632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

template<typename T>
struct is_vector : false_type{};

template<typename T>
struct is_vector<vector<T>> : true_type{};

template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

void solve() {
  int n, a, b, c; cin >> n >> a >> b >> c;
  vi target = {a, b, c};
  vi arr(n);
  rep(i,n) cin >> arr[i];

  vi perm(n);
  rep(i,n) perm[i] = i;

  int ans = 1e4;

  do {
    for (int i=2; i<n; ++i) {
      Graph G(3);
      for (int k=i; k<n; ++k) G[0].push_back(arr[perm[k]]);

      for (int j=1; j<i; ++j) {
        G[1].clear(); G[2].clear();
        for (int k=j; k<i; ++k) G[1].push_back(arr[perm[k]]);
        for (int k=0; k<j; ++k) G[2].push_back(arr[perm[k]]);

        vi mp(3, 1e4);
        rep(k,3) {
          rep1(tmp,(1<<G[k].size())-1) {
            bitset<8> s(tmp);
            int p = 0;
            p += 10 * (s.count() - 1);
            int sz = 0;
            rep(l,G[k].size()) if (s[l]) sz += G[k][l];
            p += abs(target[k] - sz);

            mp[k] = min(mp[k], p);
          }
        }

        ans = min(ans, accumulate(ALL(mp), 0));
      }
    }
  } while (next_permutation(ALL(perm)));

  cout << ans << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
using namespace std;
#pragma endregion
signed main() {
	int X,A,B;
	cin >> X >> A >> B;
	cout << (X-A)%B;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    
    vector<int> v(n, 0);
    rep(i, n){
        if(t[i] == 'r'){
            v[i] = p;
        }else if(t[i] == 's'){
            v[i] = r;
        }else if(t[i] == 'p'){
            v[i] = s;
        }

        if(i - k >= 0 && t[i-k] == t[i] && v[i-k] != 0){
            v[i] = 0;
        }
    }

    ll ans = 0;
    rep(i, n){
        ans += v[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 848
import sys 
input = sys.stdin.readline

n, m, Q = map(int,input().split())
lr = [[0 for i in range(n+1)] for j in range(n+1)]
for i in range(m):
    l,r = map(int,input().split())
    lr[l][r] += 1

# 二次元累積和(indexに注意)
s = [[0 for i in range(n+1)] for j in range(n+1)]
# s[x][y]:=[0,x-1]×[0,y-1]の長方形区間の総和
for i in range(n):
    for j in range(n):
        s[i+1][j+1] = s[i+1][j] + s[i][j+1] -s[i][j] + lr[i+1][j+1]

for i in range(Q):
    p,q = map(int,input().split())
    ans = s[q][q] - s[q][p-1] - s[p-1][q] + s[p-1][p-1] 
    print(ans)

# 72


Measured memory_bytes: 15784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const ll mod=1e9+7;
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll res=pow(x,y/2);
  res*=res;
  res%=mod;
  if(y%2==1) res*=x;
  return res%mod;
}
ll gyaku(ll x){return pow(x,mod-2);}
vector<ll> frac,gfrac;
void set_frac(ll n){
  frac.push_back(1);
  gfrac.push_back(1);
  for(ll i=1;i<=n;i++){
    frac.push_back(frac[i-1]*i%mod);
    gfrac.push_back(gyaku(frac[i]));
  }
}
ll nCr(ll n,ll r){
  ll res=frac[n]*gfrac[r]%mod;
  res*=gfrac[n-r];
  return res%mod;
}
signed main(){
  ll h,w,a,b;
  cin>>h>>w>>a>>b;
  ll x=b,y=h-a-1;
  ll ans=0;
  set_frac(300005);
  while(x<w&&y>=0){
    ll kans=nCr(x+y,x)*nCr(h+w-x-y-2,w-x-1);
    kans%=mod;
    ans+=kans;
    ans%=mod;
    x++;
    y--;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 10464
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define MOD 1e9 + 7
#define pb push_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)
#define repi(i, a, b) for (ll i = ll(a); i < ll(b); ++i)
#define all(x) (x).begin(), (x).end()

void Main()
{
    string n;
    cin >> n;
    vector<string> list = {"pon",
                           "pon",
                           "hon",
                           "bon",
                           "hon",
                           "hon",
                           "pon",
                           "hon",
                           "pon",
                           "hon"};
    cout << list[((int)n[n.size() - 1] - 48)] << endl;
    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3680
#include <cstdio>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

char buf[30000+10];

int main(void) {
  int n;
  cin >> n >> buf;
  char d[3];
  int res = 0;
  for(d[0] = '0'; d[0] <= '9'; ++d[0]) {
    for(d[1] = '0'; d[1] <= '9'; ++d[1]) {
      for(d[2] = '0'; d[2] <= '9'; ++d[2]) {
        int x = 0;
        REP(i, n) {
          if(buf[i] == d[x]) {
            ++x;
            if(x == 3) {
              ++res;
              break;
            }
          }
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3220
// Believe in yourself
#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Pair vector<pair<ll,ll>>
#define vec vector <ll> 
#define all(a) a.begin(),a.end()
#define mo 1000000007
#define decimal(i,n) fixed << setprecision(i) << n
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define show_nl(a) for(auto xyz:a)cout<<xyz<<endl;


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

/*
Enter the test case


Some helpful points
1.) Calm yourself
2.) check for semicolon or data type mismatch
*/


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);    
    ll t=1;
    // cin>>t;
    while(t--)
    {
      ll n,k;
      cin>>n>>k;
      ll a[n],s=0;
      for(ll i=0;i<n;i++)
      {
         cin>>a[i];
         s=s+a[i];
      }
      sort(a,a+n);
      for(ll i=n-1;i>n-1-k && i>=0;i--)
      {
        s=s-a[i];
      }
      cout<<s<<"\n";
    }
}



Measured memory_bytes: 5188
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <bits/stdc++.h>
using namespace std;

int main()
{
    string S;
    cin >> S;
    if ( S == "Sunny" ) {
        cout << "Cloudy" << endl;
    }else if ( S == "Cloudy" ){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
 
    int H,W,i,j;
 
    while(1){
        scanf("%d", &H);
        scanf("%d", &W);
      
         if(H==0 && W==0){
             break;
         }
          
        for ( i = 0; i < H; i++ ){
            for ( j = 0; j < W; j++ ){
                
                    if( (i+j) %2 == 0){
                        printf("#");
                    }else{
                        printf(".");
                    }

                
            }
            printf("\n");
        }
    printf("\n");
    }
    return 0;
}


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

int main(){
    int N; cin >> N;
    vector <int> A(N);
    vector <int> B(N);
    rep(i,N) cin >> A[i];//宝石の価値
    rep(i,N) cin >> B[i];//宝石の値段
    
    int ans=0;
    rep(i,N){
        if(A[i]>B[i]) ans+=A[i]-B[i]; 
    }
    cout << ans;
    
    
}

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

int main(){

  string s1 = ".,!? ";
  string s2 = "abc";
  string s3 = "def";
  string s4 = "ghi";
  string s5 = "jkl";
  string s6 = "mno";
  string s7 = "pqrs";
  string s8 = "tuv";
  string s9 = "wxyz";
  string num;
  int n;
  cin >> n;
  while(n--){
    cin >> num;
    string ans = "";
    int len = num.size();
    int t1, t2, t3, t4, t5, t6 ,t7, t8, t9;
    t1 = t2 = t3 = t4 = t5 = t6 = t7 = t8 = t9 = 0;
    for(int i = 0; i < len; i++){
      if(num[i] == '0'){
        if(t1 > 0) ans += s1[(t1-1)%5];
        if(t2 > 0) ans += s2[(t2-1)%3];
        if(t3 > 0) ans += s3[(t3-1)%3];
        if(t4 > 0) ans += s4[(t4-1)%3];
        if(t5 > 0) ans += s5[(t5-1)%3];
        if(t6 > 0) ans += s6[(t6-1)%3];
        if(t7 > 0) ans += s7[(t7-1)%4];
        if(t8 > 0) ans += s8[(t8-1)%3];
        if(t9 > 0) ans += s9[(t9-1)%4];
        t1 = t2 = t3 = t4 = t5 = t6 = t7 = t8 = t9 = 0;
      }else{
        if(num[i] == '1') t1++;
        if(num[i] == '2') t2++;
        if(num[i] == '3') t3++;
        if(num[i] == '4') t4++;
        if(num[i] == '5') t5++;
        if(num[i] == '6') t6++;
        if(num[i] == '7') t7++;
        if(num[i] == '8') t8++;
        if(num[i] == '9') t9++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3008
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int h, w;

void view(bool list[501][501]){
	for(int y = 0;y < h;y++){
		for(int x = 0;x < w;x++){
			if(list[x][y]){
				cout << "#";
			}else{
				cout << ".";
			}
		}
		cout << endl;
	}
}


int main() {
	bool red[501][501] = {};
	bool blue[501][501] = {};

	bool ans[501][501] = {};
	cin >> h >> w;
	string str;
	for(int i = 0;i < h;i++){
		cin >> str;
		for(int j = 0;j < str.size();j++){
			if(str[j] == '#') ans[j][i] = true;
		}
	}

	for(int y = 0;y < h;y++){
		for(int x = 0;x < w;x++){
			if(y % 2 == 0){
				if(x != w - 1){
					red[x][y] = true;
				}else{
					blue[x][y] = true;
				}
			}else{
				if(x == 0){
					red[x][y] = true;
				}else{
					blue[x][y] = true;
				}
			}

			if(ans[x][y]){
				blue[x][y] = true;
				red[x][y] = true;
			}
		}
	}

	view(red);
	view(blue);

	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  bool f=true;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]%2==0&&a[i]%3!=0&&a[i]%5!=0){
      f=false;
      break;
    }
  }
  if(f)cout << "APPROVED";
  else cout << "DENIED";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <sstream>
#include <fstream>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <map>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define MIN(x, y) ( (x) < (y) ? (x) : (y) )
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define IVFOR(p,a) for(vector<int>::iterator p = (a).begin(); p!=(a).end(); p++)
#define ILFOR(p,a) for(list<int>::iterator p = (a).begin(); p!=(a).end(); p++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define CHECK(x)  cout << #x << " = " << (x) << endl
#define FINA(y) cout << (y) << endl

int main(){

  int n;
  int t[100];
  int sum = 0;

  cin >> n;
  
  FOR(i,0,n){
    cin >> t[i];
    sum += t[i];
  }

  int m;
  int p;
  int x;

  cin >> m;
  
  FOR(i,0,m){
    cin >> p >> x;
    FINA(sum - t[p-1] + x);
  }
  
 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,q,x,y,ans[200010],f[200010];
vector<int> v[200010];
void dfs(int deep){
	for (int i=0;i<v[deep].size();i++)
		if (f[v[deep][i]]==0){
			f[v[deep][i]]=1;ans[v[deep][i]]+=ans[deep];
			dfs(v[deep][i]);
		}
}
int main(){
	cin>>n>>q;
	for (int i=0;i<n-1;i++){
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	for (int i=0;i<q;i++){
		cin>>x>>y;
		ans[x]+=y;
	}
	f[1]=1;
	dfs(1);
	for (int i=1;i<=n;i++) cout<<ans[i]<<' ';
	return 0;
}

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

int main(){
  string p, s;
  cin >> s;
  cin >> p;
  while(s.size() <= 100) s += s;
  if(s.find(p) != string::npos) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 1192
def resolve():
    x,k,d = map(int,input().split())
    if x < 0:
        x = -x
    if k*d > x:
        g = x//d * d
        if (k - x//d) % 2 == 0:
            print(x - g)
        else:
            print(abs(x-g-d))
    else:
        print(x-k*d)
resolve()

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

const int N = 321;
const long long inf = 1e17;

int n, m, l, q;

long long dist[N][N];

int main() {
    scanf("%d %d %d", &n, &m, &l);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            dist[i][j] = inf;
        }
        dist[i][i] = 0;
    }
    for (int i = 0; i < m; ++i) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        --a; --b;
        dist[b][a] = dist[a][b] = c;
    }
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (dist[i][j] <= l) dist[i][j] = 1;
            else dist[i][j] = inf;
        }
    }
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    scanf("%d", &q);
    while (q--) {
        int s, t;
        scanf("%d %d", &s, &t);
        if (dist[s-1][t-1] >= inf) printf("-1\n");
        else printf("%lld\n", dist[s-1][t-1]-1);
    }
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(a) cout << a << endl
#define re0 return 0
#define exout(a) printf("%.10f\n", a)
#define pb push_back
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll n; 
    double a, b, c = 0, ans;
    cin >> n;

    rep(i, n) {
        cin >> a;
        b = 1.0/a;
        c += b;
    }

    ans = 1.0/c;

    exout(ans);
    re0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int[] list = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

		System.out.println(list[K-1]);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
const int MAX = 1000010;
//const int MOD = 998244353;
const int MOD = 1000000007;
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;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    // 前処理
    COMinit();
    ll X,Y;
    cin >> X >> Y;
    // a+2b = X
    // 2a+b = Y
    // -> b = (2X-Y)/3
    // -> a = (2Y-X)/3
    if((2*X-Y)%3 != 0 || (2*Y-X)%3 != 0){
        cout << 0 << endl;
        return 0;
    }
    ll a = (2*Y-X)/3;
    ll b = (2*X-Y)/3;
    if(a<0||b<0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = fac[a+b];
    ans*=finv[a];
    ans%=MOD;
    ans*=finv[b];
    ans%=MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 27036
h,w,n,*l=map(int,open(0).read().split())
g=[[] for i in range(h)]
r=t=0
for i,c in enumerate(l):
  i+=1
  while c>=(s:=w-t):
    if r%2: g[r]+=[i]*s
    else: g[r]=[i]*s+g[r]
    r+=1
    c-=s
    t=0
  if c:
    if r%2: g[r]+=[i]*c
    else: g[r]=[i]*c+g[r]
    t+=c
for r in g: print(*r)

Measured memory_bytes: 9564
S = input().strip()
p = 2019
t = 1
y = 0
c = [0] * p
c[y] += 1
for x in map(int, S[::-1]):
    y = (y + t*x) % p
    c[y] += 1
    t = (t*10) % p
print(sum(i*(i-1)//2 for i in c))

Measured memory_bytes: 9332
#include <sys/time.h>
#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 <ctime>
#include <cstring>
 
#define IT(a,it) for(auto it=a.begin(); it != a.end(); it++)
#define REV_IT(a,it) for(auto it=a.rbegin(); it != a.rend(); it++)
#define LL long long
#define LD long double
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define INF (int)(1e9)
#define EPS (double)(1e-9)
 
#ifndef ONLINE_JUDGE
#  define LOG(x) cerr << #x << " = " << (x) << endl
#else
#  define LOG(x) 0
#endif
 
#define MAXX 5005
 
using namespace std;
 
typedef pair <int, int> pi_i;
typedef pair<int, pi_i> pi_ii;
 
bool cmp(int a, int b){ return a>b; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a * (b / gcd(a, b)); }
 
double getTime(){
   timeval tv; 
   gettimeofday(&tv, 0); 
   return tv.tv_sec + tv.tv_usec * 1e-6;
}
 
int n, k, p[MAXX], q[MAXX], deg[MAXX], vis[MAXX], dist[MAXX][MAXX];
vector<int> G[MAXX];
 
void dfs(int start, int u, int dd){
	vis[u] = 1;
	dist[start][u] = dd;
	//dist[u][start] = dd;
	for(int i = 0;i < G[u].size();i++){
		int v = G[u][i];
		if(vis[v] == 0) dfs(start, v, dd+1);
	}
}
 
int main(){
	ios_base::sync_with_stdio(false);
	
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	
	cin >> n >> k;
	for(int i = 0;i < n-1;i++){
		cin >> p[i] >> q[i];p[i]--;q[i]--;
		G[p[i]].PB(q[i]);G[q[i]].PB(p[i]);
	}
	
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++) vis[j] = 0;
		dfs(i, i, 0);
	}
	int ans = INF;
	if(k % 2 == 0){
		for(int i = 0;i < n;i++){	//current center
			int curr = 0;
			for(int j = 0;j < n;j++){
				if(dist[i][j] > k/2) curr++;
			}
			//LOG(curr);
			ans = min(curr, ans);
		}
	}else{
		int curr = 0;
		for(int i = 0;i < n-1;i++){
			int curr = 0;
			for(int j = 0;j < n;j++){
				int dd = min(dist[p[i]][j], dist[q[i]][j]);
				if(dd > k/2) curr++;
			}
			ans = min(curr, ans);
		}
	}

	cout << ans << endl;
 
	//fclose(stdin);
	//fclose(stdout);
return 0;	
}

Measured memory_bytes: 40704
import java.util.*;
class Main{
    Scanner sc=new Scanner(System.in);
    void main(){
	int r=sc.nextInt();
        int c=sc.nextInt();
	int[][]x=new int[r+1][c+1];
	for(int i=0;i<r;i++){
	    for(int j=0;j<c;j++){
		x[i][j]=sc.nextInt();
		x[i][c]+=x[i][j];
	    }
	}
	for(int i=0;i<r;i++)for(int j=0;j<c+1;j++)x[r][j]+=x[i][j];
	for(int i=0;i<r+1;i++){
	    for(int j=0;j<c;j++)System.out.print(x[i][j]+" ");
	    System.out.println(x[i][c]);
	}
    }
    public static void main(String[]ag){
	new Main().main();
    }
}

Measured memory_bytes: 41912
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static int Get(int i)
        {
            Console.WriteLine(i);
            switch (Read())
            {
            case "Male":   return (i ^ 0) & 1;
            case "Female": return (i ^ 1) & 1;
            default:       return -1;
            }
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            int s1 = Get(0);
            int min = 0;
            int max = N;
            if (s1 == -1) { return; }
            for (int i = 1; i < 20; ++i)
            {
                int med = (min + max) / 2;
                var s2 = Get(med);
                if (s2 == -1)
                {
                    break;
                }
                else if (s1 == s2)
                {
                    min = med;
                    s1 = s2;
                }
                else
                {
                    max = med;
                }
            }
        }
    }
}


Measured memory_bytes: 13512
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=2*1e5+2;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s;
	cin>>s;
	for(auto x:s) 
	{
		cout<<"x";
	}
} 
// I never lose. I either win or I learn

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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const int INF = 1e9;


ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b & 1) tmp = mulMod(tmp,a);
	return tmp;
}

ll GCD(ll a, ll b){
	if(a > b) return GCD(b,a);
	if(a == 0) return b;
	return GCD(b%a,a);
}

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

const int N = 1e5;

int n;
int a[N + 5];

bool solve(){
	ll tot = 0;
	REP(i,1,n){
		tot += a[i];
	}
	if(tot % ((ll)n * (n + 1) / 2) != 0) return false;
	ll cnt = tot / ((ll)n * (n + 1) / 2);
	REP(i,2,n){
		ll dif = a[i] - a[i-1];
		if(cnt - dif < 0) return false;
		if((cnt - dif) % n != 0) return false;
	}
	return true;
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	REP(i,1,n) cin >> a[i];
	if(solve()) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

using namespace std;

bool is_square(int x) {
    int y = (sqrt(x));
    return (y-1)*(y-1) == x || y*y == x || (y+1)*(y+1) == x;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, d;
    cin >> n >> d;
    vector<vector<int>> xss(n, vector<int>(d));
    for (auto& xs : xss) {
        for (auto& x : xs) {
            cin >> x;
        }
    }
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            int dist = 0;
            for (int k = 0; k < d; ++k) {
                dist += (xss[i][k]-xss[j][k])*(xss[i][k]-xss[j][k]);
            }
            sum += is_square(dist);
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  vector<vector<ll> > vv(3,vector<ll>());
  rep(i,0,3){
    ll a,b,c;
    cin>>a>>b>>c;
    vv[i].pb(a);
    vv[i].pb(b);
    vv[i].pb(c);
  }
  ll n;
  cin>>n;
  map<ll,ll> ma;
  rep(i,0,n){
    ll a;
    cin>>a;
    ma[a]++;
  }
  ll flag = 0;
  rep(i,0,3){
    ll c = 0;
    rep(j,0,3){
      c += ma[vv[i][j]];
    }
    if(c==3)flag = 1;
  }
  rep(i,0,3){
    ll c = 0;
    rep(j,0,3){
      c += ma[vv[j][i]];
    }
    if(c==3)flag = 1;
  }
  {
    ll c = 0;
    c += ma[vv[0][0]];
    c += ma[vv[1][1]];
    c += ma[vv[2][2]];
    if(c==3)flag = 1;
  }
  {
    ll c = 0;
    c += ma[vv[0][2]];
    c += ma[vv[1][1]];
    c += ma[vv[2][0]];
    if(c==3)flag = 1;
  }
  if(flag==1){
      cout << "Yes" << endl;
  }
  else{
      cout << "No" << endl;
  }
  return 0;
}

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

int main(){
	int a, b;
	cin >> a >> b;
	if(abs(a-b) <= 1){
		cout << "Yay!" << endl;
	}else{
		cout << ":(" << endl;
	}
	return 0;
}

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

namespace Contest.cs
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = ReadIntList()[0];
			int sum = 0;
			int temp = n;
			while(temp != 0)
			{
				sum += temp % 10;
				temp /= 10;
			}
			string ans;
			if(n%sum == 0)
			{
				ans = "Yes";
			}
			else
			{
				ans = "No";
			}
			Console.WriteLine(ans);
		}

		static string[] ReadStr()
		{
			return Console.ReadLine().Split(' ').ToArray();

		}

		static int[] ReadIntList()
		{
			return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
		}
	}
}

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

int main(){
  int n,i,cur=0,ans=0;
  cin >> n;
  vector<int> p(n);
  for(i=0; i<n; i++){
    cin >> p[i];
  }
  for(i=1; i<n-1; i++){
    cur=0;
    if(p[i]>p[i-1]) cur++;
    if(p[i]>p[i+1]) cur++;
    if(cur==1) ans++;
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef unsigned long long ull;

int main(){
	ull num_1 = 2, num_2 = 1;
	int n;
	cin >> n;
	for(int i = 2; i < n+1; i++){
		ull num = num_1 + num_2;
		num_1 = num_2;
		num_2 = num;
	}
	cout <<  num_2 << endl;
	return 0;
}


Measured memory_bytes: 3604
N =int (input())
W =list(map(int,input().split()))
sum_front=0
sum_lear =0
#pはリストの先頭、qはリストの最後尾
p=0
q =N-1

sum_front =W[p]
sum_lear  =W[q]
while(1):
    
    
    if(sum_front >= sum_lear):
        q -=1
        if(p ==q):
            break
        else:
            sum_lear +=W[q]
    elif(sum_lear >sum_front):
        p +=1
        if(p ==q):
            break
        else:
            sum_front+=W[p]
    
print(abs(sum_front - sum_lear))

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

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

   int ans1;
   int ans2;
   int ans3;
   int ans4;
   ans1 = x / 500; 
   ans2 = x % 500;

   ans3 = ans2 / 5; 
   ans4 = ans2 % 5;

   int fans;
   fans = ans1 * 1000 + ans3 * 5;
   cout << fans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {
    cout<<setprecision(16);

    double t,x;
    cin>>t>>x;
    cout<<t/x<<endl;



    return 0;
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int,input().split()))
dp = N*[0]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,N):
	dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[N-1])

Measured memory_bytes: 13928
#include <iostream>
#include <algorithm>
#include <cstdio>
#define INF 200000

using namespace std;

const int MAX=11;

int d[MAX][MAX];
int V;

int main()
{
    int n;
    while(~scanf("%d", &n) && n)
    {
        for(int i=0; i<MAX; i++)
        {
            for(int j=0; j<MAX; j++)
            {
                if(i!=j)
                    d[i][j]=INF;    //初始化
            }
        }
        V=0;
        for(int i=0; i<n; i++)
        {
            int x,y,m;
            scanf("%d %d %d", &x, &y, &m);
            d[x][y]=m;
            d[y][x]=m;
            V = max(V, max(x+1, y+1));
        }
   //     printf("%d\n",V);
//        for(int i=0; i<V; i++)
//        {
//            for(int j=0; j<V; j++)
//            {
//                printf("%d ", d[i][j]);
//            }
//            printf("\n");
//        }
//        printf("\n");
        for(int k=0; k<V; k++)
        {
            for(int i=0; i<V; i++)
            {
                for(int j=0; j<V; j++)
                    d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
            }
        }
        int u=0;
        for(int i=0; i<V; i++)
        {
            for(int j=1; j<V; j++)
            {
                if(d[i][j] != INF && i!=j)
                    d[i][0]+=d[i][j];
            }
            if(d[i][0]<d[u][0])
                u=i;
        }
        printf("%d %d\n", u, d[u][0]);
    }
    return 0;
}

Measured memory_bytes: 3204
# Grading

end = 0
while end == 0:
    test = [int(i) for i in input().rstrip().split()]
    midterm = test[0]
    final = test[1]
    makeup = test[2]
    if midterm == -1 and final == -1 and makeup == -1:
        end += 1
    elif midterm == -1 or final == -1:
        print('F')
    else:
        if midterm + final >= 80:
            print('A')
        elif midterm + final >= 65:
            print('B')
        elif midterm + final >= 50:
            print('C')
        elif midterm + final >= 30:
            if makeup >= 50:
                print('C')
            else:
                print('D')
        else:
            print('F')



Measured memory_bytes: 5600