akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n; cin >> n;
  Vll a(3*n); cin >> a;
  Vll l(n+1), r(n+1);

  {
    priority_queue<int, vector<int>, greater<int>> pq;
    ll sum = 0;
    rep(i, n) {
      sum += a[i];
      pq.push(a[i]);
    }

    l[0] = sum;
    rep(i, n) {
      sum += a[n+i];
      pq.push(a[n+i]);
      sum -= pq.top(); pq.pop();
      l[i+1] = sum;
    }
  }
  
  {
    priority_queue<int> pq;
    ll sum = 0;
    drep(i, n) {
      sum += a[2*n+i];
      pq.push(a[2*n+i]);
    }

    r[n] = sum;
    drep(i, n) {
      sum += a[n+i];
      pq.push(a[n+i]);
      sum -= pq.top(); pq.pop();
      r[i] = sum;
    }
  }

  ll ans = -INFll;
  rep(i, n+1) chmax(ans, l[i] - r[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5104
#include<cstdio>
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<utility>
using namespace std;
int a[100009];
vector<int> rev[100009];
int search(int x){
	vector<int> len;
	if(rev[x].empty())return 0;
	for(int i=0;i<rev[x].size();i++){
		len.push_back(search(rev[x][i]));
	}
	sort(len.begin(),len.end(),greater<int>());
	for(int i=0;i<len.size();i++){
		len[i]+=i+1;
	}
	sort(len.begin(),len.end(),greater<int>());
	return len[0];
}
int main(){
	int n;
	cin>>n;
	for(int i=2;i<=n;i++){
		cin>>a[i];
		rev[a[i]].push_back(i);
	}
	cout<<search(1)<<endl;
	return 0;
}

Measured memory_bytes: 13952
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


void mtxprd( int p, int q, int r, const ll* A, const ll* B, ll* C )
{
    int i, j, k;
    for(i=0; i<p; i++) {
        for(k=0; k<r; k++) {
            C[i*r+k] = 0;
            for(j=0; j<q; j++) {
                C[i*r+k] = (C[i*r+k] + A[i*q+j] * B[j*r+k])%MOD;
            }
        }
    } 
    return;
}
 
void mtxuni(int dim, ll* mtx){
    int i,j;
    for(i=0; i<dim; i++) {
        for(j=0; j<dim; j++) {
            mtx[i*dim+j]=(i==j? 1: 0);
        }
    }
    return;
}
 
void mtxcpy(int dim, const ll* mtx, ll* mtx2){
    int i,j;
    for(i=0; i<dim; i++) {
        for(j=0; j<dim; j++) {
            mtx2[i*dim+j]=mtx[i*dim+j];
        }
    }
    return;
}
 
void mtxpow(int dim, const ll* mtx, ll n, ll* mtx2){ //x^n(mod M)
    vector<ll> mtx0(dim*dim);
    vector<ll> mtxtmp(dim*dim);
    mtxcpy( dim, mtx, &mtx0[0] );
    mtxuni( dim, mtx2 );
    while(n != 0){        
        if(n&1) {
            mtxprd( dim, dim, dim, mtx2, &mtx0[0], &mtxtmp[0] );
            mtxcpy( dim, &mtxtmp[0], mtx2 );
        }
        mtxprd( dim, dim, dim, &mtx0[0], &mtx0[0], &mtxtmp[0] );
        mtxcpy( dim, &mtxtmp[0], &mtx0[0] );
        n = n >> 1;
    }
    return;
}

int main(int argc, char* argv[])
{
    int n, m;
    scanf("%d%d", &n, &m);

    vector<ll> a(n*m);
    int i,j;
    for(i=0; i<n; i++) {
        for(j=0; j<m; j++) {
            scanf("%lld", &a[i*m+j]);
        }
    }
    vector<ll> b(m);
    for(j=0; j<m; j++) {
        scanf("%lld", &b[j]);
    }
    vector<ll> c(n);
    mtxprd(n, m, 1, &a[0], &b[0], &c[0] );

    for(i=0; i<n; i++) {
        printf("%lld\n", c[i]);
    }

    return 0;
}



Measured memory_bytes: 2736
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def sum_n(n):
    return int(n*(1+n)/2)


N = int(input())

if (N == 1):
    print(0)
    exit(0)

fac = factorization(N)


count = 0

for i in range(len(fac)):
    j = 0
    while (True):
        j += 1
        if (sum_n(j) == fac[i][1]):
            break
        elif (sum_n(j) > fac[i][1]):
            j = j - 1
            break

    count += j

print(count)


Measured memory_bytes: 9508
#include <stdio.h>

int main(void)
{
	int  w, n;
	int  lottery[31];
	int  i;
	char str[6];
	
	scanf("%d", &w);
	scanf("%d", &n);
	for (i = 1; i <= w; i++){
		lottery[i] = i;
	}
	for (i = 0; i < n; i++){
		int a, b;
		int tmp;
		
		scanf("%s", str);
		a = str[0] - '0';
		if (str[1] != ','){
			a = a * 10 + (str[1] - '0');
			//str[2] == ','
			b = str[3] - '0';
			if (str[4] != '\0'){
				b = b * 10 + (str[4] - '0');
			}
		}
		else {
			//str[1] == ','
			b = str[2] - '0';
			if (str[3] != '\0'){
				b = b * 10 + (str[3] - '0');
			}
		}
		tmp = lottery[a];
		lottery[a] = lottery[b];
		lottery[b] = tmp;
	}
	for (i = 1; i <= w; i++){
		printf("%d\n", lottery[i]);
	}
	
	return (0);
}

Measured memory_bytes: 596
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split();
        int[] list = new int[N];
        for(int i = 0; i < N; i++)
        {
            list[i] = int.Parse(input[i]);
        }
        int ans = 0;
        for(int i = 0; i < N-2; i++)
        {
            if (list[i] > list[i + 1] && list[i + 1] > list[i + 2]) { ans++; }
            else if(list[i] < list[i + 1] && list[i + 1] < list[i + 2]) { ans++; }

        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#include <cstdio>

void trace(int A[], int N)
{
    for (int i = 0; i < N; i++)
    {
        if (i > 0)
        {
            printf(" ");
        }
        printf("%d", A[i]);
    }
    printf("\n");
}

int bubbleSort(int A[], int N)
{
    int flag = 1;
    int cnt = 0;
    while (flag)
    {
        flag = 0;
        for (int j = N-1; j > 0; j--)
        {
            if (A[j] < A[j-1])
            {   
                int tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                flag = 1;
                cnt++;
            }
        }
    }
    return cnt;
}

int main(){
    int N;
    scanf("%d", &N);

    int A[N];

    for (int i = 0; i < N; i++)
    {
        scanf("%d", &A[i]);
    }

    int cnt = bubbleSort(A, N);
    trace(A, N);
    printf("%d", cnt);
    printf("\n");

    return 0;
}


Measured memory_bytes: 2756
#
import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    s = input()
    front = int(s[0:2])
    back = int(s[2:4])
    if 0 < front < 13:  # front can be month
        if 0 < back < 13: # back can be month
            print('AMBIGUOUS')
        else: # back can not be month
            print('MMYY')
    else: # front can not be month
        if 0 < back < 13: # back can be month
            print('YYMM')
        else: # back can not be month
            print('NA')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
bool isprime[1000001];
vector<int> prime;
int main() {
    fill(isprime, isprime+1000001, true);
    isprime[0]=isprime[1]=false;
    for (int i=2; i<1000001; i++) {
        if (isprime[i]) {
            prime.push_back(i);
            for (int j=i+i; j<1000001; j+=i) isprime[j]=false;
        }
    }
    int n;
    while (scanf("%d",&n)) {
        if (!n) break;
        printf("%d\n",upper_bound(prime.begin(),prime.end(),2*n)-upper_bound(prime.begin(),prime.end(),n));
    }
}

Measured memory_bytes: 0
/*input
5 5
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
*/
 
#include <unordered_map>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
 
using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define ar array
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define tests int r; cin >> r; while(r--)
#define MP make_pair
#define PI acos(-1)
typedef pair<long long, long long> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
#define godspeed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
 
#define M(x) ((x)%(1000000007))
 
 int64 fact(int n) {
   int64 count = 1;
   for(int64 i = 1;i<=n;i++){
   		count = M(count * i);
   }
   return count;
}
 
 
 
int main() {
	godspeed;
	int64 n;
	cin>>n;
	int64 w;
	cin>>w;
	int64 dp[n+1][w+1];
	memset(dp,0,sizeof(dp));
	int64 val[n];
	int64 weight[n];
	rep(i,n){
		int64 a;
		int64 b;
		cin>>a>>b;
		weight[i] = a;
		val[i] = b;
	}
	for(int i = 1; i<=n; i++){
		for(int j = 1; j<=w; j++){
			int64 ma = dp[i-1][j];
			if(j-weight[i-1]>=0){
				ma = max(ma, dp[i-1][j-weight[i-1]] + val[i-1]);
			}
			dp[i][j] = ma;
		}
	}
	cout<<dp[n][w]<<endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;
const int mod = 1e9 + 7;

int main(){
    ll n;
    cin >> n;
    int u, v;
    ll res = n * (n+1) * (n+2) / 6; // 各頂点を含む[L, R]の数の和
    for (int i = 0; i < n - 1; ++i) {
        cin >> u >> v;
        if (u > v) swap(u, v);
        res -= u * (n - v + 1); //　各辺を含む[L, R]の数の和
    }
    cout << res << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-9;
const int inf=1e8;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	int a;
	cin>>a;
	if(a<1200)cout<<"ABC"<<endl;
	else cout<<"ARC"<<endl;
}










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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int j=0;j<n;j++){
    cin >> a[j];
  }

  long long ans = 0;
  long long sum = a[0];
  long long ans1;
  long long ans2;
  long long ans3;
  long long ans4;
  if(a[0] != 0){
    for(int i=1;i<n;i++){
      long long sum_old = sum;
      sum = sum + a[i];
      if((long long)(sum * sum_old) < 0){
      }
      else{
        ans = ans + abs(sum) + 1;
        sum = (sum_old / abs(sum_old)) * -1;
      }
    }
    ans1 = ans;

    ans = abs(a[0]) + 1;
    sum = (a[0] / abs(a[0]) * -1);
    for(int i=1;i<n;i++){
      long long sum_old = sum;
      sum = sum + a[i];
      if((long long)(sum * sum_old) < 0){
      }
      else{
        ans = ans + abs(sum) + 1;
        sum = (sum_old / abs(sum_old)) * -1;
      }
    }
    ans2 = ans;
    ans = min(ans1, ans2);
  }
  else{
    sum = 1;
    ans = 1;
    for(int i=1;i<n;i++){
      long long sum_old = sum;
      sum = sum + a[i];
      if((long long)(sum * sum_old) < 0){
      }
      else{
        ans = ans + abs(sum) + 1;
        sum = (sum_old / abs(sum_old)) * -1;
      }
    }
    ans3 = ans;

    sum = -1;
    ans = 1;
    for(int i=1;i<n;i++){
      long long sum_old = sum;
      sum = sum + a[i];
      if((long long)(sum * sum_old) < 0){
      }
      else{
        ans = ans + abs(sum) + 1;
        sum = (sum_old / abs(sum_old)) * -1;
      }
    }
    ans4 = ans;
    ans = min(ans3, ans4);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.ArrayList;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		double sum = 0;
		int answer = 0;
		double average = 0;
		double memo = 0;
		ArrayList<Double> arrayList = new ArrayList<Double>();
		for(int i = 0; i < a; i++){
			double b = sc.nextInt();
			sum += b;
			arrayList.add(b);
		}
		average = sum/a ;
		memo = arrayList.get(0);
		for(int i = 1; i < a; i++){
			if(Math.abs(average-memo)>Math.abs(average-arrayList.get(i))){
				memo = arrayList.get(i);
				answer = i;
			}
		}
		System.out.println(answer);
	}
}

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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, M, ans=0, tmp=0, tmp1=0, tmp2=0;
vector<ll> A, B, SA, SB;

signed main(){
    cin >> N >> M;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    for(int i=0;i<M;i++) {
        ll a;
        cin >> a;
        B.push_back(a);
    }
    tmp = N*(N-1)/2;
    for(int i=0;i<N-1;i++) {
        ll num = tmp-i*(i+1)/2-(N-i-1)*(N-i-2)/2;
        tmp1 += num*(A[i+1]-A[i]);
        tmp1 %= MOD;
    }
    tmp = M*(M-1)/2;
    for(int i=0;i<M-1;i++) {
        ll num = tmp-i*(i+1)/2-(M-i-1)*(M-i-2)/2;
        tmp2 += num*(B[i+1]-B[i]);
        tmp2 %= MOD;
    }
    ans = tmp1*tmp2;
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5524
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	sc.Scan()
	var abc = strings.Split(sc.Text(), " ")
	if len(abc) != 3 {
		fmt.Println("Illegal arguments.")
		return
	}
	var a, err1 = strconv.Atoi(abc[0])
	if err1 != nil {
		fmt.Println(err1)
		return
	}
	var b, err2 = strconv.Atoi(abc[1])
	if err2 != nil {
		fmt.Println(err2)
		return
	}
	var c, err3 = strconv.Atoi(abc[2])
	if err3 != nil {
		fmt.Println(err3)
		return
	}
	if a < b && b < c {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


Measured memory_bytes: 1104
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    s=input()
    if s=='MON':
        print(6)
    elif s=='TUE':
        print(5) 
    elif s=='WED':
        print(4) 
    elif s=='THU':
        print(3) 
    elif s=='FRI':
        print(2) 
    elif s=='SAT':
        print(1) 
    elif s=='SUN':
        print(7) 

if __name__ == "__main__":
    main()

Measured memory_bytes: 4456
#include<bits/stdc++.h>
using ll = int_fast64_t;

struct Segtree{
        using F = std::function<ll(ll,ll)>;
        std::vector<ll> seg;
        int size;
        ll unit;
        F func;

        Segtree(int n, ll u, F f): unit(u), func(f) {
                size = 1;
                while(size<n) size <<= 1;
                seg.assign(2*size-1, unit);
                for(int k=size-2; k>=0; k--) seg[k] = func(seg[2*k+1], seg[2*k+2]);
        }

        void update(int idx, ll x){
                idx += size-1;
                seg[idx] = x;
                while(idx>0){
                        idx = (idx-1) / 2;
                        seg[idx] = func(seg[2*idx+1], seg[2*idx+2]);
                }
        }

        ll query(int a, int b, int k=0, int l=0, int r=-1){
                if(r<0) r = size;
                if(b<=l or r<=a) return unit;
                if(a<=l and r<=b) return seg[k];
                ll lvalue = query(a, b, 2*k+1, l, (l+r)/2);
                ll rvalue = query(a, b, 2*k+2, (l+r)/2, r);
                return func(lvalue, rvalue);
        }
};


int main(){
        int n, q;
        scanf("%d %d", &n, &q);
        Segtree seg(n, INT_MAX, [](ll a, ll b){return std::min(a, b);});
        for(int i=0; i<q; i++){
                int com, x, y;
                scanf("%d %d %d", &com, &x, &y);
                if(com==0) seg.update(x, y);
                else printf("%ld\n", seg.query(x, y+1));
        }
}


Measured memory_bytes: 4944
#include <iostream>

int main(void){
  int a, b, tmp, count = 0;
  std::cin >> a >> b;
  while(a <= b){
    tmp = a;
    if(tmp/10000%10 == tmp%10)
      if(tmp/1000%10 == tmp/10%10)
        count++;
    a++;
  }
  std::cout << count << std::endl;
  return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end());
#define fill(a,x) memset(a,x,sizeof(a))
#define zero(a) fill(a,0)
#define minus(a) fill(a,-1)
#define dbg(x) cout << #x"=" << x << endl

int main() {
  ll ac=0;
  ll wa=0;
  ll n, num;
  ll m;
  ll counter=0;
  string subm="";
  map<int, string> mp;
  cin >> n;
  cin >> m;
  vi acArray;
  vi pena(n+1);
  while(counter<m) {
    if(m==0) break;
    cin >> num;
    cin >> subm;
    if (mp[num] == "") {
      if(subm == "WA") {
        pena[num]++;
      }else{
        ac++;
        mp[num] = "AC";
      }
    }
    counter++;
  }

  rep(i, n+1) {
    if (mp[i] != "") {
      wa += pena[i];
    }
  }
  cout << ac << ' ' << wa << endl;
  return 0;
}


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

int main()
{
    //freopen("test.in","r",stdin);
    //freopen("test.ok","w",stdout);
    int64_t n,i;
    cin >> n;
    int64_t s[n];
    for (int i=0;i<n;i++)
    {
        cin >> s[i];
        if (s[i]%2==0) 
            if (s[i]%3==0 || s[i]%5==0); 
                else 
                {
                    cout << "DENIED";
                    break;
                }
        if (i==n-1) cout << "APPROVED";
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=550;
//↑templete
int main() {
	int N;
	cin>>N;
	int D[SIZE][SIZE]={};
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			for(int k=0;k<32;k++)
				if(((i>>k)&1)^((j>>k)&1)){
					D[i][j]=k+1;
					break;
				}
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++)
			cout<<D[i][j]<<" ";
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	fastio
	int n;
	cin>>n;
	cout<<(1000-n%1000)%1000;
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    int n; cin >> n;
    rep(i,n) {
        char c; cin >> c;
        if (c == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
}

Measured memory_bytes: 256
s = input()

s1 = s[0:len(s)//2]
s2 = s[len(s)-len(s)//2:len(s)]
s2 = s2[::-1]

count = 0

for i in range(len(s1)) :
  if s1[i:i+1] != s2[i:i+1] :
    count += 1

print(count)

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    int n,i,g=1;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",s);
    for(i=1;i<n;i++){
        if(s[i]!=s[i-1]) g++;
    }
    printf("%d\n",g);
    return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
INF = 10**12
goods = [tuple(map(int, input().split())) for _ in range(N)]
total_val = 0
for item in goods:
    total_val += item[1]
dp = [[INF for i in range(total_val+1)] for j in range(N+1)]
dp[0][0] = 0
for i, item in enumerate(goods):
    i += 1
    for v in range(total_val+1):
        if v < item[1]:
            dp[i][v] = dp[i-1][v]
        else:
            dp[i][v] = min(dp[i-1][v], dp[i-1][v-item[1]] + item[0])

for i in range(total_val+1):
    if dp[N][i] <= W:
        ans = i
print(ans)

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

using namespace std;

typedef long long ll;

int m=1e9+7;

int fun(int n,int r)
{
    vector<int>C(r+1,0);
    C[0]=1;
    for(int i=0;i<=n;i++)
      {
          for(int j=min(i,r);j>0;j--)
          C[j]=(C[j]+C[j-1])%m;
      }
      return C[r];
}

ll modularExponentiation(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%m;
        x=(x*x)%m;
        n=n/2;
    }
    return result;
}

// code calculating the nCa
ll calculate(ll n, ll a){
    if( a > n )
        return 0;
    
    ll numerator = 1, denominator = 1;
    for(ll i = a; i > 0; i--){
        numerator = ( numerator*n )%m;
        denominator = ( denominator*a )%m;
        n--, a--;
    }

    ll res = ( numerator * modularExponentiation(denominator, m-2) )%m;

    return res;
}

int main()
{
  ll n,a,b;
  cin>>n>>a>>b;
  ll ans=(modularExponentiation(2,n)%m-1+m)%m;
  ll a1=calculate(n,a);
  ll b1=calculate(n,b);

  ans = (ans%m - a1%m + m)%m;
  ans = (ans%m - b1%m + m)%m;
  cout<<ans;
  
  return 0;
}


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

int main(void){
    int N;
    cin >> N;
    vector<int> A(N);
    
    
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    sort(A.begin(), A.end(), less<int>());

    vector<int> B(0);
    B.push_back(1);
    for(int i = 1; i < N; i++){
        if(A[i] == A[i-1]) {
            B[B.size()-1]++;
        } else {
            B.push_back(1);
        }
    }

    int cnt = 0;
    int bsize = B.size();
    for(int i = 0; i < bsize; i++){
        if(B[i] % 2 != 0) cnt++;
    }

    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 4248
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,m,n) for(ll i=(m);i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back





int main(){

     ll n;
     cin>>n;
     vector<ll> data(n);
     rep(i,n){
         ll tmp;
         cin>>tmp;
         data.at(i)=tmp;
     }


     ll answer=0;

     for (ll i=1;i<n;i++){
         if (data.at(i)<data.at(i-1)){
             answer+=(data.at(i-1)-data.at(i));
             data.at(i)=data.at(i-1);
         }
     }

     cout<<answer<<endl;

}

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

using namespace std;

#define int long long

using ll = long long;
using pii =  pair<int, int>;

const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;

#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_(i,0,n)
#define rrep(i,n) rfor_(i,0,n)

#define pb push_back
//#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))

#define endl '\n'

const int limit = 100007;

int N, A;

signed main(){
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  
  cin>>N>>A;
  
  cout<<(N*N-A)<<endl;
  
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#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(void)
{
  for(;;){
    int n,m,q;
    cin >> n >> m >> q;
    if(!n&&!m&&!q) return 0;
    string preb="";
    REP(i,m) preb.push_back('0');
    int prob[1024][64];
    REP(i,m) REP(j,n) prob[i][j]=1;
    REP(i,q){
      string s,b;
      cin >> s >> b;
      REP(j,m){
	if(preb[j]!=b[j]){
	  REP(k,n) if(s[k]=='0') prob[j][k]=0;
	}else{
	  REP(k,n) if(s[k]=='1') prob[j][k]=0;
	}
      }
      preb=b;
    }
    REP(i,m){
      int p=0,ans=0;
      REP(j,n){
	if(prob[i][j]){
	  ++p;
	  ans=j;
	}
      }
      if(p!=1) cout << '?';
      else{
	if(ans>9) cout << (char)('A'+ans-10);
	else cout << (char)('0'+ans);
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;



int main(){
    int n; cin >> n;
    if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9){
        cout << "hon" << endl;
    }
    else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
        cout << "pon" << endl;
    }
    else{
        cout << "bon" << endl;
    }

   

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define mod(n) (n) % 1000000007
#define sp << " "
#define precision(n) cout << fixed << setprecision(n);
#define startTime time_t start, end;time(&start);
#define endTime time(&end);double tt = double(end-start);cout<<"Time taken : "<<fixed<<tt<<setprecision(5);cout <<" sec"<< endl;
 
using namespace std;
 
int main() { 
    IOS;
    precision(10);
    ll n;
    cin >> n;
    vector<double> p(n, 0);
    int cnt1 = 0, cnt2 = 0, cnt3 = 0;
    for (int i = 0; i < n; i++) {
    	cin >> p[i];
    	if (p[i] == 1) cnt1++;
    	else if (p[i] == 2) cnt2++;
    	else cnt3++;
    }
    vector<vector<vector<double>>> dp(cnt3 + 1, vector<vector<double>>(cnt3 + cnt2 + 1, vector<double>(cnt3 + cnt2 + cnt1 + 1, 0.0)));

    for (int i = 0; i < cnt3 + 1; i++) {
    	for (int j = 0; i + j < cnt3 + cnt2 + 1; j++) {
    		for (int k = 0; i + j + k < cnt3 + cnt2 + cnt1 + 1; k++) {
    			if (i + j + k > cnt3 + cnt2 + cnt1 || i + j + k == 0) continue;
    			double a = 0.0, b = 0.0, c = 0.0, d = 0.0;
    			if (k) a = dp[i][j][k - 1] * (double)(k) / (i + j + k);
    			if (j) b = dp[i][j - 1][k + 1] * (double)(j) / (i + j + k);
    			if (i) c = dp[i - 1][j + 1][k] * (double)(i) / (i + j + k);
    			d = (double)(n) / (i + j + k);
    			dp[i][j][k] = a + b + c + d;
    		}
    	}
    }
    cout << dp[cnt3][cnt2][cnt1] << endl;    
}

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

int main(){

    ll a , b , c ;
    cin >> a >> b >> c ;
    a= abs(a) ;
    ll z = a/c ;

    if (z >= b) {
        cout << abs( a - b * c ) << endl ;
        return 0 ;
    }

    b-=z ;
    ll ans = abs(a-z*c) ;

    if (b%2) {
        cout << abs(ans - c) ;
    }
    else cout << ans ;

    return 0 ;
}


Measured memory_bytes: 3632
package main

import (
    "fmt"
)

func main() {
    var n int
    fmt.Scan(&n)
    bs := make([]int, n)
    for i := 0; i < n; i++ {
        var b int
        fmt.Scan(&b)
        bs[i] = b
    }

    if isValid(bs) {
        res := calc(bs)
        for _, v := range res {
            fmt.Println(v)
        }
    } else {
        fmt.Println(-1)
    }
}

func calc(ts []int) []int {
    if len(ts) == 1 && ts[0] == 1 {
        return []int{1}
    }
    for i, v := range ts {
        ns := make([]int, len(ts)-1)
        for j := range ns {
            if j < i {
                ns[j] = ts[j]
            } else {
                ns[j] = ts[j+1]
            }
        }
        if isValid(ns) {
            return append(calc(ns), v)
        }
    }
    return []int{}
}

func isValid(ts []int) bool {
    for i, v := range ts {
        if v > i+1 {
            return false
        }
    }
    return true
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define inf 2000000000
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false);cin.tie(NULL)
#define rng_23 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define mod 998244353
 using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef set<int> si;
typedef multiset<int> msi;
typedef map<int,int> mii;
int ara[3001];
ll dp[3001][3001];
int main()
{
    int i,j,k;
    int n,s;
    scanf("%d %d",&n,&s);
    for(i=1;i<=n;i++)
        scanf("%d",&ara[i]);
    dp[0][0]=1;
    for(i=1;i<=n;i++){
        for(j=0;j<=3000;j++)
            dp[i][j]=(2*dp[i-1][j]+((j>=ara[i])? dp[i-1][j-ara[i]]:0))%mod;
    }
    printf("%lld",dp[n][s]);
}


Measured memory_bytes: 74096
//////////////      VATSAL AGARWAL       ////////////////////////
////////////// Codeforces id : warhead38 ////////////////////////
////////////// Codechef   id : vatsal38  //////////////////////// 


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define endl '\n'
#define loop(var,a,b,c) for(ll var=a;var<=b;var+=c)
#define intarr(arr,n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i]
#define inparr(arr,n) for(ll i=0;i<n;i++)cin>>arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define newline cout<<endl
#define ump unordered_map<ll,ll>
#define vec vector<ll>
#define mkp make_pair
#define disp(var1,var2) cout<<var1<<" "<<var2<<endl;
#define all(v)             v.begin(),v.end()
#define cout(var) cout<<var<<endl
#define mod2 998244353
#define fbo find_by_order  /// find kth smallest by passing k-1
#define ook order_of_key  //// find no of smaller items less than k
#define teensort(a,r,g,b) a[0]=r;a[1]=g;a[2]=b;sort(a,a+3);
#define ss second
#define ff first
#define displayarray(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
#define pi pair<ll,ll>
#define meramax 1e18
#define meramin -1e18
#define percentile 1000000007
#define PI 3.14159265358979323846
#define input2darr(n,m,in) ll a[n+1][m+1];if(in==0){loop(i,0,n-1,1)loop(j,0,m-1,1)cin>>a[i][j];}else{loop(i,1,n,1)loop(j,1,m,1)cin>>a[i][j];}
#define output2darr(n,m,in) if(in==0){loop(i,0,n-1,1){loop(j,0,m-1,1)cout<<a[i][j]<<" ";cout<<endl;}}else{loop(i,1,n,1){loop(j,1,m,1)cout<<a[i][j]<<" ";}cout<<endl;}
#define minheap priority_queue<ll>
#define maxheap priority_queue<ll,vector<ll>,greater<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////                                     ///////////////////////////////////////////////////////////////
////////////////////////////////////////              CODE                   ///////////////////////////////////////////////////////////////
////////////////////////////////////////                                     ///////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void AcDegaYe()
{
    ll n;
    cin>>n;
    if(n%1000==0)cout(0);
    else cout(1000-n%1000);
}
int main()
{   
    fastio

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    //ll t;
    //cin>>t;
    ll t=1;
    while(t--)
    {
        AcDegaYe();
    }
    //cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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


typedef long long ll;
const ll MOD = 1000000007;

int main(){

    ll N, M;
    cin>>N>>M;
    vector<ll>A(N), B(M);
    set<ll>AS, BS;
    for(ll i=0;i<N;i++){
        cin>>A[i];
        AS.insert(A[i]);
    }
    for(ll i=0;i<M;i++){
        cin>>B[i];
        BS.insert(B[i]);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    if(AS.size()!=N || BS.size()!=M){
        cout << 0<<endl;
        return 0;
    }

    ll ans = 1;
    ll Al = N;
    ll Bl = M;
    for(ll i = 0; i < N*M; i++){
        ll num = N*M-i;
        for(;Al > 0;Al--)if(A[Al-1]<num)break;
        for(;Bl > 0;Bl--)if(B[Bl-1]<num)break;
        ll Aw = N - Al;
        ll Bw = M - Bl;
        if(AS.count(num) && BS.count(num))continue;
        if(AS.count(num)){
            ans = ans * Bw % MOD;
            continue;
        }
        if(BS.count(num)){
            ans = ans * Aw % MOD;
            continue;
        }
        ll tmp = Aw * Bw - i;
        if(tmp <= 0)ans = 0;
        else ans = ans * tmp % MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
n = int(input())
alpha = "abcdefghijklmnopqrstuvwxyz"
tmp = [26 ** i for i in range(1, 20)]
lst = [0]
for num in tmp:
    lst.append(lst[-1] + num)
for i, num in enumerate(lst):
    if num >= n:
        p = i
        break
ans = list("a" * p)
n -= lst[p - 1] + 1
for i in range(p - 1, -1, -1):
    if n == 0:
        break
    pos = n % 26
    n //= 26
    ans[i] = alpha[pos]
print("".join(ans))

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

using namespace std;

int mp[8][8] = {};
int k[12] = { 1, 2, 3, -1, -2, -3, 0, 0, 0, 0, 0, 0 };
int h[12] = { 0, 0, 0, 0, 0, 0, 1, 2, 3, -1, -2, -3 };

void bomb(int x, int y) {
	if (x < 0 || x > 7 || y < 0 || y > 7)
		return;
	if (mp[x][y] == 0)
		return;
	mp[x][y] = 0;
	for (int i = 0; i < 12; i++) {
		bomb(x + k[i], y + h[i]);
	}
	return;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 8; j++) {
			int a;
			cin >> a;
			for (int o = 7; o >= 0; o--) {
				mp[o][j] = a % 10;
				a /= 10;
			}
		}
		int x, y;
		cin >> x;
		cin >> y;
		bomb(x -1, y -1);
		cout << "Data " << i + 1 << ":" << endl;
		for (int j = 0; j < 8; j++) {
			for (int o = 0; o < 8; o++) {
				cout << mp[o][j];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3000
#include <string>
#include <math.h>
#include <iostream>
 
using namespace std;
 
int main()
{
  int a, b;
  cin >> a >> b;
  int aa = 0;
  int bb = 0;
  int cc = 0;
  int dd = 0;
  int ee = 0;
  int ff = 0;
  
  if (a == 1)
    ee = 300000;
  else if (a == 2)
    aa = 200000;
  else if (a == 3)
    bb = 100000;
   if (b == 1)
    ff = 300000;
   else if (b == 2)
    cc = 200000;
   else if (b == 3)
    dd = 100000;
  
  if (a == 1 && b == 1)
    cout << "1000000";
  else
    cout << aa + bb + cc + dd + ee + ff;
}

Measured memory_bytes: 3604
# 100 => 99 => 18
# 9995 => 9989=> 35 9994
# 9944 => 9944 => 9939
# 9499 => 9499 => 8999
# 9444 => 8999
# 5444 => 4999 
# 994 => 989

N=int(raw_input())

dig=[]
rem = N

while rem>0:
    dig.append( rem % 10)
    rem = rem / 10

dig.reverse()

#print dig

for i in range(1, len(dig)):
    if dig[i] < 9:
        dig[i-1] = dig[i-1] - 1
        dig[i] = 9
        for j in range(i+1, len(dig)):
            dig[j] = 9
        break

#print dig

sum=0

for d in dig:
    sum = sum + d

print sum



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int X,N;
int NG[1011];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>X>>N;
	FOR(i,N) {
		cin>>x;
		NG[x]=1;
	}
	
	int ret=-2020;
	for(i=-100;i<=1010;i++) {
		if(i>=0 && NG[i]) continue;
		if(abs(X-i)<abs(X-ret)) ret=i;
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int M = scan.nextInt();

		Integer[] aList = new Integer[M];
		for (int i = 0; i < M; i++) {
			int a = scan.nextInt();
			aList[i] = a;
		}

		int wDay = 0;
		for (int i = 0; i < aList.length; i++) {
			wDay = wDay + aList[i];
		}

		if (N < wDay) {
			System.out.println("-1");
		} else {
			System.out.println(N - wDay);
		}

	}
}


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

using namespace std;

typedef long long ll;

const int N = 1e5;
const int INF = 1e9;


int dp[N + 1][3];

int main() {
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i] >> c[i];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for (int i = 1; i < n; i++) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }
    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
}



Measured memory_bytes: 2560
from collections import Counter

N = int(input())

A = [str(i) for i in range(1, N + 1)]

C = Counter()
for s in A:
    C[s[0] + s[-1]] += 1

ans = 0
for s in A:
    if s[0] != '0' and s[-1] != '0':
        ans += C[s[-1] + s[0]]

print(ans)


Measured memory_bytes: 16116
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;
int R, C, N, X1, Y1, X2, Y2;
bool TREE[1 << 19];
vector<pair<int, int>>v;
set<int>st;

bool f(int x, int y) {
	if (x == 0 || x == R || y == 0 || y == C)return true;
	else return false;
}
pair<int, int> ff(){
	int a, b;
	if (Y1 == 0) {
		a = X1;
	}
	else if(Y1 == C){
		a = R + C + R - X1;
	}
	else if (X1 == 0) {
		a = R + C + R + C - Y1;
	}
	else if (X1 == R) {
		a = R + Y1;
	}
	if (Y2 == 0) {
		b = X2;
	}
	else if(Y2 == C){
		b = R + C + R - X2;
	}
	else if (X2 == 0) {
		b = R + C + R + C - Y2;
	}
	else if (X2 == R) {
		b = R + Y2;
	}
	
	if (a > b)swap(a, b);
	return mkp(a, b);
}
int main() {
	cin >> R >> C >> N;
	for (int i = 0; i < N; ++i) {
		cin >> X1 >> Y1 >> X2 >> Y2;
		if (f(X1, Y1) && f(X2, Y2)) {
			v.push_back(ff());
		}
	}
	sort(v.begin(), v.end());
	st.insert(-1);
	for (int i = 0; i != v.size(); ++i) {
		auto it = st.insert(v[i].second).first;
		--it;
		if (*it > v[i].first) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }
#define dump(...) cout<<#__VA_ARGS__<<": [L_"<<__LINE__<<"]"<<'\n'; print(__VA_ARGS__);cout<<'\n';

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

int main() {
  string s; cin>>s;
  s = '0' + s;
  int n = s.size();
  vector<vector<int>> dp(n, vector<int>(2, INF));
  dp[0][0] = 0;
  dp[0][1] = 1;

  REP(i, 1, n) {
    int x = s[i] - '0';
    int y = 10 - x;
    dp[i][0] = min(dp[i-1][0]+x, dp[i-1][1]+y);
    dp[i][1] = min(dp[i-1][0]+x+1, dp[i-1][1]+y-1);
  }

  print(dp[n-1][0]);

  return 0;
}

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

long long cnt(long long a){
    long long res = 0;
    while(a != 0){
        res++;
        a /= 10;
    }
    return res;
}

void solve(long long N){
    long long res = N;
    for(long long i=1; i*i <= N; i++){
        if(N%i == 0){
            res = min(res, max(cnt(i), cnt(N/i)));
        }
    }

    cout << res << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/2/24
Solved on 2019/2/
@author: shinjisu
"""


# ABC 076 C Explanation
def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7


def dmp(x, cmt=''):
    global debug
    if debug:
        if cmt != '':
            print(cmt, ':  ', end='')
        print(x)
    return x


def probC():
    N = getInt()
    dmp(N)
    count = N // (5+6) * 2
    rem = N % (5+6)
    if rem > 6:
        count += 2
    elif rem > 0:
        count += 1
    return count


debug = False  # True False
ans = probC()
print(ans)
#for row in ans:
#    print(row)


Measured memory_bytes: 3064