akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
    for(int i = 0; i < (int)v.size(); i++)
        os << (i ? " " : "") << v[i];
    return os;
}
/*-------------------------------------------*/

int D;
int c[26];
ll s[365][26];

int last[26];

set<int> st[26];
vector<int> ret;
vector<int> ans;

ll sum = 0, MAX;

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

    srand((unsigned)time(NULL));

    rep(i, 26) st[i].insert(-1);

    cin >> D;
    rep(i, 26) cin >> c[i];
    rep(i, D) rep(j, 26) cin >> s[i][j];

    rep(d, D) {
        ll a = -1, mx = -1;
        rep(i, 26) if(chmax(mx, (d - *st[i].rbegin()) * c[i] + s[d][i])) a = i;
        ans.push_back(a);
        st[a].insert(d);
        sum += s[d][a];
        rep(i, 26) sum -= c[i] * (d - *st[i].rbegin());
    }

    MAX = sum;
    ret = ans;

    rep(i, 26) st[i].insert(D);

    while(clock() < CLOCKS_PER_SEC * 1.9) {
        int x = rand() % D;
        ll a = -1, mx = -inf;
        rep(i, 26) if(i != ans[x]) {
            auto it1 = st[i].upper_bound(x);
            auto it2 = st[i].lower_bound(x);
            it2--;
            ll y = s[x][i] + (*it1 - *it2) * (*it1 - *it2 - 1) / 2 * c[i];
            y -= (*it1 - x) * (*it1 - x - 1) / 2 * c[i];
            y -= (x - *it2) * (x - *it2 - 1) / 2 * c[i];
            if(chmax(mx, y)) a = i;
        }
        auto it1 = st[ans[x]].upper_bound(x);
        auto it2 = st[ans[x]].lower_bound(x);
        it2--;
        ll y = s[x][ans[x]] + (*it1 - *it2) * (*it1 - *it2 - 1) / 2 * c[ans[x]];
        y -= (*it1 - x) * (*it1 - x - 1) / 2 * c[ans[x]];
        y -= (x - *it2) * (x - *it2 - 1) / 2 * c[ans[x]];
        if(mx >= y) {
            st[a].insert(x);
            st[ans[x]].erase(x);
            ans[x] = a;
            sum += mx - y;
            if(chmax(MAX, sum)) ret = ans;
        } else if((sum + mx - y) * 101 >= MAX * 100) {
            sum += mx - y;
            st[a].insert(x);
            st[ans[x]].erase(x);
            ans[x] = a;
        }
    }

    rep(i, D) cout << ret[i] + 1 << endl;

    return 0;

    cout << endl;

    sum = 0;
    rep(d, D) {
        int x = ret[d];
        last[x] = d + 1;
        sum += s[d][x];
        rep(i, 26) sum -= (d + 1 - last[i]) * (c[i]);
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
const int MOD = 2019;
const int INF = 0x3f3f3f3f;

int l, r, ans;

int main(){
	scanf("%d %d", &l, &r);
	if(r / MOD > l / MOD) l %= MOD, r = r % MOD + MOD;
	else l %= MOD, r %= MOD;
	ans = INF;
	for(int i = l; i <= r; i++)
		for(int j = i + 1; j <= r; j++)
			ans = min(ans, (i * j) % MOD);
	printf("%d\n", ans);
	return 0;
}

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

int main(){
    int n,x,m,minm=10000;
    cin>>n>>x;
    for(int i=0;i<n;i++){
        cin>>m;
        x-=m;
        minm=min(minm,m);
    }
    cout<<x/minm+n<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    string a,b;
    cin>>a>>b;
    a+=b;
    if(pow((int)sqrt((double)stoi(a)),2)==stoi(a)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,k;
	cin>>a>>b>>k;
	vector<int>arr;
	
	if(a<b)
	{
		swap(a,b);
	}
	
	for(int i=1; i<=b; i++)
	{
		if((a%i==0) && (b%i==0))
		{
			arr.push_back(i);
		}
	}
	sort(arr.begin(), arr.end(), greater<int>());
	cout<<arr[k-1]<<endl;
	return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n-1],
    }

    let mut dp = vec![0; n + 1];
    for i in (0..n - 1).rev() {
        dp[a[i]] += 1;
    }

    for i in 1..=n {
        println!("{}", dp[i]);
    }
}


Measured memory_bytes: 5528
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
LL point[1000001];

void solve() {
    int N, Q;
    LL K;
    cin >> N >> K >> Q;
    
    REP0(i, Q) {
        int tmp; cin >> tmp;
        point[tmp]++;
    }

    REP1(i, N) {
        cout << ((point[i] > Q-K) ? "Yes" : "No") << endl; 
    }

}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout<<std::fixed<<std::setprecision(10);
  solve();
  return 0;
}

