akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    string inp;
    cin >> inp;
    if(inp == "Rainy"){
        cout<< "Sunny";
    }
    else if(inp == "Cloudy"){
        cout<< "Rainy";
    }
    else{
        cout<< "Cloudy";
    }
}



Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    string S;
    cin >> S;
    vec<string> bt;
    bt.push_back(S.substr(0, 1));
    bt.push_back("");
    int cnt = 1;
    FOR(i, S.length(), 1){
        bt[cnt] += S[i];
        if(bt[cnt-1] != bt[cnt]){
            //cout << bt[cnt] << el;
            bt.push_back("");
            cnt++;
        }
    }
    if(bt[cnt] == ""){
    }else{
        if(bt[cnt-2] != bt[cnt-1] + bt[cnt]){
            //cout << "Ze1" << el;
        }else{
            //cout << "Ze2" << el;
        }
    }
    cout << cnt << el;
}



Measured memory_bytes: 10996
// AOJ 2024: Blackjack
// 2017.11.04 bal4u@uu

#include <stdio.h>

int score[10];
int tr['Z'];

int main()
{
	int cno, i, s, ace;
	char buf[3];

	tr['A'] = 1, tr['T'] = tr['J'] = tr['Q'] = tr['K'] = 10;
	for (i = 2; i <= 9; i++) tr[i+'0'] = i;

	scanf("%d", &cno); while (cno--) {
		for (i = 0; i < 10; i++) scanf("%s", buf), score[i] = tr[*buf];
		ace = 0;
		for (s = 0, i = 0; ; i++) {
			if (i == 10) { printf("%d\n", s); break; }
			if (s < 17 || s == 17 && ace) {
				if (score[i] == 1 && s + 11 <= 21) s += 11, ace = 1;
				else s += score[i];
				if (s > 21 && ace) s -= 10, ace = 0;
				if (i == 1 && s == 21) { puts("blackjack"); break; }
				if (s > 21) { puts("bust"); break; }
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1732
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

int main() {
    ll N;
    cin >> N;
    if (N % 2 == 0) {
        cout << N * (N-2) / 2 << endl;
    } else {
        cout << (N-1) * (N-3) / 2 + (N-1) << endl;
    }
    ll M = N / 2;
    for (ll i = 1; i <= 2 * M; i++) {
        for (ll j = i + 1; j <= 2 * M; j++) {
            if (i + j != 1 + 2 * M) {
                cout << i << " " << j << endl;
            }
        }
    }
    if (N % 2 == 1) {
        for (ll i = 1; i <= 2 * M; i++) {
            cout << i << " " << N << endl;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  ll N,K;
  cin >> N >> K;
  vector<ll> a(N);
  vector<ll> S(N+1);
  map<int,int> m;
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  for(int i=0;i<N;i++){
    S[i+1]=S[i]+a[i];
  }
  ll ans=0;
  for(int i=0;i<N;i++){
    if(i>0){
      m[(S[i]-i)%K]--;
      if(i+K-1<=N)
        m[(S[i+K-1]-(i+K-1))%K]++;
    }
    if(i==0){
        for(int j=1;j<=min(K-1,N);j++)
          m[(S[j]-j)%K]++;
    }
    ans+=m[(S[i]-i)%K];
  }
  cout << ans << endl;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll x,k,d;
    cin>>x>>k>>d;
    ll x1 = abs(x)%d;
    ll x2 = x1 - d;
    if(x<0){
        x1=-x1;
        x2=-x2;
    }
    ll cnt = abs(x)/d;
    if(cnt > k){
        if(x>0)x -= k*d;
        else x += k*d;
        cout << abs(x) << endl;
        return 0;
    }
    k -= cnt;
    if(abs(x1) > abs(x2) && k>0){
        k--;
        swap(x1,x2);
    }
    if(k%2)cout << abs(x2) << endl;
    else cout << abs(x1) << endl;
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}

#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

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

	int n, k;
	cin >> n >> k;
	vector<int> d(k), ok(10, 1);
	REP(i, k) cin >> d[i], ok[d[i]] = 0;

	auto good = [&](int n) {
		while(n) {
			if(!ok[n % 10]) return false;
			n /= 10;
		}
		return true;
	};

	while(!good(n)) n++;

	cout << n << "\n";
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int a,b,n;

void input(){
	cin>>n>>a>>b;
	return;
}

void solve(){
	cout<<min(a,b)<<' '<<max(0,min(a,b)-(n-(max(a,b))))<<endl;
	return;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	string s;
	cin>>s;
	if (s=="ABC")  cout<<"ARC";
	if (s=="ARC")  cout<<"ABC";
	re 0;
}

Measured memory_bytes: 3592
n=int(input())
a=list(map(int,input().split()))
#print(bin(11^9^24))
B=a[0]
for i in range(1,n):
    B=B^a[i]
ans=[]
for j in range(n):
    x=B^a[j]
    ans.append(x)
print(*ans)

Measured memory_bytes: 31432
x;
char s[20];
d(int l,int r,int k){
    x=abs(s[l]-s[r]);
    x=(l<0||!s[r]?k:x&&x<3?d(l-1,r+1,k+2):fmax(d(l-1,r,k),d(l,r+1,k)));
}
  
int main(){ 
    scanf("%s",s);
    x=strchr(s,'i')-s;
    printf("%d\n",d(x-1,x+3,3));
    exit(0);
}

Measured memory_bytes: 544
#include <iostream>
#include <vector>

int main(void){
  
  using namespace std;
  vector<char> N(4);
  for(int i=0; i<4; i++) {
    cin >> N[i];
  }
  
  if((N[0] == N[1] && N[1] == N[2]) ||
     (N[1] == N[2] && N[2] == N[3]))
  {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K,A,B;
  cin>>K>>A>>B;
  
  bool judge =false;
  for(int i=A; i<B+1; i++){
    if(i%K==0){
      judge=true;
      break;
    }
  }
  
  if(judge){
    cout<<"OK"<<endl;
  }
  else{
    cout<<"NG"<<endl;
  }

}

Measured memory_bytes: 3636
N=int(input())
P=[int(i) for i in input().split()]
inf = 10**20
table=[[0]*(N+2) for i in range(N+2)]
for i in range(1,N+1):
    if P[i-1]>0:
        table[i][N+1]=P[i-1]
    else:
        table[0][i]=-P[i-1]
    for j in range(2*i,N+1,i):
        table[i][j]=inf
#print(table)
def fk(x,t,f):
    #print(x)
    visit[x]=True
    if x==t:
        return f
    for i in range(N+2):
        if (not visit[i]) and table[x][i]>0:
            df=fk(i,t,min(f,table[x][i]))
            if df>0:
                table[x][i]-=df
                table[i][x]+=df
                return df
    return 0

ans=0
while True:
    visit=[False]*(N+2)
    df=fk(0,N+1,inf)
    if df>0:
        ans+=df
    else:
        break
num=sum([p for p in P if p>0])
print(num-ans)

Measured memory_bytes: 42716
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

int n;
char a[105], b[105], c[105];

int main(){
	scanf(" %d", &n);
	scanf(" %s", a + 1);
	scanf(" %s", b + 1);
	scanf(" %s", c + 1);
	int sum = 0;
	for(int i = 1; i <= n; i ++){
		if(a[i] == b[i]){
			if(b[i] != c[i]) sum ++;
		}
		else if(b[i] == c[i]){
			if(a[i] != b[i]) sum ++;
		}
		else if(a[i] == c[i]){
			if(b[i] != a[i]) sum ++;
		}
		else sum += 2;
	}
	printf("%d\n", sum);
}

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

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

int main() {
  int d, n;
  cin >> d >> n;
  int ans;

  if (d == 0) {
    ans = n;
    if (n == 100) ans += 1;
  } else if (d == 1) {
    ans = 100 * n;
    if (n == 100) ans += 100;
  } else if (d == 2) {
    ans = 100 * 100 * n;
    if (n == 100) ans += 10000;
  }

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


Measured memory_bytes: 256
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define MOD 1000000007
#define INF 1e18
#define EPS 1e-15
#define int long long
#define value_at find_by_order
#define index_of order_of_key
#define fill(a,v) memset(a,v,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define PER(i,n) for(int i=(int)n-1;i>=0;--i)
#define REP1(i,n) for(int i=1;i<=(int)n;++i)
#define LOOP(i,begin,end) for (int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);std::cout.tie(NULL)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma+1, args...);
}
#else
#define trace(...)
#endif

typedef long long ll;
typedef string str;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef long double db;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define N 100005

int n, x;
int l[105];
int d[105];

int32_t main() {
  FAST_IO;

  cin >> n >> x;
  REP(i, n) cin >> l[i];
  int ans = 0;
  d[0] = 0;
  if (d[0] <= x) ++ans;
  LOOP(i, 1, n + 1) {
    d[i] = d[i - 1] + l[i - 1];
    if (d[i] <= x) ++ans;
  }
  cout << ans;
  rtn 0;
}


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

int main(){
	int n,a=0,b=0;
	string s,sam="abcdefghijklmnopqrstuvwxyz";
	vector<int>x(26);
	vector<int>y(26);
	cin>>n>>s;
	for(int i=0;i<n;i++){
		for(int j=0;j<26;j++){
			if(sam[j]==s[i]){
				x[j]++;
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<26;j++){
			if(sam[j]==s[n-i-1]){
				x[j]--;
				y[j]++;
			}
		}
		for(int j=0;j<26;j++){
			if(x[j]>0&&y[j]>0){
				a++;
			}
		}
		if(a>b){
			b=a;
		}
		a=0;
		
	}
	cout<<b<<endl;
	
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  string s; cin >> s;
  bool used[s.length()]; CLR(used);
  ll ans1 = 0;
  ll cal = s[0] - '0';
  // method 1
  bool plus = false;
  for(int i = 1; i < s.length(); i += 2) {
    if(s[i] == '*') {
      cal *= s[i+1] - '0';
      used[i-1] = used[i+1] = true;
      if(i == s.length() - 2) {
        ans1 += cal;
      }
      plus = true;
    } else if(plus){
      ans1 += cal;
      cal = s[i+1] - '0';
      plus = false;
    } else {
      cal = s[i+1] - '0';
    }
  }
  for(int i = 0; i < s.length(); i += 2) {
    if(!used[i]) ans1 += s[i] - '0';
  }
  // method 2
  ll ans2 = s[0] - '0';
  for(int i = 1; i < s.length(); i += 2) {
    if(s[i] == '*') {
      ans2 *= s[i+1] - '0';
    } else {
      ans2 += s[i+1] - '0';
    }
  }
  //cout << ans1 << " " << endl;
  ll x; cin >> x;
  if(ans1 == x && ans2 == x) {
    puts("U");
  } else if(ans1 == x) {
    puts("M");
  } else if(ans2 == x) {
    puts("L");
  } else {
    puts("I");
  }
  return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
    ll T1,T2;
    cin >> T1 >> T2;
    ll A1,A2;
    cin >> A1 >> A2;
    ll B1,B2;
    cin >> B1 >> B2;
    if(T1 * A1 + T2 * A2 == T1 * B1 + T2 * B2) {
        cout << "infinity" << endl;
    }
    else {
        if(A1 > B1) {
            if(T1 * A1 + T2 * A2 > T1 * B1 + T2 * B2) {
                cout << 0 << endl;
            }
            else {
                ll cnt1 = (A1 - B1) * T1;
                ll cnt2 = cnt1 - (T1 * A1 * 2 + T2 * A2 - T1 * B1 * 2 - T2 * B2);
                if(cnt1 % cnt2 == 0) {
                    cout << 1 + (cnt1 / cnt2 - 1) * 2 + 1 << endl;
                }
                else {
                    cout << 1 + cnt1 / cnt2 * 2 << endl;
                }
            }
        }
        else {
            if(T1 * A1 + T2 * A2 < T1 * B1 + T2 * B2) {
                cout << 0 << endl;
            }
            else {
                ll cnt1 = (B1 - A1) * T1;
                ll cnt2 = cnt1 - (T1 * B1 * 2 + T2 * B2 - T1 * A1 * 2 - T2 * A2);
                if(cnt1 % cnt2 == 0) {
                    cout << 1 + (cnt1 / cnt2 - 1) * 2 + 1 << endl;
                }
                else {
                    cout << 1 + cnt1 / cnt2 * 2 << endl;
                }
            }
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
using edge = struct {int to;LL cost;};
vector<edge> v[100001];
LL depth[100001];

void dfs(int i,int j,LL count){
    auto e=v[i].begin();
    depth[i]=count;
    for(int s=0;s<v[i].size();s++,e++){
        if(e->to==j) continue;
        dfs(e->to,i,count+e->cost);
    }
}

int main(){
    int N;
    cin >> N;
    for(int i=0;i<N-1;i++){
        int x,y;
        LL r;
        cin >> x >> y >> r;
        v[x].push_back({y,r});
        v[y].push_back({x,r});
    }
    int Q,K;
    cin >> Q >> K;
    dfs(K,-1,0);
    for(int i=0;i<Q;i++){
        int x,y;
        cin >> x >> y ;
        cout << depth[x]+depth[y] << endl;
    }
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;cin>>n>>m;
    string s;cin>>s;
    string s2;
    rep(i,s.size()){
        s2 += s[s.size()-i-1];
    }
    s = s2;
    vector<int> prevzero(n+1);
    rep(i,n+1){
        if(s[i]=='0')prevzero[i]=i;
        else prevzero[i]=prevzero[i-1];
    }
    int pos = 0;
    vector<int> op(0);
    while(pos<n){

        int p  = min(pos+m,n);
        if(pos==prevzero[p]){cout<<-1<<endl;return 0;}
        op.push_back(prevzero[p]-pos);
        pos = prevzero[p];
    }
    for(int i=0; i<op.size(); i++){
        cout<<op[op.size()-i-1]<<" ";
    }
    return 0;
}

Measured memory_bytes: 1768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    int x[n], y[n];
    ll h[n];
    rep(i, n){
        cin >> x[i] >> y[i] >> h[i];
    }
    ll H;
    rep(cy, 101){
        rep(cx, 101){
            bool flag = true;
            rep(i, n){
                if (h[i] > 0) H = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
            }
            rep(i, n){
                if (h[i] != max(H - abs(cx - x[i]) - abs(cy - y[i]), ll(0))) flag = false;
            }
            if (flag){
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

using namespace std;

#define ll long long
#define debug(n) cerr << #n << ':' << n << endl;

int main(){
  int h,w;cin >> h >> w;
  string room[2000];
  for(int i = 0; i < h; ++i)cin >> room[i];
  int ycnt[2000][2000]={}, tcnt[2000][2000]={};
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      if(room[i][j] == '#')continue;
      if(i == 0 || room[i - 1][j] == '#')tcnt[i][j] = 1;
      else tcnt[i][j] = tcnt[i - 1][j] + 1;
      if(j == 0 || room[i][j - 1] == '#')ycnt[i][j] = 1;
      else ycnt[i][j] = ycnt[i][j - 1] + 1;
    }
  }
  for(int i = h - 1; i >= 0; --i){
    for(int j = w - 1; j >= 0; --j){
      if(room[i][j] == '#')continue;
      if(i != h - 1)tcnt[i][j] = max(tcnt[i][j], tcnt[i + 1][j]);
      if(j != w - 1)ycnt[i][j] = max(ycnt[i][j], ycnt[i][j + 1]);
    }
  }

  int ans = 0;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      ans = max(ans, tcnt[i][j] + ycnt[i][j]);
    }
  }
  cout << ans - 1 << endl;
  return 0;
}


Measured memory_bytes: 35584
n = int(input())
A = list(map(int, input().split()))

cumsum = [[0 for j in range(2)] for i in range(60)]
ans = [0] * 60
#print(cumsum)

for i in range(len(A) - 1, -1, -1):
    plus_num = A[i]
    bit_num = format(plus_num, "060b")
    #print(bit_num)
    for i, bit in enumerate(bit_num):
        bit = int(bit)
        if bit == 0:
            ans[i] += cumsum[i][1]
        else:
            ans[i] += cumsum[i][0]
        cumsum[i][bit] += 1
    #print(ans)
    #print(cumsum)

ans_num = 0
mod = 10**9 + 7
for i, cnt in enumerate(ans):
    ans_num += 2**(59-i) * cnt
    ans_num %= mod
print(ans_num)



Measured memory_bytes: 124672
let () =
  Scanf.scanf "%d %d\n" @@ fun a b ->
  let ans = ref 0 in
  for num = a to b do
    if num / 10000 = num mod 10 && (num / 1000) mod 10 = (num / 10) mod 10
    then ans := !ans + 1
  done;
  Printf.printf "%d\n" !ans

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n;cin>>n;
  ll psum=0,qsum=0;
  vector<ll> a(3*n);
  priority_queue<ll,vector<ll>,greater<ll>> p;
  priority_queue<ll> q;
  vector<ll> b(n+1),c(n+1);
  for(i=0;i<3*n;i++){
    cin>>a[i];
    if(i<n){
      psum+=a[i];
      p.push(a[i]);
    }
    else if(i>=2*n){
      qsum+=a[i];
      q.push(a[i]);
    }
  }
  b[0]=psum;c[0]=qsum;
  for(i=n;i<2*n;i++){
    if(p.top()<a[i]){
      //cout<<p.top() spa a[i]<<endl;
      psum+=a[i]-p.top();
      p.pop();
      p.push(a[i]);
    }
    b[i-n+1]=psum;
    //cout<<b[i-n+1] spa i-n+1<<endl;

  }
  for(i=n;i<2*n;i++){
    if(q.top()>a[3*n-i-1]){
      qsum+=a[3*n-i-1]-q.top();
      q.pop();
      q.push(a[3*n-i-1]);
    }
    c[i-n+1]=qsum;
  }
  res=-INF;
  for(i=0;i<n+1;i++){
    chmax(res,b[i]-c[n-i]);
    //cout<<b[i] spa c[n-i]<<endl;
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 6516
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

a,b=get_i
if a+b==15
    puts "+"
elsif a*b==15
    puts "*"
else
    puts "x"
end

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

int main(){
    string s;
    cin >> s;
    rep(0,s.length()){
        s[i] = 'x';
    }
    cout << s << endl;
    return 0;
}

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

int main(){
    using namespace std;
    unsigned long N, A1, A2, A{0};
    cin >> N >> A1 >> A2;
    unsigned long S{A1 + A2};
    for(unsigned long i{2}, a; i < N; ++i){
        cin >> a;
        A ^= a;
    }
    if((A ^ S) & 1)return 0 & puts("-1");
    if(S < A)return 0 & puts("-1");
    unsigned long ans{(S - A) >> 1};
    if(ans > A1 || (ans & A))return 0 & puts("-1");
    for(unsigned long i{1UL << 63}; i; i >>= 1)if((A & i) && ans + i <= A1)ans += i;
    if(!ans)return 0 & puts("-1");
    cout << A1 - ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main(){

  int r, g;
  cin >> r >> g;

  cout << 2*g-r << endl;  

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <cmath>
#define ll long long

using namespace std;


int main() {
    int a,b,c;
    int res[5];
    cin>>a>>b>>c;
    res[0]=abs(a-b);
    res[1]=abs(c-b);
    res[2]=abs(a-c);
    cout<<res[0]+res[2]+res[1]-max(res[0],max(res[2],res[1]));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char str[10];

int main(){
    scanf("%s", str);
    int ans = 0;
    for(int i = 0; str[i]; i++){
      if(str[i] == '1') ans++;
    }
   printf("%d\n", ans);
   return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char *argv[])
{
	int n;
	std::cin >> n;
	int sn = 0, tmp = n;
	
	while(tmp != 0) {
		sn += tmp%10;
		tmp = tmp/10;
	}
	if (n % sn == 0) 
		printf("Yes\n");
	else
		printf("No\n");
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int A,B;
int main(){
    cin >> A >> B;
    for(int i=1;i<1010;i++){
        if((int)(i*0.08)==A && (int)(i*0.1)==B){
            cout << i;
            return 0;
        }
    }
    cout << -1;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

int A, B;

int solve() {
    return max(
        A+B,
        max(A-B, A*B)
    );
}

int main() {
    cin >> A >> B;
    cout << solve() << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n, m = [int(x) for x in input().split()]  
    n = int(input())
    d = defaultdict(int)
    for x in range(2, n+1):
        i = 2
        xd = x
        while i * i <= xd:
            while x % i == 0:
                x //= i
                d[i] += 1
            i += 1
        if x != 1:
            d[x] += 1
    ans = 1

    for k in d:
        ans *= (d[k] + 1)
        ans %= MOD

    print(ans)

    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""
a b a
d c d
a b a
"""


Measured memory_bytes: 9928
from sys import stdin, setrecursionlimit
from math import atan, degrees


def main():
    input = stdin.buffer.readline
    a, b, x = map(int, input().split())

    if a ** 2 * b > 2 * x:
        h = 2 * x / (a * b)
        print(degrees(atan(b / h)))
    else:
        h = 2 * (a ** 2 * b - x) / (a ** 2)
        print(degrees(atan(h / a)))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38256
S,T = map(str,input().split())
A,B = map(int,input().split())
U = input()

dic = {S:A,T:B}

if S == U:
    dic[S] = dic[S] - 1
    print(dic[S])
    print(dic[T])
elif T == U:
    dic[T] = dic[T] - 1
    print(dic[S])
    print(dic[T])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int main(){
    int h,w,d; cin >> h >> w >> d;
    map<int,pair<int,int>> A;
    REP(i,h){
        REP(j,w){
            int tmp; cin >> tmp;
            A.insert(make_pair(tmp,make_pair(i,j)));
        }
    }
    vector<int> cost[d+1];
    FOR(i,1,d+1){
        int a=i;
        cost[i].push_back(0);
        while(a+d<=h*w){
            auto from = A[a];
            auto to = A[a+d];
            int c = abs(from.first-to.first)+abs(from.second-to.second);
            cost[i].push_back(c+*(cost[i].end()-1));
            a+=d;
        }
    }
    int q; cin >> q;
    REP(i,q){
        int l,r; cin >> l >> r;
        if(l%d!=0){
            cout << cost[l%d][r/d] - cost[l%d][l/d]  << endl;
        }else{
            cout << cost[d][r/d-1] - cost[d][l/d-1]  << endl;
        }
    }



}

Measured memory_bytes: 11008
#include <iostream>
#include<list>
#include <algorithm>
typedef long long int ll;

using namespace std;

int main()
{
    list <ll>p;
    list<ll>::iterator point = p.end();
    int N;
    cin >> N;
    while (N--)
    {
        int opr;
        cin >> opr;
        switch (opr)
        {
        case 0:
            int num;
            cin >> num;
            p.insert(point, num);
            point--;
            break;
        case 1:
            int step;
            cin >> step;
            if (step >= 0)
                for (int i = 0;i < step;i++)point++;
            else
                for (int i = 0;i < -step;i++)point--;
            break;
        case 2:
            
            if (point != p.end())
            {
                list<ll>::iterator point2 = point;
                point = p.erase(point2);
            }
            else point = p.end();
            break;
        default:break;
        }
    }
    for (point = p.begin();point != p.end();point++)
        cout << *point << endl;
}



Measured memory_bytes: 18640
n = int(input())
t = [int(i) for i in input().split()]
v = [int(i) for i in input().split()]

maxspeed = [0]*(n+1)
for i in range(n-1,0,-1):
    maxspeed[i] = min(v[i], v[i-1], t[i] + maxspeed[i+1])

def dist(i,first): # distance,lastspeed
    ta = v[i] - first
    tb = v[i] - maxspeed[i+1]
    if ta + tb <= t[i]:
        c = (first+v[i])*ta/2 + v[i]*(t[i]-ta-tb) + (maxspeed[i+1]+v[i])*tb/2
        lastspeed = maxspeed[i+1]
    elif maxspeed[i+1] - first > t[i]:
        c = (first + first + t[i])*t[i]/2
        lastspeed = first + t[i]
    else:
        a = (maxspeed[i+1]+t[i]-first)/2
        c = (first+first+a)*a/2 + (first+a+maxspeed[i+1])*(t[i]-a)/2
        lastspeed = maxspeed[i+1]
    return c, lastspeed


ans = 0
firstspeed = 0
for i in range(n):
    d,firstspeed = dist(i,firstspeed)
    ans += d

print(ans)    


Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
   int i, n, x0, y0, x1, y1, x2, y2, x3, y3, l0x, l0y, l1x, l1y;
   scanf("%d", &n);
for (i = 0; i < n; i++){
    scanf("%d %d %d %d %d %d %d %d", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3);
    l0x = x1 - x0;
    l0y = y1 - y0;
    l1x = x3 - x2;
    l1y = y3 - y2;
    if (l0x == 0 && l1x == 0){
        printf("2\n");
        continue;
    }
    if ((l0x == 0 && l1y == 0)||(l1x == 0 && l0y == 0)){
        printf("1\n");
        continue;
    }
    if (l0x == 0 || l1x == 0){
        printf("0\n");
        continue;
    }
    if (l0y * l1x == l1y * l0x){
        printf("2\n");
    }else if (l0y * l1y == -1 * l0x * l1x){
        printf("1\n");
    }else{
        printf("0\n");
    }
    }

    return 0;
}



Measured memory_bytes: 2104
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz // math is your friend
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N = 2e5+10;

int a[N];

ll comb2(ll n){ return n*(n-1)/2; }

int main(){

	fastio;
	int n;
	cin >> n;
	map<int,int> mp;
	REP(i,0,n){ 
		cin >> a[i];
		mp[a[i]]++;
	}

	ll ans = 0;
	for(auto par : mp) ans += comb2(par.snd);
	
	for(int i = 0; i < n; ++i){
		ans -= comb2(mp[a[i]]);
		mp[a[i]]--;
		ans += comb2(mp[a[i]]);
		cout << ans << endl;
		ans -= comb2(mp[a[i]]);
		mp[a[i]]++;
		ans += comb2(mp[a[i]]);
	}

	return 0;
}


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

char moji[9][5] = {
  {'.',',','!','?',' '},
  {'a','b','c'},
  {'d','e','f'},
  {'g','h','i'},
  {'j','k','l'},
  {'m','n','o'},
  {'p','q','r','s'},
  {'t','u','v'},
  {'w','x','y','z'}
};

int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for(int j = 0; j < s.size(); j++) {
      char c = s[j];
      if(c == '0') continue;
      for(int k = 0; j+k < s.size(); k++) {
	if(s[j+k+1] == '0') {
	  int num = c-'0'-1;
	  if(num == 0) printf("%c", moji[num][k%5]);
	  else if(num == 6 || num == 8) printf("%c", moji[num][k%4]);
	  else printf("%c", moji[num][k%3]);
	  j += k;
	  break;
	}
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 1196
# https://atcoder.jp/contests/abc109/tasks/abc109_c
# C - Skip
import fractions

n, m = list(map(int, input().split()))
x_list = list(map(int, input().split()))

x_list = sorted(x_list + [m])
work_list = x_list[1:]
diff_list = [b - a for a, b in zip(x_list[:-1], x_list[1:])]

# 差分の最大公約数になるはず
work = diff_list[0]
if len(diff_list) > 1:
    for a in diff_list[1:]:
        work = fractions.gcd(work, a)
d = work

print(d)


Measured memory_bytes: 16280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class User
    {
        internal int group;
        internal List<int> friends;

        public User()
        {
            group = -1;
            friends = new List<int>();
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int n = input[0], m = input[1];

            User[] users = new User[n];
            for (int i = 0; i < n; i++) users[i] = new User();

            for (int i = 0; i < m; i++)
            {
                input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                users[input[0]].friends.Add(input[1]);
                users[input[1]].friends.Add(input[0]);
            }

            for (int i = 0; i < n; i++)
            {
                if (users[i].group == -1) DFS(users, i, i);
            }

            StringBuilder sb = new StringBuilder();
            int q = int.Parse(Console.ReadLine());

            for (int i = 0; i < q; i++)
            {
                input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                sb.AppendLine(users[input[0]].group == users[input[1]].group ? "yes" : "no");
            }
            Console.Write(sb);
        }

        static void DFS(User[] U, int u, int g)
        {
            U[u].group = g;

            foreach (var friend in U[u].friends)
            {
                if (U[friend].group == -1)
                {
                    U[friend].group = g;
                    DFS(U, friend, g);
                }
            }
        }
    }
}

Measured memory_bytes: 39324
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long int;


bool IsPrime(int num) {
    if (num < 2)return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}


int main(void) 
{
    int X = 0;
    cin >> X;

    while (true) {
        if (IsPrime(X))break;

        X++;
    }

    cout << X << endl;
}

Measured memory_bytes: 256
N=int(input().strip())
A=[0]*N
xy=[]
for i in range(N):
    A[i]= int(input().strip())
    xy.append([list(map(int, input().split())) for j in range(A[i])])

def count_ones_by_minus(num):
    count = 0
    while num:
        num &= num -1
        count += 1
    return count

ans=0
for k in range(2**N):# combination
    ok=True
    for i in range(N): # people
        # lst=[0]*N # everyone dishonest
        if k>>i & 1: # check lowest bit
            for j in range(A[i]): # opinion
                if xy[i][j][1] != k >> (xy[i][j][0]-1) &1:
                    ok=False
    # print(bin(k),bin(lst_h))
    if ok:
        ans=max(ans,count_ones_by_minus(k))
    # print(ans)

print(ans)

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

int main(){
	int N;
	cin>>N;
	vector<string>S(N);
	for(int i=0;i<N;++i)cin>>S[i];
	vector<long>num(5,0);
	for(int i=0;i<N;++i){
		if(S[i][0]=='M')num[0]++;
		if(S[i][0]=='A')num[1]++;
		if(S[i][0]=='R')num[2]++;
		if(S[i][0]=='C')num[3]++;
		if(S[i][0]=='H')num[4]++;
	}
	/*
	for(int i=0;i<5;++i){
		cout<<num[i]<<" ";
	}
	cout<<endl;
	*/
	long ans=0;
	for(int i=0;i<5;++i){
		for(int j=i+1;j<5;++j){
			for(int k=j+1;k<5;++k){
				ans+=num[i]*num[j]*num[k];
			}
		}
	}
	cout<<ans<<endl;
}


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

string solve(int k, int x) {
  if(500*k >= x){
  return "Yes";
 }
  else{
    return "No";
  }
}

int main() {
  int k,x ;
  cin >> k >> x;
  cout << solve(k, x) << endl;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define int long long int
#define vi vector<int>
#define vvi vector < vi >
#define pii pair<int,int>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define tr(k,st,en) for(int k = st; k <= en ; k++)

using namespace std;

bool isl (int k){
    while (k > 0) {
        int x = k%100;
        k/=10;
        if (k == 0) {
            break;
        }
        int y = x % 10;
        x/=10;
        if (abs(x-y) > 1) {
            return false;
        }
    }
    return true;
}

vector<int> facto(int x){
    vector<int> vec;
    int m = (int)sqrt(x);
    if (m == 1) {
        return vec;
    }
    for (int i = 2 ; i < m; i++) {
        if (x%i == 0) {
            vec.push_back(i);
            vec.push_back(x/i);
        }
    }
    if (m*m == x) {
        vec.push_back(m);
    } else if ( x% m == 0){
        vec.push_back(m);
        vec.push_back(x/m);
    }
    return vec;
}

bool check(int n,int k){
    int i = 0;
    while(n > 1 && i < 100){
        if (n%k==0) {
            n/=k;
        } else {
            n%=k;
        }
        i++;
    }
//    if (i==100) {
//        cout<<"i "<<endl;
//    }
    if (n == 1) {
        return true;
    }
    return false;
}

int32_t main()
{
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    auto fact1 = facto(n);
    auto fact2 = facto(n-1);
    int ans = 0;
    for (int k: fact1) {
        if (check(n, k)) {
            ans ++;
        }
    }
    for (int k: fact2) {
        if (check(n, k)) {
            ans ++;
        }
    }
    ans += 2;
    if(ans == 2){
        ans--;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
typedef long long LL;
const int N=100005;
int n,a[N];LL ans;
int main()
{
	n=read();
	for(RI i=1;i<=n;++i) {
		a[i]=read();
		if(a[i-1]&&a[i]) --a[i-1],--a[i],++ans;
		ans+=(LL)a[i]/2,a[i]&=1;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
	int n, m, i, j;
	int sum = 0;

	cin >> n >> m;

	int a[n][m];
	int b[m];

	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
		cin >> a[i][j];
		}
	}
	for(j=0; j<m; j++){
		cin >> b[j];
	}

	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			sum = sum + a[i][j] * b[j]; 
		}
		cout << sum << endl;
		sum = 0;
	}


}

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

int main() {
    ll mod=1e9+7;
    ll n,k;
    cin>>n>>k;
    ll itr=0;
    vector<ll> num;
    for(ll i=1;i<=n;){
        ll j=n/i;
        if(i<=j){
            num.push_back(1);
            i++;
        }else{
            num.push_back(n/j-i+1);
            i=n/j+1;
        }
        itr++;
    }
    vector<vector<ll>> dp(k+1,vector<ll>(itr));
    dp[0][0]=1;
    for(ll i=0;i<k;i++){
        vector<ll> sdp(itr+2);
        for(ll j=0;j<=itr;j++){
            sdp[j+1]=sdp[j]+dp[i][j];
            sdp[j+1]=(sdp[j+1]+mod)%mod;
        }
        for(ll j=0;j<itr;j++){
            dp[i+1][j]=sdp[itr-j]*num[j];
            dp[i+1][j]=(dp[i+1][j]+mod)%mod;
        }
    }
    ll sum=0;
    for(ll i:dp[k])sum+=i;
    cout<<(sum+mod)%mod<<endl;
}

Measured memory_bytes: 51448
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
d = []
tv = 0
tc = 0
for i in range(N):
    if V[i] - C[i]  >  0:
        tv += V[i]
        tc += C[i]
print(tv - tc)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;
int main(){
  int n,k,q;
  cin>>n>>k>>q;
  vector<int> a(q+4);
  vector<int> point(n+3);
  for(int i=1;i<n+1;i++){
    point[i]=k-q;
  }
  for(int i=1;i<q+1;i++){
    cin>>a[i];
    //    point[i+1]-=k-q;
  }
  for(int i=1;i<q+1;i++){
    point[a[i]]++;
  }
  for(int i=1;i<n+1;i++){
    if(point[i]>0){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(){
  
  char A[1010];
  int i,sum=0;
  while(1){
  scanf("%s\n",A);
    //printf("%s\n",A);
  if(A[0]=='0')break;
  for(i=0;i<strlen(A);i++){
  	sum += A[i]-'0';
  }
    printf("%d\n",sum);
    sum=0;
  
  }
  

  
  return 0;

  
}


Measured memory_bytes: 2052
x, n = gets.to_s.split.map(&:to_i)
p_arr = gets.to_s.split.map(&:to_i)

sort_arr = p_arr.sort_by { |pi| [(x - pi).abs, pi] }

n.times do |i|
  diff = (i + 1) / 2
  expected = i % 2 == 1 ? x - diff : x + diff
  if sort_arr[i] != expected
    puts expected
    exit
  end
end

diff = (n + 1) / 2
expected = n % 2 == 1 ? x - diff : x + diff

puts expected

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

using namespace std;
typedef long long ll;

const int mod = 1000000007;
class mint
{
    long long x;

public:
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const
    {
        return mint(-x);
    }
    mint &operator+=(const mint &a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint &a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint &a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint &a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint &a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint &a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint &a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint &a) const
    {
        mint res(*this);
        return res /= a;
    }

    friend ostream &operator<<(ostream &os, const mint &m)
    {
        os << m.x;
        return os;
    }
};

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} c(200005);

mint kelas(int i, int s)
{
  
  cout << i << endl;

    mint ans = 0;

    if (i == 1 )
    {
        if(s<=6){

            return 1;
        }
        else{

            return 0;
        }
    }
    else
    {

        for (int j = 0; j <= 6; j++)
        {

            if ((s - j) >= 0)
            {

                ans += kelas(i - 1, s - j);
            }
        }
        return ans;
    }

    
}

int main()
{

    int s;
    cin >> s;

    int max_k = s / 3;


    mint total_a=0;
  
  if(max_k>0){

    for (int k = 1; k <= max_k; k++)
    {

        

        int Si = s;

        Si = Si - 3*k; 
      
      if(k==1){
        
        total_a+=1;
      }else{
        total_a+=c((Si + (k-1)),(k-1));
      }
    }
  }

    cout << total_a << endl;


return 0;}

Measured memory_bytes: 6232
#include <iostream>
#include <string>
#include <stdio.h> 
using namespace std;

int main() {
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> s;
    int t = 0;
    REP(i,n) {
        int x; cin >> x;
        if (x % 10 == 0) t += x;
        else s.push_back(x);
    }
    sort(ALL(s));
    int ssum = accumulate(s.begin(),s.end(),0);
    int ans = 0;
    if (!s.empty()) {
        if (ssum % 10 == 0) ans = t + ssum - s[0];
        else ans = t + ssum;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
#-------------------------------------------------------------------
#-------------------------------------------------------------------
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")
#-------------------------------------------------------------------
import math
def prm(n, r):
	return math.factorial(n)//math.factorial(n-r)

def cmb(n, r):
	return prm(n, r)//math.factorial(r)
#-------------------------------------------------------------------
def v(k):
	#p("B-1, k-1, cmb", B-1, k-1, cmb(B-1, k-1))
	p("R, k, cmb(R, k)",R, k, cmb(R, k))
#-------------------------------------------------------------------
MOD = 10**9+7
#-------------------------------------------------------------------


N, K = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7

B=K
R=N-K


def calc(i):
	r = cmb(R+1, i) % MOD
	b = cmb(B-1, i-1) % MOD
	return (r * b) % MOD

for i in range(1,K+1):
	if R+1>=i:
		print( calc(i) )
	else:
		print(0)




Measured memory_bytes: 3316