akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
 
int main(){

    int n, count = 0;
    string s;

    cin >> n >> s;

    if (n % 2 != 0)
    {
        cout << "No";
    }
    else{
        for (int i = 0; i < n/2; i++)
        {
            if (s[i] == s[n/2+i])
            {
                count++;
            }
        }
        if (count == n/2)
        {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
    }
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	ll ans1 = 0, sum1 = 0;
	rep(i,n){
		sum1 += a[i];
		if(i%2 == 1){
			if(sum1 >= 0){
				ans1 += 1 + sum1;
				sum1 = -1;
			}
		}
		else{
			if(sum1 <= 0){
				ans1 += 1 - sum1;
				sum1 = 1;
			}
		}
	}
	ll ans2 = 0, sum2 = 0;
	rep(i,n){
		sum2 += a[i];
		if(i%2 == 1){
			if(sum2 <= 0){
				ans2 += 1 - sum2;
				sum2 = 1;
			}
		}
		else{
			if(sum2 >= 0){
				ans2 += 1 + sum2;
				sum2 = -1;
			}
		}
	}
	ll ans = min(ans1, ans2);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3976
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

char s[99];;
int main(){
	scanf("%s",s);
	ll a=(s[0]-48)*10+(s[1]-48);
	ll b=(s[2]-48)*10+(s[3]-48);
	if(1<=a&&a<=12){
		puts(1<=b&&b<=12?"AMBIGUOUS":"MMYY");
	}else{
		puts(1<=b&&b<=12?"YYMM":"NA");
	}
}

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

bool isPrime(int n) {
  for (int p = 3; p * p <= n; p += 2) {
    if (n % p == 0)
      return false;
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  int c = 11;
  cout << c;
  for (int i = 1; i < n; ++i) {
    c += 10;
    while (!isPrime(c))
      c += 10;
    cout << " " << c;
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << 6 - (a + b) << endl;
    return 0;
}


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

int main() {
 int N;
 long long Ans;
 cin >> N;
 vector <long long> vec(N);
 Ans =1;
 for (int i=0; i<N; i++){
   cin >> vec.at(i);
     if( vec.at(i) == 0 ){
     Ans = 0;
     }
   }
 if (Ans == 0){
   cout << 0 << endl;
 }
 else {
   sort(vec.begin(), vec.end());
   for (int i=0; i<N; i++){
     if (vec.at(i)>1000000000000000000/Ans){
     Ans = -1;
     break;
     }
     Ans *= vec.at(i);
   }
   cout << Ans << endl;
 }
}

Measured memory_bytes: 4032
#include <cstdio>
#include <cmath>
#include <cstring>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

#define NMAX 1000
typedef pair<double, pair<int, int> > P;
int n;
int b[NMAX], x[NMAX], y[NMAX], prev[NMAX], r[NMAX];
bool u[NMAX];
double c[NMAX], d[NMAX][NMAX];

int solve(int s, int g) {
  P p;
  int num, t;
  priority_queue<P> q;
  bool solved = false;

  memset(u, 0, n);
  memset(c, 0, sizeof(double)*n);
  q.push(make_pair(0.0, make_pair(s, -1)));
  while (!q.empty()) {
    p = q.top();
    q.pop();
    t = p.second.first;
    if (u[t]) continue;
    u[t] = true;
    prev[p.second.first] = p.second.second;
    if (t == g) {
      solved = true;
      break;
    }
    for (int i=0; i<n; i++) {
      if (u[i] || d[t][i] > 50.) continue;
      q.push(make_pair(p.first - d[t][i], make_pair(i, t)));
    }
  }

  if (solved) {
    num = 0;
    t = g;
    while (t!=-1) {
      r[num++] = t;
      t = prev[t];
    }
    reverse(r, r+num);
  }
  return solved ? num : -1;
}

int main() {
  int m, s, g, t;
  map<int,int> id;
  while (1) {
    scanf("%d", &n);
    if (!n) break;
    for (int i=0; i<n; i++) {
      scanf("%d %d %d", &b[i], &x[i], &y[i]);
    }
    id.clear();
    for (int i=0; i<n; i++) {
      id.insert(make_pair(b[i], i));
    }
    for (int i=0; i<n; i++) {
      for (int j=i; j<n; j++) {
        d[i][j] = d[j][i] = sqrt((x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i]));
      }
    }
    scanf("%d", &m);
    for (int i=0; i<m; i++) {
      scanf("%d %d", &s, &g);
      t = solve(id[s], id[g]);
      if (t == -1) {
        printf("NA\n");
      } else {
        for (int j=0; j<t; j++) {
          if (j) printf(" ");
          printf("%d", b[r[j]]);
        }
        puts("");
      }
    }
  }
  return 0;
}

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

int main() {
	vector<int> IsPrime(55556, 1), Ans;
	for (int i = 2; i <= 55555; i++) {
		if (!IsPrime[i]) continue;
		else {
			int j = i + i;
			while (j <= 55555) {
				IsPrime[j] = 0;
				j += i;
			}
			if (i % 5 == 1) Ans.push_back(i);
		}
	}

	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cout << Ans[i] << endl;
}

Measured memory_bytes: 512
N = int(input())
CSF = [list(map(int,input().split())) for i in range(N-1)]
Ans = [0 for i in range(N)]

for i in range(N):
  for j in range(i+1,N):
    if i+1 == j:
      Ans[i]=CSF[i][1]
    elif Ans[i]<CSF[j-1][1]:
      Ans[i]=CSF[j-1][1]
    elif Ans[i] % CSF[j-1][2] != 0:
      Ans[i]+=CSF[j-1][2]-(Ans[i] % CSF[j-1][2])
  
    Ans[i]+=CSF[j-1][0]

      
for i in range(N):
  print(Ans[i])

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	long long int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	if(a == 0) cout << 1 << '\n';
	if(b == 0) cout << 2 << '\n';
	if(c == 0) cout << 3 << '\n';
	if(d == 0) cout << 4 << '\n';
	if(e == 0) cout << 5 << '\n';
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x);
    }
    return res;
}
lli solve(){
	lli t;
	string s;
	cin>>t>>s;
	lli n = s.length();
	loop(i, 0, n){
		lli ch = s[i]-'A';
		loop(j, 0, t){
			ch = (ch + 1)%26;
		}
		s[i] = ch + 'A';
	}
	cout<<s;
}
int main(){
	fastio;
	lli t;
//	cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}

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

int main(){

    long long int N;
    cin >> N;

    long long int i,j;
    for (size_t t = 1; t <= sqrt(N); t++)
    {
        if(N%t==0){
            i=t;
            j=N/t;
        }
            
    }
    
    cout << i-1+j-1 << endl; 

    return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(s) (s).begin(), (s).end()
const ll MOD = 1e9 + 7;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    long long n, k;
    cin >> n >> k;
    n %= k;
    cout << min(abs(n), abs(k - n));
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
const int ms = 1e4+9;
vector<int> g[ms];
typedef pair<int,int> ii;
vector<ii> va;
vector<ii> vb;
vector<int> match, vis;

int aug(int l){
	//cout<<l<<" "<<vis[l]<<endl;
	if(vis[l]) return 0;
	vis[l] =1;
	for(auto &it : g[l]){
		if(match[it] == -1 || aug(match[it])){
			//cout<<"oi";
			match[it] = l;
			return 1;
		}
	}
	return 0;
}

int main(){
	int n,a,b;
	cin >> n;
	
	for(int i= 0;i<n;i++){
		cin >> a >> b;
		va.push_back({a,b});
	}
	
	for(int i = 0;i<n;i++){
		cin >> a >> b;
		vb.push_back({a,b});
	}
	int sz = 0;
	for(int i =0;i<n;i++){
		for(int j = 0;j<n;j++){
			if(va[i].first < vb[j].first and va[i].second < vb[j].second){
				g[i].push_back(j+1000);
				//g[j+1000].push_back(i);
				sz++;
			}
		}
	}
	
	int sol =0;
	n = 2000;
	match.assign(n,-1);
	for(int i =0;i<2000;i++){
		vis.assign(n,0);
		sol += aug(i);
	}
	
	cout<<sol;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (a+b > c+d){
    cout << "Left" << endl;
  }
  else if (a+b < c+d){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<string> s(n);
	rep(i, n)cin >> s[i];
	sort(s.begin(), s.end());
	int sum = 1;
	rep(i, n - 1) {
		if (s[i] != s[i + 1])++sum;
	}
	cout << sum;
}

Measured memory_bytes: 9540
#include <iostream>

using namespace std;

string s;
char ch;

inline bool check(int a, int b, int c)
{
    if (s[a] == s[b] & s[a] == s[c] & s[a] != 's') {
        ch = s[a];
        return true;
    }
    else
        return false;
}

int main()
{
    while (cin >> s) {
        ch = 'd';

        if (check(0, 1, 2) | check(3, 4, 5) | check(6, 7, 8)
            | check(0, 3, 6) | check(1, 4, 7) | check(2, 5, 8)
            | check(0, 4, 8) | check(2, 4, 6))
            cout << ch << endl;
        else
            cout << ch << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef string st;
typedef vector<ll> vl;
typedef vector<vl> mt;
typedef vector<string> vs;

st s;
vs ans;

void dfs(ll used, ll d){
  if(d == s.size()){
    ans.push_back(s);
    return;
  }
  if((used&(1 << s[d]-'a')) == 0){
    if(s[d] < 'z'){
      s[d]++;
      if((used&(1 << s[d]-'a')) == 0) dfs(used|(1 << (s[d]-'a')),d+1);
      s[d]--;
    }else{

    }
  }else{
    dfs(used,d+1);
    if(s[d] < 'z'){
      s[d]++;
      if((used&(1 << s[d]-'a')) == 0) dfs(used|(1 << (s[d]-'a')),d+1);
      s[d]--;
    }else{

    }
  }
}

int main(){
  while(cin >> s){
    if(s == "#") return 0;
    ans = vs();
    dfs(1,0);
    cout << ans.size() << endl;
    sort(ans.begin(),ans.end());
    if(ans.size() <= 10){
      for(st out : ans) cout << out << endl;
    }else{
      for(ll i = 0;i < 5;i++) cout << ans[i] << endl;
      for(ll i = ans.size()-5;i < ans.size();i++) cout << ans[i] << endl;
    }
  }
}



Measured memory_bytes: 4236
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int f(int x) {
    int res = 0;
    while(x%2==0) {
        res++;
        x /= 2;
    }
    return res;
}

int main() {
    int n;ll m;
    cin >> n >> m;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    rep(i,n) a[i] /= 2;
    int t = f(a[0]);
    rep(i,n) {
        if(t != f(a[i])) {
            cout << 0 << endl;
            return 0;
        }
        a[i] >>= t;
    }
    m >>= t;
    ll l = 1;
    rep(i,n) {
        l = lcm(l,a[i]);
        if(l>m) {
            cout << 0 << endl;
            return 0;
        }
    }
    m /= l;
    int ans = (m+1)/2;
    cout << ans << endl;
}

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

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

int H, W, K;
vector<string> g0;

ll solve(){
	int res = 0;
	for(int s=0; s<(1<<(H+W)); s++){
		set<int> rs, cs;
		for(int i=0; i<H; i++){
			if(s & (1<<i)) rs.insert(i);
		}
		for(int j=H; j<H+W; j++){
			if(s & (1<<j)) cs.insert(j - H);
		}

		int nb = 0;
		for(int i=0; i<H; i++){
			if(rs.find(i) != rs.end()) continue;
			for(int j=0; j<W; j++){
				if(cs.find(j) != cs.end()) continue;
				nb += g0[i][j] == '#';
			}
		}

		res += nb == K;
	}
	return res;
}

int main(){
	cin>>H>>W>>K;
	g0 = vector<string>(H);
	for(int i=0; i<H; i++){
		cin>>g0[i];
	}
	cout<<solve()<<endl;
    return 0;
}






Measured memory_bytes: 3596
n = int(input())
x = list(map(int, input().split()))
x.sort()

ans = 0

for i in range(x[0]+1, x[-1]+1):
    sum = 0
    for item in x:
        sum += pow(item-i, 2)

    if sum < ans or ans == 0:
        ans = sum

print(ans)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int L[100001],N;

int main(void)
{
	cin >> N;
	for(int i = 0;i < N;i++)
	{
		cin >> L[i];
	}
	int len = 0,t,s,l;
	t = 1;
	s = 0;
	while(L[t] != L[t+1] && t < N-1)
	t++;
	while(s > 0 && L[s] != L[s-1])
	s--;
	len = max(len,(t - s)+1);
	for(int i = 0;i < N-1;i++)
	{
		if(L[i] == L[i+1])
		{
			t = i+1;
			s = i;
			while(L[t] != L[t+1] && t < N-1)
				t++;
			while(s > 0 && L[s] != L[s-1])
				s--;
			if(t != N-1)
				l = t+1;
			else
				l = t;
			while(L[l] != L[l+1] && l < N-1)
				l++;
			//i = t-1;
			len = max(len,(l - s)+1);
		}
	}
	cout << len << endl;
}

Measured memory_bytes: 3476
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc155_b solver = new abc155_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc155_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            boolean ret = true;
            for (int i = 0; i < N; i++) {
                int a = in.nextInt();
                if ((a % 2) == 0) {
                    if ((a % 3) == 0 || (a % 5) == 0) {
                        ret = true;
                    } else {
                        ret = false;
                        break;
                    }
                }
            }
            if (ret) {
                out.println("APPROVED");
            } else {
                out.println("DENIED");
            }
        }

    }
}



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

vector<int> par(100000);
vector<int> ranks(100000);
vector<int> sizes(100000);

void init(int n)
{
  int i;
  for(i=0;i<n;i++)
  {
    par[i]=i;
    ranks[i]=0;
    sizes[i]=1;
  }
}

int find(int x)
{
  if(par[x]==x)
  {
    return x;
  }
  else
  {
    return par[x] = find(par[x]);
  } 
}

void unite(int x, int y)
{
  x = find(x);
  y = find(y);
  if(x==y)return;
  if(ranks[x]<ranks[y])
  {
    par[x] = y;
    sizes.at(y)+=sizes.at(x);
  }
  else
  {
    par[y] = x;
    sizes.at(x)+=sizes.at(y);
    if(ranks[x]==ranks[y])ranks[x]++;
  }
}

int sizing(int x)
{
  return sizes.at(find(x));
}

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

int main()
{
  int n,m,k;cin>>n>>m>>k;
  init(n);
  vector<int> a(m);
  vector<int> b(m);
  int i,j;
  for(i=0;i<m;i++)cin>>a.at(i)>>b.at(i);
  vector<int> c(k);
  vector<int> d(k);
  for(i=0;i<k;i++)cin>>c.at(i)>>d.at(i);
  for(i=0;i<m;i++)
  {
    unite(a.at(i)-1,b.at(i)-1);
  }
  vector<vector<int>> friends(n,vector<int>(0));
  vector<vector<int>> block(n,vector<int>(0));
  for(i=0;i<m;i++)
  {
    friends.at(a.at(i)-1).emplace_back(b.at(i)-1);
    friends.at(b.at(i)-1).emplace_back(a.at(i)-1);
  }
  for(i=0;i<k;i++)
  {
    block.at(c.at(i)-1).emplace_back(d.at(i)-1);
    block.at(d.at(i)-1).emplace_back(c.at(i)-1);
  }
  for(i=0;i<n;i++)
  {
    int kans=sizing(i)-1;
    for(j=0;j<friends.at(i).size();j++)
    {
      if(same(i,friends.at(i).at(j)))kans--;
    }
    for(j=0;j<block.at(i).size();j++)
    {
      if(same(i,block.at(i).at(j)))kans--;
    }
    cout<<kans;
    if(i!=n-1)cout<<' ';
  }
  cout<<endl;
}


Measured memory_bytes: 14584
n,k = input().split(" ")
l = input().split(" ")
l1 = ['0','1','2','3','4','5','6','7','8','9']
d = sorted(list(set(l1)-set(l)))
i = int(n)
while(True):
    if set(list(str(i))).difference(set(d))==set():
        break
    else:
        i+=1
print(i)

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
import itertools

lunlun = [[] for i in range(11)]

def main():
    n = int(input())
    for i in range(100):
        flag = True
        l = len(str(i))
        if l == 1:
            lunlun[l - 1].append(i)
        else:
            for a in range(1, len(str(i))):
                if abs(int(str(i)[a - 1]) - int(str(i)[a])) >= 2:
                    flag = False
                    break
            if flag:
                lunlun[l - 1].append(i)
            else:
                continue
    for j in range(1, 9):
        for a in lunlun[j]:
            for b in range(10):
                if abs(int(str(a)[-1]) - b) < 2:
                    lunlun[j+1].append(int(str(a)+str(b)))
    lunlun2 = list(itertools.chain.from_iterable(lunlun))
    print(lunlun2[n])

if __name__ == '__main__':
    main()


Measured memory_bytes: 65628
import sys
import numpy as np

#n=int(sys.stdin.readline())
n,k=map(int,sys.stdin.readline().split())
#a=np.array(sys.stdin.readline().split(),dtype='int64')
#a=np.array([sys.stdin.readline().split() for i in range(n)],dtype='int64')

ans=0
mod=10**9+7
for i in range(k,n+2):
   ans+=(i*(n-i+1)+1)%(mod)

print(ans%(mod))


Measured memory_bytes: 27116
N = int(input())
p = {}

for _ in range(N):
    s = input()
    p.setdefault(s, 0)
    p[s] += 1

M = int(input())

for _ in range(M):
    s = input()
    p.setdefault(s, 0)
    p[s] -= 1

ans = max(p.values())

print(ans if ans >= 0 else 0)


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


int main() {
    string s; cin >> s;
    ll k; cin >> k;
    ll ans=1;
    ll n=s.size();
    n= min(n,k);
    rep(i,n){
        if(s.at(i)!='1'){
            cout << s.at(i) << endl;
            return 0;
        }
    }
    cout << '1' << endl;
    return 0;
}

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

int main(int argc, char const *argv[])
{
	int n,x;
	cin>>n>>x;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int ans=0;
	for (int i = 0; i < n-1; ++i)
	{
		x-=a[i];
		++ans;
		if (x<0)
		{
			--ans;
			break;
		}
	}
	if (a[n-1]==x)
	{
		++ans;
	}
	cout<<ans<<endl;
	return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int a, b, c; cin >> a >> b >> c;
        int x, y; cin >> x >> y;
        c = min(2 * c, a + b);
        int ans = min(x, y) * c;
        x -= ans / c, y -= ans / c;
        int cnt = max(x, y) * c, ans1 = x * a + y * b;
        ans += min(cnt, ans1);
        cout << ans;
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, m;
vector<p> edge;
int a[10000];
vector<int> G[100000];

void add_edge(int u, int v)
{
    G[u].push_back(v);
    G[v].push_back(u);
}
/*
bool dfs(int now, bool used[])
{
    used[now] = true;
    for (int i = 0; i < G[node].size; i++)
    {
        if()
    }
    return true;
}
*/
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    bool used[n];
    for (int i = 0; i < n; i++)
    {
        used[i] = false;
    }
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        add_edge(a - 1, b - 1);
    }
    /*
    if (dfs(0, used))
        YES;
    else
        NO;
        */
    for (int i = 0; i < n; i++)
    {
        if (G[i].size() % 2 != 0)
        {
            NO;
            return 0;
        }
    }
    YES;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

string s;

ll dp[20][20];
int n;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    cin >> s;
    ll ans = 0;
    for(int S = 0;S < (1 << n);S++){
        string red = "", blue = "";
        for(int i = 0;i < n;i++){
            if(S & (1 << i)){
                red.push_back(s[i]);
            }else{
                blue.push_back(s[i]);
            }
        }
        for(int i = 0;i <= n;i++){
            for(int j = 0;j <= red.length();j++){
                dp[i][j] = 0;
            }
        }
        dp[0][0] = 1;
        string t = s.substr(n, n);
        reverse(t.begin(), t.end());
        for(int i = 0;i < n;i++){
            for(int j = 0;j <= min((int)red.length(), i);j++){
                if(dp[i][j] == 0)
                    continue;
                int k = i - j;
                if(j < red.length() and t[i] == red[j]){
                    dp[i + 1][j + 1] += dp[i][j];
                }
                if(k < blue.length() and t[i] == blue[k]){
                    dp[i + 1][j] += dp[i][j];
                }
            }
        }
        ans += dp[n][red.length()];
    }
    cout << ans << endl;
    return 0;
}


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

#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))

#整数値龍力　複数の入力(配列で1つずつ渡される)
def input_multiple_number_as_list_sep(N):
    ins = []
    for i in range(N):
        ins.append(input())
    return ins

#2次元配列入力
def input_map():
    return [list(map(int,list(input()))) for i in range(h)]

#リスト出力
def print_list(list):
    print(*list)
    return

#2次元配列出力
def print_map(maplist):
    for i in maplist:print(*i, sep='')
    return

#素数生成
def generate_primenums():
    n = 100
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5+1)):
        primes.difference_update(range(i*2, n+1, i))
    primes=list(primes)
    return primes