Measured memory_bytes: 1408
import os
import sys
from operator import add

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

K = int(sys.stdin.readline())
X, Y = list(map(int, sys.stdin.readline().split()))


def mh(x, y):
    return abs(x) + abs(y)


def add(a, b):
    if a >= 0:
        return a + b
    else:
        return a - b


def sub(a, b):
    return add(a, -b)


def closer(x, y, k):
    assert mh(x, y) >= k
    # x, y を k だけ原点に近づける
    if abs(x) >= k:
        x = sub(x, k)
    elif abs(y) >= k:
        y = sub(y, k)
    else:
        x = sub(x, k - abs(y))
        y = 0
    return x, y


# d*2だけ遠回りする
rem = K - mh(X, Y) % K
if rem % 2 == 0:
    d = rem // 2
elif K % 2 == 1:
    d = (rem + K) // 2
else:
    print(-1)
    exit()
    assert False

# 0 に向かう
x = X
y = Y
xy = [(x, y)]
if mh(x, y) % K != 0:
    while abs(x) + d < K and abs(y) + d < K:
        if K % 2 == 0:
            d += K // 2
        else:
            if abs(x) < abs(y):
                x = add(x, K)
            else:
                y = add(y, K)
            xy.append((x, y))

    if abs(x) + d >= K:
        y = add(y, d)
        x = sub(x, K - d)
        xy.append((x, y))
    elif abs(y) + d >= K:
        x = add(x, d)
        y = sub(y, K - d)
        xy.append((x, y))
    else:
        assert False

while x != 0 or y != 0:
    x, y = closer(x, y, K)
    xy.append((x, y))

x, y = xy[0]
xsign = 1 if x == X else -1
ysign = 1 if y == Y else -1

print(len(xy) - 1)
for x, y in reversed(xy[:-1]):
    print(x * xsign, y * ysign)


Measured memory_bytes: 61884
R,G,B,N = map(int,input().split(' '))
count = 0
rr = int(N/R) +1
gg = int(N/G) +1
bb = int(N/B) +1
for r in range(rr):
    for g in range(gg):
        b = N - r*R - g*G
        if b<0:
            break
        if b%B==0:
            count+=1
print(count)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    string str;
    cin>>str;
  	
  	if(str.find("RRR")!=-1){
      	cout<<3<<endl;
    }else if(str.find("RR")!=-1){
      	cout<<2<<endl;
    }else if(str.find("R")!=-1){
      	cout<<1<<endl;
    }else{
      	cout<<0<<endl;
    }
  	return 0;
  	
}

Measured memory_bytes: 3624
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())

import collections
d = collections.defaultdict(list)

for i in range(N):
    S, P = input().split()
    P = int(P)
    d[S].append((i+1, P))

ordered = list(d.keys())
ordered.sort()

for city in ordered:
    mises = d[city]
    mises = sorted(mises, key=lambda x: x[1], reverse=True)
    for mise in mises:
        print(mise[0])

Measured memory_bytes: 9340
def log_2(n):
    t = 0
    while n:
        if n % 2 == 1:
            break
        t += 1
        n //= 2
    return t


def solve(A, B, C)->int:

    s = A+B+C
    odd = min(log_2(s-A), log_2(s-B), log_2(s-C))
    even = min(log_2(s+A), log_2(s+B), log_2(s+C))

    if odd == even:
        return odd
    else:
        return odd+1


A, B, C = map(int, input().split())

ans = 0
if A % 2 == 1 or A % 2 == 1 or A % 2 == 1:
    ans = 0
elif A == B == C:
    ans = -1
else:
    ans = solve(A, B, C)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
int main(){
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double th = abs((H + M / 60) * 2 / 12 - M * 2 / 60) * PI;
    double ans = pow(A, 2) + pow(B, 2) - 2 * A * B * cos(th);
    double ans_2 = sqrt(ans);
    cout << fixed << setprecision(11) << ans_2 << endl;
}


Measured memory_bytes: 4216
import scala.io.StdIn.{readLong,readLine}

object Main {
  def main(args:Array[String]) = {
    val n = readLine.split(" ").map(_.toInt)
    val a = (0 until n(0)).map(_=>readLong).toArray
    val l = a.max
    val r = 100000*100000

    def load(i:Int, j:Int, s:Long, p:Long):Boolean = {
      if(i==n(0)) true
      else if(j==n(1)) false
      else {
        if(s + a(i) <= p) load(i+1,j,s+a(i),p) else load(i,j+1,0,p)
      }
    }

    def scan(left:Long, right:Long):Long = {
      if(left<right) {
        val mid = (left+right)/2
        if(load(0,0,0,mid)) scan(left,mid)
        else scan(mid+1, right)
      } else right
    }

    println(scan(l,r))
  }
}

