akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.conv, std.string, std.algorithm;
import std.array, std.conv, std.c.string;
 
long[102][1001][10] table;

long solve_dp(int comb, int limit) {
  long  dp[10][1000];
  dp[0][0] = 1;
  
  for(long i = 0; i <= 100; i++)
    for(long j = limit; j >= 0; j--)
      for(long k = comb; k >= 1; k--)
        if (j - i >= 0) {
          dp[k][j] += dp[k - 1][j - i];
        }
  
  return dp[comb][limit];
}
 
void main() {
  memset(cast(void *)table, -1, table.sizeof);
  while(true) {
    int[] line = readln.chomp.split(" ").map!(to!(int)).array;
    if (line[0] == 0 && line[1] == 0) break;
    solve_dp(line[0], line[1]).writeln;
  }
}

Measured memory_bytes: 9124
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def fillzerostr(n):
    s = str(n)
    while len(s) < 6:
        s = '0' + s
    return s

def main():
    N, M = LI()
    py = []
    py_original = []
    memo = {}
    for _ in range(M):
        P, Y = LI()
        py.append((P, Y))
        py_original.append((P, Y))

    py = sorted(py, key=lambda x: (x[0], x[1]))
    prev_ken = 0
    order = 1
    for i in range(M):
        ken = py[i][0]
        year = py[i][1]
        if prev_ken == ken:
            order += 1
        else:
            order = 1
        memo[py[i]] = fillzerostr(ken) + fillzerostr(order)
        prev_ken = ken

    for i in range(M):
        print(memo[py_original[i]])

main()



Measured memory_bytes: 42340
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const double pi = 3.14159265;
const ll LLINF = 1LL << 50;
using namespace std;



int main() {
    int k;
    string s;
    vector<string> sub;
    cin >> s >> k;
    for (int i = 1; i <= min(int(s.length()), k); i++) {
        for (int j = 0; j <= s.length() - i; j++) {
            sub.pb(s.substr(j, i));
        }
    }
    sort(sub.begin(), sub.end());
    unique(sub.begin(), sub.end());
    cout << sub[k-1] << endl;
    return 0;
}


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

int main () {
  string S;
  cin >> S;
  bool flag = false;
  
  if (S.at(2) == S.at(3)) {
    if (S.at(4) == S.at(5)) {
      flag = true;
    }
  }
  
  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
from math import sqrt
lst=[]
def prime(x,lst):
    n=int(sqrt(x))
    for i in range(2,n+1):
        if x%i==0:
            return lst
    if x%5==1:
        lst.append(x)

for i in range(2,55555):
    prime(i,lst)
m=int(input())
y=''
for i in range(m):
    y+=str(lst[i])+' '
print(y)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  vector<string> p(n);
  int ans=0;
  int a=0;
  int b=0;
  int ab=0;
  rep(i,n){
    cin>>p[i];
    int m=p[i].size();
    rep(j,m-1){
      if(p[i][j]=='A'&&p[i][j+1]=='B') ans++;
    }
    if(p[i][0]!='B'&&p[i][m-1]=='A') a++;
    if(p[i][0]=='B'&&p[i][m-1]!='A') b++;
    if(p[i][0]=='B'&&p[i][m-1]=='A') ab++;
  }

  if(ab==0) ans+=min(a,b);
  if(ab>=1) {
    if(a>0 && b>0) ans+=ab+1+min(a-1,b-1);
    if(a==0 && b>0) ans+=ab;
    if(a>0 && b==0) ans+=ab;
    if(a==0 && b==0) ans+=ab-1;
  }


  cout << ans << endl;
}

Measured memory_bytes: 768
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <cctype>

using ll = long long;
using ull = unsigned long long;

