akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace abc098c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var l = 0;
            var r = s.Substring(1, n - 1).Count(x => x == 'E');
            var minTurn = l + r;
            for(var i = 2; i <= n; ++i)
            {
                l += s[i - 2] == 'W' ? 1 : 0;
                r -= s[i - 1] == 'E' ? 1 : 0;
                var count = l + r;
                if (count < minTurn) minTurn = count;
            }
            Console.WriteLine(minTurn);
        }
    }
}


Measured memory_bytes: 13256
A,B = map(int,input().split())
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
scr = gcd(A, B)
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
b= prime_factorize(scr)
c = collections.Counter(b)
b_se = set(b)
b_li = list(b_se)
d = len(b_se)
print(d+1)

Measured memory_bytes: 38512
program main
  implicit none
  integer(8) i,HS,CS,N
  integer(8),allocatable :: H(:)
  read(*, *) N
  allocate(H(N))
  read(*, *) (H(i), i = 1,N)
  HS = 0
  CS = 0
  if (N == 1) then
    HS = 0
  else
    do i =1,N-2
      if (H(i) >= H(i+1)) then
        CS = CS + 1
      else
        if (CS > HS) then
          HS = CS
        end if
        CS = 0
      endif
    end do
    if (H(N-1) >= H(N)) then
      CS = CS + 1
      if (CS > HS) then
        HS = CS
      end if
    else
      if (CS > HS) then
        HS = CS
      end if
    endif
  end if

  write(*, *) HS
end program main


Measured memory_bytes: 1536
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll mod=1e9+7;

int main(){
    string s,t;
    cin >> t;
    s="ABC";
    string ans=s+t;
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,qu;
    cin>>n>>qu;
    vector<vector<int> > g(n+1);
    for(int i=0;i<n-1;i++){
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    vector<int> v(n+1,0);
    for(int i=0;i<qu;i++){
        int r,val;
        cin>>r>>val;
        v[r]+=val;
    }

    vector<bool> vis(n+1,false);
    queue<int> q;
    q.push(1);
    while(!q.empty()){
        int a=q.front();
        q.pop();
        vis[a]=true;
        for(int i=0;i<g[a].size();i++){
            if(!vis[g[a][i]])
            {
                q.push(g[a][i]);
                v[g[a][i]]+=v[a];   
            }
        }
    }

    for(int i=1;i<=n;i++){
        cout<<v[i]<<" ";
    }   
    return 0;
}

Measured memory_bytes: 15604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String N = scan.next();
		char [] date = N.toCharArray();

		if(date[0]=='9'|| date[1]=='9' ){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

}
}

Measured memory_bytes: 21584
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

struct kasu {
    double aho;
};

int main()
{
    int a, b, c, d; cin >> a >> b >> c >> d;
    int left = a + b, right = c + d;
    string ans;
    if (left == right) {
        ans = "Balanced";
    }
    else if (left > right) {
        ans = "Left";
    }
    else {
        ans = "Right";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc()) if(ch=='-') positive=0;
	for(;isdigit(ch);ch=gc()) x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(ll x){
	if(x<0){
		x=-x;putchar('-');
	}
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=4005;
int S[N],ans[N];
char s[N];
void query(int x,int y){
	printf("? %d %d\n",x,y);
	fflush(stdout);
	scanf("%s",s);
}
int main(){
	int A=read(),B=read(),n=A+B;
	if(A<=B) return puts("Impossible"),0;
	int top=0;
	For(i,1,n){
		if(!top) S[++top]=i;
		else{
			query(S[top]-1,i-1);
			if(s[0]=='Y') S[++top]=i;
			else top--;
		}
	}
	For(i,1,n){
		query(S[top]-1,i-1);
		if(s[0]=='Y') ans[i]=1;
		else ans[i]=0;
	}
	printf("! ");
	For(i,1,n){
		if(ans[i]) putchar('1');
		else putchar('0');
	}
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine();
            var dfs = new DfsMaster(int.Parse(n));

            // 2桁未満は対象外だからindex=2から開始
            for (var i = 2; i < n.Length; i++)
            {
                dfs.Keta = i + 1;
                dfs.Execute(0, "");
            }

            Console.WriteLine(dfs.Total);
        }
    }

    public class DfsMaster
    {
        public int Value { get; set; }
        public int Keta { get; set; }
        public int Total { get; set; }

        public DfsMaster(int n)
        {
            this.Value = n;
        }

        public void Execute(int x, string s)
        {
            if (x == Keta)
            {
                var hSet = new HashSet<char>();
                s.ToCharArray().Select(z => hSet.Add(z)).Count();
//                var hSet = s.ToCharArray().Select(z => int.Parse(z.ToString())).ToHashSet();
                if (Value >= int.Parse(s))
                {
                    if (hSet.Count == 3)
                        Total++;
                }
                return;
            }

            Execute(x + 1, s + 3);
            Execute(x + 1, s + 5);
            Execute(x + 1, s + 7);
        }
    }
}


