akhauriyash/Code-Regression huggingface dataset:
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n;
	cin >> n;
	int answer = INT_MAX;
	while(n--)
	{
		int a;
		cin >> a;
		int count = 0;
		while(!(a % 2))
		{
			a /= 2;
			++count;
		}
		answer = min(answer, count);
	}
	cout << answer << '\n';
}

Measured memory_bytes: 3656
n = int(input())
e = [0 for i in range(n + 1)]

for i in range(2, n + 1):
    cur = i
    for j in range(2, i + 1):
        while cur % j == 0:
            e[j] += 1
            cur //= j

def num(m):
    return len(list(filter(lambda x: x >= m - 1, e)))

print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) + num(5) * (num(5) - 1) * (num(3) - 2) // 2)

Measured memory_bytes: 3064
import java.awt.geom.Point2D;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

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

	public Main() {
		while(sc.hasNext()){
			new AOJ().doIt();
		}
	}
	class AOJ{
		void doIt(){
			boolean card[] = new boolean[10];
			int C1 = Integer.parseInt(sc.next());
			int C2 = Integer.parseInt(sc.next());
			int C3 = Integer.parseInt(sc.next());
			card[C1 - 1] = true;
			card[C2 - 1] = true;
			card[C3 - 1] = true;
			
			int my_C = C1 + C2;
			int your_C = C3;
			
			int cnt = 0;
			for(int i = 0;i < 10;i++){
				if(!card[i]){
					if(my_C + i + 1 <= 20)cnt++;
				}
			}
			
			if(cnt < 4)System.out.println("NO");
			else System.out.println("YES");
		}
	}
}

Measured memory_bytes: 25968
#include <stdio.h>
#include <string.h>

int main()
{
	char day[4];
	scanf("%s", day);

	if (strcmp(day, "SUN") == 0) {
		printf("7\n");
	} else if (strcmp(day, "MON") == 0) {
		printf("6\n");
	} else if (strcmp(day, "TUE") == 0) {
		printf("5\n");
	} else if (strcmp(day, "WED") == 0) {
		printf("4\n");
	} else if (strcmp(day, "THU") == 0) {
		printf("3\n");
	} else if (strcmp(day, "FRI") == 0) {
		printf("2\n");
	} else if (strcmp(day, "SAT") == 0) {
		printf("1\n");
	}

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
 
vector<int>E[200000];
int in[200000];
int dp[200000];
 
int main(){
	int n,m;scanf("%d%d",&n,&m);
	rep(i,m){
		int x,y;scanf("%d%d",&x,&y);x--;y--;
		E[x].push_back(y);
		in[y]++;
	}
	queue<int>que;
	rep(i,n){
		if(!in[i]){
			que.push(i);
		}
	}
	while(!que.empty()){
		int p=que.front();que.pop();
		for(int u:E[p]){
			dp[u]=max(dp[u],dp[p]+1);
			in[u]--;
			if(!in[u])que.push(u);
		}
	}
	cout<<*max_element(dp,dp+n)<<endl;
}


Measured memory_bytes: 8832
/* be name khoda */

// #define stream_enable
#define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl;
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl;
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl;
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl;
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl;
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_da].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = (a + (b)) % MOD
#define Mul(a, b) a = (a * (b)) % MOD

stringstream sss;

// -----------------------------------------------------------------------

const ll maxn = 100010;

void MAIN() {

    ll n, a, b;
    cin >> n >> a >> b;
    if (a < b) swap(a, b);
    ll ans = min(a - 1, n - b);
    if ((a - b) % 2 == 0) {
        smin(ans, (a - b) / 2);
    }
    smin(ans, b + (a - b) / 2);
    smin(ans, n - a + 1 + (a - b) / 2);
    cout << ans << '\n';

}

// -----------------------------------------------------------------------

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(
5 2 4
    )";
    MAIN();
    return 0;
}


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

int A, B, N;
bool Answer[100009];

