akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N = 20;
const int mod = 1e9+7;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll llINF = 0x3f3f3f3f3f3f3f3f;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
inline bool read(ll &num) {
  char in;bool IsN=false;
  in=getchar();
  if(in==EOF) return false;
  while(in!='-'&&(in<'0'||in>'9')) in=getchar();
  if(in=='-'){ IsN=true;num=0;}
  else num=in-'0';
  while(in=getchar(),in>='0'&&in<='9'){
      num*=10,num+=in-'0';
  } 
  if(IsN) num=-num;
  return true;
}
int a[N];
int x[N][N],y[N][N];
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    for(int j=1;j<=a[i];j++){
      cin>>x[i][j]>>y[i][j];
    }
  }
  int ans=0;
  for(int i=0;i<(1<<n);i++){
    set<int> all[20];
    int cnt=0;
    bool flag=0;
    for(int j=0;j<n;j++){
      if((i>>j)&1){
        ++cnt;
        all[j].insert(1);//j为1
        for(int k=1;k<=a[j];k++){
          all[x[j][k]-1].insert(y[j][k]);
        }
      }else{
        all[j].insert(0);
      }
    }
    for(int j=0;j<20;j++){
      if(all[j].size()>=2){
        flag=1;break;
      }
    }
    if(!flag){
       ans=max(ans,cnt);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
//Love and Freedom.
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 20021225
#define N 5010
#define mdn 1000000007
using namespace std;
int read()
{
	int s=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return f*s;
}
struct edge{int to,lt;}e[N<<1];
int in[N],cnt,sz[N],f[N],g[N][N],tmp[N],n;
void add(int x,int y)
{
	e[++cnt].to=y; e[cnt].lt=in[x]; in[x]=cnt;
	e[++cnt].to=x; e[cnt].lt=in[y]; in[y]=cnt;
}
void init()
{
	f[0]=1;
	for(int i=2;i<=n;i+=2)	f[i]=1ll*f[i-2]*(i-1)%mdn;
}
void upd(int &x,int y){x+=x+y>=mdn?y-mdn:y;}
void dfs(int x,int fr)
{
	sz[x]=1; g[x][1]=1;
	for(int i=in[x];i;i=e[i].lt)
	{
		int y=e[i].to; if(y==fr)	continue; dfs(y,x);
		memcpy(tmp,g[x],sz[x]+1<<2); memset(g[x],0,sz[x]+1<<2);
		for(int sy=0;sy<=sz[y];sy++)	for(int sx=0;sx<=sz[x];sx++)
			upd(g[x][sx+sy],1ll*g[y][sy]*tmp[sx]%mdn);
		sz[x]+=sz[y];
	}
	for(int i=1;i<=sz[x];i++)	upd(g[x][0],1ll*(mdn-1)*g[x][i]%mdn*f[i]%mdn);
}
int main()
{
	n=read(); for(int i=1;i<n;i++)	add(read(),read()); init();
	dfs(1,1); printf("%d\n",mdn-g[1][0]);
	return 0;
}

Measured memory_bytes: 97152
#include<iostream>
using namespace std;
int p, q; int gcd(int a, int b) { if (b == 0)return a; return gcd(b, a%b); }
int main() {
    cin >> p >> q; int res = 1; int r = gcd(p, q); q /= r;
    for (int i = 2; i*i <= q; i++) {
        if (q%i == 0) { res *= i; while (q%i == 0)q /= i; }
    }
    if (q >= 2)res *= q;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  rep(i, n - 1) if(a[i] == a[i + 1]) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, num, digit, rev = 0;
    cin >> num;
    n = num;
    do
    {
        digit = num % 10;
        rev = (rev * 10) + digit;
        num = num / 10;
    } while (num != 0);
    if (n == rev)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
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 main(){
 ll n,m ,k; cin>>n>>m>>k ;
 vector<ll> A(n) ,B(m) ; 
 rep(i,n) cin>>A[i] ;
 rep(i,m) cin>>B[i] ;
 ll ans=0 ;

 vector<ll> asum(n+1) ,bsum(m+1) ;
 asum[0]=0 ;bsum[0]=0 ;
 rep(i,n){
      asum[i+1]= asum[i]+A[i] ;
 }
 rep(i,m){
      bsum[i+1]= bsum[i] +B[i] ;
 }
 rep(i,n+1){
     if(asum[i]>k) break ;
     ll now = (i)+(upper_bound(bsum.begin(),bsum.end(),
     k-asum[i])-bsum.begin()) -1 ;
     chmax(ans,now) ;
 }
 cout<<ans<<endl ;
 return 0 ; 
}

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

int p[200001];          // parent node
int a[200001];

int f(int x) {          // find root
    return p[x] = p[x] == x ? x : f(p[x]);
}

void u(int x, int y) {  // unite
    p[f(x)] = f(y);
}

int main() {
	int n, m, ans;
    cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		p[i] = i;       // initialize
	}
	for(int i = 1, x, y; i <= m; i++){
		cin >> x >> y;
		u(x, y);
	}
	for(int i = 1; i <= n; i++){
		if(f(i) == f(a[i])) ans++;
	}
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<int> cost;
vector<int> ans;
vector<vector<int>> G;

void dfs(int node, int from) {
  ans[node] = cost[node];
  if (node != 0)
    ans[node] += ans[from];
  for (auto g : G[node]) {
    if (g == from)
      continue;
    dfs(g, node);
  }
}

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

  int n, q;
  cin >> n >> q;
  cost.resize(n);
  ans.resize(n);
  G.resize(n);

  rep(i, 0, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  rep(i, 0, q) {
    int p, x;
    cin >> p >> x;
    p--;
    cost[p] += x;
  }

  dfs(0, -1);
  rep(i, 0, n) {
    if (i > 0)
      cout << " ";
    cout << ans[i];
  }
  cout << endl;
}


Measured memory_bytes: 25080
#include<iostream>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a * b == 3) cout << 2 << endl;
    else if(a * b == 2) cout << 3 << endl;
    else if(a * b == 6) cout << 1 << endl;
    return 0;
}

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

using namespace std;

int main()
{
    string s;
    long long int ans = 1;
    int n;
    int al[26] = {};

    cin >> n >> s;

    for (int i = 0; i < s.size(); i++) {
        al[s[i]-'a']++;
    }

    for (int i = 0; i < 26; i++) {
        ans *= al[i]+1;
        ans %= 1000000007;
    }

    cout << ans-1 << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<vector<int>> tree(n+1);
	for(int i=0;i<n-1;++i){
		int a,b;
		cin>>a>>b;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	queue<pair<int,int>> que;
	int l,r,dst;
	vector<int> cost(n+1,n*2);
	cost[l=1]=0;
	vector<bool> visited(n+1,false);
	que.push(make_pair(l,cost[l]));
	while(!que.empty()){
		pair<int,int> p=que.front();
		que.pop();
		visited[p.first]=true;
		if(cost[l]<p.second)l=p.first;
		for(auto c:tree[p.first]){
			if(!visited[c]){
				que.push(make_pair(c,p.second+1));
				cost[c]=min(cost[c],p.second+1);
			}
		}
	}
	cost = vector<int>(n+1,n*2);
	cost[r=l]=0;
	visited = vector<bool>(n+1,false);
	que.push(make_pair(l,cost[l]));
	while(!que.empty()){
		pair<int,int> p=que.front();
		que.pop();
		visited[p.first]=true;
		if(cost[r]<p.second)r=p.first;
		for(auto c:tree[p.first]){
			if(!visited[c]){
				que.push(make_pair(c,p.second+1));
				cost[c]=min(cost[c],p.second+1);
			}
		}
	}
	vector<bool> dp(cost[r]+1,0);
	dp[0]=true;
	dp[1]=false;
	for(int i=2;i<=cost[r];++i){
		dp[i]=!(dp[i-1]&&dp[i-2]);
	}
	cout<<(dp[cost[r]]?"First":"Second");
	return 0;
}

Measured memory_bytes: 14452
n=int(input())
total=0
mini=101
check=0
for i in range(n):
    s=int(input())
    total+=s
    if s%10!=0 and s<mini:
        mini=s
        check=1
if total%10!=0:
    print(total)
else:
    if check==1:
        print(total-mini)
    else:
        print(0)

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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            //string s = Console.ReadLine();

            // 整数の入力
            //long n = long.Parse(Console.ReadLine());

            // 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long jyoyo = inputLongArray[0] * inputLongArray[1] % 2;

            string result = jyoyo == 0 ? "Even" : "Odd";

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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

int main() {
  int K, A, B, ans;
  cin >> K >> A >> B;
  
  ans = ceil((double)A / (double)K);
  if(ans*K <=B){
    cout << "OK";
  }
  else{
    cout << "NG";
  }
}
 

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int n, k;
void update(vll &a) {
    vll sum(n, 0);
    rep(i, n) {
        ll l = max(0ll, i-a[i]);
        ll r = min((ll)(n-1), i+a[i]);
        sum[l]++;
        if (r < n-1) sum[r+1]--;
    }
    rep(i, n-1) sum[i+1] += sum[i];
    a = sum;
}

int main() {
    cin >> n >> k;
    vll a(n);
    rep(i, n) cin >> a[i];

    rep(i, min(k, 100)) update(a);
    out_ary(a);
    return 0;
}

Measured memory_bytes: 6372
#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; }

ll bur[55], pat[55];

ll solve(int n, ll x){
    if(x == 1) return (n == 0 ? 1 : 0);
    else if(1 < x && x <= 1 + bur[n-1]) return solve(n-1, x-1);
    else if(x == 2 + bur[n-1]) return pat[n-1] + 1;
    else if(2 + bur[n-1] < x && x <= 2 + 2*bur[n-1]) return pat[n-1] + 1 + solve(n-1, x-2-bur[n-1]);
    else if(x == 3 + 2*bur[n-1]) return pat[n-1] * 2 + 1;
    return 0;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll x;
    cin >> n >> x;
    bur[0] = 1;
    pat[0] = 1;
    rep(i,50){
        bur[i+1] = 3 + bur[i] * 2;
        pat[i+1] = 1 + pat[i] * 2;
    }
    ll ans = solve(n, x);
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N, l, r, sum=0;
  cin >> N;
  int i=0;
  
  while(i<N){
  	cin >> l >> r;
    sum+=r-l+1;
    i++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#define MAIN 200010
using namespace std;
const long long p=1000000007;
long long fact[MAIN]={1},inv[MAIN]={1};
long long Lucas(long long a,long long m)
{
    long long ans=fact[a];
    ans=(ans*inv[a-m]%p)*inv[m]%p;
    return ans;
}
long long power(long long a,long long b)
{
    long long ans=1;
    while (b)
    {
        if (b&1) ans=(ans*a)%p;
        b=b>>1;
        a=(a*a)%p;
    }
    return ans;
}
int main()
{
    long long h,w,a,b;
    scanf("%lld%lld%lld%lld",&h,&w,&a,&b);
    for (int i=1; i<=200000; i++)
    {
        fact[i]=(fact[i-1]*i)%p;
        inv[i]=power(fact[i],p-2);
    }
    long long ans=0;
    for (long long i=1; i<=w-b; i++)
        ans=(ans+Lucas(a+i-2,i-1)*Lucas(h-a+w-i-1,w-i))%p;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3328
N, T = gets.split.map &:to_i
cusum = [0] * (T+1)
$<.map{|s|
  l, r = s.split.map &:to_i
  cusum[l] += 1
  cusum[r] -= 1
}
sum = 0
p cusum.map{|n|
  sum += n
}.max

Measured memory_bytes: 11368
#pragma comment(linker, "/STACK:102400000,102400000")
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <stdlib.h>
#include <deque>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <complex>
#include <functional>
#include <fstream>
#include <ctime>
#include <stdexcept>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5+5;
const int mod = 1e9+7;
const double eps = 1e-8;
const double pi = asin(1.0)*2;
const double e = 2.718281828459;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}

struct edge {
	double u;
	double v;
	double d;
	edge(double _u = 0, double _v = 0, double _d = 0): u(_u), v(_v), d(_d) {}
	bool operator < (const edge &a) const {
		return d > a.d;
	}
};

int n, m;
int tu, tv;
double ans;
PDD co[maxn];
int pre[maxn];
vector<edge> q;

void init() {
	for (int i = 1; i <= n; ++i) {
		pre[i] = i;
	}
}

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

double caldis(PDD a, PDD b) {
	return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second));
}

int main(int argc, char *argv[]) {
//#ifndef ONLINE_JUDGE
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
//#endif
	read(n); read(m);
	init();
	for (int i = 1; i <= n; ++i) {
		read(co[i].first);
		read(co[i].second);
	}
	for (int i = 1; i <= m; ++i) {
		read(tu); read(tv);
		q.pb(edge(tu, tv, caldis(co[tu], co[tv])));
	}
	sort(q.begin(), q.end());
	ans = 0;
	for (int i = 0; i < int (q.size()); ++i) {
		int x = find(q[i].u), y = find(q[i].v);
		if (x != y) {
			pre[x] = y;
		}
		else {
			ans += q[i].d;
		}
	}
	printf("%.3lf\n", ans);
//#ifndef ONLINE_JUDGE
//	fclose(stdin);
//	fclose(stdout);
//	system("gedit out.txt");
//#endif
    return 0;
}



Measured memory_bytes: 3876
import sys
from collections import deque
INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())
sys.setrecursionlimit(10 ** 9)


def main():
    H, W = MAP()
    dungeon = []
    walls = 0

    for _ in range(H):
        line = [0 if i == "." else 1 for i in INPUT()]
        walls += line.count(1)
        dungeon.extend([line])

    queue = deque([(0, 0, 1)])
    while queue:
        y, x, cnt = queue.popleft()
        if y == H-1 and x == W-1:
            print(H*W - walls - cnt)
            exit()
        for row, col in [(y, x-1), (y-1, x), (y, x+1), (y+1, x)]:
            if 0 <= row < H and 0 <= col < W and not dungeon[row][col]:
                dungeon[row][col] = 2
                queue.append((row, col, cnt+1))

    print(-1)


if __name__ == '__main__':
    main()


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

using namespace std;

int a[1000000];

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    for(int i=0;i<n-1;++i){
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    for(int i=1;i<n;++i){
        int v=a[i];
        int j=i-1;
        while(j>=0 && a[j]>v){
            a[j+1]=a[j];
            --j;
            a[j+1]=v;
            
            }
            for(int p=0;p<n-1;++p){
                cout << a[p] << " ";
            } 
        cout << a[n-1] << endl;
    }
}
    



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
typedef long long int ll;
#define int long long int
typedef vector<ll> vi;
typedef pair<int, int> ii; typedef vector<ii> vii;
#define INF numeric_limits<ll>::max()
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
ll powmod(ll a,ll l, ll md){ll res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
ll binpow(ll a,ll l){ll res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
ll invmod(ll a, ll md){return powmod(a,md-2,md);}
const ll inf = 0xFFFFFFFFFFFFFFFL;


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll n, a, b, c, d;
	cin>>n>>a>>b>>c>>d;
	string s;
	cin>>s;
	a--;b--;c--;d--;
	bool flag = true;
	if ((a<b && b<c && c<d)|| (a<c && c<b && b<d)){
		for (ll i = a+1 ; i<c;i++){
			if (s[i] == '#' && s[i+1]=='#'){
				flag = false;
				break;
			}

		}
		for (ll i = b+1 ; i<d;i++){
			if (s[i] == '#' && s[i+1]=='#'){
				flag = false;
				break;
			}

		}

	}
	else{
		for (ll i = a+1 ; i<c;i++){
			if (s[i] == '#' && s[i+1]=='#'){
				flag = false;
				break;
			}

		}
		if (flag){
			bool flag1 = false;
			for (ll i = b ; i<=d;i++){
				if (s[i-1] == '.' && s[i+1]=='.'&& s[i]== '.'){
					flag1 = true;
					break;
				}
			}
			if (flag1==false)flag = false;

		}


	}
	if (flag)cout<<"Yes"<<"\n";
	else cout<<"No"<<"\n";
    return 0;
}
 

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

typedef long long ll;

ll dp[101][100001], w[100001], v[100001];

ll knapsack(ll i, ll j)
{
	if (dp[i][j] != -1)
	{
		return dp[i][j];
	}

	if ((i == 0) || (j == 0))
		return (dp[i][j] = 0);
	else if (w[i] > j)
		return dp[i][j] = knapsack(i-1, j);
	else
		return dp [i][j] = max(v[i] + knapsack(i-1, j-w[i]), knapsack(i-1, j));
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll n, m, i, j;
	cin >> n >> m;
	memset(dp, -1, sizeof(dp));

	for (i = 1; i < n+1; i++)
		cin >> w[i] >> v[i];

	// for (i = 1; i < n+1; i++)
	// 	cin >> v[i];

	knapsack(n, m);

	cout << dp[n][m] << endl;

	return 0;
}

Measured memory_bytes: 79232
D, G = [int(_) for _ in input().split()]
PC = [tuple(int(_) for _ in input().split()) for i in range(D)]

from itertools import product

INF = 10**20

def calc(es):
    r = 0
    last_row = None
    result = 0
    for i, e, pc in zip(range(D), es, PC):
        d = (i+1) * 100
        if e:
            r += d * pc[0] + pc[1]
            result += pc[0]
        else:
            last_row = d, pc[0]
    if r >= G:
        return result
    if last_row:
        n = (G - r + last_row[0] - 1) // last_row[0]
        if 1 <= n < last_row[1]:
            return result + n
    return INF

result = min(calc(pat) for pat in product((0, 1), repeat=D))

print(result)


Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
 int n,K;
 cin>>n>>K;
 int i,A[n];
 for(i=0;i<n;i++)
 {
     cin>>A[i];
 }
 double ans=0.0;
 vector<double> vec;
 double r=0.5;
 for(i=0;i<n;i++)
 {
     double p=(double)(A[i]+1);
     p*=r;
     vec.push_back(p);
 }
 double s=0;
 for(i=0;i<K;i++)
 {
     s+=vec[i];
 }
 ans=max(ans,s);
 for(i=1;i<n-K+1;i++)
 {
     s+=vec[i+K-1];
     s-=vec[i-1];

     ans=max(ans,s);
 }
 cout<<setprecision(10)<<fixed<<ans;
}


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

using namespace std;

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	
	if((b-a)%2==0){
		cout<<"Alice"<<endl;
	}
	else{
		cout<<"Borys"<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

bool m[4][4];
int x[4],y[4];
int dfs(int cnt){
    int res=0;
    if(cnt>=16) return 1;
    int x1=cnt%4,y1=cnt/4;
    if(m[y1][x1]) return dfs(cnt+1);
    rep(i,4){
        if(x1+x[i]>=0&&x1+x[i]<4&&y1+y[i]>=0&&y1+y[i]<4&&!m[y1+y[i]][x1+x[i]]){
            m[y1][x1]=m[y1+y[i]][x1+x[i]]=true;
            res +=dfs(cnt+1);
            m[y1][x1]=m[y1+y[i]][x1+x[i]]=false;
        }
    }
    return res;
}
int main(){
    while(cin>>x[0],x[0]<5){
        cin>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]>>x[3]>>y[3];
        memset(m,0,sizeof(m));
        int ans=dfs(0);
        cout<<ans<<endl;
    }
    return 0;
}

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

bool isprime(long long int val) {
    if (val <= 1)return false;
    for (long long int i = 2; i*i <= val; i++) {
        if (val%i == 0LL)return false;
    }
    return true;
}


int main(){
    int n;
    cin>>n;
    vector<int> ans;
    for(int i=2;i<55556;i++){
        if(isprime(i) && i%5==1){
            ans.push_back(i);
        }
    }

    for(int i=0;i<n;i++){
        cout<<ans[i]<<" ";
    }
    
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

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

    int64 ans = a * c;
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);

    cout << ans << endl;
}


Measured memory_bytes: 3192
//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << (x) << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}

	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

int main() {
	string s;
	cin >> s;
	int ans = 0;
	for (char c : s) ans += c - '0';
	for (ui i = 0; i < s.length(); i++) {
		if (s[i] == '0') continue;
		int now = s[i] - '0' - 1;
		for (ui j = 0; j < i; j++)
			now += s[j] - '0';
		now += 9 * (s.length() - i - 1);
		ans = max(ans, now);
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rint register int 
#define ll long long 
using namespace std;
int N,A[1010000];
inline bool cmp(int i,int j){return i>j;}
int main() {
	cin>>N;
	for(rint i=1;i<=N;++i) cin>>A[i];
	sort(A+1,A+N+1,cmp);
	int pos=0;
	for(rint i=1;i<=N+1;++i){
		if(A[i]<i) {
			pos=i-1;
			int x=A[pos]-pos;
			int y=0;
//			cout<<pos<<endl;
			for(rint x=pos+1;x<=N;++x) if(A[x]>=pos) ++y;
			if((x&1)||(y&1)) {
				cout<<"First\n";
			}
			else cout<<"Second\n";
			exit(0);
		}
	}
	return 0;
}

Measured memory_bytes: 4024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    string ans;
    if(s<t) ans = "Yes";
    else ans = "No";

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9


int main()
{
    fastio;
    int n;
    cin >> n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
        cin >> v[i];
    map<int,int>m;
    for(int i=0;i<n;i++)
        m[v[i]]+=1;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(v[i]==1)
        {
            if(m[v[i]]<2)
                ans+=1;
            continue;
        }
        if(m[v[i]]>1)
            continue;
        int f=0;
        for(int j=2;j<=sqrt(v[i]) and f==0;j++)
        {
            if(v[i]%j==0)
            {
                if(m.find(j)!=m.end() or m.find(v[i]/j)!=m.end())
                    f=1;
            }
        }
        if(m.find(1)!=m.end())
            f=1;
        if(f==0)
            ans+=1;
    }
    cout << ans << endl;
}

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

using namespace std;

#define mods 1000000000+7;
typedef long long ll; 

int main(){

	int n;
	cin >> n;
	ll power = 1;
	for(int i=1; i<=n;++i){
		power*=i;
		power%=mods;
	}
	cout << power << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<string>
#include<iterator>
#include<iomanip>
#include<cmath>
#include<map>
#include<string.h>
#include<algorithm>

using namespace std;
void ll(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(0);
}

int main() {

	ll();
	 
	int a, b, c;
	cin >> a >> b >> c;
	if ((a != b&&a==c)||(a==b&&a!=c)||(b==c&&c!=a))
		cout << 2 << endl;
	else if (a != b&&a != c&&b != c)
		cout << 3 << endl;
	else if (a == b&&a == c)
		cout << 1 << endl;
	

}





Measured memory_bytes: 3620
#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
using ll = long long;

int main()
{
	int n,k;
	cin >> n >> k;
	ll ans = 0;
	vector<vector<int>> a(n);
	vector<pair<int,int>> vp(n);
	for(int i = 0;i<n;i++)
	{
		cin >> vp[i].first >> vp[i].second;
	}
	sort(vp.begin(),vp.end(),[&](auto a,auto b){return a.second>b.second;});
	map<int,int> mp;
	priority_queue<int,vector<int>,greater<int>> pq;
	ll sum = 0;
	ll v = 0;
	for(int i = 0;i<k;i++)
	{
		sum+= vp[i].second;
		if(mp.count(vp[i].first))
		{
			pq.push(vp[i].second);
		}
		mp[vp[i].first]++;
	}
	v = mp.size();
	ans = v*v+sum;
	for(int i = k;i<n;i++)
	{
		if(mp.count(vp[i].first)==0&&pq.size()>0)
		{
			sum -= pq.top();
			pq.pop();
			mp[vp[i].first]=1;
			v++;
			sum += vp[i].second;
			ans = max(ans,v*v+sum);
			
		}
	}
	cout<<ans<<endl;
}


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

int main() {
  int n;
  cin >> n;
  int n1=n/100;
  int n2=n%100;
  if(0<n1&&n1<13) {
    if(0<n2&&n2<13) {
      cout << "AMBIGUOUS" << endl;
    }
    else {
      cout << "MMYY" << endl;
    }
  }
  else {
    if(0<n2&&n2<13) {
      cout << "YYMM" << endl;
    }
    else {
      cout << "NA" << endl;
    }
  }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment (linker, "/stack:256000000")

#include <iostream>
#include <cstdio>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <cmath>
#include <cassert>
#include <ctime>
#include <memory.h>

using namespace std;

#define fo(a,b,c) for(int a=(b);a<(c);a++)
#define fd(a,b,c) for(int a=(b);a>=(c);a--)
#define fi(a) fo(i,0,(a))
#define fj(a) fo(j,0,(a))
#define fk(a) fo(k,0,(a))
#define _(a,b) memset((a),(b),sizeof(a))
#define __(a) memset((a),0,sizeof(a))
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#ifdef _DEBUG
#define dbg(...) {fprintf(stderr, __VA_ARGS__);fflush(stderr);}
#define dbgx(x) {cerr << #x << " = " << (x) << endl;}
#else
#define dbg(...) {}
#define dbgx(x) {}
#endif

typedef long long lint;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int INF = 1000000000;
const lint LINF = 4000000000000000000LL;
const double eps = 1e-9;

void prepare()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
}

const int maxn = 10100;

int n, m;
int a[maxn], dp[maxn];
vector<int> sums[2][maxn];

void read()
{
	scanf("%d%d", &n, &m);
	fi(n)
		scanf("%d", &a[i]);
}

void go(int sid)
{
	__(dp);
	dp[0] = 1;
	sums[sid][0].pb(0);
	fi(n)
	{
		fd(j, m, 0)
		{
			if (dp[j])
				dp[j + a[i]] = 1;
		}
		fj(m + 1)
		{
			if (dp[j])
				sums[sid][i + 1].pb(j);
		}
	}
}

bool solve()
{
	sort(a, a + n);
	fi(n)
	{
		if (a[i] >= m)
		{
			n = i;
			break;
		}
	}
	go(0);
	reverse(a, a + n);
	go(1);
	reverse(a, a + n);
	int res = 0;
	fi(n)
	{
		int sl = i, sr = n - i - 1;
		int l = 0, r = sz(sums[1][sr]) - 1;
		int lb = m - a[i];
		bool ok = false;
		while (true)
		{
			if (l >= sz(sums[0][sl]) || r < 0)
				break;
			int ss = sums[0][sl][l] + sums[1][sr][r];
			if (ss >= m)
				r--;
			else if (ss < lb)
				l++;
			else
			{
				ok = true;
				break;
			}
		}
		if (!ok)
			res++;
	}
	printf("%d\n", res);
	return false;
}

int main()
{
	prepare();
	read();
	while (solve());
	return 0;
}

Measured memory_bytes: 178432
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;


signed main() {
  int n;
  cin>>n;
  int ans=n+1;
  for(int i=1;i*i<=n;i++){
    if(n%i==0){
      ans=min(ans,i+ n/i);
    }
  }
  cout<<ans-2;
  return 0;
}


Measured memory_bytes: 256
use std::cmp::max;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let v:Vec<Vec<usize>> = (0..n).map(|_| vec![read(), read(), read()]).collect();
    let mut dp = vec![vec![0; 3]; n+1];
    for i in 0..n {
        for j in 0..3 {
            for k in 0..3 {
                if j == k {
                    continue;
                }
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + v[i][k]);
            }
        }
    }

    let mut ans = 0;
    for i in 0..3 {
        ans = max(ans, dp[n][i]);
    }
    println!("{}", ans);
}


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


int main(){
    int N;
    cin >> N;
    N %= 100;
    N %= 10;
    if(N==3)
        cout << "bon" << endl;
    else if(N==0 || N==1 || N==6 || N==8)
        cout << "pon" << endl;
    else
        cout << "hon" << endl;

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if(a<=8 && b<=8) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int mu=1000000007,N=1005;
int p[N],inv[N],n,a,b,c,d,dp[N];
int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=x*1ll*x%mu)
		if (y&1) ans=ans*1ll*x%mu;
	return ans;
}
int C(int x,int y){
	return 1ll*p[x]*inv[y]%mu*inv[x-y]%mu;
}
int main(){
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	p[0]=1;
	for (int i=1;i<=n;i++) p[i]=p[i-1]*1ll*i%mu;
	inv[n]=ksm(p[n],mu-2);
	for (int i=n;i>=1;i--) inv[i-1]=inv[i]*1ll*i%mu;
	int now=0;
	dp[0]=1;
	for (int i=a;i<=b;i++){
		for (int j=n-i,rest=i;j>=0;j--,rest++)
			for(int k=c,t=ksm(inv[i],c);k<=d && j+k*i<=n;k++,t=t*1ll*inv[i]%mu)
				dp[j+k*i]=(dp[j+k*i]+dp[j]*1ll*t%mu*p[rest]%mu*inv[rest-k*i]%mu*inv[k]%mu)%mu;
	}
	printf("%d\n",dp[n]);
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    rep(i, N) {
        int a, b, c;
        cin >> a >> b >> c;
        A[i] = a, B[i] = b, C[i] = c;
    }

    vector<vector<ll>> dp(N, vector<ll>(3, 0));
    dp[0][0] = A[0], dp[0][1] = B[0], dp[0][2] = C[0];

    for (int i = 1; i < N; i++) {
        dp[i][0] = max(dp[i - 1][1] + A[i], dp[i - 1][2] + A[i]);
        dp[i][1] = max(dp[i - 1][0] + B[i], dp[i - 1][2] + B[i]);
        dp[i][2] = max(dp[i - 1][0] + C[i], dp[i - 1][1] + C[i]);
    }

    ll res = max(max(dp[N - 1][0], dp[N - 1][1]), dp[N - 1][2]);
    cout << res << endl;
}

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

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

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  int N = s.length();
  s.push_back('R');
  int rcount = 0;
  int lcount = 0;
  vector<int> v(N+1);
  rep(i,s.length()){
    v[i] = 0;
    if(s[i] == 'R'){
      if(lcount != 0){
        v[i-lcount] = (lcount+rcount)/2;
        v[i-lcount-1] = (lcount+rcount)/2;
        if((lcount+rcount)%2 == 1){
          bool lup = true;
          if(lcount>rcount) lup = !lup;
          if(max(lcount,rcount)%2 == 1) lup= !lup;
          if(lup)++v[i-lcount];
          else ++v[i-lcount-1];
        }
        lcount = 0;
        rcount = 0;
      }
      ++rcount;
    }else ++lcount;
  }
  rep(i,N) cout << v[i] SPF;
  cout << endl;
  return 0;
}


