akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll int,ll int>
#define pdd pair<double,double>
#define MOD 1000000007
using namespace std;

//--------------------SEGMENT TREE IMPLEMENTATION WITH LAZY UPDATE FOR RANGE SUM----------------

ll int segtree[200005];
ll int arr[100005];
ll int seglazy[200005];

void build(int node,int st,int en)
{
	if(st==en)
	{
		segtree[node]=arr[st];
		return;
	}

	int mid=(st+en)/2;

	build(2*node,st,mid);
	build(2*node+1,mid+1,en);

	segtree[node]=segtree[2*node]+segtree[2*node+1];
}

ll int query(int node,int st,int en,int l,int r)
{
	if(l > en || r < st)
	{
		return 0;
	}

	if(l<=st && r>=en) return segtree[node];

	int mid=(st+en)/2;

	ll int p1=query(2*node,st,mid,l,r);
	ll int p2=query(2*node+1,mid+1,en,l,r);

	return p1+p2;
}

void updateRangeLazy(int node,int st,int en,int l,int r,int val)	// Value changed to 'val'
{
	if(st > en || l > en || r < st) return;

	if(seglazy[node]!=0)
	{
		segtree[node]+=(en-st+1)*seglazy[node];

		if(st!=en)
		{
			seglazy[2*node]+=seglazy[node];
			seglazy[2*node+1]+=seglazy[node];
		}
		seglazy[node]=0;
	}

	if(l<=st && en<=r)
	{
		segtree[node]=(en-st+1)*val;

		if(st!=en)
		{
			seglazy[2*node]+=val;
			seglazy[2*node+1]+=val;
		}
		return;
	}

	int mid=(st+en)/2;

	updateRangeLazy(2*node,st,mid,l,r,val);
	updateRangeLazy(2*node+1,mid+1,en,l,r,val);

	segtree[node]=segtree[2*node]+segtree[2*node+1];
}

//------------------POWER, GCD, LCM and INVERSE MODULO FUNCTIONS-----------------------------

ll int pow(ll int base,ll int p,ll int mod = MOD)
{
	ll int powAns = 1;

	while(p)
	{
		if(p%2)
		{
			powAns=(powAns*base)%mod;
		}

		base=(base*base)%mod;
		p=p/2;
	}

	return powAns;
}

ll int gcd(ll int a, ll int b)
{
	if(b==0) return a;
	else return gcd(b,a%b);
}

ll int lcm(ll int a,ll int b)
{
	return (a*b)/gcd(a,b);
}

ll int invMod(ll int val)
{
	return pow(val,MOD-2,MOD);
}

//---------------------------------MAIN STARTS HERE------------------------------------------

int check(long long int x)
{
	// cout<<"yay : "<<x<<endl;

	int ans  = x&(x-1);

	if(ans==0) return 1;
	else return 0;
}

long long int get2Pow(long long int val)
{
	long long int x = 1;

	while(x<=val)
	{
		x=x*2;
	}

	return x-1;
}

long long int getMax(long long int val)
{
	for(int i=2;i*i<=val;i++)
	{
		if(val%i==0)
		{
			long long int a = i;
			long long int b = val/i;

			return max(a,b);
		}
	}

	return 1;
}

int main()
{
	// freopen("input.txt","r",stdin);		freopen("output.txt","w",stdout);
	
	int n,k;
	string str;

	cin>>n>>k;

	int tot=0;

	for(int i=1;i<=n;i+=2)
	{
		tot+=1;
	}

	if(tot>=k) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        long long a , b , c , k;
        cin >> a >> b >> c >> k;
        long long ans = 0;
        if(k % 2 == 0){
            ans = a - b;
        }else{
            ans = b - a;
        }
        cout << ans << endl;
        
        return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=550;
char ditu[maxn][maxn];
int cnt[maxn];
int n,m,t;
int sum1,sum2,sum3;
int main(){
//	scanf("%d",&t);
//	while(t--){
		memset(cnt,0,sizeof(cnt));
		memset(ditu,0,sizeof(ditu));
		scanf("%d%d",&n,&m);
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				cin>>ditu[i][j];
				cnt[ditu[i][j]-'a'+1]++;
			}
		}
		sum1=0,sum2=0,sum3=0;
		for(int i=1;i<=26;i++){
			while(cnt[i]>=4){
				cnt[i]-=4;
				sum1++;
			}
			if(cnt[i]>=2){
				cnt[i]-=2;
				sum2++;
			}
			if(cnt[i]) sum3++;
		}
		if(sum3>1||sum3==1&&!(n&1)||sum3==1&&!(m&1)){
			printf("No\n");
			return 0;
		}  
		if(sum1<(n/2)*(m/2)){
			printf("No\n");
			return 0;
		}
		printf("Yes\n");
//	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#pragma GCC optimise ("0fast")
 
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void inline add(int&,int);
int mul(int,int);
int powz(int,int);
int sub(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);
 
const int N=100002;

void solve(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<max(0,b+c-a);
	
}

 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void inline add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;
}