Measured memory_bytes: 15556
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if(a==b && b==c){
		cout << "1" << endl;
	}else if(a==b || b==c || c==a){
		cout << "2" << endl;
	}else{
		cout << "3" << endl;
	}
}

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 ;
typedef vector<int> vint;
typedef vector<double> vdbl ;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int,int>> vpii ;
typedef vector<pair<ll,ll>> vpll ;
typedef priority_queue<int, vector<int>, greater<int>> spqint ; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll ; //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint ; //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll ; //大きい順に取り出し


#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++)
#define IREP(i,v) for(auto i=v.begin(); i !=v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(),(v).end()
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}
//-----------------------------------------




















//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c, d ;
  cin >> a >> b >> c >> d ;
  while(1){
    c -= b ;
    if(c<=0){
      yes() ;
      break ;
    }
    a -= d ;
    if(a<=0){
      no() ;
      break ;
    }
  }
  
  
  
  return 0 ;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 2019;

bool isPrime(int x){
    int i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}


int main(){
    ll Q; cin >> Q;
    vector<ll> P;
    for(int i = 2; i < 200000; i++){
        if(isPrime(i) && isPrime((i+1)/2)) P.push_back(i);
    }

    for(int i = 0; i < Q; i++){
        ll l, r; cin >> l >> r;
        auto itr = lower_bound(P.begin(), P.end(), l);
        int idx = distance(P.begin(), itr);
        ll ans = 0;
        while(P[idx] <= r){
            ans++;
            idx++;
        }
        cout << ans << endl;

    }



}


Measured memory_bytes: 640
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

string s;
string t[]{"dream", "dreamer", "erase", "eraser"};
bool dp[100010];

int main(){
  cin >> s;
  dp[0] = true;
  rep(i, s.size()) rep(j, 4){
    if (s.substr(i, t[j].size()) == t[j]){
      dp[i + t[j].size()] |= dp[i];
    }
  }
  cout << (dp[s.size()] ? "YES\n" : "NO\n");
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N, M;
    cin >> N >> M;
    vll A(M);
    ll sum = 0;
    for (size_t i = 0; i < M; i++)
    {
        cin >> A[i];
        sum += A[i];
    }
    if (sum > N)
        cout << -1;
    else
        cout << N - sum;
    return 0;
}

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

int N;

int main(int argc, const char * argv[]) {
    cin >> N;
    
    vector<int> d(N);
    for (int i = 0; i < N; i++) cin >> d[i];
    
    sort(d.begin(), d.end());
    int mid = (N / 2);
    int a = d[mid - 1];
    int b = d[mid];
    int c = b - a;
    
    cout << c << endl;
    
    return 0;
}


Measured memory_bytes: 640
// test.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#include <iostream>
#include <algorithm>
#include <vector>




using namespace std;


int main()
{
	// 整数の入力
	int N;
	cin >> N ;
	vector<int> A(N);

	vector<int> ans(N);
	for (int i = 0; i < N ; i++) {
		cin >>A.at(i);
		
	}
	for (int i = 0; i < N; i++) {
		ans.at(A.at(i) - 1) = i + 1;
	}
	
	for (int i = 0; i < N; i++) {

		cout << ans.at(i) << " ";
	}
	cout << endl;
	
	return 0;
}





// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 1664
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int ans,N,M;
vector<bool> visited;
vector<vector<bool>> edge;
void dfs(int current_node , vector<bool> visited){
  for(int i = 0; i < N; i++){
    if(visited[i] && i == N-1){
      ans ++;
      return ;
    }else if(visited[i]) continue;
    else break;
  }

  for(int i = 0; i < N; i++){
    if(visited[i]) continue;
    else if(edge[current_node][i] == false) continue;
    else if(edge[current_node][i] && visited[i] == false){
      visited[i] = true;
      dfs(i,visited);
      visited[i] = false;
    }
  }
  return ;
}

int main(){
  int a,b;
  cin >> N >> M;
  edge = vector<vector<bool>>(N,vector<bool>(N,false));
  visited = vector<bool>(N,false);
  for(int i = 0; i < M; i++){
    cin >> a >> b ;
    edge[a-1][b-1] = true;
    edge[b-1][a-1] = true;
  }
  visited[0] = true;
  dfs(0,visited);
  cout << ans << endl;
  return 0;
}


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

