akhauriyash/Code-Regression huggingface dataset:
from itertools import combinations, count
 
n = int(input())
r = range(n)
a = [(set(), set()) for _ in r]
for i in r:
    for _ in range(int(input())):
        x, y = map(int, input().split())
        a[i][y].add(x - 1)
ans = next(i for i in count(n, -1) for x in map(set, combinations(r, i))
           if all(a[j][0].isdisjoint(x) and a[j][1] < x for j in x))
print(ans)

Measured memory_bytes: 58204
#include<cstdio>

int main(){
    //printf("%lld\n",50ll*10000000000000000ll);
    long long x;
    scanf("%lld",&x);
    long long n = 50;
    long long cnt = x/n, left = x%n;
    printf("%lld\n",n);
    for(int i = 1; i <= n; i++){
        if(i<=left) printf("%lld ",cnt+n-1-(left-1)+n);
        else printf("%lld ",cnt+n-1-left);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define MAX 200005
#define INF (1<<26)
 
int segN=1000000;
struct data{
  int value;
  data* ch[2];
  
  void init(){
    value=INF;
    ch[0]=(data*)malloc(sizeof(data));
    ch[1]=(data*)malloc(sizeof(data));
    ch[0]->ch[0]=NULL;
    ch[1]->ch[0]=NULL;
  }
   
  void set(int i,int x,int l,int r){
    int m=(l+r)/2;
    if(ch[0]==NULL)init();
    if(i<l || r<=i)return;
    if(x<value)value=x;
    if(r-l==1)return;
    ch[0]->set(i,x,l,m);
    ch[1]->set(i,x,m,r);
  }
    
  void set(int i,int x){
    set(i,x,0,segN);
  }
    
  int min(int a,int b,int l,int r){
    int m=(l+r)/2;
    if(ch[0]==NULL)init();
    if(b<=l || r<=a)return INF;
    if(a<=l && r<=b)return value;
    int lc=ch[0]->min(a,b,l,m);
    int rc=ch[1]->min(a,b,m,r);
    return (lc<rc?lc:rc);
  }
  
  int min(int a,int b){
    if(0<=a&&a<b)return min(a,b,0,segN);         
    else return INF;
  }
};
  
  
    
  
  
  
  
  
 
 
int rak[MAX+1];
int tmp[MAX+1];
int n,k;
 
bool compare_sa(int i,int j){
  if(rak[i]!=rak[j])return (rak[i]<rak[j]);
  else{
    int ri=(i+k<=n?rak[i+k]:-1);
    int rj=(j+k<=n?rak[j+k]:-1);
    return ri < rj;
  }
}
 
void construct_sa(string s,int *sa){
  n=s.size();
  for(int i=0;i<=n;i++){
    sa[i]=i;
    rak[i]=(i<n?s[i]:-1);
  }
  for(k=1;k<=n;k*=2){
    sort(sa,sa+n+1, compare_sa );
    tmp[sa[0]]=0;
    for(int i=1;i<=n;i++){
      tmp[sa[i]]=tmp[sa[i-1]]+
        (compare_sa(sa[i-1],sa[i])?1:0);
    }
    for(int i=0;i<=n;i++)rak[i]=tmp[i];
  }
}
 
 
int search(string &target,int *sa,string &s){
  int l=0,r=n,m;
  int size=target.size(),res;
  while(l<r){
    m=(l+r)/2;
    res=s.compare(sa[m],size,target);
    if(res>=0)r=m;
    else l=m+1;
  }
  if(s.compare(sa[l],size,target)<0)return n+1;
  return l;
}
 
int search2(string &target,int *sa,string &s){
  int l=0,r=n,m;
  int size=target.size(),res;
  while(l<r){
    m=(l+r)/2;
    res=s.compare(sa[m],size,target);
    if(res>0)r=m;
    else l=m+1;
  }
  if(s.compare(sa[l],size,target)<=0)return n+1;
  return l;
}
 
data T,T2;
string s,s2;
string x,y;
int m;
int sa[MAX+1];
int sa2[MAX+1];
 
int main(){
  ios::sync_with_stdio(false);
    
  T.init();
  T2.init();

  cin>>s;
  s2=s;
  reverse(s2.begin(),s2.end());
   
  construct_sa(s2,sa2);
  construct_sa(s,sa);
 
  for(int i=0;i<=n;i++){
    //cout<<i<<' '<<sa[i]<<' '<<s.substr(sa[i])<<endl;
  }
  for(int i=0;i<=n;i++){
    //cout<<i<<' '<<sa2[i]<<' '<<s2.substr(sa2[i])<<endl;
  }
   
  for(int i=0;i<=n;i++){
    T.set(i,sa[i]);
    T2.set(i,sa2[i]);
  }
   
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>x>>y;
    reverse(y.begin(),y.end());
    int xl=search(x,sa,s),xr=search2(x,sa,s);
    int yl=search(y,sa2,s2),yr=search2(y,sa2,s2);
    int xs=x.size();
    int X=T.min(xl,xr);
    int Y=T2.min(yl,yr);
    if(Y!=INF)Y=n-Y;
     
    //cout<<xl<<' '<<xr<<' '<<X<<endl;
    //cout<<yl<<' '<<yr<<' '<<Y<<endl;
 
    if(Y<X+xs)cout<<0<<'\n';
    else if(X==INF||Y==INF)cout<<0<<'\n';
    else cout<<Y-X<<'\n';
     
  }
     
  return 0;
}

Measured memory_bytes: 55112
#include<cstdio>
#include<algorithm>
using namespace std;

double a[20],b[20],c[20];
double dist[20][32];
double squ(double x){return x*x;}
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%lf %lf %lf",a+i,b+i,c+i);
	}
	if(m==0){
		printf("%.5f\n",0.);
		return 0;
	}
	for(int i=0;i<n;i++)
 		for(int j=i+1;j<n;j++)
 			dist[i][j]=squ(a[i]-a[j])+squ(b[i]-b[j])+squ(c[i]-c[j]);
	double ans=0;
	int comb = (1 << m) - 1;
	while (comb < 1 << n) {
		double sum=0;
 		for(int i=0;i<n;i++){
 			if((comb>>i&1)^1)continue;
 			for(int j=i+1;j<n;j++){
 				if(comb>>j&1)sum += dist[i][j];
 			}
 		}
		ans=max(ans,sum);
  		int x = comb & -comb, y = comb + x;
  		comb = ((comb & ~y) / x >> 1) | y;
	}
	printf("%.5f\n",ans);
	return 0;
}

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

