akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MAX 10000
#define NIL -1

void setDepth(int, int);
int setHeight(int);
int getSibling(int);
void print(int);

struct node{
  int parent;
  int left;
  int right;
};
struct node T[MAX];

int n, D[MAX], H[MAX];

int main(){
  int n, i, v, l, r, root = 0;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    T[i].parent = NIL;
    T[i].left = NIL;   /*入力で -1 を入力するから、left と rightを NIL で初期化する必要はないけど、初期化しておく。*/
    T[i].right = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d %d %d", &v, &l, &r);
  T[v].left = l;
  T[v].right = r;
  if(l != NIL) T[l].parent = v;
  if(r != NIL) T[r].parent = v;
  }
  for(i = 0; i < n; i++) if(T[i].parent == NIL) root = i;

  setDepth(root, 0);
  setHeight(root);

  for(i = 0; i < n; i++) print(i);

  return 0;
}
void setDepth(int u, int d){
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d + 1);
  setDepth(T[u].right, d + 1);
}
int setHeight(int u){
  int h1 = 0, h2 = 0;
  if(T[u].left != NIL) h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL) h2 = setHeight(T[u].right) + 1;
  if(h1 > h2) return H[u] = h1;
  else return H[u] = h2;
}
int getSibling(int u){
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL) return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL) return T[T[u].parent].right;
  return NIL;   /*兄弟が存在しない場合は、-1 だから、NIL を入れる。*/					      
}
void print(int u){
  int degree;
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  if(T[u].left != NIL) degree++;
  if(T[u].right != NIL) degree++;
  printf("degree = %d, ", degree);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if(T[u].parent == NIL) printf("root\n");
  else if(T[u].left == NIL && T[u].right == NIL) printf("leaf\n");
  else printf("internal node\n");
}



Measured memory_bytes: 2104
#include "bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }

lint N;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	string s = to_string(N);
	lint sum = 0;
	REP(i, s.size()) {
		sum += (s[i] - '0');
	}
	if (N % sum == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def main():
    N, M, X, Y = map(int, input().split())
    x = map(int, input().split())
    y = map(int, input().split())
    max_x = max(x)
    min_y = min(y)
    if max_x > min_y:
        print('War')
        return
    if X >= Y:
        print('War')
        return
    for i in range(X+1, Y):
        if max_x < i <= min_y:
            print('No War')
            break
    else:
        print('War')





if __name__ == "__main__":
    main()



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

int main() {
 string s,t;
 cin>>s>>t;
 
 int count = 0;
 int maxcount = 0;
 for(int i = 0;i<s.size()-t.size()+1;i++) {
   for(int j = 0;j<t.size();j++){
   if(s.at(i+j) == t.at(j)) {
    count++;
    }
  
  }
 maxcount = max(maxcount,count);
   count = 0;
  }
 
 cout << t.size()-maxcount;
 
 }

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

int main(){

	string s;
  	int mx=0,pr=0;
  	cin >> s;
  	for(int i=0; i<3; ++i){
      if(s[i]=='R'){
        if(pr==0){
			mx = max(mx,1);
          	pr++;
        }else{
			mx = max(mx,pr+1);
          	pr++;
        }
      }else{
        pr = 0;
      }
    }
  
  	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 3560
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        switch (N % 10) {
            case 3:
                System.out.println("bon");
                return;
            case 0:
            case 1:
            case 6:
            case 8:
                System.out.println("pon");
                return;
            default:
                System.out.println("hon");
                return;
        }
    }
}

Measured memory_bytes: 26852
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i, _ := range arr {
		fmt.Scan(&arr[i])
	}

	fmt.Println(len(removeDuplicate(arr)))
}

func removeDuplicate(args []int) []int {
	results := make([]int, 0, len(args))
	check := map[int]bool{}
	for _, v := range args {
		if !check[v] {
			check[v] = true
			results = append(results, v)
		}
	}
	return results
}


Measured memory_bytes: 512
from collections import deque
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

x, n = NextInts()
da = NextIntList()

ans = -1000

for i in range(200):
    if abs(ans-x) > abs(x-i) and not(i in da):
        ans = i

print(ans)