int main()
{
    int N;
    vector<int> X;

    cin >> N;

    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        X.push_back(a);
    }

    vector<int> Y;
    copy(X.begin(), X.end(), back_inserter(Y));
    sort(Y.begin(), Y.end());

    for (int i = 0; i < N; i++) {
        int index = (Y.size() + 1)/2;

        if(X[i] < Y[index]) {
            cout << Y[index] << endl;
        } 
        else if (X[i] >= Y[index]) {
            cout << Y[index - 1] << endl;
        } 
    }
}

Measured memory_bytes: 3828
K,N=map(int,input().split())
A=list(map(int,input().split()))

B1=K-A[N-1]+A[0]

B=[]
i=0
while i<=N-2:
    B.append(A[i+1]-A[i])
    i=i+1
B=sorted(B)
print(K-max(B1,B[-1]))

Measured memory_bytes: 26444
mark=[0 for i in range(10)]
n,k=map(int,raw_input().split())
l=map(int,raw_input().split())


def check(num):
	temp=num

	while(temp>0):
		d=temp%10
		if d in l:
			return 0
		temp=temp//10
	return 1




while True:

	if check(n)==1:
		print n
		break
	n+=1


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

using namespace std;
typedef long long ll;
const long long MAX = 1000000000000000 + 5;