Measured memory_bytes: 256
"""
~~ Author : Bhaskar
~~ Dated : 13~06~2020
"""

import sys
from bisect import *
from math import floor, sqrt, ceil, factorial as F, gcd, pi
from itertools import chain, combinations, permutations, accumulate
from collections import Counter, defaultdict, OrderedDict, deque

INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize) - 1
mod = 1000000007
ch = "abcdefghijklmnopqrstuvwxyz"
lcm = lambda a, b: (a * b) // gcd(a, b)
setbit = lambda x: bin(x)[2:].count("1")
INT = lambda type: type(sys.stdin.readline()) if type in [int, float] else type(sys.stdin.readline()).replace("\n", "")
ARRAY = lambda type: list(map(type, sys.stdin.readline().split()))
NUMS = lambda type: map(type, sys.stdin.readline().split())


def solve():

    n = INT(int)
    print(2*pi*n)



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


Measured memory_bytes: 9452
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  ll n;
  cin >> s >> n;
  set<char> se;
  rep(i,s.size()) se.in(s[i]);
  if(se.size()==1) {
    ll d=(ll)s.size()*n;
    pr(d/2);
    return;
  }
  if(n<=2) {
    if(n==2) s+=s;
    vector<ll> v;
    ll c=1;
    REP(i,1,s.size()) {
      if(s[i-1]==s[i]) c++;
      else {
        v.pb(c);
        c=1;
      }
    }
    v.pb(c);
    ll ans=0;
    rep(i,v.size()) ans+=v[i]/2;
    pr(ans);
    return;
  }
  s+=s;
  vector<ll> v;
  ll c=1,k=0;
  REP(i,1,s.size()) {
    if(s[i-1]==s[i]) c++;
    else {
      v.pb(c);
      c=1;
      if(i>=s.size()/2) {
        k=i;
        break;
      }
    }
  }
  ll ans=0;
  if(s[0]!=s.back()) {
    rep(i,v.size()) ans+=(ll)v[i]/2*(n-1);
  } else {
    REP(i,1,v.size()) ans+=(ll)v[i]/2*(n-1);
    v.clear();
    c=1;
    REP(i,1,k-s.size()/2) {
      if(s[i-1]==s[i]) c++;
      else {
        v.pb(c);
        c=1;
      }
    }
    v.pb(c);
    rep(i,v.size()) ans+=(ll)v[i]/2;
  }
  v.clear();
  c=1;
  REP(i,k+1,s.size()) {
    if(s[i-1]==s[i]) c++;
    else {
      v.pb(c);
      c=1;
    }
  }
  v.pb(c);
  rep(i,v.size()) ans+=(ll)v[i]/2;
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s;
    cin >> s;
    for(int i = 0; i < 8; ++i) {
        int tmp = s[0] - '0';
        string t;
        for(int j = 0; j < 3; ++j) {
            if((i >> j) & 1) {
                t += "+";
                tmp += s[j + 1] - '0';

            } else {
                t += "-";
                tmp -= s[j + 1] - '0';

            }
        }
        if(tmp == 7) {
            for(int j = 0; j < t.size(); ++j) {
                cout << char(s[j]) << char(t[j]);

            }
            cout << char(s[s.size() - 1]) << "=7" << endl;
            return 0;
        }
    }
    return 0;
}



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

using namespace std;

#define FOR(i,s, t) for(int i = s; i < t; i++)
#define ALL(a)  a.begin(), a.end()
#define SZ(x) (int)x.size()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define SORT(a) sort(ALL(a))
using VI = vector<int>;
using LL = long long;
using VVL = vector<vector<LL>>;
using VL = vector<LL>;
const LL LINF = 1e18;

int main() {

	LL N, K;
	cin >> N >> K;
	if (K == 0) {
		cout << N*N << endl;
		return 0;
	}

	//// a%bについてみる
	//FOR(b, 1, N + 1) {
	//	cout << "b:" << b << ",, ";
	//	FOR(a, 1, N + 1) {
	//		cout << a%b << " ";
	//	}
	//	cout << endl;
	//}
	
	LL ans = 0;
	// a%bについてみる
	FOR(b, 1, N + 1) {
		if (b <= K)continue;

		int box = N / b;
		int backet = N%b;
		ans += box*(b - K);
		ans += max(0LL, backet - K+1);
		//cout << ans << endl;
	}


	
	cout << ans << "\n";

	return 0;
}


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

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

  string t;
  t.reserve(n);
  t.push_back(s[0]);
  for (int i = 1; i < n; i++)
  {
    if (s[i - 1] != s[i])
    {
      t.push_back(s[i]);
    }
  }

  cout << t.size() << endl;

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}


int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

//#############################
const int MAXN = 1000005;