template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    int n;
    cin >> n;
    vec<int> L(n);

    for (auto& e : L)
        cin >> e;

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

    if (accumulate(L.begin(), L.end() - 1, 0) > L.back())
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
a,op,b=map(str,input().split())
while op!="?":
    a=int(a)
    b=int(b)
    if op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    else:
        print(a//b)
    a,op,b=map(str,input().split())    
else:
    pass


Measured memory_bytes: 5596
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	string a = "keyence";
	string s;
	while(cin >> s) {
		string ans = "NO";
		REP(i, SZ(s)) {
			FOR(j, i+1, SZ(s) + 1) {
				// int len = i - j;
				if(s.substr(0, i+1) + s.substr(j, SZ(s)-j) == a) {
					ans = "YES";
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
x,y = list(map(lambda x: int(x), input().split(" ")))

a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
  print("Yes")
else:
  print("No")
                                              

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstring>
#include <map>
#include<cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m;
vector<pair<int, int> > graph[201];
int r[101];
const int INF = (1 << 30 );
int R;
int dist[201];
bool visited[201];
struct node{
    int idx, cost;
    node (){}
    node(int _i, int _c){
        idx = _i;
        cost = _c;
    }

    bool operator < (const node &a)const{
        return cost > a.cost;
    }
};
int mat[201][201];
void dijkstra(int S){
    for(int i = 0; i < n; i ++){
        dist[i] = INF;
        visited[i] = false;
    }
    priority_queue<node> q;
    q.push(node(S, 0));
    dist[S] = 0;
    node tmp;
    int nxtNode, weight;
    while(!q.empty()){
        tmp = q.top();
        q.pop();
        if(visited[tmp.idx])continue;
        visited[tmp.idx] = true;
        for(int i = 0; i < (int)graph[tmp.idx].size();i ++){
            nxtNode = graph[tmp.idx][i].first;
            weight = graph[tmp.idx][i].second;
            if(!visited[nxtNode] && tmp.cost + weight < dist[nxtNode]){
                dist[nxtNode] = tmp.cost + weight;
                q.push(node(nxtNode, tmp.cost + weight));
            }
        }

    }

    for(int i = 0; i < n; i ++){
        mat[S][i] =dist[i];
    }

}

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    cin >> R;
    for (int i = 0; i < R; i ++) {
        cin >> r[i];
    }
    for(int i = 0; i < n;  i ++){
        for(int j = 0; j < n; j ++){
            mat[i][i] = INF;
        }
    }
    int a, b, c;
    for(int i = 0; i < m; i ++){
        cin >> a >> b >> c;
        a --;
        b --;
        graph[a].push_back(make_pair(b, c));
        graph[b].push_back(make_pair(a, c));
    }
    for(int i = 0; i < n; i ++){
        dijkstra(i);
    }


    int p[10];
    for(int i = 0; i < R; i ++){
        p[i] = r[i] - 1;
    }
  //  cout << "\n";
    sort(p, p + R);
    int ret = INF;
    do{
            int tmp = 0;
            for(int i = 0; i < R - 1; i ++){
                tmp += mat[p[i]][p[i + 1]];
        //        cout << p[i] << " ";
            }
      //      cout << p[R - 1] << endl;
  //  tmp += mat[p[R - 2]][p[R - 1]];
        ret = min(ret, tmp);
    // cout << tmp << endl;

    }while(next_permutation(p, p + R));
    cout << ret << endl;
    return 0;
}
//1234567894848
//1234567891011


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

namespace ALDS1_11_D
{
    class Program
    {
        private static int n;
        private static int m;
        private static int q;
        private static Dictionary<int, List<int>> neighborDictionary;
        private static int[] graphGroup;
        static void Main(string[] args)
        {
            int[] tmpLine = Console.ReadLine()
                                   .Split(' ')
                                   .Select(s => int.Parse(s))
                                   .ToArray();
            Program.n = tmpLine[0];
            Program.m = tmpLine[1];

            Program.neighborDictionary = new Dictionary<int, List<int>>();
            Program.graphGroup = new int[Program.n];
            for (int i = 0; i < Program.n; i++)
            {
                Program.neighborDictionary.Add(i, new List<int>());
                Program.graphGroup[i] = -1;
            }
            
            for (int i = 0; i < Program.m; i++)
            {
                int[] tmpLine2 = Console.ReadLine()
                                       .Split(' ')
                                       .Select(s => int.Parse(s))
                                       .ToArray();
                Program.neighborDictionary[tmpLine2[0]].Add(tmpLine2[1]);
                Program.neighborDictionary[tmpLine2[1]].Add(tmpLine2[0]);
            }

            for (int i = 0; i < Program.n; i++)
            {
                if (Program.graphGroup[i] == -1)
                {
                    Program.DepthFirstSerach(i, i);
                }
            }
            
            Program.q = int.Parse(Console.ReadLine());

            for (int i = 0; i < Program.q; i++)
            {
                int[] tmpLine3 = Console.ReadLine()
                                        .Split()
                                        .Select(s => int.Parse(s))
                                        .ToArray();
                if (Program.graphGroup[tmpLine3[0]] == Program.graphGroup[tmpLine3[1]])
                {
                    Console.WriteLine("yes");
                }
                else
                {
                    Console.WriteLine("no");
                }
            }
        }

        private static void DepthFirstSerach(int groupID, int targetVertex)
        {
            Program.graphGroup[targetVertex] = groupID;

            Stack<int> stackToVisit = new Stack<int>();

            foreach (int neighbor in Program.neighborDictionary[targetVertex])
            {
                if (Program.graphGroup[neighbor] == -1)
                {
                    Program.DepthFirstSerach(groupID, neighbor);
                }
            }
        }
    }
}



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

Hs = list(map(int, input().split()))
cnt = 0
while 1:
    mode = 0
    for i in range(N):
        if Hs[i]>=1:
            if not mode:
                cnt += 1
            mode = 1
            Hs[i] -= 1
        else:
            mode = 0
    if sum(Hs)==0:
        break
print(cnt)

Measured memory_bytes: 3064
def main
  n,k = gets.chomp.split(/ /).map {|i| i.to_i}

  sn = Array.new(n,0)
  (1..k).each {|i|
    d = gets.chomp.to_i
    as = gets.chomp.split(/ /).map {|i| i.to_i}
    as.each {|j|
      sn[j-1] = sn[j-1]+1
    }
  }

  x = sn.select {|i|
    i == 0
  }.length

  puts x
end

main


Measured memory_bytes: 14304
mod = 10**9+7
n = int(input())
input_list = list(map(int,input().split()))
input_len = len(input_list)
remain_num = sum(input_list[1:])
remain_list = [remain_num]
for i in range(1,input_len):
    remain_list.append(remain_list[i-1]-input_list[i])

temp = 0
for i in range(input_len):
    temp = (temp+input_list[i]*remain_list[i])%mod
print(temp)

Measured memory_bytes: 31572
#include<bits/stdc++.h>
#define ll            long long
#define pb            emplace_back
#define fi            first
#define se            second
#define mp            make_pair
//#define int           int64_t

using namespace std;

typedef pair<int, int> pii;
const int N = (int)2e5 + 10;

int n, m, u, v, in[N], id[N], cnt;
vector<int> adj[N], rev[N];
queue<int> q;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #define FileName      "test"
    if(fopen(FileName".inp", "r")) {
       freopen(FileName".inp", "r", stdin);
       freopen(FileName".out", "w", stdout);
    }
    cin >> n >> m; m += n - 1;
    for(int i = 1; i <= m; ++i) {
        cin >> u >> v;
        adj[u].pb(v); ++in[v];
        rev[v].pb(u);
    }
    for(int i = 1; i <= n; ++i)
        if(in[i] == 0) {q.push(i); break;}
    while(q.size()) {
        id[u = q.front()] = ++cnt; q.pop();
        for(int v: adj[u])
            if(--in[v] == 0) q.push(v);
    }
    int res = 0;
    for(int i = 1; i <= n; ++i) {
        res = 0;
        for(int u: rev[i])
            if(id[u] > id[res]) res = u;
        cout << res << '\n';
    }
}


Measured memory_bytes: 17664
#include <iostream>
int main() {
	int N, Y, x;
	std::cin >> N >> Y;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
			x = N - i - j;
			if (i + j + x != N)continue;
			if (x < 0)continue;
			if (i * 10000 + j * 5000 + x * 1000 == Y) {
				std::cout << i << " " << j << " " << x << std::endl;
				return 0;
			}
		}
	}
	std::cout << "-1 -1 -1" << std::endl;
}

Measured memory_bytes: 256
///বিসমিল্লাহির_রহমানির_রহীম
#include<bits/stdc++.h>
#define     pie                          acos(-1.0)
#define     N                            2000015
#define     eps                          1e-9
#define     ff                           first
#define     ss                           second
#define     nl                           '\n'
#define     mod                          1000000007
#define     sp                           ' '
#define     CLR(a)                       memset(a,0,sizeof(a))
#define     SET(a)                       memset(a,-1,sizeof(a))
#define     all(x)                       x.begin(),x.end()
#define     allr(x)                      x.rbegin(),x.rend()
#define     sz(x)                        (int)(x).size()
#define     Fast_Read                    ios_base::sync_with_stdio(false); cin.tie(nullptr);  cout.tie(nullptr);
#define     Precision(x)                 cout.setf(ios::fixed); cout.precision(x);
#define     bug                          cout<<"debug"<<nl;
using namespace std;
int dx[]={0,0,1,-1,-1,-1,1,1};
int dy[]={1,-1,0,0,-1,1,1,-1};
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
template < class T> inline T biton(T n,T pos){return n |((T)1<<pos);}
template < class T> inline T bitoff(T n,T pos){return n & ~((T)1<<pos);}
template < class T> inline T ison(T n,T pos){return (bool)(n & ((T)1<<pos));}
template < class T> inline T gcd(T a, T b){while(b){a%=b;swap(a,b);}return a;}
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}
inline ll lxt(){ll aaa;scanf("%lld",&aaa);return aaa;}
inline double dxt(){double aaa;scanf("%lf",&aaa);return aaa;}
#ifdef obaydullah
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
///******************************************START******************************************
void solve(){
    int n;
    string s;
    cin>>n>>s;
    if(n<3200) cout<<"red"<<nl;
    else cout<<s<<nl;
}
int main(){
    Fast_Read
    Precision(10)
    #ifdef obaydullah
        double start_time = clock();
        ///freopen ("output.txt","w",stdout);
        ///freopen ("input.txt","r",stdin);
    #endif
    int tc=1;
    ///cin>>tc;
    while(tc--){
      solve();
    }
    #ifdef obaydullah
        double end_time = clock();
        cerr<<"Time = "<<fixed<<setprecision(10)<<(end_time - start_time) / CLOCKS_PER_SEC<<'\n';
    #endif

    return 0;
}


