akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.List;
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 = sc.nextInt();
		int b = sc.nextInt();
		
		sc.close();
		
		int ct = 0;
		for (int i=1 ; i<=n ;i++) {
			int h = Calc(i);
			if (h >= a && h <= b) {
				ct += i;
			}
		}	
		
		System.out.println(ct);

	}
	
	
	public static int Calc(int k) {
		int total = 0;
		String s = String.valueOf(k);
		List<Character> l = new ArrayList<>();
		for (int i=0 ; i< s.length();i++) {
			l.add(s.charAt(i));
		}
		for (int i=0 ; i< l.size();i++) {
			total += Character.getNumericValue(l.get(i));
		}
		
		return total;
	}

}


Measured memory_bytes: 24704
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto A = N.iota.map!(_ => readln.split.map!(to!long).array).array;

    auto dp = new long[][](N+1, 3);

    foreach (i; 0..N) {
        foreach (j; 0..3) {
            foreach (k; 0..3) {
                if (j == k) continue;
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + A[i][k]);
            }
        }
    }

    dp[N].reduce!max.writeln;
}


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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
    int n, t; cin >> n >> t;
    vector<int> a(n);
    for(int i = 0; i < n; ++i){cin >> a[i];}
    
    int profit = 0, ans = 1;
    int right = 0;
    for (int left = 0; left < n; ) {
    	int tmp = -1;
        while (right < n && (right == left || a[right] > a[left])) {
            ++right;
            tmp = max(tmp, a[right]-a[left]);
        }
        if(tmp > profit){
        	profit = tmp;
        }
        else if(tmp ==profit ){++ans;}
        else{
        }
        left =right;
        
    }
   
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
s = input()
K = int(input())

ans = []
for i in range(len(s)):
    if K >= ord('z')-ord(s[i])+1 and s[i] != 'a':
        K -= ord('z')-ord(s[i])+1
        ans.append('a')
    else:
        ans.append(s[i])

if K >= 1:
    ans[-1] = chr(ord(ans[-1])+K % 26)

print(''.join(ans))


Measured memory_bytes: 46448
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            var ls = new List<int>();
            for (int i = 0; i < n; i++)
            {
                ls.Add(int.Parse(ReadLine()));

            }

            int goIndex = 0;
            long ans = 0;
            var endIndex = 1;
            for (int i = 0; i < n; i++)
            {
                if (goIndex == endIndex)
                {
                    WriteLine(ans);return;
                }
                ans++;
                goIndex = ls[goIndex] - 1;
            }
            WriteLine(-1);
        }
    }
}

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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;

  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - (x + y);
      if (z >= 0 && z <= k) ans++;
    }
  }

  cout << ans << '\n';
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(i % 2) continue;
        cout << s[i];
    }
    cout << endl;
}


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

struct Node{
    vector<int> edges_to;
    vector<int> edges_cost;
    int from;
    bool done;
    int cost;
};

int N, M;
vector<int> a, b, c;
vector<Node> nodes;
set< pair<int, int> > st;

void dijkstra(int start, int end)
{
    for (int i = 1; i <= N; i++) {
        nodes[i].done = false;
        nodes[i].cost = -1;
    }
    nodes[start].cost = 0;
    while (1) {
        int doneIndex = -1;
        for (int i = 1; i <= N; i++) {
            if (nodes[i].done || nodes[i].cost < 0) continue;
            else if (doneIndex == -1) {
                doneIndex = i;
            } else if(nodes[i].cost < nodes[doneIndex].cost) {
                doneIndex = i;
            }
        }
        if (doneIndex == -1) break;

        nodes[doneIndex].done = true;
        for (int i = 0; i < nodes[doneIndex].edges_to.size(); i++) {
            int to = nodes[doneIndex].edges_to[i];
            int cost = nodes[doneIndex].cost + nodes[doneIndex].edges_cost[i];
            if (nodes[to].cost < 0 || cost < nodes[to].cost) {
                nodes[to].cost = cost;
                nodes[to].from = doneIndex;
            }
        }
    }
    int x, y;
    x = end;
    while (1) {
        y = nodes[x].from;
        int a = x, b = y;
        if (a > b) swap(a, b);
        st.insert(make_pair(a, b));
        x = y;
        if (x == start) break;
    }
}