int main()
{
    ll n;
    cin >> n;
    ll minv = MAX;
    for (int i = 0; i < 5; i++)
    {
        ll temp;
        cin >> temp;
        minv = min(minv, temp);
    }
    ll pack;
    if (n < minv)
    {
        pack = 1;
    }
    else
    {
        pack = (n % minv != 0) ? n / minv + 1 : n / minv;
    }
    
    ll ans = pack - 1 + 5;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  std::vector<int> data(n);
  for(int i = 0; i < n; i++){
    cin >> data.at(i);
  }
  
  bool even = true; int count = 0;
  while(even)
  {
    for(int i = 0; i < n; i++)
    {
      //cout << data.at(i) << endl;
      if( data.at(i)%2 == 0 ){
        data.at(i) = data.at(i)/2;
      }
      else{
        even = false;
        break;
      }
    }
    if(even)
      count++;//処理しきったらカウント
  }
  cout << count << endl;  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

std::vector<bool> hurui(int n){
    std::vector<bool> isprime(n,true);
    isprime[0]=false;
    isprime[1]=false;
    int p=2;
    while(p*p<n){
        for(size_t i = p+p; i < n; i+=p)
        {
            if(i%p==0)isprime[i]=false;
        }
        for(size_t i = p+1; i < n; i++)
        {
            if(isprime[i]){
                p=i;
                break;
            }
        }
    }
    return isprime;
}

int main(){
    std::vector<bool> isprime=hurui(100001);
    std::vector<int> primes(100001,0);
    for(size_t i = 3; i <= 1e5; i+=2)
    {
        if(isprime[i]&&isprime[(i+1)/2]){
            ++primes[i];
        }
    }
    for(size_t i = 1; i <= 1e5; i++)
    {
        primes[i]+=primes[i-1];
    }

    int q;
    std::cin>>q;
    for(size_t i = 0; i < q; i++)
    {
        int l,r;
        std::cin>>l>>r;
        //std::cout<<primes[r]<<" "<<primes[l]<<"\n";
        std::cout<<primes[r]-primes[l-1]<<"\n";
    }
    return 0;
}

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

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

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

	int a,b,c,d,e; cin >> a >> b >> c >> d >> e;
	int ans = 0;
	while(a != b){
		if(a < 0){
			a++; ans += c;
		}else if(a == 0){
			a++;
			ans += d+e;
		}else{
			a++;
			ans += e;
		}
	}

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 3176
#include<iostream>
using namespace std;
int dp[1001];
int main(){
	int m,a,b;
	while(true){
	cin>>m;
	if(m==0)break;
	for(int i=0;i<=1000;i++)dp[i]=0;
	dp[0]=1;
	for(int u=0;u<m;u++){
		cin>>a>>b;
		for(int i=1000;i>=0;i--){
			for(int j=1;j<=b;j++){
				if(i+j*a>1000)break;
				dp[i+j*a]+=dp[i];
			}
		}
	}
	int g,n;
	cin>>g;
	for(int u=0;u<g;u++){
		cin>>n;
		cout<<dp[n]<<endl;
	}
	}
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cmath>

int main(){
    long long l, r;
    std::cin >> l >> r;

    long long min = 2 * std::pow(10, 9);
    if(r - l + 1 < 2018){
        for(long long i = l; i < r; ++i){
            for(long long j = i + 1; j <= r; ++j){
                min = std::min(min, (i * j) % 2019);
            }
        }
    }else{
        min = 0;
    }

    std::cout << min << std::endl;

    return 0;
}

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


int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < m; i++) {
        cin >> b.at(i);
    }

    ll t = 0;
    for (int i = 0; i < m; i++) {
        t += b.at(i);
    }

    int j = m;
    int ans = 0;
    for (int i = 0; i < n + 1; i++) {
        while (j && t > k) {
            j--;
            t -= b.at(j);
        }
        if (t > k) {
            break;
        }
        ans = max(ans, i + j);
        if (i == n) {
            break;
        }
        t += a.at(i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,B,C;
  B = 0;
  cin >> N >> M;
  vector<int> vec(M);
  for (int j = 0; j < N; j++) {
    cin >> C;
  	for (int i = 0; i < C; i++) {
      	int A;
    	cin >> A;
  		vec.at(A-1) = vec.at(A-1) + 1;
		}
  }
  for (int i = 0; i < M; i++) {
   if (vec.at(i) >= N){
     B = B + 1;
  	}
  }
  cout << B << endl;
}

Measured memory_bytes: 256
a, b, c, d = list(map(int, input().split()))

def euclid(p, q):
    if p > q:
        p, q = q, p
    while q > 0:
        p, q = q, p % q
    return p

def lcm(p, q):
    return p * q // euclid(p, q)

c_a = (a-1) // c
c_b = b // c
d_a = (a-1) // d
d_b = b // d
cd_a = (a-1) // lcm(c, d)
cd_b = b // lcm(c, d)
# print(c_a, c_b, d_a, d_b, cd_a, cd_b)

print(b - a + 1 - ((c_b + d_b - cd_b) - (c_a + d_a - cd_a)))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MAXN=110000;
vector<int> adj[MAXN];
int N,U,V;
int distU[MAXN],distV[MAXN];
int maxdep[MAXN];

void dfs1(int v,int dist=0) {
	if (distU[v]!=-1) return;
	distU[v]=dist;
	for (int u:adj[v]) dfs1(u,dist+1);
}

void dfs2(int v,int dist=0) {
	distV[v]=dist;
	for (int u:adj[v]) if (distV[u]==-1) {
		dfs2(u,dist+1);
		maxdep[v]=max(maxdep[v],maxdep[u]+1);
	}
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	cin>>N>>U>>V;
	U--,V--;
	rep(i,0,N-1) {
		int x,y;
		cin>>x>>y;
		x--, y--;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	memset(distU,~0,sizeof(distU));
	dfs1(U);

	memset(distV,~0,sizeof(distV));
	dfs2(V);


	int res=-1;
	rep(p,0,N) if (distV[p]>distU[p]){
		int d1=distV[p]+maxdep[p];
		int d2=distU[p]+maxdep[p];
		res=max(res,d1-1);
		//~ cout<<p+1<<" "<<d1<<" "<<d2<<" ";
		//~ if ((d1-d2)%2==0) {
			//~ cout<<d1<<endl;
			//~ res=max(res,d1);
		//~ } else {
			//~ cout<<d1-1<<endl;
			//~ res=max(res,d1-1);
		//~ }
	}

	//~ if (distU[V]==1) {
		//~ res=max(res,0);
	//~ }
	//~ if (distU[V]==2) {
		//~ res=max(res,1);
	//~ }

	assert(res!=-1);

	cout<<res<<'\n';

	//~ rep(i,0,N) cout << distU[i] << " ";
	//~ cout << endl;
	//~ cout << endl;

	//~ rep(i,0,N) cout << distV[i] << " ";
	//~ cout << endl;

	//~ rep(i,0,N) cout << maxdep[i] << " ";
	//~ cout << endl;
}


Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n;
	cin >> n;
	while(n--){
		int d[10];
		int dp[10]={1,1,1,1,1,1,1,1,1,1},m[10]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
		rep(i,10) cin >> d[i];
		rep(i,10) rep(j,i) if(d[j] < d[i]) if(dp[i] <= dp[j]){ dp[i] = dp[j]+1 , m[i] = j;}
		int p = find( dp , dp+10 , *max_element( dp , dp+10 ) ) - dp;
		while(~p){ d[p] = -1; p = m[p];}
		bool ans = true; int prev = -1;
		rep(i,10) if(~d[i]){
			if(d[i] > prev) prev = d[i];
			else ans = false;
		}
		cout << (ans ? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

class BipartiteMatching {
    int n, n0;
    int mode;
    vvi adj;
    vi mc;
    vi used;

    bool dfs(int v) {
        used[v] = true;
        for (int i = 0; i < adj[v].size(); i++) {
            int u = adj[v][i];
            int w = mc[u];
            if (w < 0 || (!used[w] && dfs(w))) {
                mc[v] = u;
                mc[u] = v;
                return true;
            }
        }
        return false;
    }
public:
    BipartiteMatching(int n) : n(n), adj(n), mc(n, -1) {
        mode = 0;
    }
    BipartiteMatching(int n, int m) : n(n + m), n0(n), adj(n + m), mc(n + m, -1) {
        mode = 1;
    }

    void addEdge(int u, int v) {
        if (mode == 0) {
            adj[u].push_back(v);
            adj[v].push_back(u);
        } else {
            adj[u].push_back(n0 + v);
            adj[n0 + v].push_back(u);
        }
    }

    int match() {
        int ret = 0;
        for (int v = 0; v < n; v++) {
            if (mc[v] < 0) {
                used = vi(n);
                if (dfs(v)) {
                    ret++;
                }
            }
        }
        return ret;
    }

    int operator[](int k) {
        return mc[k];
    }
};

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

    while (1) {
        int n, m;
        cin >> n >> m;
        if (n == 0) break;
        vector<int> as(n), bs(m);
        for (int i = 0; i < n; i++) cin >> as[i];
        for (int i = 0; i < m; i++) cin >> bs[i];
        BipartiteMatching match(n, m);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (__gcd(as[i], bs[j]) > 1) match.addEdge(i, j);
            }
        }
        cout << match.match() << '\n';
    }
}


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

namespace abc118c
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var As = ReadIntList();
            var flg = true;
            while (As.Count()>1)
            {
                var min = As.Min();
                As = As.Select(x => (x!=min) ? x % min : x).Where(x=>x>0).Distinct().ToList();
                
            }

            Console.WriteLine(As[0]);
#if DEBUG
            Console.ReadKey();
#endif
        }

        private static bool IsRange(int a, int from, int to) => (from <= a && a <= to);
        private static int ReadInt() => int.Parse(Console.ReadLine());
        private static List<int> ReadIntList() => Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToList();
        private static List<int> Int2Digits(int a) => a.ToString().ToCharArray().Select(_ => int.Parse(_.ToString())).ToList();
    }
}


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