def memo():
    a=[0]*5
    b=a  #良くない配列のコピー
    b2=a[:]  #1次元のときはコピーはこれで良い
    a[1]=3
    print('b:{}, b2:{}'.format(b,b2))  #b:[0, 3, 0, 0, 0], b2:[0, 0, 0, 0, 0]
    
    import copy
    a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
    b=copy.deepcopy(a)  #2次元配列はこうコピーする
    
    #内包表記奇数のみ
    odd=[i for i in range(100) if i%2==1] #[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]

    #二部探索
    import bisect
    a = [1, 2, 3, 5, 6, 7, 8, 9]
    b=bisect.bisect_left(a, 8)

    #combinations、組み合わせ、順列
    from itertools import permutations, combinations,combinations_with_replacement,product
    a=['a','b','C']
    print(list(permutations(a)))
    print(list(combinations(a,2)))
    print(list(combinations_with_replacement(a,3)))

    #第3要素で並び替え
    magics.sort(key=lambda x:x[2],reverse=True)


#階乗
def kaijo(n):
    import math
    return math.factorial(n)

#選び方（コンビネーション nCr）
def num_combination(n,r):
    import math
    return math.factorial(n) // math.factorial(n - r)


#最大公約数、最小公倍数
def calc_gcd(a,b):
    import fractions
    GCD=fractions.gcd(a,b)
    lcm=a*b//gcd
    return gcd,lcm