Measured memory_bytes: 63808
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PI 3.1415926535897932384626433832795
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
long long MOD = 998244353;
pair<int,int> dx[4] = {{1,0},{-1,0},{0,1},{0,-1}};
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct chash {
    int operator()(int x) const { return x ^ RANDOM; }
};
//uniform_int_distribution(0,1)(rng)
string toString(long long x)
{
stringstream ss;
ss << x;
string str = ss.str();
return str;
}
long long fastpow(long long x,long long k)
{
    if(!k)
        return 1;
    if(k & 1)
        return ((x * fastpow(x,k-1) % MOD) % MOD) % MOD;
    long long ans = fastpow(x,k/2);
    ans %= MOD;
    ans *= ans;
    ans %= MOD;
    return ans;
}
long long sumF(long long x)
{
    int s = 0;
    while(x)
        s += x%10,x /= 10;
    return s;
}
int main()
{
    IO;
   // freopen("hello.in","r",stdin);
    int n;
    int curMx = -1;
    cin >> n;
    int ans = 0;
    for(int i = 1;i <= n;i++)
    {
        int x;
        cin >> x;
        if(x >= curMx)
        {
            ans++;
            curMx = x;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
long long int dp[21][1 << 21];
bool mat[21][21];
int posb[21];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> mat[i][j];
			if (mat[i][j])
				posb[i] |= 1 << (n - 1 - j);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 1; j < (1 << n); j++) {
			if (i == 0) {
				dp[i][j] = __builtin_popcount(posb[i] & j);
			}
			else {
				int tmpj = j;
				while (tmpj) {
					int pp = (tmpj & (-tmpj));
					tmpj ^= pp;
					if (posb[i]&pp) {
						dp[i][j] += dp[i - 1][j ^ (pp)];
						if (dp[i][j] >= MOD)
							dp[i][j] -= MOD;
					}
				}
			}
		}
	}
	cout << dp[n - 1][(1 << n) - 1];
	return 0;
}

Measured memory_bytes: 344320
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

ll gcd(ll a, ll b){ return b ? gcd(b,a%b):a; }

int main(){
  ll n;
  cin >> n;
  n++;
  ll ans = 0;
  REP(i,1,n)REP(j,1,n)REP(k,1,n){
    ans += gcd(i,gcd(j,k));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		Double S = Double.parseDouble(lines[0]);
		Double W = Double.parseDouble(lines[1]);

		if(W >= S) {
			System.out.println("unsafe");
		}
		else {
			System.out.println("safe");
		}
	}

}


Measured memory_bytes: 35896
#include<stdio.h>

int main()
{
	double x1,x2,r;
	int q;
	
	while(1)
	{
		scanf("%d",&q);
		if(q==-1){break;}
		x1=(double)q/2;
		r=x1*x1*x1-q;
		
		do
		{
			x2=x1-r/(3*x1*x1);
			x1=x2;
			r=x1*x1*x1-q;
		}while(r>0.00001*q||r<-0.00001*q);
		
		printf("%lf\n",x1);
	}
	return 0;
}

Measured memory_bytes: 0
N,M=map(int,input().split())
n=int(N)
m=int(M)
numlist=[]
loglist=[]
for i in range(n):
  numlist.append(0)
  loglist.append(0)
answer=0

for i in range(m):
  s,c=map(int,input().split())
  s=int(s)
  c=int(c)
  if s==1 and c==0 and n!=1:
    answer=-1
  elif loglist[s-1]!=0 and numlist[s-1]!=c:
    answer=-1
  else:
    numlist[s-1]=c
    loglist[s-1]=1

if answer==-1:
  print(answer)
elif n==1 and numlist[0]==0:
  print(0)
else:
  if numlist[0]==0:
    numlist[0]=1
  else:
    pass
  for i in range(n):
    answer+=numlist[i]*10**(n-i-1)
  print(answer)

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

using namespace std;

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

	int n;
	cin >> n;
	vector<int> a(n);
	int sum = 0;
	for(int & i : a) cin >> i, sum ^= i;
	for(int i : a) cout << (sum ^ i) << ' ';
}

Measured memory_bytes: 3936
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        for(int i=0;i<n;i++) {
           String[] s=sc.next().split(":");
           double c=Math.abs(Double.parseDouble(s[0])*60-Double.parseDouble(s[1])*11)/2;
           //double d=Math.min(c,360-c);
           //System.out.println(d<30?"alert":d<90?"warning":"safe");
           System.out.println(c<30||c>330?"alert":c<90||c>270?"warning":"safe");
        }
    }
}


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