int main()
{
    int D;
    cin >> D;
    int c[26];
    int sd[D][26];
    for (int i = 0; i < 26;i++)
        cin >> c[i];
    for (int i = 0; i < D;i++){
        for (int k = 0; k < 26;k++){
            cin>>sd[i][k];
        }
    }
    int ans[D];
    ans[0] = 0;
    int lastDay[26];
    for (int i = 0; i < 26;i++){
        lastDay[i] = 0;
    }
    int select = 0;
    int tmp = 0;
    for (int i = 0; i < D; i++){
        for (int k = 0; k < 26;k++)
            if (tmp!=max(tmp, sd[i][k])){
                tmp = max(tmp, sd[i][k]);
                select = k;
            }
        ans[i] = select + 1;
        tmp = 0;
    }
    for (int i = 0; i <D;i++)
        cout << ans[i] << endl;
}



Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){ 
 int N; cin >> N; ll K; cin >> K;
  vector<ll> A(N); for(int i = 0; i < N; i++){ cin >> A[i];}
  vector<ll> S(N+1,0);
  
  for(int i = 0; i < N; i++){ S[i+1] = S[i]+A[i];}
  for(int i = 0; i <= N; i++){ S[i] -= i;}
  for(int i = 0; i <= N; i++){ S[i] %= K;} 
  
  map<ll,ll> mp;
  ll ans = 0; 
  for(int i = 0; i <= N; i++){ 
    
    //次にansにカウントしていく
    ans += mp[S[i]];
    // mpに追加
    mp[S[i]]++;
    
    if(i-K+1>=0){ mp[S[i-K+1]]--;}
  }
  
  cout << ans << endl; return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
double n,t,a,b;
int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      cin>>a>>b;
      ll ans=-1;
      for(int i=1;i<100000;i++)
      {
          double x=i*(0.08);
          double y=i*(0.1);
          if((ll)x==a&&(ll)y==b){ans=i;break;}
      }
      cout<<ans<<endl;
}