Measured memory_bytes: 256
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<random>
#include<unordered_set>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const int big=1e9-10;
const llint red=0xE869120;
const llint pro=1002001;
const long double pai=3.141592653589793238462643383279;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
class UF{
public:
	vector<int>go;
	UF(int in){go.res(in);for(int i=0;i<in;i++){go[i]=i;}}
	int find_uf(int a){
		if(go[a]==a){return a;}
		return go[a]=find_uf(go[a]);
	}
	void uni_uf(int a,int b){go[find_uf(a)]=find_uf(b);}
};
int main(void){
	int all=0,n,i,q,w,ans=0;cin>>n;
	vector<int>mot(n+1);
	vector<int>at(n+1);
	vector<pair<int,int>> sor;//最初数,後すう
	for(i=0;i<n;i++){cin>>mot[i];all^=mot[i];}
	mot[n]=all;
	all=0;
	for(i=0;i<n;i++){cin>>at[i];all^=at[i];if(mot[i]==at[i]){continue;}sor.pub(mp(mot[i],at[i]));}
	at[n]=all;sor.pub(mp(mot[n],at[n]));//取り残し
	sort(sor.begin(),sor.end());
	sort(mot.begin(),mot.end());
	sort(at.begin(),at.end());
	if(mot!=at){cout<<"-1"<<endl;return 0;}
	UF ren(sor.size());
	for(i=1;i<sor.size();i++){
		if(sor[i-1].fir==sor[i].fir){ren.uni_uf(i,i-1);}
	}
	for(i=0;i<sor.size();i++){
		q=lower_bound(sor.begin(),sor.end(),mp(sor[i].sec,-1))-sor.begin();
		ren.uni_uf(q,i);
	}
	vector<int> kaz(sor.size());
	for(i=0;i<sor.size();i++){kaz[i]=ren.find_uf(i);}
	sort(kaz.begin(),kaz.end());
	ans=kaz.size();
	auto itr=unique(kaz.begin(),kaz.end());
	cout<<ans+(itr-kaz.begin())-2<<endl;
	return 0;
}

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

