akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
import sys
input = sys.stdin.readline

N = int(input())
lst_blue = [input() for _ in range(N)]
set_blue = set(lst_blue)
M = int(input())
lst_red = [input() for _ in range(M)]

ans = 0
for word in set_blue:
    cnt_blue = lst_blue.count(word)
    cnt_red = lst_red.count(word)
    cnt = cnt_blue - cnt_red
    if cnt >= ans:
        ans = cnt

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;

int main() {
	vector< pair <double, pair<int, int> > > m;
	FOR(i, 1, 151) FOR(j, i+1, 151)
		m.push_back(make_pair(sqrt(i * i + j * j), make_pair(i, j)));
	sort(m.begin(), m.end());

//	REP(i, 1000)
//		cout << i << ' ' << m[i].first << ' ' << m[i].second.first << ' ' << m[i].second.second << endl;

	int w, h;
	while(cin >> h >> w, w|h) {
		double v = sqrt(w * w + h * h);
		REP(i, m.size()) {
			if(m[i].first >= v && m[i].second.first == h && m[i].second.second == w) {
				cout << m[i+1].second.first << ' ' << m[i+1].second.second << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1328
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    string s;
    cin>>s;
    cout<<"A"<<(s[1]=='B'?'R':'B')<<"C"<<endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

constexpr int MAX = 50;

int main (int argc, char *argv[]) {
    int n, r, p, c;
    vector<int> h;
    int i, j;
    
    // input
    while (cin>>n>>r, n||r) {
        // init
        for (i = 0, j = 1; i < n; ++i, ++j) {
            h.push_back(j);
        }

        // solve
        for (i = 0; i < r; ++i) {
            // cout<<"-----init------"<<endl;
            // for (int i = n-1; i > -1; --i) {
            //     cout<<i<<":"<<h[i]<<endl;
            // }

            cin>>p>>c;

            int p_ = n - p;
            int c_ = p_ - (c - 1);

            // copy
            vector<int> tmp;
            for (int i = 0; i < c; ++i) {
                tmp.push_back(h[c_]);
                c_++;
            }

            // cout<<"---tmp---"<<endl;
            // for (int i = c-1; i >= 0; --i) {
            //     cout<<tmp[i]<<endl;
            // }

            // erase
            c_ = p_ - (c - 1);
            h.erase(h.begin() + c_, h.begin() + c_ + c);

            // cout<<"-----erase------"<<endl;
            // // for (int i = n-1; i > -1; --i) {
            // //     cout<<h[i]<<endl;
            // // }
            // for (auto e : h) {
            //     cout<<e<<endl;
            // }
        
            // copy
            for (int i = 0; i < c; ++i) {
                h.push_back(tmp[i]);
            }

            tmp.clear();
        }

        // cout<<"-----init------"<<endl;
        // for (int i = n-1; i > -1; --i) {
        //     cout<<h[i]<<endl;
        // }

        // cout<<"---ans---"<<endl;
        cout<<h[n-1]<<endl;
        
        // clear
        h.clear();
    }
    return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll d;cin >> d;
    vl c(26);rep(i,26)cin >> c[i];
    vvl s(d,vl(26));rep(i,d)rep(j,26)cin >> s[i][j];
    vl last(26,-1);
    ll sum=0;
    rep(i,d){
        ll t;
        ll maxi=0;
        rep(j,26){
            ll p=s[i][j];
            rep(k,26){
                if(k==j)continue;
                p-=c[k]*(i-last[k]);
            }
            if(chmax(maxi,p))t=j;
        }
        cout << t+1 <<endl;
        last[t]=i;
    }
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,s,c;
    cin>>n>>m;
    int arr[n];
    for(int i=0;i<n;i++)
        arr[i]=-1;
    while(m--)
    {
        cin>>s>>c;
        if(arr[s-1]==-1 || arr[s-1]==c)
        arr[s-1]=c;
        else
        {
        cout<<"-1";
        return 0;
        }
    }
    if(n>1)
    {
    for(int i=1;i<n;i++)
    {
        if(arr[i]==-1)
        arr[i]=0;
    }
    }
    if(n==1 && arr[0]==-1)
    arr[0]=0; 
    if(n>1)
    {
        if(arr[0]==-1)
        arr[0]=1;
        if(arr[0]==0)
        {
            cout<<"-1";
            return 0;
        }
    }
    for(int i=0;i<n;i++)
    cout<<arr[i];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = (a); i < (b); ++i)
#define repr(i, a, b) for (ll i = (a); i > (b); --i)
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll n, k;
vector<vector<ll>> es(1e5 + 10, vector<ll>());
vector<ll> fact(1e5 + 10);
vector<ll> invs(1e5 + 10);
vector<bool> seen(1e5 + 10, false);
ll ans;

ll mod_pow(ll x, ll m, ll mod)
{
    // x ** m % mod
    if (m == 0)
    {
        return 1;
    }
    else if (m % 2 == 0)
    {
        ll half = mod_pow(x, m / 2, mod);
        return half * half % mod;
    }
    else
    {
        return x * mod_pow(x, m - 1, mod) % mod;
    }
}

ll perm(ll n, ll r)
{
    if (n < r)
        return 0;
    return fact[n] * invs[n - r] % mod;
}

void rec(ll v)
{
    if (seen[v])
        return;
    seen[v] = true;

    // 注目ノードは着色済み
    // 子を塗る
    if (v == 0)
    {
        ans *= perm(k - 1, es[v].size());
        ans %= mod;
    }
    else
    {
        ans *= perm(k - 2, es[v].size() - 1);
        ans %= mod;
    }
    for (ll nv : es[v])
        rec(nv);
    return;
}

int main()
{
    cin >> n >> k;
    rep(i, 0, n - 1)
    {
        ll a, b;
        cin >> a >> b;
        --a;
        --b;
        es[a].push_back(b);
        es[b].push_back(a);
    }

    fact[0] = 1;
    rep(i, 1, k + 1) fact[i] = fact[i - 1] * i % mod;
    invs[k] = mod_pow(fact[k], mod - 2, mod);
    repr(i, k - 1, -1) invs[i] = invs[i + 1] * (i + 1) % mod;

    ans = k; // 最初の頂点の塗り方
    rec(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }
using P = pair<ll, ll>;
void prp(P& p) {cout << p.first << " " << p.second << endl;}

// スタート地点からの最短距離を返す。不閉路がある場合はそれも検出できる
// P = pair<cost, to>
int V, E;
arr<P> G;
vector<ll> dist;
void BellmanFord(int st, bool& has_negative, int k){
    rep(i, V) dist[i]=INFL;
    dist[st] = 0;
    bool update=true;
    has_negative = false;

    int cnt=0;
    while(update){
        update = false;
        cnt++;
        if(cnt==k) {has_negative=true; return;}
        rep(i, V){
            if(dist[i]==INFL) continue;
            for(auto e: G[i]){
                if(dist[e.second] > dist[i]+e.first){
                    dist[e.second] = dist[i] + e.first;
                    update = true;
                }
            }
        }
    }

    return;
}
int main()
{
    cin >> V >> E;
    dist.resize(V);
    G.resize(V);
    rep(i, E){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back({-c, b});
    }

    bool flag=false;
    BellmanFord(0, flag, V);
    ll ans = dist[V-1];
    BellmanFord(0, flag, V+1);
    if(ans != dist[V-1]) pr("inf");
    else pr(-ans);
    return 0;}

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

int main (){

  int A;
  cin >> A;
  int a,b,c,d;
  d=A%10; c=(A/10)%10; b=(A/100)%10; a=(A/1000)%10;
  if(a+b+c+d==7) cout << a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7" << endl;
  else if(a+b+c-d==7) cout <<  a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7" << endl;
  else if(a+b-c+d==7) cout <<  a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"  << endl;
  else if(a-b+c+d==7) cout <<  a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"  << endl;
  else if(a-b-c+d==7) cout <<  a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"  << endl;
  else if(a-b+c-d==7) cout <<  a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"  << endl;
  else if(a+b-c-d==7) cout <<  a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"  << endl;
  else  cout <<  a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7" << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		
		if (x < y) {
			System.out.println("a < b"); 
		} else if (x > y) {
			System.out.println("a > b"); 
		} else
			System.out.println("a == b");
	}
}

Measured memory_bytes: 17160
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = a / 2;
            string input = Console.ReadLine();

            string Lword = input.Substring(0, b);
            string Rword = input.Substring(b , b);

            if (a % 2 != 0)
            {
                Console.WriteLine("No");

            }
            else
            {
                if (Lword == Rword)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
            
        }
    }
}

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

using namespace std;

const int mod = 1e9 + 7;

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

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

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

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

void dfs(vector<vector<int>> &v, vector<int> &visited, int node, int &ans){
    if(visited[node]){
        return;
    }
    visited[node] = 1;
    ans++;
    for(auto i : v[node]){
        dfs(v, visited, i, ans);
    }
}

/*bool good(vector<int> &v, int d, int mid){
    vector<int> p(v.size());
    p[0] = v[0] - mid;
    for(int i = 1;i < v.size();i++){
        p[i] = p[i - 1] + (v[i] - mid);
    }
    vector<int> m(v.size());
    m[0] = p[0];
    int mi = m[0];
    for(int i = 1;i < v.size();i++){
        mi = min(mi, p[i]);
        m[i] = mi;
    }
    for(int r = 0;r < v.size();r++){
        if(r - d > 0){
            if(m[r - d - 1] <= p[r]){
                L = r - d;
                R = r;
                return true;
            }
        }
    }
    return false;
}*/

long long good(vector<long long> &v, long long mid){
    long long ans = 0;
    for(long long i = 0;i < v.size();i++){
        ans += abs(v[i] - pow(mid, i));
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0;i < n;i++){
        cin >> h[i];
    }
    vector<int> dp(n + 1);
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = abs(h[1] - h[0]);
    for(int i = 3;i <= n;i++){
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i - 2]), dp[i - 2] + abs(h[i - 1] - h[i - 3]));
    }
    cout << dp[n] << endl;
}
/*
5 2
-1 -2 -3 4 5
2 3
4

-3 -2 -1 4 5
2 3
5 + (-3) = 2
4 + -2 = 2
ans = 4

-3 -2 -1 4 5
3 2
5 + -3 = 2
4 + -1 = 3
ans = 5
*/