int main()
{
    scanf("%d%d", &N, &M);
    a.resize(M + 1);
    b.resize(M + 1);
    c.resize(M + 1);
    nodes.resize(N + 1);
    for (int i = 1; i <= M; i++) {
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
        nodes[a[i]].edges_to.push_back(b[i]);
        nodes[a[i]].edges_cost.push_back(c[i]);
        nodes[b[i]].edges_to.push_back(a[i]);
        nodes[b[i]].edges_cost.push_back(c[i]);
    }
    for (int i = 1; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            dijkstra(i, j);
        }
    }
    printf("%d\n", M - (int)st.size());
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	int n;
	string s;
	cin>>n>>s;
	
	int ans=1;
	for(int i=1;i<n;++i){
		if(s[i-1]==s[i]){}
		else ans++;
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 512
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();

        long ans = f(A-1) ^ f(B);

        System.out.println(ans);
    }

    static long f(long ln){

        long val =0;
        for (int i = 1; i < 50; i++) {

            long cycle = 1L << i;

            long count = 0;
            count = ((ln +1 )/ cycle) * cycle/2;
            count +=Math.max(0,((ln +1) % cycle) - cycle/2);
            if(count%2 == 1){
                val += 1L <<(i-1);
            }
        }
        return val;
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;

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

void solve() {
    int n;
    cin >> n;
    map<int, int> y;
    VI ps;
    REP(i,2,100) {
        bool b = true;
        for (int j = 2; j * j <= i; ++j) if (i % j == 0) {
            b = false;
            break;
        }
        if (b) ps.push_back(i);
    }
    REP(i,2,n+1) {
        EACH(p, ps) {
            int cnt = 1;
            while (i % (int)(pow(p,cnt++)) == 0) y[p]++;
        }
    }
    map<int,int> cs;
    for (auto it = y.begin(); it != y.end(); ++it) {
        //cout << it->first << "," << it->second << endl;
        if (it->second >= 2) ++cs[2];
        if (it->second >= 4) ++cs[4];
        if (it->second >= 14) ++cs[14];
        if (it->second >= 24) ++cs[24];
        if (it->second >= 74) ++cs[74];
    }
    for (auto it = cs.begin(); it != cs.end(); ++it) {
        //cout << it->first << "," << it->second << endl;
    }
    int sum = 0;
    sum += cs[74];
    sum += cs[24] * (cs[2] - 1);
    sum += cs[14] * (cs[4] - 1);
    sum += cs[4] * (cs[4] - 1) / 2 * (cs[2] - 2);
    cout << sum << endl;
}

int main() {
    solve();
    
    return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    cout << int(a / b) << " " << a % b << " ";
    cout << fixed;
    cout << setprecision(10) << double(a) / double(b) << endl;
}



Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << ": " << x << '\n';

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, n, cnt = 0;
  cin >> a >> b;
  n = __gcd(a, b);
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      cnt++;
    
      while(n % i == 0) {
        n /= i;
      }  
    }
  }
  if (n != 1) {
    cnt++;
  }
  cout << cnt + 1 << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int  N = 2e5+7;
int n;
vector<int> h(N,0);
vector<int> val(N,0);
vector<ll>tree(4*N,0);

ll query(int tree_l,int tree_r,int treeix,int q_l,int q_r)
{
  //cout<<"tree_range : "<<tree_l<<":"<<tree_r<<endl;
  if(q_l<=tree_l && q_r>=tree_r)
  {
    return tree[treeix];
  }
  else if(q_l>tree_r || q_r<tree_l)
  {
    return 0;
  }
  int m = (tree_l + tree_r)/2;
  ll left = query(tree_l,m,2*treeix,q_l,q_r);
  ll right = query(m+1,tree_r,2*treeix+1,q_l,q_r);
  return max(left,right);
  //cout<<"timestamp : "<<left.timestamp<<" "<<right.timestamp<<endl;
  //cout<<"for range "<<tree_l<<" "<<tree_r<<" : "<<ans.data<<endl;
  //ans.timestamp = max(left.timestamp,right.timestamp);
}

void update(int tree_l,int tree_r,int treeix,int valix,ll value)
{
  //cout<<"tree_range : "<<tree_l<<":"<<tree_r<<endl;
  if(tree_l == tree_r)
  {
    tree[treeix] = max(tree[treeix],value);
    return;
  }
  int m = (tree_l + tree_r)/2;
  if(m<valix)
  {
    update(m+1,tree_r,2*treeix+1,valix,value);
  }
  else
  {
    update(tree_l,m,2*treeix,valix,value);
  }
  ll l = tree[2*treeix];
  ll r = tree[2*treeix+1];
  tree[treeix] = max(l,r);
}


int main()
{
  cin>>n;
  for(int i=1;i<=n;i++) cin>>h[i];
  for(int i=1;i<=n;i++) cin>>val[i];
  vector<ll> sol(n+1);
  ll ans = 0;
  for(int i=1;i<=n;i++)
  {
    sol[i] = val[i] + query(1,N,1,0,h[i]-1);
    ans = max(ans,sol[i]);
    update(1,N,1,h[i],sol[i]);
  }
  cout<<ans<<endl;
  return 0;
}


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

namespace ConsoleApp11
{
    class Class25
    {
        static void Main()
        {
            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            List<long> R = new List<long>();
            for (long i = A[0]; i < A[0] + A[2]&i<=A[1]; i++)
                R.Add(i);
            for (long i = A[1] - A[2] + 1; i <= A[1]; i++)
                if(i>=A[0])
                R.Add(i);
            foreach (int i in R.Distinct())
                Console.WriteLine(i);
        }
    }
}


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

const double PI = acos(-1);

int main()
{
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double th = double(60*h+m)/720 * 2 *PI;
    double tm = double(m)/60 * 2*PI;
    double ac = a*cos(th);
    double as = a*sin(th);
    double bc = b*cos(tm);
    double bs = b*sin(tm);
    double ans = (ac-bc)*(ac-bc) + (as-bs)*(as-bs);
    printf("%.20f\n", sqrt(ans));
    return 0;
}