public class Program
{
	public static void Main()
	{
		int[] KT = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var a = Console.ReadLine().Split().Select(int.Parse);
		Console.WriteLine(Math.Max(a.Max() -
			(a.Sum() - a.Max() + 1), 0));
	}
}

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

#define MOD (1000000007LL)
long long memo[400100] = {1, 0, };
using namespace std;

long long exp(long long b, long long e){
    if(e == 0) return 1;
    long long ee = exp(b, e / 2);
    long long ans = ee * ee;
    ans %= MOD;
    if(e % 2 == 1) ans *= b;
    return ans % MOD;
}

long long inv(long long n){
    return exp(n, MOD - 2);
}

long long fact(long long n){
    return memo[n];
}

long long comb(long long n, long long k){
    long long ans = fact(n);
    ans *= inv(fact(n - k));
    ans %= MOD;
    ans *= inv(fact(k));
    ans %= MOD;
    return ans;
}

long long P(long long n, long long k){
    return comb(n + k - 1, k);
}

int main(void){
    long long n, k;
    cin >> n >> k;
    for(long long f = 1; f <= 2 * n; f++){
        memo[f] = f * memo[f - 1] % MOD;
    }
    if(k >= n){
        long long ans = fact(2 * n - 1);
        ans *= inv(fact(n));
        ans %= MOD;
        ans *= inv(fact(n - 1));
        ans %= MOD;
        cout << ans << endl;
        return 0;
    }
    long long ans = 0;
    for(int i = 0; i <= k; i++){
        ans += comb(n, i) * P(n - i, i) % MOD;
        ans %= MOD;
    }

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


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

int main(){
  char a[100],b[100],c[200];
  int i,n;
  
  cin >> n;
  cin >> a >> b;
  
  for(i = 0;i<=(n-1);i++){
    cout << a[i];
    cout << b[i];
  }
   
  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

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

    ll N; cin >> N;
    vll A(N+1);
    rep(i, N+1) cin >> A[i];
    vll sa(N+2, 0);
    // sa[i] := sum of A[0, i)
    rep(i, N+2) {
        if(i > 0) sa[i] = sa[i-1] + A[i-1];
    }

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

    ll b = 1 - A[0];
    ll ans = 1;
    for(int i = 1; i <= N; i++) {
        b = 2 * b - A[i];
        if(b < 0) {
            cout << -1 << endl;
            return 0;
        }
        chmin(b, sa[N+1] - sa[i+1]);
        ans +=  b + A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4784
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ n, x, y ] <- readInts
	mapM_ print $ solve n ( x - 1 ) ( y - 1 )

solve n x y = runST $ do
	res <- newArray ( 0, n - 2 ) 0 :: ST s ( STUArray s Int Int )
	forM_ [ 0 .. n - 1 ] $ \i -> do
		forM_ [ i + 1 .. n - 1 ] $ \j -> do
			let
				d1 = j - i
				d2 = abs ( i - x ) + abs ( j - y ) + 1
				k = min d1 d2
			modifyArray res ( k - 1 ) succ
	getElems res

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
 int x;
  cin >> x;
 ll sum=0;
   int ans;
  for(int i=1;i<100000;i++){
    sum+=i;
    if(x<=sum){
       ans=i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static final int MAX = 100000+24;
    private static boolean[] isPrime=new boolean[MAX];
    private static int[] Prime=new int[MAX];
    private static long[] Sum=new long[MAX];
    public static void makePrime(){
        Arrays.fill(isPrime,false);
        Arrays.fill(Sum,0);
        int tot=0; isPrime[1]=isPrime[0]=true;
        for(int i=2;i<MAX;i++){
            if(!isPrime[i]){
                Prime[tot++]=i;
            }
            for(int j=0;j<tot;j++){
                if(i*Prime[j]>=MAX) break;
                isPrime[i*Prime[j]] = true;
                if(i%Prime[j] == 0) break;
            }
            if( !isPrime[i] && !isPrime[(i+1)/2]){
                Sum[i]++;
            }
            Sum[i]+=Sum[i-1];
        }
    }
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        makePrime();
        while(in.hasNext()) {
            int Q=in.nextInt();
            for(int i=1;i<=Q;i++){
                int l=in.nextInt(),r=in.nextInt();
                out.println(Sum[r]-Sum[l-1]);
            }
            out.flush();
        }
        in.close();
        out.close();
    }

}


Measured memory_bytes: 65504
#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))

int main(void)
{
    int h, w;
    int **grid;
    int **ans;
    grid = (int **)malloc(sizeof(int *) * 2000);
    ans = (int **)malloc(sizeof(int *) * 2000);
    rep(i, 2000)
    {
        grid[i] = (int *)malloc(sizeof(int) * 2000);
        ans[i] = (int *)malloc(sizeof(int) * 2000);
    }

    scanf("%d%d", &h, &w);
    rep(i, h)
    {
        char tmp[w + 1];
        scanf("%s", tmp);
        rep(j, w)
        {
            if (tmp[j] == '.')
                grid[i][j] = 0;
            else
                grid[i][j] = 1;
        }
    }

    rep(i, h)
    {
        int sum[2000] = {0};
        int sumCnt = 0;
        rep(j, w)
        {
            if (grid[i][j] == 0)
                sum[sumCnt]++;
            else
                sumCnt++;
        }

        sumCnt = 0;
        rep(j, w)
        {
            if (grid[i][j] == 0)
                ans[i][j] += sum[sumCnt];
            else
                sumCnt++;
        }
    }

    rep(i, w)
    {
        int sum[2000] = {0};
        int sumCnt = 0;
        rep(j, h)
        {
            if (grid[j][i] == 0)
                sum[sumCnt]++;
            else
                sumCnt++;
        }

        sumCnt = 0;
        rep(j, h)
        {
            if (grid[j][i] == 0)
                ans[j][i] += sum[sumCnt];
            else
                sumCnt++;
        }
    }

    int max = -1;
    rep(i, h)
        rep(j, w)
            max = max(max, ans[i][j]);

    printf("%d\n", max - 1);
    free(grid);
    free(ans);
    return 0;
}

Measured memory_bytes: 31488
#include <stdio.h>
#define N  100

void trace(int a[], int n) {
  int i;
  printf("%d", a[0]);
  for (i = 1; i < n; i++)
    printf(" %d", a[i]);
  putchar('\n');
}

void insertionSort(int a[], int n) {
  int t, i, j, k;
  
  for (i = 1; i < n; i++) {
    t = a[i];
    j = i - 1;
    
    while (j >= 0 && a[j] > t) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = t;
    trace(a, n);
  }
}

int main(void) {
  int a[N], n, i, j;

  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &a[i]);

  trace(a, n);
  
  insertionSort(a, n);
    
  return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n; cin >> n;
  vector<pair<pair<string, int>, int>> a(n);
  REP (i, n) {
    cin >> a[i].fi.fi >> a[i].fi.se;
    a[i].fi.se = -a[i].fi.se;
    a[i].se = i;
  }
  sort(ALL(a));
  REP (i, n) {
    cout << a[i].se + 1 << endl;
  }
}


Measured memory_bytes: 256
import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *H = map(int, read().split())
cnt = 0
ans = 0
for p, n in zip(H, H[1:]):
    if p >= n:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
    ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 13040
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val D = in.next().toInt
  val c = new Array[Long](26+1)
  val s = Array.ofDim[Long](D+1, 26+1)

  for (i <- 1 to 26) {
    c(i) = in.next().toInt
  }
  for (d <- 1 to D) {
    for (i <- 1 to 26) {
      s(d)(i) = in.next().toInt
    }
  }

  // val a = new Array[Int](N)
  for (i <- 1 to D) {
    pw.println(7)
  }

  pw.flush()
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


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

int main()
{
    int N, K, Q, answer_num;
    string answer;

    cin >> N >> K >> Q;
    int A[N];
    for (int i = 0; i < N; i++)
    {
        A[i] = K - Q;
    }
    for (int i = 0; i < Q; i++) {
        cin >> answer_num;
        A[answer_num - 1]++;
    }
    for (int i = 0; i < N; i++)
    {
        answer = (A[i] <= 0) ? "No" : "Yes";
        cout << answer << endl;
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int[] a = new int[n];
            int[] b = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            for (int i = 0; i < n; i++) {
                b[i] = Integer.parseInt(in.next());
            }

            List<Long> plus = new ArrayList<>();
            long sum = 0;
            long num = 0;
            for (int i = 0; i < n; i++) {
                long diff = a[i] - b[i];
                if (diff < 0) {
                    sum -= diff;
                    ++num;
                } else {
                    plus.add(diff);
                }
            }

            if (num == 0) {
                out.println(0);
                return;
            } else {
                long ans = num;
                Collections.sort(plus, Collections.reverseOrder());
                long ptr = 0;
                for (int i = 0; i < plus.size(); i++) {
                    ptr += plus.get(i);
                    ++ans;
                    if (ptr >= sum) {
//                    ++ans;
                        break;
                    }
                }

                // 出力
                if (ptr >= sum) out.println(ans);
                else out.println(-1);
            }

        }

    }
}