void Print(char S[3]){
  int i;
  if(strlen(S) == 3){
    for(i = strlen(S) - 1;i >= 0;i--) printf("%c", S[i]);
    printf("\n");
  }else printf("%s\n", S);
}

int main(void){
  char S[3];
  scanf("%s", S);
  Print(S);
  return 0;
}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, i, j;
	cin >> n;
	vl a(n);
	set<ll> st;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		auto itr = st.find(a[i]);
		if (itr == st.end()) {
			st.insert(a[i]);
		}
		else {
			st.erase(itr);
		}
	}
	cout << st.size() << endl;
	
}

Measured memory_bytes: 5760
/*
 * Author : Sadi
 * Sat 18/07/2020
 * 15:29:13.22
 */
#include <bits/stdc++.h>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;

bool same(vector<int> &a, vector<int> &b) {
    if(a == b) return true;
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for(int i = 0; i < n; ++i) cin >> p[i];
    for(int i = 0; i < n; ++i) cin >> q[i];
    vector<int> u(n), v(n);
    for(int i = 0; i < n; ++i) {
        u[i] = i + 1;
        v[i] = i + 1;
    }

    int a = 0, b = 0;
    // assert(false);
    while(!same(u, p)) {
        next_permutation(u.begin(), u.end());
        a++;
    }

    while(!same(v, q)) {
        next_permutation(v.begin(), v.end());
        b++;
    }

    cout << abs(a - b) << endl;
    return 0;
}


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

const int MOD = 1e9+7;
const int MAX_N = 2006;
int N, M;
int a[MAX_N];
int b[MAX_N];

ll dp[MAX_N][MAX_N];

void solve()
{
	for(int i=1;i<=N;++i)for(int j=1;j<=M;++j){
		(dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+MOD)%=MOD;
		if(a[i-1]==b[j-1]) (dp[i][j]+=1+dp[i-1][j-1])%=MOD;
	}
	cout << (dp[N][M]+1)%MOD;
}

int main()
{
	cin >> N >> M;
	for(int i=0;i<N;++i) cin >> a[i];
	for(int i=0;i<M;++i) cin >> b[i];
	solve();
	return 0;
}

Measured memory_bytes: 34756
// Ver19.02
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  char s[11];
  ll maybe;
  ll ans = INF;
  scanf("%s", s);
  for (int i = 0; s[i + 2]; i++)
  {
    maybe = ((s[i] - '0') * 10 + s[i + 1] - '0') * 10 + s[i + 2] - '0';
    if (ans > llabs(753 - maybe))
      ans = llabs(753 - maybe);
  }

  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[200010];
    rep(i,0,N) cin >> A[i];
    map<ll,ll> mp;
    rep(i,0,N){
        mp[i - A[i]]++;
    }
    ll ans = 0;
    rep(i,0,N){
        ll v = i + A[i];
        ans += mp[v];
    }
    print(ans);


    

}

Measured memory_bytes: 27968
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> l(n);
    vector<int> r(n);
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>l.at(i)>>r.at(i);
        if(l.at(i)==r.at(i))
        sum++;
        else
        sum+=r.at(i)-l.at(i)+1;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    int k;
    char s[1000];
    scanf("%d\n",&k);
    scanf("%s",s);
    if(strlen(s)>k)
    {
        for(int i=0;i<k;i++)
        {
            printf("%c",s[i]);
        }
        printf("...\n");
    }
    else printf("%s",s);
    return 0;
}


Measured memory_bytes: 1736
#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 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 int inf = INT_MAX;
const ll INF = LLONG_MAX;
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=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, K; cin >> n >> K;
    K--;
    string in; cin >> in;

    in[K] = 'a' + (in[K] - 'A');

    cout << in << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e3 + 5;
const int M = 1e4 + 5;
const int mod = 1e9 + 7;
const int inf = 1e18 + 9;
 
int a[N], b[N], dp[N][M];

signed main() {
    IOS;
    int h, n;
    cin >> h >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i] >> b[i];
    for(int i = 0; i <= n; i++)
        for(int j = 1; j < M; j++)
            dp[i][j] = inf;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < M; j++){
            int pre = j - a[i];
            dp[i][j] = dp[i-1][j];
            if(pre >= 0)
                dp[i][j] = min(dp[i][j], dp[i][pre] + b[i]);
            else
                dp[i][j] = min(dp[i][j], dp[i][0] + b[i]);
        }
    }   
    cout << dp[n][h] << endl;
    return 0;
}