Measured memory_bytes: 1104
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n >> k;
  vi a(n),b(n);
  REP(i,n) cin>>a[i];

  sort(a.begin(), a.end());
  for(ll i=0;i<k;i++){
    ans+=a[i];
  }

  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3640
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let a: Vec<Vec<u8>> = (0..n).map(|_| (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect()).collect();
    let mut dp = vec![0; 1 << n];
    dp[0] = 1;
    const MOD: u64 = 1_000_000_007;
    for i in 1usize..(1 << n) {
        let x = i.count_ones() as usize - 1;
        for j in 0..n {
            if (i >> j) & 1 == 1 && a[x][j] == 1 {
                dp[i] += dp[i ^ (1 << j)];
            }
        }
        dp[i] %= MOD;
    }
    println!("{}", dp[(1 << n) - 1]);
}

fn main() {
    run();
}

Measured memory_bytes: 20732
#include<stdio.h>
 
int main(void){
    int dice[6],q,i;
    char c;
     
    for(i=0;i<6;i++){
        scanf("%d",&dice[i]);
    }
     
    scanf("%d",&q);
    for(i=0;i<q;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        if((x==dice[5] && y==dice[4])||(x==dice[4] && y==dice[0])||(x==dice[0] && y==dice[1])||(x==dice[1] && y==dice[5])){
            printf("%d\n",dice[2]);
        }else if((x==dice[0] && y==dice[2])||(x==dice[2] && y==dice[5])||(x==dice[5] && y==dice[3])||(x==dice[3] && y==dice[0])){
            printf("%d\n",dice[4]);
        }else if((x==dice[5] && y==dice[1])||(x==dice[1] && y==dice[0])||(x==dice[0] && y==dice[4])||(x==dice[4] && y==dice[5])){
            printf("%d\n",dice[3]);
        }else if((x==dice[0] && y==dice[3])||(x==dice[3] && y==dice[5])||(x==dice[5] && y==dice[2])||(x==dice[2] && y==dice[0])){
            printf("%d\n",dice[1]);
        }else if((x==dice[2] && y==dice[1])||(x==dice[1] && y==dice[3])||(x==dice[3] && y==dice[4])||(x==dice[4] && y==dice[2])){
            printf("%d\n",dice[5]);
        }else{
            printf("%d\n",dice[0]);
        }
    }
    return 0;
}