Measured memory_bytes: 60696
//Har Har Mahadev
using namespace std;
#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll long long int
#define pb push_back
#define mp make_pair
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " -> " << a << endl;
	err(++it, args...);
}

void testcase(){
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << max({a*c,a*d,b*c,b*d});
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    int res = 0;
    while (n) {
        res++;
        n /= k;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int mem[100005];
bool noo[100005];
int dp(int n){
    if(n == 0){
        return 1;
    }
    if( n < 0){
        return 0;
    }
    if(mem[n]!=-1){
        return mem[n];
    }
    if(noo[n]){
        return 0;
    }
    return mem[n] = (dp(n-1)%SMOD + dp(n-2)%SMOD)%SMOD;
}
      
    

inline void solve(){
    memset(mem,-1,sizeof(mem));
    int n, m,a[100005];
    cin >> n >> m;
    FOR(i,m){
        cin >> a[i];
        noo[a[i]]=true;
    }
    int ans=0;

    cout << dp(n)%SMOD fin;
    

}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) a.begin(),a.end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define debug(x) cout<<#x<<": "<<x<<endl
#define INF 1e9
typedef long long ll;

int main(void){
    string s;
    cin>>s;
    reverse(all(s));
    int idx;
    rep(i,12){
        if(s[i]=='?'){
            idx = i;
        }
    }
    // debug(s);debug(idx);
    int res,ok=0;
    rep(k,10){
        s[idx] = '0'+k;
        ll sigma = 0;
        rep1(n,11){
            sigma += (s[n]-'0')*((n<=6) ? (n+1) : (n-5));
        }
        int check = 11-(sigma%11);
        if((sigma%11)<=1) check = 0;
        // debug(k);
        // debug(sigma);
        // debug(check);
        if(check == s[0]-'0'){
            ok++;
            res=k;
        }
    }
    if(ok>1){
        cout<<"MULTIPLE"<<endl;
    }else{
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 3192
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x;
		for(int i = 1; i <= n; i++){
			x = i;
			if(x%3 == 0){
				System.out.print(" "+i);
			}else{
				while(x != 0){
					if(x%10 == 3){
					System.out.print(" "+i);
					break;
					}else{
					x /= 10;
					}
				}
			}
		}
		System.out.print("\n");
	}
}

Measured memory_bytes: 24464
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	uint64_t N;
	int kugyu;
	if (scanf("%" SCNu64, &N) != 1) return 1;
	kugyu = 1;
	while ((UINT64_C(1) << (kugyu + 1)) - 1 <= N) kugyu++;
	printf("%d\n", kugyu);
	return 0;
}



