akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int c_get_keta(long long int a) {
	int a_cnt = 0;
	while (a > 0){
		a_cnt++;
		a /= 10;
	}

	return a_cnt;
}

void c_digits_in_multiplication(void) {
	long long int n;
	int min_tmp;
	int ans_min = 10000000;
	cin >> n;
	//int n_end = int(sqrt(long double(n)));
	long int n_end = sqrt(n);

	for (long long int a = 1; a <= (n_end); a++) {
		if (n % a != 0) continue;
		//cout << a << endl;
		long long int b = n / a;
		if (a > b) {
			min_tmp = c_get_keta(a);
		}
		else {
			min_tmp = c_get_keta(b);
		}
		//cout << "n, a,b:" << n<<","<<a << "," << b << endl;
		if (min_tmp < ans_min) ans_min = min_tmp;
	}

	cout << ans_min << endl;
}

int main()
{
	c_digits_in_multiplication();
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int n;
  cin>>n;
  int i=0;
  while(1){
    i++;
    if(jo(i,2)>n){
      break;
    }
  }
  cout<<jo(i-1,2);
}

// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
h,w = gets.chomp.split.map(&:to_i)
ary = []
h.times do
  ary << gets.chomp.split("")
end

ary.delete_if {|line| line.count('.')==line.length}
# p ary
if ary.length == 1
  ary.each do |line|
    # p "#"*line.count("#")
    ary = "#"*line.count("#")
  end
  # p ary
else
  ary = ary.transpose
end
if ary.class == Array
  ary.delete_if {|line| line.count('.')==line.length}
  ary = ary.transpose
  ary.each do |line|
    print(line.join)
    puts
  end
else
  puts ary
end



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

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

#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define testcase int _;cin>>_;while(_--)

/*C-Tsundoku*/
void Solve()
{
	int n,m,k;
	cin>>n>>m>>k;
	int a[n],b[m];
	ll asum=0,bsum=0;
		
	for(int i=0;i<n;i++)
		cin>>a[i],asum+=a[i];
	for(int i=0;i<m;i++)
		cin>>b[i];

	int cnt=0,bp=0;
	for(int i=n;i>=0;i--)
	{
		if(i<n)
			asum-=a[i];
      	if(asum<=k)
        {
            while(bp<m && (asum+bsum+b[bp])<=k)
            {
                bsum+=b[bp];
                bp++;
            }
            cnt=max(cnt,bp+i);
        }  
	}
	cout<<cnt<<"\n";
}

int main()
{
	fast
	Solve();
	return 0;
}

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

#define LL long long
#define COIN const int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

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

#define ALL(c) (c).begin(), (c).end()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

int a,b,c,cnt=0;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >>a >>b >>c;
	if (a==b) cnt++;
	if (b==c) cnt++;
	if (a==c) cnt++;
	if (cnt==1)
		cout <<"Yes"<<endl;
	else 
		cout <<"No"<<endl;
	return 0;
}
/******************************************************************************
******************************************************************************/


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

int main(){
    long long n;
    cin>>n;
    string s;
    cin>>s;
    n=s.size();
    long long a=count(s.begin(),s.end(),'R');
    long long b=count(s.begin(),s.end(),'G');
    long long c=count(s.begin(),s.end(),'B');
    long long ans;
    long long less=0;

    for(long long i=0;i<n;i++){
        for(long long j=i+1;j<n;j++){
            if((s[i]=='R' && s[j]=='G') ||(s[i]=='G' && s[j]=='R')){
                if(s[2*i-j]=='B' && 2*i-j>=0 )less++;
            }
            if((s[i]=='G' && s[j]=='B') ||(s[i]=='B' && s[j]=='G')){
                if(s[2*i-j]=='R' && 2*i-j>=0)less++;
            }
            if((s[i]=='R' && s[j]=='B') ||(s[i]=='B' && s[j]=='R')){
                if(s[2*i-j]=='G' && 2*i-j>=0)less++;
            }
        }
    }
    ans=a*b*c;
    ans=ans-less;
    cout<<ans;

}
   


Measured memory_bytes: 3632
#include<iostream>