#複数の最大公約数
def calc_gcd_list(l):
    gcd = l[0]
    for i in range(1, N):
        gcd = fractions.gcd(gcd, l[i])
    return gcd

#各桁の和
def sum_digit(n):
    sum = 0
    while n > 0:
        sum += n%10
        n //= 10
    return sum

K,S = input_multiple_number()

cnt = 0
for x in range(K+1):
    for y in range(K+1):
        a = S - (x + y)
        if 0 <= a and a <= K:
            cnt += 1

print(cnt)


Measured memory_bytes: 40684
k=int(input())
que=[i for i in range(1,10)]
# print(que)
for i in range(k):
  now=que.pop(0)
  too=now%10

  if too!=0:
    que.append(now*10+too-1)

  que.append(now*10+too)

  if too!=9:
    que.append(now*10+too+1)

print(now)

Measured memory_bytes: 18568
#include<stdio.h>
#include<stdlib.h>
 
#define Array_MAX 10000
 
void countingSort(short *A,short *B,int n){
  int i,j;
  int C[Array_MAX+1];
 
  for(i=0;i<=Array_MAX;i++)
    C[i] = 0;
  for(j=1;j<=n;j++)
    C[A[j]]++;
  for(i=1;i<=Array_MAX;i++)
    C[i] = C[i] + C[i-1];
  for(j=n;j>=1;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}
 
int main(){
  unsigned short *A, *B;
  int n,i;
 
  scanf("%d",&n);
   
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
 
  for(i=1;i<=n;i++)
    scanf("%hd",&A[i]);
   
  countingSort(A,B,n);
 
  for(i=1;i<n;i++)
    printf("%hd ",B[i]);
  printf("%hd\n",B[n]);
   
  free(A);
  free(B);
  return 0;
}
     
  

Measured memory_bytes: 8408
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  string S, T;
  cin >> S >> T;
  
  vector<int64_t> Ra(26, -1), Rb(26, -1);
  
  bool flag = true;
  for (uint64_t i = 0; i < S.size(); ++i) {
    if (Ra[S[i] - 'a'] < 0) {
      Ra[S[i] - 'a'] = T[i] - 'a';
    } else {
      flag &= Ra[S[i] - 'a'] == T[i] - 'a';
    }
    
    if (Rb[T[i] - 'a'] < 0) {
      Rb[T[i] - 'a'] = S[i] - 'a';
    } else {
      flag &= Rb[T[i] - 'a'] == S[i] - 'a';
    }
  }
  
  cout << (flag ? "Yes" : "No") << endl;
  
  return 0;
}