Measured memory_bytes: 78464
//***Little by little one travels far***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
    ll n,x,d,ans=0;
    cin>>n>>x>>d;

    if(d==0){
        if(x==0) cout<<"1";
        else cout<<(n+(ll)1);
        return 0;
    }

    map<ll,vector<pair<ll,ll>>> m;
    for(ll len=0;len<=n;len++){
        ll l,r;
        ll p=(len*x)/d;
        l=((len-1)*len)/2;
        r=((2*n-len-1)*len)/2;
        //cout<<p+l<<" "<<p+r<<endl;
        m[(len*x)%d].push_back(mp(p+l,p+r));
    }

    for(auto &i:m){
        auto &v=i.se;
        sort(v.begin(),v.end());
        ll l,r,f=0;
        for(auto &p: v){
            if(f==0){
                f=1;
                l=p.fi;
                r=p.se;
            }
            else{
                if(p.fi<=r)
                r=max(r,p.se);
                else{
                    ans+=(r-l+1);
                    l=p.fi;
                    r=p.se;
                }
            }
        }
        ans+=(r-l+1);
    }
    cout<<ans;
}

Measured memory_bytes: 22144
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
  	int x;
  	cin>>x;
  	if(x==0)
  	cout<<"1";
  	else
      cout<<"0";
	return 0;
}

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

int main() {
    using Int = long long;
    
    Int n, k;
    cin >> n >> k;
    
    vector<Int> a(n);
    Int sum = 0;
    
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    
    auto f = [&](Int d) {
        vector<Int> r(n);
        Int sum_r = 0;
         
        for (int i = 0; i < n; i++) {
            r[i] = a[i] % d;
            sum_r += r[i];
        }
        
        sort(r.begin(), r.end());
        
        Int cnt = 0;
        
        for (int i = 0; i < n - sum_r / d; i++) {
            cnt += r[i];
        }
        
        return cnt <= k;
    };
    
    Int ans = 1;
    
    for (Int i = 1; i * i <= sum; i++) {
        if (sum % i == 0) {
            if (f(i)) {
                ans = max(ans, i);
            }
            
            if (sum % (sum / i) == 0 && f(sum / i)) {
                ans = max(ans, sum / i);
            }
        }
    }
    
    cout << ans << endl; 
}

Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    a, v = i_map()
    b, w = i_map()
    t = i_input()



    if a < b:
        at = a + v * t
        bt = b + w * t
        print('YES' if at >= bt else 'NO')
    else:
        at = a - v * t
        bt = b - w * t
        print('YES' if at <= bt else 'NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 72604
#include <bits/stdc++.h>
#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(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
void chmax(short& x,short y){
	if(x<y) x=y;
}
int H,W;
string s[100];
short dp[100][100][100][100];		//u,b,l,r
int o[101][101];
int onum(int u,int b,int l,int r){	//[u,b]*[l,r]
	b++,r++;
	return o[b][r]-o[u][r]-o[b][l]+o[u][l];
}
int main(){
	cin>>H>>W;
	rep(i,H) cin>>s[i];
	rep(i,H) rep(j,W) if(s[i][j]=='o') o[i+1][j+1]=1;
	rep(i,H+1) rep(j,W) o[i][j+1]+=o[i][j];
	rep(i,H) rep(j,W+1) o[i+1][j]+=o[i][j];
	rep(i,H) rep(j,H) rep(k,W) rep(l,W) dp[i][j][k][l]=-1;
	int sx,sy;
	rep(i,H) rep(j,W) if(s[i][j]=='E') dp[i][i][j][j]=0,sx=i,sy=j;
	rep(dx,H) rep(dy,W) rep(u,H-dx) rep(l,W-dy){
		int b=u+dx,r=l+dy;
		if(dp[u][b][l][r]<0) continue;
//		printf("u=%d,b=%d, l=%d,r=%d   dp=%d\n",u,b,l,r,dp[u][b][l][r]);
		if(b-sx<u){
			int L=max(l,r-sy),R=min(r,W-1-(sy-l));
			chmax(dp[u-1][b][l][r],dp[u][b][l][r]+onum(u-1,u-1,L,R));
		}
		if(H-1-(sx-u)>b){
			int L=max(l,r-sy),R=min(r,W-1-(sy-l));
			chmax(dp[u][b+1][l][r],dp[u][b][l][r]+onum(b+1,b+1,L,R));
		}
		if(r-sy<l){
			int U=max(u,b-sx),B=min(b,H-1-(sx-u));
			chmax(dp[u][b][l-1][r],dp[u][b][l][r]+onum(U,B,l-1,l-1));
		}
		if(W-1-(sy-l)>r){
			int U=max(u,b-sx),B=min(b,H-1-(sx-u));
			chmax(dp[u][b][l][r+1],dp[u][b][l][r]+onum(U,B,r+1,r+1));
		}
	}
	short ans=0;
	rep(i,H) rep(j,H) rep(k,W) rep(l,W) chmax(ans,dp[i][j][k][l]);
	cout<<ans<<endl;
}


Measured memory_bytes: 195584
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array

main :: IO ()
main = do
  (n:x:_) <- fmap (map read . words) getLine :: IO [Integer]
  print $ solve n x

solve _ 0 = 0
solve n x
  | x == all = p n
  | x == (all `div` 2) + 1 = (solve n (x-1)) + 1
  | x <= all `div` 2 = solve (n-1) (x-1)
  | otherwise = p n - (solve n (all - x))
    where
      all = c n

c i = cs!i
  where
    cs = listArray (0, 50) $ map f [0..50]
    f 0 = 1
    f i = 2 * cs!(i-1) + 3

p i = ps!i
  where
    ps = listArray (0, 50) $ map f [0..50]
    f 0 = 1
    f i = 2 * ps!(i-1) + 1


Measured memory_bytes: 508
from operator import itemgetter
import sys
input = sys.stdin.readline


class BIT:
    """区間加算、一点取得クエリをそれぞれO(logN)で答えるデータ構造"""
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def _add(self, i, val):
        while i > 0:
            self.bit[i] += val
            i -= i & -i

    def get_val(self, i):
        """i番目の値を求める"""
        i = i + 1
        s = 0
        while i <= self.n:
            s += self.bit[i]
            i += i & -i
        return s

    def add(self, l, r, val):
        """区間[l, r)にvalを加える"""
        self._add(r, val)
        self._add(l, -val)


n, m = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]