using namespace std;

int a, b, c, d;

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

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair

using namespace std;

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

const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    priority_queue<int, vector<int>, greater<int> > pq;
    rep(i, n) {
        int v;
        cin >> v;
        pq.push(v);
    }

    double tmp = pq.top(); pq.pop();
    while(!pq.empty()) {
        int v = pq.top(); pq.pop();
        tmp = (tmp + v) / 2.0;
    }

    printf("%.7f\n", tmp);

    return 0;
}


Measured memory_bytes: 256
n = int(input())
list_a = list(map(int, input().split()))
list_b = list(map(int, input().split()))
list_a_memo = []
list_b_memo = []
for i in range(n):
    if list_a[i] == list_b[i]:
        list_a_memo.append(0)
        list_b_memo.append(0)
    elif list_a[i] > list_b[i]:
        list_a_memo.append(0)
        list_b_memo.append(list_a[i] - list_b[i])
    else:
        list_a_memo.append((list_b[i] - list_a[i]) // 2)
sum_a = sum(list_a_memo)
sum_b = sum(list_b_memo)
if sum_a >= sum_b:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 4724
import math
N=int(input())
array = [0]*N
for i in range(N):
    array[i]=int(input())
array=sorted(array)
max=array[N-1]+1
bucket=[0]*(max+1)
for val in array:
    bucket[val]=bucket[val]+1
s=0
for i in range(max+1):
    if bucket[i]>0:
        s=s+1
print(s)


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x.begin(),x.end())