Measured memory_bytes: 776
main :: IO()
main = do
    getLine
    ls <- map read . words <$> getLine
    print $ getsolve (tail ls) (head ls) 0 0

getsolve :: [Integer] -> Integer -> Integer -> Int -> Int
-- 値段リスト　→　これまでの最小値　→　差額マックス　→　差額マックス回数　→　回答（差額マックス回数）
getsolve [] _ _ count = count
getsolve ls minval defmax count
    | nextval < minval					= getsolve (tail ls) nextval defmax count
    | nextdefmax > defmax				= getsolve (tail ls) minval nextdefmax 1
    | nextdefmax == defmax				= getsolve (tail ls) minval defmax (count + 1)
    | otherwise							= getsolve (tail ls) minval defmax count
    where nextval = head ls
          nextdefmax = nextval - minval



Measured memory_bytes: 36220
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
    string s,dum;
    std::cin >> s;
    rep(i,s.size()){
      if(s[i]!='x')dum.pb(s[i]);
    }
    bool han=0;
    rep(i,dum.size()/2)if(dum[i]!=dum[dum.size()-1-i])han=1;
    if(han){
      std::cout << -1 << std::endl;
      exit(0);
    }
    int ans=0,c=0;
    std::vector<int> a;
    rep(i,s.size()){
      if(s[i]=='x')c++;
      else{
        a.pb(c);
        c=0;
      }
    }
    a.pb(c);
    rep(i,a.size()/2){
      ans+=abs(a[i]-a[a.size()-i-1]);
    }
    std::cout << ans << std::endl;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N, A;
	cin >> N >> A;
	N %= 500;
	if(N <= A) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

