akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int i,n;
	cin>>n;
	while(1){
		if(ceil(sqrt(n))==floor(sqrt(n))){
			cout<<n<<endl;
			return 0;
		}
		else n--;
	}
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
int a[maxn];
int n;
ll power(ll a,ll b)
{
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ans=ans*a%mod;
	return ans;
}
void solve(int l,int r,ll& f,ll& g)
{
	int mn=a[l],mx=a[l];
	for(int i=l+1;i<=r;i++){
		mx=std::max(mx,a[i]);
		mn=std::min(mn,a[i]);
	}
	for(int i=l;i<=r;i++)
		a[i]-=mn;
	if(mx==mn){
		f=(power(2,r-l+1)+mod-2)%mod;
		g=power(2,mn);
		return;
	}
	ll mul1=1,mul2=1;
	int last=l,cnt=0;
	for(int i=l;i<=r;i++)
		if(a[i]&&(!a[i+1]||i==r)){
			ll tf=0,tg=0;
			solve(last,i,tf,tg);
			mul1=mul1*(tf+2*tg)%mod;
			mul2=mul2*tg%mod;
		}
		else if(!a[i]){
			last=i+1;
			++cnt;
		}
	f=(power(2,cnt)*mul1-2*mul2+2*mod)%mod;
	g=power(2,mn)*mul2%mod;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	ll f=0,g=0;
	solve(1,n,f,g);
	writeln((f+g)%mod);
	return 0;
}

Measured memory_bytes: 128
# 3.24の練習


# D maze master

h, w = map(int, input().split())

graph = {i: {} for i in range(1, h * w + 1)}

data = []
data.append([False for i in range(w + 2)])
for i in range(h):
    s = list(input())
    sub = [False]
    for i in range(w):
        if s[i] is "#":
            sub.append(False)
        else:
            sub.append(True)
    sub.append(False)
    data.append(sub)
data.append([False for i in range(2 + w)])

for i in range(1, h + 1):
    for j in range(1, w + 1):
        # now data[i][j]
        if data[i][j]:
            now = w * (i - 1) + j
            if data[i - 1][j]:
                node = w * (i - 1) + j
                graph[now][node]=1
                graph[node][now]=1
            if data[i][j + 1]:
                node = w* (i - 1) + j + 1
                graph[now][node]=1
                graph[node][now]=1
            if data[i][j - 1]:
                node = w * (i - 1) + j - 1
                graph[node][now]=1
                graph[now][node]=1
            if data[i + 1][j]:
                node = w * i + j
                graph[node][now]=1
                graph[now][node]=1

# graph=迷路のグラフデータ構造

import heapq
def dijkstra(s,graph,n):
    #ｓからのグラフの最短最短距離をまとめたデータを返す
    dist=[10**20 for i in range(n+1)]
    dist[s]=0
    pq=[]
    heapq.heapify(pq)
    #全ての接点を一度優先度付きキューに挿入する
    heapq.heappush(pq,(0,s))
    while pq:
        x=heapq.heappop(pq)
        node,mini_dis=x[1],x[0]
        for point in graph[node].keys():
            w=graph[node][point]
            #nodeからpointに対して伸びる辺の長さ
            newlen=dist[node]+w
            if newlen<dist[point]:
                heapq.heappush(pq,(newlen,point))
                dist[point]=newlen
    mea=0
    for i in range(1,n+1):
        if 0<dist[i]<10**20:
            mea=max(dist[i],mea)
    return mea

###############################################################
ans=0
for i in range(1,h*w+1):
    if graph[i]:
        ans=max(ans,dijkstra(i,graph,h*w))
print(ans)


Measured memory_bytes: 3316
sa = str(input())
sb = str(input())
sc = str(input())
sa_count = 0
sb_count = 0
sc_count = 0
tmp = 'a'