Measured memory_bytes: 9484
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    int n, m;
    cin >> n >> m;
    vector<int> s(m), c(m), d(n, -1);
    rep(i, m){
        cin >> s[i] >> c[i];
        s[i]--;
    }
    rep(i, m){
        if(d[s[i]] != -1 && d[s[i]] != c[i]){
            cout << -1 << endl;
            return 0;
        }
        d[s[i]] = c[i];
    }

    int st = 1, ed = 10;
    rep(i, n-1){
        st *= 10;
        ed *= 10;
    }
    if(n == 1) st = 0;
    REP(i, st, ed){
        string st = to_string(i);
        bool f = 0;
        rep(j, m){
            if(st[s[j]]-'0' != c[j]) f = 1;
        }
        if(f) continue;
        cout << i << endl;
        return 0;
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
import math
def String_Sort(str):
    tmp = sorted(str)
    ans = ""
    for i in tmp:
        ans += i
    return ans

def sol(n):
    return (n*(n-1))//2

# main
li = []
n = int(input())
ans = 0
for i in range(n):
    li.append(String_Sort(input()))
li.sort()
# temporary
str = li[0]
num = 0
for i in li:
    if (i == str):
        num += 1
        continue
    else:
        if num>1:
            ans += sol(num)
        num = 1
        str = i
if (num > 1):
    ans+=sol(num)
print(ans)


Measured memory_bytes: 10608
#include <bits/stdc++.h>
using namespace std;
long cal(long n){
  if(n % 2 == 0){
    return ((long)(n/2)%2)^n; 
  }else{
    return ((long)((n+1)/2)%2);
  }
}
int main() {
  long A, B;
  cin >> A >> B;
  long C = cal(A-1) ^ cal(B);
  cout << C;
}


Measured memory_bytes: 256
// 2018/05/28 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

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

	int d[300000];
	for(int i=0; i<N; i++){
		cin >> d[i];
	}

	int D = 0;

	for(int i=0; i<N-1; i++){
		D = max(D, d[i]);

		if(D<10){
			cout << "no" << endl;
			return 0;
		}

		D -= 10;
	}

	D = 0;

	for(int i=N-1; i>0; i--){
		D = max(D, d[i]);

		if(D<10){
			cout << "no" << endl;
			return 0;
		}

		D -= 10;
	}

	cout << "yes" << endl;

	return 0;
}



Measured memory_bytes: 4284
#include <stdio.h>
#include <algorithm>
#define inf 10e15;
typedef long long ll;