Measured memory_bytes: 2056
h,w=map(int,input().split())
s=[input() for _ in range(h)]
for i in range(h):
    ans=""
    for j in range(w):
        if(s[i][j] =="#"):
            ans+="#"
        else:
            c=0
            for ss in s[max(0,i-1):min(h,i+2)]:
                c+=ss[max(0,j-1):min(w,j+2)].count("#")
            ans+= str(c)
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int n, q;
long long a[100005] = { 0 };
int main() {
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < q; i++) {
		long long x;
		cin >> x;
		long long res = 0;
		int right = 0;
		long long sum = 0;
		for (int left = 0; left < n; left++) {
			while (right < n&&sum+a[right] <= x) {
				sum += a[right];
				right++;
			}
			res += (right - left);
			if (right == left) right++;
			else sum -= a[left];
		}
		cout << res << endl;
	}
	return 0;
}


Measured memory_bytes: 3860
n=int(input())
str=input()
count=str.count("R")*str.count("G")*str.count("B")
count0=0
for i in range(0,n-2):
    for j in range(i+1,int((n+i-1)/2)+1):
        k=2*j-i
        if str[k]!=str[i] and str[k]!=str[j] and str[i]!=str[j]:
            count0=count0+1
print(count-count0)

Measured memory_bytes: 9188
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#include <cassert>
#define rep(i, x) for (int i = 0; i < (x); ++i)
#define rng(i, x, y) for (int i = (x); i < (y); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
void solve();
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solve();
    return 0;
}


