akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>

#include <queue>
#include <cstring>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
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; }

// debug
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}
#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif

vector<vector<pii>> edge;

int dijkstra(int start, int end, int N) {
  ll cost[N];
  priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>> > q;
  fill(cost, cost + N, INF); cost[start] = 0;
  q.push(make_pair(0, start));

  while (!q.empty()) {
    pair<ll, int> p = q.top(); q.pop();
    int u = p.second;
    ll cur_cost = p.first;

    if (cost[u] < cur_cost)
      continue;
    for (const auto& v : edge[u]) {
      int to = v.first, c = v.second;
      if (cost[to] > cost[u] + c) {
        cost[to] = cost[u] + c;
        q.push(make_pair(cost[to], to));
      }
    }
  }
  return cost[end];
}

int main() {
  int N, M; cin >> N >> M;
  int S, T;

  edge.resize(3*N, vector<pii>());

  rep(i, M) {
    int u, v; cin >> u >> v;
    --u, --v;
    edge[3*u].emplace_back(3*v+1, 1);
    edge[3*u+1].emplace_back(3*v+2, 1);
    edge[3*u+2].emplace_back(3*v, 1);
  }
  cin >> S >> T;
  --S, --T;

  int ans = dijkstra(3*S, 3*T, 3*N);
  if (ans == INF)
    cout << -1 << endl;
  else
    cout << ans/3 << endl;

  return 0;
}


Measured memory_bytes: 18944
#include <stdio.h>
int main(void){
  long H,W;
  scanf("%ld %ld",&H,&W);

if(H == 1 || W == 1)
{
printf("1");
  return 0;
}
if (H * W %2 == 0)
{
printf("%ld",H * W / 2);
  return 0;
}
 else
{
printf("%ld",H * W / 2 + 1);
  return 0;
}

}

Measured memory_bytes: 128
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    readint;
    auto a = readints;
    auto b = new int[a.length];
    for (int i = 0; i < a.length; i++) {
        b[a[i] - 1] = i + 1;
    }
    writeln(b.map!(text).join(" "));
}


Measured memory_bytes: 5564
#include <iostream>

using namespace std;

int main() {
    unsigned long long a, b, c, k;
    long long String = 0;
    cin >> a >> b >> c >> k;
    if (k < a) {
        String = k;
    } else {
        String = a;
        k -= a;
        if (k > b) {
            k -= b;
            String -= k;
        }
    }
    cout << String;
    return 0;
}


Measured memory_bytes: 3192
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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


int main() {
	int n;
	cin >> n;
	int y3d = 19 * 10 + 20 * 20;
	while (n--){
		int ans = 0;
		int y, m, d;
		cin >> y >> m >> d;
		int y3 = y / 3;
		y = y % 3;
		ans += y3*y3d;
		ans += (y-1)*(19 * 5 + 20 * 5);
		if (y == 0){
			ans += (m - 1) * 20;
			ans -= 5;
		}
		else{
			REP(i,m-1)
			ans += 20-i%2;
		}
		cout << 196470-(ans + d-1) << endl;
	}
}

Measured memory_bytes: 1160
#include <stdio.h>
int a, b, c, result=0;

int main() {
  scanf("%d %d %d", &a, &b, &c);
  for (int i = a; i <= b; i++) {
    if(c % i == 0) result++;
  }
  printf("%d\n", result);
  return 0;
}



Measured memory_bytes: 2112
S = gets.to_i
L = 10 ** 9

x1 = y1 = 0
x2 = L
y2 = 1

y3, x3 = S.divmod(L)

if x3 == 0
  puts [x1, y1, x2, y2, x3, y3].join(' ')
else
  puts [x1, y1, x2, y2, L - x3, y3 + 1].join(' ')
end


Measured memory_bytes: 1788
n,k=map(int,input().split())
l=list(map(int,input().split()))

s=1
q=[0]*n
q[0]=1
r=[1]
for i in range(k):
  s=l[s-1]
  if q[s-1]==0:
    q[s-1]+=1
    r.append(s)
    if i==k-1:
      print(s)
  else:
    x=r.index(s)
    mod=len(r)-x
    t=(k-x)%mod
    print(r[x+t])
    break


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