int main() {
    int x,y,a,b,c;
    vector<ll> va,vb,vc;

    cin >> x >> y >> a >> b >> c;
    ll xx;
    REP(i, a)
        cin >> xx, va.pb(xx);
    REP(i, b)
        cin >> xx, vb.pb(xx);
    REP(i, c)
        cin >> xx, vc.pb(xx);

    sort(all(va), greater<ll>());
    sort(all(vb), greater<ll>());
    sort(all(vc), greater<ll>());

    // cout << x << " " << y << endl;
    // cout << a << " " << b << " "<< c << endl;
    // cout << to_string(va) << endl;
    // cout << to_string(vb) << endl;
    // cout << to_string(vc) << endl;


    va = vector<ll>(va.begin(), va.begin()+x);
    vb = vector<ll>(vb.begin(), vb.begin()+y);
    
    REP(i, x)
        vc.pb(va[i]);
    REP(i, y)
        vc.pb(vb[i]);
    
    sort(vc.begin(), vc.end(), greater<ll>());

    ll ans = 0;
    for(int i = 0; i < x+y; i++)
        ans += vc[i];

    cout << ans << endl;

    return 0;
}

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

n, a, b = map(int, input().split())

ans = 0

for i in range(1, n+1):
    temp = list(str(i))
    temp = [int(x) for x in temp]
    temp = sum(temp)

    if a<=temp and temp <= b:
        ans +=i
    
print(ans)

Measured memory_bytes: 3060
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}

func find(heights []int) []int {
	length := len(heights)
	counter := make([]int, length)
	counter[0] = 0 // 不要だが
	for i := 1; i < length; i++ {
		if heights[i] <= heights[i-1] {
			counter[i] = counter[i-1] + 1
		} else {
			counter[i] = 0
		}
	}
	return counter
}

func max(ints []int) (m int) {
	for _, i := range ints {
		if m < i {
			m = i
		}
	}
	return
}

func main() {
	heights := nextInts(nextInt())
	fmt.Println(max(find(heights)))
}


Measured memory_bytes: 3840
#include<stdio.h>
using namespace std;

#define MAXN 55

char v[MAXN][MAXN], fin[MAXN][MAXN];