// Main Code
void solve() {
    ll x, y;
    cin >> x >> y;
    if (x % y) cout << x << "\n";
    else cout << -1 << "\n";
    return;
}


Measured memory_bytes: 3612
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        TreeMap<Integer,Integer>dic=new TreeMap<>();
        Integer a[]=new Integer [N];
        for(int i=0;i<N;i++){
            a[i]=sc.nextInt();
            dic.put(a[i],i+1);
        }
        for(Integer value:dic.values()){
            System.out.println(value);
        }
    }
}


Measured memory_bytes: 69400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define mod 1000000007
int n,m,k;
int main(){
	cin>>n>>m>>k;
	rep(i,n+1)rep(j,m+1){
		if(i*j+(n-i)*(m-j)==k){
			puts("Yes");return  0;
		}
	}
	puts("No");
}

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

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

int main() {
  int n;
  string S;
  cin >> n >> S;
  if(S.size()<=n) cout << S << endl;
  else cout << S.substr(0,n) << "..." << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    ll a, b;
    char p;
    cin >> a >> p >> b;

    if(p == '+'){
        cout << a + b;
    }else{
        cout << a - b;
     }

    
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int x;
	cin >> x;
	if (x >= 30)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>

int main()
{
  int r,c,x,sum,i,j;
  int data[101][101];
  scanf("%d",&r);
  scanf("%d",&c);

  for (i=0;i<r;i++){
    sum=0;
    for (j=0;j<c;j++){
      scanf("%d",&x);
      data[i][j]=x;
      sum+=x;
    }
    data[i][c]=sum;
  }

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

  for (i=0;i<=r;i++){
    for (j=0;j<c;j++){
      printf("%d ",data[i][j]);
    }
    printf("%d\n",data[i][j]);
  }

  return 0;
}




Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>X(3);
  for(int i = 0; i < 3; i++){
    cin >> X.at(i) ;
  }
  sort(X.begin(),X.end());
  if(X.at(0) == X.at(1) && X.at(1) == 5 && X.at(2) == 7){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	/**
	 * ベクトルと行列の積を求める
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();	//行数
		int m = scan.nextInt();	//列数
		int[][] a = new int[n][m];	//行列A
		//行列Aへ入力された数字を格納する
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				a[i][j] = scan.nextInt();
			}//for
		}//for
		//列ベクトルbへ入力された数字を格納する
		int[] b = new int[m];
		for(int j = 0; j < m; j++){
			b[j] = scan.nextInt();
		}//for
		//計算と出力
		for(int i = 0; i < n; i++){
			int sum = 0;
			for(int j = 0; j < m; j++){
				sum += a[i][j] * b[j];
			}//for
			System.out.println(sum);
		}//for
	}
}

Measured memory_bytes: 31860