int main()
{
    int N;
    ll ans = 0;
    cin >> N;
    vector<int> s(N);
    for (int i = 0; i < N; i++) {
        cin >> s[i];
        ans += s[i];
    }

    sort(s.begin(), s.end());
    if (ans % 10 == 0) {
        for (int i = 0; i < N; i++) {
            if (s[i] % 10 != 0) {
                ans -= s[i];
                break;
            }
            if (i == N - 1)
                ans = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(void){
    // Your code here!
    double a, b, x;
    cin >> a >> b >> x;
    
    double val = x - (a*a*b) / 2;
    if(val == 0) {
        printf("%.10f", 45.000000000);
        return 0;
    }
    
    double ans = 0;
    if(val > 0){
        ans = atan(2*(a*a*b - x) / (a*a*a));
    } else {
        ans = atan((a*b*b)/(2*x));
    }
    printf("%.10f", 180 * ans / M_PI);
}


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

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int main() {
    int a, b;
    cin >> a >> b;
    reg int ans = 0, res = 1;
    while (res < b) {
        res += a - 1;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in) ) {
            String[] line = sc.nextLine().split(" ");

            int h = Integer.valueOf(line[0]);
            int a = Integer.valueOf(line[1]);

            int n = h/a;
            if (h%a > 0) {
                n += 1;
            }

            // 出力
            System.out.println(n);
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

using namespace std;

int main()
{
    //system("chcp 65001");

    int N;
    cin >> N;

    cout << N*N*N;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define N 200005
#define mod 1000000007
#define rep(i,j,k) for (ll i=j;i<=k;++i)
#define per(i,j,k) for (ll i=j;i>=k;--i)
using namespace std;
inline ll read(){
	char ch=getchar(); ll x=0,f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}
ll n,ans=1,num[N];
int main(){
	n=read();
	rep(i,2,n){
		ll t=i;
		rep(j,2,t) while (!(t%j)) ++num[j],t/=j;
	}
	rep(i,1,n) (ans*=num[i]+1)%=mod;
	printf("%lld",ans);
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define read(x) int x; cin>>x;
#define print(x) for(int i=0; i<(int) x.size(); i++) cout<<x[i]<<" "; cout<<endl;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;

const ll INFLL = (ll) 1e16;
const int INF = (int) 1e8;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	read(n) read(k)
	string s;
	cin>>s;
	
	s[k-1] = 'a'+(s[k-1] -'A');
	cout<<s<<endl;
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
}

Measured memory_bytes: 3592
N = int(input())
S = input()

sl = 0
sr = 0
slmax = 0
srmax = 0
for i in range(N):
  if(S[i] == '('):
    sl -= 1
  else:
    sl += 1
  slmax = max(slmax, sl)
for i in range(N):
  if(S[N-i-1] == '('):
    sr += 1
  else:
    sr -= 1
  srmax = max(srmax, sr)
for i in range(slmax):
  S = '(' + S
for i in range(srmax):
  S = S + ')'
print(S)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define all(v) (v).begin(),(v).end()
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/
int modpow(int x, int n) {
  int res = 1;
  while (n > 0) {
    if (n & 1) {  // nが奇数のとき
      res *= x;
      res %= MOD;
    }
    x *= x;
    x %= MOD;
    n >>= 1;
  }
  return res;
}
int ncr(int n,int r){
  int res=1;
  rep(i,r) res=(res*(n-i))%MOD;
  int fact=1;
  FOR(i,1,r) fact=(fact*i)%MOD;
  res*=modpow(fact,MOD-2);
  res%=MOD;
  return res;
}

signed main(){
  int n,a,b;
  cin>>n>>a>>b;
  int ans=modpow(2,n)-1;
  ans-=ncr(n,a)+ncr(n,b);
  ans=(ans+3*MOD)%MOD;
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define ll long long
 
int main(){
  ll int a,b,c;
  scanf("%lld%lld%lld",&a,&b,&c);
  if(c>a && c>b && (a-b)*(a-b)+(c-b)*(c-b)+(c-a)*(c-a)>a*a+b*b+c*c){
    printf("Yes");
    return 0;
  }
  else{
    printf("No");
    return 0;
  }
     
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
vector<string> m;
int h, w;

int main(void)
{
    int white = 0;
    queue<int> queueX;
    queue<int> queueY;
    cin >> h >> w;
    REP(i, h)
    {
        string s;
        cin >> s;
        m.push_back(s);
    }
    REP(i, h)
    {
        REP(j, w)
        {
            if (m[i][j] == '#')
            {
                queueX.push(j);
                queueY.push(i);
            }
            else
            {
                white++;
            }
        }
    }
    int ans = 0;
    while (white > 0)
    {
        queue<int> cx;
        queue<int> cy;
        ans++;
        while (!queueX.empty())
        {
            cx.push(queueX.front());
            cy.push(queueY.front());
            queueX.pop();
            queueY.pop();
        }
        while (!cx.empty())
        {
            int x = cx.front();
            int y = cy.front();
            cx.pop();
            cy.pop();
            REP(i, 4)
            {
                int nx = x + dx[i];
                int ny = y + dy[i];
                if (nx < 0 || ny < 0 || nx >= w || ny >= h)
                    continue;
                if (m[ny][nx] == '#')
                    continue;
                m[ny][nx] = '#';
                white--;
                queueX.push(nx);
                queueY.push(ny);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9472
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = 25 - sc.nextInt();
        System.out.print("Christmas");
        for (int i = 0; i < d; i++) {
            System.out.print(" Eve");
        }
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }


int n,m;
int ans = 0;
vector<vector<int>> g;
vector<bool> visited;


void dfs(int cur){
	bool ok = true;
	rep(i,n) if(!visited.at(i)) ok = false;
	if(ok){
		ans++;
		return;
	}
	rep(i,g[cur].size()){
		int next = g[cur][i];
		if(visited.at(next)) continue;
		visited.at(next) = true;
		dfs(next);
		visited.at(next) = false;
	}
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	g.resize(n);
	rep(i,m){
		int a,b;cin >> a >> b;
		a--;b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	visited.resize(n);
	visited.at(0) = true;
	dfs(0);
	cout << ans << endl;
}


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

int main()
{
  int n, m;
  cin >> n >> m;
  Graph G(n);
  for (int i = 0; i < m; i++)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> prev(n, -1);
  queue<int> que;
  vector<int> dist(n, -1);
  que.push(0);
  dist[0] = 0;
  while (!que.empty())
  {
    int v = que.front();
    que.pop();
    for (auto nv : G[v])
    {
      if (dist[nv] == -1)
      {
        prev[nv] = v;
        dist[nv] = dist[v] + 1;
        que.push(nv);
      }
    }
  }

  vector<int> ans;
  for (int i = 1; i < n; i++)
  {
    int x = prev[i];
    if (x != -1)
    {
      ans.push_back(x + 1);
    }
  }
  if (ans.size() > 0)
  {
    cout << "Yes"
         << "\n";
    for (auto v : ans)
    {
      cout << v << "\n";
    }
  }
  else
  {
    cout << "No"
         << "\n";
  }
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
    priority_queue<ll, vector<ll>, greater<ll>> pq_a;
    priority_queue<ll, vector<ll>, greater<ll>> pq_b;
    priority_queue<ll, vector<ll>> pq_c;
    REP(i, A) {
        ll tmp; cin >> tmp;
        pq_a.push(tmp);
    }
    REP(i, B) {
        ll tmp; cin >> tmp;
        pq_b.push(tmp);
    }
    REP(i, C) {
        ll tmp; cin >> tmp;
        pq_c.push(tmp);
    }
    // それぞれX個Y個に絞る
    while((ll)pq_a.size()!= X) pq_a.pop();
    while((ll)pq_b.size()!= Y) pq_b.pop();
    //貪欲
    while(!pq_c.empty()) {
        ll min_a = pq_a.top();
        ll min_b = pq_b.top();
        ll max_c = pq_c.top(); pq_c.pop();
        if (min(min_a,min_b) >= max_c) break;
        if (min_a <= min_b) {
            pq_a.pop();
            pq_a.push(max_c);
        }
        else {
            pq_b.pop();
            pq_b.push(max_c);
        }
    }
    ll res = 0;
    while (!pq_a.empty())
    {
        res += pq_a.top();pq_a.pop();
    }
    while (!pq_b.empty())
    {
        res += pq_b.top();pq_b.pop();
    }
    
    
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3316
#include<stdio.h>
int main(void){
	int max[7],min[7];
	int sa[7];
	int i;
	for(i = 0;i < 7;i++){
		scanf("%d %d",&max[i],&min[i]);
		sa[i] = max[i] - min[i];
	}
	for(i = 0;i < 7;i++){
		printf("%d\n",sa[i]);
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n-1);

    cin >> b[0];
    a[0] = b[0];
    a[1] = b[0];
    for(int i=1; i<n-1; i++){
        cin >> b[i];
        if(b[i] < a[i]){
            a[i] = b[i];
        }
        a[i+1] = b[i];
    }

    int sum = 0;
    for(int i=0; i<n; i++){
        sum += a[i];
    }

    cout << sum << endl;
}

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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define repr(i, n) for (ll i = n - 1; i >= 0; --i)
#define INF 10e8
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

void solve(void)
{
    int n;
    cin >> n;
    vector<int> tmp;
    rep(i, n) tmp.push_back(i + 1);
    vector<int> A(n), B(n);
    rep(i, n) cin >> A[i];
    rep(i, n) cin >> B[i];
    int a, b, cta = 1;
    do
    {
        if (tmp == A)
            a = cta;
        if (tmp == B)
            b = cta;
        cta++;
    } while (next_permutation(all(tmp)));
    cout << abs(a - b) << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3564
#include<stdio.h>
int main(void)
{
    int S,h,m,s;
    scanf("%d",&S);
    if(S<60){printf("0:0:%d\n",S);}

    else if(S<3600){
            m=S/60;
            s=S%60;
            printf("0:%d:%d\n",m,s);
    }
    else {
        h=S/3600;
        m=S%3600/60;
        s=S%3600%60;
        printf("%d:%d:%d\n",h,m,s);
    }
return 0;

}

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

int main(){
    string s;
    cin >> s;
    int cnt=0;
    rep(i,s.size()-1){
        if(s[i]!=s[i+1]) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 512
/* 	* In the name of GOD 
	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
const int N = 1012, M = 10123;
int a[N], b[N], dp[M];

int32_t main(){
	int h, n;
	cin >> h >> n;
	for (int i = 0; i < M; i++) {
		dp[i] = 1000000000;
	}
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		for (int j = 0; j < M; j += a[i]) {
			dp[j] = min(dp[j], (j / a[i]) * b[i]);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < M - a[i]; j++) {
			dp[j + a[i]] = min(dp[j + a[i]], dp[j] + b[i]);
		}
	}
	int mn = 1000000000;
	for (int i = h; i < M; i++) {
		mn = min(mn, dp[i]);
	}
	cout << mn;
}


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

int main(){
    string a,b;
    cin>>a>>b;
    a = a+b;
    int c;
    istringstream x;
    x = istringstream(a);
    x >> c;
    bool flag = false;
    
    for(int i=1;i<=1000;i++){
        if(i*i==c){
            flag = true;
            break;
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


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

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int ans[110][110];
set<int> st[10010];

int main(){
    int n;
    cin >> n;
    int k = 2 * n * n - 2 * n;
    REP(i,k) {
        int a,b;
        cin >> a >> b;
        st[a].insert(b);
        st[b].insert(a);
    }
    int beg = 0;
    REP(i,n*n) {
        if (sz(st[i+1]) == 2) {
            beg = i+1;
            break;
        }
    }
    ans[0][0] = beg;
    ans[0][1] = *st[beg].begin();
    int right = ans[0][1];
    st[beg].erase(right);
    st[right].erase(beg);
    ans[1][0] = *st[beg].begin();
    int down = ans[1][0];
    st[beg].erase(down);
    st[down].erase(beg);
    int left;
    int up;
    for (int i = 0; i < n - 1; i++) {
        if (i != 0) {
            if (ans[i+1][0] == 0)
                ans[i+1][0] = *st[ans[i][0]].begin();
            up = ans[i][0];
            down = ans[i+1][0];
            st[up].erase(down);
            st[down].erase(up);
        }
        for (int j = 1; j < n; j++) {
            if (i == 0 && j == 0) continue;
            //下
            up = ans[i][j];
            left = ans[i+1][j-1];
            set<int> tmp;
            set_intersection(all(st[up]), all(st[left]), inserter(tmp, tmp.end()));
            if (ans[i+1][j] == 0)
                ans[i+1][j] = *tmp.begin();
            down = ans[i+1][j];
            st[down].erase(up);
            st[down].erase(left);
            st[up].erase(down);
            st[left].erase(down);

            if (j != n-1) {
                //右
                left = ans[i][j];
                if (ans[i][j+1] == 0)
                    ans[i][j+1] = *st[left].begin();
                int now = ans[i][j+1];
                st[now].erase(left);
                st[left].erase(now);
                if (i != 0) {
                    up = ans[i-1][j+1];
                    st[up].erase(now);
                    st[now].erase(up);
                }
            }
        }
    }
    if (ans[n-1][n-1] == 0)
        ans[n-1][n-1] = *st[ans[n-1][n-2]].begin();
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << ans[i][j] << " \n"[j == n-1];
        }
    }
    return 0;
}


Measured memory_bytes: 5476
X = open(0).readlines()
S = X[0].strip()
T = X[1].strip()
m, n = len(T), len(S)
if m > n:
    print('UNRESTORABLE')
else:
    for i in range(n-m, -1, -1):
        U = S[i:i+m]
        if all(u == t or u == '?' for u, t in zip(U, T)):
            V = list(S.replace('?', 'a'))
            for j in range(m):
                V[i+j] = T[j]
            print(''.join(V))
            break
    else:
        print('UNRESTORABLE')

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;

ll n;
int B(ll x) {
    int c = 0;
    while (x) {
        x /= 10;
        ++c;
    }
    return c;
}
int main() {
    cin >> n;
    int ans = 1e9;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ll d = n / i;
            ans = min(ans, max(B(i),B(d)));
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){

  int n;
  vector<int> v;
  cin >> n;
  for (int i = 0; i < n; i++){
    int k;
    scanf("%d", &k);
    v.push_back(k);
  }
  int count = 0;
  for (int i = 0; i < n; i++){
    if (v[i] == i+1) {
      i++;
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 892
mod utils {
    use std::error::Error;
    use std::io::stdin;
    use std::str::FromStr;

    #[allow(dead_code)]
    pub fn read_line<T>() -> Result<Vec<T>, Box<Error>>
    where
        T: FromStr,
        T::Err: 'static + Error,
    {
        let mut line = String::new();
        let _ = stdin().read_line(&mut line)?;
        let parsed_line = line.split_whitespace()
            .map(|x| x.parse::<T>())
            .collect::<Result<Vec<T>, T::Err>>()?;

        Ok(parsed_line)
    }

    #[allow(dead_code)]
    pub fn read_lines<T>(n: usize) -> Result<Vec<Vec<T>>, Box<Error>>
    where
        T: FromStr,
        T::Err: 'static + Error,
    {
        (0..n).map(|_| read_line()).collect()
    }
}

fn solve() -> Result<(), Box<std::error::Error>> {
    let n_queries = utils::read_line::<usize>()?[0];
    let queries = utils::read_lines::<i32>(n_queries)?;

    for q in queries {
        let a = (q[2] - q[0], q[3] - q[1]);
        let b = (q[6] - q[4], q[7] - q[5]);

        let result = if a.0 * b.0 + a.1 * b.1 == 0 {
            1
        } else if a.0 * b.1 - a.1 * b.0 == 0 {
            2
        } else {
            0
        };

        println!("{}", result);
    }

    Ok(())
}

fn main() {
    match solve() {
        Err(err) => panic!("{}", err),
        _ => (),
    };
}



Measured memory_bytes: 5048
using System;

namespace ABC_050_A_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            var word = Console.ReadLine().Split(' ');
            int A = int.Parse(word[0]);
            string op = (word[1]);
            int B = int.Parse(word[2]);
            if (op == "+")
            {
                Console.WriteLine(A + B);
            }
            else if (op == "-")
            {
                Console.WriteLine(A - B);
            }
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false



int main() {
	string s, t;
	cin >> s >> t;
	sort(all(s));
	sort(all(t), greater<char>());

	cout << (s < t ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
		cout << 0 << endl;
	}else{
		ll ans = min(a * b, b * c);
		cout << min(ans, a * c) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())

S = [i for i in range(1, 14)]
H = [i for i in range(1, 14)]
C = [i for i in range(1, 14)]
D = [i for i in range(1, 14)]

for i in range(n) :
    m, r = map(str, input().split())
    
    if m == "S" :
        S.remove(int(r))
    elif m == "H" :
        H.remove(int(r))
    elif m == "C" :
        C.remove(int(r))
    else :
        D.remove(int(r))
        
if len(S) > 0 :
    for i in range(len(S)) :
        print("S", S[i])
if len(H) > 0 :
    for i in range(len(H)) :
        print("H", H[i])
if len(C) > 0 :
    for i in range(len(C)) :
        print("C", C[i])
if len(D) > 0 :
    for i in range(len(D)) :
        print("D", D[i])


Measured memory_bytes: 5624
from collections import defaultdict
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    S = input()[:-1]
    GX, GY = map(int, input().split())

    # 連続するFをまとめる ex.)FF->2
    # 連続するTをまとめる ex.)TTT->T
    S_parsed = []
    prev = S[0]
    seq = 1
    for c in S[1:]:
        if c == "F":
            if c == prev:
                seq += 1
            else:
                prev = c
                if seq % 2 == 0:
                    pass
                else:
                    S_parsed.append("T")
                seq = 1
        elif c == "T":
            if c == prev:
                seq += 1
            else:
                S_parsed.append(seq)
                seq = 1
            prev = c
    else:
        if S[-1] == "F":
            S_parsed.append(seq)

    # x,yを分離して考える
    x_move = []
    y_move = []

    dir_x = True
    for c in S_parsed:
        if c == "T":
            dir_x = not dir_x
        else:
            if dir_x:
                x_move.append(c)
            else:
                y_move.append(c)

    # x,y分けて、GX,GYに到達できるかをdpで判定
    dp_x = set()
    if len(x_move) > 0:
        if S[0] != "T":
            # Fから始まる場合は、正の方向からスタート
            dp_x.add(x_move[0])
        else:
            # TTから始まってたら、どっち方向からでもスタートできる
            dp_x.add(x_move[0])
            dp_x.add(-x_move[0])
    else:
        dp_x.add(0)

    for x in x_move[1:]:
        dp_x = {key+x for key in dp_x} | {key-x for key in dp_x}

    dp_y = set()
    if len(y_move) == 0:
        dp_y.add(0)
    else:
        dp_y.add(y_move[0])
        dp_y.add(-y_move[0])
    for y in y_move[1:]:
        dp_y = {key+y for key in dp_y} | {key-y for key in dp_y}

    if GX in dp_x and GY in dp_y:
        print("Yes")
    else:
        print("No")


solve()


Measured memory_bytes: 5288
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

#define MAX 10000

int a[MAX+2] = {0};

int main(int argc, char* argv[]){
	int N;
	cin >> N;

	long long ans = 0;
	for(int i=1; i<=N; i++){
		cin >> a[i];
		int b = a[i];
		int d = 0;
		while(true){
			if(b % 2 !=0) break;
			b = b / 2;
			d++;
		}
		ans += d;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
    int64_t n;
    cin >> n;
    vector<int> a;

    for (int i = 0; i < n; i++) {
        int64_t tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    sort(a.begin(), a.end());

    int min = a.at(0);
    int max = a.at(n - 1);
    int64_t sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a.at(i);
    }

    cout << min << " " << max << " " << sum << endl;

    return 0;
}


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

int main() {
  // input
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  
  int cnt= 0;

  for(int i=0; i<=A; i++){ // loop in [0,A]
    for(int j=0; j<=B; j++){
      int res= X- 500*i - 100*j;
      int nec50 = res/50;
      if( nec50<0 ){
        break;
      }
      else if( nec50<=C ){
      	cnt++;
      }
    }
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/*
    Ball and Boxes 5
    女、男、ひとりまで(椅子取りゲーム形式)
*/

int main() {
    ll n, k;
    cin >> n >> k;
    COMinit();

    ll ans = COM(k,n);

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



Measured memory_bytes: 15076
class RollingHash():
    def __init__(self, s):
        self.mask30 = (1 << 30) - 1
        self.mask31 = (1 << 31) - 1
        self.length = len(s)
        self.base = 1009
        self.mod = (1 << 61) - 1
        self.hash = [0] * (self.length + 1)
        self.pow = [1] * (self.length + 1)

        for i in range(self.length):
            self.hash[i+1] = self.calcmod(self.mul(self.hash[i], self.base) + ord(s[i]))
            self.pow[i+1] = self.calcmod(self.mul(self.pow[i], self.base))
    
    def mul(self, l, r):
        lu = l >> 31
        ld = l & self.mask31
        ru = r >> 31
        rd = r & self.mask31
        middle = ld * ru + lu * rd
        return ((lu * ru) << 1) + ld * rd + ((middle & self.mask30) << 31) + (middle >> 30)
    
    def calcmod(self, val):
        val = (val & self.mod) + (val >> 61)
        if val > self.mod:
            val -= self.mod
        return val

    def get(self, l, r):
        t = self.hash[r] - self.hash[l] * self.pow[r-l] % self.mod
        t = (t + self.mod) % self.mod
        return t

n = int(input())
s = input()
RH = RollingHash(s)

def check(l):
    place = {}
    for i in range(n - l + 1):
        hs = RH.get(i, i + l)
        if hs in place:
            if i - place[hs] >= l:
                return True
        else:
            place[hs] = i
    return False

l = 0; r = n // 2 + 1
while r - l > 1:
    m = (l + r) // 2
    if check(m):
        l = m
    else:
        r = m

print(l)

Measured memory_bytes: 45800
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int W = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		if(Math.abs(a - b) <= W){
			System.out.println("0");
		}else{
			System.out.println(Math.abs(a - b) - W);
		}
		
	}

}

Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <tuple>
using namespace std;

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr, class func> void array_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr, class func> void nint_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += string(out(*i)) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

int main(){
    string s;
    cin >> s;
    int ans = 1;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '('){
            ans += (s[s.size() - i - 1] != ')');
        }else if(s[i] == ')'){
            ans += (s[s.size() - i - 1] != '(');
        }else{
            ans += (s[i] != s[s.size() - i - 1]);
        }
    }
    cout << ans / 2 << endl;
}




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

double g[100][100];
double dp[100][100];

int main(){
	int n, m;
	while(scanf("%d%d", &n, &m), n){
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < n; ++j){
				scanf("%lf", &g[i][j]);
			}
		}

		for(int j = 0; j < n; ++j){
			dp[0][j] = 1.0;
		}
		for(int i = 1; i < m; ++i){
			for(int j = 0; j < n; ++j){
				dp[i][j] = -1.0;
				
				for(int k = 0; k < n; ++k){
					dp[i][j] = max(dp[i][j], dp[i-1][k] * g[k][j]);
				}
			}
		}

		double ans = -1.0;
		for(int j = 0; j < n; ++j){
			ans = max(ans, dp[m-1][j]);
		}
		printf("%.2f\n", ans);
	}
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int base = 2001, maxn = 4005, P = 1e9 + 7;
int n;
ll ans;
int a[200005], b[200005];
ll dp[maxn][maxn], inv[maxn * 2], facinv[maxn * 2], fac[maxn * 2];
ll C(int n, int m) {
	return fac[n] * facinv[m] % P * facinv[n - m] % P;
}
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) {
		scanf("%d%d", &a[i], &b[i]);
		++dp[-a[i] + base][-b[i] + base];
	}
	for(int i = 1; i < maxn; ++i) {
		for(int j = 1; j < maxn; ++j) {
			dp[i][j] = (dp[i][j] + dp[i - 1][j] + dp[i][j - 1]) % P;
		}
	}
	for(int i = 1; i <= n; ++i) {
		ans = (ans + dp[a[i] + base][b[i] + base]) % P;
	}
	fac[0] = fac[1] = inv[0] = inv[1] = facinv[0] = facinv[1] = 1;
	for(int i = 2; i < 2 * maxn; ++i) {
		inv[i] = (P - P / i) * inv[P % i] % P;
		facinv[i] = facinv[i - 1] * inv[i] % P;
		fac[i] = fac[i - 1] * i % P;
	}
	for(int i = 1; i <= n; ++i) {
		ans = ((ans - C(2 * a[i] + 2 * b[i], 2 * a[i])) % P + P) % P;
	}
	printf("%lld\n", ans * inv[2] % P);
	return 0;
}

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

int main(){
    string s;
    cin>>s;
    if (s[0] != 'A') cout<<"WA"<<endl;
    else{
        int capital_c_number = 0;
        for (int i=2;i<s.length()-1;i++){
            if (s[i] == 'C') capital_c_number++;
        }
        if (capital_c_number != 1) cout<<"WA"<<endl;
        else{
            int capital_letter_number = 0;
            for (int i=0;i<s.length();i++){
                if (isupper(s[i])) capital_letter_number++;;
            }
            if (capital_letter_number != 2) cout<<"WA"<<endl;
            else cout<<"AC"<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (x, y, z, k) = readLine()!!.split(' ').map { it.toInt() }
    val cakesA = readLine()!!.split(' ').map { it.toLong() }.sortedDescending()
    val cakesB = readLine()!!.split(' ').map { it.toLong() }.sortedDescending()
    val cakesC = readLine()!!.split(' ').map { it.toLong() }.sortedDescending()

    val set = mutableSetOf<Cakes>()

    val queue = PriorityQueue<Cakes>()

    Cakes(cakesA[0] + cakesB[0] + cakesC[0], 0, 0, 0).let {
        set.add(it)
        queue.add(it)
    }

    repeat(k) {

        val cakes = queue.poll()
        println(cakes.value)

        val (a, b, c) = cakes.indices()

        if (a + 1 < x) {
            Cakes(cakesA[a + 1] + cakesB[b] + cakesC[c], a + 1, b, c).let {
                if (set.contains(it)) {
                    return@let
                }
                set.add(it)
                queue.add(it)
            }
        }

        if (b + 1 < y) {
            Cakes(cakesA[a] + cakesB[b + 1] + cakesC[c], a, b + 1, c).let {
                if (set.contains(it)) {
                    return@let
                }
                set.add(it)
                queue.add(it)
            }
        }

        if (c + 1 < z) {
            Cakes(cakesA[a] + cakesB[b] + cakesC[c + 1], a, b, c + 1).let {
                if (set.contains(it)) {
                    return@let
                }
                set.add(it)
                queue.add(it)
            }
        }

    }

}

private data class Cakes(val value: Long, val a: Int, val b: Int, val c: Int): Comparable<Cakes> {

    override fun compareTo(other: Cakes): Int {
        return -value.compareTo(other.value)
    }

    fun indices(): Triple<Int, Int, Int> {
        return Triple(a, b, c)
    }

}

class PriorityQueue<E> where E: Comparable<E> {

    private val heap = mutableListOf<E>()

    var size = 0
        private set

    fun add(x: E) {
        var i = size++

        while (i > 0) {
            val p = (i - 1) / 2

            if (compare(x, heap[p]) >= 0) break

            set(i, heap[p])
            i = p
        }

        set(i, x)
    }

    private fun compare(a: E, b: E): Int {
        return a.compareTo(b)
    }

    private fun set(i: Int, x: E) {
        if (i < heap.size) {
            heap[i] = x
        } else {
            heap.add(i, x)
        }
    }

    fun peek(): E {
        return heap[0]
    }

    fun poll(): E {
        val ret = heap[0]

        val x = heap[--size]
        var i = 0
        while (i * 2 + 1 < size) {
            val l = i * 2 + 1
            val r = i * 2 + 2
            val p = if (r < size && compare(heap[r], heap[l]) < 0) r else l

            if (compare(x, heap[p]) <= 0) break

            heap[i] = heap[p]
            i = p
        }
        set(i, x)

        return ret
    }

}


Measured memory_bytes: 41240
input()
rates = sorted([int(x) for x in input().split()])
least = 0
for boundary in (399, 799, 1199, 1599, 1999, 2399, 2799, 3199):
    length = len(rates)
    while rates and (rates[0] <= boundary):
        rates.pop(0)
    least += length > len(rates)
print("{} {}".format((least == 0)+least, least+len(rates)))

Measured memory_bytes: 3060
/*
*  Problem Link: https://atcoder.jp/contests/abc172/tasks/abc172_a
*  Author: Raunak Sett
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long 
#define vi vector<int>
int main() {
    IOS
    // Code Here
    int a;
    cin>>a;
    cout<<a + a*a + a*a*a<<endl;
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<complex>
using namespace std;

int main(){
  while(true){
    int h,w; cin >> h >> w;
    if(h == 0 && w == 0) break;
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3092
/*
  Author: Hamza Hasbi
*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define uld unsigned long double
#define ui unsigned int
#define ud unsigned double
#define uf unsigned float
#define pi 2*acos(0.0)
#define module cin.ignore()
#define rep(i,l,r) for(auto i=l;i<=r;i++)
#define range(x,y) for(auto x:y)
//inline long long lcm(ll a,ll b) {return a*b/__gcd(a,b);}
//inline long long gcd(ll a,ll b) {return 1LL*b == 0 ? a : gcd(1LL*b, a*1LL % b*1LL);}
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin >> s;
    int sum = 700;
    range(c, s) {
      sum += (c == 'o') * 100;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256