int dirl[10]={-1, -1, -1, 0, 1, 1,  1,  0, -1};
int dirc[10]={-1,  0,  1, 1, 1, 0, -1, -1, -1};
int main(){
//  FILE*fin=fopen("b.in", "r");
  FILE*fin=stdin;
  int i, j, n, m, dir, nr;
  fscanf(fin, "%d%d", &n, &m);
  fgetc(fin);
  for(i=1; i<=n; i++){
    for(j=1; j<=m; j++)
      v[i][j]=fgetc(fin);
    fgetc(fin);
  }
  for(i=1; i<=n; i++)
    for(j=1; j<=m; j++)
      if(v[i][j]=='.'){
        nr=0;
        for(dir=1; dir<=8; dir++)
          if(v[i+dirl[dir]][j+dirc[dir]]=='#')
            nr++;
        v[i][j]=nr+'0';
      }
//      else
//        fin[i][j]='#';

  for(i=1; i<=n; i++){
    for(j=1; j<=m; j++)
      printf("%c", v[i][j]);
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 128
def postal_code(A: int, B: int, S: str)->bool:
    if '-' in S[:A]:
        return False
    if S[A] != '-':
        return False
    if '-' in S[-B:]:
        return False
    return True


if __name__ == "__main__":
    A, B = map(int, input().split())
    S = input()
    yes = postal_code(A, B, S)
    print('Yes' if yes else 'No')


Measured memory_bytes: 3060
N,A,B = map(int,input().split())

N_syo = N//(A+B)
N_amari = N%(A+B)
ans = 0

if B == 0:
    print(N)

elif N_amari == 0:
    print(N_syo*A)
else:
    ans += N_syo*A
    N -= N_syo*(A+B)
    if N <= A:
        ans += N
        print(ans)
    else:
        ans += A
        print(ans)


Measured memory_bytes: 9124
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

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

	vector<string> s(N);
	for (int32_t i = 0; i < N; i++) {
		cin >> s[i];

		vector<int32_t> val(10);
		for (int32_t j = 0; j < 10; j++) {
			val[j] = s[i][j] - 'a';
		}
		sort(val.begin(), val.end());
		for (int32_t j = 0; j < 10; j++) {
			s[i][j] = val[j] + 'a';;
		}
	}
	sort(s.begin(), s.end());

	int64_t res = 0;
	for (int32_t i = 0; i < N - 1; i++) {
		int64_t identical = 1;
		for (int32_t j = i + 1; j < N; j++) {
			if (s[i] != s[j])
				break;
			identical++;
		}
		if (identical < 2)
			continue;

		res += identical * (identical - 1) / 2;

		i += identical - 1;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define int long long
#define pb push_back
#define endl "\n";
#define deb1(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << " | " << #y << ": " << y << endl
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define printclock cerr << "Time : " << 1000 * (ld)clock() / (ld)CLOCKS_PER_SEC << "ms\n";
#define vii vector<int>
#define pii pair<int, int>
#define prec(n) fixed << setprecision(n)
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define MOD LLONG_MAX
inline void get(vector<int> &arr, int n)
{
    int a;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        arr.push_back(a);
    }
}
inline void print(vector<int> &arr, int n)
{
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
    cout << endl;
}
int dp[100005];
void solve(vii& h)
{
    rep(i,2,((int)h.size())+1)
    {
        if(i==2)
        {
            dp[i] = dp[i-1]+abs(h[i-1]-h[i]);
        }
        else
        {
            dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
        }
    }
}
int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    fast;
    //check if cin >> n
    //---------------------------------
    int t;
    t =1;
    while (t--)
    {
        int n;
        cin >> n;
        vii h(n+1);
        h[0]=INT_MAX;
        rep(i,1,n+1)
        {
            cin >> h[i];
        }
        memset(dp,0,sizeof(dp));
        solve(h);
        cout << dp[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 4728
#include <iostream>
using namespace std;
int main() {
    long long width, height;
    do {
        cin >> height >> width;
        if ((height == 0) && (width == 0)) {
            break;
        }
        for (long long j = 0; j < height; j++) {
            for (long long i = 0; i < width; i++) {
                cout << "#";
            }
            cout << "\n";
        }
        cout << "\n";
    } while (true);
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
string a;
int ans,x,y,h[100003],n,m;
vector<int>l[100003];
int che(int x1)
{
	for(int j=0;j<l[x1].size();j++)
		if(h[l[x1][j]]>=h[x1])
			return 0;
	return 1;
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	for(int i=1;i<=m;i++)
	{
		cin>>x>>y;
		l[x].push_back(y),l[y].push_back(x);
	}
	for(int i=1;i<=n;i++)
		if(che(i)==1)
			ans++;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
int main(){
    int r, g, b;
    cin >> r >> g >> b;
    int rgb = r * 100 + g * 10 + b;
    if(rgb % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int ord2(int x){
    int ans = 0;
    while (x%2 == 0){
        x /= 2;
        ans++;
    }
    return ans;
}


int main() {
    int N;
    cin >> N;
    int ans = 0;
    for(int i=0; i<N; i++){
        int ai;
        cin >> ai;
        ans +=  ord2(ai);
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
import sys

n = input()

if n[0] == '9':
	m = ''.join(['9']*len(n))
	if int(n) > int(m):
		print(''.join(['1']*(len(n)+1)))
		sys.exit()
	else:
		print(m)
		sys.exit()
else:
	s = n[0]
	m = ''.join([s]*len(n))
	if int(n) > int(m):
		print(''.join([str(int(s)+1)]*len(n)))
		sys.exit()
	else:
		print(m)
		sys.exit()




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

int main(){
    int N;  cin >> N;
    vector<int> C;
    for(int i=0; i<N; i++){
        int c;  cin >> c;
        if(i==0 || C.back() != c){
            C.push_back(c);
        }
    }
    N = C.size();

    int mod = 1e9+7;
    vector<int> memo(2e5+1,-1);
    vector<int> ans(N);
    ans[0] = 1;
    memo[C[0]] = 0;
    for(int i=1; i<N; i++){
        ans[i] = ans[i-1];
        if(memo[C[i]] != -1){
            ans[i] += ans[memo[C[i]]];
        }
        ans[i] = ans[i]%mod;
        memo[C[i]] = i;
    }
    cout << ans[N-1] << endl;
}

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

using namespace std;

const int MD = 1000000007;

int main() {
	long long n, k; cin >> n >> k;
	long long x = n - (k - 1) + 1;
	cout << (x * x * n * 3 + x * x * 6 - x * x * k * 6 + x * k * n * 6 - x * n * 3 - x * k * k * 6 + x * k * 12 - x * x * x * 2 + x * 2) / 6 % MD << '\n';
	return 0;
}


Measured memory_bytes: 3544
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e15+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, m;
vector<string> vs;

int main(){
	cin >> n >> m;
	REP(i, n){
		string s;
		cin >> s;
		vs.push_back(s);
	}
	sort(ALL(vs));
	REP(i, vs.size()){
		cout << vs[i];
	}
	cout << endl;
}


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

int main() {
	// your code goes here
	int n,k;
	cin>>n>>k;
	
	int dp[n];
	int arr[n];
	for(int i=0;i<n;i++)
	{
	    cin>>arr[i];
	}
	//dp[i] minimum cost to reach nth stode
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	
	for(int i=2;i<n;i++)
	    dp[i] = INT_MAX;
	
	for(int i=2;i<n;i++)
	{
	    for(int j=1;j<=k;j++)
	    {
	        if(i-j>=0)
	            dp[i] = min(abs(arr[i]-arr[i-j])+dp[i-j],dp[i]);
	    }
	    
	    //cout<<dp[i]<<" "<<abs(arr[i]-arr[i-1])+dp[i-1]<<" "<<abs(arr[i]-arr[i-2])+dp[i-2]<<endl;
	}
	
	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;
class Main {
    public static void main (String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        for(int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if('a' <= c && c <= 'z') System.out.print((char)(c - 32));
            else if('A' <= c && c <= 'Z') System.out.print((char)(c + 32));
            else System.out.print(c);
        }
        System.out.println();
    }
}


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

int main(){
	string S;
	cin >> S;
	int value = 700;
	for(int i=0;i<3;++i){
		if(S[i] == 'o'){
			value += 100;
		}
	}
	cout << value << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	double xa, ya, ra, xb, yb, rb, dif;
	int i, n;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%lf %lf %lf %lf %lf %lf", &xa, &ya, &ra, &xb, &yb, &rb);
		
		dif = (xb - xa) * (xb - xa) + (yb - ya) * (yb - ya);
		
		if (dif > (ra + rb) * (ra + rb)){
			printf("0\n");
		}
		else if (dif < (rb - ra) * (rb - ra)){
			if (ra > rb){
				printf("2\n");
			}
			else {
				printf("-2\n");
			}
		}
		else {
			printf("1\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 620
import random

random.seed(0)

def calc_point(point_list, interval, choice):
    point = 0

    for i, day in enumerate(interval):
        point -= c[i] * day

    point += point_list[choice - 1]

    return point

d = int(input())

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

s = []

for _ in range(d):
    temp = list(map(int,input().split()))

    s.append(temp)

choices = [(i % 26) + 1 for i in range(d)]

interval = [0] * 26
result = 0

for i in range(d):
    choice = choices[i]

    interval = [x + 1 for x in interval]

    interval[choice - 1] = 0

    result += calc_point(s[i], interval, choice)

for _ in range(1000):
    temp_choices = choices.copy()
    temp_result = 0

    temp_choices[random.randint(0, d - 1)] = random.randint(1, 26)

    interval = [0] * 26
    
    for i in range(d):
        choice = temp_choices[i]

        interval = [x + 1 for x in interval]

        interval[choice - 1] = 0

        temp_result += calc_point(s[i], interval, choice)

    if temp_result > result:
        choices = temp_choices
        result = temp_result

for choice in choices:
    print(choice)

Measured memory_bytes: 85316
def solve(dic, n, bad):
    if bad:
        return -1

    li = [-1]*n
    for k, v in dic.items():
        li[k-1] = v

    if n==1:
        if li[0] == -1: ## unset
            return 0
        else: ## li is obviously set by dictionary
            st = map(str, li)
            return int(''.join(st))

    else:
        if li[0] == 0:
            ## well not possible for a n digit number
            return -1
        if li[0] == -1:
            ## unset; so take any one one digit
            li[0] = 1
            for i in range(1, n):
                if li[i] == -1:
                    li[i] = 0

            st = map(str, li)
            return int(''.join(st))
        else:
            for i in range(1, n):
                if li[i] == -1:
                    li[i] = 0
            st = map(str, li)
            return int(''.join(st))
        

n, m = map(int, input().split())

dic = {}
bad = False
for i in range(m):
    s, c = map(int, input().split())
    if dic.get(s, -1) == -1: ## key s doesn't exist
        dic[s] = c
    else:
        if dic[s] != c:
            bad = True

print(solve(dic, n, bad))


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

long N;
long A[500];
long dp[100000];
long dpsub[100000];
long dp2[100000];
long dpsub2[100000];
int main(){
  long MOD=998244353;
  cin >> N;
  for (int i=1;i<=N;i++){
    cin >> A[i];
  }
  for (int j=0;j<=90000;j++){
    dp[j]=0;
    dpsub[j]=0;
    dp2[j]=0;
    dpsub2[j]=0;
  }
  dp[0]=1;
  dp2[0]=1;
  sort(A+1,A+N+1);
  for (int i=1;i<=N;i++){
    for (int j=0;j<=90000;j++){
      dpsub[j]=dp[j]*2;
      if (j>=A[i])dpsub[j]+=dp[j-A[i]];
      dpsub[j]%=MOD;
    }
    for (int j=0;j<=90000;j++){
      dp[j]=dpsub[j];
      dp[j]%=MOD;
    }
  }
  for (int i=1;i<=N;i++){
    for (int j=0;j<=90000;j++){
      dpsub2[j]=dp2[j];
      if (j>=A[i])dpsub2[j]+=dp2[j-A[i]];
      dpsub2[j]%=MOD;
    }
    for (int j=0;j<=90000;j++){
      dp2[j]=dpsub2[j];
      dp2[j]%=MOD;
    }
  }

  long sum=0;
  for (int i=1;i<=N;i++){sum+=A[i];sum%=MOD;}
  long sum2=0;
  for (int i=(sum+1)/2;i<=sum;i++){sum2+=dp[i];sum2%=MOD;}

  long sum3=0;
  if (sum%2==0)sum3=dp2[sum/2];
  long sum4=1;
  for (int i=0;i<N;i++){sum4*=3; sum4%=MOD;}
  long ans=(MOD+sum4-((sum2-sum3)*3+MOD)%MOD)%MOD;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3704
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  l1=LI()
  l2=sorted(l1)

  ans=0
  _ans=0
  for i,x in enumerate(l1):
    _l=sorted(l1[i:])
    ans+=bisect.bisect_left(_l,x)
    _ans+=bisect.bisect_left(l2,x)
  # print(ans,_ans)

  return (ans*k+(_ans*(k-1)*k//2))%mod


# main()
print(main())


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MAX = 1e5+10;
const ll INF = 1e12;

int A, B, Q;
ll S[MAX], T[MAX], X[MAX];

void solve() {
    set<ll> SS, TT;
    SS.insert(-INF); SS.insert(INF);
    REP (i, A) SS.insert(S[i]);
    TT.insert(-INF); TT.insert(INF);
    REP (i, B) TT.insert(T[i]);

    REP (q, Q) {
        ll x = X[q];
        auto its = SS.upper_bound(x);
        ll s2 = *its;
        ll s1 = *(--its);
        auto itt = TT.upper_bound(x);
        ll t2 = *itt;
        ll t1 = *(--itt);
        ll ans = min(max(x-s1, x-t1), max(s2-x, t2-x));
        ans = min(ans, min(x+t2-2*s1, 2*t2-x-s1));
        ans = min(ans, min(x+s2-2*t1, 2*s2-x-t1));
        cout << ans << endl;
    }
}

int main() {
    cin >> A >> B >> Q;
    REP (i, A) cin >> S[i];
    REP (i, B) cin >> T[i];
    REP (i, Q) cin >> X[i];
    solve();
}

Measured memory_bytes: 13056
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H, W;
		while (true) {
			H = sc.nextInt();
			W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for(int i=0;i<W;i++){
				System.out.print("#");
			}
			System.out.println("");
			for(int i=0;i<H-2;i++){
				System.out.print("#");
				for(int j=0;j<W-2;j++){
					System.out.print(".");
				}
				System.out.print("#");
				System.out.println("");
			}
			for(int i=0;i<W;i++){
				System.out.print("#");
			}
			System.out.println("");
			System.out.println("");
		}
		sc.close();
	}
}



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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    int N;
    while (cin >> N, N) {
        vector<pair<double, string>> score(N);
        REP(i, N) {
            string l;
            int p, a, b, c, d, e, f, s, m;
            cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
            int time = a+b+c;
            REP(i, m) {
                time += d+e;
            }
            int seed = f*m;
            double value = (seed*s - p) / (double)time;
            score[i] = {-value, l};
        }
        SORT(score);
        REP(i, N) {
            cout << score[i].second << endl;
        }
        cout << "#" << endl;
    }
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	string s,c;
	int q,t,f;
	bool flag=true;
	cin>>s;
	cin>>q;
	for(int i=0;i<q;i++)
	{
		cin>>t;
		if(t==1)
		{
			if(flag)flag=false;
			else flag=true;
		}
		else
		{
			cin>>f>>c;
			if(f==1)
			{
				if(flag)s.insert(0,c);
				else s+=c;
			}
			else
			{
				if(flag)s+=c;
				else s.insert(0,c);
			}
		}
	}
	if(flag)cout<<s<<endl;
	else
	{
		reverse(s.begin(),s.end());
		cout<<s<<endl;
	}
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


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

  int m = n;
  int sn = 0;
  while (m > 0){
    sn += m % 10;
    m /= 10;
  }
  cout << (n%sn==0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
template <class... T> void printArr(T&&...){ }
#endif

int none = 0, black = 1, white = 2;
struct Node{
    vector<Node*> dests;
    int color = none;
    bool valid = true;
    void add(Node* n){
        dests.push_back(n);
    }
    void add2(Node* n){
        add(n);
        n->add(this);
    }
    void dfs(Node* from = nullptr){
        for(Node* d : dests){
            if(d == from){ continue; }
            d -> dfs(this);
        }
    }
    void setColor(int c){
        if(!color){
            color = c;
        }
    }
    int validDests(){
        int ret = 0;
        for(Node* d : dests){
            ret += (d->valid);
        }
        return ret;
    }
    Node* getOne(){
        for(Node* d : dests){
            if(d->valid){
                return d;
            }
        }
        exit(1);
    }
};

int main(){
    int n; cin >> n;
    vector<Node> nodes(n);
    for(int i=0;i<n-1;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        nodes[a].add2(&nodes[b]);
    }
    while(1){
        vector<pair<Node*, Node*>> cps;
        for(int i=0;i<n;i++){
            if(nodes[i].valid && nodes[i].validDests() == 0){
                cout << "First" << '\n';
                return 0;
            }
            if(nodes[i].valid && nodes[i].validDests() == 1){
                cps.emplace_back(&nodes[i], nodes[i].getOne());
            }
        }
        if(cps.empty()){ break; }
        for(auto& cp : cps){
            if(cp.second->color && !cp.first->color){
                cout << "First" << '\n';
                return 0;
            }
            cp.first->color = white;
            cp.second->color = black;
            cp.first->valid = false;
            cp.second->valid = false;
        }
    }
    cout << "Second" << '\n';
    return 0;
}


Measured memory_bytes: 8820
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    mid = A.index(1)
    count = 1
    r = K - 1
    while r < mid:
        r += (K - 1)
        count += 1

    if r < N - 1:
        l = N - K
        count += 1
        while l > r:
            l -= (K - 1)
            count += 1
    print(count)


    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 13876
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if(a%3==0||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI acos(-1)
#define sz 100010
#define RUN_FAST ios::sync_with_stdio(false);
using namespace std;

int main()
{
    RUN_FAST; cin.tie(nullptr);
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << ' ' << b << ' ' << c << endl;
    return 0;
}


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

#include<stdlib.h>
#include<iostream>
#include<math.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define INF 2000000000
#define Min(a,b) (a<b?a:b)
#define Max(a,b) (a>b?a:b)
#define PI 3.1415926535897932
using namespace std;






int main()
{
int c,a,b;
cin>>a>>b>>c;
for(int i=b;i<=c;i++){
	if(i%a==0){
		cout<<"OK"<<endl;
		return 0;
	}
}
cout<<"NG"<<endl;


return 0;
}



Measured memory_bytes: 3560
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int q = sc.nextInt();
		int[][] table = new int[n+1][n+1];
		for(int i = 0; i < m; i++){
		    int x = sc.nextInt();
		    int y = sc.nextInt();
		    table[x][y]++;
		}
		int[][] query = new int[q][2];
		for(int i = 0; i < q; i++){
		    query[i][0] = sc.nextInt();
		    query[i][1] = sc.nextInt();
		}
		
		// 計算
		int[][] sumTable = new int[n+1][n+1];
		for(int i = 1; i <= n; i++){
		    for(int j = 1; j <= n; j++){
		        sumTable[i][j] = sumTable[i][j-1] + sumTable[i-1][j] - sumTable[i-1][j-1] + table[i][j];
		    }
		}
		int result = 0;
		for(int i = 0; i < q; i++){
		    int x = query[i][0];
		    int y = query[i][1];
		    result = sumTable[y][y] - sumTable[y][x-1] - sumTable[x-1][y] + sumTable[x-1][x-1];
		    System.out.println(result);
		}
	}
}


Measured memory_bytes: 164600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {
    public static void main(String []args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int x=Integer.parseInt(st.nextToken());
        int n=Integer.parseInt(st.nextToken());
        HashSet<Integer> num = new HashSet<>();
        int c=1;
        int temp1=x;
        int temp2=x;
        if(n==0){
            System.out.println(x);
        }
        else {
            st = new StringTokenizer(br.readLine());
            for (int i = 0; i < n; i++) {
                num.add(Integer.parseInt(st.nextToken()));
            }
            for(c=0;c<n+1;c++) {
                temp1 = x + c;
                temp2 = x - c;
                if (!num.contains(temp2)) {
                    System.out.println(temp2);
                    break;
                }
                if (!num.contains(temp1)) {
                    System.out.println(temp1);
                    break;
                }
            }

        }
    }
}


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


void solve(long long X){
    auto n500 = X/500;
    X %= 500;
    auto n5 = X/5;
    auto res = n500*1000 + n5*5;
    cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
// D - Sum of Divisors
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rp(i,s,e) for(int i=(s);i<(int)(e);++i)

int main(){
	int N; cin>>N;
	vector<int> f(N+1);
	rp(d, 1, N+1)
		for(int k=d; k<=N; k+=d) f[k]++;
	ll  s = 0;
	rp(k, 1, N+1) s += (ll)k * f[k];
	cout<< s <<endl;
}


Measured memory_bytes: 42312
N = int(input())
A = list(map(int, input().split()))

std = 0
base = int(A[0])
ans = 0

for n in range(1,N):
    std = int(A[n]-1)

    if std < base:
        ans += A[n-1] - A[n]
        std += base - std
        A[n] = std

    base = A[n]

print(ans)

Measured memory_bytes: 32108
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 

    struct Unionfind{
    vector<int> rank;
    Unionfind(int n){
       rank=vector<int>(n,-1);
    }
    int goroot(int x){
       if(rank.at(x)<0) return x;
       return rank.at(x)=goroot(rank.at(x));
    }
    bool unite(int x,int y){
       x=goroot(x);
       y=goroot(y);
       if(x==y)return false;
       if(rank[x] > rank[y]) swap(x,y);
       rank[x]+=rank[y];
       rank[y]=x;
       return true;
    }
    
 
 };  
int main(){
   int n,m;
   cin >> n >> m;
   Unionfind Uf(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a-=1;
        b-=1;
        Uf.unite(a,b);
    }

    int ans=0;
    rep(i,n){
        if(Uf.goroot(i)==i)ans++;
    }
    cout << ans-1 << endl;


}


Measured memory_bytes: 3784
#include <iostream>

int main(void)
{
	using namespace std;
	
	int n;
	cin >> n;

	for(int i=1; i<=n; ++i){
		int x = i;
		if(x % 3 == 0)	cout << " " << i;
		else{
			while(x != 0){
				if(x % 10 == 3){
					cout << " " << i;
					break; 
				}
				x /= 10;
			}
		}
	}
	cout << endl;


	return 0;

}

Measured memory_bytes: 3080
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n+1-i):
        k = n - (i + j)
        if 10000*i + 5000*j + 1000*k == y:
            print('{} {} {}'.format(i, j, k))
            break
    else:
        continue
    break
else:
    print('-1 -1 -1')

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

struct Dice {
	int num[6]; // top, bottom, front, back, right, left;
	static const int rd[3][4]; //?????¢??????
	
	Dice(int top, int bottom, int front, int back, int right, int left) {
		num[0] = top;		num[1] = bottom;
		num[2] = front;	num[3] = back;
		num[4] = right;	num[5] = left;
	}
	Dice(const Dice &d) {
		copy(d.num, d.num + 6, num);
	}
	
	bool operator < (const Dice &d) const {
		REP(i, 6) if (num[i] != d.num[i]) {
			return num[i] < d.num[i];
		}
		return false;
	}
	
	void X() { rotate(0); }
	void Y() { rotate(1); }
	void Z() { rotate(2); }
	
	void rotate(int p) {
		int tmp = num[rd[p][0]];
		
		REP(i, 3) num[rd[p][i]] = num[rd[p][i + 1]];
		num[rd[p][3]] = tmp;
	}
	
	Dice unique() {
		Dice now = *this;
		
		Dice mi(*this);
		
		REP(i, 4) {
			REP(j, 4) {
				REP(k, 4) {
					if (now < mi) mi = now;
					now.X();
				}
				now.Y();
			}
			now.Z();
		}
		return mi;
	}
	
	void print() {
		REP(i, 6) printf("%d%c", num[i], i == 5 ? '\n' : ' ');
	}
};

const int Dice::rd[3][4] = {
	{2,1,3,0}, // x
	{2,4,3,5}, // y
	{0,5,1,4}, // z
};

int main() {
	char color[6][10] = { "Red", "Yellow", "Blue", "Magenta", "Green", "Cyan" };
	map<string, int> trans;
	REP(i, 6) trans[color[i]] = i;
	
	int n;
	while (cin >> n, n) {
		set<Dice> ss;
		
		REP(i, n) {
			int col[6] = {};
			REP(j, 6) {
				string str; cin >> str;
				col[j] = trans[str];
			}
			
			ss.insert(Dice(col[0], col[5], col[1], col[4], col[2], col[3]).unique());
		}
		
		cout << n - ss.size() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3036
#include <iostream>

using namespace std;
typedef long long ll;

ll num_digits(ll x){
    ll ret = 0;
    for(ret = 0; x > 0; ret++, x /= 10){}
    return ret;
}


int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n; ++i){
        if(num_digits(i) % 2 == 1){ ans++; }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

class Main{

	//static long[] a;
	static	int N ;
	static	int M ;
	static long[][] dp;
	static int ans = 100000000;
	static	boolean[] flag ;

	public static void main(String[] args) {



		Scanner sc = new Scanner(System.in);			//文字の入力
		int N = sc.nextInt();
		ArrayList<String> s = new ArrayList<String>();
		ArrayList<String> t = new ArrayList<String>();
		ArrayList<String> list = new ArrayList<String>();		

		for(int i = 0;i < N;i++){
			String x = sc.next();
			s.add(x);
			list.add(x);
		}
		int M = sc.nextInt();

		for(int i = 0;i < M;i++){
			String x = sc.next();
			t.add(x);
			list.add(x);
		}

		list = new ArrayList<String>(new HashSet<>(list));
		
	
		int ans = 0;

		for(int i = 0;i < list.size();i++){
			int count = 0;
			for(int j = 0;j < s.size();j++){
				if(s.get(j).equals(list.get(i)) ){
					count++;
				}
			}
			for(int j = 0;j < t.size();j++){
				if(t.get(j).equals(list.get(i))){
					count--;
				}
			}
			ans = Math.max(ans, count);

		}
		System.out.println(ans);





	}


}




Measured memory_bytes: 21972
#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;
using ll = long long;


int main(){
    string s;
    cin >> s;
    set<char> c;
    for (int i=0;i<s.size();++i) {
        c.insert(s[i]);
    }

    cout << ((c.size() == 2) ? "Yes" : "No") << endl;    
}

Measured memory_bytes: 256
K, N = map(int, input().split())
A = list(map(int, input().split()))
memo = []

for i in range(N-1):
    memo.append(abs(A[i] - A[i+1]))

memo.append(K-A[-1]+A[0])

sum_memo = sum(memo)
sum_memo -= max(memo)
print(sum_memo)


Measured memory_bytes: 26060
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(void){
  int d[4];
  cin >> d[0] >> d[1] >> d[2] >> d[3];
  vector<int> x;
  vector<int> y;
  for(int i=0; i<d[0]; i++){
    int tmp;
    cin >> tmp;
    x.push_back(tmp);
  }
  for (int i = 0; i < d[1]; i++){
    int tmp;
    cin >> tmp;
    y.push_back(tmp);
  }
  x.push_back(d[2]);
  y.push_back(d[3]);
  int maxe = *max_element(x.begin(), x.end());
  int mine = *min_element(y.begin(), y.end());
  if(maxe < mine) cout << "No War";
  else cout << "War";
  return 0;
}


Measured memory_bytes: 256