for i in range(n):
    info[i] = info[i][0], info[i][1], info[i][1] - info[i][0] + 1
info = sorted(info, key=itemgetter(2))

bit = BIT(m + 1)
l_info = 0
ans = n
res = [0] * m
for d in range(1, m + 1):
    while True:
        if l_info < n and info[l_info][2] < d:
            l, r, _ = info[l_info]
            bit.add(l, r + 1, 1)
            l_info += 1
            ans -= 1
        else:
            break
    cnt = ans
    for i in range(0, m + 1, d):
        cnt += bit.get_val(i)
    res[d - 1] = cnt

print('\n'.join(map(str, res)), end='\n')


Measured memory_bytes: 128348
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	
	static int mod = (int)1e9 + 7;
	static int h, w;
	static char[][] grid;
	static int[][] memo;
	
	public static int dp(int i, int j) {
		if(!isValid(i, j))
			return 0;
		if(i == h - 1 && j == w - 1)
			return 1;
		
		if(memo[i][j] != -1)
			return memo[i][j];
		
		return memo[i][j] = ((dp(i + 1, j) % mod) + (dp(i, j + 1) % mod)) % mod;
	}
	
	public static boolean isValid(int i, int j) {
		return i < h && j < w && grid[i][j] == '.';
	}
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		
		st = new StringTokenizer(br.readLine());
		h = Integer.parseInt(st.nextToken());
		w = Integer.parseInt(st.nextToken());
		
		grid = new char[h][w];
		for(int i = 0; i < h; i++) {
			String s = br.readLine();
			for(int j = 0; j < w; j++)
				grid[i][j] = s.charAt(j);
		}
		
		memo = new int[h][w];
		for(int i = 0; i < h; i++)
			Arrays.fill(memo[i], -1);
		
		System.out.println(dp(0, 0));
	}
}


Measured memory_bytes: 32792
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

n=int(input())
ab=[list(map(int,input().split())) for i in range(n-1)]
c=list(map(int,input().split()))
c.sort()
print(sum(c)-c[-1])
lst=[[] for i in range(n)]
nodelst=[0]*n
ans=0
for i in range(n-1):
    a,b=ab[i]
    lst[a-1].append(b)
    lst[b-1].append(a)

# print(lst)
nodelst[0]=c[-1]
d=deque(lst[0])
cnt=-2
while d:
    tmp=d.popleft()-1
    if nodelst[tmp]==0:
        nodelst[tmp]=c[cnt]
        cnt-=1
        d+=lst[tmp]
print(*nodelst)

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

if n<=9:
	res=n
else:
	if n<=99:
		res=9
	else:
		if n<=999:
			res=n-99+9
		else:
			if n<=9999:
				res=909
			else:
				if n<=99999:
					res=n-9999+909
				else:
					res=90909

print(res)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  int a;
  string s;
  cin >> a >> s;
  if(a >= 3200) cout << s <<endl;
  else cout << "red" << endl;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
int cha[31][100001];
int sum[100001];