for _ in range(300):
    if tmp=='a':
        sa_count += 1
        if sa_count==len(sa)+1:
            print('A')
            break
        else:
            tmp = str(sa[sa_count-1])
    elif tmp=='b':
        sb_count += 1
        if sb_count==len(sb)+1:
            print('B')
            break
        else:
            tmp = str(sb[sb_count-1])
    elif tmp=='c':
        sc_count += 1
        if sc_count==len(sc)+1:
            print('C')
            break
        else:
            tmp = str(sc[sc_count-1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const char block= '#';

void init_row(const vector<string> &museum, vector<vector<int>> *row){
  const int H= museum.size();
  const int W= museum.at(0).size();

  for(int i=0; i<H; i++){
    int lower= 0;
    int upper= 0;
    while(lower < W){
      while(upper < W && museum.at(i).at(upper)!=block){
        upper++;
      }
      for(int j=lower; j<upper; j++){
        row->at(i).at(j)= upper- lower;
      }

      upper++;
      lower= upper;
    }
  }
}

void init_col(const vector<string> &museum, vector<vector<int>> *col){
  const int H= museum.size();
  const int W= museum.at(0).size();

  for(int j=0; j<W; j++){
    int lower= 0;
    int upper= 0;
    while(lower < H){
      while(upper < H && museum.at(upper).at(j)!=block){
        upper++;
      }
      for(int i=lower; i<upper; i++){
        col->at(i).at(j)= upper- lower;
      }

      upper++;
      lower= upper;
    }
  }
}

int main(){
  int H,W;
  cin >> H >> W;

  vector<string> museum(H);
  for(int i=0; i<H; i++){
    cin >> museum.at(i);
  }

  vector<vector<int>> row(H, vector<int>(W));
  vector<vector<int>> col(H, vector<int>(W));

  init_row(museum, &row);
  init_col(museum, &col);

  int ans= 0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      ans= max(ans, row.at(i).at(j)+ col.at(i).at(j)- 1);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 35712
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(S: str):
    c = 0
    b = S[0]
    N = len(S)
    for i in range(1,N):
        if S[i] != S[i-1]:
            c += 1

    print(c)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

int main(){
  string a,b; cin>>a >>b;
  int k=stoi(a+b);
  bool flag=false;
  for(int i=3;i<=316;i++){
    if(i*i==k)flag=true;
  }
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
n = gets.to_i
as = gets.split.map(&:to_i)

count = n.times.each_with_object(Hash.new(0)) do |i, h|
  h[i + as[i]] += 1
end

ans = n.times.inject(0) do |r, i|
  r += count[i - as[i]]
end

puts ans


Measured memory_bytes: 37020
import sys
input = sys.stdin.readline
from collections import deque
def main():
    N = int( input())
    E = [[] for _ in range(N)]
    for _ in range(N-1):
        u, v, w = map( int, input().split())
        u -= 1
        v -= 1
        E[u].append((v,w))
        E[v].append((u,w))
    V = [-1]*N
    V[0] = 0
    d = deque([(0,0)])
    while d:
        u, l = d.popleft()
        for v,w in E[u]:
            if V[v] == -1:
                V[v] = (l+w)%2
                d.append((v, (l+w)%2))
    print("\n".join( map( str, V)))
    
    
if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
    int a, b;
    char op;
    cin >> a >> op >> b;
    
    if (op == '+') {
        cout << a + b << endl;
    } else if (op == '-') {
        cout << a - b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
main(){
 int a;
  scanf("%d",&a);
  int t=0,i;
  long int b[20000000],k=0;
  for(i=0;i<a;i++){
    scanf("%ld",&b[i]);
  if(t<b[i]) t=b[i];
    else k+=t-b[i];
  }
printf("%ld",k);
}


Measured memory_bytes: 3228
package main

import (
	"fmt"
)

func main() {
	var n int
	var m1 = 0
	var m2 = 0
	array := []int{}
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		array = append(array, a)
		if a > m1 {
			m2 = m1
			m1 = a
		} else if a > m2 {
			m2 = a
		}
	}
	for i := 0; i < n; i++ {
		if array[i] != m1 {
			fmt.Println(m1)
		} else {
			fmt.Println(m2)
		}
	}
}


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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

// #define DEBUG

void solve(long long N, std::vector<long long> A){
    vec<ll> nums(N + 1, 0);
    for(int i=0; i < N; i++){
        nums[A[i]]++;
    }

    ll fullTotal = 0;
    for(int i=0; i <= N; i++){
        fullTotal += max(0LL, nums[i]*(nums[i] - 1)/2);
        #ifdef DEBUG
        printf("*START: \n");
        cout << nums[i] << ", " << max(0LL, nums[i]*(nums[i] - 1)/2) << endl;
        printf("*END: \n");
        #endif
    }

    for(int i=1; i <= N; i++){
        auto res = fullTotal;
        ll n = nums[A[i-1]];

        res -= max(0LL, n*(n-1)/2);
        res += max(0LL, (n-1)*(n-2)/2);
        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 N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

const long long INF = 1LL << 60;
const ll MOD = ll(1e9)+7;

bool has_key(unordered_map<string, ll> &m, string s){
    if (m.find(s) == m.end()){
        return false;
    }
    else{
        return true;
    }
}


bool vector_find(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) {
    return true;
  }
  else {
    return false;
  }
}


void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}


void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

ll count_black(vector<vector<string>> C) {

  ll num = 0;
  for (ll i = 0; i < C.size(); i++) {
    for (ll j = 0; j < C.at(i).size(); j++) {
      if (C.at(i).at(j) == "#") num++;
    }
    
  }

  return num;
  
}

vector<vector<string>> paint(vector<vector<string>> C, vector<ll> x, vector<ll> y) {

  vector<vector<string>> C_painted = C;

  for (ll i = 0; i < x.size(); i++) {
    if(x.at(i) == 1) {
      for (ll j = 0; j < C_painted.size(); j++) {
        C_painted.at(j).at(i) = "r";
      }
    }
  }

  for (ll i = 0; i < y.size(); i++) {
    if(y.at(i) == 1) {
      for (ll j = 0; j < C_painted.at(0).size(); j++) {
        C_painted.at(i).at(j) = "r";
      }
    }
  }

  return C_painted;
  
}

vector<vector<ll>> vec_x;

void sublistx(vector<ll> tmp, ll n) {
    if (n == 0) {
      vec_x.push_back(tmp);
    }
    if (n > 0) {
      vector<ll> tmp0 = tmp;
      vector<ll> tmp1 = tmp;
      tmp0.push_back(0);
      tmp1.push_back(1);
      sublistx(tmp0, n - 1);
      sublistx(tmp1, n - 1);
    }
}

vector<vector<ll>> vec_y;

void sublisty(vector<ll> tmp, ll n) {
    if (n == 0) {
      vec_y.push_back(tmp);
    }
    if (n > 0) {
      vector<ll> tmp0 = tmp;
      vector<ll> tmp1 = tmp;
      tmp0.push_back(0);
      tmp1.push_back(1);
      sublisty(tmp0, n - 1);
      sublisty(tmp1, n - 1);
    }
}


int main() {

  ll K;

  cin >> K;
  
  ll div = 7%K;
  ll ans = 1;
  while(div != 0) {
    if(ans >= 10000000) {
      ans = -1;
      break;
    }
    
    div = (div*10 + 7)%K;

    ans++;
  }

 
  


  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int x;
	cin >> x;
	int result;
	if(x < 600) {
		result = 8;
	} else if(x < 800) {
		result = 7;
	} else if(x < 1000) {
		result = 6;
	} else if(x < 1200) {
		result = 5;
	} else if(x < 1400) {
		result = 4;
	} else if(x < 1600) {
		result = 3;
	} else if(x < 1800) {
		result = 2;
	} else {
		result = 1;
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

const int MAX_N = 150;

struct Rect {
    int h, w, d; // h < w
    Rect(int h, int w) : h(h), w(w) {
        d = h * h + w * w;
    }
};
bool operator < (const Rect &a, const Rect &b)
{
    return (a.d != b.d) ? (a.d < b.d) : (a.h < b.h);
}

Rect r(0, 0);

void solve()
{
    Rect ans(MAX_N, MAX_N);

    for (int th = 1; th <= MAX_N; th++) {
        for (int tw = th + 1; tw <= MAX_N; tw++) {
            Rect tmp(th, tw);
            
            if (r < tmp && tmp < ans)
                ans = tmp;
        }
    }
    cout << ans.h << " " << ans.w << endl;
}

int main()
{
    while (cin >> r.h >> r.w, r.h || r.w) {
        r.d = r.h * r.h + r.w * r.w;
        solve();
    }

    return 0;
}

Measured memory_bytes: 1160
let () =
  let x1,y1,x2,y2 = Scanf.scanf "%f %f %f %f\n" (fun a b c d -> a,b,c,d) in
  let sqr x = x *. x in
  Printf.printf "%f\n" (sqr (x1-.x2) |> (+.) (sqr (y1-.y2)) |> sqrt)

Measured memory_bytes: 2340
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = INT_MAX;
bool mywish(const pii &a,const pii &b)
  {
    return a.first > b.first;
  }

void solve()
  {
   int k,x;
   cin>>k>>x;
   cout<<(500ll*k >= x ? "Yes" : "No");
  } 
signed main()
 {
  
  /* int t;
   cin>>t;
   while(t--)*/
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 384
d ={"o":0, "x":1}
e =["S","W"]
n = int(input())
s = [d[t] for t in input()]
#print(s)

u = [0,1,0,1]
v = [0,0,1,1]

for i in range(4):
  a = [-1]*(n+2)
  a[0] = u[i]
  a[1] = v[i]
  for i in range(n):
    a[i+2] = a[i] ^ a[i+1] ^ s[i]
  if a[0] == a[n] and a[1] == a[n+1]:
    print("".join([e[t] for t in a[1:n+1]]))
    quit()
print(-1)

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

using namespace std;

int main(){

  vector <long long> d;
  int n;
  long long a;
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> a;
    d.push_back(a);
  }
  if(d.size()%2 == 0){
    

    for(int i = d.size() - 1;i >= 1; i = i - 2){
      cout << d[i] << " ";
    }
    for(int i = 0; i <= d.size() - 2;i = i + 2){
      cout << d[i] << " ";
    }
  }
  if(d.size()%2 == 1){
    if(d.size() == 1){
      cout << d[0];
    }
    else{
      for(int i = d.size() - 1;i >= 0; i = i - 2){
	cout << d[i] << " ";
      }
      for(int i = 1; i <= d.size() - 2;i = i + 2){
	cout << d[i] << " ";
      }
    }
  }

}

Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

int main(){

  int N; cin >> N;
  vector <double> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());

  for (int i = 1; i < N; i++){
    A[i] = (A[i] + A[i - 1]) / 2;
  }
  cout << setprecision(16) << A[N-1] << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
x, y = map(int, input().split())
ans = 10 ** 9 + 3
if y >= x:
    ans = min(ans, abs(y - x))
if - y >= x:
    ans = min(ans, abs(-y - x) + 1)
if y >= -x:
    ans = min(ans, abs(y + x) + 1)
if - y >= -x:
    ans=min(ans, abs(-y + x) + 2)
print(ans)

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

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

    int f = 0;
    vector<int> a(n);
    for (int i = 0; i < s.size(); ++i) {
      int j = i % n;

      if (s[i] == 'S') {
        f += a[j] + 1;
        a[j] = 0;
      } else if (s[i] == 'L') {
        a[j] += f + 1;
        f = 0;
      } else {
        a[j]++;
      }
    }

    sort(a.begin(), a.end());
    for (int i = 0; i < n; ++i) {
      cout << a[i] << " ";
    }
    cout << f << endl;
  }
}

Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
constexpr lnt INF = 2e18;
/*-*/

int main() {
	std::string s;
	std::cin >> s;
	int n=s.size();
	rep(i,n) if(s[i]=='?') s[i]='D';
	print(s);
}


Measured memory_bytes: 3724
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef int int_;
#define int long long
#define maxn 200010
const int inf=1e9+7;
inline int read(){
	int ret=0,ff=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') ff=-ff;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		ret=ret*10+ch-'0';
		ch=getchar();
	}
	return ret*ff;
}

int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
int ksm(int a,int b,int p){
	int ret=1;
	while(b){
		if(b&1) ret=ret*a%p;
		a=a*a%p;
		b>>=1;
	}
	return ret%p;
}
bool vis[maxn];
int a[maxn],ans[maxn];
int qwq[maxn];
int_ main(){
	int n=read();
	int cnt=0;
	while(n--){
		ans[++cnt]=n%26;
		n/=26;
	}
	while(cnt){
		printf("%c",'a'+ans[cnt]);
		--cnt;
	}
} 

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

using namespace std;

int main(){
     
    int n,aux,soma=0;

    cin>>n;

    aux = n;

    while(aux>0){
        soma += aux%10;
        aux = aux/10; 
    }

    if(n%soma==0){
        cout<<"Yes";
    }else{
        cout<<"No";
    }

    return 0;
}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        x: i64,
    }

    for c in 1.. {
        if c * c > x {
            break;
        }
        if x % c != 0 {
            continue;
        }
        for &c in &[c, x / c] {
            if c % 5 != x % 5 {
                continue;
            }
            if (x - c.pow(5)) % (5 * c) != 0 {
                continue;
            }
            for b in -1000..=1000 {
                let a = b + c;
                if a.pow(5) - b.pow(5) == x {
                    println!("{} {}", a, b);
                    return;
                }
                let a = b - c;
                if a.pow(5) - b.pow(5) == x {
                    println!("{} {}", a, b);
                    return;
                }
            }
        }
    }
    panic!();
}


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

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> c(h);
  for(int i=0;i<h;i++) cin>>c[i];
  for(int i=0;i<h;i++){
    for(int j=0;j<2;j++)
      cout<<c[i]<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b;
  int A, B;
  cin >> a >> b;
  
  A = a % 2;
  B = b % 2;
  
  if((A == 0 && B == 0)||(A == 1 && B == 0)||(A == 0 && B == 1))
  {
    cout << "Even" << endl;
  }
  else if(A == 1 && B == 1)
  {
   	cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;
template <typename T> 
class Combination {
  private: 
    vector<T> _fact, _rfact;
  
  private: 
  int mpow(int x, int y) {
    int res = 1;
    x %= MOD;
    while (y > 0) {
      if (y & 1) res = res * x % MOD;
      x = x * x % MOD;
      y >>= 1;
    }
    return res;
  }

  public:
  Combination(int sz) : _fact(sz + 1), _rfact(sz + 1) {
    _fact[0] = _rfact[sz] = 1;
    for(int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i % MOD;
    _rfact[sz] = mpow(_fact[sz], MOD - 2);
    for(int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1) % MOD;
  }

  inline T fact(int k) const { return _fact[k]; } 
  inline T rfact(int k) const { return _rfact[k]; } 

  T C(int n, int r) const {
    if (r < 0 || n < r) return 0;
    return fact(n) * rfact(r) % MOD * rfact(n - r) % MOD;
  }
};


int n, k;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n >> k;
  Combination<int> cmb(2005);
  erep(i, 1, k) {
    cout << cmb.C(n - k + 1, i) * cmb.C(k - 1, i - 1) % MOD << endl;
  }
  return 0;
}




Measured memory_bytes: 256
from decimal import Decimal

def to_binary(s_16):
    s_2 = []
    for tmp in s_16:
        tmp_10 = int(tmp, 16)
        if tmp_10 >= 8:
            s_2.append("1")
            tmp_10 -= 8
        else:
            s_2.append("0")
        if tmp_10 >= 4:
            s_2.append("1")
            tmp_10 -= 4
        else:
            s_2.append("0")
        if tmp_10 >= 2:
            s_2.append("1")
            tmp_10 -= 2
        else:
            s_2.append("0")
        if tmp_10 >= 1:
            s_2.append("1")
            tmp_10 -= 1
        else:
            s_2.append("0")
    return s_2

def is_int(s_2):
    b = True
    for i in s_2[25:]:
        if i == '1':
            b = False
            break
    return b

Q = input()
for i in range(Q):
    s_16 = raw_input()
    s_2 = to_binary(s_16)
    num_10 =  Decimal("0.0")
    for i in range(1, 32):
        if i <= 24:
            if s_2[i] == "1":
                tmp = 2 ** (24-i)
                num_10 += Decimal(str(tmp))
        else:
            if s_2[i] == "1":
                tmp = 0.5 ** (i-24)
                num_10 += Decimal(str(tmp))
    if s_2[0] == "1":
        if is_int(s_2):
            print "-%.1f" % num_10
        else:
            print "-%s" % str(num_10)

    else:
        if is_int(s_2):
            print "%.1f" % num_10
        else:
            print "%s" % str(num_10)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    ll k;
    cin>>k;
    vll a;
    ll num1=k/50,num2=k%50;
    rep(i,50)a.push_back(49);
    rep(i,50)a[i]+=num1;
    rep(i,50){
        if (i<num2)a[i]+=50-num2+1;
        else a[i]-=num2;
    }
    cout<<50<<endl;
    rep(i,50)cout<<a[i]<<" ";
    cout<<endl;

    return 0;
}

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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    ll A, B, C;
    cin >> A >> B >> C;
    ull dif = 0;
    if(A % 2 == 0 or B % 2 == 0 or C % 2 == 0) dif = 0;
    else dif = min(A * B, min(B * C, A * C));

    cout << dif << endl;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define OUT(a) cout << (a) << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    string n;

  cin >> n;

  if (n.find('7') != string::npos){
      cout << "Yes" << endl;
  } else {
      cout << "No" << endl;
  }

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MOD = 998244353;
const int MAX = 2e5 + 5;
int fat[MAX];

inline int add(int a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
    return a;
}

inline int mult(int a, int b) {
    return (1LL * a * b) % MOD;
}

int f_exp(int x, int e) {
    if (e == 0) return 1;
    if (e & 1) return mult(x, f_exp(x, e - 1));
    return f_exp(mult(x, x), e / 2);
}

inline int inv(int x) {
    return f_exp(x, MOD - 2);
}

inline int comb(int n, int k) {
    return mult(fat[n], mult(inv(fat[n - k]), inv(fat[k])));
}

void preprocess() {
    fat[0] = 1;
    fori (i, 1, MAX) {
        fat[i] = mult(fat[i - 1], i);
    }
}

void solve() {
    preprocess();
    int n, m, k;
    cin >> n >> m >> k;
    int ans = 0;
    fori (i, 0, k + 1) {
        int a = mult(m, f_exp(m - 1, (n - 1 - i)));
        int b = comb(n - 1, i);
        int cur = mult(a, b);
        ans = add(ans, cur);
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}



Measured memory_bytes: 4472
from collections import defaultdict
class UnionFind:
    def __init__(self, num):
        self.table = [-1 for _ in range(num)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)

        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False

N = int(input())
dx = defaultdict(list)
dy = defaultdict(list)
xy = []

for i in range(N):
    x,y = map(int,input().split())
    dx[x].append(i)
    dy[y].append(i)
    xy.append([x,y])

u = UnionFind(N)

for x in dx:
    i = dx[x][0]
    for j in dx[x]:
        u.union(i,j)

for y in dy:
    i = dy[y][0]
    for j in dy[y]:
        u.union(i,j)

dx = defaultdict(list)
dy = defaultdict(list)

for i in range(N):
    dx[u.find(i)].append(xy[i][0])
    dy[u.find(i)].append(xy[i][1])

ans = -N
for i in dx:
    ans += len(set(dx[i]))*len(set(dy[i]))

print(ans)

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

const int MAXN = 100005;

int N, S, W, Q;
lli a[MAXN];

void init() {
  int g = S;
  for(int i=0; i<N; i++) {
    a[i] = (g/7) % 10;
    if( g%2 == 0 ) { g = (g/2); }
    else           { g = (g/2) ^ W; }
  }
}

int main() {
  while(cin >> N >> S >> W >> Q && (N|S|W|Q)) {
    init();
    lli res = 0;
    if(Q == 2 || Q == 5) {
      for(lli i = 0, sum = 0; i < N; ++i) {
        sum += a[i] != 0;
        if(a[i] % Q == 0) res += sum;
      }
    } else {
      map<lli, lli> num;
      num[0] = 1;
      for(lli i = N-1, now = 0, ten = 1; i >= 0; --i, ten = ten * 10 % Q) {
        now = ( now + a[i] * ten ) % Q;
        if(a[i]) res += num[now];
        num[now] += 1;
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 7596
import sys
lstlet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
lstint = [0] * 26
moji = ""
while True:
  try:
    moji = moji + str(input())
  except:
    break;
lstin = list(moji)
length = len(lstin)
for i in range(length):
  if str(lstin[i]) == "a" or str(lstin[i]) == "A":
    lstint[0] += 1
  elif str(lstin[i]) == "b" or str(lstin[i]) == "B":
    lstint[1] += 1
  elif str(lstin[i]) == "c" or str(lstin[i]) == "C":
    lstint[2] += 1
  elif str(lstin[i]) == "d" or str(lstin[i]) == "D":
    lstint[3] += 1
  elif str(lstin[i]) == "e" or str(lstin[i]) == "E":
    lstint[4] += 1 
  elif str(lstin[i]) == "f" or str(lstin[i]) == "F":
    lstint[5] += 1
  elif str(lstin[i]) == "g" or str(lstin[i]) == "G":
    lstint[6] += 1
  elif str(lstin[i]) == "h" or str(lstin[i]) == "H":
    lstint[7] += 1
  elif str(lstin[i]) == "i" or str(lstin[i]) == "I":
    lstint[8] += 1
  elif str(lstin[i]) == "j" or str(lstin[i]) == "J":
    lstint[9] += 1
  elif str(lstin[i]) == "k" or str(lstin[i]) == "K":
    lstint[10] += 1
  elif str(lstin[i]) == "l" or str(lstin[i]) == "L":
    lstint[11] += 1
  elif str(lstin[i]) == "m" or str(lstin[i]) == "M":
    lstint[12] += 1
  elif str(lstin[i]) == "n" or str(lstin[i]) == "N":
    lstint[13] += 1
  elif str(lstin[i]) == "o" or str(lstin[i]) == "O":
    lstint[14] += 1
  elif str(lstin[i]) == "p" or str(lstin[i]) == "P":
    lstint[15] += 1
  elif str(lstin[i]) == "q" or str(lstin[i]) == "Q":
    lstint[16] += 1
  elif str(lstin[i]) == "r" or str(lstin[i]) == "R":
    lstint[17] += 1
  elif str(lstin[i]) == "s" or str(lstin[i]) == "S":
    lstint[18] += 1
  elif str(lstin[i]) == "t" or str(lstin[i]) == "T":
    lstint[19] += 1
  elif str(lstin[i]) == "u" or str(lstin[i]) == "U":
    lstint[20] += 1
  elif str(lstin[i]) == "v" or str(lstin[i]) == "V":
    lstint[21] += 1
  elif str(lstin[i]) == "w" or str(lstin[i]) == "W":
    lstint[22] += 1
  elif str(lstin[i]) == "x" or str(lstin[i]) == "X":
    lstint[23] += 1
  elif str(lstin[i]) == "y" or str(lstin[i]) == "Y":
    lstint[24] += 1
  elif str(lstin[i]) == "z" or str(lstin[i]) == "Z":
    lstint[25] += 1
for j in range(26):
  print(str(lstlet[j]) + " : " + str(lstint[j]))


Measured memory_bytes: 5756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main() {
    int n,t;
    cin >> n >> t;
    vector<int> vec(n);
    REP(i,n){
        cin >> vec.at(i);
    }
    int ans = t+vec.at(n-1)-vec.at(0);
    REP(i,n-1){
        ans -= max(0,vec.at(i+1)-vec.at(i)-t);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3904
/******************************************
* AUTHOR : cf/villazer *
******************************************/
#include <iostream>
#include<iomanip>
using namespace std;
#define N 100005
#define mod 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
#define lb(arr,n,x) lower_bound(arr,arr+n,x)-arr
#define ub(arr,n,x) upper_bound(arr,arr+n,x)-arr
#define endl "\n"
#define PI 3.14159265358979323846  /* pi */
#define sqr(x) (x)*(x)
#define all(v)  ((v).begin()),((v).end())
#define degreesToRadians(angleDegrees) (angleDegrees * PI / 180.0) // Converts degrees to radians.
#define radiansToDegrees(angleRadians) (angleRadians * 180.0 / PI) // Converts radians to degrees.

typedef long long ll;
typedef long double ld;
//Calculation of (x^y)%mm
ll mod_exp(ll x,ll y,ll mm)
{
    if(y==0)
        return(1);
    else if(y%2==0)
        return(mod_exp((x*x)%mm,y/2,mm));
    else
        return((x*mod_exp((x*x)%mm,(y-1)/2,mm))%mm);
}


int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif

ll r;
cin>>r;
ld s = 2*PI*r;
cout<<fixed<<setprecision(18)<<s<<endl;

return 0;
}

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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  int a,b,c;
  cin >> a >> b >> c;

  set<int> S;
  S.insert(a);
  S.insert(b);
  S.insert(c);
  cout << S.size() << endl;
}

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

int main(){
	int n;
	cin>>n;
	vector<int> p(n),q(n),r(n);
	rep(i,n) cin>>p[i];
	rep(i,n) cin>>q[i];
	rep(i,n) r[i]=i+1;
	int a,b,cnt=1;
	do{
		bool okp=true,okq=true;
		rep(i,n){
			if(p[i]!=r[i]) okp=false;
			if(q[i]!=r[i]) okq=false;
		}
		if(okp) a=cnt;
		if(okq) b=cnt;
		cnt++;
	}while(next_permutation(all(r)));
	cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int h[100002];
long long f[100002];
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
 
    int n, k;
    cin>>n>>k;
    for (int i=1;i<=n;i++) cin>>h[i];
    f[1] = 0;
    for (int i=2;i<=n;i++){
 
        f[i] = 1e9;
        for (int j=max(1, i-k);j<i;j++){
            f[i] = min(f[i], f[j] + abs(h[i] - h[j]));
        }
    }
    cout<<f[n];
 
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,m;
   cin >> n >> m;
   vector<int> H(n+1);
   vector<int> A(n+1,1);
   f(i,1,n+1){
      cin >> H[i];
   }
   f(i,1,m+1){
      int a,b;
      cin >> a >> b;
      if(H[a] == H[b]){
         A[a] &= 0;
         A[b] &= 0;
      }else if(H[a] > H[b]){
         A[a] &= 1;
         A[b] &= 0;
      }else{
         A[a] &= 0;
         A[b] &= 1;
      }
   }
   int R = 0;
   f(i,1,n+1) R += A[i];
   cout << R << '\n';
   return 0;
}

Measured memory_bytes: 4708
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long n, m;
    scan(n, m);
    auto S = new long[](m);
    auto C = new long[](m);
    // writeln(tmp);
    foreach (i; 0 .. m)
    {
        long s, c;
        scan(s, c);
        S[i] = s;
        C[i] = c;
    }
    foreach (i; 0 .. 10 ^^ 3)
    {
        string i_str = i.to!string();
        if (i_str.length == n)
        {
            // writeln(i);
            // writeln(isValid(i, S, C));

            if (isValid(i, S, C))
            {
                writeln(i);
                return;
            }
        }
    }
    writeln(-1);
}

bool isValid(long x, long[] S, long[] C)
{
    string x_str = x.to!string();
    foreach (i; 0 .. S.length)
    {
        if (x_str[S[i] - 1] != C[i] + '0')
        {
            // writeln(x_str[S[i] - 1], C[i]);
            return false;
        }
    }
    return true;

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


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

struct PrimalDual {
  struct Edge { int to, cap, cost, rev; };
  int n, init;
  vector<vector<Edge>> g;
  vector<int> dist, pv, pe, h;

  PrimalDual() {}
  PrimalDual(int n, int INF = 1e9)
    : n(n), init(INF), g(n), dist(n), pv(n), pe(n) {}

  void addEdge(int u, int v, int cap, int cost) {
    int szU = g[u].size();
    int szV = g[v].size();
    g[u].push_back({v, cap, cost, szV});
    g[v].push_back({u, 0, -cost, szU - 1});
  }
  int dijkstra(int s, int t) {
    dist = vector<int>(n, init);
    using Node = pair<int, int>;
    priority_queue<Node, vector<Node>, greater<Node>> pq;
    pq.push({dist[s] = 0, s});

    while (!pq.empty()) {
      auto d = pq.top().first;
      auto u = pq.top().second;
      pq.pop();
      if (dist[u] < d) continue;
      for (size_t i = 0; i < g[u].size(); ++i) {
        Edge& e = g[u][i];
        int v = e.to;
        if (e.cap > 0 && dist[v] > dist[u] + e.cost + h[u] - h[v]) {
          dist[v] = dist[u] + e.cost + h[u] - h[v];
          pv[v] = u;
          pe[v] = i;
          pq.push({dist[v], v});
        }
      }
    }
    return dist[t];
  }
  int build(int s, int t, int f) {
    int res = 0;
    h = vector<int>(n, 0);
    while (f > 0) {
      if (dijkstra(s, t) == init) return -1;
      for (int i = 0; i < n; ++i) h[i] += dist[i];
      int flow = f;
      for (int u = t; u != s; u = pv[u]) {
        flow = min(flow, g[pv[u]][pe[u]].cap);
      }
      f -= flow;
      res += flow * h[t];
      for (int u = t; u != s; u = pv[u]) {
        Edge& e = g[pv[u]][pe[u]];
        e.cap -= flow;
        g[u][e.rev].cap += flow;
      }
    }
    return res;
  }
};

int main() {
  int n;
  cin >> n;
  string S, T;
  cin >> S >> T;
  vector<int> s(26, 0);
  vector<int> t(26, 0);
  for (int i = 0; i < n; i++) {
    s[S[i] - 'a']++;
    t[T[i] - 'a']++;
  }
  int src = 26 * 2;
  int dst = src + 1;
  int V = dst + 1;
  PrimalDual pd(V);
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 26; j++) {
      int c = -min(t[j], s[i]);
      pd.addEdge(i, 26 + j, 1, (s[i] > 0) ? c : 1e9);
    }
  }
  for (int i = 0; i < 26; i++) {
    pd.addEdge(src, i, 1, 0);
    pd.addEdge(26 + i, dst, 1, 0);
  }
  int kind = 0;
  for (auto c : s) {
    if (c > 0) kind++;
  }
  int F = kind;
  cout << n + pd.build(src, dst, F) << endl;  
  return 0;
}



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

int main() {
  
  int H, W;
  cin >> H >> W;
  vector<string> vec(H);
  rep(i, H){
  	cin >> vec.at(i);
  }
  rep(j, W + 2){
  	cout << "#";
  }
  	cout << endl;
  rep(k, H){
    cout << "#" + vec.at(k) + "#" << endl;}
  rep(l, W + 2){
  	cout << "#";
  }
  	cout << endl;
  	return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define ll long long
#define int ll
#define ld long double
#define mn 55
#define pi 3.1415926535897
#define inf 6969696969696969696
#define mod (ll)1000000009
#define base 31
#define FLN "TEST"
#define pii pair <int, int>
#define one first
#define two second
#define all(n) n.begin(),n.end()

int n,a;
int s[mn],dp[mn][5005][mn];

void input()
{
	cin>>n>>a;
	for (int i=1; i<=n; i++)
	{
		cin>>s[i];
		s[i]-=a;
	}
	return;
}

int DP(int x, int y, int z)
{
	if (x==0)
	{
		if (y==2500 && z!=0) return 1;
		return 0;
	}
	if (dp[x][y][z]!=inf) return dp[x][y][z];
	return dp[x][y][z]=DP(x-1,y,z) + DP(x-1,y+s[x],z+1); 
}

void output()
{
	cout<<DP(n,2500,0);
	return;
}

void ezclap()
{
	for (int i=0; i<=n; i++)
	{
		for (int j=0; j<=5000; j++)
		{
			for (int k=0; k<=n; k++)
			{
				dp[i][j][k]=inf;
			}
		}
	}
}

signed main()
{
#ifdef Checker
	freopen(FLN".inp", "r", stdin);
	freopen(FLN".out", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	int tt;
//	cin>>tt;
//	for (int i=1; i<=tt; i++)
	{
		input();
		ezclap();
		output();
	}
	return 0;
}



Measured memory_bytes: 110848
A, B, H, M = map(int, input().split())
import math

PI = math.acos(-1)
th = (H / 12 + (M / 60) * (1 / 12)) * 2 * PI
tm = (M / 60) * 2 * PI

xh = A * math.cos(th)
yh = A * math.sin(th)
xm = B * math.cos(tm)
ym = B * math.sin(tm)
dx = xh - xm
dy = yh - ym
ans = (dx * dx + dy * dy) ** (1 / 2)
print(ans)

Measured memory_bytes: 62672
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int M = 2e5 + 10;

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll N,K; cin >> N >> K;
  //入力
  vector<int> v(N);
  rep(i,N) cin >> v[i];
  //ある値xの一周回ってきたときのindex
  vector<int> p(M);
  per(i,N) p[v[i]] = i+N;
  //次に同じ値が来るまでの数
  vector<int> y(N);
  per(i,N){
    y[i] = p[v[i]] - i;
    p[v[i]] = i;
  }

  //n週目る時の最初の位置(周期性がある,max周期はN+1)
  vector<int> freq(N+1,-1);
  int index = 0;
  int i = 0;
  //一週目は0スタート
  freq[index++] = 0;
  while(true){
    i += y[i]+1;
    if(i>=N){
      i%=N;
      if(i==0)break;
      freq[index++] = i;
    }
  }
  if(index == N)++index;
  int s = freq[(K-1)%index];
  vector<int> ans;
  while(true){
    if(s+y[s]>=N)ans.push_back(v[s++]);
    else s += y[s]+1;

    if(s == N)break;
  }
  rep(j,ans.size()) cout << ans[j] SPF;
  cout << endl;
  return 0;
}


Measured memory_bytes: 5620