int main(){
  int r, c, sum;
  int cell[101][101];

  for(int i = 0; i < 101; i++){
    for(int j = 0; j < 101; j++){
      cell[i][j] = 0;
    }
  }

  std::cin >> r >> c;

  for(int i = 0; i < r; i++){
    for(int j = 0; j < c; j++){
      std::cin >> cell[i][j];
    }
  }

  for(int i = 0; i < r; i++){
    sum = 0;
    for(int j = 0; j < c; j++){
      sum += cell[i][j];
    }
    cell[i][c] = sum;
  }

  for(int i = 0; i <= c; i++){
    sum = 0;
    for(int j = 0; j < r; j++){
      sum += cell[j][i];
    }
    cell[r][i] = sum;
  }


  for(int i = 0; i <= r; i++){
    for(int j = 0; j <= c; j++){
      std::cout << cell[i][j];
      if(j < c) std::cout << ' ';
    }
    std::cout << std::endl;
  }

  
  return 0;
}

Measured memory_bytes: 3128
// https://atcoder.jp/contests/abc087/tasks/abc087_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, t;
    cin >> a >> b;
    t = b;
    while (t > 0) {
        a *= 10;
        t /= 10;
    }
    int r = sqrt(a + b);
    if (r * r == a + b) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ll long long
long long min(long long x,long long y){return (x<y ? x:y);}
long long max(long long x,long long y){return (x>y ? x:y);}
#define ld long double
int stoi(string s) {return atoi(s.c_str());}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}

int func(ll x,ll y){
  int kx = keta(x);
  int ky = keta(y);
  return max(kx,ky);
}

