akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

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

    int cnt = 0;
    while (true) {
        if (a <= 0 || c <= 0) break;
        if (cnt % 2) a -= d;
        else c -= b;
        cnt++;
    }

    // cout << a << " " << c << endl;
    if (a > c) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define repeat(i,a,b) for(int i=(a),_=(b);i<_;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,_=(a);i>=_;i--)
#define mst(a,x) memset(a,x,sizeof(a))
#define vector basic_string
#define fi first
#define se second
#ifndef qwq
int cansel_sync=(ios::sync_with_stdio(0),cin.tie(0),0);
#endif
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=100010; const double err=1e-11; typedef long long ll; const int inf=~0u>>2; const ll INF=~0ull>>2; ll read(){ll x; if(scanf("%lld",&x)==-1)exit(0); return x;} typedef double lf; typedef long double llf; const lf pi=acos(-1.0); lf readf(){lf x; if(scanf("%lf",&x)==-1)exit(0); return x;} template<typename T> T sqr(const T &x){return x*x;} typedef pair<int,int> pii; template<typename A,typename B> ostream &operator<<(ostream &o,const pair<A,B> &x){return o<<'('<<x.fi<<','<<x.se<<')';}
const int mod=(1?1000000007:998244353); ll mul(ll a,ll b,ll m=mod){return a*b%m;} ll qpow(ll a,ll b,ll m=mod){ll ans=1; for(;b;a=mul(a,a,m),b>>=1)if(b&1)ans=mul(ans,a,m); return ans;} ll getinv(ll v,ll m=mod){return qpow(v,m-2,m);}
//#define int ll
string s;
signed main(){
	cin>>s;
	cout<<(s.find('7')!=-1?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 3672
#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=5001*5001;
int gA,sA,bA;
int gB,sB,bB;
ll f[N];
int main()
{
	int n;init(n);
	init(gA),init(sA),init(bA);
	init(gB),init(sB),init(bB);
	for(int i=0;i<=n;++i) {
		if(i+gA<=n) f[i+gA]=max(f[i+gA],f[i]+gB);
		if(i+sA<=n) f[i+sA]=max(f[i+sA],f[i]+sB);
		if(i+bA<=n) f[i+bA]=max(f[i+bA],f[i]+bB);
	}ll m=0;
	for(int i=0;i<=n;++i) m=max(m,f[i]+n-i);
	Set(f,0);n=m;
	for(int i=0;i<=n;++i) {
		if(i+gB<=n) f[i+gB]=max(f[i+gB],f[i]+gA);
		if(i+sB<=n) f[i+sB]=max(f[i+sB],f[i]+sA);
		if(i+bB<=n) f[i+bB]=max(f[i+bB],f[i]+bA);
	}
	ll ans=0;
	for(int i=0;i<=n;++i) ans=max(ans,f[i]+n-i);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 195584
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
vector<pair<int,int>> hen[100000];
int iro[100000]={};

signed main() {
int a;string s;
cin>>a>>s;
if(a>=3200)cout<<s;
else cout<<"red";



return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int a[200010];
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi(),M=gi();
	for(int i=1;i<=n*2;++i)a[i]=gi();
	std::sort(a+1,a+n*2+1);
	int l=0,r=n,mid;
	while(l<r){
		mid=(l+r>>1)+1;
		bool flg=1;
		for(int i=0;i<mid;++i)flg&=(a[2*n-i]+a[(n-mid)*2+1+i])>=M;
		if(flg)l=mid;else r=mid-1;
	}
	int ans=0;
	for(int i=0;i<l;++i)cxk(ans,a[2*n-i]+a[(n-l)*2+1+i]-M);
	for(int i=0;i<n-l;++i)cxk(ans,a[i+1]+a[(n-l)*2-i]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
// #include<stack>
// #include<queue>
using namespace std;
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2;
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
// vector<vector<ll>> vec(100,vector<ll>(100));
int main(){
  ll n;
  cin >> n;
  cout << n * (n-1) / 2;
}


Measured memory_bytes: 256
import math
n = int(input())
f_dict = dict()
n_sqrt = int(math.sqrt(n))
for x in range(1,n_sqrt+1):
    for y in range(1,n_sqrt+1):
        for z in range(1,n_sqrt+1):
            f_dict[x*(x+y+z)+y*(y+z)+z*z] = f_dict.get(x*(x+y+z)+y*(y+z)+z*z,0) + 1

for i in range(1,n+1):
    print(f_dict.get(i,0))

Measured memory_bytes: 11456
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = map(int, readline().split())
    s = input()
    t = [0] * (n + 1)

    cur = n
    for i in range(n, -1, -1):
        if s[i] == "0":
            cur = i
            t[i] = cur
        else:
            t[i] = cur

    res = []

    i = n
    while i > 0:
        nx = max(0, i - m)
        if t[nx] == i:
            return print(-1)
        else:
            res.append(i - t[nx])
            i = t[nx]

    print(*res[::-1])


if __name__ == '__main__':
    main()


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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    int n; cin >> n;
    int a[n]; rep(i,0,n) cin >> a[i];

    bool f = false;
    bool neko[101] = {};
    stack<int> st;
    rep(i,0,n){
        if(a[i] > 0 && neko[a[i]] == 0){
            st.push(a[i]);
            neko[a[i]] = 1;
        }else{
            int b = 0;
            if(!st.empty()) b = st.top();

            if(b == -1*a[i]){
                st.pop();
                neko[b] = 0;
            }else{
                cout << i+1 << "\n";
                f = true;
                break;
            }
        }
    }
    if(!f) cout << "OK\n";
}


Measured memory_bytes: 3108
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <climits>
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<ll> seq(n);
    for (int i=0; i<n; ++i) {
        cin >> seq[i];
    }

    vector<ll> lis(n, INT_MAX);
    int ans = 0;
    for (int i=0; i<n; ++i) {
        vector<ll>::iterator pos = lower_bound(lis.begin(), lis.end(), seq[i]);
        *pos = seq[i];
        ans = max(ans, (int)(pos - lis.begin()) + 1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2580
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int d = sc.nextInt();

      if (a*b>c*d) {
        System.out.println(a*b);
      }else{
        System.out.println(c*d);
      }
  }
}


Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    char a[105];
    gets(a);
    int n=strlen(a);
    int s=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]=='C')
        {
            for(int j=i;j<n;j++)
            {
                if(a[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	int k, c = 1;

	cin >> k;
	// vector<int> x(n), y(n);
	int s = 7;
	if (k % 2 == 0 || k%5==0){
		cout << -1 << endl;
		return 0;
	}
	while(s%k != 0){
		s = s%k * 10 + 7;
		c = c+1;
	}

	cout << c << endl;

	return 0;
}


Measured memory_bytes: 3576
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

const int INF = int(1.05e9);

class SegMax {
	int N;
	vector<int> maxi;
	inline void doit(int k, int x) {maxi[k] = max(maxi[k], x);}
public:
	SegMax(int n) : N(n == 1 ? 1 : 1<<(32 - __builtin_clz(n - 1))), maxi(2*N, 0) {}
	int query(int k) {
		int ans = 0;
		for (k+=N;k>0;k>>=1) ans = max(ans, maxi[k]);
		return ans;
	}

	void fill(int L, int R, int x) {
		for(L+=N,R+=N;L<R;L>>=1,R>>=1){
			if(R&1) doit(--R,x);
			if(L&1) doit(L++,x);
		}
	}
};

class SegRMQ {
	int N;
	vector<pair<int, bool> > datas;//(mini, uniform)
	inline void update(int k) {
		datas[k].first = min(datas[2*k].first, datas[2*k+1].first);
	}
	inline void prop(int k) {
		if (datas[k].second) {
			datas[2*k] = datas[2*k+1] = datas[k];
			datas[k].second = false;
		}
	}
public:
	SegRMQ(const vector<int>& ns) {
		N = ns.size() == 1 ? 1 : 1<<(32 - __builtin_clz(int(ns.size())-1));
		datas.assign(2*N, make_pair(INF, false));
		for (int i = 0; i < int(ns.size()); ++i) {
			datas[i+N].first = ns[i];
		}
		for (int i = N - 1 ; i > 0; --i) update(i);
	}

	int getMin(int L, int R) {
		static int inds[128], len;
		len = 0;
		for(int a=L?(N+L)/(L&-L)/2:0,b=R?((N+R)/(R&-R)-1)/2:0;;b>>=1){
			if(a==b){
				for(;a;a>>=1) inds[len++]=a;
				break;
			}
			if(a>b) swap(a,b);
			inds[len++] = b;
		}
		for(int i=len-1; i>=0; --i) prop(inds[i]);
		int ans = INF;
		for(L+=N,R+=N;L<R;L>>=1,R>>=1){
			if(R&1) ans = min(ans, datas[--R].first);
			if(L&1) ans = min(ans, datas[L++].first);
		}
		return ans;
	}

	void fill(int L, int R, int x) {
		static int inds[128], len;
		len = 0;
		for(int a=L?(N+L)/(L&-L)/2:0,b=R?((N+R)/(R&-R)-1)/2:0;;b>>=1){
			if(a==b){
				for(;a;a>>=1) inds[len++]=a;
				break;
			}
			if(a>b) swap(a,b);
			inds[len++] = b;
		}
		for(int i=len-1; i>=0; --i) prop(inds[i]);
		for(L+=N,R+=N;L<R;L>>=1,R>>=1){
			if(R&1) datas[--R] = make_pair(x,true);
			if(L&1) datas[L++] = make_pair(x,true);
		}
		for(int i=0; i<len; ++i) update(inds[i]);
	}
};

const int MAX_N = int(5e4);
int as[MAX_N], bs[MAX_N], ys[MAX_N], ns[2*MAX_N], ts[MAX_N];

int main() {
	int n; scanf("%d", &n);
	int L = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%d%d%d%d", ts+i, as+i, bs+i, ys+i);
		++bs[i];
		ns[L++] = as[i];
		ns[L++] = bs[i];
	}
	sort(ns, ns + L);
	L = unique(ns, ns+L) - ns;
	for (int i = 0; i < n; ++i) {
		as[i] = lower_bound(ns, ns+L, as[i]) - ns;
		bs[i] = lower_bound(ns, ns+L, bs[i]) - ns;
	}

	SegMax seg(L);
	set<int> ids;
	vector<int> xs(L);
	for (int i = 0; i < L; ++i) {
		ids.insert(i);
	}
	for (int i = 0; i < n; ++i) {
		if (ts[i] == 0) {
			seg.fill(as[i], bs[i], ys[i]);
		}
		else {
			for (set<int>::iterator itr = ids.lower_bound(as[i]); itr != ids.end() && *itr < bs[i]; ids.erase(itr++)) {
				xs[*itr] = seg.query(*itr);
			}
		}
	}
	for (set<int>::iterator itr = ids.begin(); itr != ids.end(); ++itr) {
		xs[*itr] = seg.query(*itr);
	}
	SegRMQ rmq(xs);
	for (int i = 0; i < n; ++i) {
		if (ts[i] == 0 && rmq.getMin(as[i], bs[i]) != ys[i]) {
			puts("NO");
			return 0;
		}
		else if (ts[i] == 1) {
			rmq.fill(as[i], bs[i], ys[i]);
		}
	}
	puts("YES");

	return 0;
}

Measured memory_bytes: 8124
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
int main(){
    vector <long long> v;
    long long a,b,c=0,d=0,e=0,f=0,g=0,i,j,k=1,l=0,r=1,n,m,z,h[600001],p[600001];
    string s,t,x,y;
    double q,u,w;
    cin>>a>>b>>c>>d;
    if(a<=d){
        d-=a;
    }
    else{
        cout<<d;
        stop;
    }
    if(b<=d){
        d-=b;
    }
    else{
        cout<<a;
        stop;
    }
    a-=d;
    cout<<a;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c && c <= b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
} 

Measured memory_bytes: 3608
#include<stdio.h>

int main(void){
  int c1;
  int c5;
  int c10;
  int c50;
  int c100;
  int c500;
  int sum=0;

  scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500);
  sum=1*c1+5*c5+10*c10+50*c50+100*c100+500*c500;
  if(sum>=1000) printf("1\n");
  else printf("0\n");
  return 0;
}



Measured memory_bytes: 2108
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  int n, i;
  int *f;

  scanf("%d", &n);
  f = (int *)malloc(sizeof(int) * (n + 1));

  f[0] = 1;
  f[1] = 1;

  for (i = 2; i <= n; i++) f[i] = f[i-1] + f[i-2];

  printf("%d\n", f[n]);

  return 0;
}

Measured memory_bytes: 596
// 5/28
// 2-5-4 ベルマンフォード
// 類題
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = LONG_MAX;

struct Edge {
    int from;
    int to;
    ll cost;
    Edge(int f, int t, ll c) : from(f), to(t), cost(c) { }
    bool operator<(const Edge& o) const {
        return cost < o.cost;
    }
};
using Graph = vector<Edge>;

vector<bool> negative;

vector<ll> bellman_ford(int N, Graph& es, int s) {
    // 初期化
    vector<ll> d(N, INF);
    d[s] = 0;
    
    // vector<bool> negative(N, false);
    negative.assign(N, false);
    // bool have_negative_loop = false;

    // 辺の緩和を反復
    rep(i, N) {
        for (auto e : es) {
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (i == N - 1) {
                    // have_negative_loop = true;
                    negative[e.to] = true;
                    // break;
                }
            }
            if (negative[e.from]) {
                negative[e.to] = true;
            }
        }
    }

    // ネガティブループが存在する場合は全ての値を-1にする。
    // スタート地点の値でチェックする。
    // if (have_negative_loop) d.assign(N, -1);
    return d;
}

int main() {
    int N;  // 与えられた有向グラフの頂点の数
    int M;  // 同辺の数（辺の重みは負の場合がある）
    cin >> N >> M;

    vector<Edge> es;
    rep(i, M) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--; b--;
        es.push_back(Edge(a, b, -c));
    }

    vector<ll> d;
    d = bellman_ford(N, es, 0);

    // if (d[0] == -1) cout << "inf" << endl;
    if (negative[N - 1]) cout << "inf" << endl;
    else cout << -d[N - 1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n, m, k;
int color[100009], ans[100009];
struct edge {
    int to;
    edge(int to) : to(to) {}
};
vector<edge> G[100009];

int dfs(int s, int c) {
    int num = 0;
    stack<int> st;
    st.push(s);
    color[s] = c;

    while (!st.empty()) {
        int u = st.top();
        st.pop();
        num++;
        for (auto &e : G[u]) {
            if (color[e.to] == -1) {
                color[e.to] = c;
                st.push(e.to);
            }
        }
    }
    return num;
}

int main() {
    cin >> n >> m >> k;
    int a, b, c, d;
    rep(i, m) {
        scanf("%d%d", &a, &b);
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
        ans[a]--, ans[b]--;
    }
    int col = 0;
    fill(color, color + n, -1);
    vector<int> num;
    rep(i, n) {
        if (color[i] == -1) {
            num.push_back(dfs(i, col++));
        }
    }
    rep(i, n) { ans[i] += num[color[i]] - 1; }

    rep(i, k) {
        scanf("%d%d", &c, &d);
        c--, d--;
        if (color[c] == color[d]) {
            ans[c]--, ans[d]--;
        }
    }
    rep(i, n) {
        if (i) printf(" ");
        printf("%d", ans[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 7928
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int fi=n/100;
    int la=n%100;
    if((fi>=1 && fi<=12)&& (la>=1 && la<=12)){
        cout<<"AMBIGUOUS"<<endl;
        return 0;
    }
      else if(fi>=1 && fi<=12){
        cout<<"MMYY"<<endl;
         return 0;
      }
      else if(la>=1 && la<=12){
        cout<<"YYMM"<<endl;
         return 0;
      }
      else{
        cout<<"NA"<<endl;
         return 0;
      }


}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val k = readLine()!!.toInt()

    var answer = 0L

    for (h in 1..k) {
        if (h == 1) {
            answer += k*k
        } else {
            for (i in 1..k) {
                val gcdhi = gcd(h,i)
                if (i == 1) {
                    answer += k
                } else {
                    for (j in 1..k) {
                        answer += gcd(gcdhi, j)
                    }
                }
            }
        }
    }
    println(answer)
}

fun gcd(a: Int, b: Int): Int {
    if (a==1 || b== 1) return 1
    if (a < b) return gcd(b, a)
    if (b == 0) return a
    return gcd(b, a % b)
}

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

using namespace std;

int gcd(int a, int b) {
    int tmp;

    while (b != 0) {
        tmp = b;
        b = a % b;
        a = tmp;
    }
    return a;
}

int main() {

    int k;
    int ans = 0;
    cin >> k;

    for (int i=1; i<=k; i++) {
        for (int j=1; j<=k; j++) {
            for (int n=1; n<=k; n++) {
                ans += gcd(gcd(i, j), n);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
N, M = gets.chomp.split(" ").map(&:to_i)
a = []
M.times{
  a << gets.to_i
}
CD = 10 ** 9 + 7

Fib = [1, 1]
def fibonacci(n)
  return 0 if n == -1
  return Fib[n] if Fib.size > n
  (Fib.size..n).each{|i|
    tmp = Fib[i-2] + Fib[i-1]
    tmp %= CD if tmp > CD
    Fib << tmp
  }
  return Fib[n]
  
end

a << N + 1
ls = 0
ans = 1
a.each{|stp|
  ans *= fibonacci(stp - ls - 1)
  ls = stp + 1
}

p ans % CD


Measured memory_bytes: 14132
#include<iostream>
using namespace std;
 
int main(){
    int H, W, i, j;
     
    while(1) {
        cin >> H >> W;
        if(H == 0 && W == 0) {
            break;
        }
        for(i = 0; i < H; i++) {
            for(j = 0; j < W; j++) {
                if( (i + j) % 2 == 0) {
                cout << '#';
            }else{
                cout << '.';
            }
        }
        cout << endl;
        }
    cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3088
def main():
    N = int(input())
    A = [int(a) for a in input().split()]

    ans = 0
    s = A[0]
    count = 0
    for a in A:
        if a == s:
            count += 1
        else:
            s = a
            ans += count // 2
            count = 1
    
    ans += count // 2
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  rep(i, N) cin >> p[i];
  int max = 0;
  int maxd = 0;
  int now = 0;
  rep(i, K) now += p[i];
  rep(i, N-K+1) {
    if(now > max) {
      max = now;
      maxd = i;
    }
    now -= p[i];
    if(i != N-K) now += p[i+K];
  }
  double ans = 0;
  for (int i = maxd; i < maxd + K; i++) {
    int a = p[i] * (p[i]+1) / 2;
    int b = p[i];
    ans += (double)a/b;
  }
  cout << fixed << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1e9 + 7;

#define MAX_V 200000

struct edge{
	int to;
	long long int cost;
};

vector<edge> G[MAX_V];
long long int d[MAX_V];

// 計算コストはO(ElogV)

void shortest_path(int s, int V){ // Vは頂点数
	
	priority_queue<P, vector<P>, greater<P> > que;
	
	for(int i = 0; i < V; i++){
		d[i] = INF;
	}
	d[s] = 0;
	
	que.push(P(0, s));
	
	while(!que.empty()){
		
		P p = que.top();
		que.pop();
		
		int v = p.second;
		
		if(d[v] < p.first){
			continue;
		}
		
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost + d[v]){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		} // 頂点への最小コストを更新
	}
}

int main(){
	
	while(true){
		long long int V, E, C;
		cin >> V >> E >> C;
		
		if(V == 0){
			break;
		}
		
		for(int i = 0; i < V * V; i++){
			G[i].clear();
		}
		
		for(int i = 0; i < E; i++){
			int f, t, c;
			cin >> f >> t >> c;
			f--; t--;
			edge e;
			e.cost = c;
			for(int j = 0; j < V; j++){
				e.to = t + j * V;
				G[f + j * V].push_back(e);
			}
			e.cost = 0;
			for(int j = 0; j < V - 1; j++){
				e.to = t + (j + 1) * V;
				G[f + j * V].push_back(e);
			}
		}
		
		shortest_path(0, V * V);
		
		for(int i = 0; i < V; i++){
			if(C >= d[V - 1 + i * V]){
				cout << i << endl;
				break;
			}
		}
	}
	
	return 0;
}


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

using namespace std;

using ll = long long int;
using ld = long double;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

const int MOD = 1000000007;

ll fact(ll n) {
	return (n == 1 ? 1 : n * fact(n - 1) % MOD);
}

ll solve(ll n, ll m) {
	if (abs(n - m) > 1) {
		return 0;
	} else if (abs(n - m) == 1) {
		return fact(n) * fact(m) % MOD;
	} else {
		return 2 * fact(n) * fact(m) % MOD;
	}
}

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

	ll n, m;
	cin >> n >> m;

	cout << solve(n, m) << endl;
	return 0;
}

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

int main(){
  int n,ans = 0;
  cin >> n;
  int a[2*n];
  for(int i=0;i<2*n;i++) cin >> a[i];
  sort(a,a+2*n);
  for(int i=0;i<2*n;i++){
    if(i%2==0) ans+= a[i];
  }
  cout << ans << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
long long int n,m,x,k,d,index,flag;
//long long int a[2000005],b[2000005],i,count=0,result,odd,even,sum=0,temp;
 cin>>n;
 double t=(double)pow(n,2);
 double u=(double)pow(n,3);
 d=(int)(t+u);
 cout<<n+d<<endl;
}



Measured memory_bytes: 4008
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
  public static void main(String[] args) {
    new Main().solve();
  }

  private void solve() {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

      String[] ln = in.readLine().split(" ");
      int n = atoi(ln[0]);
      int m = atoi(ln[1]);
      int r = atoi(ln[2]);

      int[] t = mapInt(in.readLine().split(" "));

      final int INF = 1 << 28;
      Graph G = new Graph(n, r, t);

      for (int a[] : G.graph) Arrays.fill(a, INF);
      for (int i = 0; i < m; i++) {
        int[] edge = mapInt(in.readLine().split(" "));
        G.graph[edge[0]-1][edge[1]-1] = edge[2];
        G.graph[edge[1]-1][edge[0]-1] = edge[2];
      }

      // warshall-Froyd
      for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
          for (int j = 0; j < n; j++) {
            G.graph[i][j] = min(G.graph[i][j], G.graph[i][k] + G.graph[k][j]);
          }
        }
      }

      final int ans = G.compute();
      out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

 class Graph {
    private int n, enm;
    private int[] pmt;
    private int ret;
    private boolean[] visited;

    public int[][] graph;
    // option
    private int t[];

    public Graph(int n, int enm, int[] t) {
      this.n = n;
      this.enm = enm;
      this.t = t;
      ret = Integer.MAX_VALUE;
      graph = new int[n][n];
      pmt = new int[enm];
      visited = new boolean[n];
    }

    public int compute() {
      dfs(0);
      return ret;
    }

    private void dfs(int cnt) {
      if(cnt == enm) {
        evalute();
        return;
      }
  
      for (int v: t) {
        if(visited[--v]) continue;

        pmt[cnt] = v;
        visited[v] = true;
        dfs(cnt+1);
        visited[v] = false;
      }
    }
  
    private void evalute() {
      int result = 0;
      for (int i = 1; i < enm; i++) result += graph[pmt[i-1]][pmt[i]];
      ret = min(ret, result);
    }
  }

  int  atoi(String s) { return Integer.parseInt(s); }
  long atol(String s) { return Long.parseLong(s); }
  int[] mapInt(String[] sa) {
    int[] ret = new int[sa.length];
    for (int i = 0; i < sa.length; i++) ret[i] = Integer.parseInt(sa[i]);
    return ret;
  }
  void mapInt(int[] ret, String[] sa) {
    for (int i = 0; i < sa.length; i++) ret[i] = Integer.parseInt(sa[i]);
  }
  long[] mapLong(String[] sa) {
    long[] ret = new long[sa.length];
    for (int i = 0; i < sa.length; i++) ret[i] = Long.parseLong(sa[i]);
    return ret;
  }
  void mapLong(long[] ret, String[] sa) {
    for (int i = 0; i < sa.length; i++) ret[i] = Long.parseLong(sa[i]);
  }
}

Measured memory_bytes: 33160
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: Skip
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

int xs[MAX_N];

/* subroutines */

bool mod0(int n, int d) {
  for (int i = 1; i < n; i++)
    if (xs[i] % d != 0) return false;
  return true;
}

/* main */

int main() {
  int n, sx;
  scanf("%d%d", &n, &sx);
  for (int i = 0; i < n; i++) {
    int xi;
    scanf("%d", &xi);
    xs[i] = abs(xi - sx);
  }
  sort(xs, xs + n);

  int &x0 = xs[0];
  int maxd = 1;

  for (int d0 = 1; d0 * d0 <= x0; d0++)
    if (x0 % d0 == 0) {
      int d1 = x0 / d0;

      if (maxd < d1 && mod0(n, d1)) maxd = d1;
      if (maxd < d0 && mod0(n, d0)) maxd = d0;
    }

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


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

int main() {
  double n, m;
  cin >> n >> m;
  cout << ((n / m) == 1 ? "Yes" : "No") << endl;
}

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

constexpr long MOD = 1000000007;

long mpow(long a, long b) {
  long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}

int main() {
  long N, K;
  cin >> N >> K;
  vector<long> V(K + 1);
  for (long i = 1; i <= K; i++) {
    long tmp = K / i;
    if (tmp == 1) {
      V.at(i) = 1;
      continue;
    }
    V.at(i) = mpow(tmp, N);
  }
  for (long i = K; i >= 1; i--) {
    for (long j = i + i; j <= K; j += i) {
      V.at(i) -= V.at(j);
    }
  }
  long ans = 0;
  for (long i = 1; i <= K; i++) {
    ans += V.at(i) * i % MOD;
    ans %= MOD;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 4020
//$ darklife_12
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <cstring>
#include <bits/stdc++.h>
#include <iostream>
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
#define enterarray(a,n) for(int i=0;i<(int)(n);++i)cin>>a[i];
#define ins insert
const int MOD =998244353;
const int MX = int(2e6+9);
using namespace std;
int even(ll num){
    if(num%2==0)return 1;
    else return 0;
}
void printvector(vector<int> v){
    int i;
    for0(i,v.size())cout<<v[i]<<" ";
}
void solve()              
{
    ll n,m,i,j,k;
    long long a[200005],b[200005];
    ll ans=0,res;
    bool flag=true;
    vector<int> v;
    string s1,s2;
    set<int> s;
    cin>>n;
    for0(i,n)cin>>a[i];
    sort(a,a+n);
    for(k=1;k<=n-1;k++){
        ans+=a[n-1-(k/2)];
    }
    cout<<ans;
}
 
int main()
{
    FAST;
   int t;
    t=1;
    while(t--)
    {
        solve();
       cout<<"\n";
    }
}

Measured memory_bytes: 5172
S = input()

hagu = 0

if len(S) % 2 == 0:
    for i in range(len(S)//2):
        if S[i] != S[len(S)-1-i]:
            hagu += 1

else:
    for i in range((len(S)-1)//2):
        if S[i] != S[len(S)-1-i]:
            hagu += 1

print(hagu)


Measured memory_bytes: 2940
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 62;
const int HALF = 1LL << 61;

/* ---------- Functions */
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int N;
    cin >> N;
    vector<int> A(N+1);
    vector<int> B(N+1);
    for (int i= 0; i < N+1; i++) cin >> A[i];

    B[0] = 1;
    for (int i = 1; i < N+1; i++) {
        if (B[i-1] - A[i-1] > HALF) {
            B[i] = INF;
        } else {
            B[i] = (B[i-1] - A[i-1]) * 2;

            if (B[i] <= 0) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    if (A[N] > B[N]) {
        cout << -1 << endl;
        return 0;
    }

    int cnt = A[N];
    int ret = cnt;

    for (int i = N-1; i >= 0; i--) {
        cnt = min(B[i], cnt + A[i]);
        ret += cnt;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 4756
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0301
WA
"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def main(args):
    # members = deque(list(range(10)))
    # numbers = [2, 6, 5, 18, 3]
    # queries = [3, 0, 5]

    N, M, Q = map(int, input().split(' '))
    members = deque(list(range(N)))
    numbers = [int(x) for x in input().split(' ')]
    queries = [int(x) for x in input().split(' ')]


    for n in numbers:
        if n % 2 == 0:
            n = n % N
            members.rotate(-n)
            members.popleft()
        else:
            n = n % N
            members.rotate(n)
            members.popleft()
        N -= 1


    for q in queries:
        ans = 1 if q in members else 0
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 31264
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { int cnt7 = 0,cnt5=0;
  REP(i, 3) { int t;
    cin >> t;
    if (t % 5 == 0) cnt5++;
    if (t % 7 == 0) cnt7++;
  }
  if(cnt5==2&&cnt7==1){
    puts("YES");
  }else{
    puts("NO");
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int c=b-a;
  int high=0;
  for(int i=1;i<c;i++){
    high+=i;
  }
  cout<<high-a<<endl;
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int t = 0;

    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            if(n == (4 * i + 7 * j)){
                t = 1;
            }
        }
    }
    if(t == 1)
        cout << "Yes";
    else
        cout << "No";
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
typedef vector<vector<int>> Graph;
Graph G(100010);
vector<int> par(100010);
int room[100010] = { };
void init(int N) { //最初は全てが根であるとして初期化
  for (int i = 0; i < N; i++)
    par[i] = i;
}

int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
  if (par[x] == x)
    return x;
  return par[x] = root(par[x]);
}

void unite(int x, int y) { // xとyの木を併合
  int rx = root(x); //xの根をrx
  int ry = root(y); //yの根をry
  if (rx == ry)
    return; //xとyの根が同じ(=同じ木にある)時はそのまま
  if (ry < rx) {
    par[rx] = ry;
  } else {
    par[ry] = rx;
  }
}

bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
  int rx = root(x);
  int ry = root(y);
  return rx == ry;
}
int main() {
  int n, m, a, b;
  cin >> n >> m;
  init(n + 1);
  rep(i,m)
  {
    cin >> a >> b;
    unite(a, b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (int i = 2; i <= n; i++) {
    if (!same(1, i)) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes" << endl;
  queue<int> q;
  q.push(1);
  while (!q.empty()) {
    int c = q.front();
    q.pop();
    rep(i,G[c].size())
    {
      if (room[G[c][i]] == 0) {
        room[G[c][i]] = c;
        q.push(G[c][i]);
      }
    }
  }
  for (int i = 2; i <= n; i++)
    cout << room[i] << endl;
}


Measured memory_bytes: 10760
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

constexpr int mod = 1e9 + 7;
int n, k, p[2010][2010];
void init() {
	for (int i = 0; i <= 2000; i++)
		p[i][0] = 1;
	for (int i = 1; i <= 2000; i++)
		for (int j = 1; j <= i; j++)
			p[i][j] = (p[i - 1][j] + p[i - 1][j - 1]) % mod;
}
int main() {
	scanf("%d %d", &n, &k);
	init();
	for (int i = 1; i <= k; i++) {
		ll a = p[n - k + 1][i];
		ll b = p[k - 1][i - 1];
		printf("%lld\n", a * b % mod);
	}
}

Measured memory_bytes: 14976
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>

#include <map>

using namespace std;

typedef long long LL;

int n, m, k;

int a[200010];



int main() {
    
    cin >> n ;

    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        a[x] = i;
    }
    for (int i = 1; i <= n; ++i) {
        cout << a[i] << ' ';
    }
}

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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n,m;
  const int max_n = 1e5;
  int a[max_n+1];
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    cin >> a[i];
    a[i] --;
    if(i != 0 && a[i] - a[i-1] == 1){
      cout << 0 << endl;
      return 0;
    }
  }

  unsigned long long dp[max_n+1];
  long long now = 0;
  long long k = 1;
  unsigned long long ans = 1;
  dp[0] = 1;
  for(long long i = 0; i < n; i++){
    if(i == a[now] && now < m){
      // cout << dp[i-1] << endl;
      if(i!=0) ans *= dp[i-1];
      // dp[i] = 1;
      ans %= MOD;
      now ++;
      k = 0;
    }else{
      if(k == 0) dp[i] = 1;
      else if(k == 1) dp[i] = 1;
      else if(k == 2) dp[i] = 2;
      else dp[i] = dp[i-1] + dp[i-2];
      dp[i] %= MOD;
      k++;
    }
  }
  // cout << dp[n-1] << endl;
  ans *= dp[n-1];
  ans %= MOD;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4604
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
using namespace std;
#define ul unsigned long long

#define rep(a, b) for(int i = a; i < b; i++)

int main() {
	int r, g, b;
	cin >> r >> g >> b;
	
	int s = r * 100 + g * 10 + b;
	if (s % 4 == 0) cout << "YES";
	else cout << "NO";
	cout << endl;
	return 0;
}





Measured memory_bytes: 256
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v):
    print(["Yes", "No"][not v])


def main():
    """エントリーポイント"""
    N, K = input(int, int)
    n = N
    ans = 0
    while 0 < n:
        n //= K
        ans += 1
    print(ans)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
// bbw -> bwb -> wbb
//bwbwbw -> wbbwbw -> wbwbbw -> wwbwb -> wwwbw -> wwwwb
int main() {
    string s;
    cin >> s;
    ll n =s.size();
    ll ans = 0, cnt = 0;
    rep(i,s.size()) {
        if(s[i]=='B') cnt++;
        else ans+=cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 200100;

string input;
int n;
ll arr[MAXN];
int cnt2[MAXN], cnt5[MAXN], mp[32][32];
ll ans;

int main(){
	scanf("%d", &n);
	memset(cnt2, 0, sizeof(cnt2));
	memset(cnt5, 0, sizeof(cnt5));
	memset(mp, 0, sizeof(mp));
	for(int i = 1; i <= n; i++){
		cin >> input;
		int flag = -1;
		int length = input.size();
		for(int j = 0; j < length; j++){
			if(input[j] == '.'){
				flag = 0;
				continue;
			}
			arr[i] = arr[i] * 10 + input[j] - '0';
			if(flag != -1) flag++;
		}
		if(flag == -1) flag = 0;
		for(; flag < 9; flag++) arr[i] = arr[i] * 10;
		while(arr[i] % 2 == 0){
			cnt2[i]++;
			arr[i] /= 2;
		}
		while(arr[i] % 5 == 0){
			cnt5[i]++;
			arr[i] /= 5;
		}
		if(cnt2[i] > 18) cnt2[i] = 18;
		if(cnt5[i] > 18) cnt5[i] = 18;
		mp[cnt2[i]][cnt5[i]]++;
	}
	//18 * "0" = (18 * "2") * (18 * "5")
//	for(int i = 18; i >= 0; i--){
//		for(int j = 18; j >= 0; j--){
//			mp[i][j] += mp[i + 1][j] + mp[i][j + 1] - mp[i + 1][j + 1];
//		}
//	}
//	for(int i = 1; i <= 18; i++){
//		for(int j = 1; j <= 18; j++) 
//			printf("%d ", mp[i][j]);
//		printf("\n");
//	}
	ans = 0;
	for(int i = 1; i <= n; i++){
		mp[cnt2[i]][cnt5[i]]--;
		for(int j = 18 - cnt2[i]; j <= 18; j++)
			for(int k = 18 - cnt5[i]; k <= 18; k++)
				ans += mp[j][k];
//		ans += mp[18 - cnt2[i]][18 - cnt5[i]];
//		if(cnt2[i] >= 9 && cnt5[i] >= 9) ans--;
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {
    int A, B;
    cin >> A >> B;
    
    if (B % A == 0) {
        print(A+B);
    } else {
        print(B-A);
    }

}

signed main() {
    solve();
}


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

typedef string str;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<bool> vb;

#define pb push_back
#define fi first
#define se second
#define in insert
#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)

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

const int MID = 1e5 + 3;
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;

int main(){
    speed;
    int n;
    cin >> n;
    str s;
    cin >> s;
    int cnt = 0;
    int m = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] == '('){
            cnt++;
        }
        else{
            if(cnt){
                cnt--;
            }
            else{
                m++;
            }
        }
    }
    cout << string(m, '(');
    cout << s;
    cout << string(cnt, ')');
}

Measured memory_bytes: 3656
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

#define int long long
#define double long double

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); }
template<class T> T sqr(T x) { return x*x; }
template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; }

int toint(string s) { int v; stringstream i(s); i >> v; return v; }
bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define REP(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	REP(i,0,n)
#define PER(i,a,b)	for(int (i) = (a-1);i >= (b);(i)--)
#define per(i,n)	PER(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define dump(val) 	cerr << #val " = " << val << endl;
#define dum(val)	cerr << #val " = " << val;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 };
const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 };
const int mod = 1e9 + 7;
const int INF = 1e17 + 9;

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

	int k, s;
	cin >> k >> s;

	int ans = 0;
	rep(x, k + 1)rep(y, k + 1) {
		int z = s - x - y;
		if (z >= 0 && z <= k)ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            var V = ReadInts();
            int sum = 0;
            switch (V[0])
            {
            case 1: sum += 300000; break;
            case 2: sum += 200000; break;
            case 3: sum += 100000; break;
            }
            switch (V[1])
            {
            case 1: sum += 300000; break;
            case 2: sum += 200000; break;
            case 3: sum += 100000; break;
            }
            if (V[0] == 1 && V[1] == 1) { sum += 400000; }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13140
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

n = int(input())
a = list(map(int, input().split()))
M = 10**9+7

def factor(n, m=None):
    # mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力する
    arr = {}
    temp = n
    M = int(-(-n**0.5//1))+1
    if m is not None:
        M = min(m+1, M)
    for i in range(2, M):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if not arr:
        arr[n] = 1

    return arr

ds = [factor(num) for num in a]
D = {}
for d in ds:
    for k,v in d.items():
        if k in D:
            D[k] = max(D[k], v)
        else:
            D[k] = v
l = 1
for k,v in D.items():
    l *= pow(k,v,M)
    l %= M
ans = 0
for num in a:
    ans += (l*pow(num, M-2, M))
    ans %= M
print(ans)

Measured memory_bytes: 78668