akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
N = INT()
S = list(input())

cnt = list(Counter(S).values())

ans = 1
for x in cnt:
	ans = ans*(x+1)%mod

print((ans-1%mod))



Measured memory_bytes: 11416
#!/usr/bin/env python3
import sys


def solve(S: str):
    acgt = [1 if s in ["A", "C", "G", "T"] else 0 for s in S]
    ans = 0
    tmp = 0
    for a in acgt:
        if a == 0:
            ans = max(ans, tmp)
            tmp = 0
            continue
        tmp += a
    ans = max(ans, tmp)
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] menu = new int[n];
    int[] point = new int[n];
    int[] bonus = new int[n];
    int sum = 0;
    
    for(int i = 0; i < n; i++){
      menu[i] = sc.nextInt();
    }
    for(int i = 0; i < n; i++){
      point[i] = sc.nextInt();
    }
    for(int i = 1; i < n; i++){
      bonus[i] = sc.nextInt();
    }
    
    for(int i = 0; i < n; i++){//計算
      sum += point[menu[i] - 1];
      if(i != 0 && (menu[i] == menu[i - 1] + 1)){
        sum += bonus[menu[i -1]];
      }
    }
         
    System.out.println(sum);
  } 
}

Measured memory_bytes: 21844
# k-1Ci-1 * n-k+1Ci
mod = 10**9+7
n, k = map(int, input().split())
ans = n-k+1
print(ans)
for i in range(1, k):
    ans = ans*(k-i)*(n-k-i+1)//(i*(i+1))
    print(ans % mod)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 1005;