int main(){
  ll N; cin >>N;
  int r = keta(N);
  for(int i=2;i<sqrt(N)+1;i++){
    if(N%i==0){
      r = min(func(i,N/i),r );
    }
  }
  printf("%d\n",r);
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long int ll;

int main(){

    string S;
    ll K;
    cin >> S >> K;

    for(ll i = 0; i < K; i++){
        //cout << S[i] << endl;
        if(S[i] != '1'){
            cout << S[i] << endl;
            return 0;
        }
    }
    cout << "1" << endl;
    return 0;     
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int ga, sa, ba;
Int gb, sb, bb;

Int solve(Int n){
    Int res = 0;
    vector<P> difs;
    if(ga < gb)difs.push_back(P(ga, gb));
    if(sa < sb)difs.push_back(P(sa, sb));
    if(ba < bb)difs.push_back(P(ba, bb));
    if(difs.size() == 0)return n;
    if(difs.size() == 3){
        for(Int g = 0;g * ga <= n;g++){
            for(Int s = 0;s *sa + g * ga <= n;s++){
                Int rest = n - (g*ga + s*sa);
                Int b = rest / ba;
                res = max(res, n - (g * ga + b * ba + s * sa) + (g * gb + b * bb + s * sb));
            }
        }
        return res;
    }
    if(difs.size() == 1){
        Int ta = difs[0].first;
        Int tb = difs[0].second;
        return n % ta + (n / ta) * tb;
    }
    Int ta = difs[0].first;
    Int tb = difs[0].second;
    Int ua = difs[1].first;
    Int ub = difs[1].second;
    for(Int t = 0;t * ta <= n;t++){
        Int rest = n - t * ta;
        Int u = rest / ua;
        res = max(res, n - (t*ta + u * ua) + t*tb + u*ub);
    }
    return res;
}

int main(){
    Int n;
    cin >> n;
    cin >> ga >> sa >> ba;
    cin >> gb >> sb >> bb;
    n = solve(n);
    swap(ga, gb);
    swap(sa, sb);
    swap(ba, bb);
    cout << solve(n) << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = [int(x) for x in input().split()]
isball = [0]*N
ball_list = []
oddeven = 0
for i in reversed(range(1, N)):
    ball_sum = 0
    for j in range(1, N // (i + 1)+1):
        ball_sum += isball[((j) * (i+1))-1]
    if ball_sum % 2 != a[i]:
        ball_list.append(i + 1)
        isball[i] = 1
        oddeven += 1

if oddeven % 2 != a[0]:
    ball_list.append(1)

print(len(ball_list))
print(*ball_list)


Measured memory_bytes: 14036
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;

typedef int64_t ll;
vector<int> polc;
array<int, 1000000> p, od;

void calc(){
    for (int i = 0; i < p.size(); ++i) {
        p[i] = od[i] = i;
    }

    for(auto&& plc: polc){
        for (int i = plc; i < p.size(); ++i) {
            p[i] = min(p[i], p[i-plc] + 1);
        }
        if(plc % 2) {
            for (int i = plc; i < p.size(); ++i) {
                od[i] = min(od[i], od[i - plc] + 1);
            }
        }
    }
}

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

    for (int i = 1; i < 1000; ++i) {
        int pl = i*(i+1)*(i+2) / 6;
        if(pl > 1000000) break;
        polc.push_back(pl);
    }
    int n;
    calc();
    while(cin >> n){
        if(n == 0)
            break;
        cout << p[n] << ' ' << od[n] << endl;
    }


}



Measured memory_bytes: 10948
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll N,M;
	cin>>N>>M;
	ll sum1=0,sum2=0;
	if(N>=2){
		sum1=(N*(N-1))/2;
	}
	if(M>=2){
		sum2=(M*(M-1))/2;
	}
	cout<<sum1+sum2<<endl;
}

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

int main(){
	int n;
	while(cin >> n, n){
		vector<int> vi(n);
		for(int i = 0; i < n; i++){
			cin >> vi[i];
		}
		sort(vi.begin(), vi.end());
		long long ans = 0, sum = 0;
		for(int i = 0; i < n; i++){
			ans += sum;
			sum += vi[i];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1248
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll A;
	string B;
	cin >> A >> B;
	ll BN = B.at(0) - '0';
	ll B1 = B.at(2) - '0';
	ll B2 = B.at(3) - '0';
	cout << ll((100*A * BN + (10*A * B1) + (A * B2))/100) << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define For(n) for(int i=0;i<n;i++)
#define Forj(n) for(int j=0;j<n;j++)
#define pi 3.141592654
#define hell 1000000007
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define in1(n,c) c n;cin>>n
#define in2(a,b,c) c a,b;cin>>a>>b
#define ina(a,n,c) c a[n];rep(i,0,n)cin>>a[i]
#define ins(s) string s;cin>>s
#define mset(a,n) memset(a,n,sizeof a)
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define lbd lower_bound
#define ubd upper_bound
#define ll  long long
#define ull unsigned long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define piii pair<pair<int,int>,int>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
#define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define line cout<<endl

int main ()
{
in1(n,int);
ina(a,n,int);
int cnt=0;
int t;
For(n)
{

    if (a[i]!=i+1)
    {
        t=a[a[i]-1];
       a[a[i]-1]=a[i];
       a[i]=t;
       cnt++;
    }
}
if (cnt>1)
    outl("NO");
else
    outl("YES");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n), c(m), d(m);
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, m) cin >> c[i] >> d[i];
    auto dist = [&](int i, int j) {
        return abs(a[i] - c[j]) + abs(b[i] - d[j]);
    };
    rep(i, n) {
        int MIN = INF, ans;
        rep(j, m) {
            if (chmin(MIN, dist(i, j))) {
                ans = j + 1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

string str;
int d;
ll dp[10001][101];

int main() {
    cin >> str >> d;
    ll sum = 0;
    rep(i,str.size()) {
        int num = str[i]-'0';
        rep(j,num) {
            dp[i+1][(sum+j)%d] = (dp[i+1][(sum+j)%d]+1)%MOD;
        }
        sum += num;
        rep(j,d+1) {
            rep(k,10) {
                dp[i+1][(j+k)%d] = (dp[i+1][(j+k)%d] + dp[i][j]) % MOD;
            }
        }
    }
    dp[str.size()][sum%d]++;
    cout << (dp[str.size()][0]+MOD-1)%MOD << endl;
}



Measured memory_bytes: 8192
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x)end()
#define sz(x) (int)(x).size
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int main ()
{
	char s[105];
	scanf("%s",s);
	int len = strlen(s);
	printf("%c%d%c\n",s[0],len-2,s[len-1]);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define p pair<int,int>
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> k(m), y(m);
	vector<vector<int>> x(n);
	rep(i, m) {
		cin >> k[i] >> y[i];
		k[i]--;
		x[k[i]].push_back(y[i]);
	}
	rep(i, n) {
		vector<int> z = x[i];
		sort(z);
		x[i] = z;
	}
	rep(i, m) {
		int a = k[i] + 1;
		int b = (lower_bound(x[k[i]].begin(), x[k[i]].end(), y[i]) - x[k[i]].begin()) + 1;
		printf("%06d%06d\n", a, b);

	}

}


Measured memory_bytes: 7808
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>

using namespace std;

#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
    string S;
    int size;
    cin >> S;
    size = S.length();
    string front = S.substr(0, (size-1)/2);
    string rear = S.substr(size - (size-1)/2, size - 1);
    reverse(rear.begin(), rear.end());
    if(front != rear) {
        cout << "No" << endl;
        return 0;
    }
    if(front.length() == 1) {
        cout << "Yes" << endl;
        return 0;
    }
    size = front.size();
    string front_f = front.substr(0, (size-1)/2);
    string front_r = front.substr(size - (size-1)/2, size - 1);
    reverse(front_r.begin(), front_r.end());
    if(front_r.length() == 0 || front_f != front_r) {
        cout << "No" << endl;
        return 0;
    }

    size = rear.length();
    string rear_f = rear.substr(0, (size-1)/2);
    string rear_r = rear.substr(size - (size-1)/2, size - 1);
    reverse(rear_r.begin(), rear_r.end());
    if(rear_f.length() == 0 || rear_f != rear_r) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
X, K, D = [int(x) for x in input().split()]

if X < 0:
    X = -X
a = X // D
b = X % D

if K <= a:
    ans = X - D * K
else:
    if (K - a) % 2:
        ans = D - b
    else:
        ans = b
print(ans)


Measured memory_bytes: 9168
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] arr = new int[m][2];
        for (int i=0; i<m; i++) {
            arr[i][0] = sc.nextInt() - 1;
            arr[i][1] = sc.nextInt() - 1;
        }

        UnionFind uf = new UnionFind(n);
        for (int i=0; i<m; i++) {
            uf.unite1(arr[i][0], arr[i][1]);
        }

        Set<Integer> set = new HashSet<>();
        for (int i=0; i<n; i++) {
//            System.out.println(uf.parent[i]);
            set.add(uf.find(i));
        }

//        System.out.println(set);
        System.out.println(set.size() - 1);

    }

    class UnionFind {

        int[] parent, rank, size;

        void init(int n) {
            parent = new int[n];
            rank = new int[n];
            for (int i=0; i<n; i++) {
                parent[i] = i;
                rank[i] = 0;
            }
        }

        UnionFind(int n) {
            parent = new int[n];
            size = new int[n];
            for (int i=0; i<n; i++) {
                parent[i] = i;
                size[i] = 1;
            }
        }

        public int find(int x) {
            if (x==parent[x]) return x;
            return parent[x] = find(parent[x]);
        }

        //    結合して木のサイズを更新
        public void unite1(int x, int y) {
            x = find(x);
            y = find(y);
            if (!same(x, y)) {
                parent[x] = y;
            }        }

        //    結合して木の深さを更新
        public void unite2(int x, int y) {
            x = find(x);
            y = find(y);
            if (x==y) return;
            if (rank[x] < rank[y]) {
                parent[x] = parent[y];
            } else {
                parent[y] = parent[x];
                if (rank[x]==rank[y]) rank[x]++;
            }
        }

        public boolean same(int x, int y) {
            return find(x) == find(y);
        }

        public int size(int x) {
            return size[find(x)];
        }


    }


}



Measured memory_bytes: 62044
#include<stdio.h>

int main()
{
	int n;
	scanf("%d", &n);
	if(n==1) printf("Hello World\n");
	else if(n==2){
		int a, b;
		scanf("%d %d", &a, &b);
		printf("%d\n", a + b);
	}
		
	return 0;
}

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

int bubbleSort(vector<int> &A) {
    bool flag = true;
    int cnt = 0;
    while (flag) {
        flag = false;
        for (int j = A.size() - 1; j >= 1; j--) {
            if (A[j] < A[j - 1]) {
                swap(A[j], A[j - 1]);
                flag = true;
                cnt++;
            }
        }
    }
    return cnt;
}

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

    int N;
    cin >> N;
    vector<int> A;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    int ret = bubbleSort(A);
    for (int i = 0; i < N; i++) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << ret << endl;

    return 0;
}



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

int main(){
    int n;
    string s,t;
    cin >> n >> s >> t;
    string ans;
    for(int i=0;i<n;i++){
        ans+=s.at(i);
        ans+=t.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder172
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());

            var acCnt = 0;
            var waCnt = 0;
            var tleCnt = 0;
            var reCnt = 0;

            for (var i = 0; i < n; i++)
            {
                var resultStr = Console.ReadLine();

                switch (resultStr)
                {
                    case "AC":
                        acCnt++;
                        break;
                    case "WA":
                        waCnt++;
                        break;
                    case "TLE":
                        tleCnt++;
                        break;
                    case "RE":
                        reCnt++;
                        break;
                }
            }

            Console.WriteLine($"AC x {acCnt}");
            Console.WriteLine($"WA x {waCnt}");
            Console.WriteLine($"TLE x {tleCnt}");
            Console.WriteLine($"RE x {reCnt}");
        }
    }
}

