akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;

const int mod=1e9+7;

int main(){
  string k;
  cin>>k;
  int d;
  cin>>d;
  vector<vector<long>> dp(d, vector<long>(2));
  dp[0][0]=1;
  for(int i=0;i<k.size();i++)
  {
    vector<vector<long>> newdp(d, vector<long>(2));
    for(int sum=0;sum<d;sum++)
    {
      for(bool sm_already : {false,true})
      {
        for(int digit=0;digit<10;digit++)
        {
          if(digit>k[i]-'0'&&!sm_already)
            break;
          newdp[(sum+digit)%d][sm_already or digit<k[i]-'0']+=dp[sum][sm_already];
          newdp[(sum+digit)%d][sm_already or digit<k[i]-'0']%=mod;
        }
      }
    }
    dp=newdp;
  }
  long ans=(dp[0][false]+dp[0][true])%mod;
  ans--;
  if(ans==-1)
	ans=mod-1;
  cout<<ans;
  
}

Measured memory_bytes: 256
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(long long int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); vect(A);for(long long i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll p=1e5;

int main()
{
    /*#ifndef ONLINE_JUDGE
       freopen ("input.txt" , "r" , stdin);
		// freopen ("OUTPUT.txt" , "w" , stdout);
	#endif
	*/
    fio;
    char gen[26];
    forin(i,0,25)
    {
        gen[i]=char('A'+i);
    }
    string s;
    ll n;
    cin>>n>>s;
    forin(i,0,s.length()-1)
    {
        char c;
        forin(j,0,25)
        {
            if(s[i]==gen[j])
            {
                c=gen[(j+n)%26];
            }
        }
        s[i]=c;
    }
    cout<<s<<endl;
}



Measured memory_bytes: 256
a, b = map(int,input().split())
if a > 0:
    print("Positive")
elif a == 0 or b == 0 or a < 0 and b > 0:
    print("Zero")
else:
    if (b - a) % 2 == 0:
        print("Negative")
    else:
        print("Positive")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define Set(a,b) memset(a,b,sizeof(a))
template<class T>inline void init(T&x){
	x=0;char ch=getchar();bool t=0;
	for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') t=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch-48);
	if(t) x=-x;return;
}typedef long long ll;
const int N=2000+10;
const int mod=1e9+7;
int C[N][N];
int f[N][N];//S[N][N];
inline int Sum(int x,int y){x+=y;if(x>=mod) x-=mod;return x;}
template<class T>inline void Inc(T&x,int y){x+=y;if(x>=mod) x-=mod;}
int main()
{
	int n,K;
	init(n),init(K);C[0][0]=1;
	for(int i=1,j;i<=n;++i)
		for(C[i][0]=j=1;j<=i;++j)
			C[i][j]=Sum(C[i-1][j],C[i-1][j-1]);
	f[0][0]=1;//S[0][0]=1;for(int i=1;i<=K;++i) S[0][i]=1;
	for(int i=1;i<=K;++i) {f[i][0]=1;for(int j=1;j<=K;++j) f[i][j]=Sum(f[i][j-1],f[i-1][j]);}
	for(int i=1;i<=K;++i) printf("%lld\n",(ll)f[i][K-i]*C[n-K+1][i]%mod);
	return 0;
}


Measured memory_bytes: 31744
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    bool beki[10000]={};
    beki[1]=true;
    for(int i=2;i<=35;i++){
        for(int p=2;p<=10;p++){
           if(pow(i,p)<=2000)beki[(int)pow(i,p)]=true;
        }
    }
    int X;
    cin >> X;
    for(int i=X;i>=1;i--){
        if(beki[i]){
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

struct ball{
  int left;
  int right;
  int index;

  bool operator>(const ball &other) {
    if (other.right != right) return right > other.right;
    if (other.left != left) return left > other.left;
    if (other.index != index) return index > other.index;
    return false;
  }

  bool operator<(const ball &other) {
    if (other.right != right) return right < other.right;
    if (other.left != left) return left < other.left;
    if (other.index != index) return index < other.index;
    return false;
  }
};

struct BIT {
  ll n;
  vector<ll> bit;
  BIT(ll n, ll init=0): n(n), bit(n+1, init) {}

  //functions
  //OPERATION: ADD
  
  //i番目（0-indexed) にaを加算する
  void add(ll i, ll a) {
    i++;
    for (int j = i; j <= n; j += (j & -j)) bit[j] += a;
    return;
  }

  //区間和: [a, b)の区間和
  ll sum(ll a, ll b) {
    if (a == 0) {
      ll ans = 0;
      for (int i = b; i > 0; i -= (i & -i)) ans += bit[i];
      return ans;
    }
    else {
      return sum(0, b) - sum(0, a);
    }   
  }
};

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

  int n, q;
  cin >> n >> q;
  vector<int> color(n);
  for (int i = 0; i < n; i++) cin >> color[i];
  vector<ball> queries(q);
  for (int i = 0; i < q; i++) {
    queries[i].index = i;
    cin >> queries[i].left >> queries[i].right;
  }
  sort(queries.begin(), queries.end());

  vector<int> rightb(n, -1), ans(q);
  int r = 0;
  BIT bit(n);
  for (int i = 0; i < q; i++) {
    ball b = queries[i];
    while (r < b.right) {
      bit.add(r, 1);
      if (rightb[color[r]-1] != -1) bit.add(rightb[color[r]-1], -1);
      rightb[color[r]-1] = r;
      r++;
    }
    ans[b.index] = bit.sum(b.left-1, b.right);
  }
  for (int i = 0; i < q; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 19348
#include<cstdio>
#include<algorithm>

using namespace std;

typedef	long long	ll;

ll gcd(ll a,ll b){
	for(;a;swap(a,b))	b%=a;
	return b;
}

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

int main(){
	for(int n;scanf("%d",&n),n;){
		int d[10],v[10];
		for(int i=0;i<n;i++)scanf("%d%d",d+i,v+i);

		ll deno=d[0];
		for(int i=1;i<n;i++)	deno=lcm(deno,d[i]);
		ll nume[10];
		for(int i=0;i<n;i++)	nume[i]=v[i]*deno/d[i];
		ll g=nume[0];
		for(int i=1;i<n;i++)	g=gcd(g,nume[i]);
		for(int i=0;i<n;i++)	printf("%d\n",nume[i]/g);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

typedef struct
{
  int a;
  int b;
} Edge;

int N, M;

int root(int node, int *pair)
{
  if (pair[node] == node)
  {
    return node;
  }
  else
  {
    return pair[node] = root(pair[node], pair);
  }
}

//x < y
void unite(int x, int y, int *pair)
{
  x = root(x, pair);
  y = root(y, pair);
  if (x == y)
    return;
  pair[y] = x;
}

void init(int *pair)
{
  for (int i = 0; i <= N; i++)
  {
    pair[i] = i;
  }
}

int main()
{
  int result = 0;
  cin >> N >> M;
  int pair[N + 1];
  Edge edge[M];
  for (int i = 0; i < M; i++)
  {
    cin >> edge[i].a >> edge[i].b;
  }
  init(pair);
  /////////////////////////

  for (int i = 0; i < M; i++)
  {
    for (int j = 0; j < M; j++)
    {
      if (i != j)
      {
        unite(edge[j].a, edge[j].b, pair);
      }
    }
    for (int h = 1; h <= N; h++)
    {
      root(h, pair);
    }

    for (int k = 1; k <= N; k++)
    {
      if (pair[k] != pair[1])
      {
        result++;
        break;
      }
    }
    init(pair);
  }

  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s,t;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  string u;
  cin>>u;
  if(u==s)
    cout<<a-1<<" "<<b;
  else
    cout<<a<<" "<<b-1;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int x;
  int y;
  int z;
  cin >> x;
  cin >> y;
  cin >> z;
  
  if ((x == y) && (y == z))
    cout <<"No";
  else
    if ((x == y)||(y == z)||(x == z))
        cout <<"Yes";
    else 
        cout <<"No";
}

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

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

using namespace std;

int main(){
	string s; cin>>s;
	int n=s.length();

	bool used[128]={};
	int cnt=0,l=1;
	vector<int> len(n+1); // len[i] = minimum length for s[i..)
	for(int i=n-1;i>=0;i--){
		if(!used[s[i]]){
			used[s[i]]=true;
			cnt++;
			if(cnt==26){
				for(char c='a';c<='z';c++) used[c]=false;
				cnt=0;
				l++;
			}
		}
		len[i]=l;
	}
	len[n]=1;

	vector<int> pos[128];
	rep(i,n) pos[s[i]].emplace_back(i);
	for(char c='a';c<='z';c++) pos[c].emplace_back(n);

	string ans;
	int idx=0;
	rep(i,len[0]){
		for(char c='a';c<='z';c++){
			int p=*lower_bound(pos[c].begin(),pos[c].end(),idx);
			if(p==n || len[p+1]==len[0]-i-1){
				idx=p+1;
				ans+=c;
				break;
			}
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 2180
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
char s[107];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    cin>>s+1;
    if(n&1)
        cout<<"No";
    else{
        int flag=0;
        for(int i=1;i<=n/2;++i)
            if(s[i]!=s[i+n/2])
                flag=1;
        if(flag)
            cout<<"No";
        else
            cout<<"Yes";
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int main()
{
    int N, A;
    int x[50];

    scanf("%d %d", &N, &A);
    int X = N;
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &x[i]);
        X = max(X, x[i]);
    }

    long long dp[N + 1][N + 1][N * X + 1];
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    for (int i = 0; i <= N; i++)
    {
        for (int j = 0; j <= N; j++)
        {
            for (int k = 0; k <= N * X; k++)
            {
                if (i == 0 && j == 0 && k == 0)
                {
                    continue;
                }
                else if (i >= 1 && x[i - 1] > k)
                {
                    dp[i][j][k] = dp[i - 1][j][k];
                }
                else if (i >= 1 && j >= 1 && x[i - 1] <= k)
                {
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i - 1]];
                }
                else
                {
                    dp[i][j][k] = 0;
                }
            }
        }
    }

    long long ans = 0LL;
    for (int i = 1; i <= N; i++)
    {
        ans += dp[N][i][i * A];
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 50944
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<map>
#include<algorithm>
#define N (100000+1000)
using namespace std;

int n,a[N],b[N],ans;
map<int,int>pos;

int main()
{
	scanf("%d",&n);
	for (int i=1; i<=n; ++i)
		scanf("%d",&a[i]),b[i]=a[i];
	sort(b+1,b+n+1);
	for (int i=1; i<=n; ++i) pos[b[i]]=i;
	for (int i=1; i<=n; ++i) 
		if (abs(i-pos[a[i]])%2)
			ans++;
	printf("%d",ans>>1);
}

Measured memory_bytes: 5760
from collections import Counter
import itertools

n = int(input())
s = []
for i in range(n):
    s.append(str(input()))

cnt_words = Counter(s)

mode_v = cnt_words.most_common()[0][-1]
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, cnt_words.most_common()
)
m = []
for i in it:
    m.append(i[0])
m.sort()
for item in m:
    print(item)

Measured memory_bytes: 45032
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k, ans;
    ans = 0;
    cin >> n >> k;
    vll h(n, 0);
    REP(i, n)cin >> h[i];
    while(n > k-1){//1とk-1つを毎回選んで1にする
        n -= k-1;
        ans++;
    }
    if(n > 1) ans ++;//端数
    cout << ans <<"\n";
	return 0;
}

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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
#define INF INFINITY
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

/*******************************************************/

int main() {
	ll n; cin >> n;
	ll ans = (n - 2) * 180;
	cout << ans << endl;
}

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

int main()
{
    int n,m;
    std::cin >> n >> m;
    std::vector<std::string> t(n), k(n);
    for(int i = 0; i < n; i++)std::cin >> t[i];
    for(int i = 0; i < m; i++)std::cin >> k[i];

    bool res = false;
    for(int i = 0; i <= n - m; i++){
        for(int j = 0; j <= n - m; j++){
            bool flag = true;
            for(int x = 0; x < m; x++){
                for(int y = 0; y < m; y++){
                    if(t[x + i][y + j] != k[x][y])flag = false;
                }
            }
            if(flag)res = true;
        }
    }
    std::cout << (res ? "Yes" : "No") << std::endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int ans=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    ans+=a[i]-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import bisect

a,b,q = map(int,input().split())
s = [0] * a
t = [0] * b
ans = []

for i in range(a):
    s[i] = int(input())
for j in range(b):
    t[j] = int(input())
for x in range(q):
    x = int(input())
    shr = bisect.bisect_left(s,x)
    if shr == 0:
        shrr = shr
    elif shr == a:
        shr = a - 1
        shrr = a - 1
    else:
        shrr = shr - 1
    
    tem = bisect.bisect_left(t,x)
    if tem == 0:
        temm = tem
    elif tem == b:
        tem = b - 1
        temm = b - 1
    else:
        temm = tem - 1
    
    can = []
    l = [[shr,tem],[shr,temm],[shrr,tem],[shrr,temm]]
    
    for i in range(4):
        can.append(min(abs(s[l[i][0]]-x)+abs(t[l[i][1]]-s[l[i][0]]),abs(t[l[i][1]]-x)+abs(s[l[i][0]]-t[l[i][1]])))
    
    ans.append(min(can))

for p in ans:
    print(p)



Measured memory_bytes: 78552
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define allr(v) v.rbegin(),v.rend() 
//#define endl '\n'  
typedef  long long ll; 
typedef  unsigned long long ull; 
typedef vector< ll > edge; 
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1e9+7;
const ll inf=1e15+10;
const ll N=1e6+10;

int main()
{
	boost;
	ll h,w;
	cin>>h>>w;
	string s[h];
	for(ll i=0;i<h;i++) cin>>s[i];
	ll dp[h][w],dp1[h][w];
	for(ll i=0;i<h;i++)
	{
		for(ll j=0;j<w;j++)
		{
			dp[i][j]=0;
			if(s[i][j]=='.')
			{
				if((j-1)>=0 )
				{
					if(s[i][j-1]=='.') dp[i][j]+=dp[i][j-1];
					else
					{
						ll count=0;
						for(ll k=j;k<w and s[i][k]=='.';k++) count++;
						dp[i][j]+=count;	

					}
				}
				else
				{
					ll count=0;
					for(ll k=j;k<w and s[i][k]=='.';k++) count++;
					dp[i][j]+=count;	

				}					
				
				
			}
			//cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}	
	//cout<<endl;
	for(ll i=0;i<h;i++)
	{
		for(ll j=0;j<w;j++)
		{
			dp1[i][j]=0;
			if(s[i][j]=='.')
			{
					
				if((i-1)>=0)
				{
					if(s[i-1][j]=='.') dp1[i][j]+=dp1[i-1][j];
					else
					{
						ll count=0;
						for(ll k=i;k<h and s[k][j]=='.';k++) count++;
						dp1[i][j]+=count;	
					}

				}
				else
				{
					ll count=0;
					for(ll k=i;k<h and s[k][j]=='.';k++) count++;
					dp1[i][j]+=count;	
				}				
				
			}
			//cout<<dp1[i][j]<<" ";
		}
		//cout<<endl;
	}		
	ll ans=0;
	for(ll i=0;i<h;i++) for(ll j=0;j<w;j++) ans=max(ans,dp[i][j]+dp1[i][j]-1);
	cout<<ans;	
  	return 0;
}  

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

int main(){
    long long h,n;cin>>h>>n;
    vector<long long> skills(n);for(long long i=0;i<n;i++){cin>>skills[i];}

    long long acc = 0;
    for (auto k : skills){
        acc += k;
    }
    if (acc >= h){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------


//--MAIN-----------------------------------
void Main() {
    ll ni,no,nt,nj,nl,ns,nz; cin>>ni>>no>>nt>>nj>>nl>>ns>>nz;
    ll K=no+(ni/2)*2+(nj/2)*2+(nl/2)*2;
    if(ni>0 and nl>0 and nj>0){
        if(ni%2+nl%2+nj%2 ==2) K+=1;
        if(ni%2+nl%2+nj%2 ==3) K+=3;
    }
    cout<< K <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

vector<long long> v;
void dfs(ll x, ll num, ll st, ll cc){
	if(v.size() > 100050) return;
	if(num == 0) num += x;
	else {
		num *= 10;
		num += x;
	}
	if(cc > st) return;
	if(cc == st){
		v.push_back(num);
		return;
	}
	if(x-1 >= 0) dfs(x-1,num,st,cc+1);
	if(x+1 <= 9) dfs(x+1,num,st,cc+1);
	dfs(x,num,st,cc+1);
	return;
}

int main(){
	
	ll k; cin>>k;
	for(int i = 1; i <= 10; i++){
		for(int j = 1; j <= 9; j++){
			dfs(j,0,i,1);
		}
	}
	//cout<<v.size()<<"\n";
	//for(int i = 0; i <= 100000; i++) cout<<v[i]<<" ";
	sort(v.begin(),v.end());
	cout<<v[k-1]<<"\n";
	
	
}

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

int main()
{
	int a, b;
	std::cin >> a >> b;
	if (a < b) 
	{
		std::cout << "a < b" << "\n";
	}
	else if (a > b)
	{
		std::cout << "a > b" << "\n";
	}
	else 
	{
		std::cout << "a == b" << "\n";
	}
}

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
# A

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

s = list(input())[:-1]
# print(s)
max_ans = 0
ans = 0
for s in s:
    if s == 'R':
        ans += 1
        if ans > max_ans:
            max_ans = ans
    else:
        ans = 0

print(max_ans)

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

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

  int V; cin >> V;
  vector< vector<int> > G(V,vector<int> (V,0));
  for(int i = 0; i < V; i++){
    for(int j = 0; j < V; j++){
      cin >> G[i][j];
    }
  }

  vector< vector<bool> > use(V,vector<bool> (V,true));
  for(int k = 0; k < V; k++){
    for(int i = 0; i < V; i++){
      for(int j = 0; j < V; j++){
        if(i == j || j == k || k == i) continue;

        if(G[i][j] > G[i][k] + G[k][j]){
          cout << -1 << endl;
          return 0;
        }

        if(G[i][j] == G[i][k] + G[k][j]){
          use[i][j] = false;
        }
      }
    }
  }

  int ans = 0;
  for(int i = 0; i < V; i++){
    for(int j = 0; j < V; j++){
      if(use[i][j]){
        ans += G[i][j];
      }
    }
  }
  cout << ans / 2 << endl;

  return 0;
}


Measured memory_bytes: 1152
object Main extends App {
  val n = scala.io.StdIn.readInt()
  val aInput =  scala.io.StdIn.readLine()
  val aArray = aInput.split(" ").map(_.toInt).toVector

  var result = 0
  (1 to aArray.length).foreach { i =>
    if (i % 2 == 1 && aArray(i - 1) % 2 == 1) {
      result = result + 1
    }
  }

  println(result)
}

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

int main() {
    int n, k, x[100000];
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> x[i];

    int min_time = 3 * 100000000;

    for (int i = 0; i < n - (k - 1); i++) {
        int front = i, back = i + (k - 1);
        int distance = abs(x[back] - x[front]);
        int start = (abs(x[front]) < abs(x[back]) ? abs(x[front]) : abs(x[back]));

        min_time = min(min_time, distance + start);
    }

    cout << min_time << endl;
}

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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
        #define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

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

  vi a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];

  sort(all(a));
  sort(all(b));
  sort(all(c));

  ll ans = 0;
  rep(i, n){
    int x = lower_bound(all(a), b[i])-a.begin();
    int y = n-(upper_bound(all(c), b[i])-c.begin());
    ans += (ll)x*y;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x,y,z,a,b;
    cin>>x>>y;
    if(y%2){
        cout<<"No";
        return 0;
    }
    z=y/2;
    a=2*x-z;
    b=z-x;
    if(a<0 || b<0){
        cout<<"No";
        return 0;
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define get(i,x) get<i>(x)
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	string s; cin>>s;
	int r=0,b=0;
	for(auto i:s)
	{
		if(i=='R') r++;
		else b++;
	}
	if(r>b) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	string S;
	cin >> S;

	deque<char> sl( S.begin(), S.end() );
	bool rev = false;

	int Q;
	cin >> Q;
	while( Q-- ) {
		int T, F;
		char C;
		cin >> T;

		if( T == 1 ) {
			rev = !rev;
		}
		else {
			cin >> F >> C;
			if( !rev ) {
				if( F == 1 ) { sl.push_front( C ); }
				else { sl.push_back( C ); }
			}
			else {
				if( F == 1 ) { sl.push_back( C ); }
				else { sl.push_front( C ); }
			}
		}
	}

	if( !rev ) {
		for( int i = 0; i < sl.size(); ++i ) { cout << sl[i]; }
	}
	else {
		for( int i = sl.size()-1; i >= 0; --i ) { cout << sl[i]; }
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 976
#include <cstdio>

const int N = 1 << 20;
const int mod = 998244353;

int n;
int a[N], b[N], p[N], sum;

inline int add( int a, int b ) { return ( a + b ) % mod; }
inline int mul( int a, int b ) { return ( 1LL * a * b ) % mod; }
inline void add_eq( int &a, int b ) { a = ( a + b ) % mod; }
inline void mul_eq( int &a, int b ) { a = ( 1LL * a * b ) % mod; }

int ksm( int a, int p ) {
	int res = 1;
	while( p ) {
		if( p & 1 ) 
			res = mul( res, a );
		a = mul( a, a );
		p >>= 1;
	}
	return res;
}
inline int inv( int a ) { return ksm( a, mod - 2 ); }

void XOR( int *f, int len, int x = 1 ) {
	for( int o = 2, k = 1; o <= len; o <<= 1, k <<= 1 ) {
		for( int i = 0; i < len; i += o ) {
			for( int j = 0; j < k; j ++ ) {
				add_eq( f[ i + j ], f[ i + j + k ] );
				f[ i + j + k ] = add( f[ i + j ], add( - f[ i + j + k ], - f[ i + j + k ] ) );
				mul_eq( f[ i + j ], x ); mul_eq( f[ i + j + k ], x );
			}
		}
	}
}

int main() {
#ifdef woshiluo
	freopen( "F.in", "r", stdin );
	freopen( "F.out", "w", stdout );
#endif
	scanf( "%d", &n );
	n = 1 << n;
	for( int i = 0; i < n; i ++ ) {
		scanf( "%d", &a[i] );
		sum += a[i];
		b[i] = mod - 1;
	}
	sum = inv(sum);
	for( int i = 0; i < n; i ++ ) {
		p[i] = mul( a[i], sum );
	}

	b[0] = n - 1; p[0] -= 1;
	XOR( b, n ); XOR( p, n );
	for( int i = 0; i < n; i ++ ){ 
		mul_eq( b[i], inv( p[i] ) );
	}
	XOR( b, n, inv(2) );
	for( int i = 0; i < n; i ++ ) {
		printf( "%d\n", ( ( add( b[i], -b[0] ) + mod ) % mod ) );
	}
}

Measured memory_bytes: 7808
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	k, _ := strconv.Atoi(Scanner())
	b := make([]int, 41)
	for i := 0; i < n; i++ {
		a, _ := strconv.Atoi(Scanner())
		for j := 0; ; j++ {
			b[j] += a % 2
			a /= 2
			if a == 0 {
				break
			}
		}
	}
	w := make([]int, 41)
	w[0] = 1
	for i := 1; i < 41; i++ {
		w[i] = w[i-1] * 2
	}
	v := make([]int, 41)
	l := make([]int, 0)
	ans := 0
	for i := 0; i < 41; i++ {
		v1 := w[i] * (n - b[i])
		v0 := w[i] * b[i]
		if v1 > v0 && w[i] <= k {
			l = append(l, i)
			v[i] = v1 - v0
		}
		ans += v0
	}
	ansl := make([]int, 0)
	if len(l) > 0 {
		vs := make([]int, len(l))
		ws := make([]int, len(l))
		vs[0] = v[l[0]]
		ws[0] = w[l[0]]
		for i := 1; i < len(l); i++ {
			vs[i] = vs[i-1] + v[l[i]]
			ws[i] = ws[i-1] + w[l[i]]
		}
		for i := len(l) - 1; i >= 0; i-- {
			idx := l[i]
			if i > 0 {
				if ws[i] <= k {
					ans += vs[i]
					k -= ws[i]
					break
				} else if w[idx] <= k {
					if ws[i-1] <= k {
						ansl = append(ansl, ans+vs[i-1])
					}
					ans += v[idx]
					k -= w[idx]
				}
			} else {
				if w[idx] <= k {
					ans += v[idx]
				}
			}
		}
	}
	for _, i := range ansl {
		if i > ans {
			ans = i
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2304
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
int N,M;
struct edge
{
    int next;
    int to;
    void set(int n,int t)
    {
        next=n;
        to=t;
    }
};
edge edges[200100];
int edgecount;
int map[200100];
void addedge(int f,int t)
{
    edges[edgecount].set(map[f],t);
    map[f]=edgecount++;
}
int searchforway(int index,int jibu)
{
    if(index==N-1)
        return 1;
    else if(jibu>=2)
        return 0;
    for(int n=map[index];n!=-1;n=edges[n].next)
    {
        if(searchforway(edges[n].to,jibu+1))
            return 1;
    }
    return 0;
}
int main()
{
    while(scanf("%d%d",&N,&M)==2)
    {
        memset(map,-1,sizeof(map));
        edgecount=0;
        int f,t;
        for(int i=0;i<M;i++)
        {
            scanf("%d%d",&f,&t);
            addedge(f-1,t-1);
        }
        if(searchforway(0,0))
            printf("POSSIBLE\n");
        else
            printf("IMPOSSIBLE\n");

    }
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>
#include <map>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(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; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

//////////////////////////////////////////////////////////////


int main() {

	int N;
	cin >> N;
	int n = N % 10;

	if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
		cout << "hon" << endl;
	}
	else if(n == 0 || n == 1 || n == 6 || n == 8){
		cout << "pon" << endl;
	}
	else{
		cout << "bon" << endl;
	}
	return 0;
}


Measured memory_bytes: 3624
//2018.10.16 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register LL
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline LL read(){
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y){
    x^=y^=x^=y;
}
inline LL _abs(const res &x){
    return x>0?x:-x;
}
inline LL _max(const res &x,const res &y){
    return x>y?x:y;
}
inline LL _min(const res &x,const res &y){
    return x<y?x:y;
}
namespace MAIN{
    LL x,y;
    inline void MAIN(){
        x=read(),y=read();
        if(x==y)puts("0");
        else if(x>y)printf("%lld\n",_min(_abs(x+y)+1,_abs(x-y)+2));
        else printf("%lld\n",_min(y-x,_abs(x+y)+1));
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    string s = "";
    for (int i = 0; i < b; i++) {
        s += to_string(a);
    }
    string t = "";
    for (int i = 0; i < a; i++) {
        t += to_string(b);
    }
    cout << min(s, t) << endl;
}


Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
 
#define forz(i, n) for (int i = 0; i < n; i++)
#define bui(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define mui(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
 lli power(lli x,lli y,lli p)
{
  lli res=1;
  x=x%p;
  while(y>0)
  {
    if(y&1)
      res=(res*x)%p;
    //y must be even now
    y=y>>1; //y=y/2
    x=(x*x)%p;
  }
  return res;
}
 
lli gcd(lli a, lli b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{ return a * b / gcd(a, b); }
lli max(lli a, lli b)
{
  if (a > b)
    return a;
  return b;
}
lli min(lli a, lli b)
{
  if (a < b)
    return a;
  return b;
}
using namespace std;

int main()
{  
    kira;
    //freopen("input.txt","r",stdin);
    lli n;
    cin>>n;
    lli a[n];
    forz(i,n)
    cin>>a[i];
    sort(a,a+n);
    if(n==1)
    {
      cout<<a[0]<<endl;
      return 0;
    }
    double s=(a[0]+a[1])/(2.0);
    for(lli i=2;i<n;i++)
    {
      s=(s+a[i])/(2.0);
    }
    cout<<fixed<<setprecision(10);
    cout<<s<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            char a = char.Parse(Console.ReadLine());


            if (Char.IsUpper(a))
            {
                Console.WriteLine('A');
            }
            else
            {
                Console.WriteLine('a');
            }
        }
    }
}


Measured memory_bytes: 25896
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N;
    cin >> N;
    bool isev = true;
    vi A(N);
    rep(i, N) {
        cin >> A[i];
        if(A[i]%2) isev = false;
    }

    int res = 0;
    while(isev) {
        rep(i, N) {
            A[i] /= 2;
            if(A[i]%2) isev = false;
        }
        res++;
    }
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
string s;
cin>>s;
ll n=s.size();
string ans;
string q;
for(ll i=0; i<n; i++){
if(s.at(i)=='0'){
ans+='0';}
else if(s.at(i)=='1'){
ans+='1';}
else if(ans.size()==0){
continue;}
else{
q=ans.substr(0,ans.size()-1);
ans=q;;}}
cout<<ans<<endl;}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	int dp[n+1][m+1];
	rep(i,n+1)rep(j,m+1) dp[i][j] = 0;
	For(i,1,n+1){
		For(j,1,m+1){
			//添字一個正にずらす
			if(s[i-1] == t[j-1]){
				dp[i][j] = dp[i-1][j-1] + 1;
			} else {
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}

	string ans = "";
	int x = n;
	int y = m;
	while(x > 0 && y > 0){
		if(dp[x][y] == dp[x-1][y]){
			x--;
		} else if(dp[x][y] == dp[x][y-1]){
			y--;
		} else {
			x--;
			y--;
			ans.push_back(s[x]);
		}
	}
	reverse(ans.begin(),ans.end());
	cout << ans << endl;
}


Measured memory_bytes: 35456
from fractions import gcd
from functools import reduce
import sys
input = sys.stdin.readline

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


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=1)
ans=0
m=int(10**9+7)
g=1
l=1
'''
for x in a:
  if l%x!=0:
    g=gcd(l,x)
    l=l*x//g
'''
l=lcm(*a)

for x in a:
  ans+=l//x

print(ans%m)


Measured memory_bytes: 6132
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,s=0,res=1e10;
	vector<int>W;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int a;
		cin>>a;
		W.push_back(a);
		s+=a;
	}
	int t=0;
	for(int i=0;i<N;i++)
	{
		t+=W[i];
		res=min(res,abs(t-(s-t)));
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
k,a,b = list(map(int, input().split()))

# 2手かけて増えるのが2枚以下なら地道に増やす
if b-a <= 2:
    print(1+k)
else:
    k -= a-1
    q,r = divmod(k,2)
    print(a+q*(b-a)+r)

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

int main(){
  string s, t;
  cin >> s;
  cin >> t;

  if(s == t.substr(0, t.size()-1)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3600
#include <stdio.h>
#define size 4000000
char g[1009][1009];
int visit[1009][1009];
int N, M, ans;
int start, end;
int di[4] = {-1, 1, 0, 0};
int dj[4] = { 0, 0, -1, 1 };
struct store{
	int x, y;
	int cost;
}queue[size];

void init_bfs(){
	start = end = 0;
}

void insert(int si, int sj, int swt){
	queue[end%size].x = si;
	queue[end%size].y = sj;
	queue[end%size].cost = swt;
	end++;
}

void front(int *i, int *j, int *wt){
	*i = queue[start%size].x;
	*j = queue[start%size].y;
	*wt = queue[start%size].cost;
	start++;
}

void bfs(){
	int i, j, wt, d, Ni, Nj;
	while (start < end){
		front(&i, &j, &wt);
		if (wt > ans){
			ans = wt;
		}
		for (d = 0; d < 4; d++){
			Ni = i + di[d];
			Nj = j + dj[d];
			if (Ni < 0 || Ni >= N || Nj < 0 || Nj >= M) continue;
			//printf("%d %d\n", Ni, Nj);
			if (visit[Ni][Nj] == 0){
				insert(Ni, Nj, wt + 1);
				visit[Ni][Nj] = 1;
			}
		}
	}
}

int main()
{
	//freopen("input.txt", "r", stdin);
	int i, j;
	ans = -1;
	scanf("%d %d", &N, &M);
	init_bfs();
	for (i = 0; i < N; i++){
		for (j = 0; j < M; j++){
			visit[i][j] = 0;
		}
	}

	for (i = 0; i < N; i++){
		getchar();
		for (j = 0; j < M; j++){
			scanf("%c", &g[i][j]);
			if (g[i][j] == '#'){
				insert(i, j, 0);
				visit[i][j] = 1;
			}
		}
	}
	bfs();
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 19200
N=gets.strip.to_i

result = N
(1..Math.sqrt(N).ceil).to_a.each do |num|
  next if(N%num!=0)
  f_num = [(N/num).to_s.split('').size, num.to_s.split('').size].max
  result =[result, f_num].min
end

p result

Measured memory_bytes: 2684
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int n;
string s;
int cor;
int ans;
int main()
{
	//cin>>n;
	cin>>s;n=s.size();
	rep(i,n)
	{
		if(s[i]=='0')
		{
			if(cor<0)ans+=2;
			cor++;
		}
		if(s[i]=='1')
		{
			if(cor>0)ans+=2;
			cor--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
d_dict = {}
for d in D:
    if d not in d_dict:
        d_dict[d] = 0
    d_dict[d] += 1

count = 0
for t in T:
    if t in d_dict and d_dict[t] > 0:
        d_dict[t] -= 1
        count += 1
if count == M:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 41316
/// referenced: https://beta.atcoder.jp/contests/abc049/submissions/1800772
#include<bits/stdc++.h>
using namespace std;
int getGroup(int node,vector<int>*groups){
  vector<int>&xs=*groups;
  int parent=xs[node];
  if(parent==node) {
    return node;
  } else {
    xs[node] = getGroup(xs[node], &xs);
    return xs[node];
  }
}
main(){
  int N,K,L;
  cin>>N>>K>>L;
  vector<int> road(N);
  vector<int> rail(N);
  for(int i=0;i<N;++i){  // Initializes groups for each node.
    road[i]=i;
    rail[i]=i;
  }
  for(int i=0;i<K;++i){
    int p,q;
    cin>>p>>q;
    --p;
    --q;
    p=getGroup(p,&road);
    q=getGroup(q,&road);
    if(p!=q)road[p]=q;  // Connects by a road.
  }
  for(int i=0;i<L;++i){
    int r,s;
    cin>>r>>s;
    --r;
    --s;
    r=getGroup(r,&rail);
    s=getGroup(s,&rail);
    if(r!=s)rail[r]=s;  // Connects by a rail.
  }
  map<pair<int,int>,int>map_;
  for(int i=0;i<N;++i){
    int u=getGroup(i,&road);
    int v=getGroup(i,&rail);
    ++map_[{u,v}];
  }
  for(int i=0;i<N;++i){
    int u=getGroup(i,&road);
    int v=getGroup(i,&rail);
    cout<<map_[{u,v}];
    if(i!=N-1)cout<<" ";
  }
  cout<<endl;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

template< typename T >
T binomial(int64_t N, int64_t K) {
    if(K < 0 || N < K) return 0;
    T ret = 1;
    for(T i = 1; i <= K; ++i) {
        ret *= N--;
        ret /= i;
    }
    return ret;
}

signed main() {
    int N, A, B;
    cin >> N >> A >> B;
    vector<double> v(N);
    map<int, int> count;
    for (int i = 0; i < N; i++) {
        cin >> v[i];
        count[v[i]]++;
    }
    double ans = 0;
    bool check = true;
    sort(v.rbegin(), v.rend());
    int temp = 0, end = 0;
    for (int i = 0; i < A; i++) {
        if (i > 0 && v[i] != v[i - 1]) {
            check = false;
            temp = 0;
        }
        ans += v[i];
        end = v[i];
        temp++;
    }
    ans /= A;
    int C = 0;
    if (check) {
        for (int i = A; i <= min(B, count[end]); i++) {
            C += binomial<int>(count[end], i);
        }
    } else {
        C = binomial<int>(count[end], temp);
    }
    cout << fixed << setprecision(10) << ans << endl;
    cout << C << endl;
}


Measured memory_bytes: 256
L, R = map(int, input().split())
if L + 2018 <= R or L%2019 > R%2019:
    print(0)
else:
    ans = 2018
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(ans, i*j%2019)
    print(ans)


Measured memory_bytes: 40940
#include<iostream>
#include<cstdio>
#include<cstring>

const int N=301000;

int s[N];
int n,A,B;
int tot;

int L,R;

void dec()
{
	int x=L+B-1;L=x+1;
	if(x>R)x=R;
	for(int tmp=B;tot<n && tmp--;)s[++tot]=x,x--;
}
void inc()
{
	int x=R-A+1;R=x-1;
	if(x<L)x=L;
	for(int tmp=A;tot<n && tmp--;)s[++tot]=x,x++;
}

bool solve()
{
	if(A+B>n+1)return 0;

	tot=0;
	while(tot<n)
	{
		if(!B)return 0;
		dec(),A--;
		if(A<0)return 0;
		if(tot==n)break;

//		printf("%d--%d\n",L,R);

		if(!A)return 0;
		inc(),B--;
		if(B<0)return 0;

//		printf("%d--%d\n",L,R);
	}
	
	return 1;
}

int main()
{
	scanf("%d%d%d",&n,&A,&B);
	L=1,R=n;
	if(!solve()){printf("-1\n");return 0;}

	for(int i=1;i<=n;i++)
		printf("%d ",s[i]);
	printf("\n");

	return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll k; cin>>k;
	ll x; cin>>x;
	if(500*k>=x){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256