Measured memory_bytes: 256
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()
def factorization(n):
  res = []
  if n%2==0:
    res.append(2)
  for i in range(3,math.floor(n//2)+1,2):
    if n%i==0:
      c = 0
      for j in res:
        if i%j==0:
          c=1
      if c==0:
        res.append(i)
  if len(res)==0:
    res = [n]
  return res
def fact2(n):
  p = factorization(n)
  res = []
  for i in p:
    c=0
    z=n
    while 1:
      if z%i==0:
        c+=1
        z/=i
      else:
        break
    res.append([i,c])
  return res
def fact(n):#階乗
  ans = 1
  m=n
  for _i in range(n-1):
    ans*=m
    m-=1
  return ans
def comb(n,r):#コンビネーション
  if n<r:
    return 0
  l = min(r,n-r)
  m=n
  u=1
  for _i in range(l):
    u*=m
    m-=1
  return u//fact(l)
def combmod(n,r,mod):
  return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
  r=copyQueue(q)
  ans=[0]*r.qsize()
  for i in range(r.qsize()-1,-1,-1):
    ans[i] = r.get()
  print(ans)
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1]*n

  def find(self, x): # root
    if self.parents[x]<0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self,x,y):
    x = self.find(x)
    y = self.find(y)

    if x==y:
      return

    if self.parents[x]>self.parents[y]:
      x,y = y,x

    self.parents[x]+=self.parents[y]
    self.parents[y]=x

  def size(self,x):
    return -1*self.parents[self.find(x)]

  def same(self,x,y):
    return self.find(x)==self.find(y)

  def members(self,x): # much time
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i)==root]

  def roots(self):
    return [i for i,x in enumerate(self.parents) if x<0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
  x = 1
  zero = "0"*n
  ans = []
  ans.append([0]*n)
  for i in range(2**n-1):
    ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
    x+=1
  return ans;
def arrsSum(a1,a2):
  for i in range(len(a1)):
    a1[i]+=a2[i]
  return a1
def maxValue(a,b,v):
  v2 = v
  for i in range(v2,-1,-1):
    for j in range(v2//a+1): #j:aの個数
      k = i-a*j
      if k%b==0:
        return i
  return -1
def copyQueue(q):
  nq = queue.Queue()
  n = q.qsize()
  for i in range(n):
    x = q.get()
    q.put(x)
    nq.put(x)
  return nq
def get_sieve_of_eratosthenes(n):
  data = [2]
  #data = [0,0,0]
  for i in range(3,n+1,2):
    data.append(i)
    data.append(0)
  for i in range(len(data)):
    interval = data[i]
    if interval!=0:
      for j in range(i+interval,n-1,interval):
        data[j] = 0
  ans = [x for x in data if x!=0]
  #ans = data[:]
  return ans


a,b = readInts()

#print(a+b)
print(a*b)

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, M; cin >> N >> M;
    if(N >= M/2) cout << M/2 << endl;
    else{
        M -= N*2;
        cout << N + M/4 << endl;
    }
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <list>
#include <array>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <random>
#include <chrono>

#define PI 3.14159265359
#define mt make_tuple
#define mp make_pair
#define pii pair <int, int>
#define pll pair <long long, long long>
#define all(x) (x).begin(), (x).end()

//mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());

using namespace std;

int main()
{
	int A, B, V, W, T;
	cin >> A >> V;
	cin >> B >> W;
	cin >> T;
	if (V <= W)
		cout << "NO\n";
	else
	{
		if (1.0 * abs(A - B) / (V - W) > T)
			cout << "NO\n";
		else
			cout << "YES\n";
	}
	return 0;
}



Measured memory_bytes: 3156
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];


int main(){
    int a,b;
    cin >> a >> b;
    if(a<b){
        for(int i=0; i<b; i++)cout << a;
        cout << endl;
    }else{
        for(int i=0; i<a; i++)cout << b;
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  char c='1';
  int r=s.size();
  rep(i,n){
    if(c==s[i])r--;
    c=s[i];
  }
  cout << r << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc = new Scanner(System.in);
	int a, b, c, d;
	public void run(){
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		d = sc.nextInt();
		
		solve();
	}
	public void solve(){
		if(Math.abs(c - a) <= d ){
			System.out.println("Yes");
		}
		else if(Math.abs(b - a) <= d &&Math.abs( c - b) <= d){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
	static class Pair {
        int first,second;
        public Pair(int a,int b) {
            this.first = a;
            this.second = b;
        }
    }	
}


Measured memory_bytes: 21716
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		int sum = 0;
 
		for(int i=0; i<N; i++){
			a[i] = sc.nextInt();
			sum += a[i]-1;
		}
 
		System.out.println(sum);
	}
}

Measured memory_bytes: 25772
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	long[] cache = new long[100];

	void solve() {
		int n = readNum();
		long ans = calc(n);
		pln(ans);
	}

	long calc(int n) {
		if (n == 0)
			return 2;
		else if (n == 1)
			return 1;
		if (cache[n] > 0)
			return cache[n];
		long ans = calc(n - 2) + calc(n - 1);
		cache[n] = ans;
		return ans;
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

ll modPow(ll x, ll n, ll mod) {
  ll res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  int n, p;
  cin >> n >> p;
  string s;
  cin >> s;

  reverse(all(s));

  if (p == 2 || p == 5) {
    ll ans = 0;
    ll cnt = 0;
    rep(i, s.size()) {
      int d = s[i] - '0';
      if (d % p == 0) cnt++;
      ans += cnt;
    }
    cout << ans << endl;
    return 0;
  }

  ll ans = 0;
  ll tmp = 0;
  map<ll, ll> cnt;
  cnt[tmp] = 1;
  rep(i, s.size()) {
    int d = s[i] - '0';
    tmp = (tmp + modPow(10, i, p) * d) % p;
    ans += cnt[tmp];
    cnt[tmp]++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1028
#include <stdio.h>

int main(void){  
  int n,i,j,res[7];
  double a;
  char b='*';
     
  res[1]=0;  
  res[2]=0;
  res[3]=0;
  res[4]=0;
  res[5]=0;
  res[6]=0;
  
  scanf("%d",&n);
  
  for(i=1;i<n+1;i++){
    
    scanf("%lf",&a);
    
    if( a < 165.0 ){
      res[1]=res[1]+1;
    }
    else if( a >= 165.0 && a < 170.0 ){
      res[2]=res[2]+1;
    }
    else if( a >= 170.0 && a < 175.0 ){
      res[3]=res[3]+1;
    }
    else if( a >= 175.0 && a < 180.0 ){
      res[4]=res[4]+1;
    }
    else if( a >= 180.0 && a < 185.0 ){
      res[5]=res[5]+1;
    }
    else{
      res[6]=res[6]+1;
    }
  }
  
  for( n=1 ; n<7 ; n++ ){
    printf("%d:",n);

    j=1;    
    while( j < res[n]+1 ){
      printf("%c",b);
      j = j + 1;
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>

using namespace std; 

typedef long long LL;

const long long INF = 1e9+7; 

long long pow(LL a, LL b){
	long long res = 1;
	while(b){
		if(b & 1){
			res = res * a % INF; 
		}
		a = a * a % INF;
		b >>= 1;
	}
	return res;
}
int main(int argc, char** argv) {
	LL n;
	cin >> n;
	cout << ((pow(10ll,n) -2 * pow(9ll,n) +pow(8ll,n)) % INF + INF) % INF << endl;
	
	
}

Measured memory_bytes: 3172
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

typedef double Real;

const Real EPS = 1e-8;

int sign(Real d){
	return d > EPS ? 1 : d < -EPS ? -1 : 0;
}

struct Point{
	Real x,y;
	
	Point(Real x_ = 0,Real y_ = 0):x(x_),y(y_){}

	Point operator+(const Point &p) const {return Point(x+p.x,y+p.y);}
	Point operator-(const Point &p) const {return Point(x-p.x,y-p.y);}
	Point operator*(Real s) const {return Point(x*s,y*s);}
	Point operator/(Real s) const {return Point(x/s,y/s);}
	bool operator<(const Point &p) const{return sign(x-p.x) == -1 || (sign(x-p.x) == 0 && sign(y-p.y) == -1);}
	bool operator==(const Point &p) const{return sign(x-p.x) == 0 && sign(y-p.y) == 0;}

};

istream &operator>>(istream &is,Point &p){return is >> p.x >> p.y;}//??\???????°???????
ostream &operator<<(ostream &os ,const Point &p){return os << '(' << p.x << ", " << p.y << ')';}//??????????°???????

struct Segment : public array<Point,2>{
	Segment(const Point &a,const Point &b){	at(0) = a; at(1) = b;}
};

struct Line : public array<Point,2>{
	Line(const Point &a,const Point &b){at(0) = a; at(1) = b;}
};

struct Circle{
	Point c;
	Real r;

	Circle(const Point &c_, Real r_):c(c_),r(r_){}
};

typedef vector<Point> Polygon;



Point rotate90(const Point &p){
	return Point(-p.y,p.x);
}

Point rotate(const Point &p,Real theta){
	const Real s = sin(theta),c = cos(theta);
	return Point(c*p.x-s*p.y,s*p.x+c*p.y);
}

Real angle(const Point &p){
	return atan2(p.y,p.x);
}

Real dot(const Point &a,const Point &b){ //??????????????????
	return a.x*b.x+a.y*b.y;
}

Real cross(const Point &a,const Point &b){ //??????????????????
	return a.x*b.y-a.y*b.x;
}

bool intersect(const Line &a,const Line &b){ //????????????
	return sign(cross(a[1]-a[0],b[1]-b[0])) != 0
		||	sign(cross(a[1]-a[0],b[1]-a[0]) == 0);
}

Real norm(const Point &p){
	return p.x*p.x+p.y*p.y;
}

Real abs(const Point &p){
	return sqrt(norm(p));
}

int main(){
	Point p0,p1;
	int q;
	
	cout.setf(ios::fixed);
	cout.precision(10);

	cin >> p0 >> p1;
	cin >> q;
	rep(i,q){
		Point p2;
		cin >> p2;
		Line l1(p0,p1);
		Real t = dot(p2-l1[0], l1[1]-l1[0]) / norm(l1[0] - l1[1]);
		Point ans = l1[0] + (l1[1] - l1[0]) * t;
		cout << ans.x << " " << ans.y << endl;
	}

	return 0;
}

Measured memory_bytes: 1296
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
#include<vector>
using namespace std;
long long  mod = 1000000007;

struct edge {
	int to, cost;
};
vector<int> G[100010];

/*int gcd(int a, int b) {
	if (a < b) return gcd(b, a);
	else if (b == 0) return a;
	else return gcd(b, a % b);
}*/
int d[100010][2];
void dfs(int T,int v, int parent) {
	for (auto to : G[v]) {
		if (to == parent)
			continue;
		d[to][T] = (d[v][T]) + 1;
		dfs(T, to, v);
	}
}

int main()
{

	int N, a, b;
	scanf("%d", &N);
	for (int i = 0; i < N - 1; i++) {
		scanf("%d%d", &a, &b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(0,1, -1);
	dfs(1, N, -1);
	int f = 0, s = 0;
	for (int i = 1; i <= N; i++) {
		if (d[i][0] <= d[i][1]) {
			f++;
		}
		else {
			s++;
		}
	}
	if (f > s) {
		printf("Fennec");
	}
	else {
		printf("Snuke");
	}
	return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h> //g++-9で実行（gcc version 9.3.0），g++だとデフォルトのclang

using namespace std;

//#define int long long                         //intでオーバフローした時の切り替え用
#define debug(x) cerr << #x << ": " << x << endl //エラー出力として変数名と変数の中身表示
#define DEBUG_VEC(v)                   \
    cerr << #v << ":";                 \
    for (int i = 0; i < v.size(); i++) \
        cerr << " " << v[i];           \
    cerr << endl;
#define DEBUG_MAT(v)                          \
    cerr << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cerr << v[i][j] << " ";           \
        }                                     \
        cerr << endl;                         \
    }
#define Sp(p) cout << setprecision(25) << fixed << p << endl; //小数点以下を25桁で表示
#define all(obj) (obj).begin(), (obj).end()
#define pb push_back

//usingエイリアス（別名という意味，型定義のこと）
using ll = long long;
//template <class T> using Vec = std::vector<T>;//エイリアステンプレート

const ll MOD = (ll)1e9 + 7;
//const ll MOD = 998244353;
const ll INF = (ll)1e18 + 1;
const double EPS = 1e-9;
const long double pi = 3.1415926535897932384626433832795028841971L;

//マクロでintをlong longと定義したときはsinged
int main()
{
    cin.tie(0);                  //cinとcoutの同期を切る（高速化)
    ios::sync_with_stdio(false); //iostreamとstdioの同期を切る（高速化)

    ll n;
    cin >> n ;

    ll tmp = n%10;
    if (tmp == 3) cout << "bon" << endl;
    else if (tmp == 0 || tmp == 1 || tmp == 6 || tmp == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
    return 0;
}

Measured memory_bytes: 3628
using System;
class Program
 {
        static void Main(string[] args)
        {
    　　int a,b;
            string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            string[] str2 = Console.ReadLine().Split(' ');
            a = int.Parse(str2[0]);  //数値で受け取りたい場合は変換する
            b = int.Parse(str2[1]);
            string u = Console.ReadLine();
          
          	if( u == str[0] ){
              Console.WriteLine("{0} {1}", a-1,b);         
            }
          	else{
              Console.WriteLine("{0} {1}", a, b-1);
            }
        }
 }

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s,t;
	cin>>s>>t;
	ll a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(s==u){
		a--;
	}
	else{
		b--;
	}
	cout << a<<" "<<b;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3604
/**
*    author:  y_takano
*    created: 19.06.2020 16:53:48
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

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

using namespace std;

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

  int r, c, tmp;
  cin >> r >> c;

  int a[r + 1][c + 1] = {0};

  a[0][c] = 0;

  REP(i, r)
  {
      REP(j, c)
      {
          cin >> tmp;
          a[i][j] = tmp;
          a[i][c] += tmp;
          a[r][j] += tmp;
          a[r][c] += tmp;
      }
  }

  REP(i, r + 1)
  {
      REP(j, c)
      {
          cout << a[i][j] << ' ';
      }
      cout << a[i][c] << endl;
  }

  return 0;
}


Measured memory_bytes: 3204
#include <stdio.h>

#define MAX 100000
typedef long long ll;

int check(ll,ll*,int,int);

int main(){
  int n,k,i;
  ll lb,ub,mid,w[MAX],sum = 0;

  scanf("%d%d" ,&n ,&k);
  for(i = 0 ; i < n ; i++){
    scanf("%lld" ,&w[i]);
    sum += w[i];
  }

  lb = 0, ub = sum;
  while(ub - lb > 0){
    mid = (lb + ub) / 2;

    if(check(mid,w,n,k)){
      ub = mid;
    }else{
      lb = mid+1;
    }
  }
  printf("%lld\n" ,ub);

  return 0;
}

int check(ll limit,ll w[],int n,int k){
  int i,kk = 0;
  ll sum = 0;

  for(i = 0 ; i < n ; i++){
    if(limit < w[i]) return 0;
    sum += w[i];

    if(sum == limit){
      kk++;
      sum = 0;
    }else if(sum > limit){
      kk++;
      sum = w[i];
    }
  }

  if(sum > 0){
    kk++;
  }

  return kk <= k;
}

Measured memory_bytes: 1380
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

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

	cin >> N >> M;
	K = power(2, M, MOD);
	vector<vector<long long int>>dp(N, vector<long long int>(N, 0));
	vector<vector<long long int>>ch(N, vector<long long int>(N, 0));
	vector<long long int>rev_by(N + 1, 1);
	for (int i = 1; i <= N; i++) {
		rev_by[i] = rev_by[i] * power(2, MOD - 2, MOD);
		rev_by[i] %= MOD;
	}
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (v[i] > v[j])dp[i][j] = K;
		}
	}
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		L--;
		R--;
		for (int j = 0; j < N; j++) {
			if (j == L || j == R)continue;
			long long int sum = dp[L][j] + dp[R][j];
			sum %= MOD;
			sum *= rev_by[1];
			sum %= MOD;
			ch[R][j] = ch[L][j] = sum;
			sum = dp[j][L] + dp[j][R];
			sum %= MOD;
			sum *= rev_by[1];
			sum %= MOD;
			ch[j][R] = ch[j][L] = sum;
		}
		for (int j = 0; j < N; j++) {
			if (j == L || j == R)continue;
			dp[R][j] = dp[L][j] = ch[L][j];
			dp[j][R] = dp[j][L] = ch[j][L];
		}
		dp[L][R] = dp[R][L] = (((dp[L][R] + dp[R][L])%MOD)*rev_by[1]) % MOD;
	}
	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++)ans += dp[i][j];
	}
	cout << ans % MOD << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int n; cin >> n;
	vector<int> X(n);
	int sum = 0;
	for (int i=0; i<n; i++) {
		int x; cin >> x;
		X[i] = x;
		sum += x;
	}
	int p1 = sum / n;
	int p2 = (sum + (n - 1)) / n;
	ll ret1 = 0, ret2 = 0;
	for (int i=0; i<n; i++) {
		ret1 += pow(X[i] - p1, 2);
		ret2 += pow(X[i] - p2, 2);
	}
	if (ret1<=ret2) cout << ret1 << endl;
	else cout << ret2 << endl;
	return 0;
}

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

n = int(input())

memo = [[0 for i in range(19)] for j in range(19)]
for i in range(n):
    ai = input().rstrip('\n')
    if '.' in ai:
        a1, a2 =  ai.split('.')
        a2 = a2 + '000000000'
        ai = a1 + a2[:9]
    else:
        ai = ai + '000000000'
    ai = int(ai)
    c2 = 0
    c5 = 0
    while True:
        if ai % 2 or c2 == 18:
            break
        ai = ai // 2
        c2 += 1
    while True:
        if ai % 5 or c5 == 18:
            break
        ai = ai // 5
        c5 += 1
    memo[c2][c5] += 1

ans1 = 0
ans2 = 0


for i in range(19):
    for j in range(19):
        for k in range(19):
            for l in range(19):
                if i + k >= 18 and j + l >= 18:
                    if i != k or j != l:
                        ans2 += memo[i][j] * memo[k][l]
                    else:
                        ans1 += max(memo[i][j] * (memo[k][l]-1), 0)

print(ans2 // 2 + ans1 // 2)


    



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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int a1,a2,a3; cin >> a1 >> a2 >> a3;
    int ans=a1+a2+a3;
    if(ans>=22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long D = sc.nextLong();
		long E = sc.nextLong();
		sc.close();
		long min = Long.MAX_VALUE;
		int index = 0;
		long[] trans = new long[] {A,B,C,D,E};
		for(int i = 0;i < 5;i++) {
			min = Math.min(min, trans[i]);
			if(min == trans[i]) {
				index = i+1;
			}
		}
		long btm = N%min==0 ? N/min : N/min + 1;
		System.out.println(btm + 4);
	}
}

Measured memory_bytes: 21972
n, k = map(int, input().split())

def main():
    max = (n-1)*(n-2)//2
    if max < k:
        print(-1)
        return 0
    add = max - k
    m = n-1 + add
    print(m)
    for i in range(2,n+1):
        print(1, i)
    for i in range(2, n+1):
        for j in range(i+1, n+1):
            if add <= 0:
                return 0
            print(i, j)
            add -= 1

main()

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

int main(){
	int n,t,a;
	cin >> n >> t >> a;
	vector<int> h(n);

	double ans = __INT_MAX__;
	rep(i, n){
		cin >> h.at(i);
		ans = min(ans, abs(a - (t-h.at(i)*0.006)));
	}

	rep(i, n){
		if(abs(a - (t-h.at(i)*0.006)) == ans){
			cout << i+1 << endl;
			break;
		}
	}
}

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

using namespace std;

namespace {

#define VERA(i, a, b)for(auto i=(ll)(a);i<(ll)(b);++i)
#define ANDY(i, a, b)for(auto i=(ll)(a);i>(ll)(b);--i)

typedef long long ll;
typedef double dd;

template <class T> inline ll Size(const T& x) { return x.size(); }

bool Solve(ll test_num) {
  (void) test_num;
  ll x, y;
  cin >> x >> y;
  ll res = x;
  VERA(i, 1, 1000) {
    if (res % y) {
      cout << res << endl;
      return false;
    }
    res += x;
    if (res > ll(1e18))
      break;
  }
  cout << "-1" << endl;
  return false;
}

void Init() {
}

}

int main() {
#ifdef AZN
  const auto start_time = chrono::system_clock::now();
  freopen("../input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand(1223);
  Init();
  ll test = 1;
  while (true)
    if (not Solve(test++))
      break;
#ifdef AZN
  cerr << "Took: " << ((chrono::system_clock::now() - start_time).count() /
                       static_cast<double>(chrono::system_clock::period::den)) << " s" << endl;
#endif
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <set>
#include <algorithm>
#include <iterator>

using namespace std;
int main()
{
    int n, m, tmp;
    set<int> a, b, result;
    cin >> n;
    for (int i=0; i<n; ++i){
        cin >> tmp;
        a.insert(tmp);
    }
    cin >> m;
    for (int i=0; i<m; ++i){
        cin >> tmp;
        b.insert(tmp);
    }
    set_symmetric_difference(a.begin(), a.end(), b.begin(), b.end(), inserter(result, result.end()));
    for (auto itr=result.begin(); itr != result.end(); ++itr){
        cout << *itr << endl;
    }
}


Measured memory_bytes: 40584
def solve():
    n = int(input())
    ans = 0
    for i in range(n):
        x, u = input().split()
        x = float(x)
        if u == 'JPY':
            ans += x
        else:
            ans += x * 380000
    print(ans)



if __name__ == '__main__':
    solve()


Measured memory_bytes: 9164
#include <stdio.h>

int main( void )
{
	int i, x;
	
	scanf( "%d", &x );
	
	for( i = 1; x != 0; i++ ){
		printf( "Case %d: %d\n", i, x );
		scanf( "%d", &x );
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FOR(i, 1, n + 1)

template <class T>
bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

template <class T>
bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}

//a,bの最大公約数
ll gcd(ll a, ll b)
{
	ll temp;
	while (a % b != 0)
	{
		temp = a;
		a %= b;
		b = temp;
	}
	return b;
}

//a,bの最小公倍数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}

const ll INF = 1LL << 60;
const int MAX_NM = 1e5 + 10;

string s;
char a, b;
int ca, cb;

int main()
{
	cin >> s;
	a = s[0];
	b = '0';
	bool ans = true;
	for (char x : s)
	{
		if (a == x)
		{
			++ca;
		}
		else if (b == x)
		{
			++cb;
		}
		else if (b == '0')
		{
			b = x;
			++cb;
		}
		else
		{
			ans = false;
			break;
		}

		if (ca > 2 || cb > 2)
		{
			ans = false;
			break;
		}
	}

	if (ans)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
function Main(input) {
	const input = input.split("\n");
    const tmp = input[0].split(" ");
	const a = parseInt(tmp[0], 10);
	const b = parseInt(tmp[1], 10);
	const n = b-a+1;
	if ((a<=0&&b>=0)||a==0||b==0) {
        console.log("Zero");
	} else {
		if (a>0||n%2==0) {
    	    console.log("Positive");
		} else {
    	    console.log("Negative");
		}
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define ld long double
#define zeros(x) x^(x-1)&x
#define pii pair<ll,ll>
#define cd complex<double>
#define dbg(x) cerr<<#x<<": "<<x<<endl;ll
#define Nmax 400005
#define OFF 100001
#define MOD 1000000007
using namespace std;

ll n, s, v[Nmax], d[Nmax], x, nr;

int main()
{
    cin >> n;
    for (int i=0;i<n;i++){
        cin >> v[i];
        s += v[i];
    }
    x = n * (n+1) / 2;
    if (s % x){
        cout << "NO\n";
        return 0;
    }
    x = s / x;

    for (int i=0;i<n;i++){
        d[i] = x - (v[(i+1) % n] - v[i]);
        if (d[i] < 0 || d[i] % n){
            cout << "NO\n";
            return 0;
        }
        nr += d[i] / n;
    }
    if (nr != x) cout << "NO\n";
    else cout << "YES\n";


    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = 2e9;

int main() {
  int N, C; cin >> N >> C;
  int ans = INF;
  vvi D(C, vi(C));
  vvi counts(3, vi(C));
  for (int i = 0; i < C; i++) {
    for (int j = 0; j < C; j++) {
      cin >> D[i][j];
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      int c; cin >> c;
      counts[(i+j)%3][c-1]++;
    }
  }
  for (int i = 0; i < C; i++) {
    for (int j = 0; j < C; j++) {
      if (i == j) continue;
      for (int k = 0; k < C; k++) {
        if (k == i || k == j) continue;
        int sum = 0;
        for (int l = 0; l < C; l++) {
          sum += counts[0][l] * D[l][i];
        }
        for (int l = 0; l < C; l++) {
          sum += counts[1][l] * D[l][j];
        }
        for (int l = 0; l < C; l++) {
          sum += counts[2][l] * D[l][k];
        }
        ans = min(ans, sum);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

if C<D:
  c, d = C, D
else:
  c, d = D, C
while d%c!=0:
  c, d = d%c, c
lcm = C*D//c

ans = (B-B//C-B//D+B//lcm)-(A-1-(A-1)//C-(A-1)//D+(A-1)//lcm)
print(ans)

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

int main(){
  int n,m,a,b,ans=0;
  cin>>n>>m;
  vector<int>h(101000);
  vector<int>c(101000,0);
  for(int i=0;i<n;i++){
    cin>>h.at(i);
  }
  for(int i=0;i<m;i++){
    cin>>a>>b;
    if(h.at(a-1)>=h.at(b-1))c.at(b-1)++;
    if(h.at(a-1)<=h.at(b-1))c.at(a-1)++;
  }
  for(int i=0;i<n;i++){
    if(c.at(i)==0)ans++;
  }
  cout <<ans;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cerr<<x<<endl;
#define endl "\n"
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
    //cout.tie(NULL);
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;

    vector<int>cnt(n+5,0);
    int t=0;
    cnt[1]=t;

    for(int i=1;i<n;i++)
    {
        if(s[i]=='C' && s[i-1]=='A')
            t++;

        cnt[i+1]=t;
    }

    for(int i=0;i<q;i++)
    {
        int l,r;
        cin>>l>>r;

        cout<<cnt[r]-cnt[l]<<endl;

    }


    return 0;
}


Measured memory_bytes: 1488
S = list(input())
a = int(S[0])*10 + int(S[1])
b = int(S[2])*10 + int(S[3])
flag1 = True
flag2 = True
if a > 12 or a == 0:
    flag1 = False
if b > 12 or b == 0:
    flag2 = False


if flag1 and flag2:
    print("AMBIGUOUS")
elif flag1 and not flag2:
    print("MMYY")
elif not flag1 and flag2:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <algorithm>


int main(){
    int N;
    std::cin >> N;
    
    int count_AC = 0;
    int count_WA = 0;
    int count_TLE = 0;
    int count_RE = 0;
    
    for (int i = 0;i < N;i++){
        std::string S;
        std::cin >> S;
        if (S == "AC"){
            count_AC++;
        }else if (S == "WA"){
            count_WA++;
        }else if (S == "TLE"){
            count_TLE++;
        }else if (S == "RE"){
            count_RE++;
        }
    }
    
    std::cout << "AC x " << count_AC << "\n";
    std::cout << "WA x " << count_WA << "\n";
    std::cout << "TLE x " << count_TLE << "\n";
    std::cout << "RE x " << count_RE << "\n";
}

Measured memory_bytes: 3540
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
#include <set>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };
const double PI = 3.14159265358979323846;

void cheak(vector<int> a);

int main() {

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a.at(i);
	}

	cheak(a);


	return 0;

}

void cheak(vector<int> a) {

	rep(i, size(a)) {

		if (a.at(i) % 2 == 0) {
			if (a.at(i) % 3 != 0 && a.at(i) % 5 != 0) {
				cout << "DENIED" << endl;
				break;
			}
		}
		if (i == (size(a) - 1)) cout << "APPROVED" << endl;
	}

}



Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> A;

int main() {
    string S, T;
    cin >> S >> T;

    int N = S.length(), M = T.length();
    int answer = M;
    for(int i = 0; i <= N-M; i++) {
        int match = 0;
        for(int j = i; j < i + M; j++) {
            if(S[j] == T[j-i]) {
                match++;
            }            
        }
        answer = min(answer, M - match);
    }
    
    cout << answer << "\n";

    return 0;
}

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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int n, k;
    cin >> n >> k;

    long ans = k;
    ans = ans * pow(k - 1, n - 1);
    cout << ans << endl;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int P, Q, R;
    cin >> P >> Q >> R;
    int ans = min(P + Q, P + R);
    ans = min(ans, Q + R);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;


public class Main{
	 public static void main(String[] args){
	   Scanner sc = new Scanner(System.in);
	  int a = sc.nextInt();
	  String s = sc.next();
	  if(a<3200) {
		  System.out.println("red");
	  }
	  else {
		  System.out.println(s);
	  }
	}
}

Measured memory_bytes: 24788
#include <iostream>
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  string s;
  cin >> s;
 
  long long sum = 0;
  int n = s.size();
 
  for(int temp=0;temp<(1<<n-1);temp++){
    long long t = s[0] - '0';
    //cout << temp << endl;
    for(int i=0;i<(n-1);i++){
      if( temp & (1<<i) ){
        sum += t;
        t = s[i+1] - '0';
      }
      else{
        t *= 10;
        t += s[i+1] - '0';
      }
    }
    sum += t;
 
  }
 
  cout << sum <<endl;
 
 
  return 0;
}

Measured memory_bytes: 256
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        p: [usize;n]
    }

    let mut ans = 1;
    let mut min = p[0];
    for i in 1..n {
        if p[i] <= min {
            ans += 1;
            min = p[i];
        }
    }

    println!("{}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 10620
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
long long n,m,x[100005],y[100005],ans,sum[200005],maxx[200005],maxn[200005];
int main(){
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++)scanf("%lld%lld",&x[i],&y[i]);
    for(int i=1;i<=n;i++){
    	sum[i]=sum[i-1]+y[i];
	}
	for(int i=n;i>=1;i--){
		maxx[i]=max(maxx[i+1],(sum[n]-sum[i-1])-(m-x[i]));
	}
	for(int i=1;i<=n;i++){
		maxn[i]=max(maxn[i-1],sum[i]-x[i]);
	}
    for(int i=1;i<=n;i++){
    	ans=max(ans,max(sum[i]-2*x[i]+maxx[i+1],sum[i]-x[i]));
    }
    for(int i=n;i>=1;i--){
    //	cout<<sum[n]<<" "<<sum[i-1]<<" "<<m-x[i]<<" "<<maxn[i-1]<<endl;
    	ans=max(ans,(sum[n]-sum[i-1])-(m-x[i])*2+maxn[i-1]);
    	ans=max(ans,sum[n]-sum[i-1]-(m-x[i]));
	}
	cout<<ans<<endl;
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,sum=0,sum1=0,d,e;
    cin>>a;
    vector<long long>tap;
    vector<long long>dp;
    for(int i=0;i<a-1;i++)
    {
        cin>>b;
        tap.push_back(b);
        sum=sum+b;
        //reverse(tap.begin(),tap.end());


    }
    cin>>b;
    sum1=b;
    d=abs(sum-sum1);
    //cout<<sum<<" "<<sum1<<" "<<d<<endl;
    dp.push_back(d);

    for(int i=a-2;i>=1;i--)
    {



        //e=tap[i];
        sum-=tap[i];
        sum1+=tap[i];
        d=abs(sum-sum1);
        dp.push_back(d);


        //reverse(tap.begin(),tap.end());


    }
    

    sort(dp.begin(),dp.end());
    cout<<dp[0];

}



Measured memory_bytes: 4848
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  map<char, int> A;
  for (auto& c : s) A[c]++;
  bool found = false;
  for (auto& it : A) {
    if (it.second != 2) found = true;
  }
  cout << (found ? "No" : "Yes") << endl;
  return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define INF 100000000000000000

int main(){
  ll n,m;
  cin >> n >> m;
  vector<pair<ll,ll> >  graph[n];
  ll l,r,c;
  for(int i=0;i<m;i++){
    cin >> l >> r >> c;
    graph[l-1].push_back(make_pair(r-1,c));
  }
  for(int i=0;i<n-1;i++){
    graph[i+1].push_back(make_pair(i,0));
  }
  ll dist[n];
  for(int i=0;i<n;i++){
    dist[i] = INF;
  }
  priority_queue<pair<ll,ll>, vector<pair<ll,ll> >, greater<pair<ll,ll> > > q;
  q.push(make_pair(0,0));
  while(!q.empty()){
    pair<ll,ll> now;
    now = q.top();
    q.pop();
    if(dist[now.first] < now.second) continue;
    dist[now.first] = now.second;
    pair<ll,ll> temp;
    for(int i=0;i<graph[now.first].size();i++){
      temp = graph[now.first][i];
      if(dist[temp.first] > dist[now.first]+temp.second){
        q.push(make_pair(temp.first,dist[now.first]+temp.second));
      }
    }
  }
  if(dist[n-1]==INF) cout << -1 << endl;
  else cout << dist[n-1] << endl;


  return 0;
}


Measured memory_bytes: 18028
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        double n = sc.nextDouble();
        double m = sc.nextDouble();
        int d = sc.nextInt();
        sc.close();

        double sum = 0;
        if(d != 0){
            sum += Math.max(0, 2*(n-2*d));
            sum += 2*d;
        } else {
            sum += n;
        }
        System.out.println(sum/n/n*(m-1));
    }
}

Measured memory_bytes: 23252