int main()
{
    int n;
    long long c;
    cin >> n >> c;
    long long x[n + 2] = {}, v[n + 2] = {};
    for (int i = 1; i <= n; i++)
    {
        cin >> x[i] >> v[i];
    }
    vector<long long> g(n + 2);
    g[0] = 0ll;
    for (int i = 1; i <= n; i++)
    {
        g[i] = g[i - 1] + v[i] + x[i - 1] - x[i];
    }
    for (int i = 1; i <= n; i++)
    {
        g[i] = max(g[i - 1], g[i]);
    }

    vector<long long> p(n + 2);
    p[n + 1] = 0;
    x[n + 1] = c;
    for (int i = n; i > 0; i--)
    {
        p[i] = p[i + 1] + v[i] + (c - x[i + 1]) - (c - x[i]);
    }
    for (int i = n; i > 0; i--)
    {
        p[i] = max(p[i], p[i + 1]);
    }

    long long ans = 0;
    for (int i = 1; i <= n + 1; i++)
    {
        ans = max(ans, g[i - 1] + p[i] - x[i - 1]);
        ans = max(ans, g[i - 1] + p[i] - (c - x[i]));
        ans = max(ans, g[i]);
        ans = max(ans, p[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
} 

int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(a%b,b);
}
int SIM (int N,int K)
{
  while(N >= K)
  {
    // DEBUG(N,K,"call\n");
  if(N%K == 0)
  {
    N /=K;
  }
  else
  {
    N %=K;
  }
  }
  return N;
}
void solve(void)
{
  int N;
  cin>>N;
  vector<int> D2 = divisor(N-1);
  vector<int> D = divisor(N);
  int ANS = D2.size() -1;
  // DEBUG(D);
  for (int i = 0; i < D.size(); i++)
  {
    int X = D[i];
    if(X == 1)continue;
    if(SIM(N,X) == 1)ANS++;

  }
  cout<<ANS<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;

int n, a, b;

int main()
{
	cin >> n >> a >> b;
	cout << min(a, b) << ' ' << max(0, a + b - n) << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    vector<ll> num(5, 0);
    int k;
    REP(i, 5) { cin >> num[i]; }
    cin >> k;
    REP(i, 5) {
        REP(j, 5) {
            if(i == j) { continue; }
            if(num[j] - num[i] > k) {
                printf(":(\n");
                return 0;
            }
        }
    }
    printf("Yay!\n");
    return 0;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'


int main() {
  int n;
  cin >> n;
  vi a(n);
  bool all_zero = true;
  rep (i, n) {
    cin >> a[i];
    if (a[i]) all_zero = false;
  }
  if (all_zero) {
    cout << "Yes" << endl;
    return 0;
  }
  if (n % 3) {
    cout << "No" << endl;
    return 0;
  }

  sort(all(a));
  rep (i, 3) {
    int a0 = a[n / 3 * i];
    rep (j, n / 3) {
      if (a0 != a[n / 3 * i + j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  int a0 = a[0], a1 = a[n / 3], a2 = a[n / 3 * 2];
  if ((a0 ^ a1) == a2) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

vector<vi> dp(1005, vi(1005, -1));
int sg(int x, int y) {
	if (x <= 1 && y <= 1) return 0;
	if (dp[x][y] != -1) return dp[x][y];

	int &r = dp[x][y];
	set<int> ss;

	for (int i = 1; i * 2 <= x; i++) ss.insert(sg(x - i * 2, y + i));
	for (int i = 1; i * 2 <= y; i++) ss.insert(sg(x + i, y - i * 2));

	for (int i = 0; ; i++) if (ss.find(i) == ss.end()) {
		r = i;
		break;
	}

	return r;
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

 	/*printf("   ");
	rep(j, 0, 20) printf("%2d ", j);
	printf("\n");
	rep(i, 0, 20) {
		printf("%2d ", i);
		rep(j, 0, 20) {
			printf("%2d ", sg(i, j));
		}
		printf("\n");
	}*/
	ll a, b; read(a, b);
	die((abs(a - b) <= 1) ? "Brown" : "Alice");
}


Measured memory_bytes: 4224
n,m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()

cb = []
for _ in range(m):
    b, c = [int(i) for i in input().split()]
    cb.append([c, b])
cb.sort(reverse=1)

i = 0
j = 0
for k in range(n):
    a[k] = max(a[k], cb[i][0])
    j += 1
    if j == cb[i][1]:
        i += 1
        j = 0
    if i == m:
        break
print(sum(a))

Measured memory_bytes: 24012
import java.io.*;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
 
        String line1 = scanner.next();
        String line2 = scanner.next();
        String line3 = scanner.next();

        int a = Integer.parseInt(line1);
        int b = Integer.parseInt(line2);
        int c = Integer.parseInt(line3);
        int num;

        if(a > b){
            num = a;
            a = b;
            b = num;
            }
        if(a > c){
            num = a;
            a = c;
            c = num;
        }
        
        if(b > c){
            num = b;
            b = c;
            c = num;
        }

        System.out.println(a + " " + b + " " + c);
    }

}



Measured memory_bytes: 26256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using lli = long long int;
ll MM = 1000000000;
ll mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)

int main(){
    int n; cin >> n;
    int a[n];
    int mn = 100, mx = -100;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        mn = min(mn, a[i]);
        mx = max(mx, a[i]);
    }
    ll ans = 1000000;
    ll cost = 0;
    for(int i = mn; i < mx + 1; i++){
        for(int j = 0; j < n; j++){
            cost += (a[j] - i)*(a[j] - i);
        }
        ans = min(ans, cost);
        cost = 0;
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  set<string> Z;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    Z.insert(S);
  }
  cout << Z.size() << endl;
}

Measured memory_bytes: 19224
N,M=map(int,input().split())
mylist=list(map(int,input().split()))
mylist.sort(reverse=True)
total=sum(mylist)
answer=0
#print(mylist)

for i in range(M):
    if mylist[i]>=total/(4*M):
        answer+=1
    else:
        pass
    
if answer==M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
// 4/26 Greedy

#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;
    pair<int, int> red[N], blue[N];
 
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        red[i] = make_pair(a, b);
    }

    for (int i = 0; i < N; i++) {
        int c, d;
        cin >> c >> d;
        blue[i] = make_pair(c, d);
    }

    // for (int i = 0; i < N; i++) {
    //     printf("a, b, c, d = %d, %d, %d, %d\n", red[i].first, red[i].second, blue[i].first, blue[i].second);
    // }

    sort(red, red + N);
    sort(blue, blue + N);

    bool red_have_pair[N] = {false};
    int ans = 0;

    for (int i = 0; i < N; i++) {
        int x = blue[i].first;
        int y = blue[i].second;

        int max_y = -1;
        int pair_red = -1;

        for (int j = 0; j < N; j++) {
            if (red[j].first < x && red[j].second < y && red_have_pair[j] != true) {
                // cout << "here?" << endl;
                if (max_y < red[j].second) {
                    max_y = red[j].second;
                    pair_red = j;
                    // cout << "here?2" << endl;
                }
            }
        }

        if (pair_red != -1) {
            red_have_pair[pair_red] = true;
            ans++;
        }
    }

    // for (int l = 0; l <= 4 * N; l++) {
    //     // cout << "l: " << l << endl;

    //     for (int x = 0; x <= l; x++) {
    //         int y = l - x;

    //         std::cout << "x, y = " << x << ", " << y << endl;

    //         // lがある値の時のブルーを１つずつ探す。
    //         for (int i = 0; i < N; i++) {
    //             bool find_pair = false;
    //             if (blue[i].first == x && blue[i].second == y) {
    //                 std::cout << "find blue!" << endl;

    //                 for (int j = 0; j < N; j++) {
    //                     if (red[j].first < x && red[j].second < y && have_pair[j] != true) {
    //                         have_pair[j] = true;
    //                         find_pair = true;
    //                         ans += 1;
    //                         break;
    //                     }
    //                 }
    //             }

    //             // // ペアを見つけていたら次のブルーへ。
    //             // if (find_pair) break;
    //         }
    //     }
    // }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int n,R;
double h[50];//+20
double hmax;

double solve(double l,double r){//[l,r)
	//cout << "--" << l << " " << r << endl; 
	if(r-l<0.00001) return l;
	double k = (l + r)/2;
	bool okflg = true;
	REP(i,(int)R+20){
		double x = (double) i - 20;
		if(abs(x) > R) continue;
		double y1 = sqrt(R*R - x*x);
		double y2 = sqrt(R*R - (x+1)*(x+1));
		//cout << y1+k-R << " " << h[i] << endl;
		if(y1 + k - R > h[i]|| y2 + k - R > h[i]) okflg = false;
	}
	//cout << " " << okflg << endl;
	if(okflg) return solve(k,r); 
	else return solve(l,k);
}
int main(){
	while(1){
		cin >> R >> n;
		if(n==0&&R==0) break;
		REP(i,50) h[i] = 0;
		hmax = -1;
		REP(i,n){
			double a,b,c;
			cin >> a >> b >> c;
			FOR(j,a+20,b+20) h[j] = max(h[j],c);
			hmax = max(c,hmax);
		}
		cout << shosu(10) << solve(0,((double)hmax) + 0.001) << endl;
	}
}

Measured memory_bytes: 1288
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

ll c, d, cd;

// n - (dの倍数の数 + cの倍数の数 - lcm(d, c)の倍数の数)
ll f(ll n) {
  ll dn = n/d;
  ll cn = n/c;
  ll cdn = n/cd;
  return n - (dn + cn - cdn);
}

int main() {
  ll a, b; cin >> a >> b >> c >> d;
  cd = lcm(d, c);
  cout << f(b) - f(a-1) << endl;
  return 0;
}


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

int main(){

	ll h,w;
	cin >> h >> w;
	char a[h][w];
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			cin >> a[i][j];
		}
	}

	ll dp[h][w];
	ll f1=0,f2=0;
	for(ll j=0;j<w;j++){
		if(a[0][j] == '#')
			f1=1;
		if(f1==0)
			dp[0][j] = 1;
		else
			dp[0][j]= 0;
	}

	for(ll i=0;i<h;i++){
		if(a[i][0] == '#')
			f2=1;
		if(f2==0)
			dp[i][0] = 1;
		else
			dp[i][0]= 0;
	}	
	//cout << a[1][1]<<endl;

	for(ll i=1;i<h;i++){
		for(ll j=1;j<w;j++){
			if(a[i][j] == '#')
				dp[i][j] = 0;
			else
				dp[i][j] = (dp[i-1][j]+dp[i][j-1])%inf;
			//cout << dp[i][j] << " ";
		}
		//cout << endl;
	}
	cout <<dp[h-1][w-1];
	return 0;
}

Measured memory_bytes: 9088