Measured memory_bytes: 4056
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let k: i16 = read();
    let x: i16 = read();
    println!(
        "{}",
        ((x - k + 1)..(x + k - 1) + 1)
            .map(|x| x.to_string())
            .collect::<Vec<String>>()
            .join(" ")
    );
}


Measured memory_bytes: 4352
N = int(input())
A = list(map(int,input().split()))
A = [0] + A + [0]
SUM = 0
for i in range(N+1):
    SUM += abs(A[i+1] - A[i])
for i in range(1,N+1):
    if (A[i] - A[i-1]) * (A[i+1] - A[i]) >= 0:
        ans = SUM
    else:
        ans = SUM - 2 * min(abs(A[i] - A[i-1]), abs(A[i+1] - A[i]))
    print(ans)

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

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<double> a(n);
    double ans = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ans = (a[0] + a[1]) / 2.0;
    for (int i = 2; i < n; i++){
        ans = (ans + a[i]) / 2.0;
    }
    cout << ans;
    return 0;
}


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

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

    queue<int> mi;
    vi sum(s.size()+1);
    rep(i, s.size()) {
        if(s[i] == '>') {
            sum[i+1] = sum[i]-1;
            if(i == s.size()-1 || s[i+1] == '<' ) {
                mi.push(sum[i+1]);
            }
        } else {
            if(!i) {
                mi.push(0);
            }
            sum[i+1] = sum[i]+1;
        }
    }

    int i = 0;
    int now = -mi.front();
    mi.pop();
    while(i != s.size()+1) {
        if(i && i != s.size() && s.substr(i-1, 2) == "<>") {
            sum[i] += max(now, -mi.front());
            now = -mi.front();
            mi.pop();
            ++i;
            continue;
        }
        sum[i] += now;
        ++i;
        //cout << now << endl;
    }

    ll ans = 0LL;
    rep(i, s.size()+1) {
        ans += sum[i];
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, m, c, a[105];
int main() {
	read(n), read(m);
	for (int i = 1; i <= n; i++) read(a[i]);
	sort(a+1, a+n+1);
	for (int i = 1; i <= n; i++)
		if (m >= a[i]) m -= a[i], c++;
	if (c == n && m) c--;
	return printf("%d\n", c), 0;
}

Measured memory_bytes: 256
import math
def distance(x, y):
    b = 0
    for k in range(d):
        b += (x[k] - y[k]) ** 2
    return float(math.sqrt(b))

n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
a = 0
for j in range(n - 1):
    for i in range(j + 1):
        if distance(x[i], x[j + 1]) == math.floor(distance(x[i], x[j + 1])):
            a += 1
print(int(a))

Measured memory_bytes: 9124
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

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

int main(void) {
	int num, i, j, k, a, b;
	ll ans = 0;
	string s, rgb = "RGB";
	cin >> num >> s;
	vector<vector<ll>> d(3, vector<ll>(num, 0));
	rep(i, num) {
		d[rgb.find(s[i])][i]++;
	}
	rep(i, num - 1) {
		rep(j, 3) {
			d[j][i + 1] += d[j][i];
		}
	}
	rep(j, num) {
		b = rgb.find(s[j]);
		rep(i, j) {
			if (s[i] == s[j])
				continue;
			a = b + (int)rgb.find(s[i]) - 1;
			if (a == 0)
				a = 2;
			else if (a == 2)
				a = 0;
			ans += d[a][num - 1] - d[a][j];
			k = j + j - i;
			if (k < num && s[k] == rgb[a])
				ans--;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    IOS
    int n;
    cin>>n;
    pair<int,int> a[n];
    for (int i=0;i<n;i++)
    {
        int ele;
        cin>>ele;
        a[i]=make_pair(ele,(i+1));
    }
    sort(a,a+n);
    for (int i=0;i<n;i++)
    cout<<a[i].second<<" ";
    cout<<endl;
    return 0;
}

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

int main() {
	int h[10];

	for (int i = 0; i < 10; i++)
		std::cin >> h[i];

	std::sort(h, h + 10);

	std::cout
		<< h[9] << std::endl
		<< h[8] << std::endl
		<< h[7] << std::endl;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

int main(){
    ll r;
    cin >> r;
    double pi = acos(-1);

    cout << setprecision(10) << 2*r*pi << endl;
    return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793

int main(){
    double a,b,x;
    cin >> a >> b >> x;
    // double h = x / a*a ;
    double ans;
    if(a * a * b / 2.0 <= x) {
        ans = atan(2 * (a * a * b - x) / (a * a * a));
    } else {
        ans = PI / 2 - atan(2 * x / (a * b * b));
    }
    cout << setprecision(10) << ans*(180/PI) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

using namespace std;

typedef long long ll;

int ans = 0;
int n;

void go(int len, ll cur, int msk) {
	if (len == 10) return;
	
	if (msk == 7 && cur <= n) {
		ans++;
	}
	go(len + 1, cur * 10 + 3, msk | 1);
	go(len + 1, cur * 10 + 5, msk | 2);
	go(len + 1, cur * 10 + 7, msk | 4);
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	go(0, 0, 0);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N,T = map(int,input().split())

meals = [tuple(map(int,input().split())) for _ in range(N)]

# dp1[t]: i番目の料理まででt分以内に食べれるものの美味しさ
# dp2[t]: i番目の料理まででt分以内に食べれるものの美味しさ (最後に食べる用のを選んだ仮定)

dp1 = np.zeros(T,dtype=int)
dp2 = np.zeros(T,dtype=int)

for a,b in meals:
    ndp1 = dp1.copy()
    ndp1[a:] = np.maximum(dp1[a:],dp1[:-a]+b)

    ndp2 = dp2.copy()
    ndp2[a:] = np.maximum(dp2[a:],dp2[:-a]+b)
    ndp2 = np.maximum(ndp2,dp1+b)
    dp1,dp2 = ndp1,ndp2

print(ndp2[-1])

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

int main(){
	int n;
	int a[31] = {1,1,2};
	for(int i=3 ; i <= 30 ; i++ ){
		a[i] = a[i-1] + a[i-2] + a[i-3];
	}

	while( cin >> n , n ){
		cout << (a[n]/10/365 + 1) << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int N, D, X;
  cin >> N >> D >> X;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  
  D = D - 1;
  int sum = X;
  REP(i,N){
    sum += D/A.at(i) + 1;
  }
  cout << sum << endl;
}

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

using namespace std;
#define ll long long

int main(){
  ll A, B, C;
  cin >> A >> B >> C;
  if(A + B >= C) {
    cout << B + C << endl;
  } else {
    cout << A + 2 * B + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://abc080.contest.atcoder.jp/tasks/abc080_c>
問題文============================================================
 joisinoお姉ちゃんは、ある商店街に店を開こうとしています。
 
 その商店街の店は、月曜日から金曜日の 5 つの曜日を午前と午後の 2 つの時間帯に分けて、これら 10 個の時間帯それぞれについて店を営業するか否かを決めることとなっています。ただし、1 つ以上の時間帯で店を営業しなければなりません。
 
 商店街には既に N 個の店があり、1 から N までの番号がついています。
 
 これらの店の営業時間の情報として Fi,j,k が与えられ、月曜日 = 曜日 1、火曜日 = 曜日 2、水曜日 = 曜日 3、木曜日 = 曜日 4、金曜日 = 曜日 5、 午前 = 時間帯 1、午後 = 時間帯 2 と対応させたとき、Fi,j,k=1 なら曜日 j の時間帯 k に店 i が営業しており、Fi,j,k=0 なら営業していないことを意味します。
 
 店 i とjoisinoお姉ちゃんの開く店の両方が営業している時間帯の個数を ci としたとき、joisinoお姉ちゃんの店の利益は P1,c1+P2,c2+…+PN,cN となります。ただし、利益は負にもなりうることに注意してください。
 
 1 つ以上の時間帯で店を営業しなければならないことに注意しつつ、10 個の時間帯それぞれについて店を営業するか否かを決めるとき、joisinoお姉ちゃんの店の利益のあり得る最大値を求めてください。
 

=================================================================

解説=============================================================

 bitでの貪欲全探索
 
================================================================
*/
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<vector<ll>> F(N,vector<ll>(10));
    for(int i = 0; i < N;i++)for(int j = 0; j < 10;j++) cin >> F[i][j];
    vector<vector<ll>> P(N,vector<ll>(11));
    for(int i = 0; i < N;i++) for(int j = 0; j < 11;j++) cin >> P[i][j];

    ll ans = -LINF;
    for(int i = 1; i < (1<<10);i++){
        ll T = 0;
        vector<int> cnt(N,0);
        for(int j = 0; j < 10;j++){
            if(!((i>>j)&1))continue;
            for(int k = 0; k < N;k++){
                if(F[k][j] == 1){ cnt[k]++; }
            }
        }
        for(int j = 0; j < N;j++){
            T += P[j][cnt[j]];
        }
        ans = max(ans,T);
    }
    cout << ans << endl;
    return 0;
}


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

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a);i>(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1000000000;
const LL MOD = 1000000007;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  string S;
  cin >> S;
  int N = SZ(S);
  bool r = false;
  VI A(N);
  int j;
  int k=0;

  REP(i,N) {
    if(S.at(i) == 'L' && r == false) {
      r = true;
      j = i;
    }
    if(r) {
      if (S.at(i) == 'R' || i==N-1) {
        if (i==N-1) i=N;
        int M = i-k;
        A.at(j-1) = M/2;
        A.at(j) = M/2;
        
        if(M%2) {
          if((j-k)%2) A.at(j-1)++;
          else A.at(j)++;
          
        }
        
        k=i;
        i--;
        r=false;
        continue;
      }
    }
  }
  
  REP(i,N-1) {
    cout << A.at(i) << " ";
  }
  cout << A.at(N-1) << endl;
  return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	
	int n,m;
	while(cin >> n >> m,n+m){
		
		vector<vector<int>> v(n);
		
		REP(i,m){
			int a,b;cin >> a >> b;
			a--;b--;
			v[a].PB(b);
			v[b].PB(a);
		}
		
		vector<int> color(n);
		
		queue<int> q;
		q.push(0);
		color[0] = 1;
		vector<int> ans(2);
		vector<int> ret;

		while(!q.empty()){
			
			int now = q.front();q.pop();
			ans[(color[now] + 1) / 2]++;
			
			REP(i,v[now].size()){
				int aite = v[now][i];
				if(color[now] == color[aite]){
					cout << 0 << endl;
					goto NXT;
				}
				if(color[aite] == 0){
					color[aite] = -color[now];
					q.push(aite);
				}
			}
		}
		
		sort(ALL(ans));
		ans.erase(unique(ALL(ans)),ans.end());
		REP(i,ans.size()){
			if(ans[i] % 2 == 0){
				ret.PB(ans[i]);
			}
		}
		
		cout << ret.size() << endl;
		REP(i,ret.size()){
			cout << ret[i] / 2 << endl;
		}
		
		NXT:;
	}
	
	return 0;
}


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

int main() {
  int n;
  cin>>n;
  int a[3*n];
  for (int i=0; i<3*n; i++) cin>>a[i];

  priority_queue<int, vector<int>, greater<int>> pq1;
  long long dp1[3*n];
  long long v1 = 0;
  for (int i=0; i<n; i++) {
    pq1.push(a[i]);
    v1 += a[i];
  }
  dp1[n-1] = v1;
  for (int i=n; i<3*n; i++) {
    if (a[i] > pq1.top()) {
      v1 = v1 - pq1.top() + a[i];
      pq1.pop();
      pq1.push(a[i]);
    }
    dp1[i] = v1;
  }
  priority_queue<int> pq2;
  long long dp2[3*n];
  long long v2 = 0;
  for (int i=3*n-1; i>=2*n; i--) {
    pq2.push(a[i]);
    v2 += a[i];
  }
  dp2[2*n] = v2;
  for (int i=2*n-1; i>=0; i--) {
    if (a[i] < pq2.top()) {
      v2 = v2 - pq2.top() + a[i];
      pq2.pop();
      pq2.push(a[i]);
    }
    dp2[i] = v2;
  }
  long long ans = -1e14;
  for (int i=n-1; i<2*n; i++) {
    if (dp1[i] - dp2[i+1] > ans) {
      ans = dp1[i] - dp2[i+1];
    }
  }
  cout<<ans<<endl;
}

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

int main(){
  int N;
  cin >>N;
  bool flag=0;
  int count=0;
  vector <int> A(N);
  for (int i=0;i<N;i++){
    cin>> A[i];
  }
  for(int i=0;i<N;i++){
    int minj=i;
    flag=0;
    for (int j=i;j<N;j++){
      if(A[j]<A[minj]){
        minj =j;
        flag=1;
      }

      }
          if(flag){
        count++;
        flag=0;
    }
    int temp=A[i];
    A[i]=A[minj];
    A[minj]=temp;
  }

  
  for (int i=0;i<N-1;i++){
    cout<<A[i]<<" ";
  }
  cout<<A[N-1]<<endl;
  cout<<count<<endl;
  return 0;
}


        



Measured memory_bytes: 3104
import java.util.*;

import java.io.*;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static long mod = 1000000007;
	static int inf = (int) 1e15;
	static ArrayList<Integer>[] adL, adH;
	static int n, q;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
        System.out.println(Math.max(0, 100*(10-sc.nextInt()))+sc.nextInt());
		out.flush();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 21204
#!/usr/bin/env python3


def main():
    N = int(input())
    if N == 0:
        print(0)
        exit()

    ans = ''
    while N != 1:
        m = N % (-2)
        ans += str(abs(m))
        N = N // (-2)
        if m != 0:
            N += 1
        # print(ans,N)
    ans += str(N)
    print(ans[::-1])

if __name__ == "__main__":
    main()


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

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

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

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

// End of template code!
int main() 
{
    buff();
    ll n, k;
    cin >> n >> k;
    ll cand1 = n % k;
    ll cand2 = k - (n % k);
    cout << min(cand1, cand2) << '\n'; 
    return 0;
}



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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD=1e9+7;
const int MAX=1e5+100;

int main() {
  // bitでの各桁ごとに2の数x0の数*2の和
  ll N;cin>>N;
  vector<bitset<62>> AS(N);
  REP(i,N) {
    ll a;cin>>a;
    bitset<62> b(a);
    AS[i]=b;
  }
  
  ll ans = 0;
  REP(i,62) {
    ll zero_cnt = 0;
    REP(j,N) {
      if (AS[j][i]==0) zero_cnt++;
    }
    ans += (zero_cnt*(N-zero_cnt)%MOD)*((1LL<<i)%MOD);
    ans %= MOD;
  }
  OUT(ans);

  return 0;
}

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

int a, b, c;
int g(int p, int q) {
	if (p % q == 0) return q;
	g(q, p % q);
}
int main()
{
	cin >> a >> b >> c;
	if (c % g(a, b) == 0) cout << "YES";
	else cout << "NO";
    return 0;
}


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

int main() {
	int n,x,y,xx,yy;
	cin >>n;
	for(int i=0;i<n;i++){
		cin >> x >> y;
		cin >> xx >> yy;
		if(xx>=5 && yy >= 2)
		cout << (xx*x+yy*y)*0.8 << endl;
		else
		cout << min((xx*x+yy*y),(int)((max(xx,5)*x+max(yy,2)*y)*0.8)) << endl;
	}
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	long long a[n];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	
	sort(a,a+n);
	
	int ans=0;
	int cnt=0;
	long long now=a[0];
	for(int i=0; i<n; i++){
		if(now==a[i]){cnt++;}
		else if(now!=a[i]){
			if(cnt<now){ans+=cnt;}else{ans+=cnt-now;}
			now=a[i];
			cnt=1;
		}
		
		if(i==n-1){
			if(cnt>a[i]){ans+=cnt-now;}
			else if(cnt < a[i]){ans+=cnt;}
		}
	//	cout << ans << endl;
	}
	
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  map<int, long> map;

  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    map[a]++;
    map[a+1]++;
    map[a-1]++;
  }

  long ans = 0;
  for(auto x : map){
    ans = max(x.second, ans);
  }

  cout << ans << endl;
}


Measured memory_bytes: 6144
object Main extends App {

  override def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    Iterator.continually(new Data(sc.nextInt, sc.nextInt))
      .takeWhile(_.continue).map(_.solve).foreach(d => println(d._1+" "+ d._2+" "+ d._3));
  }

  case class Data(a0: Int, i: Int) {
    val continue = !(a0 == 0 && i == 0)

    def solve: (Int, Int, Int) = {
      val arr = (1 to 21).scanLeft(a0)((z, n) => getNext(z)).toArray
      val map = scala.collection.mutable.Map.empty[Int, Int]
      val list = for (i <- (0 until arr.length); j <- (i + 1 until arr.length)) yield (arr(i) - arr(j), (i, arr(i), j - i))
      list.find(_._1 == 0).get._2
    }

    def getNext(seed: Int): Int = {
      val (max, min) = maxmin(seed)
      max - min
    }

    def maxmin(seed: Int): (Int, Int) = {
      val list = (1 to i-1).scanLeft(seed)((z, n) => z / 10).map(_ % 10).sorted
      val min = list.reduceLeft((z, n) => z * 10 + n)
      val max = list.reduceRight((n, z) => z * 10 + n)
      (max, min)
    }
  }
}

Measured memory_bytes: 53168
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int a, b;

int main()
{
    cin >> a >> b;
    int ans = 0;
    for(int i = a; i <= b; i++){
        string str = to_string(i);
        int n = str.length();
        bool isOk = true;
        rep(j, n / 2){
            if(str[j] != str[n - j - 1]){ isOk = false; break; }
        }
        if(isOk){ ans++; }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args)  {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);

		String str = sc.next();

		int num = 0;
		for(int i = 0; i < str.length(); i++){
			if(str.charAt(i) == '+'){
				num++;
			}
			else {
				num--;
			}
		}
		System.out.println(num);
	}

}


Measured memory_bytes: 24020
#include<stdio.h>
#define N 10000
int A[2000001],C[N],B[2000001];
int main()
{
  int i,n;

  scanf("%d",&n);
  for(i=1;i<n+1;i++){
    scanf("%d",&A[i]);
  }

  for(i=0;i<N;i++){
    C[i]=0;
  }
  for(i=1;i<n+1;i++){
    C[A[i]]+=1;
  }
  for(i=0;i<N;i++){
    C[i]+=C[i-1];
  }
  for(i=n+1;i>0;i--){
    B[C[A[i]]]=A[i];
    C[A[i]]-=1;
  }

  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d",B[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 18272
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


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

    ll N;
    cin >> N;

    if(N == 0){
        cout << 0 << endl;
        return 0;
    }

    string result;

    while(N != 0){
        ll shan , yu;
        shan = N / (-2);
        yu = shan * (-2) - N ;
        if(yu != 0){
            yu = 1;
        }

        shan = (N - yu) / (-2);

        if(yu == 0) result += "0";
        else result += "1";
        N = shan ;
    }

    for(ll i = result.size()-1; i >= 0; i--){
        cout << result[i];
    }
    cout << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main ()
{

int a[100000], max, min, i, N;

long long sum;

cin >> N;
for (i = 0;i < N;i++)
{
cin >> a[i];
}
max = a[0];
min = a[0];
sum = 0;
for(i = 0;i < N;i++)
{
	if(max < a[i])
	{
		max = a[i];
	}
	if(min > a[i])
	{
		min = a[i];
	}

	sum += a[i];
}

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

}


Measured memory_bytes: 3180
#include <cstdio>

using namespace std;

int main()
{
	int n, a, b[100001] = {}, i, max = 0, s = 0;;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a);

		if (max < a) {
			max = a;
		}
		if (a != 0) {
			b[a - 1]++;
			b[a]++;
			b[a + 1]++;
		}
		else {
			b[a]++;
			b[a + 1]++;
		}
	}

	for (i = 1; i <= max; i++) {
		if (b[s] < b[i]) {
			s = i;
		}
	}

	printf("%d\n", b[s]);

	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <limits>

using namespace std;

namespace {

static int Merge(int* A, int left, int mid, int right) {
  const int n1 = mid - left;
  const int n2 = right - mid;

  // When sorting large arrays, allocating L and R in heap for
  // each Merge call makes a bit the program slower.
  //
  // In the real application, we should use std::vectors instead of
  // fixed sized arrays, though.
  // vector<int> L(n1+1, 0);
  // vector<int> R(n2+1, 0);
  int L[n1 + 1];
  int R[n2 + 1];

  for (int i = 0; i < n1; ++i) {
    L[i] = A[left + i];
  }
  for (int i = 0; i < n2; ++i) {
    R[i] = A[mid + i];
  }

  static const int kInf = numeric_limits<int>::max();
  L[n1] = kInf;
  R[n2] = kInf;

  int i = 0;
  int j = 0;
  for (int k = left; k < right; ++k) {
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
  return right - left;
}

static int MergeSortInternal(int* A, int left, int right) {
  if (left + 1 >= right) return 0;

  const int mid = (left + right) / 2;
  return MergeSortInternal(A, left, mid) + MergeSortInternal(A, mid, right) +
         Merge(A, left, mid, right);
}

static int MergeSort(int* A, int n) { return MergeSortInternal(A, 0, n); }
}  // namespace

int main() {
  int n;
  int S[500000];
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &S[i]);
  }

  const int swapped = MergeSort(S, n);
  for (int i = 0; i < n; ++i) {
    if (i > 0) printf(" ");
    printf("%d", S[i]);
  }
  printf("\n");
  printf("%d\n", swapped);

  return 0;
}

Measured memory_bytes: 4936
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    for(int i = 0; i < N; i++){
      a[i] = sc.nextInt();
    }
    long f = 0;
    for(int i = 0; i < N; i++){
      f += a[i] - 1; //(m - 1) mod a[i] = a[i] - 1だからf(m - 1)が一番大きくなる
    }
    System.out.println(f);
  }
}


Measured memory_bytes: 25784
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct point {
	int x, y;
	bool used;
};


bool xsmaller(const point& a, const point& b)
{
	return a.x < b.x;
}

bool ygrater(const point& a, const point& b)
{
	return a.y > b.y;
}


int main(void) {
	int N;
	cin >> N;
	vector <point> red(N), blue(N);
	for (int i = 0; i < N; i++) {
		cin >> red[i].x >> red[i].y;
		red[i].used = false;
	}
	for (int i = 0; i < N; i++) {
		cin >> blue[i].x >> blue[i].y;
	}
	sort(red.begin(), red.end(), xsmaller);
	sort(blue.begin(), blue.end(), xsmaller);

	int ans = 0;
	int xpos = 0;
	for (int i = 0; i < N; i++) {
		int x = blue[i].x;
		int y = blue[i].y;
		for (; xpos < N; xpos++) {
			if (red[xpos].x < x) continue;
			else break;
		}
		sort(red.begin(), red.begin()+xpos, ygrater);
		for (int j = 0; j < xpos; j++) {
			if (red[j].used) continue;
			if (red[j].y < y) {
				ans++;
				red[j].used = true;
				break;
			}
		}
	}
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np
N=int(input())
A=list(map(int,input().split()))
cnt=[0]*(10**6+1)
for a in A:cnt[a]+=1

if np.gcd.reduce(A)!=1:
  print("not coprime")
elif np.all([sum(cnt[i::i])<=1 for i in range(2,10**6+1)]):
  print("pairwise coprime")
else:
  print("setwise coprime")


Measured memory_bytes: 150448
n,m=map(int, input().split())
a=list(map(int, input().split()))

from heapq import heappush, heappop
hq=[]

for a_val in a:
    # heappopで最も小さい値が取り出されるため、(-1)をかけて入れる
    heappush(hq, -a_val)
for _ in range(m):
    heappush(hq, -(heappop(hq)//(-2)))
print(-sum(hq))

Measured memory_bytes: 14252
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var f = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            List<int> ret = new List<int>();
            if (f[1] - f[0] <= f[2])
            {
                for (int i = f[0]; i <= f[1]; i++)
                {
                    Console.WriteLine(i);
                }
                return;
            }
            for (int i = f[0]; i < f[0] + f[2]; i++)
            {
                ret.Add(i);
            }

            for (int i = f[1] - f[2] + 1; i <= f[1]; i++)
            {
                if (!ret.Contains(i))
                {
                   ret.Add(i); 
                }
            }

            foreach (var i in ret)
            {
                Console.WriteLine(i);
            }

        }
    }
}

Measured memory_bytes: 13280
#include <bits/stdc++.h>
#pragma GCC optimize(3 , "Ofast" , "inline")
using namespace std ;
typedef long long ll ;
typedef pair<int , int> PII ;
const int N = 1e5 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;

int main()
{
  int a , b , c , d ;
  cin >> a >> b >> c >> d ;
  while(1)
   {
     c -= b ;
     if(c <= 0) return 0 * puts("Yes")  ;
     a -= d ;
     if(a <= 0) return 0 * puts("No") ;
   }
  return 0 ;
}


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

struct Box {
    int balls = 1;
    bool red = false;
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<Box> boxes(N);
    boxes.at(0).red = true;

    for (int i=0; i<M; i++) {
        int x,y;
        cin >> x >> y;
        x--, y--; // 0base

        boxes.at(x).balls--;

        boxes.at(y).balls++;
        boxes.at(y).red |= boxes.at(x).red;

        if (boxes.at(x).balls == 0) {
            boxes.at(x).red = false;
        }
    }

    int cnt = 0;
    for (int i=0; i<N; i++) {
        if (boxes.at(i).red) {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int num=1e9+7;
int main(){
    int n,k;
    cin >> n >> k;
    ll mx = 0,mn = 0;
    for(int i = 0; i < k-1; i++){
        mn += i;
        mx += n-i;
    }
    ll sum=0;
    for(int i = k-1; i < n+1; i++){
        mn += i;
        mx += n-i;
        sum += mx-mn+1;
        sum %= num;
    }
    cout << sum << endl;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int n,k;
    cin>>n>>k;
    cout<<n-k+1<<endl;
    
    
    return 0;
}


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

int main(void) {
	char str[201], tmp[101];
	char p[101];
	int slen, plen;
	int i, j, flag;
	
	scanf("%s %s", str, p);
	
	strcpy(tmp, str);
	strcat(str, tmp);
	
	slen = strlen(str);
	plen = strlen(p);
	
	flag = 0;
	for (i = 0; i < slen - plen; i++) {
		if (strncmp(&str[i], p, plen) == 0) flag = 1;
	}
	
	if (flag) puts("Yes");
	else puts("No");
	
	return 0;
}



Measured memory_bytes: 2144