signed main(){
	ll n;
  	cin>>n;
	ll luca[90]={0};
	luca[0]=2;
	luca[1]=1;
	for(int i=2;i<=n;i++){
		luca[i]=luca[i-2]+luca[i-1];
	}
	cout<<luca[n]<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")

#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <set>           
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <deque>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <time.h>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define trie trie228
#define int long long
#define double long double
#define left left228
#define right right228
#define hash hash228
#define x1 x1228
#define y1 y1228
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pii;
mt19937 rnd(time(0));

const int maxn = 3e5 + 7, mod = 1e9 + 7, inf = 1e18;
const double eps = 1e-9, pi = acos(-1);
int n, k; 
int cnt[maxn];
        
void solve() {
    cin >> n >> k; 
    for (int i = 0; i < n; ++i) cin >> cnt[i]; 
    int id = -1; 
    for (int i = 0; i < n; ++i) {
        if (cnt[i] >= 0) {
            id = i; 
            break;
        }
    }
    
    if (id == -1) {
        cout << abs(cnt[n - k]);
        return; 
    }
    int ans = inf; 
    for (int i = id; i < n; ++i) {
        int p = i - id + 1; 
        if (p > k) continue;

        if (p == k) {
            ans = min(ans, cnt[i]);
            continue; 
        }
        p = k - p; 
        int l1 = id - p; 
        if (l1 < 0) continue; 
        ans = min(ans, cnt[i] + cnt[i] + abs(cnt[l1])); 
    }
                      
    --id; 
    for (int i = id; i >= 0; --i) {       
        int p = id - i + 1; 
        if (p > k) continue;
        if (p == k) {
            ans = min(ans, abs(cnt[i]));
            continue; 
        }
        p = k - p; 
        int l1 = id + p; 
        if (l1 >= n) continue; 
        ans = min(ans, abs(cnt[i]) + abs(cnt[i]) + abs(cnt[l1])); 
    }

    cout << ans; 
}                                                                                                           

signed main() {
//  freopen("", "r", stdin);
//  freopen("", "w", stdout);
#ifdef offline_judge
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#endif
    srand(time(0));
    cout.precision(10);
    cout << fixed;
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
} 



Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

/*
   AtCoder contest code
   coder : yoichidon
 */
import java.util.*;
import java.io.*;

public class Main {
    public static long sum(long[] array){
        long ans = 0;
        for(long e:array) ans+=e;
        return ans;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        long[] B = new long[N];
        for(int n=0;n<N;n++) A[n]=sc.nextLong();
        for(int n=0;n<N;n++) B[n]=sc.nextLong();

        if(sum(A)<sum(B)){
            System.out.println("-1");
            return;
        }
        int notEnoughStudy = 0;
        long extraStudy = 0;
        PriorityQueue<Long> margin = new PriorityQueue<>();
        for(int n=0; n<N; n++){
            if(A[n]<B[n]){
                notEnoughStudy++;
                extraStudy += (B[n]-A[n]);
            }else{
                margin.add(B[n]-A[n]);
            }
        }
        int decrease = 0;
        while(extraStudy>0){
            extraStudy += margin.poll();
            decrease++;
        }
        System.out.println(notEnoughStudy+decrease);


    }
}


Measured memory_bytes: 90632
N, T = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(N)]
l = list(sorted(C, key=lambda x: x[1]))
n = 0
for i in l:
  if i[1] > T:
    break
  else:
    n += 1
if n == 0:
  print('TLE')
else:
  print(min(l[0:n])[0])

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#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--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 22;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

ll modpow(ll a, ll b) {
  ll ans = 1;
  REP(i, b) {
    ans = (ans * a) % MOD;
  }
  return ans;
}

vi dp(12, 0);