int main() {
	cin >> A >> B; N = A + B;

	if (A <= B) {
		cout << "Impossible" << endl;
		return 0;
	}

	vector<int> vec;
	for (int i = 0; i < N; i++) vec.push_back(i);
	int last = -1, truth = -1;

	while (true) {
		if (vec.size() == 1) { truth = vec[0]; break; }
		if (vec.size() % 2 == 1) last = vec[vec.size() - 1];

		vector<int> r;
		for (int i = 0; i < vec.size() - 1; i += 2) {
			cout << "? " << vec[i] << " " << vec[i + 1] << endl;
			string x; cin >> x;
			if (x == "Y") r.push_back(vec[i + 1]);
		}

		if (r.size() == 0) { truth = last; break; }
		vec = r;
	}

	for (int i = 0; i < N; i++) {
		cout << "? " << truth << " " << i << endl;
		string x; cin >> x;
		if (x == "Y") Answer[i] = true;
	}
	cout << "! "; for (int i = 0; i < N; i++) cout << (int)Answer[i]; cout << endl;
	return 0;
}

Measured memory_bytes: 744
#include<iostream>
#include<vector>
using namespace std;
int main (void)
{
	int N, P;
	cin >> N >> P;
	vector<int> S (N);
	char input;
	for (auto &e: S)
	{
		cin >> input;
		e = input -'0';
	}
	
	long count = 0;
	vector<long> Dictionary (P, 0);
	if (P!= 2 && P != 5)
	{
		int tmp = 0;
		Dictionary [0]++;
		int tenfactor = 1;
		for (int i = 0; i < N; i++)
		{
			tmp = (tmp+S[N-1-i]*tenfactor) % P;
			Dictionary [tmp]++;
			tenfactor = (tenfactor*10)%P;
		}
		for (int j = 0; j < P; j++)
		{
			long Daburi = Dictionary [j];
			count += Daburi*(Daburi-1)/2;
		}
	}
	else
	{
		for (int i = 0; i < N; i++)
			if (S[i] % P == 0)
				count += i+1;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
int main() 
{
    buff();
    ll a, b, n;
    cin >> a >> b >> n;
    ll cand = 1ll;
    ll cand2 = min(b - 1ll, n);
    
    auto res = [&] (ll x) {
        ll fst = (a * x) / b;
        ll sec = a * (x / b);
        return fst - sec;
    };

    ll best = max(res(cand), res(cand2) );

    cout << best << '\n';

    return 0;
}



Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main()
{
    int d;
    cin>>d;
    if(d==25)
        cout<<"Christmas"<<endl;
    else if(d==24)
        cout<<"Christmas Eve"<<endl;
    else if(d==23)
        cout<<"Christmas Eve Eve"<<endl;
    else if(d==22)
        cout<<"Christmas Eve Eve Eve"<<endl;
    return 0;
}


Measured memory_bytes: 256
import itertools

N, X, Y = map(int, input().split())

result = [0]*(N-1)
list = list(itertools.combinations(list(range(1,N+1)),2))
for i in list:
    g = i[1]-i[0]
    j = abs(Y-i[1]) + abs(X-i[0]) + 1
    result[min([g,j])-1] += 1

for i in result:
    print(i)

Measured memory_bytes: 148524
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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 T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int fib (int a) {
    if (a <= 1) return 1;
    else return fib(a - 1) + fib(a - 2);
}

constexpr int MOD = 1000000007;
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, k; cin >> h >> w >> k;
    vector<vector<int> > dp(h + 1, vector<int>(w, 0));
    vector<vector<int> > way(w, vector<int>(w, 0));
    rep (i, w) {
        rep (j, w) {
            if (i == j) way[i][j] = fib(i) * fib(w - 1 - i);
            else if (abs(i - j) == 1) way[i][j] = fib(min(i, j)) * fib(w - 1 - max(i, j));
            // eprintf("%2d ", way[i][j]);
        }
        // eprintf("\n");
    }
    dp[0][0] = 1;
    rep (i, h) {
        rep (x, w) {
            rep (y, w) {
                dp[i + 1][y] = ((ll)dp[i + 1][y] + ((ll)way[x][y] * dp[i][x]) % MOD) % MOD;
            }
        }
    }
    cout << dp[h][k - 1] << "\n";
    return 0;
}

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

# 期待値:マス目の総和／マス目の数, マス目の最大値+最小値[1]／2
l = [(i+1)/2 for i in l] # 期待値に変換

# 累積和を取得
from itertools import accumulate
cum = [0] + list(accumulate(l))

# 差分を考慮しつつ k個の和をリストする → 最大値が ans
sum_k = []
for j in range(n-k+1):
    sum_k.append(cum[k+j] - cum[j])

print(max(sum_k))


Measured memory_bytes: 32432
def challenge_optimize(baggages, track_num, capacity)
	baggage_index = 0
	track_num.times do |track_index|
		loaded = 0
		while (loaded + baggages[baggage_index]) <= capacity
			loaded += baggages[baggage_index]
			baggage_index += 1
			return baggages.size if baggage_index == baggages.size
		end
	end
	baggage_index
end

MAX_NUM_OF_BAGGAGES = 100000
MAX_BAGGAGE_WEIGHT  = 10000
baggage_num, track_num = STDIN.gets.split[0...2].map(&:to_i)
baggages = []
baggage_num.times { baggages << STDIN.gets.to_i }

range = (0..MAX_NUM_OF_BAGGAGES * MAX_BAGGAGE_WEIGHT)
p range.bsearch { |n| challenge_optimize(baggages, track_num, n) >= baggage_num }

Measured memory_bytes: 7028
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define S second
#define F first

using namespace std;

const int N = 1e6 + 5, mod = 1e9 + 7;

int main()
{
    string s[] = {"Sunny", "Cloudy", "Rainy"};
    string a;
    cin>>a;
    for(int i = 0 ; i < 3 ; i++)
    {
        if(a == s[i])
        {
            return cout<<s[(i+1)%3]<<endl, 0;
        }
    }
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

const ll mod=924844033;

ll dp[4001][4001][2]={0};
ll fact[2001];

int main()
{
    fact[0]=1;
    for(ll i=1; i<=2000; ++i) fact[i]=(i*fact[i-1])%mod;

    int n,k;
    cin >>n >>k;

    vector<bool> vis(2*n,false);
    vector<pi> edge;
    vector<bool> conneced_prev;
    rep(i,n)
    {
        if(vis[i]) continue;

        int ii=i;
        int jj=i-k;
        if(jj<0) jj+=2*k;

        if(jj>=n) continue;

        edge.pb(pi(ii,jj));
        conneced_prev.pb(false);
        while(1)
        {
            if(ii<jj) ii+=2*k;
            else jj+=2*k;

            if(ii>=n || jj>=n) break;

            edge.pb(pi(ii,jj));
            conneced_prev.pb(true);
            vis[ii]=vis[jj+n]=true;
        }
    }

    int E=edge.size();
    // rep(i,E) printf(" edge %d = (%d,%d) , prev=%d\n", i,edge[i].fi,edge[i].se+n, (int)conneced_prev[i]);

    dp[0][0][0]=1;
    rep(i,E)
    {
        rep(j,i+1)
        {
            // i番目の辺を使う
            (dp[i+1][j+1][1] += dp[i][j][0]) %= mod;
            if(!conneced_prev[i]) (dp[i+1][j+1][1] += dp[i][j][1]) %= mod;

            // i番目の辺を使わない
            (dp[i+1][j][0] += dp[i][j][0]+dp[i][j][1]) %= mod;
        }
    }

    vector<ll> M(E+1);
    rep(i,E+1) M[i] = (dp[E][i][0]+dp[E][i][1])%mod;

    ll sub=0;
    for(int i=1; i<=min(E,n); ++i)
    {
        if(i%2==0) sub = (sub - (M[i]*fact[n-i])%mod + mod)%mod;
        else sub = (sub + (M[i]*fact[n-i])%mod)%mod;
    }

    ll ans=(fact[n]-sub+mod)%mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 140800
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc131/tasks/abc131_b

n, l = [int(x) for x in input().split()]
a = [(i, l + i) for i in range(n)]
a.sort(key=lambda x: abs(x[1]))
a.pop(0)
print(sum([x[1] for x in a]))


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

#define pb push_back
#define PQ priority_queue
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

typedef long long ll;
typedef long double ld;

//__builtin_popcount(x)

using namespace std;

const int mod = 1e9 + 7;

ll add(ll a, ll b) {
    ll res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

ll sub(ll a, ll b) {
    ll res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

ll mul(ll a, ll b) {
    return (((a % mod) * (b % mod)) % mod);
}

/*vector<int> find_dividers(int x) {
    vector<int> dividers;

    for (int i = 1; i <= sqrt(x); i++) {
        if (x % i == 0) {
           dividers.push_back(i);
            if (i * i != x) {
                dividers.push_back(x / i);
            }
        }
    }

    return dividers;
}*/

/*int nok(int a, int b) {
    return a / __gcd(a, b) * b;
}*/

int ans = 0;
vector<bool> used;
vector<set<int>> g;
vector<int> comp;

void dfs(int u) {
    used[u] = true;
    comp.pb(u);
    for (auto& v : g[u]) {
        if (!used[v]) {
            dfs(v);
        }
    }
}

void solve() {
    int n, m;
    cin >> n >> m;
    g.resize(n + 1);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        g[x].insert(y);
        g[y].insert(x);
    }
    used.resize(n + 1);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (!used[i]) {
            comp.clear();
            dfs(i);
            if ((int)comp.size() > ans) ans = (int)comp.size();
        }
    }
    cout << ans << endl;
}

/*

1: 3, 4
3: 1
4: 1
9: 5
6: 2
5: 9
2: 6

2 3 10
1 5 8 7
4 6 9

*/

/*

a1 a2 a3 a4 a5

ans = a1*a2 + a1*a3 + a1*a4 + a1*a5 + a2*a3 + a2*a4 + a2*a5 + ... + a4*a5;

a1a2 a1a3 a1a4 a1a5
     a2a3 a2a4 a2a5
          a3a4 a3a5
               a4a5
map ???


*/

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

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 44740
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
signed main(){
char a[3][3];
  rep(i,3)rep(j,3)
    cin>>a[i][j];
  rep(i,3)
    cout<<a[i][i];
}

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

int main() {
    string s, t;
    cin >> s;
    int mn = 101;
    char c;
    int l = s.size();
    bool o = true;
    for (int i = 1; i < l; i++) {
        if (s[0] != s[i]) {
            o = false;
            break;
        }
    }
    if (o) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 0; i < 26; i++) {
        c = 'a' + i;
        t = s;
        int cnt = 1;
        for (int j = l - 1; j > 0; j--) {
            for (int k = 0; k < j; k++) {
                if (t[k + 1] == c) {
                    t[k] = t[k + 1];
                }
            }
            bool ok = true;
            for (int k = 1; k < j; k++) {
                if (t[0] != t[k]) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                break;
            }
            cnt++;
        }
        mn = min(mn, cnt);
    }
    cout << mn << endl;
}

Measured memory_bytes: 256
from collections import deque
def resolve():
    drc = [(-1, 0), (0, 1), (1, 0), (0, -1)]
    warp = [(i, j) for j in range(-2, 3) for i in range(-2, 3) if (i, j) not in drc + [(0, 0)]]
    
    H, W = map(int, input().split())
    sy, sx = map(lambda x: int(x) - 1, input().split())
    gy, gx = map(lambda x: int(x) - 1, input().split())
    
    G = [input() for _ in range(H)]

    dist = [[-1] * W for _ in range(H)]
    q = deque()
    q.append((sy, sx))
    dist[sy][sx] = 0

    while True:
        visited = []
        while q:
            sy, sx = q.popleft()
            visited.append((sy, sx))
            for dy, dx in drc:
                ny = dy + sy
                nx = dx + sx
                if 0 <= ny < H and 0 <= nx < W and G[ny][nx] == "." and dist[ny][nx] == -1:
                    dist[ny][nx] = dist[sy][sx]
                    q.appendleft((ny, nx))

        for sy, sx in visited:
            for dy, dx in warp:
                ny = dy + sy
                nx = dx + sx
                if 0 <= ny < H and 0 <= nx < W and G[ny][nx] == "." and dist[ny][nx] == -1:
                    dist[ny][nx] = dist[sy][sx] + 1
                    q.append((ny, nx))

        if not q or dist[gy][gx] != -1:
            print(dist[gy][gx])
            return


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 93668
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    string s;
    cin>>a>>b>>s;
    vector<char> v;
    if(s.size()!=a+b+1)
    {
    	cout<<"No";
    	return 0;
    }
    for(int i=0;i<=a+b;i++)
    v.push_back(s[i]);
	if(v[a]!='-')
	{
		cout<<"No";
		return 0;
	} 
	else
	{
		for(int i=0;i<a;i++)
		if(s[i]>'9'||s[i]<'0')
		{
			cout<<"No";
			return 0;
		}
		for(int i=a+1;i<a+b+1;i++)
		if(s[i]>'9'||s[i]<'0')
		{
			cout<<"No";
			return 0;
		}
	} 
	cout<<"Yes";
	return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,A,B;
	scan(N);
	if(N==1) prin("Hello World");
	else{
		scan(A);scan(B);
		prin(A+B);
	}
	return 0;
}


Measured memory_bytes: 256
n=int(input())
l=[input() for i in range(n)]
l.sort()
ll=list(set(l))
ll.sort()
m=len(ll)
ans=[0]*m
count=0
j=0
for i in range(len(l)-1):
  if l[i]==l[i+1]:
    count+=1
    if i+1==n-1:
      ans[j]+=count
  else:
    ans[j]+=count
    count=0
    j+=1
g=max(ans)
for i in range(m):
  if ans[i]==g:
    print(ll[i])
  

Measured memory_bytes: 29628
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A.at(i);
    sort(all(A));
    reverse(all(A));
    
    bool can = true;
    if ((N % 2) == 1) can = false;
    ll ans = A.at(0);
    ll num = (N - 1) / 2;
    
    if(can){
        rep(i, 1, 1 + num){
            ans += A.at(i) * 2;
        }
    }
    else{
        rep(i, 1, num){
            ans += A.at(i) * 2;
        }
        ans += A.at(num);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 4844
N = 2019
cnt = [0] * N
S = input()
ans = 0
for s in S:
    s = int(s)
    new = [0] * N
    for n in range(N):
        idx = (10 * n + s) % N
        new[idx] += cnt[n]
    cnt = new
    cnt[s] += 1
    ans += cnt[0]
print (ans)

Measured memory_bytes: 76456
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
long long dp[100010];
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
#define rep(i,n) for(int i=0;i<n;i++)
//bitset<64>(x).count()
//fixed << setprecision(15) << 
int a[10][2] = {} ;
double dist(int x, int y){
  double ans;
  ans = pow(pow(a[x][0]-a[y][0],2)+pow(a[x][1]-a[y][1],2),0.5);
  return ans ;
}

int main (){
  int n;
  cin >> n;
  int p[n], q[n];
  rep(i,n){
    cin >> p[i];
    p[i]--;
  }
  rep(i,n){
    cin >> q[i];
    q[i]--;
  }
  int o[n], ans = 0;
  rep(i,n){
    o[i] = i;
  }
  int j = 0;
  do{
    bool flag = true;
    rep(i,n){
      if(p[i]!=o[i])
        flag = false;
    }
    if(flag){
      ans += j;
      break;
    }
    j++;
  }while(next_permutation(o,o+n));
  j = 0;
  rep(i,n){
    o[i] = i;
  }
  do{
    bool flag = true;
    rep(i,n){
      if(q[i]!=o[i])
        flag = false;
    }
    if(flag){
      ans -= j;
      break;
    }
    j++;
  }while(next_permutation(o,o+n));
  cout << abs(ans) << endl;
}

Measured memory_bytes: 3660
import itertools
N,M=map(int,input().split())
edges={tuple(sorted(map(int,input().split()))) for i in range(M)}
ans=0
for i in itertools.permutations(range(2,N+1),N-1):
    l=[1]+list(i)
    ans +=sum(1 for edge in zip(l,l[1:]) if tuple(sorted(edge)) in edges)==N-1
print(ans)

Measured memory_bytes: 3064
object Main extends App {

  import scala.io.StdIn._
  import scala.math._
  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val inns = Array.tabulate(n - 1){_ ⇒ readLine.trim.toInt}.also{arr ⇒ (1 until arr.length).foreach(i ⇒ arr(i) += arr(i - 1))}.let{0 +: _}
  var current = 0
  var sumTime = 0L
  for (_ ← 0 until m){
    val a = readLine.trim.toInt
    sumTime += math.abs(inns(current + a) - inns(current))
    sumTime %= 100000
    current += a
  }
  println(sumTime)
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 64508
def makeBlackets(strings):
    blackets=[]
    for i in range(len(strings)):
        char=strings[i]
        if char=='[' or char=='(' or char==']' or char==')':
            blackets.append(char)
    return blackets
def isBalancedNum(blackets):
    lB=0
    rB=0
    for i in range(len(blackets)):
        if blackets[i]==')' or blackets[i]==']':
            lB+=1
        else:
            rB+=1
    
    return lB==rB
def isBalanced(blackets):
    while len(blackets)!=0:
        if "()" in blackets:
            blackets=blackets.replace("()","")
        elif "[]" in blackets:    
            blackets=blackets.replace("[]","")
        else:
            break
    return len(blackets)==0
while True:
    strings=input()
    if strings==".":
        break
    blacket=makeBlackets(strings)
    blackets=''.join(blacket)
    if isBalancedNum(blackets):
        if isBalanced(blackets):
            print("yes")
        else:
            print("no")
    else:
        print("no")


Measured memory_bytes: 5588
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for {
		a, op, b := nextInt(), nextString(), nextInt()
		if op == "?" {
			break
		} else if op == "+" {
			fmt.Println(a + b)
		} else if op == "-" {
			fmt.Println(a - b)
		} else if op == "*" {
			fmt.Println(a * b)
		} else if op == "/" {
			fmt.Println(a / b)
		}
	}

}



Measured memory_bytes: 1120
NAB = input().split()

N = int(NAB[0])
A = int(NAB[1])
B = int(NAB[2])

kaisuu = N // (A+B)
amari = N % (A+B)

if kaisuu >= 10**100:
  solution = A ** (10**100)
else:
  if amari <= A:
  	solution = A * kaisuu + amari
  else:
    solution = A * kaisuu + A

print(solution)

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

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

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

	int N; cin >> N;
	int sum = 0;

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

	cout << sum << endl;

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,ab[1100000],c,d[10000000];
string s;
signed main()
{
	cin>>s;
	if(s=="Sunny"){
		cout<<"Cloudy";
	}elif(s=="Rainy"){
		cout<<"Sunny";
	}else{
		cout<<"Rainy";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N,K; cin >> N >> K;
    vecl A(N);
    REP(i,N) cin >> A[i];
    vecl cum(N+1,1);
    REP(i,N) {
        cum[i+1] = cum[i]+A[i];
        //cout << cum[i+1] << " " << A[i] << endl;
    }
    for(int i = K+1; i <= N; i++) {
        //cout << cum[i-1]-cum[i-1-K] << " " << cum[i]-cum[i-K] << endl;
        if(cum[i]-cum[i-K] > cum[i-1]-cum[i-1-K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 6384
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

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

	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());

	if (s.compare(t) < 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7

#n種類の花を使って、花束を作る組み合わせは2^n-1通り
#pow(x,y,mod) : (x**y) % mod
ans = pow(2, n, mod)-1

#nCa
nCa = 1
#分子:n*(n-1)*...*(n-a+1)
for i in range(n-a+1, n+1):
    nCa *= i
    nCa %= mod
#分母:1/a! = 1/(1*2*...*a) = 1^(p-2)*2^(p-2)*,,,*a^(p-2)
for i in range(1, a+1):
    nCa *= pow(i, mod-2, mod)
    nCa %= mod
    
#nCb
nCb = 1
for i in range(n-b+1, n+1):
    nCb *= i
    nCb %= mod
for i in range(1, b+1):
    nCb *= pow(i, mod-2, mod)
    nCb %= mod

#2^n-1通りからnCaとnCbを引く
ans -= (nCa + nCb)
ans %= mod
print(ans)


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

int main() {
    int a, b;
    cin >> a >> b;
    int arr[a][b];
    for(int i=0; i<a; i++) {
        for (int j=0; j<b; j++) {
            int num;
            cin >> num;
            arr[i][j] = num;
        }
    }

    int barr[b];
    for (int i=0; i<b; i++) {
            int num;
            cin >> num;
            barr[i] = num;
    }
    for(int i=0; i<a; i++) {
        int sum = 0;
        for (int j=0; j<b; j++) {
            sum += arr[i][j]*barr[j];
        }
        cout << sum << endl;
        sum = 0;
    }
    return 0;
}



Measured memory_bytes: 3132
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N+1);
    vector<ll> B(N);

    rep(i,N+1){
        cin >> A[i];
    }

    rep(i,N){
        cin >> B[i];
    }

    ll ans=0;

    rep(i,N){
        if(A[i] - B[i] >= 0){
            ans += B[i];
        }else if(A[i+1] - (B[i]-A[i]) >= 0){
            ans += B[i];
            A[i+1] -= B[i]-A[i];
        }else{
            ans += A[i]+A[i+1];
            A[i+1] = 0;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 4812
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
const int N=100005;
int f[N],a[N];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	memset(f,0x3f,sizeof(f));
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	f[1]=0;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=k;j++){
			if(i-j>=1) f[i]=min(f[i],f[i-j]+abs(a[i]-a[i-j]));
		}
	}
	printf("%d\n",f[n]);
}

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

const int MAX_VAL = 1e6+1;
int main() {
  int N;
  cin >> N;

  map<int, int> nums;
  bool isAns[MAX_VAL+1];
  for (int i = 0; i <= MAX_VAL; i++) {
    isAns[i]=false;
  }
  int maxN = 0;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    nums[A]++;
    isAns[A]=true;
    maxN = max(maxN,A);
  }
  
  vector<int> ans;
  for (auto num: nums) {
    int n = num.first;
    if(isAns[n]) {
      ans.push_back(n);
      for (int i = 2*n; i <= maxN; i += n) {
        isAns[i] = false;
      }
    }
  }

  int count = 0;
  for (auto as: ans) {
    if (nums[as]==1) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 14472
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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 main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  ll arr[n];
  fi(0, n){
    cin >> arr[i];
  }
  sort(arr, arr + n);
  int ng;
  fi(0, n - 1)
    fj(i + 1, n) {
      ng = upper_bound(arr, arr + n, arr[i] + arr[j] - 1) - arr;
      ans += ng - j - 1;
    }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
// Problem : B. Yet Another Meme Problem
// Contest : Educational Codeforces Round 80 (Rated for Div. 2)
// URL : https://codeforces.com/contest/1288/problem/B
// Memory Limit : 256.000000 MB 
// Time Limit : 1000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define ll                    long long int
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define MOD                   1000000007
#define vi                    vector<int>
#define vll                   vector<ll>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define eb                    emplace_back
#define ull                   unsigned long long
#define KAMEHAMEHA            ios_base::sync_with_stdio(0);
#define RASENGAN              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    KAMEHAMEHA
	char c;
  	cin>>c;
  	c++;
  	cout<<c<<endl;
    return 0;
}



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

int main(void){
   int N;
   cin>>N;
   vector<char> S(N);
   for(int i=0;i<N;i++){
      cin>>S[i];
   }
   long long cnt_R=0,cnt_G=0,cnt_B=0;
   for(int i=0;i<N;i++){
      if(S[i]=='R') cnt_R++;
      if(S[i]=='G') cnt_G++;
      if(S[i]=='B') cnt_B++;
   }
   long long ans=cnt_R*cnt_G*cnt_B;
   for(int i=0;i<N;i++){
      for(int j=i+1;j<N;j++){
         int k=2*j-i;
         if(k<N){
            if(S[i]!=S[j]&&S[j]!=S[k]&&S[k]!=S[i]){
               ans=ans-1;
            }
         }
      }
   }
   cout<<ans<<endl;
   return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b;
  cin >> a >> b;
  int cnt = 0;
  for (int i = 1; i <= a; ++i) {
    if (i < a) {
      cnt++;
      continue;
    }

    if (i <= b) {
      cnt++;
      continue;
    }
  }

  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,K;
  cin >> N >> K;
  int i;
  int sum =0;
 for ( i=0 ; i<N ; i++ ){
   int x;
   cin >> x;
   if ( x>K/2 && x<K ) sum+=(K-x);
   if ( x>K/2 && x>K ) sum+=(x-K);
   if ( x<=K/2 && x>0 ) sum+=x;
   if ( x<=K/2 && x<0 ) sum+=(-x);
      }
  cout << sum*2 << endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n;
	long long int power = 1;
	
	cin >> n;
	
	for (int i = 1; i <= n; i++) {
		power *= i;
                power %= (1000000000 + 7);
	}
	
	cout << power << endl;
	
	return (0);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        while (a % 2 == 0) {
            a = a / 2;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 888
import sys
input = sys.stdin.readline
ma = lambda : map(int,input().split())
ni = lambda : int(input())

n = 10**5+1
primes = [1]*n
primes[0] =0
primes[1] =0
for i in range(2,int(n**0.5)+1):
    if primes[i] ==1:
        for j in range(2*i,n,i):
            primes[j] = 0
p2017 = [0]*n
for i in range(1,n):
    p2017[i] = p2017[i-1]
    if primes[i] and primes[(i+1)//2]:
        p2017[i]+=1
q = ni()
for i in range(q):
    l,r = ma()
    print(p2017[r]-p2017[l-1])


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

int main() {
    int n, m;
    cin >> n >> m;
    int all_path[2];
    all_path[0] = 1;
    all_path[1] = n;
    rep(i, m){
        int l, r;
        cin >> l >> r;
        if(all_path[0] < l) all_path[0] = l;
        if(r < all_path[1]) all_path[1] = r;
    }
    if (all_path[1] < all_path[0])cout << 0 << endl;
    else cout << all_path[1] - all_path[0] + 1 << endl;
}

Measured memory_bytes: 3604
#include<cstdio>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>


using namespace std;

const int N = 1000 + 5;

int main(){
    string str;
    cin >> str;
    int ans = 0;
    for(int i = str.length() - 1; i >= 0; i--){
        if(str[i] == '+')
            ans++;
        else
            ans--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def e_virus_tree_2(N, K, Edges, MOD=10**9 + 7):
    import sys
    sys.setrecursionlimit(10**6)
    
    graph = [[] for _ in range(N)]
    for a, b in Edges:
        graph[b - 1].append(a - 1)
        graph[a - 1].append(b - 1)

    def dfs(color, graph, current, parent):
        can_use_color_num = K - 1 if parent == -1 else K - 2

        if color < len(graph[current]):
            return 0  # 塗らねばならない子の数に対して色が足りない

        # コンビネーションの計算はここで行っている
        case_num = 1
        for child in graph[current]:
            if child == parent:
                continue
            case_num *= can_use_color_num
            case_num %= MOD
            can_use_color_num -= 1
        for child in graph[current]:
            if child == parent:
                continue
            case_num *= dfs(color, graph, child, current)
            case_num %= MOD
        return case_num

    ans = K * dfs(K, graph, 0, -1)
    return ans % MOD

N, K = [int(i) for i in input().split()]
Edges = [[int(i) for i in input().split()] for j in range(N - 1)]
print(e_virus_tree_2(N, K, Edges))

Measured memory_bytes: 123080
N = int(input())

# S = []

TC = ['AC','WA','TLE','RE']
C = [0,0,0,0]

for i in range(N):
    # S.append(input())
    result = input()
    if result==TC[0]:
        C[0]+=1
    elif result==TC[1]:
        C[1]+=1
    elif result==TC[2]:
        C[2]+=1
    else:
        C[3]+=1

print("AC x "+str(C[0]))
print("WA x "+str(C[1]))
print("TLE x "+str(C[2]))
print("RE x "+str(C[3]))



Measured memory_bytes: 69940
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

ll gcd(ll x, ll y) {
  if(x > y)
    return gcd(y, x);
  else if(x == 0)
    return y;
  else
    return gcd(y % x, x);
}

int main(){
  int N;  ll X;
  cin >> N >> X;
  vector<ll> x(N+1);
  x[0] = X;
  for(int i=0; i<N; i++)
    cin >> x[i+1];
  sort(x.begin(), x.end());
  vector<ll> y(N);
  ll ans;
  for(int i=0; i<N; i++) {
    y[i] = x[i+1] - x[i];
    if(i == 0)
      ans = y[i];
    else
      ans = gcd(ans, y[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
function Main(i: string) {
  const ii = i.split("\n");
  const cnt500 = +ii[0];
  const cnt100 = +ii[1];
  const cnt050 = +ii[2];
  let total = +ii[3];
  let remainder = total;

  let v = 0;

  const max500 = Math.floor(total / 500);
  const c500 = Math.min(cnt500, max500);
  for (let i500 = c500; i500 >= 0; --i500) {
    if (i500 !== 0) {
      if (total - 500 * i500 === 0) {
        v += 1;
        // console.log("i500:" + i500);
        continue;
      }
    }
    remainder = total - 500 * i500;

    const before100 = remainder;
    const max100 = Math.floor(total / 100);
    const c100 = Math.min(cnt100, max100);
    for (let i100 = c100; i100 >= 0; --i100) {
      if (i100 !== 0) {
        if (before100 - 100 * i100 === 0) {
          v += 1;
          // console.log("i500:" + i500 + " i100:" + i100);
          remainder = before100;
          continue;
        } else {
          remainder = before100 - 100 * i100;
        }
      }

      if (remainder > 0 && 50 * cnt050 >= remainder) {
        v += 1;
        // console.log(
        //   "i500:" + i500 + " i100:" + i100 + " remainder:" + remainder
        // );
      }
    }
  }

  console.log(v);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;


int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	ll n,x=0,y=0,a,b,tmp;
	cin>>n;
	while(n--){
		cin>>a>>b;
		if(x<=a&&y<=b)
			x=a,y=b;
		else{
			tmp=0;
			if(x>a){
				if(x%a==0)
					tmp=x/a;
				else
					tmp=x/a+1;
			}
			if(y>b){
				if(y%b==0)
					tmp=max(tmp,y/b);
				else
					tmp=max(tmp,y/b+1);
			}
			x=a*tmp,y=b*tmp;
		}
	}
	cout<<x+y<<endl;
	return 0;
}

Measured memory_bytes: 256