int main(int argc, char const* argv[])
{
  int n, c;
  cin >> n >> c;
  for(int i = 0; i < n; i++){
    int s, t, u;
    cin >> s >> t >> u;
    cha[u][s-1]++;
    cha[u][t]--;
  }
  int res = 0;
  for(int i = 0; i < 100001; i++){
    sum[i] = 0;
    for(int j = 0; j < 31; j++){
      if(i > 0)cha[j][i] = cha[j][i - 1] + cha[j][i];
      if(cha[j][i] > 0)sum[i]++;
    }
    res = max(res, sum[i]);
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 12800
def main():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = collections.Counter(list(map(int, input().rstrip('\n').split()))).most_common()
    if len(a) == 3:
        if a[0][0] ^ a[1][0] ^ a[2][0] == 0 and a[0][1] == a[1][1] == a[2][1]:
            print("Yes")
            exit()
    elif len(a) == 2:
        if (a[0][0] == 0 and a[1][1] == a[0][1] * 2) or (a[1][0] == 0 and a[0][1] == a[1][1] * 2):
            print("Yes")
            exit()
    elif len(a) == 1 and a[0][0] == 0:
        print("Yes")
        exit()
    print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 60784
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define M 1000000007
int factor(int n,int i){
    int ans=0,temp=i;
    //printf("i=%d",i);
    while(n/i!=0){
        //printf(" n/i=%d",n/i);
        ans+=n/i;
        i*=temp;
    }
    //printf(" ans=%d\n",ans);
    return ans;
}
int main(void){
    int n;
    scanf("%d",&n);
    int i,j,flag;
    long long int ans=1;
    for(i=2;i<=n;i++){
        flag=1;
        for(j=2;j<=sqrt(i);j++){
            if(i%j==0){
                flag=0;
                break;}
            }
            //素数であれば
            if(flag==1){
                ans=(ans*(factor(n,i)+1))%M;
            }
        }
    printf("%lld\n",ans);
}



Measured memory_bytes: 128
h, w = map(int, input().split())
a = [list(input()) for i in range(h)]
for i in range(h) :
    a[i].insert(0, "#")
    a[i].append("#")
print("#"*(w+2))
for i in range(h) :
    for j in range(w+2) :
        print(a[i][j],sep="",end="")
    print("")
print("#"*(w+2))


Measured memory_bytes: 9168
#include<iostream>
#include<algorithm>
using namespace std;
int  a[200001];
int main() {
	int n;
	cin >> n;
	for (int i = 0;i < n;i++)cin >> a[i];
	sort(a, a + n);
	for (int i = 1;i < n;i++) {
		if (a[i] == a[i - 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 1024
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N, M = gets_i_list
a_list = Array.new(M) { gets.to_i }

MOD = (10**9 + 7)
a_index = 0

dp = Array.new(N, 0)
dp[0] = 1

if a_list[a_index] == 1
  a_index += 1
else
  dp[1] = 1
end

0.step(N-2) do |i|
  if a_list[a_index] == i+2
    a_index += 1
  else
    dp[i+2] = (dp[i+1] + dp[i]) % MOD
  end
end

puts dp[N]

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	string a, b, c; cin >> a >> b >> c;
    string s(a, 0, 1), t(b, 0, 1), u(c, 0, 1);
    string ans = s + t + u;
    transform(ans.begin(), ans.end(), ans.begin(), ::toupper);
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3504
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
const lint mod=1e9+7;

int main()
{
  lint n,m;
  cin >> n >> m;
  std::vector<lint> p(m);
  std::vector<string> s(m);
  REP(i,m){
    cin >> p[i] >> s[i];
  }

  if(m == 0){
    cout << "0 0 \n";
    return 0;
  }
  lint crt_num=0, pnt_num=0;
  std::vector<int> crt_list(n,0),pnt_list(n,0);
  for(int i=0;i<m;i++){
    if(s[i].compare("AC") == 0 && crt_list[p[i]-1] == 0){
      crt_list[p[i]-1] = 1;
      crt_num++;
    }else if(s[i].compare("WA") == 0 && crt_list[p[i]-1] == 0){
      pnt_list[p[i]-1]++;
    }
  }

  REP(i,n){
    if(crt_list[i] == 1){
      pnt_num += pnt_list[i];
    }
  }
  cout << crt_num << " " << pnt_num << "\n";
  return 0;
}


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

int main()
{
  char b;

  cin >> b;

  switch (b) {
    case 'A':
      cout << 'T' << endl;
      break;
    case 'T':
      cout << 'A' << endl;
      break;
    case 'C':
      cout << 'G' << endl;
      break;
    default:
      cout << 'C' << endl;
      break;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,-1,0,1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
    if(a>b){
        a = b; return true;
    }
    else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
    if(a<b){
        a = b; return true;
    }
    else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
    cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const ll mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    string s; cin >> s;
    cout << count(all(s),'1') << endl;
}

Measured memory_bytes: 3628
package main

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

func main() {
	s := IOInitialize()
	R := Int(s)
	if R < 1200 {
		fmt.Println("ABC")
		return
	}
	if R < 2800 {
		fmt.Println("ARC")
		return
	}
	fmt.Println("AGC")
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}


Measured memory_bytes: 640
import sys
for line in sys.stdin.readlines():
    a, b, c, d, e, f = [float(x) for x in line.split()]
    if a!=0 and d!=0:
        a, b, c = [x/a for x in [a, b, c]]
        d, e, f = [x/d for x in [d, e, f]]
        y = (c-f) / (b-e)
        x = c - b * y

    else:
        a, b, c = [x/b for x in [a, b, c]]
        d, e, f = [x/e for x in [d, e, f]]
        x = (c-f) / (a-d)
        y = c - a * x
    print(f'{x:.3f} {y:.3f}')



Measured memory_bytes: 5608
#include "bits/stdc++.h"
using namespace std;

class Cube{
public:
	int f[6];
	Cube(){}
		void roll_z(){roll(1,2,4,3);}
		void roll_y(){roll(0,2,5,3);}//to W
		void roll_x(){roll(0,1,5,4);}//to N
		void roll(int i,int j,int k, int l){
			int t=f[i];f[i]=f[j];f[j]=f[k];f[k]=f[l];f[l]=t;
		}
		void move(char ch){
			if(ch=='E')for (int i = 0; i < 3; ++i) {roll_y();}
			if(ch=='W')roll_y();
			if(ch=='N')roll_x();
			if(ch=='S')for (int i = 0; i < 3; ++i) {roll_x();}
		}
};
bool eq(Cube c1,Cube c2){
	for (int i = 0; i < 6; ++i) {
		if (c1.f[i] != c2.f[i]) {return false;}
	}return true;
}
bool equal(Cube c1,Cube c2){
	for (int i = 0; i < 6; ++i) {
		for (int j = 0; j < 4; ++j) {
			if (eq(c1,c2)) return true;
						c1.roll_z();
		}
		if (i%2==0) {c1.roll_y();}
		else{c1.roll_x();}
	}
	return false;
}


int main() {
	Cube c1,c2;
	for (int i = 0; i < 6; ++i) cin>>c1.f[i];
	for (int i = 0; i < 6; ++i) cin>>c2.f[i];

	if (equal(c1,c2)) {cout<<"Yes"<<endl;}
	else {cout<<"No"<<endl;}

	return 0;
}

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

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

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

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <boost/foreach.hpp>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
#define _GLIBCXX_DEBUG
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
vector<long> Primelist;
//template functions
/////////////////////////
void Prinit(){
long PR=10000001;
vector<long> P(PR,0);
for(long i=2;i*i<PR;i++){
    if(P.at(i)==0){
        long j=i;
      j+=i;
        while(j<PR){
            P.at(j)=1;
             j+=i;         
        }
    }
}

for(long i=2;i*i<PR;i++){//Primelist.size()=446
    if(P.at(i)==0){
        Primelist.push_back(i);
    }
}
}

void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

long strtolong(string str){
istringstream ss;
ss=istringstream(str);
long num;
ss>>num;
return num;
}

long chartolong(char ch){
long num;
num=ch-'0';
return num;
}

string longtostr(long N){
    string str;
    str=to_string(N);
    return str;
}









/////////////////////////


//Answer


int main() {
long N,K;
cin>>N>>K;
vector<long> A(N);
vector<long> F(N);
long maxA=0,maxF=0;;
for(long i=0;i<N;i++){
cin>>A.at(i);
if(maxA<A.at(i)){
    maxA=A.at(i);
}
}
for(long i=0;i<N;i++){
cin>>F.at(i);
if(maxF<F.at(i)){
    maxF=F.at(i);
}
}
sort(A.begin(),A.end());
sort(F.begin(),F.end());
reverse(A.begin(),A.end());
long ok=maxA*maxF;
long ng=-1;
while(labs(ok-ng)>1){
    long mid=(ok+ng)/2;
    long L=K;
    long t=0;
    for(long i=0;i<N;i++){
        if(A.at(i)*F.at(i)>mid&&L>=0){
            t=(A.at(i)*F.at(i)-mid);
            t=upDiv(t,F.at(i));
            L=L-t;
        }
    }
    if(L<0){
        ng=mid;
    }else{
        ok=mid;
    }
}

cout<<ok<<endl;

}





Measured memory_bytes: 240876