queue<pair<P,int> > Q;
char a[MAX_N][MAX_N];
bool visited[MAX_N][MAX_N];
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{
	int H,W;
	cin >> H >> W;
	rep(i,H)
	{
		rep(j,W)
		{
			cin >> a[i][j];
			if (a[i][j] == '#')
			{
				Q.push(make_pair(P(i,j),0));
			}
		}
	}
	int ans = 0;
	while(!Q.empty())
	{
		pair<P,int> p = Q.front();
		Q.pop();
		int pff = p.first.first, pfs = p.first.second, ps = p.second;
		if (visited[pff][pfs]) continue;
		ans = max(ans,ps);
		visited[pff][pfs] = true;
		//cout << "visiting:" << pff << " " << pfs << " " << ps << endl;
		rep(i,4)
		{
			int x1 = pff+dx[i], y1 = pfs+dy[i];
			if (x1 >= 0 && x1 < H && y1 >= 0 && y1 < W) Q.push(make_pair(P(x1,y1),ps+1));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 50504
n = int(input())

MAX_NUM = 10 ** 18

nums = list(map(int, input().split()))

for num in nums:
  if num == 0:
    print(0)
    exit()

ans = 1
for num in nums:
  ans *= num
  if ans > MAX_NUM:
    print(-1)
    exit()

print(ans)


Measured memory_bytes: 21484
#include<bits/stdc++.h>
using namespace std;
int main(){
  int s1,s2,s3;
  char c1,c2;
  cin >> s1>>c1>>s2>>c2>>s3;
  if(s1<=2019 && s2<=4) cout << "Heisei" << endl;
  else cout<<"TBD"<<endl;
  return 0;
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

void sieve(vector<int>& v, int n) {
    v.assign(n, 0);
    iota(ALL(v), 2);
    for(auto d=v.begin(); (*d)*(*d)<=v.back(); ++d)
        v.erase(remove_if(d+1, v.end(), [&](int x){return x%*d==0; }), v.end());
}

vector<int> primes;

int solve(int n, int p) {
    int k = upper_bound(ALL(primes), n) - primes.begin();
    vector<int> m;
    for(int i=k; i<k+p; ++i)
        for(int j=k; j<=i; ++j) m.push_back(primes[i] + primes[j]);
    sort(ALL(m));
    return m[p-1];
}

int main()
{
    sieve(primes, 120000);
    int n, p;
    while(cin>>n>>p, n!=-1) cout << solve(n, p) << endl;
    return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    int d = n / 2;
    int r = n % 2;
    cout << (r == 0 ? d : d + 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> p(n),q(n);
  for(int i=0;i<n;i++)cin>>p[i]>>q[i];
  for(int i=0;i<n-2;i++){
    bool ok=true;
    for(int j=i;j<i+3;j++){
      if(p[j]!=q[j])ok=false;
    }
    if(ok){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}

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

using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	vector<int> a(n,0);
	for(int &i:a){
		scanf("%d",&i);
	}
	int ans=0;
	for(int i:a){
		ans^=i;
	}
	if(ans){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main()
{
    long long N;
    cin >> N;
    long long X[100], Y[100], H[100];
    for (long long i = 0; i < N; ++i) {
        cin >> X[i] >> Y[i] >> H[i];
    }

    for (int x = 0; x < 101; ++x) {
        for (int y = 0; y < 101; ++y) {
            bool found = true;
            long long h = -1;
            for (long long n = 0; n < N; ++n) {
                if (H[n] == 0) {
                    continue;
                }
                h = H[n] + abs(X[n] - x) + abs(Y[n] -y);
            }
            for (long long n = 0; n < N; ++n) {
                long long h_candidate = max(h - abs(X[n] - x) - abs(Y[n] - y), 0ll);
                if (H[n] != h_candidate) {
                    found = false;
                    break;
                }
            }
            if (found) {
                printf("%d %d %lld\n", x, y, h);
                return 0;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main()
{
  int n;
  cin >> n;
  cout << n * n * 3 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
int main()
{
	int a,b,c,d;
	scanf("%d%d%d",&a,&b,&c);
	if(a>b&&a>c) 
	{ 
	    d=b+c;
		if(a==d) printf("Yes\n");
		else printf("No\n");
	}
	else if(b>a&&b>c)
	{
		d=a+c;
		if(d==b) printf("Yes\n");
		else printf("No\n");
	}
	else if(c>a&&c>b)
	{
		d=a+b;
		if(d==c) printf("Yes\n");
		else printf("No\n");
	}
	else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] tmpLine = Console.ReadLine()
                                    .Split(' ')
                                    .Select(s => int.Parse(s))
                                    .ToArray();
            int N = tmpLine[0];
            int M = tmpLine[1];
            long[] factor = Console.ReadLine()
                                    .Split(' ')
                                    .Select(s => long.Parse(s))
                                    .ToArray();

            MaxHeap maxHeap = new MaxHeap(factor);
            for (int i = 0; i < M; i++)
            {
                if (maxHeap.heap[0] == 0)
                {
                    break;
                }
                maxHeap.heap[0] /= 2;
                maxHeap.DownHeapfy(0);
            }
            Console.WriteLine(maxHeap.heap.Sum());
        }
    }
    class MaxHeap
    {
        public long[] heap;
        public MaxHeap(long[] factor)
        {
            this.heap = factor;
            for (int i = this.heap.Length / 2; i >= 0; i--)
            {
                this.DownHeapfy(i);
            }
        }
        public void DownHeapfy(int parentIndex)
        {
            int tmpIndex = parentIndex;
            int leftIndex = (parentIndex + 1) * 2 - 1;
            int rightIndex = (parentIndex + 1) * 2;
            if (leftIndex < this.heap.Length && this.heap[leftIndex] > this.heap[tmpIndex])
            {
                tmpIndex = leftIndex;
            }
            if (rightIndex < this.heap.Length && this.heap[rightIndex] > this.heap[tmpIndex])
            {
                tmpIndex = rightIndex;
            }
            if (tmpIndex != parentIndex)
            {
                long tmpVal = this.heap[parentIndex];
                this.heap[parentIndex] = this.heap[tmpIndex];
                this.heap[tmpIndex] = tmpVal;
                this.DownHeapfy(tmpIndex);
            }
        }


    }
}


Measured memory_bytes: 29532
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n; cin>>n;
    int a[n]; rep(i,n) cin>>a[i];
    long long ans=LINF;
    for(int y=-100;y<=100;y++){
        long long tmp=0;
        rep(i,n){
            tmp+=(a[i]-y)*(a[i]-y);
        }
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int w=ir.nextInt();
		int a=ir.nextInt();
		int b=ir.nextInt();
		if(b>=a+w)
			out.println(b-a-w);
		else if(a>b+w)
			out.println(a-b-w);
		else
			out.println(0);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}

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

struct StExpr
{
  StExpr() : m_nPerson(0), m_nAttr(0) { }

  int m_nPerson;
  int m_nAttr;
};

void fnInput(vector<vector<StExpr>>& rvvoExpr)
{
  int nPersonSiz;
  cin >> nPersonSiz;
  rvvoExpr.resize(nPersonSiz);

  for (int i = 0; i < rvvoExpr.size(); i++)
  {
    int nAttrSiz;
    cin >> nAttrSiz;
    rvvoExpr[i].resize(nAttrSiz);

    for (int j = 0; j < rvvoExpr[i].size(); j++)
      cin >> rvvoExpr[i][j].m_nPerson >> rvvoExpr[i][j].m_nAttr;
  }
}
 
int fnHonestCheck(const vector<vector<StExpr>>& cnrvvoExpr, 
                  const vector<int>& cnrvnHonest, int nMan)
{
  if (cnrvnHonest[nMan])               // Honest
  {
    for (int j = 0; j < cnrvvoExpr[nMan].size(); j++)
      if (cnrvvoExpr[nMan][j].m_nAttr  !=
          cnrvnHonest[ cnrvvoExpr[nMan][j].m_nPerson - 1 ] )
        return 0;

    return 1;
  }
  else                                 // UnKind
  {
    for (int j = 0; j < cnrvvoExpr[nMan].size(); j++)
      if (cnrvvoExpr[nMan][j].m_nAttr  !=
          cnrvnHonest[ cnrvvoExpr[nMan][j].m_nPerson - 1 ] )
        return 1;

    return 0;
  }
}
  
int fnMaxHonestGet(const vector<vector<StExpr>>& cnrvvoExpr)
{
  vector<int> vnHonest(cnrvvoExpr.size());
  int nMaxHonestCnt = 0;
  
  for (int n = 0; n < ( 1 << cnrvvoExpr.size() ); n++)
  {
    int nHonestCnt = 0;

    for (int i = 0; i < cnrvvoExpr.size() ; i++)
      if (n & ( 1 << i ))
      {
        vnHonest[i] = 1;               // Honest
        nHonestCnt++;
      }
      else
        vnHonest[i] = 0;               // UnKind

    bool bReslt = true;

    for (int nMan = 0; nMan < vnHonest.size(); nMan++)
      if (!fnHonestCheck(cnrvvoExpr, vnHonest, nMan))
      {
        bReslt = false;
        break;
      }

    if (bReslt) nMaxHonestCnt = max(nMaxHonestCnt, nHonestCnt);
  }
  return nMaxHonestCnt;
}

int main()
{
  vector<vector<StExpr>> vvoExpr;

  fnInput(vvoExpr);
  cout << fnMaxHonestGet(vvoExpr) << endl;

  return 0;
}

Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
class Program{
	static List<long>[] li;
	static int[] hf;
	static int k=0;
	static void Main(){
		long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		long[] h=new long[s[0]+1];
		hf=new int[s[0]+1];
		for(int i=1;i<=s[0];i++){h[i]=long.MinValue;}
		h[1]=0;
		long[][] arr=new long[s[1]][];
		for(int i=0;i<s[1];i++){arr[i]=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}

		int l=0,z=0;
		bool b=true;
		while(b&&l<=s[0]){
			l++;
			b=false;
			for(int i=0;i<s[1];i++){
				if(h[arr[i][0]]!=long.MinValue&&h[arr[i][1]]<h[arr[i][0]]+arr[i][2]){
					h[arr[i][1]]=h[arr[i][0]]+arr[i][2];
					b=true;
					if(l==s[0]){hf[arr[i][1]]=1;z++;}
				}
			}
		}
		if(z>0){
			li=new List<long>[s[0]+1];
			for(int i=1;i<=s[0];i++){li[i]=new List<long>();}
			for(int i=0;i<s[1];i++){li[arr[i][1]].Add(arr[i][0]);}
			fu(s[0]);
		}
		Console.WriteLine("{0}",k>0?"inf":h[s[0]].ToString());
	}
	static void fu(long n){
		k+=hf[n];
		hf[n]=2;
		for(int i=0;i<li[n].Count;i++){
			if(hf[li[n][i]]<2){fu(li[n][i]);}
		}
	}
}

Measured memory_bytes: 13376
#include<iostream>
#include<string>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;

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

  int len=S.length();
  long long ans=0;

  REP(bit, 1<<len-1){
    int lpi=-1;
    REP(pi, len-1){
      if(bit & (1<<pi)){
        ans += stol(S.substr(lpi+1, pi-lpi));
        lpi = pi;
      }
    }
    ans += stol(S.substr(lpi+1, len-lpi-1));
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define vpi vector<ppi>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

int main()
{
    fast


        
    int a,b,c;
    cin>>a>>b>>c;

    if(c*a <= b)
    {
        cout<<c;
    }    
    else
    {
        cout<<b/a;
    }












    return 0;
}

Measured memory_bytes: 256
var
	N,i,j,tmp:Longint;
	S:array[1..100]of String[10];
	P,id:array[1..100]of Longint;
	t:String;
begin
	readln(N);
	for i:=1 to N do begin
		id[i]:=i;
		readln(t);
		j:=1;
		while t[j]<>' ' do begin
			S[i]:=S[i]+t[j];
			inc(j);
		end;
		inc(j);
		for j:=j to length(t)do begin
			P[i]:=P[i]*10+ord(t[j])-48;
		end;
		for j:=i-1 downto 1 do begin
			if(S[id[j]]>S[id[j+1]])or((S[id[j]]=S[id[j+1]])and(P[id[j]]<P[id[j+1]]))then begin
				tmp:=id[j];
				id[j]:=id[j+1];
				id[j+1]:=tmp;
			end;
		end;
	end;
	for i:=1 to N do writeln(id[i]);
end.

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

void max_self(ll& a, ll b) {
    a = max(a, b);
}

// O(n * W)

int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<ll> dp(W + 1); // 0 ... W
    // dp[i] - the maximum total value of items with total weight exactly i
    for(int item = 0; item < n; ++item) {
        int weight, value;
        scanf("%d%d", &weight, &value);
        // dp[0] -> dp[3] -> dp[6]
        for(int weight_already = W - weight; weight_already >= 0; --weight_already) {
        //~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            max_self(dp[weight_already+weight], dp[weight_already] + value);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= W; ++i) {
        max_self(answer, dp[i]);
    }
    printf("%lld\n", answer);
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;

int main(){
	string s;
	cin>>s;
	if(s=="ABC")cout<<"ARC"<<"\n";
	if(s=="ARC")cout<<"ABC"<<"\n";
	
	
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a, b;
        cin >> a >> b;
    cout << a / b << endl;
    cout << a % b << endl;
    long double f = (long double)a / b;
    cout << std::fixed << std::setprecision(6) << f << endl;
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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


int main() {
    int n, m, c;
    cin >> n >> m >> c;
    int count = 0;

    vector<int> b(m, 0);
    REP(i, m)cin >> b[i];
//OK
    vector<vector<int>> am(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> am[i][j];
        }
    }
    int ans = 0;
    REP(i, n) {
        int sum = 0;
        REP(j, m) {
            sum += b[j] * am[i][j];
        }
        sum += c;
        if (sum > 0) ans++;

    }
    cout << ans << endl;
}


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

int main()
{
    int N, M; cin >> N >> M;
    vector<int> A(N); for (auto& a : A) cin >> a;

    vector<int> R(N);
    R[0] = A[0] % M;
    for (int i = 1; i < N; i++) {
        R[i] = (R[i-1] + A[i]) % M;
    }

    unordered_map<int, int> cnt;
    cnt[0] = 1;
    for (int r : R) cnt[r]++;

    ll ans = 0;
    for (auto it = cnt.begin(); it != cnt.end(); it++) {
        int c = it->second;
        if (c >= 2) {
            ans += ((ll)c * (c - 1)) / 2;
        }
        
    }
    cout << ans << endl; 
}


Measured memory_bytes: 4492
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
#define int long long

// 最大公約数
long long gcd(long long a, long long b){
    long long c;
    if (a < b) {
        a+=b; b=a-b; a-=b;
    }
    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

// 最小公倍数
long long lcm( long long m, long long n ){
    // 引数に０がある場合は０を返す
    if ( ( 0 == m ) || ( 0 == n ) ) return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

signed main(void){
    int n; cin >> n;
    int ans = 1;
    REP(i, n){
        int tmp; cin >> tmp;
        ans = lcm(tmp, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, M, Q = map(int, input().split())
A, B, C, D = [],[],[],[]
for i in range(Q):
    a, b, c, d = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)
    D.append(d)

L = []
def dfs(S):
    if len(S) == N:
        L.append(S)
    elif S == "":
        for i in range(M):
            S = str(i)
            dfs(S)
    else:
        for i in range(int(S[-1]), M):
            dfs(S+str(i))
dfs("")

Ans = 0
for l in L:
    ans = 0
    for a, b, c, d in zip(A,B,C,D):
        if int(l[b-1]) - int(l[a-1]) == c:
            ans += d
    Ans = max(ans, Ans)
print(Ans)


Measured memory_bytes: 83304
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }

bool ok[2010][2010];
int U[2010][2010], D[2010][2010], L[2010][2010], R[2020][2010];

int main(int argc, char const *argv[]) {
  int h, w;
  cin >> h >> w;
  vector<string> G(h);
  rep(i, h) cin >> G[i];
  rep(i,h)rep(j,w){
    if (G[i][j] == '#') ok[i][j] = false;
  }
  //down
  rep(x,w){
    int cnt = 0;
    rep(y, h) {
      if (G[y][x]=='#') cnt = 0;
      else{
        cnt++;
        D[y][x] += cnt;
      }
    }
  }
  //up
  rep(x,w){
    int cnt = 0;
    for (int y = h - 1; y >= 0; y--) {
      if (G[y][x] == '#') cnt = 0;
      else {
        cnt++;
        U[y][x] += cnt;
      }
    }
  }
  
  //right
  rep(y,h) {
    int cnt = 0;
    rep(x,w) {
      if (G[y][x] == '#') cnt = 0;
      else {
        cnt++;
        R[y][x] += cnt;
      }
    }
  }

  // left
  rep(y, h) {
    int cnt = 0;
    for (int x = w - 1; x >= 0; x--) {
      if (G[y][x] == '#')
        cnt = 0;
      else {
        cnt++;
        L[y][x] += cnt;
      }
    }
  }

  //check
  /*rep(i,h){
    rep(j,w){
      printf("%d",L[i][j]);
    }
    cout << endl;
  }*/
  
  int ans = 0;
  rep(i, h) rep(j, w) chmax(ans, U[i][j] + D[i][j] + R[i][j] + L[i][j] - 3);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 71424
# 16:06
s = input()
num = 0
ans = 0
for i in range(len(s)):
    if s[i] == "A"or s[i] == "G" or s[i] == "C"or s[i] == "T":
        for j in range(i, -1, -1):
            if s[j] == "A"or s[j] == "C"or s[j] == "G"or s[j] == "T":
                num += 1
            else:
                break
        for k in range(i+1, len(s)):
            if s[k] == "A"or s[k] == "C"or s[k] == "G"or s[k] == "T":
                num += 1
            else:
                break
        if num > ans:
            ans = num
        num = 0
print(ans)


Measured memory_bytes: 3064
#include<cstdio>
#include<functional>
#include<algorithm>
#define MM 20000000000000000
using namespace std;
int main(void)
{
	int n,m,flg[1001],a[2000],b[2000],c[2000],i,j;
	long long leng[1001];
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)	{
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
		c[i]=-c[i];
	}
	for(i=1;i<=n;i++)	leng[i]=2000000000000000000;
	leng[1]=0;
	for(i=0;i<n;i++)	{
		for(j=0;j<m;j++)	{
			leng[b[j]]=min(leng[b[j]],leng[a[j]]+c[j]);
		}
	}
	for(i=1;i<=n;i++)	flg[i]=0;
	for(i=0;i<m;i++)	{
		if(leng[b[i]]>leng[a[i]]+c[i])	{
			flg[b[i]]=1;
		}
		if(flg[a[i]]==1)	flg[b[i]]=1;	
	}
	if(flg[n]==1)	printf("inf\n");
	else printf("%lld\n",-leng[n]);
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!int);
    auto K = s[0];
    auto N = s[1];

    if (N == 1) {
        writeln(K/2+K%2);
        return;
    }
    
    if (K % 2 == 0) {
        write(K/2, " ");
        foreach (i; 0..N-1) write(K, " ");
        writeln;
        return;
    }

    auto ans = new int[](N);
    ans.fill(K/2+1);
    int p = N-1;

    foreach (_; 0..N/2) {
        if (ans[p] == 1) {
            ans[p] = 0;
            p -= 1;
        } else {
            ans[p] = ans[p] - 1;
            p += 1;
            while (p < N) ans[p] = K, p += 1;
            p = N-1;
        }
    }

    ans.filter!(a => a!= 0).map!(to!string).join(" ").writeln;
}


Measured memory_bytes: 7420
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>

typedef long long int64;

const int maxn = 100005;
int n, size[maxn];
int64 d[maxn];
std::map<int64, int> s;

int main()
{
	static int id[maxn];
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%lld", d + i), s[d[i]] = i, id[i] = i;
	std::sort(id + 1, id + 1 + n, [](int x, int y) { return d[x] < d[y]; });
	std::vector<std::pair<int, int>> e;
	for (int i = 1; i <= n; ++i)
		size[i] = 1;
	for (int i = n; i != 1; --i)
	{
		if (2 * size[id[i]] >= n || !s.count(d[id[i]] - (n - 2 * size[id[i]])))
		{
			puts("-1");
			return 0;
		}
		int fa = s[d[id[i]] - (n - 2 * size[id[i]])];
		e.emplace_back(fa, id[i]);
		size[fa] += size[id[i]];
		d[id[1]] -= size[id[i]];
	}
	if (d[id[1]])
		puts("-1");
	else
		for (const auto &p : e)
			printf("%d %d\n", p.first, p.second);
	return 0;
}


Measured memory_bytes: 10104
def f(i, m)
    c = $cache[[i, m]]
    return c if c
    return m if i >= $y
    e = 0
    $roulette.each do |v|
        if $event[i + v]
            if $event[i + v][0] == 1
                e += f(i + v + $event[i + v][1], m) / $roulette.size.to_f
            elsif $event[i + v][0] == 2
                e += f(i + v, m + $event[i + v][1]) / $roulette.size.to_f
            else
                e += f(i + v, [m - $event[i + v][1], 0].max) / $roulette.size.to_f
            end
        else
            e += f(i + v, m) / $roulette.size.to_f
        end
    end
    $cache[[i, m]] = e
end

loop do
    x, $y, z = gets.split.map(&:to_i)
    break if x == 0
    $roulette = gets.split.map(&:to_i)
    $event = {}
    z.times do
        n, e, a = gets.split.map(&:to_i)
        $event[n] = [e, a]
    end
    $cache = {}
    p f(0, 0).to_i
end



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

// b.cpp
// author: Seong Yong-ju ( @sei40kr )
// Copyright (c) 2017 Seong Yong-ju

#define DEBUG(x) cout << #x << ": " << x << endl

#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)

#define ALL(a) (a).begin(), (a).end()

using namespace std;

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

  int h, w;
  cin >> h >> w;
  bool map[h + 2][w + 2] = {};

  REP(i, h) {
    REP(j, w) {
      char tmp;
      cin >> tmp;
      map[i + 1][j + 1] = tmp == '#';
    }
  }

  REP(i, h) {
    REP(j, w) {
      if (map[i + 1][j + 1]) {
        cout << '#';
      } else {
        bool tmp[] = {map[i][j],
          map[i][j + 1],
          map[i][j + 2],
          map[i + 1][j],
          map[i + 1][j + 2],
          map[i + 2][j],
          map[i + 2][j + 1],
          map[i + 2][j + 2]};
        cout << count(tmp, tmp + 8, true);
      }
    }

    cout << endl;
  }
}


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

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    if (N % 1000 != 0)
        ans = 1000 - (N % 1000);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){

int a,b,c ;
cin >>a>>b>>c;

if(a>b) swap(a,b);
if(b>c) swap(b,c);
if(a>b) swap(a,b);

cout<<a<<" "<<b<<" "<<c<<endl;

return 0;
}


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

using namespace std;

#define ll long long
#define ar array



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

	int h,w,k;
	cin >> h >> w >> k;
	string arr[h];
	for(int i =0;i < h;i++) cin >> arr[i];
	int ans= 0;
	for(int maskR = 0;maskR < (1<<h);maskR++){
		for(int maskC = 0;maskC < (1<<w);maskC++){
			int black = 0;
			for(int i =0;i < h;i++){
				for(int j = 0;j < w;j++){
					if((maskR>>i)&1^1 && (maskC>>j)&1^1 && arr[i][j]=='#') black++;
				}
			}
			if(black==k) ans++;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	vector<int> X;
	int s;
	for (int i = 0; i < N; i++) {
		s = 0;
		for (int j = i; j < N; j++) {
			s += A[j];
			X.push_back(s);
		}
	}
	vector<int> nX;
	for (int i = 60; i >= 0; i--) {
		int bit = ((int)1 << i);
		int c = 0;
		nX.clear();
		for (int j = 0; j < X.size(); j++) {
			if ((X[j] & bit)) {
				c++;
				nX.push_back(X[j]);
			}
		}
		if (c >= K) {
			swap(X, nX);
			res += bit;
		}

	}
	cout << res << endl;
}

Measured memory_bytes: 6512
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}
	sort.Ints(as)

	comInit()
	ans := 0
	for i := 0; i < n; i++ {
		ans = add(ans, mul(com(i, k-1), as[i]))
		ans = sub(ans, mul(com(n-i-1, k-1), as[i]))
	}
	fmt.Println(ans)
}

const mod int = 1e9 + 7

func pow(n, k int) int {
	if k == 0 {
		return 1
	} else if k%2 == 1 {
		return pow(n, k-1) * n % mod
	} else {
		t := pow(n, k/2)
		return t * t % mod
	}
}

func add(a, b int) int {
	return (a + b) % mod
}

func sub(a, b int) int {
	return (a + mod - b) % mod
}

func mul(a, b int) int {
	return a % mod * b % mod % mod
}

func div(a, b int) int {
	return mul(a, pow(b, mod-2))
}

const max int = 1e5*2 + 1000

var fac [max]int
var finv [max]int
var inv [max]int

func comInit() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for i := 2; i < max; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func com(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod
}


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

int main()
{
	ll n;
	cin>>n;
	vector<pair<ll, ll>> a[n+1];
	ll x,y,z;
	fr(i,0,n-1)
	{
		cin>>x>>y>>z;
		a[x].push_back(make_pair(y,z));
		a[y].push_back(make_pair(x,z));
	}
	ll dist[n+1];
	queue<int> q;
	q.push(1);
	bool visited[n+1];
	fr(i,1,n+1)
	visited[i]=false;
	visited[1]=true;
	dist[1]=0;
	while(!q.empty())
	{
		ll w=q.front();
		q.pop();
		fr(i,0,a[w].size())
		{
			if(visited[a[w][i].first]==false)
			{
				visited[a[w][i].first]=true;
				dist[a[w][i].first]=dist[w]+a[w][i].second;
				q.push(a[w][i].first);
			}
		}

	}

	fr(i,1,n+1)
	{
		if(dist[i]%2==0)
			cout<<'0'<<endl;
		else
			cout<<'1'<<endl;

	}

}			

Measured memory_bytes: 8704
#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input
 
def insertionSort(a,g):
    global cnt
    for i in range(g,len(a)):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j - g
            cnt+=1
            a[j+g] = v
 
def shellSort(a):
    global cnt
    cnt = 0
    g = []
    h = 1
    while h <= len(a):
        g.append(h)
        h = 3*h+1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str,g)))
    for i in range(m):
        insertionSort(a,g[i])
 
a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a)
print(cnt)
for e in a: print(e)


Measured memory_bytes: 45528
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
// int mI(int a, int m)  {return power(a, m - 2, m);}
vector<vector<int>> dir = {{2, 1}, {2, -1}, {-2, 1}, {-2, -1},{1,2},{1,-2},{-1,2},{-1,-2}};

void solve(){
    int x, n;
    cin >> x >> n;
    int ans = -1;
    int diff = 1e9;
    map<int, int> m;
    fo(i,n){
        int xx;
        cin >> xx;
        m[xx]++;
        

    }
    vec v;
    fo(i,110){
        if(m[i]==0){
            v.pb(i);
        }
    }
    fo(i,110){
        v.pb(-i);
    }
    for(auto xx:v){
        //deb(xx);
        if(abs(xx-x)<diff){
            diff = abs(xx - x);
            ans = xx;
        }
        else if(abs(xx-x)==diff){
            ans = min(ans, xx);
        }
    }
    cout << ans;

}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    while(t--){
        solve();
    }
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;


int main(){
    ll ans=INF;
    ll n;cin >>n;
    vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    for (int i = -100; i <=100; ++i) {
        ll now=0;
        for (int j = 0; j < n; ++j) {
            now+=(a[j]-i)*(a[j]-i);
        }
        ans=min(ans,now);
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 256
ans = 0
while True:
    try:
        s = list(input())
        numlst = []
        anslst = []

        for num, i in enumerate(s):
            try:
                k = int(i)
                numlst.append(num)

            except:
                pass
        
        for i in range(len(numlst)-1):
            if numlst[i+1] - numlst[i] == 1:
                s[numlst[i+1]] = s[numlst[i]] + s[numlst[i+1]]
            else:
                anslst.append(numlst[i])

        if numlst !=[]:
            anslst.append(numlst[-1])
        
        for i in anslst:
            ans = ans + int(s[i])

    except EOFError:
        break

print(ans)


Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o set

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int a;cin >>a;
    cout<<a+a*a+a*a*a<<endl;
}


Measured memory_bytes: 3664
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT fixed << setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

#if 1
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int N;
int A[100001];

int main() {
	cin >> N;
	REP(i, 0, N) {
		cin >> A[i];
	}
	int c = 0;
	REP(i, 0, N) {
		if (A[i] == i + 1) {
			c++;
			i++;
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <queue>

using namespace std;

class Process {
private:
    string _name;
    int _time;
public:
    Process(string n, int t):_name(n), _time(t) {}

    string name() const { return _name; }
    int time() const { return _time; }
};

class Finished {
private:
    string _name;
    int _time;
public:
    Finished(string n, int t):_name(n), _time(t) {}

    string name() const { return _name; }
    int time() const { return _time; }
};

int main() {
    int n,q;
    cin >> n >> q;

    queue<Process> ps;

    for (int i = 0; i < n; i++) {
        string name;
        int time;
        cin >> name >> time;
        ps.push(Process(name, time));
    }

    int elapsed = 0;
    vector<Finished> fs;

    while(!ps.empty()) {
        Process p = ps.front();
        ps.pop();

        if (p.time() > q) {
            ps.push(Process(p.name(), p.time() - q));
            elapsed += q;
        } else {
            elapsed += p.time();
            fs.push_back(Finished(p.name(), elapsed));
        }
    }

    for (const auto& f : fs) {
        cout << f.name() << " " << f.time() << endl;
    }

    return 0;
}

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

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

int main() {
	int x1, x2, x3, x4;
	int y1, y2, y3, y4;

	cin >> x1 >> y1 >> x2 >> y2;

	x4 = x1 + (x2 - x1) * 0 - 1 * (y2 - y1);
	y4 = y1 + 1 * (x2 - x1) + 0 * (y2 - y1);

	x3 = x2 + (x1 - x2) * 0 + 1 * (y1 - y2);
	y3 = y2 + (-1) * (x1 - x2) + 0 * (y1 - y2);

	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

	
	return 0;
}


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

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

int main(){
  ll N, K;
  cin >> N >> K;

  ll ans = (N / K) * (N / K) * (N / K);
  if(K % 2 == 0){
    ans += ((N + K / 2) / K) * ((N + K / 2) / K) * ((N + K / 2) / K);
  }
  cout << ans << endl;
  return 0;
}


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

// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4765
const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x(x % mod) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
} comb(100005);

mint f(int n, int k) {
  if (n < 0) return 0;
  // nPk = nCk * k!
  mint res = comb(n, k);
  res *= comb.fact[k];
  return res;
}

int k;
mint ans;
vector<int> to[100005];
void dfs(int v, int p = -1) {
  for (int u : to[v]) {
    if (u == p) continue;
    dfs(u, v);
  }
  int nk = (p == -1) ? k : k - 2;
  int c = (p == -1) ? to[v].size() + 1 : to[v].size() - 1;
  ans *= f(nk, c);
}

int main() {
  int n;
  cin >> n >> k;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans = 1;
  dfs(0);
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 10752