int main () {
  cin.tie(0);
  cout << setprecision(10);

  ll h, w, k; cin >> h >> w >> k;

  vvll dp(h+1);
  REP(i, h+1) {
    dp[i].resize(w+2, 0);
  }

  dp[h][k] = 1;

  map<int, int> f;
  REP(i, w) {
    if(i == 0 || i == 1) f[i] = 1;
    else f[i] = f[i-1] + f[i-2];
  }

  RFOR(i, h, 1) {
    FOR(j, 1, w+1) {
      dp[i-1][j-1] = (dp[i-1][j-1] + dp[i][j] * max(1, f[j-2]) % MOD * max(1, f[w-j]) % MOD ) % MOD;
      dp[i-1][j] = (dp[i-1][j] + dp[i][j] * max(1, f[j-1]) % MOD * max(1, f[w-j]) % MOD) % MOD;
      dp[i-1][j+1] = (dp[i-1][j+1] + dp[i][j] * max(1, f[j-1]) % MOD * max(1, f[w-j-1]) % MOD) % MOD;

    }

  }

  // REP(i, h+1) {
  //   printv(dp[i]);
  // }

  cout << dp[0][1] << endl;
  
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def main():
    n = int(sys.stdin.readline().rstrip())
    if n < 105:
        print(0)
    else:
        z = [(i, 1) for i in range(107,n+1, 2)]
        for i in range(3, n+1, 2):
            z = list(map(lambda x: (x[0], x[1]+1) if x[0]%i==0 else x, z))
        c = len(list(filter(lambda x: x[1]==8, z)))
        print(c+1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    long long n, m;
    std::cin>>n>>m;

    long long res;
    if(n == 1 && m == 1){
        res = 1;
    }else if(n == 1 && m != 1){
        res = m - 2;
    }else if(n != 1 && m == 1){
        res = n - 2;
    }else{
        res = (n - 2) * (m - 2);
    }
    std::cout<<res<<std::endl;
    return 0;
}

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

const int MAX = 10000000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
int main() {
    COMinit();
    ll x,y;
    cin>>x>>y;
    ll a=(2*y-x)/3;
    ll b=(2*x-y)/3;
    
    ll ans=COM(a+b,a);

    if((x+y)%3==0&&(x+y)%3==0&&x>0&&y>0)  cout<<ans<<endl;
    else cout<<0<<endl;
    
 return 0;
}

Measured memory_bytes: 234624
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  long long int a,b,c,d=0,f,g,h;
  cin>>a>>b>>c;
  int e[a];
  rep(i,a)e[i]=0;
  b--;
  c--;
  for(int i=0;i<a-1;i++){
    for(int o=i+1;o<a;o++){
      f=o-i;
      g=fabs(b-i)+1+fabs(c-o);
      h=fabs(c-i)+1+fabs(b-o);
		d=min(f,min(g,h));
      e[d-1]++;
    }
  }
  rep(i,a-1)cout<<e[i]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t;
    cin>>t;
    map<string,long long int>m;
    while(t--)
    {
        string s;
        cin>>s;
        m[s]++;
    }
    cout<<"AC x"<<" "<<m["AC"]<<endl;
    cout<<"WA x"<<" "<<m["WA"]<<endl;
    cout<<"TLE x"<<" "<<m["TLE"]<<endl;
    cout<<"RE x"<<" "<<m["RE"]<<endl;


}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(auto& x : a)
        cin >> x;
    int sum = 0;
    for(int i = 0; i < n; ++i){
        sum += min(a[i], abs(a[i] - k)) * 2;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
/*  ex2_3
    potter0723sw  */

#include <stdio.h>

int main() {
    int N,A,answer;
    scanf("%d", &N);
    scanf("%d", &A);
    answer = N*N - A;//全体のマス数-白のマス数
    printf("%d\n", answer);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define PI 3.1415926535
 
 
int main()
 {
	int a,b,h,m;
	double answer,deg,adeg,bdeg,rad;
	
	scanf("%d%d%d%d",&a,&b,&h,&m);

	adeg=30*h+m*0.5;
	
	bdeg=6*m;

	deg=adeg-bdeg;

	if(deg<0)
	{
		deg=-deg;
	}

	if(deg>180)
	{
		deg=360-deg;
	}
	rad=deg*(PI/180);
	
	answer=sqrt(a*a+b*b-2*a*b*cos(rad));

	printf("%.10lf",answer);

			return 0;
	}


	







Measured memory_bytes: 2616
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace ABC119C_2
{
    class Program
    {
        List<int> bamboos = new List<int>();
        List<int> targets = new List<int>();

        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().Solve();
        }

        void Solve()
        {
            var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var numBamboos = temp[0];
            targets.Add(temp[1]);
            targets.Add(temp[2]);
            targets.Add(temp[3]);

            for (int i = 0; i < numBamboos; i++)
            {
                bamboos.Add(int.Parse(Console.ReadLine()));
            }

            Console.WriteLine(Calculate(0, new List<int> { 0, 0, 0 }, 0));
        }

        // index: これから使用する竹の番号
        // sizes: 現在の門松の大きさ
        // consumed: ここまでに消費したMP
        int Calculate(int index, List<int> sizes, int consumed)
        {
            if (index == bamboos.Count)
            {
                // 竹を使い切った
                if (sizes.Min() == 0)
                {
                    // 何もない部分に延長魔法は使えない
                    return int.MaxValue;
                }

                // 延長魔法・短縮魔法で竹の大きさを調節する
                for (int i = 0; i < sizes.Count; i++)
                {
                    consumed += Math.Abs(targets[i] - sizes[i]);
                }

                return consumed;
            }

            var bamboo = bamboos[index];
            var min = int.MaxValue;

            for (int i = 0; i < sizes.Count; i++)
            {
                // 竹をいずれかの部分に合成して次へ進む
                var synthesized = sizes[i] == 0 ? 0 : 10; // 最初の1本は選ぶだけ。2本目からはMPを10消費する
                var nextSizes = new List<int>(sizes);
                nextSizes[i] += bamboo;
                min = Math.Min(min, Calculate(index + 1, nextSizes, consumed + synthesized));
            }

            // この竹を使わない
            min = Math.Min(min, Calculate(index + 1, sizes, consumed));
            return min;
        }
    }
}


Measured memory_bytes: 17356
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
int N;
int A[100003];
int M[100003];

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

  cin >> N;
  ll sm=0;
  ll sm2=0;
  int a;
  rep(i, N){
    cin >> a;
    A[i] = a;
    sm += a; 
    if (i%2==0) sm2 +=a;
  }

  M[0] = 2*sm2 - sm;
  
  for(int i=1; i<N; ++i){
    ll c = A[i-1] - M[i-1]/2;
    M[i] = c*2; 
  }

  rep(i, N){
    if (i==N-1){
      cout << M[i] << endl;
      break;
    }
    cout << M[i] << " ";
  } 
  return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    string s; cin >> s;
    int n = (int)s.size();
    bool flag = true;
    for(int i=0;i<n/2;i++){
        if(s[i] != s[n/2 - i - 1]) flag = false;
    }
    for(int i=0;i<n/2;i++){
        if(s[i + n/2 + 1] != s[n - i -1]) flag = false;
    }
    for(int i=0;i<n;i++){
        if(s[i] != s[n - i - 1]) flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import combinations
N, X, Y = map(int, input().split())
N_lst = [i for i in range(1, N + 1)]
michi = combinations(N_lst, r = 2)
dis = [0 for _ in range(N + 1)]
for i,j in michi:
    seiki = j - i
    betsu = abs(j-Y) + 1 + abs(X-i)
    if seiki <= betsu:
        dis[seiki] += 1
    else:
        dis[betsu] += 1
for h in range(1, N):
    print(dis[h])

Measured memory_bytes: 74768
#include <iostream>
#include <cstdlib> // abs() for integer
#include <cmath>   // abs() for float, and fabs()
#include <climits>
using namespace std;
int main()
{
    // 整数の入力
    int N;
    cin >> N;

    int frames[N];

    for (int num = 0; num < N; num++)
    {
        cin >> frames[num];
        // cout << frames[num] << "\n";
    }

    double ave = 0;

    for (int num = 0; num < N; num++)
    {
        ave += frames[num];
    }

    ave = ave / N;

    //cout << "\n" << ave  << "ave \n";

    double ans = __DBL_MAX__;
    int ans_no = 0;

    for (int num = --N; 0 <= num; num--)
    {
        //cout << num << "\n" << frames[num] <<" num \n";
        if (abs(ave - frames[num]) <= ans) {
            ans = abs(ave - frames[num]);
            ans_no = num;
            //cout << ans << "kosin\n";
        }
    }

    cout << ans_no;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive.lib
{

    internal class Solution
    {
        public long[] X;
        public int K;

        public void Run()
        {
            X = Input.ReadIntArray().Select(e => (long) e).ToArray();
            K = Input.ReadInt();
            Array.Sort(X);

            for (int i = 0; i < K; i++)
            {
                X[2] *= 2;
            }

            long ret = X.Sum();
            Console.WriteLine(ret);
        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

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

//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back


const int N = 2e5 + 51 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

//gp_hash_table<int, int> table;

int dp[3001][3001];

signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s, t;
    int n, m;
    cin >> s >> t;
    n = s.size(), m = t.size();
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            char c = s[i - 1], c1 = t[j - 1];
            dp[i][j] = max({dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1] + (c == c1)});
        }
    }
    int i = n, j = m;
    string ans;
    if (dp[i][j] == 0) return 0;
    while (i > 0 && j > 0) {
        if (dp[i - 1][j] == dp[i][j]) i--;
        else if (dp[i][j - 1] == dp[i][j])j--;
            else
                if (dp[i - 1][j - 1] + 1 == dp[i][j]) {
                    ans+= s[i - 1];
                    i--;
                    j--;
                    continue;
                }
    }
    if (dp[n][m] != ans.size()) while (true);
    reverse(ans.begin(), ans.end());
    cout << ans;
}


Measured memory_bytes: 70656
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

n = int(input())
jobs = []

for i in range(n):
    a,b = map(int,input().split())
    jobs.append([a,b])

jobs.sort(key=lambda x:x[1])
# print(jobs)

flag = False
now_limit = 0
past = 0
for i in range(n):
    now_limit = jobs[i][1]
    past += jobs[i][0]
    if past > now_limit:
        flag = True
        break

if flag:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 38056
import java.util.*;
public class Main{
	public static void main(String [] args){
    	Scanner scan = new Scanner(System.in);
      	int x = scan.nextInt();
 		int [] arr = new int[(int)1e5+10];
      	int size = arr.length;
      arr[1]=1;
      arr[2]=1;
      arr[3]=1;
      	for(int i=4;i<size;i++){
          boolean isPrime=true;
        	for(int j=2;j<=Math.sqrt(i);j++){
            	if(i%j==0){
                  isPrime=false;
                  break;
                }
            }
          if(isPrime){
          arr[i]=1;
          }
        }
      	for(int i = x;i<size;i++){
        	if(arr[i]==1){
            System.out.println(i);
              break;
            }
        }
      	
    }
}


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

string S;
int cn = 0;

int main(){
  cin >> S;
  int L = S.size();

  for(int i = 0; i < L / 2; i++){
    if(S[i] != S[L - 1 - i]) cn++;
  }

  cout << cn << endl;
  return 0;
    
}

Measured memory_bytes: 256