Measured memory_bytes: 30488
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << (char)toupper(a[0]);
	cout << (char)toupper(b[0]);
	cout << (char)toupper(c[0]) << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

int main(){
  int n;
  while(~scanf("%d",&n)){
    int fish_num[21];
    memset(fish_num,0,sizeof(fish_num));

    int max_fish = 0;
    for(int i=0;i<n;i++){
      int a,v;
      scanf("%d %d",&a,&v);
      fish_num[a] += v;
      max_fish = max(max_fish,fish_num[a]);
    }

    for(int a=1;a<=n;a++){
      if(fish_num[a] == max_fish){
	printf("%d %d\n",a,fish_num[a]);
	break;
      }
    }
  }
}

Measured memory_bytes: 1192
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

int n,m,x;
map<int,int> hs;
int main() {
	scanf("%d",&n);
	rep(i,0,n) {
		scanf("%d",&x);
		hs[x]++;
	}
	scanf("%d",&m);
	rep(i,0,m) {
		scanf("%d",&x);
		hs[x]--;
	}
	for (auto p:hs) if (p.se<0) {
		puts("NO");
		return 0;
	}
	puts("YES");
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 2000000000
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int n;
	while(~getI(n)){
		int arr[n];
		F(i,0,n) getI(arr[i]);
		int ans=0;
		F(i,1,n-1) if((arr[i-1]>arr[i]&&arr[i]>arr[i+1])||(arr[i-1]<arr[i]&&arr[i]<arr[i+1])) ans++;
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 256
#include <cmath>
 #include <cstring>
 #include <iostream>
 #include <ostream>
 #include <vector>
   
 using std::cin;
 using std::cout;
 using std::cerr;
 using std::endl;
   
 // n 以下の素数のリストを返す O(nlog(log(n)))
 std::vector<int> eratosthenes(int n) {
   std::vector<int> is_prime(n + 1, 1);
   std::vector<int> primes;
  
   is_prime[0] = is_prime[1] = 0;
   primes.push_back(2);
   for(int i = 3; i <= n; i += 2) {
     if(is_prime[i]) {
       primes.push_back(i);
       for(int j = 3; i * j <= n; j += 2) {
         is_prime[i * j] = 0;
       }
     }
   }
  
   return primes;
 }
   
 int main() {
   int n;
   std::vector<int> primes = eratosthenes(10000);
   
   while(cin >> n, n) {
     int a = 2, b = 3;
     for(int i = 1; i < primes.size(); i++) {
       if (primes[i] > n) break;
  
       if(primes[i] - primes[i - 1] == 2) {
         a = primes[i - 1];
         b = primes[i];
       }
     }
     cout << a << " " << b << endl;
   }
   
   return 0;
 }


Measured memory_bytes: 3120
x=int(input())
def beki(n):
    for i in range(2,32):
        k=n
        if k%i==0:
            t=0
            while k>=1:
                k/=i
                if k==1 and t>=1:
                    return True
                t+=1
y=1
for i in range (1,x+1):
    if beki(i)==True:
        y=i
print(y)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define vll vector<long long>
#define vi vector<int>
#define wh(t) while(t--)
#define fi(n) for(long long i = 0; i < n; i++)
#define fj(n) for(long long j = 0; j < n; j++)
#define fu(i,s,e) for(ll i = s; i <=e; i++)
#define fd(i,s,e) for(ll i = s; i >=e; i--)
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define sll stack<ll>
#define qll queue<ll>
using namespace std;
// const ll M = 1e9+7;
//const ll M = 998244353;
const ll M = 1e10;

ll pmp(ll x,ll n){
	ll a = 1;
	while(n > 0){
		if(n & 1) a = (a * x)%M;
		x = (x * x) % M;
		n = n>>1;
	}
	return a;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t;
	t = 1;
	// cin >> t;
	wh(t){
		ll x;
		cin >> x;
		vll p(121,0);
		fi(121){
			p[i] = pmp(i,5);
			if(x == p[i]){
				cout << i << ' ' << 0;
				return 0;
			}
		}
		fi(121){
			fu(j,i,121){
				if(x == p[i] + p[j]){
					cout << i << ' ' << -j;
					return 0;
				}
				if(x == p[j] - p[i]){
					cout << j << ' ' << i;
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3672
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();

        if (a < 1200)
            System.out.println("ABC");
        else
            System.out.println("ARC");
    }
}


Measured memory_bytes: 35644
<?php
fscanf(STDIN, "%d %d", $D, $E);

while($D!=0||$E!=0){
	if ($D<=$E) {
		printf("%d\n", $E-$D);
	}else{
		$obj=$E;
		$min=100000;
		for ($i=0; $i <= $D/2; $i++) { 
			$cal = abs($obj - sqrt($i * $i + ($D - $i)*($D - $i)));
			if ($min>$cal) {
				$min = $cal;
			}
		}
		printf("%f\n", $min);
	}
	fscanf(STDIN, "%d %d", $D, $E);
}


Measured memory_bytes: 9224
#include<bits/stdc++.h>
using namespace std;
int a,b,n;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>a>>b;
    if((b-a)%2==0)
        puts("Alice");
    else
        puts("Borys");
    return 0;
}


Measured memory_bytes: 256
<?php
// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d %d", $N, $M);
$p = [];
for ($i = 0; $i < $M; $i++) {
    fscanf(STDIN, "%d %d", $A, $B);
    $p[$A][$B] = 1;
    $p[$B][$A] = 1;
}

$visited = [];
$q = [1];
$ans = array_pad(array(), $N - 1, 0);
while($q) {
    if (DEBUG) echo "-----\n";
    $new_q = [];
    foreach ($q as $tmp) {
        foreach ($p[$tmp] as $v => $dummy) {
            if (DEBUG) echo "$tmp -> $v\n";
            if (! isset($visited[$v])) {
                $visited[$v] = 1;
                if ($v >= 2) {
                    $ans[$v - 2] = $tmp;
                }
                array_push($new_q, $v);
            }
        }
    }
    $q = $new_q;
    if (DEBUG) echo implode(' ', $q) . PHP_EOL;
}
//var_dump($ans);
//exit;
ksort($ans);
//var_dump($ans);
//exit;
echo "Yes\n";
echo implode(PHP_EOL, $ans);


Measured memory_bytes: 74540
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)     (x).begin() , (x).end()
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
typedef long long int ll;
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}


const ll mod = 1e9+7;
const double eps = 1e-9;




int n;
string s;
void solve(){
    char a;
    cin>>a;
    if(a>='a'&&a<='z')cout<<'a'<<"\n";
    else cout<<"A\n";
}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	string s;cin >> s;
	int ans = 1;
	rep(i,n - 1){
		if(s.at(i) != s.at(i + 1)) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <utility>
#include <numeric>
#include <iomanip>

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

using namespace std;

int main()
{
    int n;
    string s;

    cin >> n;
    cin >> s;

    int ans = 0;

    for (int i = 0; i < n-2; i++)
    {
        if (s[i] == 'A')
        {
            if (s[i+1] == 'B')
            {
                if (s[i+2] == 'C')
                {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
    
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

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

    vector<ll> a(n);
    REP(i,n) {
        ll b;
        cin >> b;
        a[i] = b;
    }
    vector<ll> a2(a);

    // a[0] > 0
    ll res1 = 0, sum1 = 0;
    REP(i, n) {
        if(i%2 == 0) {
            if (sum1 + a[i] <= 0) {
                ll dif = -(sum1 + a[i]) + 1;
                res1 += dif;
                a[i] += dif;
            }
            sum1 += a[i];
        } else {
            if (sum1 + a[i] >= 0) {
                ll dif = (sum1 + a[i]) + 1;
                res1 += dif;
                a[i] -= dif;
            }
            sum1 += a[i];
        }
    }

    ll res2 = 0, sum2 = 0;
    REP(i, n) {
        if(i%2 == 1) {
            if (sum2 + a2[i] <= 0) {
                ll dif = -(sum2 + a2[i]) + 1;
                res2 += dif;
                a2[i] += dif;
            }
            sum2 += a2[i];
        } else {
            if (sum2 + a2[i] >= 0) {
                ll dif = (sum2 + a2[i]) + 1;
                res2 += dif;
                a2[i] -= dif;
            }
            sum2 += a2[i];
        }
    }

    cout << min(res1, res2) << endl;
}


Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (A, B) = Scanner.Scan<int, int>();
            Console.WriteLine(A * B);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28272
#include<stdio.h>

int main(void){
  long int a,b,k,p,q;
  scanf("%ld%ld%ld",&a,&b,&k);
  if(a>k){
    p=a-k;
    q=b;
  }else if(a+b>k){
    p=0;
    q=a+b-k;
  }else{
    p=0;
    q=0;
  }
  
  printf("%ld %ld",p,q);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl

template<typename T>
T gcd(T x, T y){
    if ((x==1)||(y==1)) return 1;
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}

int main() {
    IN(int, n);
    IN(int, m);
    vi a(n,-1);
    REP(i, m){
        IN(int, s);
        IN(int, c);
        if (a[s-1]==-1 || a[s-1]==c) {
            a[s-1] = c;
        }else{
            COUT(-1);
            return 0;
        }
    }
    if (n!=1) {
        if(a[0]==0) {
            COUT(-1);
            return 0;
        }else if (a[0]==-1){
            a[0]=1;
        }
    }
    
    REP(i, n){
        if (a[i]==-1) {
            cout << 0;
        }else{
            cout << a[i];
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    int ans = 0;
    rep(i, n) rep3(j, i + 1, n) chmax(ans, abs(a[i] - a[j]));
    cout << ans << endl;
}


Measured memory_bytes: 3660
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <utility>
#include <queue>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;



int main() {
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n)cin >> p[i];

    sort(p.begin(), p.end());
    int ans = 0;
    rep(i, k) {
        ans += p[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define inf 0x7FFFFFFF
#define N 110000
using namespace std;
vector<int>a[N];
int l1[N],r1[N],l2[N],r2[N],val[N],n,u,v,k;
bool dfs1(int u,int fa){
//	printf("%d %d:\n",u,fa);
	l1[u]=-inf;r1[u]=inf;
	if(val[u]!=-inf) l1[u]=r1[u]=val[u];
//	for(int i=0;i<a[u].size();++i)
//		printf("  %d\n",a[u][i]);
	for(int i=0;i<a[u].size();++i){
		if(a[u][i]==fa) continue;
		if(!dfs1(a[u][i],u)) return false;
		if(l1[a[u][i]]==-inf) continue;
		l1[a[u][i]]-=1,r1[a[u][i]]+=1;
		if(r1[u]==inf) l1[u]=l1[a[u][i]],r1[u]=r1[a[u][i]];
		else{
			if(r1[a[u][i]]<l1[u] or r1[u]<l1[a[u][i]]) return false;
			if(abs(l1[u]-l1[a[u][i]])%2==1) return false;
			l1[u]=max(l1[u],l1[a[u][i]]);
			r1[u]=min(r1[u],r1[a[u][i]]);
		}
		l1[a[u][i]]+=1,r1[a[u][i]]-=1;
	}
	return true;
}
void dfs2(int u,int fa){
	if(l2[fa]==-inf) l2[u]=l2[fa],r2[u]=r2[fa];
	else{
		l2[u]=l2[fa]-1;r2[u]=r2[fa]+1;
	}
	l2[u]=max(l2[u],l1[u]);
	r2[u]=min(r2[u],r1[u]);
	
	if(val[u]!=-inf) l2[u]=r2[u]=val[u];
	for(int i=0;i<a[u].size();++i)	
		if(a[u][i]!=fa) dfs2(a[u][i],u);
}
int main(){
//	freopen("a.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<n;++i){
		scanf("%d%d",&u,&v);
		a[u].push_back(v);
		a[v].push_back(u);
	}
	scanf("%d",&k);
	for(int i=1;i<=n;++i) val[i]=-inf;
	for(int i=1;i<=k;++i) scanf("%d%d",&u,&v),val[u]=v;
	int yu=dfs1(1,0);
	if(yu){
		printf("Yes\n");
		l2[0]=-inf;
		r2[0]=inf;
		dfs2(1,0);
		for(int i=1;i<=n;++i) printf("%d\n",l2[i]); 
	}
	else printf("No");
	return 0;
}

Measured memory_bytes: 16384
N = int(input())
H = list(map(int, input().split()))

now = H[0] - 1

for i in range(1,N):
    if H[i] - now == 0:
        pass
    elif H[i] - now == 1:
        pass
    elif H[i] - now >= 2:
        now = H[i] - 1
    else:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 14836