akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool has_key(T mp, U key) { return mp.find(key) != mp.end(); }
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, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1000000007;



std::map<long long, long long> factorint(long long n)
{
    std::map<long long, long long> res;
    do {
    top:
        for (long long i = 2; i < std::sqrt(n)+1000; ++i) {
            if (n % i == 0) {
                if (res.find(i) == res.end()) res[i] = 0;
                res[i]++;
                n /= i;
                goto top;
            } 
        }
        if (n != 1) res[n] = 1;
        break;
    } while (true);
    
    return res;
}


long long n_divisor(long long n)
{
        if (n <= 1) return 1;
        else {
                auto f = factorint(n);
                long long res = 1;
                for (auto factor : f) {
                        res *= factor.second + 1;
                }
                return res;
        }
}


int main()
{
        
        ll N;
        cin >> N;
        map<ll, ll> allf; 
        ll ans = 1;
        rep(i, 1, N+1) {
                auto f = factorint(i);
                for (auto el : f) {
                        if (! has_key(allf, el.first)) {
                                allf[el.first] = el.second;
                        } else {
                                allf[el.first] += el.second;
                        }
                }
        }
        for (auto el : allf) {
                ans %= mod;
                //cout << el.first << ' ' << el.second << endl;
                ans = (ans * (el.second + 1)) % mod;
        }
        cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>

using namespace std;

typedef long long ll;

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

const ll INF = 1LL << 60;



signed main() {

	ll n, m;
	cin >> n >> m;
	vector<ll>pi(m + 1), ac(n + 1), wa(n + 1);
	vector<string>s(m + 1);
	rep(i, n + 1) {
		ac[i] = 0;
		wa[i] = 0;
	}

	rep(i, m) {
		cin >> pi[i];
		cin >> s[i];
		if (ac[pi[i] - 1] == 0) {
			if (s[i] == "AC")ac[pi[i] - 1]++;
			if (s[i] == "WA")wa[pi[i] - 1]++;
		}
	}
	ll ansac = 0, answa = 0;
	rep(i, n) {
		ansac += ac[i];
		if(ac[i] != 0)answa += wa[i];
	}
	cout << ansac << endl << answa;
}


Measured memory_bytes: 8064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    vector<string> st={"KIH","B","R",""s};
    rep(i,(1<<4)){
        string temp=""s;
        rep(j,4){
            if(i&(1<<j)) temp+="A";
            temp+=st[j];
        }
        if(temp==s){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}


Measured memory_bytes: 3576
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
map<PLL, LL> memo;
LL solve(LL S, LL X) {
	if (S == 0 && X == 0) return 1;
	if (memo.find(MP(S, X)) != memo.end()) return memo[MP(S, X)];
	LL ret = solve(S / 2, X / 2);
	if (S >= 1 && X >= 1) ret = (ret + solve((S - 1) / 2, (X - 1) / 2)) % MOD;
	if (S >= 2) ret = (ret + solve((S - 2) / 2, X / 2)) % MOD;
	return memo[MP(S, X)] = ret;
}
int main() {
	LL N;
	cin >> N;
	cout << solve(N, N) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node{
	int next,to;
}a[11451];
int n,m,x[2005],y[2005],cnt,head[2005],ll,da;
void add(int e,int r){
	a[++cnt].next=head[e];a[cnt].to=r;head[e]=cnt;
}
void dfs(int u,int fa,int deep){
	if(deep>m/2)return ;
	ll++;
	for(int i=head[u];i;i=a[i].next){
		if(a[i].to==fa)continue;
		dfs(a[i].to,u,deep+1);
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<n;i++){
		cin>>x[i]>>y[i];
		add(x[i],y[i]);add(y[i],x[i]);
	}
	if(m%2==0){
		for(int i=1;i<=n;i++){
			ll=0;
			dfs(i,0,0);
			da=max(da,ll);
		}
		cout<<n-da;
		return 0;
	}
	if(m%2==1){
		for(int i=1;i<n;i++){
			ll=0;
			dfs(x[i],y[i],0);
			dfs(y[i],x[i],0);
			da=max(da,ll);
		}
		cout<<n-da;
		return 0;
	}
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 0;
    ll cnt = 1;
    rep(i,n){
        if(a[i] == a[i+1]) cnt++;
        else{
            if(cnt%2 == 1) ans++;
            cnt = 1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for (int i = 0; i < (int)(n); ++i)
#define fore(i,a,b) for (int i = a; i < (int)(b); ++i)
#define forin(i, n) for (auto& i : (n))
#define make_unique(x) (x).erase(unique(all((x))), (x).end())
#define hbar ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<class T> T mgcd(T a, T b) {while(b) {a%=b; swap(a,b);} return a;}

const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  hbar;
  ll a, b;
  cin >> a >> b;
  ll n = mgcd(a,b), ans=1;
  for (ll i = 2; i*i <= n; i++){
    if(n%i==0){
      while(n%i==0) n/=i;
      ++ans;
    }
  }
  if(n>1) ++ans;

  cout << ans << '\n';
  
  return 0;
}


Measured memory_bytes: 256
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

ll cur,x,ans;

int main(){
	cin>>x;
	ll add=1;
	while(cur<x){
		cur+=add;
		add++;
		ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
const int MOD = 1000000007;

int main() {
    int N, D;
    cin >> N >> D;
    int d = 2 * D + 1;
    cout << (N + d - 1) / d << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main(void)
{
  int k=0,i;
  char s[1000],a[10];
  scanf("%s",a);
  for(i=0;i<10;i++) a[i]=tolower(a[i]);
  while (1){
    scanf("%s",s);
    if(strcmp(s,"END_OF_TEXT") ==0) break;
    for(i=0;i<1000;i++) s[i]=tolower(s[i]);
    if(strcmp(s,a) ==0)k++;
  }
  printf("%d\n",k);
  return 0;
}

Measured memory_bytes: 552
"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

!function () {
  function splitNum(line) {
    return (Array.isArray(line) ? line : line.split(/\s+/)).map(function (n) {
      return parseInt(n);
    });
  }

  !function (input) {
    var lines = input.split("\n");

    var _splitNum = splitNum(lines[0]),
        _splitNum2 = _slicedToArray(_splitNum, 2),
        A = _splitNum2[0],
        B = _splitNum2[1];

    if (A <= 5) console.log(0);else if (A <= 12) console.log(B / 2);else console.log(B);
  }(require("fs").readFileSync("/dev/stdin", "utf8"));
}();


Measured memory_bytes: 21064
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    int a = n/100, b = n%100;
    bool YM = false, MY = false;
    if(1 <= b && b <= 12)YM = true;
    if(1 <= a && a <= 12)MY = true;
    if(YM && MY)cout << "AMBIGUOUS";
    else if(YM) cout << "YYMM";
    else if(MY) cout << "MMYY";
    else cout << "NA";
}
    


Measured memory_bytes: 256
// fahadmd16(IIEST Shibpur)
#include<bits/stdc++.h>
using namespace std;

#define ll                                      long long
#define pb                                      push_back
#define pf                                      push_front
#define eb                                      emplace_back
#define mp                                      make_pair
#define ff                                      first
#define ss                                      second
#define db                                      double
#define pll                                     pair<ll, ll>
#define ALL(a)                                  (a).begin(),(a).end()
#define endl                                    "\n"

#define forn(i, n) for (ll i = 0; i < n; i++)
#define forn1(i, n) for (ll i = 1; i < n; i++)
#define ford(i, n) for (ll i = n - 1; i >= 0; i--)
#define ford1(i, n) for (ll i = n - 1; i >= 1; i--)
#define forab(i, a, b) for(ll i = a; i < b; i++)
#define forabd(i, a, b) for(ll i = a; i >= b; i--)
#define eps 1e-10

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)


#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define tracen( x , n ){ cout<<(#x)<<":";for(int i=0;i<n;i++)cout<<(#x)<<"["<<i<<"]:"<< x[i] << "    "; cout<<endl;}
#define tracenm( x , n , m ){ cout<<(#x)<<endl;for(int i=0;i<n;i++){ cout<<"Row #"<<i<<":"; for(int j=0;j<m;j++) cout<<x[i][j]<<"     "; cout << endl;}}
#define trace(v){ cout<<#v<<": ";for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;}
using namespace std;



const ll sz = 8000;
const ll mod = 1e9 + 7;
const db PI = acos(-1);



typedef vector<ll> VL;
typedef vector<pll > VLL;
typedef vector<vector<ll> > VVL;



ll power(ll n, ll k, ll m) {
	ll ans = 1;
	while (k) {
		if (k & 1)ans = (ans * n) % m;
		k /= 2;
		n = (n * n) % m;
	}
	return ans;
}

void solver() {
	ll n; cin >> n;
	set<string> s;
	forn(i, n) {string st; cin >> st; s.insert(st);}
	cout << s.size() << endl;
}


int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	IOS;
	ll T = 1; //cin >> T;
	forn1(i, T + 1) {
		clock_t z = clock();
		solver();
		debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	}
	return 0;
}


Measured memory_bytes: 19408
#include<stdio.h>
int main(void)
{
	int i,n,a,b,m,t;
	char x[100000];
	scanf("%d %d %d",&n,&a,&b);
	scanf("%s",x);
	m=0;
	t=0;
	for(i=0;i<n;i++){
		if(i<=a-1){
			if(x[i]=='a'){
				printf("Yes\n");
				t++;
			}
			else if(x[i]=='b'){
				if(m<b){
					printf("Yes\n");
					m++;
					t++;
				}
				else{
					printf("No\n");
				}
			}
			else if(x[i]=='c'){
				printf("No\n");
			}
		}
		else{
			if(x[i]=='a'){
				if(t<a+b){
					printf("Yes\n");
					t++;
				}
				else{
					printf("No\n");
				}
			}
			if(x[i]=='b'){
				if(t<a+b && m<b){
					printf("Yes\n");
					m++;
					t++;
				}
				else{
					printf("No\n");
				}
			}
			if(x[i]=='c'){
				printf("No\n");
			}
		}
	}
	return 0;
}

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

vector<string> grid;
    int h,w;

bool dfs(int x, int y){
    if(x==h-1 and y==w-1) return true;
    if(x+1<h){ if(grid.at(x+1).at(y)=='#') return dfs(x+1,y); }
    if(y+1<w){ if(grid.at(x).at(y+1)=='#') return dfs(x,y+1); }
    return false;
}


signed main(){
    cin>>h>>w;
    int cnt=0;
    rep(i,h){
        grid.push_back("");
        cin>>grid.at(i);
        rep(j,w){
            if(grid.at(i).at(j)=='#') cnt++;
        }
    }
    cout<<((dfs(0,0) and cnt==h+w-1)?"Possible":"Impossible")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int M, N, P[20000], C[500], E[500];
int dp[500][20000];

int dfs(int n, int m){
  if(n == N){
    return P[m];
  }
  if(dp[n][m] >= 0) return dp[n][m];
  return dp[n][m] = max(dfs(n+1, m), dfs(n+1, (m+C[n])>M?M:(m+C[n]))-E[n]);
}

int main(){
  scanf("%d%d", &M, &N);
  memset(dp, -1, sizeof(dp));

  rep(i, M) scanf("%d", P+i+1);
  sort(P+1, P+M+1, greater<int>());
  rep(i, 19999) P[i+1] += P[i];

  rep(i, N) scanf("%d%d", C+i, E+i);

  printf("%d\n", dfs(0, 0));
  return 0;
}

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

int main(){
    int n,d,x;
    cin >> n >> d>> x;
    int a;
    for(int i=0;i<n;i++){
        cin >> a;
        x += d/a + (int)(d%a>0);
    }
    cout << x << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	private void doit() {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String s = sc.next();
			ArrayList<Integer> list = new ArrayList<Integer>();
			ArrayList<Integer> list2 = new ArrayList<Integer>();
			for(int i = 0; i < s.length(); i++){
				list.add(s.charAt(i) - '0');
			}
			while(list.size() > 1){
				for(int i = 0; i <= list.size() - 2; i++){
					int num1 = list.get(i);
					int num2 = list.get(i + 1);
					int res = (num1 + num2) % 10;
					list2.add(res);
				}
				list.clear();
				for(int i = 0; i < list2.size(); i++){
					list.add(list2.get(i));
				}
				list2.clear();
				
			}
			System.out.println(list.get(0));
		}
		
	}

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

Measured memory_bytes: 12000
#include <iostream>
#include <stdio.h>

int main()
{
	int H, W;
	while (std::cin >> H >> W, H || W)
	{
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				std::cout << "#";
			}
			std::cout << '\n';
		}
		std::cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 3072
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  int a, b, k;
  set<int> ret;
  scanf("%d%d%d", &a, &b, &k);
  for(int i = 0; i < k; i++) {
    ret.insert(a+i);
    ret.insert(b-i);
  }
  for(auto x: ret) {
    if(a <= x && x <= b)
      printf("%d\n", x);
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int i, j;
	
	for(i = 1; i <= 9; i++){
		
		for(j = 1; j <= 9; j++){
			
			printf("%dx%d=%d\n", i, j, i*j);
			
		}
		
	}
	
    return 0;
}

Measured memory_bytes: 524
from math import sqrt
N = int(input())
dp = [[0] for i in range(N+1)]
dp[5] = [11,31,41,61,71]
def is_prime(x):
    if x == 1:
        return False
    if x % 2 == 0:
        if x == 2:
            return True
        else:
            return False
    for i in range(3,int(sqrt(x))+1,2):
        if x % i == 0:
            return False
    return True

for i in range(5,N):
    tmp = dp[i][-1]+10

    for j in range(tmp,55556,10):

        if is_prime(j):
            dp[i+1] = dp[i]+[j]
            break
        
print(*dp[N])

Measured memory_bytes: 3064
N = int(input())
H = [int(h) for h in input().split()]

dp = [0]*(N+1)
dp[1] = abs(H[0]-H[1])

for n in range(2,N):
    dp[n] = min(dp[n-2] + abs(H[n] - H[n-2]), dp[n-1] + abs(H[n-1] - H[n]))

print(dp[N-1])

Measured memory_bytes: 52208
# -*- coding: utf-8 -*-

import sys
import os
import math

def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

def lcm(a, b):
    return (a * b) // gcd(a, b)

def interval(a, m):
    cnt = 0
    x = 1
    while True:
        x = (a * x) % m
        cnt += 1
        if x == 1:
            return cnt

for s in sys.stdin:
    a1, m1, a2, m2, a3, m3 = map(int, s.split())
    if sum([a1, m1, a2, m2, a3, m3]) == 0:
        break

    x_num = interval(a1, m1)
    y_num = interval(a2, m2)
    z_num = interval(a3, m3)

    a = lcm(x_num, y_num)
    b = lcm(a, z_num)
    print(b)

Measured memory_bytes: 7720
//winnable
#include<bits/stdc++.h>
using namespace std;
bool solve()
{
	string s;
	cin>>s;
	int n = s.size();
	int len = (n-1)/2;
	string s2 = s;
	reverse(s2.begin(),s2.end());
	if(s2!=s)
		return false;
	string s1 = s.substr(0,len);
	string s3 = s2.substr(0,len);
	string s4 = s1;
	reverse(s4.begin(),s4.end());
	if(s4!=s1)
		return false;
	s4 = s3;
	reverse(s4.begin(),s4.end());
	if(s4!=s3)
		return false;
	return true;
}
int main()
{
	int t = 1;
	//cin>>t;
	while(t--)
	{
		if(solve())
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}


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

class graph{
    int nodes;
    list<int> *adj;
    map<int, int> m;
public:
    graph(int n){
        this->nodes = n;
        this->adj = new list<int>[n+1];
        for(int i=1;i<n;i++){
            m[i] = 0;
        }
        for(int i=1;i<n;i++)
            this->addEdge(i,i+1);
    }
    void addEdge(int u, int v){
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    void bfs(int start){
        int d[nodes+1];
        bool used[nodes+1];
        for(int i=0;i<=nodes;i++){
            d[i] = 0;
            used[i] = false;
        }
        queue<int> q;
        q.push(start);
        used[start] = true;
        while(!q.empty()){
            int v = q.front();
            for( int u : adj[v]){
                if(!used[u]){
                    used[u]=true;
                    q.push(u);
                    d[u] = d[v]+1;
                }
            }
            q.pop();
        }
        for(int i=1;i<=nodes;i++){
            if(i!=start)
                m[d[i]]++;
        }
    }
    void display(){
        for(map<int, int>::iterator it = m.begin();it!=m.end();it++){
            cout<<it->second/2<<"\n";
        }
    }
};

int main(){
    int n,x,y;
    cin>>n>>x>>y;
    graph g(n);
    g.addEdge(x,y);
    for(int i=1;i<=n;i++){
        g.bfs(i);
    }
    g.display();
    return 0;
}

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

int main()
{
  int a,b;
  cin >>a>>b;
  char arr[a][b];
  int i,j;
  for(i=0;i<a;i++)
    for(j=0;j<b;j++)
      cin >>arr[i][j];
  int dp[a+1][b+1];
  for(i=0;i<=b;i++)
    dp[0][i]=0;
  for(i=0;i<=a;i++)
    dp[i][0]=0;
  int flag=0;
  for(i=1;i<=b;i++)
  {
    if(flag==1)
      dp[1][i]=0;
    else
    {
      if(arr[0][i-1]=='#')
      {
         dp[1][i]=0;
        flag=1;
        continue;
      }
      else
      {
        dp[1][i]=1;
      }
    }
  }
  for(i=2;i<=a;i++)
  {
    for(j=1;j<=b;j++)
    {
      if(arr[i-1][j-1]=='#')
      dp[i][j]=0;
      else
      {
        dp[i][j]=(dp[i][j-1]+dp[i-1][j])%1000000007;
      }
    }
    
  }
  cout <<dp[a][b]<<endl;
  
}

Measured memory_bytes: 5120
# AtCoder 市には 3 つの駅があり、1,2,3 の番号がつけられています。
# これらの駅は、それぞれ鉄道会社A, Bのいずれかが管理しています。
# 管理状況は長さ 3 の文字列 S で表され、
# 駅 i は Si が A のとき鉄道会社 A が、
# B のとき鉄道会社 B が管理しています。
# 鉄道会社 A が管理している駅と、鉄道会社 B が管理している駅の間には、
# 交通の便のためにバスを運行することになりました。
# 実際にバスが運行することになる駅の組み合わせが存在するかどうかを判定してください。

s = gets

if s.include?("A") && s.include?("B")
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cstdlib>

#define FASTIO ios::sync_with_stdio(NULL); cin.tie(NULL);
#define show(x) cerr << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define vss vector  <string>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define PI  3.141592654
#define OO (ll)1e18
using namespace std;
void ONLINE__JUDGE();

pii swapii( pii pr ){ return { pr.S , pr.F }; }
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 200 + 9;

ll x , k , cnt; vpi vec; vii v;

int main()
{
    FASTIO //ONLINE__JUDGE();

    cin >> x >> k;

    vec.pb({1 , 2});
    for ( int i = 3; i <= x; ++i ) vec.pb( {2 , i} ) , v.pb(i);

    ll sz = SZ(v); cnt = (sz*(sz-1))/2 + sz;
    if ( k > cnt ) cout << -1;
    else
    {
        cnt = cnt-k;
        for ( int i = 0; i < sz; ++i )
            for ( int j = i+1; j < sz; ++j )
            {
                if ( cnt == 0 ) break;
                else
                {
                    vec.pb( {v[i] , v[j]} ); cnt--;
                }
            }

        for ( ll i : v )
        {
            if ( cnt == 0 ) break;
            vec.pb( {1 , i} ); cnt--;
        }

        cout << SZ(vec) << "\n";
        for ( auto i : vec ) cout << i.F << " " << i.S << "\n";
    }
    return 0;
}


Measured memory_bytes: 512
use proconio::input;
#[allow(unused_mut)]
fn main() {
    input! {
        a: usize,
        b: usize
    }
    let (a, b) = if a > b { (b, a) } else { (a, b) };
    (0..b).for_each(|_| print!("{}", a));
    println!();
}


Measured memory_bytes: 2064
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int m;
    cin >> m;
    cout << 48 - m << endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
 
typedef long long ll;
 
using namespace std; 
 
#define REP(inc, bgn, end) for (int inc = bgn; inc < end; inc++)

int main() {
    string s;
    cin >> s;
    string zero = "", one = "";
    int n = s.size();
    if (n == 1) {
        cout << 0 << endl;
        exit(0);
    }
    else {
        REP(i, 0, n/2) {
            zero += "01";
            one += "10";
        }
        if (n % 2 == 1) {
            zero += "0";
            one += "1";
        }
    }

    int zero_cnt = 0, one_cnt = 0;
    REP(i, 0, n) {
        if (s[i] != zero[i]) zero_cnt++;
        if (s[i] != one[i]) one_cnt++;
    }

    cout << min(zero_cnt, one_cnt) << endl;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

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

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

void solve()
{
  int n; cin >> n;
  vector<ll> t(n); REP(i, n) cin >> t[i];
  ll ans = t[0];
  for (int i=1; i<n; i++) {
    ans = lcm(ans, t[i]);
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 256
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}



int n,a[101010];



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        if(a[i]>a[i-1])a[i]--;
        if(a[i]<a[i-1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;





return 0;
}
///....




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
 
int main() {
  int n; cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i) >> b.at(i) >> c.at(i);
  }
  int dp[n+10][3]={};
  dp[0][0]=a[0];
  dp[0][1]=b[0];
  dp[0][2]=c[0];
  for(int i=1;i<n;i++){
    for(int j=0;j<3;j++){
      if(j==0){
        dp[i][j]=max((dp[i-1][1]+a[i]),(dp[i-1][2]+a[i]));
      }
      if(j==1){
        dp[i][j]=max((dp[i-1][0]+b[i]),(dp[i-1][2]+b[i]));
      }
      if(j==2){
        dp[i][j]=max((dp[i-1][0]+c[i]),(dp[i-1][1]+c[i]));
      }
    }
  }
  cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
}

Measured memory_bytes: 2560
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }

    val big = Math.max(a, b)
    val small = Math.min(a, b)

    if((big+small)%2 == 1) {
        println("IMPOSSIBLE")
        return
    }

    println((big+small)/2)
}

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

int main()
{
  int N, M;
  cin >> N >> M;

  multimap<int,int> m;
  int a, b;
  for(int i = 0; i < M; ++i){
    cin >> a >> b;
    m.insert(make_pair(b, a));
  }

  int x = 0;
  int ans = 0;
  for(const auto& e : m){
    if(x <= e.second){
      x = e.first;
      ++ans;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 4992
n = int(input())
x,y = map(int,input().split())
max_xpy = x+y
min_xpy = x+y
max_xmy = x-y
min_xmy = x-y
for i in range(n-1):
  x,y = map(int,input().split())
  max_xpy = max(max_xpy,x+y)
  min_xpy = min(min_xpy,x+y)
  max_xmy = max(max_xmy,x-y)
  min_xmy = min(min_xmy,x-y)
print(max(max_xpy-min_xpy,max_xmy-min_xmy))

Measured memory_bytes: 72868
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#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*/
        

fast();
//ll t;cin>>t;while(t--)
{
    map<ll,ll>a,b,c;
    
    a[2]=1;a[4]=1;a[5]=1;a[7]=1;a[9]=1;
   b[0]=1;b[1]=1;b[6]=1;b[8]=1;
   c[3]=1;
   ll n;
   cin>>n;
   ll d=n%10;
   if(a[d])
   {
     cout<<"hon"<<endl;
   }
   else if(b[d])
   {
       cout<<"pon"<<endl;
   }
   else
   {
     cout<<"bon"<<endl;
   }

}
return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main (){
    
    long long N,x,odd=0,even=0;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> x;
        
        if(x % 2 == 1){
            odd += 1;
        }
        else{
            even += 1;
        }  
    }
    
    if(odd % 2 == 0){
        cout << "YES" << endl;
    }
    else if(even % 2 ==0 && odd % 4 == 0){
        cout << "YES" << endl;
    }
    else if (even % 2 ==1 && odd % 4 ==2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 256
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// solution 
use std::cmp;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        X: usize,
        Y: usize,
    }

    let mut rest = Y / X;
    let mut count = 0;

    while rest >> count > 0 {
        count += 1;
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef int64_t Int;
#define dump(x) cout << (x) << '\n'
Int mod = 1e9+7;
//Int mod = 998244353; 
Int INF = 1e9+7;

int main() {    
    Int n;
    cin >> n;
    Int res = 0;
    for (Int i = 1; (n - i) / i > i; i++) {
        if ((n - i) % i == 0) {
            res += (n - i) / i;
            //res %= mod;
        }
    }
    dump(res);
    return 0;  
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b; cin >> a >> b;
  if (a + b == 15) cout << "+\n";
  else if (a * b == 15) cout << "*\n";
  else cout << "x\n";
  return 0;
}


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

const int MX = 100005;
const ll INF = 1000000000LL * 1000000000LL;

int n;

vector<pair<int, int>> neigh[4 * MX];

struct {
	int L, R;
	int pl, pr;
} T[4 * MX];
int nxt;
int buildTree1(int L, int R) {
	if (L == R) return L;
	int cur = nxt++;
	T[cur].L = L;
	T[cur].R = R;
	if (L < R) {
		T[cur].pl = buildTree1(L, (L + R) / 2);
		T[cur].pr = buildTree1((L + R) / 2 + 1, R);
		neigh[cur].emplace_back(T[cur].pl, 0);
		neigh[cur].emplace_back(T[cur].pr, 0);
	}
	return cur;	
}
int buildTree2(int L, int R) {
	if (L == R) return L;
	int cur = nxt++;
	T[cur].L = L;
	T[cur].R = R;
	if (L < R) {
		T[cur].pl = buildTree2(L, (L + R) / 2);
		T[cur].pr = buildTree2((L + R) / 2 + 1, R);
		neigh[T[cur].pl].emplace_back(cur, 0);
		neigh[T[cur].pr].emplace_back(cur, 0);
	}
	return cur;	
}
void add1(int L, int R, int to, int c, int cur) {
	if (L <= T[cur].L && R >= T[cur].R) {
		neigh[to].emplace_back(cur, 0);
		return;
	}
	if (L <= T[ T[cur].pl ].R) {
		add1(L, R, to, c, T[cur].pl);
	}
	if (T[ T[cur].pr ].L <= R) {
		add1(L, R, to, c, T[cur].pr);
	}
}
void add2(int L, int R, int to, int c, int cur) {
	if (L <= T[cur].L && R >= T[cur].R) {
		neigh[cur].emplace_back(to, c);
		return;
	}
	if (L <= T[ T[cur].pl ].R) {
		add2(L, R, to, c, T[cur].pl);
	}
	if (T[ T[cur].pr ].L <= R) {
		add2(L, R, to, c, T[cur].pr);
	}
}

ll d[4 * MX];

int main()
{
	int m;
	ignore = scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++) T[i].L = T[i].R = i;
	nxt = n + 1;
	int rt1 = buildTree1(1, n);
	int rt2 = buildTree2(1, n);
	while (m--) {
		int l, r, c;
		ignore = scanf("%d %d %d", &l, &r, &c);
		add1(l, r, nxt, c, rt1);
		add2(l, r, nxt, c, rt2);
		nxt++;
	}
	
	/*
	for (int v = 1; v < nxt; v++) {
		printf("%d: ", v);
		for (auto e : neigh[v]) {
			printf("(%d %d) ", e.first, e.second);
		}
		printf("\n");
	}
	*/
	
	set<pair<ll, int>> S;
	for (int i = 1; i < 4 * MX; i++) d[i] = INF;
	
	d[1] = 0;
	S.insert({0, 1});
	
	while (!S.empty()) {
		auto cur = *S.begin();
		S.erase(S.begin());
		int v = cur.second;
		if (cur.first != d[v]) continue;
		
		for (auto e : neigh[v]) {
			if (d[e.first] > d[v] + e.second) {
				d[e.first] = d[v] + e.second;
				S.insert({d[e.first], e.first});
			}
		}
	}
	
	if (d[n] == INF) {
		printf("-1\n");
		return 0;
	}
	cout << d[n] << "\n";
}


Measured memory_bytes: 65264
#include <string.h>

#include <algorithm>
#include <cstdlib>  // abs() for integer
#include <iostream>

using namespace std;

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

  string S[N];
  for (int i = 0; i <= N - 1; i++) {
    cin >> S[i];
  }

  int cnt[4] = {0, 0, 0, 0};
  for (int i = 0; i <= N - 1; i++) {
    if (S[i] == "AC") {
      cnt[0]++;
    } else if (S[i] == "WA") {
      cnt[1]++;
    } else if (S[i] == "TLE") {
      cnt[2]++;
    } else {
      cnt[3]++;
    }
  }

  cout << "AC x " << cnt[0] << endl;
  cout << "WA x " << cnt[1] << endl;
  cout << "TLE x " << cnt[2] << endl;
  cout << "RE x " << cnt[3] << endl;

  return 0;
}

Measured memory_bytes: 6752
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
ll power(ll x,ll y,ll p){
ll res = 1;x = x % p;
while (y > 0){
if (y & 1){res = (res*x) % p;}
y = y>>1;
x = (x*x) % p;}
return res;}
ll mcd(ll a,ll b){
    if(b>a)swap(a,b);
    if(b==0)return a;
    else return mcd(b,a%b);
}
ll t,n,m,k;
bool esprimo(ll n){
ll s=0;
for(ll i=1;i*i<=n;i++){
    if(n%i==0){s++;}}
if(s>=2){return false;}
return true;
}
int main(){
    //    cout<<fixed<<setprecision(2);
//cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
cin>>n>>m>>k;
char a[n][m];
for(int j=0;j<n;j++){
    for(int z=0;z<m;z++){
        cin>>a[j][z];
    }
}

ll mas=1<<(n+m);
//cout<<mas<<endl;
ll c=0;
for(ll i=0;i<mas;i++){
    ll x,y,s=0;
    for(int j=0;j<n;j++){
        x=1<<j;
        if((x&i)!=0){continue;}
        for(int z=0;z<m;z++){
            y=1<<(z+n);
            if((y&i)!=0){continue;}
            if(a[j][z]=='#'){s++;}
            //cout<<i<<" "<<j<<" "<<z<<endl;}
        }
    }
   // cout<<s<<endl;
    if(s==k){c++;}
}
cout<<c;
}



Measured memory_bytes: 3540
#pragma GCC optimize("O3")
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000
vector<int>a;
int n;

int solve(int k) {
	int x = 1;
	int y = 0;
	int z = 0;
	if ((x + k) <= a[0])return -1;
	while (true) {
		if ((x + k) > a[n - 1])return (y + 1);
		while ((x + k) > a[z + 1]) {
			if (abs(a[z] - x) > abs(a[z + 1] - x))z++;
			else break;
		}
		y++;
		x += max(1, k - abs(a[z] - x));
	}
	return 0;
}




int main() {
	int x, l, r, mid;
	int m;
	while (true) {
		scanf("%d %d", &n, &m);
		if ((n == 0) && (m == 0))break;
		a.clear();
		f(i, n) {
			scanf("%d", &x);
			a.push_back(x);
		}
		l = 1;
		r = 100000000;
		while ((l + 1) < r) {
			mid = (l + r) / 2;
			x = solve(mid);
			if (x == -1)l = mid;
			else if (x < m)r = mid;
			else l = mid;
		}
		x = solve(l);
		if (x >= m)printf("%d\n", l);
		else printf("-1\n");
	}

	return 0;
}


Measured memory_bytes: 3156
m, k = gets.split.map(&:to_i)

if k >= 2 ** m
  puts -1
else
  if m == 0
    puts "0 0"
  elsif m == 1
    if k == 0
      puts "0 0 1 1"
    else
      puts -1
    end
  else
    0.upto(2**m - 1) do |i|
      next if i == k
      print "#{i} "
    end
    print "#{k} "
    (2**m - 1).downto(0) do |i|
      next if i == k
      print "#{i} "
    end
    puts k
  end
end


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll h,w;
    cin >> h >> w;
    vs s(h);
    rep(i,h)cin >> s[i];
    rep(i,w+2)cout << '#';
    cout << endl;
    rep(i,h)cout << '#' << s[i] << '#'<< endl;
    rep(i,w+2)cout << '#';
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    N, M = list(map(int, input().split()))
    
    if M == 0:
        if N == 1:
            return [0]
        else:
            return [1] + [0] * (N - 1)
        
    arr = [-1] * N
    
    for _ in range(M):
        i,j = list(map(int, input().split()))
        i -= 1
        if arr[i] >= 0 and arr[i] != j:
            return [-1]
        if N == 1 and i == 0 and j == 0:
            return [0]
        if i == 0 and j == 0:
            return [-1]
        arr[i] = j
    
    for i in range(N):
        if i == 0 and arr[i] == -1:
            arr[i] = 1
            continue
        if arr[i] == -1:
            arr[i] = 0
    
    return arr

print(*main(), sep="")

Measured memory_bytes: 3064
// https://atcoder.jp/contests/arc091/tasks/arc091_a

#include "algorithm"
#include "cmath"
#include "functional"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, M;
  cin >> N >> M;

  if (N == 1 && M == 1) drop(1);

  if (N == 1 || M == 1) drop(max(N, M) - 2);

  ll res = (N - 2) * (M - 2);
  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
map<int,int> dp,depth;
map<int,int> ::iterator it;

main()
{
    int h,ans = 0;
    cin>>h;
    int x=  h;
    int i  =0;
    while(h){
        depth[h] = i++;
        h/=2;
    }

    for(it = depth.begin(); it!= depth.end(); it++){
        ans+=(1LL << (it->second));
    }
    cout<<ans<<endl;




    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <deque> 
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cingroup(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfgroup(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
typedef unsigned long long ull;
using namespace std;
int dist[100005];

int main()
{
//	freopen("input.txt","r",stdin);
	int n;
	cin>>n;
	deque <int> dq;
	memset(dist,0x3f,sizeof(dist));
	dq.push_back(1);
	dist[1]=1;
	while(dq.size())
	{
		int now=dq.front();
		dq.pop_front();
		if(dist[(now*10)%n]>dist[now])
		{
			dist[(now*10)%n]=dist[now];
			dq.push_front((now*10)%n);
		}
		if(dist[(now+1)%n]>dist[now]+1)
		{
			dist[(now+1)%n]=dist[now]+1;
			dq.push_back((now+1)%n);
		}
	}
	cout<<dist[0]<<endl;
	return 0;
}

Measured memory_bytes: 896