Measured memory_bytes: 4080
#include<iostream>
#include<algorithm>
#define rep(i,x,n) for(int i=x;i<n;i++)
#define per(i,x,n) for(int i=n-1;i>=x;i--)
using namespace std;
#define ll long long
//head
ll n, L ,need;
ll l, r, mid;
struct Bottle {
    ll up, down, val;
    bool operator < (const Bottle a)const {
        return val > a.val;
    }
} a[100005];
ll b[100005], c[100005], sum[100005];
int main()
{
     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     cin>>n>>L;
     rep(i,1,n+1)cin>>a[i].up>>a[i].down,a[i].val = a[i].up - a[i].down;
     rep(i,1,n+1)cin>>b[i],c[i]=c[i-1]+b[i];         //c[i]保存b的前缀和
     sort(a+1,a+n+1);
     rep(i,1,n+1)sum[i]=sum[i-1]+a[i].val;               //sum[i]保存a的前缀和
    ll day = 1;for(int i=1;a[i].val>0&&i<=n;i++,day++);    //找到可能的答案范围
     ll ans=999999999;        //保存答案
     rep(k,1,n+1)
     {
         l=1,r=day;
         need=L-a[k].up;
         while(l<r)
         {
             ll mid=(l+r)>>1;
             if(mid==1)l=mid+1;
             else if((mid-1)>=k&&sum[mid]-a[k].val<=c[mid-1])r=mid;
             else if((mid-1)<k&&sum[mid-1]<=c[mid-1])r=mid;
              else l=mid+1;
         }      //求出k作为最后一瓶饮料使用时最少需要多少天被追上，复杂度为logr
         l=1;
         while(((r-1)>=k&&sum[r]-a[k].val<=c[r-1])||((r-1)<k&&sum[r-1]<=c[r-1]))
         r--;     //判断第r天前是否被追上
         ll vis=0;
        while(l<r)
        {
            ll mid=(l+r)>>1;
            if((mid-1)>=k&&sum[mid]-a[k].val>=need){r=mid;vis=mid;}
             else if((mid-1)<k&&sum[mid-1]>=need){r=mid;vis=mid;}
              else l=mid+1;
        }     //求出最少所用天数复杂度为logr
        if(((l-1)>=k&&sum[l]-a[k].val>=need)||((l-1)<k&&sum[l-1]>=need))
        ans=min(l,ans);
        else if(vis)
        ans=min(vis,ans);
     }
     if(ans==999999999)cout<<-1<<endl;
     else cout<<ans<<endl;
     return 0;
}



Measured memory_bytes: 7916
#include <iostream>
using namespace std;
int n,l,r,ans,i,i2;
bool u[100001];
int main()
{
	cin>>n;
	for (i=0;i<n;i++)
	{
		cin>>l>>r;
		for(i2=l;i2<=r;i2++)
		if(!u[i2])u[i2]=1,ans++;
	}
	cout << ans<<"\n";
}

Measured memory_bytes: 384
#include <stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int data[n], max,min;
  long int ans;
  scanf("%d",&data[0]);
  max = min = ans =data[0];
  for(int i = 1; i < n; i++){
    scanf("%d",&data[i]);
    ans +=data[i];
    if(max < data[i])max = data[i];
    if(min > data[i])min = data[i];
  }
  printf("%d %d %ld\n",min,max,ans);
  return 0;
}

Measured memory_bytes: 1848
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] highs = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            highs[i] = sc.nextInt();
        }
        int[] leastCostAt = new int[n + 1];
        leastCostAt[1] = 0;
        leastCostAt[2] = Math.abs(highs[2] - highs[1]);
        for (int i = 3; i <= n; i++) {
            int planACost = leastCostAt[i - 1] + Math.abs(highs[i] - highs[i - 1]);
            int planBCost = leastCostAt[i - 2] + Math.abs(highs[i] - highs[i - 2]);
            if (planACost < planBCost) {
                leastCostAt[i] = planACost;
            } else {
                leastCostAt[i] = planBCost;
            }
        }
        System.out.println(leastCostAt[n]);
    }
}


