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

int n, a, b, ans;

int f(int k) {
    int t = 0;
    while (k) {
        t += k % 10;
        k /=10;
    }
    return t;
}


int main() {
    ios::sync_with_stdio(false);
    cin >> n >> a >> b;
    
    for (int i = 1; i <= n; i++) {
        if (f(i) >=a && f(i) <= b)
            ans += i;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a, b, s, i = 10, j = 1;
  while(scanf("%d %d", &a, &b) != EOF) {
    s = a + b;
    i = 10;
    j = 1;
    while(1) {
      if(s % i == s) {
	break;
      }
      i *= 10;
      j++;
    }
    printf("%d\n", j);
  }
  return 0;
}

Measured memory_bytes: 0
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

w = list(IS())
set_w = set(w)
for s in set_w:
    if w.count(s)%2 != 0:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	nums := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&nums[i])
	}
	sort.Ints(nums)
	fmt.Println(nums[N-1] - nums[0])
}


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

int main()
{
    int n,q;
    cin>>n>>q;
    queue<int>a[n];
    REP(i,q)
    {
        int x,y,z;
        cin>>x>>y;
        if(x==0)
        {
            cin>>z;
            a[y].push(z);
        }
        if(x==1)
        {
            if(a[y].empty()==0)cout<<a[y].front()<<endl;
        }
        if(x==2)
        {
            if(a[y].empty()==0)a[y].pop();
        }
    }
}


Measured memory_bytes: 4388
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n;
ll a[100100];

bool solve() {
    ll sum = 0, t = n * (n + 1) / 2;
    for (int i = 0; i < n; i++) sum += a[i];
    if (sum % t != 0) return false;

    ll s = sum / t, u = 0;
    for (int i = 0; i < n; i++) {
        ll d = a[(i+1)%n] - a[i];
        if (s - d < 0 || (s - d) % n != 0) return false;
        u += (s - d) / n;
    }
    return s == u;
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << (solve()?"YES":"NO") << endl;
}


Measured memory_bytes: 1024
#define		_CRT_SECURE_NO_WARNINGS
#include	<cstdio>
#include	<cstdint>
#include	<iostream>
#include	<cmath>

typedef		std::uint_least32_t		ULI;		//10^9
typedef		std::int_least32_t		SLI;
typedef		std::uint_least64_t		ULLI;
typedef		std::int_least64_t		SLLI;

using namespace std;

bool IsPrime(ULI x);


int main()
{
	int		n;
	cin >> n;
	cin.clear();
	cin.ignore();
	int		sum = 0;

	for (int i = 0; i < n; i++)
	{
		ULI		v;
		cin >> v;

		if (IsPrime(v))
		{
			sum++;
		}
	}

	cout << sum << "\n";

	return 0;
}

bool IsPrime(ULI x)
{
	if (x == 2u)	
		return true;

	if ((x < 2u) || (x % 2 == 0))
		return false;

	ULI sq = static_cast<ULI>(sqrt(static_cast<double>(x)) + 1);

	for (ULI i = 3u; i <= sq; i += 2u)
	{
		if (x % i == 0)
			return false;
	}

	return true;
}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

bool comp(const P &a, const P &b){
		if(a.second != b.second)return a.second < b.second;
		else return a.first < b.first;
}