Measured memory_bytes: 2140
#include <stdio.h>
int main(void){
    double x1,x2,y1,y2,x,y;
    scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
    x = x2 - x1;
    y = y2 - y1;
    printf("%lf\n" , sqrt(x*x+y*y));
    return 0;
}



Measured memory_bytes: 2056
#include <stdio.h>
  int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int n = a+b;
    if(b+c < n){
      n = b+c;
    }
    if(a+c < n){
      n = a+c;
    }
    printf("%d\n",n);
  }

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import math

A,B,H,M = map(int, input().split())

A_ratio = (60*H+M)/720
B_ratio = M/60

sa = abs(A_ratio - B_ratio)

theta = min(2*math.pi*sa, 2*math.pi*(1-sa))

C = math.sqrt(pow(A,2)+pow(B,2) - (2*A*B*math.cos(theta)))

print(C)

Measured memory_bytes: 9504
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 07/03/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

template <typename T>
class max_segment_tree {
  size_t mpt_;
  vector<T> vec_;
 public:
  max_segment_tree(size_t size) {
    mpt_ = 1;
    while (mpt_ < size) mpt_<<=1;
    vec_.resize(mpt_+size, 0);
  }
  void update(size_t index, long long value) {
    auto i = mpt_ + index;
    vec_[i] = value;
    i /= 2;
    while (i > 0) {
      vec_[i] = max(vec_[i*2], vec_[i*2+1]);
      i /= 2;
    }
  }
  long long operator[](size_t i) const { return vec_[mpt_+i]; }
  long long range_max(size_t l, size_t r, size_t _l=0, size_t _r=numeric_limits<size_t>::max(), size_t _d=1) const {
    if (_r == numeric_limits<size_t>::max())
      _r = mpt_;
    if (_r <= l or r <= _l) {
      return 0;
    } else if (l <= _l and _r <= r) {
      return vec_[_d];
    } else {
      return max(range_max(l, r, _l, (_l+_r)/2, _d*2),
                 range_max(l, r, (_l+_r)/2, _r, _d*2+1));
    }
  }
};