int main(void) {
  ll i, j, h, w, k, sum = 0;
  scanf("%lld%lld", &h, &w);
  char s[h][w + 10];
  for(i = 0; i < h; ++i) scanf("%s", s[i]);
  for(i = 0; i < h; ++i) for(j = 0; j < w; ++j) if(s[i][j] == '.') ++sum;
  ll dp[h][w];
  for(i = 0; i < h; ++i) for(j = 0; j < w; ++j) dp[i][j] = inf;
  dp[0][0] = 1;
  for(i = 0; i < h * w + 5; ++i) {
    for(j = 0; j < h; ++j) {
      for(k = 0; k < w; ++k) {
        if(s[j][k] == '.') {
        if(j) {
          if(s[j - 1][k] == '.' && dp[j - 1][k] + 1 < dp[j][k]) dp[j][k] = dp[j - 1][k] + 1;
        }
        if(j != h - 1) {
          if(s[j + 1][k] == '.' && dp[j + 1][k] + 1 < dp[j][k]) dp[j][k] = dp[j + 1][k] + 1;
        }
        if(k) {
          if(s[j][k - 1] == '.' && dp[j][k - 1] + 1 < dp[j][k]) dp[j][k] = dp[j][k - 1] + 1;
        }
        if(k != w - 1) {
          if(s[j][k + 1] == '.' && dp[j][k + 1] + 1 < dp[j][k]) dp[j][k] = dp[j][k + 1] + 1;
        }
        }
      }
    }
  }
  sum -= dp[h - 1][w - 1];
  /*for(i = 0; i < h; ++i) {
    for(j = 0; j < w; ++j)printf("%d ", dp[i][j]);
    printf("\n");
  }*/
  ll o = inf;
  if(dp[h - 1][w - 1] != o)printf("%lld", sum);
  else printf("-1");
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
  int A,B,C,D;
  scanf("%d %d %d %d",&A,&B,&C,&D);
  do{
    C=C-B;
    A=A-D;}while(C>0&&A>0);
  if(C<=0&&A>0)
    puts("Yes");
  if(A<=0&&C>0)
    puts("No");
  if(A<=0&&C<=0)
    puts("Yes");
  return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(){
    int a, b;
    scanf ("%d%d", &a, &b);
    int sum = a+b;
    int sub = a-b;
    int mul = a*b;

    if (sum >= sub && sum >= mul){
        printf ("%d\n", sum);
    } else if (sub >= sum && sub >= mul){
        printf ("%d\n", sub);
    } else {
        printf ("%d\n", mul);
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i< (int)(n); i++)
#define rep2(i,x,n) for(int i = (int)x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<vector<int>> v(n, vector<int>(3));
	rep(i, n-1) cin >> v.at(i).at(0) >> v.at(i).at(1) >> v.at(i).at(2);
	rep(i, n){
		int ans = 0;
		for(int j = i; j < n-1; j++){
			if(ans < v[j][1]){
				ans = v[j][1];
			}else if(ans % v[j][2] != 0){
				ans += v[j][2] - (ans % v[j][2]);
			}
			ans += v[j][0];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <tuple>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
#define whole(x) begin(x), end(x)
using ll = long long;
using namespace std;
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }

constexpr ll inf = ll(1e18)+9;
int main() {
    // input
    int n; scanf("%d", &n);
    vector<pair<int, int> > hps(n);
    repeat (i, n) {
        int h, p; scanf("%d%d", &h, &p);
        hps[i] = { h, p };
    }
    // solve
    sort(whole(hps), [&](pair<int, int> hp1, pair<int, int> hp2) {
        return hp1.first + hp1.second < hp2.first + hp2.second;
    });
    vector<ll> dp(n + 1, inf);
    dp[0] = 0;
    for (auto hp : hps) {
        int h, p; tie(h, p) = hp;
        repeat_reverse (j, n) {
            if (dp[j] <= h) {
                setmin(dp[j + 1], dp[j] + p);
            }
        }
    }
    int result = 0;
    repeat (i, n + 1) {
        if (dp[i] < inf) {
            result = i;
        }
    }
    // output
    printf("%d\n", result);
    return 0;
}


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

public class Main{
	public static void main(String[] args) {
		int n;
		double aver;
		int [] a=new int[10005];
		boolean p=true;
		Scanner sc=new Scanner(System.in);
		
		while(p) {
			int ans=0;
			double sum=0;
			n=sc.nextInt();
			if(n==0) break;
			for(int m=0;m<n;m++) {
				a[m]=sc.nextInt();
				sum+=a[m];
			}
			
			aver=sum/n;
			
			for(int m=0;m<n;m++) {
				if(a[m]<=aver) ans++;
			}
			System.out.printf("%d\n",ans);
		}
	}
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    ll N;
    string S;
    cin >> N >> S;

    string ans = S;
    ll cnt1 = 0, cnt2 = 0;
    for (ll i = 0; i < N; i++) {
        if (S[i] == '(') {
            ++cnt1;
        }
        else {
            ++cnt2;
        }

        if (cnt1 < cnt2) {
            ans = '(' + ans;
            ++cnt1;
        }
    }

    if (cnt1 > cnt2) {
        while (cnt1 != cnt2) {
            ans += ')';
            ++cnt2;
        }
    }
    else if (cnt1 < cnt2) {
        while (cnt1 != cnt2) {
            ans = '(' + ans;
            ++cnt1;
        }
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<deque>
#include<cmath>
using namespace std;


int main() {

    int n;
    while(cin >> n && n) {
        vector<vector<int> > cases(n + 1, vector<int>(9)); 

        char s, t, b;
        cin >> s >> t >> b;
        int start, battery, junk;
        start = (int)s - 'A';
        battery = (int)t - 'A';
        junk = (int)b - 'A';

        for(int i = 0; i <= 8; i++) {
            cases[0][i] = 0;
        }
        cases[0][battery] = 1;

        for(int i = 1; i <= n; i++) {
            for (int j = 0; j <= 8; j++) {
                cases[i][j] = 0;
                // up
                if (j >= 3 && j - 3 != junk) {
                    cases[i][j] += cases[i-1][j-3];
                } else {
                    cases[i][j] += cases[i-1][j];
                }

                // down
                if (j <= 5 && j + 3 != junk) {
                    cases[i][j] += cases[i-1][j+3];
                } else {
                    cases[i][j] += cases[i-1][j];
                }

                // right
                if (j % 3 != 2 && j + 1 != junk) {
                    cases[i][j] += cases[i-1][j+1];
                } else {
                    cases[i][j] += cases[i-1][j];
                }

                // left
                if (j % 3 != 0 && j - 1 != junk) {
                    cases[i][j] += cases[i-1][j-1];
                } else {
                    cases[i][j] += cases[i-1][j];
                }
            }

        }

        printf("%.8f", (double)cases[n][start] / pow(4.0, n));
        cout << endl;
    }
     
    return 0;
}

Measured memory_bytes: 0
import math
from typing import Union


class Point(object):
    __slots__ = ['x', 'y']

    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __add__(self, other):
        return Point(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Point(self.x - other.x, self.y - other.y)

    def __mul__(self, other: Union[int, float]):
        return Point(self.x * other, self.y * other)

    def __repr__(self):
        return f"({self.x},{self.y})"


class Vector(Point):
    __slots__ = ['x', 'y', 'pt1', 'pt2']

    def __init__(self, pt1: Point, pt2: Point):
        from_pt1_to_pt2 = pt2 - pt1
        super().__init__(from_pt1_to_pt2.x, from_pt1_to_pt2.y)
        self.pt1 = pt1
        self.pt2 = pt2

    def dot(self, other):
        return self.x * other.x + self.y * other.y

    def cross(self, other):
        return self.x * other.y - self.y * other.x

    def norm(self):
        return pow(self.x, 2) + pow(self.y, 2)

    def abs(self):
        return math.sqrt(self.norm())

    def __repr__(self):
        return f"{self.pt1},{self.pt2}"


class Segment(Vector):
    __slots__ = ['x', 'y', 'pt1', 'pt2']

    def __init__(self, pt1: Point, pt2: Point):
        super().__init__(pt1, pt2)

    def projection(self, pt: Point)-> Point:
        t = self.dot(Vector(self.pt1, pt)) / pow(self.abs(), 2)
        return Point(self.pt1.x + t * self.x, self.pt1.y + t * self.y)

    def reflection(self, pt: Point) -> Point:
        return self.projection(pt) * 2 - pt

    def is_intersected_with(self, other) -> bool:
        if (self.point_geometry(other.pt1) * self.point_geometry(other.pt2)) <= 0\
                and other.point_geometry(self.pt1) * other.point_geometry(self.pt2) <= 0:
            return True
        else:
            return False

    def point_geometry(self, pt: Point) -> int:
        """
        [-2:"Online Back", -1:"Counter Clockwise", 0:"On Segment", 1:"Clockwise",  2:"Online Front"]
        """
        vec_pt1_to_pt = Vector(self.pt1, pt)
        cross = self.cross(vec_pt1_to_pt)
        if cross > 0:
            return -1   # counter clockwise
        elif cross < 0:
            return 1    # clockwise
        else:           # cross == 0
            dot = self.dot(vec_pt1_to_pt)
            if dot < 0:
                return -2    # online back
            else:       # dot > 0
                if self.abs() < vec_pt1_to_pt.abs():
                    return 2    # online front
                else:
                    return 0    # on segment

    def __repr__(self):
        return f"{self.pt1},{self.pt2}"


def main():
    num_query = int(input())
    for i in range(num_query):
        p0_x, p0_y, p1_x, p1_y, p2_x, p2_y, p3_x, p3_y = map(int, input().split())
        seg_1 = Segment(Point(p0_x, p0_y), Point(p1_x, p1_y))
        seg_2 = Segment(Point(p2_x, p2_y), Point(p3_x, p3_y))

        print(int(seg_1.is_intersected_with(seg_2)))
    return


main()


Measured memory_bytes: 7320
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    int n;
    cin>>n;
    vector<vector<int>> g(n);
    vector<pair<int,int>> el;
    for(int i=0;i<n-1;i++)
    {
        int x,y;
        cin>>x>>y;
        g[--x].push_back(--y);
        g[y].push_back(x);
        el.push_back(make_pair(x,y));
    }
    map<pair<int,int>,int> m;
    vector<int> c(n,0);
    vector<int> used(n,1);
    int k=0;
    for(int i=0;i<n;i++)
    {
        if(g[i].size()>k) k=g[i].size();
    }
    queue<int> q;
    q.push(0);
    used[0]=0;
    while(!q.empty())
    {
        int v=q.front(); q.pop();
        int cur=1;
        for(int i=0;i<g[v].size();i++)
        {   
            if(used[g[v][i]]==0) continue;
            if(cur==c[v]) cur++;
            int ch=g[v][i];
            m[make_pair(v,ch)]=cur;
            m[make_pair(ch,v)]=cur;
            c[ch]=cur;
            cur++;
            
            if(used[ch]) q.push(ch);
            used[ch]=0;
        }

    }

    cout<<k<<endl;
    for(int i=0;i<n-1;i++)
    {
        cout<<m[el[i]]<<endl;
    }

}

Measured memory_bytes: 20084
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return True

    return False


def main():
    X = int(input())

    while is_prime(X):
        X += 1
    print(X)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
fun c109(args: Array<String>) {
    val (n, x) = args[0].split(" ").map { it.toInt() }
    val numList = args[1].split(" ").map { it.toInt() }
    fun gcd(x: Int, y: Int): Int = when {
        x < y -> gcd(y, x)
        x % y == 0 -> y
        else -> gcd(y, x % y)
    }
    println(numList.map { Math.abs(x - it) }.reduce { acc, i -> gcd(acc, i) })
}

fun main(args: Array<String>) {
    c109(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 55552
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <climits>
using namespace std;

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

int main(){
    char ch;
    cin >> ch;
    switch(ch){
        case 'a':
        case 'e':
        case 'i':
        case 'u':
        case 'o':
            cout << "vowel" << endl;
            break;
        default:
            cout << "consonant" << endl;
            break;
    }
}

Measured memory_bytes: 256
N, X = map(int,input().split())
x = list(map(int,input().split()))

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
ans = abs(X-x[0])

for k in range(1,N):
    ans = gcd(ans,abs(x[k]-x[k-1]))
print(ans)


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

int main(){
  string s;  cin >> s;
  int ans = 0, slen = s.size(), p = 0;
  
  while(p < slen){
    int i;
    for(i=p; i<slen; i++){
      bool flag = true;
      for(int j=0; j<4; j++)
        if(s[i] == "ACGT"[j])  flag = false;
      if(flag)  break;
    }
    ans = max(ans, i-p);
    p++;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <boost/rational.hpp>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  bool first = false;
  rep(i, N) {
    int a;
    cin >> a;
    first = first || (a % 2 == 1);
  }
  cout << (first ? "first" : "second") << endl;

  return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,q; cin>>n>>q;
  string s; cin>>s;
  vll sum(n+1);
  rep(i,n-1){
    sum[i+1]+=sum[i];
    if(s[i]=='A' && s[i+1]=='C') sum[i+1]++;
  }
  sum[n]=sum[n-1];
  rep(i,q){
    ll l,r; cin>>l>>r;
    l--,r--;
    cout<<sum[r]-sum[l]<<endl;
  }
}

Measured memory_bytes: 1872
#include<bits/stdc++.h>
using namespace std;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
vector<int> adj[100000];
#define ull unsigned long long int
#define ll long long int
#define MAX 1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
bool vis[200001];
ll arr[26];
string s,ans="";
ll n,k,t;
ll r[6][6],c[6][6];
ll mat[5][5];
vector<ll> v;
void lun(){
  ll pre=0;
  queue<ll> q;
  if(k<=9) {cout<<k;return;}
  for(ll i=1;i<=9;i++) q.push(i);
  k-=9;
  while(1){
    ll x=q.front();
    q.pop();
    ll x1=x*10+(x%10)-1,x2=x*10+(x%10),x3=x*10+(x%10)+1;
    if(x%10==0){
      q.push(x2);
      k--;
      if(k<=0) {cout<<x2;return;}
      q.push(x3);
      k--;
      if(k<=0) {cout<<x3;return;}
    }
    else if(x%10==9){
      q.push(x1);
      k--;
      if(k<=0) {cout<<x1;return;}
      q.push(x2);
      k--;
      if(k<=0) {cout<<x2;return;}
    }
    else{
      q.push(x1);
      k--;
      if(k<=0) {cout<<x1;return;}
      q.push(x2);
      k--;
      if(k<=0) {cout<<x2;return;}
      q.push(x3);
      k--;
      if(k<=0) {cout<<x3;return;}
    }
  }
  
}
    
int main(){
  	cin>>k;
  	lun();
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
using namespace std;
int main(){
  int a;
  int count = 0;
  cin >> a;
  if (a / 100 == 1) {
    count++;
    a = a % 100;
  }
  if (a / 10 == 1) {
    count++;
    a = a % 10;
  }
  if (a == 1){
    count++;
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
	int n,ans=1;scanf("%d",&n);
	for(int i=2;i<35;i++)
	{
		int x=i*i;if(x>n) break;
		while(x*i<=n) x*=i;
		if(x>ans) ans=x;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    int N, A, B;
    cin >> N >> A >> B;
    
    if(N * A < B)
    {
        cout << N * A << endl;
    }
    else if ( N * A > B)
    {
        cout << B << endl;
    }
    else 
    {
        cout << B << endl;
    }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void solve()
{
    string str;
    deque <char> forward,back;
    int q,rev=0,t,f;
    char ch;
    cin>>str;
    cin>>q;
    while(q--)
    {
        cin>>t;
        if(t==1)
        {
            rev=(rev+1)&1;
        }
        else
        {
            cin>>f>>ch;
            if(rev)
            {
                if(f==1)
                {
                    back.push_back(ch);
                }
                else
                {
                    forward.push_front(ch);
                }
                
            }
            else
            {
                if(f==2)
                {
                    back.push_back(ch);
                }
                else
                {
                    forward.push_front(ch);
                }
            }
            
        }
        
    }
    if(rev)
    {
        while (!back.empty())
        {
            ch=back.back();
            cout<<ch;
            back.pop_back();
        }
        reverse(str.begin(),str.end());
        cout<<str;
        while (!forward.empty())
        {
            ch=forward.back();
            cout<<ch;
            forward.pop_back();
        }
    }
    else
    {
        while (!forward.empty())
        {
            ch=forward.front();
            cout<<ch;
            forward.pop_front();
        }
        
        //reverse(str.begin(),str.end());
        cout<<str;
        while (!back.empty())
        {
            ch=back.front();
            cout<<ch;
            back.pop_front();
        }
        
    }
    
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //int _t;cin>>_t;while(_t--)
    solve();
    return 0;
}

Measured memory_bytes: 848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
const int INF=1e9+5;
const int N=2e5+5;
const int mod=998244353;

double l;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>l;
	l/=3.0;
	cout<<fixed<<setprecision(12)<<l*l*l<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  rep(i,n-1){
    if(a[i]==a[i+1]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main (void)
{
	int a, b, c, count, i;

	scanf("%d %d %d", &a, &b, &c);

	for (i=a; i<=b; i++){
		if (c%i == 0)
				count++;
	}


	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  LL n;
  cin >> n;
  LL inf = 1000000007ll;
  vector<vector<LL>> a(n,vector<LL>(n));
  for(auto &&b: a) for(auto &&c: b) cin >> c;
  REP(k,n) REP(i,n) REP(j,n) {
    if(a[i][j]>a[i][k]+a[k][j]) {
      cout << -1 << endl;
      return 0;
    }
  }
  REP(k,n) REP(i,n) REP(j,n) {
    if(a[i][j]==a[i][k]+a[k][j] && a[i][k] != 0 && a[k][j] != 0) {
      a[i][j]=inf;
    }
  }
  LL answer = 0ll;
  for(auto b: a) for(auto c: b) if(c!=inf) answer+=c;
  cout << answer/2 << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}

template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }  
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N, K;
  cin>>N>>K;

  vector<Int> A(N);
  cin>>A;

  auto calc = MFP([&](auto dfs, Int x)->Int{
      if(x == -1) return 0;
      Int a = 0, b = 0;
      for(Int i=0;i<N;i++){
	a += (A[i]>>x&1)? (1LL<<x):0;
	b += (A[i]>>x&1)? 0:(1LL<<x);
      };
      return dfs(x - 1) + max(a, b);
    });

  
  Int ans = MFP([&](auto dfs, Int x)->Int{
      if(x == -1) return 0;
      Int a = 0, b = 0;
      for(Int i=0;i<N;i++){
	a += (A[i]>>x&1)? (1LL<<x):0;
	b += (A[i]>>x&1)? 0:(1LL<<x);
      };
      if(K>>x&1) return max(dfs(x - 1) + b,
			    calc(x - 1) + a);
      return dfs(x - 1) + a;
    })(40);
  
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#define MAX 300000
#undef DEBUG

using namespace std;

bool msprime[MAX+1]={};
bool judge(int,int);

int main(void){
	for(int i=6; i<=MAX; i++)
		if(i%7==1 || i%7==6)
			msprime[i]=true;
	for(int i=6;i<=MAX; i++)
		if(msprime[i])
			for(int j=2;i*j<=MAX;j++)
				msprime[i*j]=false;

#ifdef DEBUG
	for(int i=0;i<=2000;i++)
		if(msprime[i])
			cout << i << " ";
	cout << endl;
#endif

	for(int ms; cin >> ms, ms != 1;){
		bool p = true;
		cout << ms << ":";
		for(int i = 6; i < ms; i++)
			if(msprime[i]&&judge(ms,i)){
				cout << " " << i;
				p=false;
			}
		if(p)
			cout << " " << ms;
		cout << endl;
	}
	return 0;
}

bool judge(int ms,int val){
	if(ms%val==0)
		if(msprime[ms/val])
			return true;
		else
			for(int i=6;i<=ms;i++)
				if(judge(ms/val,i))
					return true;
	return false;
}

Measured memory_bytes: 1452
#include <stdio.h>

int main(void) {
	// your code goes here
	int W,a,b,buf;
	scanf("%d %d %d",&W,&a,&b);
	buf = abs(a-b);
	if(buf>W){
		printf("%d\n",buf-W);
	}else{
		printf("0\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define PB push_back
#define PPB pop_back
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, int> psi;

static const int INF = 1LL << 60;
static const int MAX_N = 100005;

int n, ruij[MAX_N], ruii[MAX_N], dj[] = {1, 0}, di[] = {0, 1};
string s;

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

    cin >> n >> s;
    for (int i = 0; i < n; ++i) {
        ruij[i] += s[i] == 'J';
        ruii[i] += s[i] == 'I';
        ruij[i + 1] = ruij[i];
        ruii[i + 1] = ruii[i];
    }

    int ans = 0;
    for (int i = 0; i < 2; ++i) {
        int t = 0;
        for (int j = 0; j < n; ++j) {
            if (s[j] != 'O') continue;
            int numj = ruij[j] + dj[i], numi = ruii[n] - ruii[j] + di[i];
            t += numj * numi;
        }

        ans = max(ans, t);
    }
    {
        int t = 0, tmax = 0;
        for (int i = 0; i < n; ++i) {
            int numi = ruii[n] - ruii[i], temp = ruij[i] * numi;
            if (s[i] == 'O') t += temp;
            tmax = max(tmax, temp);
        }
        ans = max(ans, t + tmax);
    }

    cout << ans << endl;
}

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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    rep(i,3) {
        if (s.at(i) == '1') counter++;
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
	int A, B, K;
	cin >> K;
	cin >> A >> B;

	if (A - (A % K) + K*(int)(A%K != 0) <= B) cout << "OK" << endl;
	else cout << "NG" << endl;

	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n;

int main(){
	cin>>n;
	vvi a(3,vi(101,-1));
	for(int i=0;i<n;i++) for(int j=0;j<3;j++){
		int x;
		cin>>x;
		if(a[j][x]!=-1||a[j][x]==-2) a[j][x]=-2;
		else a[j][x]=i;
	}
	vi ans(n);
	for(int i=0;i<3;i++) for(int j=0;j<101;j++){
		if(a[i][j]>=0) ans[a[i][j]]+=j;
	}
	for(int i=0;i<n;i++) cout<<ans[i]<<endl;
}

Measured memory_bytes: 3116
#include <iostream>

using namespace std;

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

    int n;
    cin >> n;

    int min = 1000000;
    int max = -1000000;
    long sum = 0;

    while (n--) {
        int x;
        cin >> x;

        if (x < min) {
            min = x;
        }

        if (x > max) {
            max = x;
        }

        sum = sum + x;

    }

    cout << min << " " << max << " " << sum << "\n";

}



Measured memory_bytes: 3212
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
string t[4] = {"maerd", "remaerd", "esare", "resare"};

int main()
{
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    while (!s.empty())
    {
        bool flag = false;
        rep(i, 4)
        {
            if (s.find(t[i]) == 0)
            {
                s.erase(0, t[i].size());
                flag = true;
            }
        }
        if (!flag)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
long long N;

int main(){
  int N, M;
  cin >> N >> M;
  int L[M], R[M];
  rep(i, M){
    cin >> L[i] >> R[i];
  }
  int maxl = 0, minr = inf;
  rep(i, M){
    if(L[i]>maxl) maxl = L[i];
    if(R[i]<minr) minr = R[i];
  }
  int ans = max(min(minr, N) - maxl + 1, 0);
  cout << ans << endl;
    
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c; cin >> a >> b >> c;
	if(a==b && b==c){
		cout << "Yes" << endl;
		return 0;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main(){
	int n;
	cin >> n;
	cout << n * 800 - n / 15 * 200 << endl;
}


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

constexpr size_t m_gcd(size_t m, size_t n){
    if(m == 0){
        return n;
    }else if(n == 0){
        return m;
    }else{
        return m_gcd(n, m % n);
    }
}

int main(){

    size_t n;
    std::cin >> n;

    std::vector<size_t> a(n);
    for(auto&& e : a){
        std::cin >> e;
    }

    size_t ans = m_gcd(a.at(0), a.at(1));

    for(size_t i = 2; i < a.size(); i++){
        ans = m_gcd(ans, a.at(i));
    }

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

    return 0;
}


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

int main() {

  int N;
  cin >> N;

  set<int> even;
  for (int i = 0; i < N; i++) {
    int n_;
    cin >> n_;
    if (n_ % 2 == 0){
      even.insert(n_);
    }
  }

  string answer = "APPROVED";
  for(auto item:even) {
    if (item % 3 == 0 || item % 5 == 0) {
      answer = "APPROVED";
    } else {
      answer = "DENIED";
      break;
    }
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX (ll)(3e5 + 7)
#define INF (ll)(1e5 + 7)
#define MOD (int)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false);
#define LOG 20

using namespace std;
using ll = long long;

char ma[101][101];
vector<pair<int, int>> gr[MAX];
int dis[MAX];

int main () {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> ma[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int no = i * m + j;
			if (j + 1 < m) {
				gr[no].push_back (make_pair (i * m + j + 1, (ma[i][j] == '.' && ma[i][j + 1] == '#')));
			}
			if (i + 1 < n) {
				gr[no].push_back (make_pair ((i + 1)  * m + j, (ma[i][j] == '.' && ma[i + 1][j] == '#')));
			}
		}
	}
	fill (dis, dis + MAX, MOD);
	dis[0] = ma[0][0] == '#';
	priority_queue<int, vector<int>, greater <int>> pq;
	pq.push (0);	
	while (pq.size ()) {
		int no = pq.top ();
		pq.pop ();
		for (pair<int, int> x : gr[no]) {
			if (dis[x.first] > dis[no] + x.second) {
				dis[x.first] = dis[no] + x.second;
				pq.push (x.first);
			}
		}
	}
	cout << dis[(n - 1) * m + m - 1] << "\n";
}


Measured memory_bytes: 8832
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	if k > n{
		return
	}
	p := make([]int, n)
	for i:=0; i<n; i++{
		fmt.Scan(&p[i])
	}

	sort.Ints(p)

	sum := 0
	for i:=0; i<k; i++{
		sum += p[i]
	}

	fmt.Println(sum)
}

Measured memory_bytes: 1884
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		if(r < 1200) {
			System.out.println("ABC");
		} else if(r < 2800) {
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}
	}
}

Measured memory_bytes: 23764
import java.util.Scanner;

//A
//public class Main {
//	public static void main(String[] args) {
//		Scanner sc = new Scanner(System.in);
//		int ritsu = sc.nextInt();
//		double ans = 0;
//		ans = ritsu/2;
////		if(ritsu%2 != 0) {
////			ans = (ritsu/2);
////		} else {
////			ans = (ritsu/2);
////		}
//		System.out.println(1- (ans/ritsu));
//		//		// Scannerクラスのインスタンスをクローズ
//				sc.close();
//	}
//}

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int man = sc.nextInt();
		int cm = sc.nextInt();
		int count = 0;
		for(int i = 0; i < man; i++) {
			int oneMan = sc.nextInt();
			if(cm <= oneMan) {
				count++;
			}
		}
		System.out.println(count);
		//		// Scannerクラスのインスタンスをクローズ
		sc.close();
	}
}

Measured memory_bytes: 48708
n = int(input())
a = []
howmany = [[0] * (19) for _ in range(19)]
for i in range(n):
    x = input()
    len_x = len(x)
    if '.' in x:
        idx = x.index('.')
        x = int(x.replace('.', '') + '0' * (9 - len_x + idx + 1))
    else:
        x = int(x)
        x = x * 10 ** 9
    #print(x)
    cnt_2, cnt_5 = 0, 0
    while x % 2 == 0:
        x //= 2
        cnt_2 += 1
    while x % 5 == 0:
        x //= 5
        cnt_5 += 1
    cnt_2 = min(cnt_2, 18)
    cnt_5 = min(cnt_5, 18)
    howmany[cnt_2][cnt_5] += 1
    a.append((cnt_2, cnt_5))

for i in range(18, -1, -1):
    for j in range(18, 0, -1):
        howmany[i][j-1] += howmany[i][j]

for j in range(18, -1, -1):
    for i in range(18, 0, -1):
        howmany[i-1][j] += howmany[i][j]

#print(*howmany, sep='\n')

cnt = 0
for i in range(n):
    l, r = a[i]
    if l >= 9 and r >= 9:
        cnt += howmany[18-l][18-r] - 1
    else:
        cnt += howmany[18-l][18-r]


print(cnt // 2)

Measured memory_bytes: 87760
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint h(n,0);
    REP(i,n){
        cin >> h[i];
    }
    int high = h[0];
    int ans = 1;
    for(int i=1;i<n;i++){
        if(h[i]>=high){
            ans++;
            high=h[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,a[1001];
int main() {
	cin>>n>>m;
	int sum=0;
	for(int i=1;i<=n;i++)
		cin>>a[i],sum+=a[i];
	int cnt=0;
	for(int i=1;i<=n;i++)
	if(a[i]*4*m>=sum)
	cnt++;
	if(cnt>=m) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.io.PrintWriter;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        final String s;

        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            s = reader.readLine();
        }

        PrintWriter out = new PrintWriter(System.out);

        final String[] sl = s.split(" ");
        int X = Integer.parseInt(sl[0]);

        out.println(X == 7 || X == 5 || X == 3 ? "YES" : "NO");

        out.flush();
    }
}


Measured memory_bytes: 22484