int main(int argc, char const* argv[])
{
	int n, m;
	cin >> n >> m;
	vector<P> vec;
	for(int i = 0; i < m; i++){
			int a, b;
			cin >> a >> b;
			a--; b--;
			vec.pb(mk(a, b));
	}
	sort(vec.begin(), vec.end(), comp);
	int res = 0;
	int curr = -1;
	for(auto itr = vec.begin(); itr != vec.end(); ++itr){
			if(curr <= (*itr).first){
					res++;
					curr = (*itr).second;
			}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int w[8],h[8],x1[15],x2[15],f=0;
char m[8][8],ans[8][8];
void fs(int n=0){
  if(f)return;
  if(n==8){
    f=1;
    for(int i=0;i<8;i++)
      for(int j=0;j<8;j++)
	ans[i][j]=m[i][j];
    return;
  }
  if(h[n]==1)fs(n+1);
  else{
    for(int i=0;i<8;i++){
      if(w[i]+x1[7+i-n]+x2[n+i]==0){
	m[n][i]='Q';
	w[i]=x1[7+i-n]=x2[n+i]=1;
	fs(n+1);
	m[n][i]='.';
	w[i]=x1[7+i-n]=x2[n+i]=0;
      }
    }
  }
}

int main(){

  for(int i=0;i<8;i++)
    for(int j=0;j<8;j++)
      m[i][j]='.';
  
  int n,a,b;
  
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    m[a][b]='Q';
    h[a]=w[b]=1;
    x1[7+b-a]=1;
    x2[a+b]=1;
  }
  
  fs();
  
  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++)
      cout<<ans[i][j];
    cout<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;
const ll N = 1007;


ll a,b;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a>>b;
	if(a+b==15){
		cout<<"+"<<endl;
	}else if(a*b==15){
		cout<<"*"<<endl;
	}else{
		pri("x");
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int cnt = 0; int p = i;
        while (p) {
            p /= 10; cnt++;
        }
        ans += cnt % 2;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int a[100005];
	int n;
	cin >> n;
//	cout << n << endl;
	cin >> a[0];
	for(int i = 1; i < n; i++){
		int t;
		cin >> t;
		a[i] = t;
	}
	for(int i = 1; i < n; i++){
//		cout << a[i - 1] << "  " << a[i] << endl;
		if(a[i-1] > a[i]){
//			cout << a[i - 1] << "  " << a[i] << endl;
			cout << "No" << endl;
			return 0;
		}else if(a[i - 1] < a[i]){
			a[i]--;
		}
	}
	cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
int main(void)
{
  int a = 0;
  int b = 0;
  int c = 0;
  
  scanf("%d %d %d", &a, &b, &c);
 
  if(a==b && a != c){
    printf("Yes");
  }
  if(b==c && a != c){
    printf("Yes");
  }
  if(a==c && a != b){
    printf("Yes");
  }
  if(a==c && a == b){
    printf("No");
  }
  if(a !=c && a != b && b != c){
    printf("No");
  }
  return 0;
}

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

const int S=(1<<20)+5;
char buf[S],*H,*T;
inline char Get()
{
	if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
	if(H==T) return -1;return *H++;
}
inline int read()
{
	int x=0;char c=Get();
	while(!isdigit(c)) c=Get();
	while(isdigit(c)) x=x*10+c-'0',c=Get();
	return x;
}

const int N=200010;
struct Edge{int to,capa,next;} e[N];
int h[N],sum=0,n,m;
bool vis[N];
int cmt,cnt,col[N],c[3];
bool falun;

inline int color(const int &x)
{
	if(x>=3) return x-3;
	if(x<0) return x+3;
	return x;
}

void add_edge(int u,int v,int w)
{
	e[++sum].to=v;
	e[sum].capa=w;
	e[sum].next=h[u];
	h[u]=sum;
}

void dfs(int u)
{
	c[col[u]]++;vis[u]=1;cnt++;
	for(int tmp=h[u];tmp;tmp=e[tmp].next)
	{
		cmt+=(e[tmp].capa==1);
		int v=e[tmp].to;
		if(!vis[v]) col[v]=color(col[u]+e[tmp].capa),dfs(v);
		else if(col[v]!=color(col[u]+e[tmp].capa)) falun=0;
	}
}

int main()
{
	//freopen("B.in","r",stdin);
	int u,v;
	n=read();m=read();
	for(int i=1;i<=m;i++)
	{
		u=read();v=read();
		add_edge(u,v,1);
		add_edge(v,u,-1);
	}
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		if(vis[i]) continue;
		memset(c,0,sizeof(c));
		cmt=cnt=0;falun=1;
		dfs(i);
		if(!falun) ans+=1ll*cnt*cnt;
		else if(c[0]&&c[1]&&c[2]) ans+=1ll*c[0]*c[1]+1ll*c[1]*c[2]+1ll*c[2]*c[0];
		else ans+=cmt;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m,a;
  cin>>n>>m;
  a=max(n,m);
  if(a==n){
    for(int i=0;i<n;i++){
      cout<<m;
    }
  }
  else{
    for(int i=0;i<m;i++){
      cout<<n;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  string s; cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(i%2 == 0 && s[i] == 'L' || i%2 == 1 && s[i] == 'R'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
sz;
long s,t,u;
char x[18],buf[5<<17];
main()
{
	read(0,buf,5<<17);
	while(buf[sz]&4)
	{
		t=-sz;
		while(buf[sz]=='<')++sz;
		t+=sz;
		u=-sz;
		while(buf[sz]=='>')++sz;
		u+=sz;
		s+=(t*(t+1)+u*(u+1)>>1)-(t<u?t:u);
	}
	sz=17;
	do{
		x[--sz]=s%10+'0';
		s/=10;
	}while(s);
	write(1,x+sz,17-sz);
}

Measured memory_bytes: 640
/**
 *    author:  milos
 *    created: 04.08.2020 22:52:58      
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false); 
  cin.tie(0);
  int n, w;
  cin >> n >> w;
  vector<long long> a(n);
  vector<long long> b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  } 
  vector<vector<long long>> dp(n, vector<long long>(w + 1, 0));
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= w - a[i]; j++) {
      if (i > 0) dp[i][j + a[i]] = max(dp[i][j + a[i]], dp[i - 1][j] + b[i]);
      else dp[i][j + a[i]] = max(dp[i][j + a[i]], b[i]);
      ans = max(ans, dp[i][j + a[i]]); 
    }
    for (int j = 0; j <= w; j++) {
      if (i > 0) dp[i][j] = max(dp[i - 1][j], dp[i][j]);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= w; j++) {
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans << '\n';
  return 0;   
}

Measured memory_bytes: 82348
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())

def calc(te):
   if te=="r":
      point=p
   elif te=="s":
      point=r
   else:
      point=s
   return point

ans=0
L=[]
for i in range(n):
   if i>=k and t[i]==L[i-k]:
      L.append("b")
      continue
   else:
      ans+=calc(t[i])
      L.append(t[i])
print(ans)

Measured memory_bytes: 52236
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		long a = 10;
		long b = 9;
		long c = 8;
		long p = 1000000007;

		for(int i=0;i<N-1;i++) {
			a = (a*10) % p;
		}
		for(int i=0;i<N-1;i++) {
			b = (b*9) % p;
		}
		for(int i=0;i<N-1;i++) {
			c = (c*8) % p;
		}
		long ans = (p+p+p+a+c-b-b)%p;

		System.out.println(ans);

	}
}


Measured memory_bytes: 35760
using System;
using System.Collections.Generic;

namespace abc165_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var A = CIn.ReadInt();
      var B = CIn.ReadLong();
      var N = CIn.ReadLong();

      var x = Math.Min(B - 1, N);

      var ans = A * x/ B - A * (x / B);

      Console.WriteLine(ans);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 27860
n = gets.to_i
t, a = gets.split.map(&:to_i)
heights = gets.split.map(&:to_i)

puts heights.map.with_index{ |h, i| [i + 1, (t - h * 0.006 - a).abs] }
                .sort_by{ |i, t| t }[0][0]

Measured memory_bytes: 1788
"""
~~ Author : Bhaskar
~~ Dated : 07~06~2020
"""

import sys
from bisect import *
from math import floor,sqrt,ceil,factorial as F,gcd,pi,log
from itertools import chain,combinations,permutations,accumulate
from collections import Counter,defaultdict,OrderedDict,deque
from array import array
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
mod = 1000000007
ch = "abcdefghijklmnopqrstuvwxyz"
lcm = lambda a,b : (a*b)//gcd(a,b)
setbit = lambda x : bin(x)[2:].count("1")

def solve():
    x,n = map(int,sys.stdin.readline().split())
    a = list(map(int,sys.stdin.readline().split()))
    if n == 0:
        print(x)
    else:
        a.sort()
        ans = []
        for i in range(150):
            if i not in a:
                ans.append(i)
        ans.sort(key = lambda i : abs(x-i))
        print(ans[0])




if __name__ == "__main__":
    # try:
    #     sys.stdin = open("input.txt","r")
    # except :
    #     pass
    solve()


Measured memory_bytes: 9488
#include<stdio.h>
#include<math.h>
#define dis(a,b) (a)*(a)+(b)*(b)
int main(){
  int i,j;
  int n;
  double a,b,c,r,sa,sb,sc,xp,yp;
  scanf("%d",&n);
  double x[n][3],y[n][3];
  for(i=0;i<n;i++)
    for(j=0;j<3;j++)
      scanf("%lf%lf",&x[i][j],&y[i][j]);
  for(i=0;i<n;i++){
    a=dis(x[i][0]-x[i][1],y[i][0]-y[i][1]);
    b=dis(x[i][1]-x[i][2],y[i][1]-y[i][2]);
    c=dis(x[i][2]-x[i][0],y[i][2]-y[i][0]);
    r=sqrt(a*b*c/((a*b+b*c+c*a)*2-a*a-b*b-c*c));
    sa=sqrt(a/b/c)*(b+c-a)/2/r;
    sb=sqrt(b/a/c)*(a+c-b)/2/r;
    sc=sqrt(c/a/b)*(a+b-c)/2/r;
    xp=(x[i][0]*sb+x[i][1]*sc+x[i][2]*sa)/(sa+sb+sc);
    yp=(y[i][0]*sb+y[i][1]*sc+y[i][2]*sa)/(sa+sb+sc);
    printf("%.3lf %.3lf %.3lf\n",xp,yp,r);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
ll INF = 1<<25;
int main() {
    ll A,B,N; cin >> A >> B >> N;
    // ll X = -1*INF;
    // for (int i=0;i<=N;i++) {
    //     ll Y = (ll)(A*i/B)-(ll)A*(i/B);
    //     // cout << i << " " << Y << endl;
    //     chmax(X, Y);
    // }
    // cout << X << endl;
    ll Z = min(B-1, N);
    cout << (ll)(A*Z/B)-(ll)A*(Z/B) << endl;
    return 0;
}

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

int main(){
  int a,b,x;
  cin >> a >> b >> x;
  
  if(x>=a && x <= a+b) cout << "YES";
  else cout << "NO";
  
  return 0;
}

Measured memory_bytes: 256
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;


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

	int N,cnt,ans=0;
	string S;

	cin >> N;
	cin >> S;

	for(int i=1;i<N;i++){

		int alpha1[26]={0};
		int alpha2[26]={0};

		string sprit1 = S.substr(0,i);
		string sprit2 = S.substr(i,N-i);

		for(int j=0;j<(int)sprit1.length();j++){
			alpha1[sprit1[j]-0x61]++;
		}

		for(int j=0;j<(int)sprit2.length();j++){
			alpha2[sprit2[j]-0x61]++;
		}

		cnt=0;
		for(int j=0;j<(int)26;j++){
			if (alpha1[j] > 0 && alpha2[j] > 0) {
				cnt++;
			}
		}

		if(ans < cnt){
			ans = cnt;
		}
	}

	cout << ans << endl;

	return 0;

}






Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

template <class Integer>
auto boost_irange(Integer last) { return boost::irange(static_cast<Integer>(0), last); }
template <class Integer>
auto boost_irange(Integer first, Integer last) { return boost::irange(first, last); }

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << std::endl; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << val << ' ';
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val << ' ';
        return {};
    }
};

int main()
{
    input in;
    output out;

    if (in.read<int>() < 3200) {
        out << "red";
    } else {
        out << in.read<std::string>();
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }


const int q = 1e9+9;


int main()
{
    ll n;
    cin>>n;
    if(n<1200) cout<<"ABC"<<endl;
    else
    if(n<2800) cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;


    return 0;
}
// gotcha;



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;

struct UnionFind{
	vector<int> par;//xの親はpar[x].x自身が親ならpar[x]<0で、-par[x]がその集合のサイズ.
	
	UnionFind(int n):par(n,-1){}//コンストラクタ.
	
	void reset(int n){par.assign(n,-1);}
	int root(int x){return par[x]<0?x:par[x]=root(par[x]);}//再帰.
	int size(int x){return -par[root(x)];}
	bool same(int x,int y){return root(x)==root(y);}
	bool unite(int x,int y){
		x=root(x);
		y=root(y);
		if(x==y) return false;//do nothing.
		if(size(x)<size(y)) swap(x,y);//大きい集合に結合.
		par[x]+=par[y];
		par[y]=x;
		return true;
	}
};

int main(){
	int n,m;
	cin>>n>>m;
	
	vi a(m),b(m);
	REP(i,m){
		cin>>a[i]>>b[i];
		a[i]--;
		b[i]--;
	}
	
	UnionFind is(n);
	vector<llong> ans(m);
	ans[m-1]=(llong)n*(n-1)/2;
	for(int i=m-1;i>=1;--i){
		if(is.root(a[i])==is.root(b[i])) ans[i-1]=ans[i];
		else ans[i-1]=ans[i]-(llong)is.size(a[i])*is.size(b[i]);
		is.unite(a[i],b[i]);
	}
	
	REP(i,m) cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });


void solve(long long N, std::vector<std::string> S, std::vector<long long> P){
	pair<pair<string, ll>, ll> p[N+10];
	REP(i, N) {
		p[i] = make_pair(make_pair(S[i], -P[i]), i);
	}
	sort(p, p+N);
	REP(i, N) cout << p[i].second+1 << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
        scanf("%lld",&P[i]);
    }
    solve(N, std::move(S), std::move(P));
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    char b;
    cin >> b;
    cout << (b == 'A' ? 'T' :
        b == 'T' ? 'A' :
        b == 'C' ? 'G' :
        'C') << endl;;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> b1, b2;
    rep(i, n) {
        if ((i + 1) % 2 == 0) {
            b2.push_back(a[i]);
        }
        else {
            b1.push_back(a[i]);
        }
    }

    vector<int> b;
    if (n % 2 == 0) {
        // 偶数奇数
        reverse(all(b2));
        rep(i, b2.size()) b.push_back(b2[i]);
        rep(i, b1.size()) b.push_back(b1[i]);
    }
    else {
        // 奇数偶数
        reverse(all(b1));
        rep(i, b1.size()) b.push_back(b1[i]);
        rep(i, b2.size()) b.push_back(b2[i]);
    }

    rep(i, b.size()) cout << b[i] << (i == b.size() - 1 ? "" : " ");

    cout << endl;

    return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int a,b;
	cin >> a >> b;
	if((a+b)%2==0)	cout << (a+b)/2 << endl;
	else cout << ((a+b)/2)+1 << endl;

}


Measured memory_bytes: 764
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"h,w,k=map(int,input().split())\n"
"p=[sum(('11'in str(bin(j)))^1for j in range(1<<i))for i in range(8)]\n"
"dp=[w*[0]for _ in[0]*-~h]\n"
"dp[0][0]=1\n"
"for i in range(1,h+1):\n"
"    for j in range(w):\n"
"        t=u=0\n"
"        if j:\n"
"            t=p[max(0,j-2)]*p[max(0,w-j-2)]\n"
"            dp[i][j]+=dp[i-1][j-1]*t\n"
"        if j<w-1:\n"
"            u=p[max(0,j-1)]*p[max(0,w-j-3)]\n"
"            dp[i][j]+=dp[i-1][j+1]*u\n"
"        dp[i][j]=(dp[i][j]+dp[i-1][j]*(p[w-1]-t-u))%(10**9+7)\n"
"print(dp[-1][k-1])\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3408
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i = 0; i < n; i++) cin >> a[i];


  ll ans = INF;
  for(ll i = -100; i <= 100; i++){
    ll cnt = 0;
    for(auto j : a){
      cnt += pow(j - i, 2);
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
const int MAXN=2005,MAXL=MAXN*MAXN*2-3,mod=1e9+7;
int N,K;
ll fac[MAXN*MAXN*4],inv[MAXN*MAXN*4];
ll C(ll n,ll m) {
//	printf("C(%lld,%lld)\n",n,m);
	if(n<0||m<0||n<m) return 0;
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
ll f[MAXN][MAXN];
int main() {
	scanf("%d%d",&N,&K);
	fac[0]=inv[0]=inv[1]=1;
	for(int i=1;i<=MAXL;++i) fac[i]=fac[i-1]*i%mod;
	for(int i=2;i<=MAXL;++i) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=1;i<=MAXL;++i) inv[i]=inv[i]*inv[i-1]%mod;
	//printf("%lld\n",C(5,3));
	if(K<2) {
		cout<<1<<endl;
		exit(0);
	}
	f[0][0]=1;
	for(int i=1;i<=N;++i) {
		for(int j=0;j<=i;++j) {
			if(i==j) {
				f[i][j]=f[i][j-1]*C( N*K-i-(j-1)*(K-1)-1 ,K-2)%mod;
			} else {
				f[i][j]=(f[i-1][j]+f[i][j-1]*C( N*K-i-(j-1)*(K-1)-1 ,K-2)%mod)%mod;
			}
			//printf("f[%d][%d]=%lld\n",i,j,f[i][j]);
		}
	}
	printf("%lld\n",f[N][N]*fac[N]%mod);
	return 0;
}

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

using namespace std;
using ll = long long;
int main() {
    int n;
    cin >> n;
    string str;
    cin >> str;
    set<int> s[26];
    int i;
    for(i=0;i<n;i++)
        s[str[i]-'a'].insert(i);
    int q;
    cin >> q;
    while(q--)
    {
        int num;
        cin >> num;
        if(num == 1)
        {
            int id;
            char c;
            cin >> id >> c;
            char ch = c;
            int x = ch - 'a';
            id--;
            ch = str[id];
            int y = ch - 'a';
            s[y].erase(id);
            s[x].insert(id);
            str[id] = c;
        }
        else if(num == 2)
        {
            int l, r;
            cin >> l >> r;
            l--;
            r--;
            int ans = 0;
            for(i=0;i<26;i++)
            {
                auto it1 = s[i].lower_bound(l);
                auto it2 = s[i].lower_bound(r);
                if(it1 == s[i].end())
                    continue;
                int num1 = *it1;
                if(num1 <= r)
                    ans++;
            }
            cout << ans << '\n';
        }
    }
}

Measured memory_bytes: 24196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
        double A, B  ;
        cin >> A >> B  ;
        cout << fixed << setprecision(10) ;
        cout << (A*B)/(A+B) << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int s =0; //sec
    int hour =0;
    int min =0;
    int sec =0;
    cin >> s;
    if(0 <= s && s < 86400){
        hour = s/60/60;
        min = s%3600/60;
        sec = s%60%60;
        
        cout << hour<<":"<<min<<":"<<sec<< endl;
    }
}

Measured memory_bytes: 3064
n=int(input())
ai=[int(x) for x in input().split()]
#print(len(set(ai)), -(-n // 2))
if (ai.count(0)==0 or ai.count(0)==1) and len(set(ai))==-(-n//2):
    ans=1
    for i in range(n//2):
        ans*=2
        ans%=10**9+7
    print(ans)
else:
    print(0)

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

int main(){
	double a,b,c,d,e,f,g,h;
	while(cin >> a >> b >> c >> d >> e >> f >> g >> h){
		if(((c - a) * (g- e)) + ((d - b) * (h - f)) == 0) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

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

int n, m;

void solve() {
	scanf("%d%d", &n, &m);
	if(n & 1); else n--;
	int l = 1, r = (n + 1) / 2 + 1;
	int t = n / 2;
	for(int i = 1; i <= m; i++) {
		if(i & 1) {
			printf("%d %d\n", l, l + t);
			t--;
			l++;
		}
		else {
			printf("%d %d\n", r, r + t);
			t--;
			r++;
		}
	}
}

int main()
{
	int T = 1;
	//scanf("%d", &T);
	
	while(T--) {
		solve();
	}
}

Measured memory_bytes: 3788
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<deque>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
using namespace std;
int main()
{
     int n,a,b;
     scanf("%d%d%d",&n,&a,&b);
     int sum=n-a;
     sum%=b;
     printf("%d\n",sum);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
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; }
typedef int64_t lint;

int main() {
	int N;
	cin >> N;
	vector<lint> v(N);
	rep(i, N) {
		cin >> v.at(i);
	}

	lint a=0, b=0, c=0, x, y, z;
	rep(i, N) {
		b = v.at(i);
		if (a > b) c += a-b;
		chmax(a, b);
	}
	std::cout << c << '\n';
}


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

bool check(string s) {
    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i + 1] - s[i] != 1) return false;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = -1;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int mul = a[i] * a[j];
            stringstream s;
            s << mul;
            if (check(s.str())) ans = max(ans, mul);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
import numpy as np

N, M, C = (int(i) for i in input().split())
e = [[int(i) for i in input().split()] for i in range(N+1)]

B = np.array(e[0])
A = np.array(e[1:])


print(((np.sum(B*A, axis=1)+C)>0).sum())

Measured memory_bytes: 12500
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X=sc.nextInt();
        int Y=sc.nextInt();
        for (int i=0;i<=100;i++){
            int crane=X-i;
            if (crane>=0){
                if (crane*2+i*4==Y){
                    System.out.println("Yes");
                    return;
                }
            }




        }
        System.out.println("No");
        return;


    }
}


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


typedef long long ll;
ll MOD = 1000000007;
ll modpow(ll a, ll n) {
	a %= MOD;
	if (a == 0) return 0;
	ll r = 1;
	while (n) r = r*((n % 2) ? a : 1) % MOD, a = a*a%MOD, n >>= 1;
	return r;
}
//-----------------------------------------------------------------
int N;
int A[101010];
map<int, int> cnt;

ll solve() {
	if (N % 2 == 0) {
		// 1, 3, 5, ..., N - 1
		for (int i = 1; i <= N - 1; i += 2) {
			if (cnt[i] != 2) return 0;
		}

		return modpow(2, N / 2);
	}
	else {
		// 0, 2, 4, ..., N - 1
		for (int i = 0; i <= N - 1; i += 2) {
			if (i == 0) {
				if (cnt[i] != 1) return 0;
			}
			else {
				if (cnt[i] != 2) return 0;
			}
		}

		return modpow(2, N / 2);
	}
}

int main() {
	cin >> N;
	rep(i, 0, N) scanf("%d", &A[i]);
	rep(i, 0, N) cnt[A[i]]++;

	cout << solve() << endl;
}

Measured memory_bytes: 3584
gcd_memo = {}


def gcd(a, b):
    if b == 0:
        return a
    elif (a, b) in gcd_memo:
        return gcd_memo[(a, b)]
    else:
        r = a % b
        gcd_memo[(a, b)] = gcd(b, r)
        gcd_memo[(b, a)] = gcd_memo[(a, b)]
        return gcd_memo[(a, b)]


if __name__ == "__main__":
    K = int(input())
    ans = 0
    for a in range(1, K+1):
        for b in range(1, K+1):
            for c in range(1, K+1):
                tmp = gcd(gcd(a, b), c)
                ans += tmp
    print(ans)


Measured memory_bytes: 83088
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

a,b,c,d,e,f = li()

water_set = set()
sugar_set = set()

MAX = 3000

# ありうる水と砂糖の重さ
for ai in range(0,MAX//100+1,a):
    for bi in range(0,MAX//100+1,b):
        if 100 * (ai + bi) <= MAX:
            water_set.add(100 * (ai + bi))

water_list = sorted(list(water_set))

for ci in range(0,30*e+1,c):
    for di in range(0,30*e+1,d):
        if ci + di <= 30*e:
            sugar_set.add(ci+di)
            
sugar_list = sorted(list(sugar_set))

node_max = -1
sw = 0
sg = 0

for wi in water_list:
    for si in sugar_list:
        if wi+si <= f and si <= e * (wi//100) and wi+si > 0:
            node = (100*si) / (wi+si)
            if node > node_max:
                sw = si + wi
                sg = si
                node_max = node
                
print(sw,sg)

Measured memory_bytes: 41436
# coding: utf-8
import numpy as np

n = int(input())

dp = [np.inf for _ in range(n+10)]
dp[0] = 0

for i in range(1, n+1):
    dp[i] = i
    pow6 = 1
    while pow6 <= i:
        dp[i] = min(dp[i], dp[i-pow6]+1)
        pow6 *= 6
    pow9 = 1
    while pow9 <= i:
        dp[i] = min(dp[i], dp[i-pow9]+1)
        pow9 *= 9
    
print(dp[n])

Measured memory_bytes: 13536
fun main(args: Array<String>){

    var N = readLine()!!.toLong()

    for(i in Math.sqrt(N.toDouble()).toInt() downTo 1){
        if( N % i == 0L){
            var A = N / i
            var B = N / A
            if(A >= B){
                print(A.toString().length)
            } else {
                print(B.toString().length)
            }
            break
        }
    }

}


Measured memory_bytes: 34464
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#define N 105
using namespace std;
char s[N];
int len;
bool a, b;
int main()
{
	scanf("%s", s);
	len = strlen(s);
	for(int i = 0; i < len; i++)
	{
		if(s[i] == 'C')
			a = true;
		if(s[i] == 'F' && a)
			b = true;
		if(a && b)
			break;
	}
	if(a && b)
		printf("Yes");
	else
		printf("No");
	return 0;
}

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

int main(){
  int X,N;
  cin >> X >> N;
  vector<int> P(N);
  for(int i=0;i<N;i++){
    cin >> P.at(i);
  }
  int A,B;
  int i=X;
  while(true){
    bool a=false;
    for(int j=0;j<N;j++){
      if(i==P.at(j)){
        a=true;
        break;
      }
    }
    if(!a){
        A=i;
      break;
    }
    else{
      i--;
    }
  }
  i=X;
  while(true){
    bool b=false;
    for(int j=0;j<N;j++){
      if(i==P.at(j)){
        b=true;
        break;
      }
    }
    if(!b){
        B=i;
      break;
    }
    else{
      i++;
    }
  }
  if(abs(A-X)<=abs(B-X)){
    cout << A << endl;
  }
  else{
    cout << B << endl;
  }
}

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

int main(){
    int a[5];
    int k;
    for(int i = 0; i < 5; i++){
        cin >> a[i];
    }
    cin >> k;
    if((a[4]- a[0]) <= k) cout << "Yay!" << endl;
    else cout << ":(\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin>>n;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      int kb=i^j,cnt=1;
      while(kb%2==0){
        kb/=2;
        cnt++;
      }
      cout<<cnt<<" ";
    }
    cout<<endl;
  }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)

// void time() {
//     #ifndef ONLINE_JUDGE
//     cout << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
//     #endif
// }
 



  int factorial(int n)
  {
    if(n == 1 || n == 0)
    {
      return 1;
    }
    else return n * factorial(n-1);
  }

  int arr[9][9];

  bool compare(const pair<int,int> &a,const pair<int,int> &b)
  {
    if(a.f == b.f)
    {
      return (a.s < b.s);
    }
    return a.f < b.f;

  }

  double distance(int x1,int y1,int x2,int y2)
  {
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)) ;  
  }
  int32_t main()
  {        

     IOS

    int n;
    cin >> n;
    vector<pair<int,int>> v;

    for(int i = 1; i <= n; i++)
    {
      int x, y;
      cin >> x >> y;
      v.PB(MP(x,y)); 
    }



    double answer = 0 ;

      sort(all(v),compare);

       for(int i = 0; i < v.size() -1; i++)
      {
        answer += distance(v[i].f,v[i].s,v[i+1].f,v[i+1].s);
      }

    while(next_permutation(v.begin(),v.end()))
    {
      for(int i = 0; i < v.size() -1; i++)
      {
        answer += distance(v[i].f,v[i].s,v[i+1].f,v[i+1].s);
      }
    }



    cout << fixed << setprecision(15) << (answer) / factorial(n);


    //time();
    return  0;
     }


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ios();
    int n, m;
    cin >> n >> m;

    map<ll,ll> mp;
    REP(i, n){
        ll a;
        cin >> a;
        mp[a]++;
    }

    REP(i, m){
        ll a, b;
        cin >> a >> b;
        mp[b] += a;
    }

    ll ans = 0, cnt = n;

    for(auto i = mp.rbegin(); i != mp.rend(); i++){
        ans += (*i).first * min(cnt, (*i).second);
        cnt -= (*i).second;
        if(cnt <= 0) break;
    }

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


Measured memory_bytes: 12800
n,p = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
ans = 0
fact = [1]*(n+1)

for i in range(1,n+1):
    fact[i] = fact[i-1]*i
def C(x,y):
    return fact[x]//fact[y]//fact[x-y]
    
    
for x in a:
    if x %2 == 1:
        cnt += 1
if p :
    for i in range(1,n+100,2):
        if i >cnt:break
        ans += C(cnt,i)*(2**(n-cnt))
else:
    for i in range(0,n+100,2):
        if i > cnt:break
        ans += C(cnt,i)*(2**(n-cnt))
print(ans)

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

int main() {
  int N;
  int count = 0;
  int divided = 0;
  cin >> N;
  int A[N];
  
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  
  while(true){
    
    for(int i = 0; i < N; i++){
      if(A[i] % 2 == 0){
        divided++;
      }
    } 
    
    if(divided == N){
      count++;
      divided = 0;
      for(int i = 0; i < N; i++) {
        A[i] /= 2;
      }
    }else {
      break;
    }
    
  } 
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    string s;
    cin >> s;

    if(s == "SUN") cout << 7 << endl;
    else if(s == "MON") cout << 6 << endl;
    else if(s == "TUE") cout << 5 << endl;
    else if(s == "WED") cout << 4 << endl;
    else if(s == "THU") cout << 3 << endl;
    else if(s == "FRI") cout << 2 << endl;
    else if(s == "SAT") cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int x = (a+b)/2;
    System.out.println((a+b)%2 == 0 ? x : x+1);
  }
}

Measured memory_bytes: 21844
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  string s;
  cin >> s;
  vector<bool> flag(4, false);
  rep(i, s.size()) {
    if (s[i] == 'N') flag[0] = true;
    else if (s[i] == 'S') flag[1] = true;
    else if (s[i] == 'W') flag[2] = true;
    else flag[3] = true;
  }
  if (flag[0] && !flag[1]) {
    cout << "No" << endl;
    return 0;
  }
  else if (!flag[0] && flag[1]) {
    cout << "No" << endl;
    return 0;
  }
  else if (flag[2] && !flag[3]) {
    cout << "No" << endl;
    return 0;
  }
  else if (!flag[2] && flag[3]) {
    cout << "No" << endl;
    return 0;
  }
  else {
    cout << "Yes" << endl;
    return 0;
  }
}

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


int main(){
 int N;
 bool flag = true;
 cin>>N;
 int a[N];
 for(int i = 0;i < N;i++){
     cin>>a[i];
     if(a[i]%2 == 0){
         if(a[i]%3==0 || a[i]%5==0);
         else flag = false;
         }
     }
  if(flag)cout<<"APPROVED";
  else cout<<"DENIED";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
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<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;
vvi a;

bool f(int i,int j,int k,int t){
	bool B=1;
	if(k&1<<j||k&1<<(j+1)) B=0;
	if(t&1<<j||t&1<<(j+1)) B=0;
	return B;
}

int main(){
	cin>>n>>m;
	a=vvi(n,vi(4));
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		a[y][x]=1;
	}
	vi dp(1<<4,-inf);
	int t=0;
	for(int i=0;i<4;i++) t+=a[0][i]*(1<<i);
	dp[t]=0;
	for(int i=0;i<n-1;i++){
		vi DP(1<<4,-inf);
		int t=0;
		for(int j=0;j<4;j++) t+=a[i+1][j]*(1<<j);
		for(int j=0;j<1<<4;j++){
			if(f(i,0,j,t)&&f(i,2,j,t)) DP[t|3|12]=max(DP[t|3|12],dp[j]+2);
			if(f(i,0,j,t)) DP[t|3]=max(DP[t|3],dp[j]+1);
			if(f(i,2,j,t)) DP[t|12]=max(DP[t|12],dp[j]+1);
			if(f(i,1,j,t)) DP[t|6]=max(DP[t|6],dp[j]+1);
			DP[t]=max(DP[t],dp[j]);
		}
		dp=DP;
	}
	int res=0;
	for(int i=0;i<1<<4;i++) res=max(res,dp[i]);
	cout<<res<<endl;
}


Measured memory_bytes: 3472