constexpr long long MOD = 998244353;

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

  int N; cin>>N;
  vector<pair<int, int>> R(N);
  for (int i = 0; i < N; i++) {
    cin>>R[i].first>>R[i].second;
  }
  sort(R.begin(), R.end());

  vector<long long> dp(N+1);
  dp.back()=1;
  max_segment_tree<long long> sg(N);
  for (int i = N-1; i >= 0; i--) {
    int l=i, r=N;
    while (l+1<r) {
      auto c = (l+r)/2;
      if (R[c].first < R[i].first+R[i].second) {
        l = c;
      } else {
        r = c;
      }
    }

    sg.update(i, i);
    auto edge = sg.range_max(i, r);
    sg.update(i, edge);
    dp[i] = dp[i+1] + dp[edge+1];
    dp[i] %= MOD;
  }
  cout << dp[0] << endl;

  return 0;
}


Measured memory_bytes: 7040
a,b = list(map(int, input().split()))
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

c = set(make_divisors(a))
d = set(make_divisors(b))
e = list(c & d)

f = []
for i in range(len(e)):
        if is_prime(e[i]):
            f.append(e[i])
print(len(f) + 1)

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair
#define int         int64_t

using namespace std;

const int N = 302;
const int mod = int(1e9) + 7;

typedef pair<int, int> pii;

int res = 0, n, m, f[N][N], cost[N][N];
string c[N];

int Cost(int x, int y) {
    memset(&cost, 0, sizeof cost);
    for(int i = n; i >= 1; --i) {
        for(int j = n; j >= 1; --j) {
            cost[i][j] = cost[i + 1][j + 1] + (c[i][x] == c[j][y]);
        }
    }
    for(int i = 1; i <= n + 1; ++i) {
        for(int j = 1; j <= n + 1; ++j) {
            if(i == 1 && j == 1) f[i][j] = 0;
            else {
                f[i][j] = (ll)1e18;
                if(i > 1) f[i][j] = min(f[i][j], f[i - 1][j] + cost[i - 1][j]);
                if(j > 1) f[i][j] = min(f[i][j], f[i][j - 1] + cost[i][j - 1]);
            }
        }
    }
    return f[n + 1][n + 1];
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> m;
    for(int i = n; i >= 1; --i) {
        cin >> c[i]; c[i] = ' ' + c[i];
    }
    for(int i = 1; i < m; ++i) {
        res += Cost(i, i + 1);
    }
    cout << res;
}


Measured memory_bytes: 1792