Measured memory_bytes: 48300
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		sc.close();

		int ans = 0;
		long now = 100;
		while (now < x) {
			now = (long) (now * 1.01);
			ans++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35756
x = int(input())


def prime(n):
    flag = ''
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            break
    else:
        flag = 'prime_number'

    return(flag)


if x == 2:
    print(2)
else:
    i = x + int(x % 2 == 0)

    while(prime(i) != 'prime_number'):
        i += 1

    print(i)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

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

int main(){
    int a,b,c;
    cin >> a>>b>>c;
    if((a==b&&b!=c)||(a==c&&a!=b)||(a!=b&&b==c)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}



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

int n, k;
vector<char> h;

int is_ok(int a) {
	stringstream ss;
	string s;
	vector<char> v;
	int len;

	ss << a;
	s = ss.str();
	len = s.length();
	v.resize(len);
	for (int i = 0; i < len; ++i)
		v[i] = s[i];
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	vector<char> w;
	set_intersection(h.begin(), h.end(), v.begin(), v.end(), back_inserter(w));

	return w.size();
}

int main(void) {
	cin >> n >> k;
	h.resize(k);
	for (int i = 0; i < k; ++i)
		cin >> h[i];

	int ans = 0;
	for (int i = n; i <= n * 10; ++i) {
		if (is_ok(i) == 0) {
			ans = i;
			break;
		}
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, q;cin>>n>>q;
	int arr[] = {-1, -1, -1};
	bool pos = true;
	for(int i = 0; i < q; ++i){
		int x, y;cin>>x>>y;--x;
		if(x==0){
			if(y==0 && n > 1) pos = 0;
		}
		if(arr[x]==y  || arr[x]==-1){
			arr[x] = y;
		} else{
			pos = 0;
		}
	}
	if(!pos){
		cout<<-1<<endl;
	} else if(n==1){
		cout<<max(0, arr[0])<<endl;
	}else{
		int ans = 0;
		for(int i = 0; i < n; ++i){
			if(arr[i]==-1) arr[i] = 0;
			if(i == 0 && !arr[i]) arr[i] = 1;
			ans += arr[i];
			//cout<<arr[i];
			ans*=10;
		}
		ans/=10;
		cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  int N;
  cin >> N;
  int A[N];
  rep(i,N) cin >> A[i];
  int ans[N]={};
  if(N%2==0){
    int p=N/2,x=-1;
    for(int i=1;i<=N;i++){
      ans[p]=A[i-1];
      p+=x*i;
      x*=-1;
    }
  }
  else{
    int p=N/2,x=1;
    for(int i=1;i<=N;i++){
      ans[p]=A[i-1];
      p+=x*i;
      x*=-1;
    }
  }
  rep(i,N) cout << ans[i] << " ";
}

Measured memory_bytes: 3712
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n; 
  cin>>n;
  vector<int> p(n);
  rep(i,n)cin >>p[i];
  ll ans=0;
  rep(i,n-1){
    if(p[i]==i+1){
      swap(p[i],p[i+1]);
      ans++;
      i++;
    }
  }
  if(p[n-1]==n)ans++;
  cout <<ans<<endl;
}

Measured memory_bytes: 3792
package main
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
    "strings"
    "sort"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func main() {
    N := getStdinInt()
    A := getStdinIntArr()
    sort.Ints(A)

    list := make([]int, A[N-1]+1)
    list, _ = fill(list, 1, 0, A[N-1]+1)

    count := make([]int, A[N-1]+1)
    count, _ = fill(count, 0, 0, A[N-1]+1)
    for i := 0; i < N; i++ {
        count[A[i]]++
    }

    ans := 0

    for i := 0; i < N; i++ {
        if list[A[i]] == 1 {
            if count[A[i]] == 1 {
                ans++
            }
            for j := 2; A[i] * j <= A[N-1]; j++ {
                list[A[i] * j] = 0
            }
        }
    }

    fmt.Println(ans)
}

func fill(slice []int, val, start, end int) ([]int, error) {
    if len(slice) < start || len(slice) < end {
        return nil, fmt.Errorf("Error")
    }
    for i := start; i < end; i++ {
        slice[i] = val
    }
    return slice, nil
}

func getStdin() string {
    return readLine()
}
func getStdinInt() int {
    str := getStdin()
    res, _ := strconv.Atoi(str)
    return res
}
func getStdinIntArr() []int {
    str := getStdin()
    list := strings.Split(str, " ")
    res := make([]int, len(list))
    for idx, v := range list {
        res[idx], _ = strconv.Atoi(v)
    }
    return res
}
func getStdinArr() []string {
    str := getStdin()
    list := strings.Split(str, " ")
    return list
}
func readLine() string {
    buf := make([]byte, 0, 0)
    for {
        l, p, e := sc.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

Measured memory_bytes: 27956
n,a,b=map(int,input().split())
s=input()
cnt=0
cnt_f=0
for i in range(n):
    if s[i] == 'a' and cnt < a+b:
        print('Yes')
        cnt+=1
    elif s[i] == 'b' and cnt < a+b and cnt_f < b:
        print('Yes')
        cnt+=1
        cnt_f+=1
    elif s[i] == 'c':
        print('No')
    else:
        print('No')

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  if (N == 1) {
    cout << 1 << endl;
    return 0;
  }

  vector<int> d(N);
  REP(i, N) { cin >> d.at(i); }
  sort(d.begin(), d.end());
  int ans = 1;
  int prev_d = d.at(0);
  REPI(i, 1, N) {
    if (d.at(i) > prev_d) {
      ++ans;
    }
    prev_d = d.at(i);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// 2013/10/22 Tazoe

#include <iostream>
using namespace std;

char F[102][102];

void DFS(int Y, int X, char C)
{
	if(F[Y][X]!=C)
		return;

	F[Y][X] = 0;

	DFS(Y-1, X, C);
	DFS(Y, X+1, C);
	DFS(Y+1, X, C);
	DFS(Y, X-1, C);
}

int main()
{
	while(true){
		int H, W;
		cin >> H >> W;

		if(H==0 && W==0)
			break;

		for(int y=1; y<=H; y++){
			for(int x=1; x<=W; x++){
				cin >> F[y][x];
			}
		}

		int cnt = 0;
		for(int y=1; y<=H; y++){
			for(int x=1; x<=W; x++){
				if(F[y][x]!=0){
					cnt++;
					DFS(y, x, F[y][x]);
				}
			}
		}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1476
from collections import Counter

N = int(input())

arr = list(map(int, input().split(" ")))

cnt = Counter()
for word in arr:
    cnt[word] += 1

even_cnt_list = []
for k, v in cnt.items():
    if v % 2 == 0:
        even_cnt_list.append(v)

num_delete = 1 if len(even_cnt_list) % 2 else 0

origin_length = len(cnt.keys())

print (origin_length - num_delete)

Measured memory_bytes: 18648
import math


def main():
    nvertices, nedges = map(int, input().split())
    INF = float('inf')
    D1 = [[0 if i == j else INF for i in range(nvertices)]
          for j in range(nvertices)]
    for i in range(nedges):
        u, v, w = map(int, input().split())
        D1[u][v] = w

    for k in range(nvertices):
        D2 = [[0] * nvertices for i in range(nvertices)]
        for i in range(nvertices):
            for j in range(nvertices):
                D2[i][j] = min(D1[i][j], D1[i][k] + D1[k][j])
        D1 = D2

    for v in range(nvertices):
        if D1[v][v] < 0:
            print("NEGATIVE CYCLE")
            return

    for D in D1:
        print(" ".join(map(lambda e: "INF" if math.isinf(e) else str(e), D)))


main()

Measured memory_bytes: 8760
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

struct edge{
private:
public:
    edge(){}
    edge(uint u_in, uint v_in, uint cost_in): u(u_in), v(v_in), cost(cost_in) {}
    ~edge(){}
    int u; // from
    int v; // to
    int cost;
};
bool cmp(const struct edge& lhs, const struct edge& rhs){ return lhs.cost < rhs.cost; }

class unionFind{
private:
    vector<uint> vParent;
    vector<uint> vRank;
public:
    unionFind(uint size){
        vParent.resize(size); for(uint i=0; i<size; ++i){ vParent[i]=i; }
        vRank.resize(size, 0);
    }
    ~unionFind(){}
    
    uint find(uint rhs){
        if(rhs == vParent[rhs]){ return rhs;
        }          else        { return vParent[rhs] = find( vParent[rhs] ); }
    }
    void unite(const uint& lhs, const uint& rhs){
        uint root_l = find(lhs);
        uint root_r = find(rhs);
        if(root_l == root_r){ return; }
        
        if(vRank[root_l] < vRank[root_r]){ vParent[root_l]=root_r;
        }              else              { vParent[root_r]=root_l; if(vRank[root_l] == vRank[root_r]){ ++vRank[root_l]; } }
    }
    bool same(const uint& lhs, const uint& rhs){ return find(lhs)==find(rhs); }
};

uint64 solve_kruskal(vector<edge>& vEdge){
    sort(vEdge.begin(), vEdge.end(), cmp);
    
    class unionFind uf(vEdge.size());
    uint64 sum_cost=0ull;
    
    for(uint i=0; i<vEdge.size(); ++i){
        struct edge e = vEdge[i];
        if(uf.same(e.u, e.v)){ continue; }
        uf.unite(e.u, e.v);
        sum_cost += e.cost;
    }
    return sum_cost;
}

struct vertex{
private:
public:
    vertex(){}
    vertex(uint idx_in, uint x_in, uint y_in): idx(idx_in), x(x_in), y(y_in) {}
    ~vertex(){}
    int idx;
    int x;
    int y;
};
bool cmp_x(const struct vertex& lhs, const struct vertex& rhs){ return lhs.x < rhs.x; }
bool cmp_y(const struct vertex& lhs, const struct vertex& rhs){ return lhs.y < rhs.y; }
int costAB(const struct vertex& lhs, const struct vertex& rhs){ return min(abs(lhs.x-rhs.x), abs(lhs.y-rhs.y)); }

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N; cin >> N;
    vector<vertex> vXY(N);
    for(int i=0; i<N; ++i){
        int x, y; cin >> x >> y;
        vXY[i].idx = i;
        vXY[i].x   = x;
        vXY[i].y   = y;
    }
    
    vector<vertex> vXY_x=vXY; sort(vXY_x.begin(), vXY_x.end(), cmp_x);
    vector<vertex> vXY_y=vXY; sort(vXY_y.begin(), vXY_y.end(), cmp_y);
    
    vector<edge> vEdge(4*N); vEdge.resize(0);
    for(int i=0; i<N-1; ++i){
        int cost_x = costAB(vXY_x[i], vXY_x[i+1]);
        vEdge.push_back( edge(vXY_x[i  ].idx, vXY_x[i+1].idx, cost_x) );
        vEdge.push_back( edge(vXY_x[i+1].idx, vXY_x[i  ].idx, cost_x) );
        
        int cost_y = costAB(vXY_y[i], vXY_y[i+1]);
        vEdge.push_back( edge(vXY_y[i  ].idx, vXY_y[i+1].idx, cost_y) );
        vEdge.push_back( edge(vXY_y[i+1].idx, vXY_y[i  ].idx, cost_y) );
    }
    
    cout << solve_kruskal(vEdge) << endl;
    
    return 0;
}

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

int main() {
    
    int H, W;
    char mas[100][100];
    
    cin >> H >> W;
    for(int i = 0; i < H; i++)
        for(int j = 0; j < W; j++)
            cin >> mas[i][j];
    
    for(int i = 0; i < H; i++) {
        for(int j = 0, cnt = -1; j < W; j++) {
            if(mas[i][j] == 'c') cnt = 0;
            else if(~cnt) cnt++;
            printf("%d%c", cnt, (j == W - 1 ? '\n' : ' '));
        }
    }
}

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

int main()
{
    int a,b,w,t;
    while(cin>>w>>a>>b)
    {
        if(a>b)
        {t=a;a=b;b=t;}
        if(a+w>=b)
            cout<<"0"<<endl;
        else
            cout<<b-a-w<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

(setq *n* (read))
(setq *v* (make-array *n* :initial-contents (mapcar #'parse-integer (split " " (read-line)))))
(setq *c* (make-array *n* :initial-contents (mapcar #'parse-integer (split " " (read-line)))))

(setq *gains* nil)

(defun dfs (gain i)
  (let ((next-gain gain) (result nil))
      (if (>= i *n*)
        (setq *gains* (cons gain *gains*))
        (dotimes (n 2 result)
                 ;(print (list "next-gain " next-gain (aref *v* i) (aref *c* i)))
                 (when (= n 1) (setq next-gain (+ gain (- (aref *v* i) (aref *c* i)))))
                 (setq result (dfs next-gain (1+ i)))))))

  (dfs 0 0)
  (print (apply #'max *gains*))

Measured memory_bytes: 33852
///Bismillahir Rahmanir Rahim
#define ll long long
#define ull unsigned long long
#define scf1(a)  scanf("%lld",&a)
#define scf2(a,b)  scanf("%lld %lld",&a,&b)
#define pf    printf
#define pb    push_back
#define rsrt(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define ff first
#define ss second
#define spd ios_base::sync_with_stdio(false)
#include<bits/stdc++.h>
using namespace std;
ll dp[200005];
ll arr[200005];
int main()
{
   spd;

   ll n,i,j,k;

   cin>>n;

   for(i=1;i<=n;i++)
   {
       cin>>arr[i];
   }
   dp[2] = abs(arr[2] - arr[1]);
   dp[1] = 0;
   for(i=3;i<=n;i++)
   {
       dp[i] = min((dp[i-1] + abs(arr[i]-arr[i-1])),(dp[i-2] + abs(arr[i]-arr[i-2])));
   }

   cout<<dp[n]<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_map>
using namespace std;

int main()
{
    int n;
    cin >> n;
    unordered_map<string, int> st;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        st[s]++;
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
        string s;
        cin >> s;
        st[s]--;
    }
    int mm = 0;
    for (auto kv : st) {
        mm = max(mm, kv.second);
    }
    cout << mm << endl;
    
    return 0;
}

Measured memory_bytes: 384
# https://atcoder.jp/contests/abc121/tasks/abc121_b

inp_1 = input().split()
n = int(inp_1[0])
m = int(inp_1[1])
c = int(inp_1[2])


b = [int(i) for i in input().split()]

a_mat = []

for i in range(n):
    a_mat.append([int(a) for a in input().split()])

count = 0

for i in range(n):
    mulsum = c
    for j in range(m):
        mulsum = mulsum + a_mat[i][j]*b[j]
    if mulsum > 0:
        count = count + 1


print(count)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define PI acos(-1)
#define MM int m=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) (x)%mo_num
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define sc second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
//#define P pair<int,int>
using namespace std;
const int INF=LLONG_MAX;
const int maxn=1e6+5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;
int to[maxn],vis[maxn],sum[maxn];
vct aa;
void add(int& be,int& have)
{
    aa.pb(a[be]);
    be++;
    be=(be-1)%n+1;
    have++;
    return ;
}
void go(int be,int len)
{
    int have=0;
    while(have<len)
    {
        if(to[be]-be+have>len)
        {
            add(be,have);
            continue;
        }
        have+=to[be]-be;
        be=(to[be]-1)%n+1;
    }
    return ;
}
int32_t main()
{
    IOS
    cin>>n>>m;
    fun(i)cin>>a[i];
    fd(i,n,1)b[a[i]]=i+n;
    fd(i,n,1)
    {
        to[i]=b[a[i]]+1;
        b[a[i]]=i;
    }
    int now=1,Long=0,length=0;
    while(!vis[now])//note
    {
        vis[now]=1;
        Long+=to[now]-now;
        now=(to[now]-1)%n+1;
    }
    memset(vis,0,sizeof vis);
    while (!vis[now])
    {
        vis[now]=1;
        length+=to[now]-now;
        now=(to[now]-1)%n+1;
    }
    if(n*m<=Long)go(1,n*m);
    else go(now,(n*m-Long-1)%length+1);
    fa(i,aa)cout<<i<<" ";
    return 0;
}


Measured memory_bytes: 23664
N, K = map(int, input().split())
V = list(map(int, input().split()))
R = min(N, K)
ans = 0
for a in range(R+1):
  for b in range(R+1-a): #操作Aをa回、操作Bをb回
    tmp = list()
    for i in range(a): 
      tmp.append(V[i])
    for j in range(b):
      tmp.append(V[N-1-j])
    tmp.sort()
    x = min(K-a-b, len(tmp))
    for k in range(x):
      if(tmp[k] < 0):
        tmp[k] = 0
    ans = max(ans, sum(tmp))
print(ans)

Measured memory_bytes: 43996
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int h, w;
    cin >> h >> w;

    vector<string> a(h);
    rep(i, h) cin >> a[i];

    rep(i, w+2) cout << "#";
    cout << endl;
    rep(i, h) {
        rep(j, w + 2) {
            if (j == 0 || j == w + 1) cout << "#";
            else cout << a[i][j - 1];
        }
        cout << endl;
    }
    rep(i, w+2) cout << "#";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int D, G;
int p[11];
int c[11];

int main() {
  // 入力
  cin >> D >> G;
  for (int i = 0; i < D; i++) {
    cin >> p[i] >> c[i];
  }

  int min_num = 100 * 10;
  // 全部解くor全く解かないで全探索
  for (int bit = 0; bit < (1<<D); bit++) {
    int S = 0;
    int num = 0;
    // cout << bitset<10>(bit) << endl;
    for (int i = 0; i < D; i++) {
      if (bit & (1<<i)) {
        S += p[i] * 100 * (i+1) + c[i];
        num += p[i];
      }
    }
    if (S >= G) {
      if (num < min_num) {
        min_num = num;
        // cout << bitset<10>(bit) << ", " << num << ", " << min_num << ", " << S << endl;
      }
    } else {
      for (int i = D; i >= 0; i--) {
        if ( !(bit & (1<<i)) ) {
          for (int j = 0; j < p[i]; j++) {
            S += 100 * (i+1);
            num += 1;
            if (S >= G) {
              if (num < min_num) {
                min_num = num;
                // cout << bitset<10>(bit) << ", " << num << ", " << min_num << ", " << S << endl;
              }
            }
          }
        }
      }
    }
  }
  cout << min_num << endl;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

struct MyStruct {
	int x, y;
	bool cleared = false;
};

bool comp(const MyStruct& s, const MyStruct& t) {
	if (s.x != t.x)
		return s.x > t.x; //降順
	return s.y > t.y;
}

bool is_online(int x1, int y1, long long kx, long long ky, int cx, int cy) {
	long long dx = cx - x1;
	long long dy = cy - y1;
	if ((long long)kx*dy == (long long)dx*ky) return true;
	else return false;
}


int main() {
	int x, a;
	cin >> x >> a;
	if (x < a) {
		ANS(0);
	}
	else {
		ANS(10);
	}
	return 0;
}


Measured memory_bytes: 256
(function(stdin) {

  const inequality = function(a, b) {
      if (a === b)  return 'a == b';
      if (a > b)    return 'a > b';
      return               'a < b';
  };

  const inputs = stdin.toString().trim().split('\n');
  // const cols = Array.from(inputs[0].split(' '), Number);
  const cols = inputs[0].split(' ').map(Number);

  const result = function(a, b) {
    // return [a, b];
    return inequality(a, b);
  }(cols[0], cols[1]);


  console.log(result);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15504
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math
from fractions import gcd

mod=10**9+7
#N=int(input())
N,A,B=map(int,input().split())
#A=list(map(int,input().split()))


print(N//(A+B)*A+min(N%(A+B),A)*bool(N%(A+B)))


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

using namespace std;

#define ll				long long
#define pb				push_back
#define w(x)			int x; cin>>x; while(x--)
#define mp      		make_pair
#define mod     		1000000007
#define inf     		1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define endl	  		"\n"
#define sp 				" "
#define ca(x) 			"Case "<<x<<": "


int main()
{

	int n;
	cin >> n;
	if (n % 1000 != 0)
		cout << 1000 - (n % 1000);
	else cout << 0;

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h, n;
    cin >> h >> n;
    vector<ll> dp(30000, 1e16);
    dp[0] = 0;
    rep(i, 0, n) {
        ll a, b;
        cin >> a >> b;
        for (int i = 0; i < 20000; i++) {
            dp[i + a] = min(dp[i + a], dp[i] + b);
        }
    }
    ll ans = 1e18;
    rep(i, h, 20000) ans = min(ans, dp[i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
s = inp.shift()
o = {a: 0, b: 0, c: 0}
f = true
for (i=0; i<s.length; i++) {
    o[s[i]] += 1
    if (o[s[i]] > 1) {
        f = false
        break;
    }
}
console.log(f ? 'Yes' : 'No')

Measured memory_bytes: 7372
import scala.io.StdIn

object Main {

  def main(args: Array[String]): Unit = {
    val n = StdIn.readLine().toInt
    val Array(a, b) = StdIn.readLine().split(' ').map(_.toInt)
    val ps = StdIn.readLine().split(' ').toList.map(_.toInt)

    val difficultyCount = ps.foldLeft(Vector(0, 0, 0)){(acc, p) =>
      val i = if (p <= a) 0 else if (p <= b) 1 else 2
      acc.updated(i, acc(i) + 1)
    }
    val ans = difficultyCount.foldLeft(n)((acc, d) => acc min d)
    println(ans)
  }

}


Measured memory_bytes: 27440
#include<iostream>
using namespace std;
struct Node{int parent,left,right;};
struct Node T[100001];
#define NIL -1
int D[100001],n,dim,child,v,l,s;
void getDepth(int u,int p){
    D[u]=p;
    if(T[u].right!=NIL) getDepth(T[u].right,p);
    if(T[u].left!=NIL) getDepth(T[u].left,p+1);
}
void printchild(struct Node T[],int p,int d){
    if(d==0){
        if(T[p].left!=NIL){
            cout<<T[p].left;
            printchild(T,T[p].left,d+1);
        }
    }
    else if(T[p].right!=NIL){
            cout<<", "<<T[p].right;
            printchild(T,T[p].right,d);
     }
    
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++) T[i].parent=T[i].right=T[i].left=NIL;
    for(int i=0;i<n;i++){
        cin>>v>>dim;
        for(int j=0;j<dim;j++){
            cin>>child;
            if(j==0) T[v].left=child;
            else  T[l].right=child;
            l=child;
            T[child].parent=v;
        }
    }
    for(int i=0;i<n;i++){
        if(T[i].parent==NIL) s=i;
    }
    getDepth(s,0);
    for(int i=0;i<n;i++){
        cout<<"node "<<i<<": ";
        cout<<"parent = "<<T[i].parent<<", ";
        cout<<"depth = "<<D[i]<<", ";
        if(T[i].parent==NIL) cout<<"root, [";
        else if(T[i].left==NIL) cout<<"leaf, [";
        else cout<<"internal node, [";
        printchild(T,i,0);
        cout<<"]"<<endl;
    }
}


Measured memory_bytes: 7732
#include <iostream>
#include <map>
#include <vector>

using namespace std;

class DisjointSet {
    public:
        vector<int> rank, p;
        DisjointSet() {}
        DisjointSet(int n){
            rank.resize(n, 0);
            p.resize(n, 0);
            for(int i = 0; i < n; i++){
                makeSet(i);
            }
        }
        
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }
        
        bool same(int x, int y){
            return findSet(x) == findSet(y);
        }
        
        int findSet(int x){
            if(x != p[x]){
                p[x] = findSet(p[x]);
            }
            
            return p[x];
        }
        
        void unite(int x, int y){
            link(findSet(x), findSet(y));
        }
        
        void link(int x, int y){
            if(rank[x] > rank[y]){
                p[y] = x;
            } else {
                p[x] = y;
                if(rank[x] == rank[y]){
                    rank[y]++;
                }
            }
        }
};

int main(void){
    // Your code here!
    int N, K, L, p, q, r, s;
    cin >> N >> K >> L;
    
    DisjointSet ds1 = DisjointSet(N);
    DisjointSet ds2 = DisjointSet(N);
    
    for(int i = 0; i < K; i++){
        cin >> p >> q;
        p--;
        q--;
        if(!ds1.same(p, q)) ds1.unite(p, q);
    }
    
    for(int i = 0; i < L; i++){
        cin >> r >> s;
        r--;
        s--;
        if(!ds2.same(r, s)) ds2.unite(r, s);
    }
    
    vector<pair<int, int> > com(N);
    map<pair<int, int>, int> S;
    for(int i = 0; i < N; i++){
        com[i].first = ds1.findSet(i);
        com[i].second = ds2.findSet(i);
        S[com[i]] += 1;
    }
    
    for(int i = 0; i < N; i++){
        cout << S[com[i]] << " ";
    }
    cout << endl;
    
    return 0;
    
    
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define stp setprecision(15)
#define eps 0.000001
#define endl '\n'
#define ll lli
 
using namespace std ;
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define N 2000000

int main() 
{ 

/////////////////////////////////////
    
    fastio;   

    lli n;
    cin>>n;

    lld a[n];
    lld sum=0;

    loopl(i,0,n)
    {
        cin>>a[i];
        sum += (1/a[i]);
    }

    sum = (1/sum);

    cout<<fixed<<stp<<sum<<endl;

} 

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <queue>
#include <string>
#include <map>
#include <vector>

using namespace std;

int conv(char c) {
  switch (c) {
  case 'I':
    return 1;
  case 'V':
    return 5;
  case 'X':
    return 10;
  case 'L':
    return 50;
  case 'C':
    return 100;
  case 'D':
    return 500;
  case 'M':
    return 1000;
  default:
    return 0;
  }
}

int main() {
  char s[128];
  while (scanf("%s", s) == 1) {
    int r = 0;
    for (char *c = s; *c; c++)
      if (conv(*c) < conv(*(c+1)))
        r -= conv(*c);
      else
        r += conv(*c);
    printf("%d\n", r);
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	Int len = s.size();

	Int ans = -INF;
	Int cnt=0;

	for (Int i = 0; i < len; i++) {
		
		if (s[i]=='A'|| s[i] == 'C'|| s[i] == 'G'|| s[i] == 'T') {
			cnt++;
		}
		else {
			ans = max(ans, cnt);
			cnt = 0;
		}

	}
	ans = max(ans, cnt);
	cout << ans << "\n";
}


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

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

    Int n,h,ans=0; cin>>n>>h; vector<Int> a(n,0),b(n,0);
    for (int i = 0; i < n; i++)cin>>a[i]>>b[i];
    Int am=*max_element(a.begin(), a.end());
    sort(b.begin(), b.end());
    Int sum=0; int i=0;
    while(sum<h){
        if(i>=n||b[n-1-i]<=am){
            ans+=(h-sum+(am-1))/am; break;
        }else{
            sum+=b[n-1-i]; ans++;
        }
        i++;
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 1792