akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int MOD = 1000000007;
const int MAX = 510000;
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;
}

int main() {
    int N; cin >> N;
    N++;
    vector<int> A(N);
    int l = 0;
    map<int, int> ma;
    rep(i, 0, N) {
        cin >> A[i];
        if(ma[A[i]]) l = i + 2 - ma[A[i]];
        ma[A[i]] = i + 1;
    }
    COMinit();
    rep(i, 1, N+1) {
        ll n = COM(N, i);
        ll m = COM(N - l, i - 1);
        ll ans = (n - m + MOD) % MOD;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 18304
import Data.IntMap.Strict ((!))
import qualified Data.IntMap.Strict as M
import Control.Monad

apply n f x = foldr ($) x (replicate n f)

main = do
 [n,_] <- map read . words <$> getLine
 abcs <- map (map read . words) . lines <$> getContents
 putStrLn $ maybe "inf" show (scoreAttack n abcs)
 
scoreAttack n abcs = do 
 let gf = apply n (move abcs) (M.singleton 1 0)
 let gs = apply n (move abcs) gf
 guard (gf!n == gs!n)
 return (gf!n)
 
move abcs g = foldr (\[a,b,c] acc -> if M.member a g then M.insertWith max b ((g!a) + c) acc else acc) g abcs


Measured memory_bytes: 4476
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
int lcm(int a, int b){
  return a / gcd(a,b) * b;
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int h,w;
vector<vector<int>> d;
vector<string> s;
void warshall_floyd(int n){ //nはノード数
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      for(int k = 0; k < n; k++){
        if(d[j][i] == INF || d[i][k] == INF) continue;
        d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
      }
    }
  }
}
int main(){
  cin >> h >> w;
  d.resize(h*w,vector<int>(h*w,INF));
  s.resize(h);
  rep(i,h*w) d[i][i] = 0;
  rep(i,h){
    cin >> s[i];
  }
  rep(i,h)rep(j,w){
    if(s[i][j] == '#') continue;
    rep(k,4){
      int nx = j + dx[k]; int ny = i + dy[k];
      if(nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
      if(s[ny][nx] == '#') continue;
      int from = i*w+j; int to = ny*w+nx;
      d[from][to] = 1;
      d[to][from] = 1;
    }
  }
  
  warshall_floyd(h*w);
  
  int ans = 0;
  rep(i,h*w){
    //cout << endl;
    rep(j,h*w){
      //cout << d[i][j] << " ";
      if(d[i][j] != INF) chmax(ans, d[i][j]);
    }
  }
  //cout << endl;  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;

namespace _516_MaximumSum
{
	class Program
	{
		static void Main ( string[] args )
		{
			while (true)
			{
				//input
				int[] orderNumber = Console.ReadLine ().Split (' ').Select (str => int.Parse (str)).ToArray ();
				int dataCount = orderNumber[0];
				int addCount = orderNumber[1];

				bool isEnd = orderNumber.All (item => item == 0);
				if (isEnd)
				{
					break;
				}

				int[] numArray = new int[dataCount];
				for (int lp = 0; lp < numArray.Length; lp++)
				{
					numArray[lp] = int.Parse (Console.ReadLine ());
				}

				//process
				int max;
				int tmp = 0;

				//0??????k?????§???????¨?????±????????????????????????§???????±???????
				for (int lp = 0; lp < addCount; lp++)
				{
					tmp += numArray[lp];
				}
				max = tmp;

				//?????????????´?????????????????¬????????´?????¶????
				for (int lp = addCount, lp2 = 0; lp < numArray.Length; lp++, lp2++)
				{
					tmp -= numArray[lp2];
					tmp += numArray[lp];

					if (max < tmp)
					{
						max = tmp;
					}
				}

				//output
				Console.WriteLine (max);
			}
		}
	}
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<string,int,int>;

int main(){
  int n,m; cin >> n >> m;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h[i];
  vector<vector<int>> 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);
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    int now = h[i];
    bool flg = true;
    for(int v: g[i]){
      if(now <= h[v]){
        flg = false;
        break;
      }
    }
    if(flg) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8804
#include <stdio.h>

int main(void) {
    int a, b, i, sum=0;
    float t;

    scanf("%d %d %f", &a, &b, &t);
    for (i=a; i<t+0.5; i+=a) {
        sum += b;
    }

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

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

static class CodeJam
{
    class Edge
    {
        public readonly int A;
        public readonly int B;
        public readonly int C;
        public Edge(int[] args)
        {
            A = args[0] - 1;
            B = args[1] - 1;
            C = args[2];
        }
    }

    static bool[] Research(Edge[] edges, int N)
    {
        var nexts = new List<int>[N];
        for (int i = 0; i < N; ++i) { nexts[i] = new List<int>(); }
        foreach (var e in edges) { nexts[e.B].Add(e.A); }

        var connected = new bool[N];
        connected[N - 1] = true;

        var q = new Queue<int>();
        q.Enqueue(N - 1);
        while (q.Count > 0)
        {
            int a = q.Dequeue();
            foreach (int b in nexts[a])
            {
                if (!connected[b])
                {
                    connected[b] = true;
                    q.Enqueue(b);
                }
            }
        }
        return connected;
    }

    static int Solve(int N, int M, int P, Edge[] edges)
    {
        const int INF = int.MaxValue / 2;
        var D = Enumerable.Repeat(INF, N).ToArray();
        D[0] = 0;

        var connected = Research(edges, N);

        for (int i = 0; i < N; ++i)
        {
            foreach (var e in edges)
            {
                if (D[e.A] < INF && connected[e.A] && connected[e.B] && D[e.A] + P - e.C < D[e.B])
                {
                    if (i == N - 1) { return -1; }
                    D[e.B] = D[e.A] + P - e.C;
                }
            }
        }

        return (D[N - 1] < INF) ? Math.Max(-D[N - 1], 0) : -1;
    }

    static void Main(string[] args)
    {
        var V1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int N = V1[0], M = V1[1], P = V1[2];
        var edges = new Edge[M];
        for (int i = 0; i < M; ++i)
        {
            var V2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            edges[i] = new Edge(V2);
        }
        Console.WriteLine(Solve(N, M, P, edges));
    }
}


Measured memory_bytes: 13540
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ld PI=abs(acos(-1));
int n,m;

int main(){
	cin >> n >> m;
	
	ll s=0;
	REP(i,0,n+1){
		REP(j,0,n+1){
			if(0<=m-i-j and m-i-j<=n) s++;
		}
	}
	
	cout << s << endl;
	return 0;
}
 


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define next(a) ( ((a)+1)%SIZE )
#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define INF 1000000000
#define SIZE 100000

typedef struct queue
{
	int front;
	int rear;
	int data[200];
}queue;

void init(queue* p)
{
	p->front = 0;
	p->rear = 0;
}

void enqueue(queue *p,int x)
{
	if (next(p->rear) == p->front)
		printf("OVERFLOW!\n");
	p->data[p->rear] = x;
	p->rear = next(p->rear);
}

int dequeue(queue *p)
{
	int x;

	if (p->front == p->rear)
		printf("NO DADA\n");

	x = p->data[p->front];
	p->front = next(p->front);

	return x;
}

int empty(queue *p)
{
	return p->front == p->rear;
}

void print(char* str, int a, int b)
{
	int i;

	for (i = a; i <= b; i++)
		printf("%c", str[i]);
	printf("\n");
}

void reverse(char* str, int a, int b)
{
	int i,j=0;
	char t;

	for (i = a; i <= (a + b) / 2; i++)
	{
		t = str[i];
		str[i] = str[b - j];
		str[b - j] = t;
		j++;
	}
}

void replace(char* str, int a, int b, char* temp)
{
	int i, j=0;

	for (i = a; i <= b; i++)
	{
		str[i] = temp[j];
		j++;
	}
}

double rad(int C)
{
	return M_PI * C / 180;
}

double distance(int* a, int* b, int n, int p)
{
	double sum = 0.0;

	int i, j;

	int max = 0;

	for (i = 0; i < n; i++)
	{
		sum += pow(ABS(a[i] - b[i]), p);

		if (ABS(a[i] - b[i]) > max)
			max = ABS(a[i] - b[i]);
	}

	if (p == INF)
		return max;

	return pow(sum, (double)1 / p);
}

typedef struct Dice
{
	int num[6];
}Dice;

void ROT(Dice* p,char R)
{
	int num2[6];
	int i;

	for (i = 0; i < 6; i++)
		num2[i] = p->num[i];

	if (R == 'E')
	{
		p->num[0] = num2[3];
		p->num[1] = num2[1];
		p->num[2] = num2[0];
		p->num[3] = num2[5];
		p->num[4] = num2[4];
		p->num[5] = num2[2];
	}

	if (R == 'S')
	{
		p->num[0] = num2[4];
		p->num[1] = num2[0];
		p->num[2] = num2[2];
		p->num[3] = num2[3];
		p->num[4] = num2[5];
		p->num[5] = num2[1];
	}

	if (R == 'W')
	{
		p->num[0] = num2[2];
		p->num[1] = num2[1];
		p->num[2] = num2[5];
		p->num[3] = num2[0];
		p->num[4] = num2[4];
		p->num[5] = num2[3];
	}

	if (R == 'N')
	{
		p->num[0] = num2[1];
		p->num[1] = num2[5];
		p->num[2] = num2[2];
		p->num[3] = num2[3];
		p->num[4] = num2[0];
		p->num[5] = num2[4];
	}
}

int main()
{
	Dice dice;
	Dice dice2;
	int n;
	char str[150];
	int i, j;
	int u, d;
	int temp;

	for (i = 0; i < 6; i++)
		scanf("%d", &dice.num[i]);

	for (i = 0; i < 6; i++)
		scanf("%d", &dice2.num[i]);

	int cnt;
	int time = 3000;

	
	while (time >=0)
	{
		temp = rand() % 4;
		if (temp == 0)
			ROT(&dice, 'E');
		else if (temp == 1)
			ROT(&dice, 'S');
		else if (temp == 2)
			ROT(&dice, 'W');
		else if (temp == 3)
			ROT(&dice, 'N');

		cnt = 0;
		for (i= 0; i < 6; i++)
		{
			if (dice.num[i] == dice2.num[i])
				cnt++;
		}
		if (cnt == 6)
		{
			printf("Yes\n");
			return 0;
		}
		time--;
	}

	printf("No\n");

	return 0;
}



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

int main(){
  ll n,X,i,x,ans;
  cin >> n >> X;
  cin >> x;
  ans=abs(x-X);
  for(i=1;i<n;i++){
    cin >> x;
    ans=__gcd(ans,abs(x-X));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  ll ans = a - b;
  if (k % 2) {
    ans *= -1;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;

int main() {

  int N, K;
  cin >> N >> K;

  vector<int> h(N);
  rep(i, N) cin >> h[i];

  int cnt = 0;
  rep(i, N) if (h[i] >= K) cnt ++;

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>

#define REP(i, n) for (int i = 0; i < (n); i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9

using namespace std;
typedef long long ll;

string front = "", back = "";

void attach_char(int f, char c) {
  if (f == 1) {
    front += c;
  } else {
    back += c;
  }
  return;
}

int main() {
  string s;
  int q;

  cin >> s >> q;

  int flip_count = 0;

  int t, f;
  char c;
  for (int i = 0; i < q; i++) {
    cin >> t;

    if (t == 1) {
      flip_count++;
    } else {
      cin >> f >> c;
      if (flip_count % 2 == 0) {
        // そのまま
        attach_char(f, c);
      } else {
        // 反転
        attach_char(f == 1 ? 2 : 1, c);
      }
    }
  }

  reverse(front.begin(), front.end());
  s = front + s + back;

  if (flip_count % 2 == 1) {
    reverse(s.begin(), s.end());
  }

  cout << s << endl;

  return 0;
}

Measured memory_bytes: 1348
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define A first
#define B second
#define make_pair MP
#define MOD 1000000007
#define MAXM 100005
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }


int mulmd(ll a, ll b){
    ll ret = (a * b) % MOD;
    return (int)ret;

}

inline int power(ll x, ll y, int p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = mulmd(res,x);
        y = y>>1;
        x = mulmd(x,x);
    }
    return (int)res;
}

int submd(ll a, ll b){
    ll ret = a-b;
    if(ret<0){
        ret+=MOD;
    }
    return (int)ret;
}

int addmd(ll a, ll b){
    ll ret = (a + b) % MOD;
    return (int)ret;
}

int phi(int n){
    int result = n;
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            while(n%i==0){
                n=n/i;
            }
            result-=result/i;
        }
    }
    if(n>1) result-=result/n;
    return result;
}

int gcd(int a, int b, int& x, int& y){
    if(a==0){
        x=0;
        y=1;
        return b;
    }
    int x1,y1;
    int d = gcd(b%a, a, x1, y1);
    x = y1 - (b/a)*x1;
    y = x1;
    return d;
}

int arr[100005];

int dist(int x1,int y1,int x2,int y2)
{
    int dx=x2-x1;int dy=y2-y1;
    float ans=sqrt(dx*dx+dy*dy);
    return ceil(ans);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,k;
    cin>>h>>k;
    vector<int>vec(h);
    REP(i,h)
    {
        cin>>vec[i];
    }
    sort(vec.rbegin(),vec.rend());
    int co=1;ll ans=0;
    REP(i,h)
    {
        if(co>k)
            ans+=vec[i];
        co++;
    }
    cout<<ans;

}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

vector<int> dy = { 0,0,1,-1 };
vector<int> dx = { 1,-1,0,0 };

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}


int main() {
	ll N; cin >> N;
	string S; cin >> S;
	int Q; cin >> Q;
	V<ll> ans(Q);
	REP(n, Q) {
		int k; cin >> k; k--;
		ll D = 0, M = 0, DM = 0,cnt = 0;
		REP(i, N) {
			if (S[i] == 'D') D++;
			if (S[i] == 'M') M++;
			if (S[i] == 'M') DM += D;
			if (S[i] == 'C') cnt += DM;
			if (k > i) continue;
			if (S[i-k] == 'D') D--;
			if (S[i-k] == 'D') DM -= M;
			if (S[i-k] == 'M') M--;
		}
		ans[n] = cnt;
	}
	REP(i, Q) cout << ans[i] << endl;
	
	return 0;
}



Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main(){
  long long n,a;
  long long cnt=0,Mcnt=0;
  cin >> n;
  vector<int> h(n);
  
  for(int i=0;i<n;i++){
    cin >> a;
    h.at(i) = a;
  }
  
  for(int i=0;i<n-1;i++){
    int j = i+1;
    while(j < n){
      if(h.at(j) <= h.at(j-1)) cnt++;
      if(cnt > Mcnt) Mcnt = cnt;
      if(h.at(j) > h.at(j-1)) break;
      j++;
    }
    cnt = 0;
    i = j-1;
  }
  
  cout << Mcnt << endl;
  
}


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

int main() {
    int K;
    cin >> K;
    if (K % 2 == 0) {
        cout << (K / 2) * (K / 2) << endl;
    }
    else {
        cout << (K + 1) / 2 * ((K + 1) / 2 - 1) << endl;
    }
}

Measured memory_bytes: 256
MOD = 10**9 + 7
MAX_NUM = 10**3
is_prime = [True] * MAX_NUM
is_prime[0] = False
is_prime[1] = False
primes = []
for i in range(MAX_NUM):
    if is_prime[i]:
        primes.append(i)
        for j in range(2*i, MAX_NUM, i):
            is_prime[j] = False

def prime_factorization(x):
    res = {}
    for prime in primes:
        while x % prime == 0:
            if not prime in res:
                res[prime] = 0
            res[prime] += 1
            x //= prime
    if x > 1:
        res[x] = 1
    return res

def mod_pow(p, q):
    res = 1
    while q:
        if q & 1:
            res = (res * p) % MOD
        p = (p * p) % MOD
        q //= 2
    return res

def mod_inv(p):
    return mod_pow(p, MOD - 2)

def solve(n, a):
    D = {}
    for i in range(n):
        prime_num_mapping = prime_factorization(a[i])
        for prime, num in prime_num_mapping.items():
            if not prime in D:
                D[prime] = 0
            D[prime] = max(D[prime], num)
    L = 1
    for prime, num in D.items():
        L = (L * mod_pow(prime, num)) % MOD
    res = sum(L * mod_inv(x) for x in a)
    return res % MOD

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl
#define DOUBLE(d) cout << fixed << setprecision(15) << (d) << endl

int S, W;

int main() {
    cin >> S >> W;
    if (W >= S) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

Measured memory_bytes: 3636
N, Y = map(int,input().split())
import sys
for i in range(N+1):
  for j in range(N+1-i):
    if 10000*i + 5000*j + 1000*(N-i-j) == Y:
      print(i,j,N-i-j)
      sys.exit()
else: print(-1,-1,-1)

Measured memory_bytes: 2940
package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)

	e := []string{}
	if s.Scan() {
		e = strings.Split(s.Text(), " ")
	}

	fmt.Println(gcd(conv(e[0]), conv(e[1])))
}

func conv(e string) int {
	r, _ := strconv.Atoi(e)
	return r
}

func gcd(x, y int) int {
	if x < y {
		tmp := y
		y = x
		x = tmp
	}
	for y > 0 {
		r := x % y
		x = y
		y = r
	}
	return x
}



Measured memory_bytes: 1116
import random
from copy import deepcopy

d = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(d)]

def min_max(l):
    l_min = min(l)
    l_max = max(l)
    return [1+(i - l_min) / (l_max - l_min) for i in l]

dd = [max(s[i]) for i in range(d)]
qq = min_max(c)
dd = min_max(dd)

ddd = [i for i in range(d)]
qqq = [i for i in range(26)]

ans = []

for i in range(d):
    ans.append(s[i].index(max(s[i]))+1)

def score(l):
    lastd = [0]*26
    point = 0
    for j,k in enumerate(l):
        kk = k-1
        point += s[j][kk]
        lastd[kk] = j+1
        for l in range(26):
            point -= c[l]*(j+1-lastd[l])
    return point

ma = score(ans)

def random_search():
    global ans,ma
    li = deepcopy(ans)
    D = random.choices(ddd,k=1,weights=dd)[0]
    lin = [p+1 for p in range(26)]
    Q = random.choices(qqq,k=1,weights=qq)[0]
    li[D] = Q+1
    if score(li) > ma:
        ans = deepcopy(li)
        ma = score(li)

for i in range(20000):
    random_search()

for i in ans:
    print(i)

Measured memory_bytes: 86680
#include<iostream>
#include<cmath>
#include<algorithm>
typedef long long ll;
int inf = 1000000000;
using namespace std;
int main(void) {
	ll w, h, x, y;
	cin >> w >> h >> x >> y;
	double ans = (double)w * h * 0.5;
	printf("%.12f ", ans);
	if (w == x * 2 && h == y * 2) {
		cout << "1" << endl;
	}
	else {
		cout << "0" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
box = [1]*(N+1)
red = [False]*(N+1)
red[1] = True
for _ in range(M):
    x,y = [int(x) for x in stdin.readline().rstrip().split()]
    if red[x]:
        red[y] = True
    box[x] -= 1
    box[y] += 1
    if box[x] == 0:
        red[x] = False
ans = 0
for i in red:
    if i:
        ans += 1
print(ans)

Measured memory_bytes: 4596
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

const int mod = 1e9+7;

int main() {
    int n; cin >> n;

    ll sum = 1;    
    for(int i=1; i<=n; i++){
        sum *= i;
        sum %= mod;
    }


    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    double a, b;
    cin >> a >> b;
    string ans;
    if(a > b)
        ans = "GREATER";
    else if(a < b)
        ans = "LESS";
    else
        ans = "EQUAL";
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
/*
string S_str[H];
cins(S_str, S_str + H);
S_str[i][j];
*/
inline int at(ll x, int k){ return (x >> k) & 1; }
#define rep(i, n) for(int i = 0; i < n; i++)


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


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
const int N=1000+5;
string str;

int main()
{
    int sum=0;
    cin>>str;
    for(int i=0;i<3;i++)
        if(str[i]=='o') sum++;
    cout<<700+sum*100<<endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s) - 1
ans = 0

for i in range(2 ** n):
    l = s[0]
    for j in range(n):
        if (i >> j) & 1 == 1:
            l += '+'
        l += s[j + 1]
    ans += sum(map(int, l.split('+')))

print(ans)

Measured memory_bytes: 41452
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  V<pair<pair<string,int>,int>> s(n);
  vi p(n);
  REP(i,n){
    cin >> s[i].fi.fi;
    int tmp;
    cin >> tmp;
    s[i].fi.se = -tmp;
    s[i].se = i+1;
  }
  sort(ALL(s));
  REP(i,n) cout << s[i].se << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

int main() {
  std::string s;
  std::map<std::string, int> m;

  while (std::cin >> s) {
    decltype(m)::iterator it = m.find(s);

    if (it == m.end()) {
      m.insert(std::make_pair(s, 1));
    } else {
      it->second++;
    }
  }

  int mode = 0;
  decltype(m)::iterator modePair;
  int maxLen = 0;
  decltype(m)::iterator maxLenPair;

  for (decltype(m)::iterator i = m.begin(); i != m.end(); ++i) {
    if (mode < i->second) {
      mode = i->second;
      modePair = i;
    }

    if (maxLen < i->first.length()) {
      maxLen = i->first.length();
      maxLenPair = i;
    }
  }

  std::cout << modePair->first << " " << maxLenPair->first << std::endl;


  return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>

using namespace std;

int dfs(int a[], int b[], int c[], int d[], int n, int m, int q, int x[], int lst, int dep) {
    if (dep == n) {
        int cur = 0;
        for (int i = 0; i < q; i++) {
            if (x[b[i]] - x[a[i]] == c[i]) {
                cur += d[i];
            }
        }
        return cur;
    }

    int r = 0;
    for (int i = lst; i < m; i++) {
        x[dep] = i;
        r = max(r, dfs(a, b, c, d, n, m, q, x, i, dep + 1));
    }

    return r;
}

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

    int n, m, q;
    cin >> n >> m >> q;
    int a[q], b[q], c[q], d[q];
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }

    int x[n];
    cout << dfs(a, b, c, d, n, m, q, x, 0, 0) << endl;

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    ll A, B; cin >> A >> B;
    vll a(n); for(auto& e : a) cin >> e;

    ll res = abs(B - a.back());
    if(n >= 2){
        chmax(res, abs(a.back() - a[n - 2]));
    }

    cout << res << endl;

    return 0;
}


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

using namespace std;

#define cerr if(true)cerr
#define what(x) cerr<<#x<<" = "<<x<<endl
 
typedef long long ll;
typedef pair<ll, ll> ii;

const int maxN = 2e5 + 9, maxV = 1e6 + 9, MOD = 998244353, SQ = 322;

ll pow2(ll a, ll b){
	a %= MOD;
	ll ans = 1;
	while(b){
		if(b % 2 == 1){
			ans = ans * a % MOD;
		}
		a = a * a % MOD;
		b /= 2;
	}
	return ans;
}

ll inverse(ll a){
	return pow2(a, MOD - 2);
}

ll fact[maxN];
ll inv[maxN];
ll pot[maxN];

ll Comb(ll n, ll k){
	return fact[n] * inv[n-k] % MOD * inv[k] % MOD;
}

int main(){

	ios_base::sync_with_stdio(false); 
	cin.tie(0);
	cout.tie(0);

	fact[0] = 1;
	for(int i = 1; i < maxN; i++){
		fact[i] = (i * fact[i-1]) % MOD;
	}

	inv[maxN-1] = inverse(fact[maxN-1]);
	for(int i = maxN-2; i >= 0; i--){
		inv[i] = (inv[i+1] * (i+1)) % MOD;
	}

	ll ans = 0;
	int n, m, k;
	cin >> n >> m >> k;

	pot[0] = 1;
	for(int i = 1; i < maxN; i++){
		pot[i] = (m-1) * pot[i-1] % MOD;
	}

	for(int i = n - 1 - k; i < n; i++){
		ans = (ans + Comb(n-1, i) * m % MOD * pot[i]) % MOD;
	}

	cout << ans % MOD << endl;

	return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	cout<<max(0,a-2*b)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[105];
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i != j) {
				ans = max(ans, a[i] - a[j]);
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2**20)
n, m, k = map(int, input().split())
ab = []
for _ in range(m):
    ab.append([int(x)-1 for x in input().split()])
cd = []
for _ in range(k):
    cd.append([int(x)-1 for x in input().split()])
group = [-1 for _ in range(n)]
lis = [[] for _ in range(n)]
for x in ab:
    a = x[0]
    b = x[1]
    lis[a].append(b)
    lis[b].append(a)
g_n = 0
def dfs(now):
    global g_n
    group[now] = g_n
    global group_len_n
    group_len_n += 1
    for i in lis[now]:
        if group[i] == -1:
            dfs(i)
group_len = []
for i in range(n):
    if group[i] == -1:
        group_len_n = 0
        dfs(i)
        group_len.append(group_len_n)
        g_n += 1
friend = [0 for _ in range(n)]
block = [0 for _ in range(n)]
for x in ab:
    a = x[0]
    b = x[1]
    if group[a] == group[b]:
        friend[a] += 1
        friend[b] += 1
for x in cd:
    c = x[0]
    d = x[1]
    if group[c] == group[d]:
        block[c] += 1
        block[d] += 1
ans = []
for i in range(n):
    ans.append(str(group_len[group[i]] - friend[i] - block[i] -1))
print(" ".join(ans))

Measured memory_bytes: 379712
from operator import itemgetter
import sys
n = int(input())
data = []
s = input()
if n == 1:
    L = list(s)
    L.sort()
    print("".join(L))
    sys.exit()
data.append(s)
S = set(list(s))
for i in range(n-1):
    s = input()
    S = S & set(list(s))
    data.append(s)
A = []
for i in S:
    ans = float("inf")
    for j in range(n-1):
        ans = min(ans,data[j].count(i))
    A.append([i,ans])
A.sort(key=itemgetter(0))
s = ""
for i in A:
    s += i[0]*i[1]
print(s)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
      	
		Scanner sc = new Scanner(System.in);
		//String word_before = sc.next();
		//int K = sc.nextInt();
		
		double A = sc.nextDouble();
		double B = sc.nextDouble();
		
		for (int i = 1; i < 10000; i++) {
			boolean Aj = A <= (double)i*0.08 && (double)i*0.08 < A+1;
			boolean Bj = B <= (double)i*0.10 && (double)i*0.10 < B+1;
			if (Aj && Bj) {
				System.out.println(i);
				sc.close();
				return;
			}
		}



		System.out.println(-1);
		


      	sc.close();
    }
		
		
}

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

int main(){
  ll x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  priority_queue<ll> ra,ga,ma;
  for(int i=0;i<a;++i){
    ll p;
    cin >> p;
    ra.push(p);
  }
  for(int i=0;i<b;++i){
    ll q;
    cin >> q;
    ga.push(q);
  }
  for(int i=0;i<c;++i){
    ll p;
    cin >> p;
    ma.push(p);
  }

  priority_queue<ll,vector<ll>,greater<ll>> ans;
  while(x!=0 || y!=0){
    if(x>0){
      ans.push(ra.top());
      ra.pop();
      x--;
    }
    if(y>0){
      ans.push(ga.top());
      ga.pop();
      y--;
    }
  }
  while(!ma.empty() && ans.top()<ma.top()){
    ans.pop();
    ans.push(ma.top());
    ma.pop();
  }
  ll cal=0;
  while(!ans.empty()){
    cal+=ans.top();
    ans.pop();
  }

  cout << cal << endl;
  return 0;
}


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

int main(){
	int A[5][4][11] = {0};
	int n, b,f,r,v;
	cin >> n; 

	for(int i=0; i<n; i++){
		cin >> b >> f >> r >> v;
		A[b][f][r] += v;
	}

	for(int b=1; b<=4; b++){
		for(int f=1; f<=3; f++){
			for(int r=1; r<=10; r++){
				cout <<  " " << A[b][f][r] ;
			}
			cout << endl;
		}
		if(b!=4)
			cout << "####################" << endl;
	}

	return 0;
}

Measured memory_bytes: 3024
import java.util.*;

class Main {
    long k;
    int count = 0;
    Queue<Long> q = new LinkedList<>();

    public static void main(String[] args) {
        Main m = new Main();
        m.run();
    }

    private void run() {
        Scanner sc = new Scanner(System.in);
        k = sc.nextInt();

        for (long i = 1; i <= 9; i++) {
            q.add(i);
            count++;
            if (count == k) {
                System.out.println(i);
                System.exit(0);
            }
        }

        while(true) {
            long num = q.poll();
            long lastNum = num % 10;
            if (lastNum != 0) bfs(10 * num + lastNum - 1);
            bfs(10 * num + lastNum);
            if (lastNum != 9) bfs(10 * num + lastNum + 1);
        }
    }

    private void bfs(long i) {
        q.add(i);
        count++;
        if (count==k) {
            System.out.println(i);
            System.exit(0);
        }
    }
}


Measured memory_bytes: 27092
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,a,b;
    int flag=0;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
    {
        cout<<"OK"<<endl;
    }
    else if(flag==0)
    {
        cout<<"NG"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define ll long long
#define sz(a) (int)(a.size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(it,c) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n)	for(int i=0;i<n;i++)
#define present(c,x) (c.find(x)!=c.end()) //for set/map etc.
#define cpresent(c,x) (find(all(c),x)!=c.end())
typedef pair<int,int> pi;
	typedef vector<int> vi;
	typedef vector<vector<int>> vvi;
	typedef vector<long long> vll;
	typedef vector<pair<int,int>> vp;
int N=100001;
int mod=1e9+7;
int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}} 
bool comp(int a, int b) 
{ 
    return (a > b); 
} 

// string s,t,s1,t1;
// int ans()
// {
// 	// string s1,t1;
// 	s1.erase(all(s1));
// 	t1.erase(all(t1));
// 	int n= s.size();
// 	char c = s[0];
// 	if(n==1)return 0;
// 	// int n_s= s.size(),n_t = t.size();
// 	fr(i,n-1)
// 	s[i]=s[i+1];
// 	s[n-1]=c;
// 	fr(i,n)
// 	{
// 		if(t[i]!=s[i])
// 		{
// 			s1.pb(s[i]);
// 			t1.pb(t[i]);
// 		}
// 	}
// // 	s.clear();
// // 	t.clear();
// 	s=s1;
// 	t=t1;
// 	if(s1.size()==0)return 0;
// 	else
// 	{
// 		return ans()+1;
// 	}
// }

void solve()
{
	int l,r,d;
	cin>>l>>r>>d;
	int a= (r-l)/d;
	if(l%d==0||r%d==0)a+=1;
	cout<<a;
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	// int t;
	// cin>>t;
	// while(t--)
	// {
	// 	solve();
	// 	cout<<endl;
	// }
	solve();
	return 0;
	
}



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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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;
}

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    string s, t;
    cin >> s >> t;
    ll n = s.size(), m = t.size();
    vec<P> sums(n + 1, make_pair(0, 0)), sumt(m + 1, make_pair(0, 0));
    REP(i, n) {
        sums[i + 1] = sums[i];
        if(s[i] == 'A') {
            sums[i + 1].first++;
        } else {
            sums[i + 1].second++;
        }
    }
    REP(i, m) {
        sumt[i + 1] = sumt[i];
        if(t[i] == 'A') {
            sumt[i + 1].first++;
        } else {
            sumt[i + 1].second++;
        }
    }

    ll q;
    cin >> q;
    REP(i, q) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--;
        c--;
        ll da = (sums[b].first - sums[a].first) % 3 + 3 - (sumt[d].first - sumt[c].first) % 3;
        da %= 3;
        ll db = (sums[b].second - sums[a].second) % 3 + 3 - (sumt[d].second - sumt[c].second) % 3;
        db %= 3;
        if(da == db) {
            cout << "YES" << en;
        } else {
            cout << "NO" << en;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 6540
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn min (a: &i64, b: &i64)-> i64{
    if *a <= 0i64 {*b}
    else if *b <= 0i64  {*a}
    else if *a < *b {*a}
    else {*b}
}

fn abs (a: &i64, b: &i64) -> i64{
    if *a - *b <= 0 {*b - *a} else {*a - *b}
}

fn main(){
    input!{
        n: u64,
        s: chars
    }
    let mut ss = s.clone();
    ss.sort();
    let mut ch = ss[0];
    let mut res = 1u64;
    let mut chs = 1u64;
    for i in 1..n as usize{
        if ch != ss[i] {
            res = (res * (chs + 1)) % 1000000007;
            ch = ss[i];
            chs = 1u64;
        }
        else {
            chs += 1;
        }
    }
    print!("{}", (res*(chs + 1) - 1) % 1000000007);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std; 
#define int int64_t
#define itn int
#define fi first
#define se second
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,ans=0,w=0;
  string c;
  cin>>n>>c;
  for(int i=0;i<n;i++){
    if(c[i]=='W') w++;
  }
  for(int i=n-w;i<n;i++){
    if(c[i]=='R') ans++;
  }
  cout<<ans<<"\n";
}


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

int main() {
  int n,k,ans=0;
  cin>>n>>k;
  rep(i,n){
    int h;
    cin>>h;
    if(h>=k) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = [0]*(N+1)
for i in range(N+1):
  ans[i] = A[i]
for i in range(N):
  rem = ans[i]-B[i]
  ans[i] = max(rem,0)
  if (rem<0):
    ans[i+1] = max(ans[i+1]+rem,0)
print(sum(A)-sum(ans))

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int ans = 0;

    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            int y = x-500*i-100*j;
            if(y>=0&&y<=50*c){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    s_list = [None for _ in range(n)]
    t_list = [None for _ in range(n)]
    for i in range(n):
        s, t = input().split()
        s_list[i] = s
        t_list[i] = int(t)
    x = input()

    x_index = s_list.index(x)
    ans = sum(t_list[x_index + 1:])

    print(ans)


if __name__ == "__main__":
    main()


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

typedef long long ll;
typedef long long ld;
typedef vector<int> vi;
typedef pair<ll, ll> pii;

struct Node
{
    int node, len;
    Node() {node = len = 0;}
    Node(int node, int len) {this -> node = node, this -> len = len;}
};
typedef vector<Node> vg;

#define MAX 1
#define NON 0
#define MOD 1000000007

#define FOR(type, i, a, b) for(type i = a; i < b; i++)
#define FORR(type, i, b, a) for(type i = b; i > a; i--)
#define FORE(type, i, a, b) for(type i = a; i <= b; i++)
#define FORRE(type, i, b, a) for(type i = b; i >= a; i--)

#define testBit(n, bit) ((n >> bit) & 1)
#define flipBit(n, bit) (n ^ (1ll << bit))
#define randomize mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s; cin >> s;
    if(s == "ABC") cout << "ARC";
    else cout << "ABC";
}

Measured memory_bytes: 3640