akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

#define MAX 1010

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int n;
double cost[MAX][MAX];
int to_id[MAX];
int to_num[MAX];
vector<pair<int, int> > vv;

int prev[MAX];
double d[MAX];
bool used[MAX];
int V;

void dijkstra(int s){
    fill(d, d+V, inf);
    fill(used, used+V, false);
    fill(prev, prev+V, -1);
    d[s] = 0;

    while(true){
        int v = -1;
        for(int u=0; u < V; u++){
            if(!used[u] && (v==-1 || d[u] < d[v])) v = u;
        }

        if(v == -1)break;
        used[v] = true;

        for(int u=0; u < V; u++){
            if(d[u] > d[v] + cost[v][u]){
                d[u] = d[v] + cost[v][u];
                prev[u] = v;
            }
        }
    }
}

vector<int> get_path(int t){
    vector<int> path;
    for(; t != -1; t = prev[t]) path.push_back(t);
    reverse(path.begin(), path.end());
    return path;
}

int main(){
    while(cin >> n, n){
        V = n;
        vv.clear();
        rep(i, n){
            int b, x, y;
            cin >> b >> x >> y;
            to_id[i] = b; to_num[b] = i; vv.push_back(make_pair(x, y));
        }
        rep(i, n)rep(j, n){
            if(i == j) {cost[i][j] = inf; continue;}
            double d = abs(sqrt(pow(vv[i].first-vv[j].first, 2)+pow(vv[i].second-vv[j].second, 2)));
            if(d-eps <= 50.0){/*cout << i << " " << j << " " << d << endl;*/ cost[i][j] = d;}
            else cost[i][j] = inf;
        }
        int m;
        cin >> m;
        rep(i, m){
            int s, g;
            cin >> s >> g; s; g;
            dijkstra(to_num[s]);
            vector<int> p = get_path(to_num[g]);

            if(p.size() == 1) cout << "NA" << endl;
            else {
                rep(j, p.size()) cout << (j==0?"":" ") << to_id[p[j]];
                cout << endl;
            }
        }
    }
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define maxn 100005
struct Edge{
	int next,to;
}edge[maxn*2];
int fi[maxn],se,n,k;
long long ans=1;
inline void add_edge(int u,int v){
	edge[++se].next=fi[u],edge[se].to=v,fi[u]=se,
	edge[++se].next=fi[v],edge[se].to=u,fi[v]=se;
}
void dfs(int x,int fa,int k1){
	(ans*=k1)%=mo;
	int num=0;
	for(int i=fi[x];i;i=edge[i].next){
		int v=edge[i].to;
		if(v==fa)continue;
		dfs(v,x,k-1-(x!=1)-num++);
	}
}
int main(){
	int u,v;scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++)scanf("%d%d",&u,&v),add_edge(u,v);
	dfs(1,0,k);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
int dx[]={1,0,-1,0,0};
int dy[]={0,1,0,-1,0};
int bfs[10][10][7];
int c[10][10];
int main(){
	int a,b;
	while(scanf("%d%d",&b,&a),a){
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)scanf("%d",&c[i][j]);
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)for(int k=0;k<7;k++)
			bfs[i][j][k]=-1;
		queue<pair<pair<int,int>,int> > Q;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			if(c[i][j]==2){
				bfs[i][j][6]=0;
				Q.push(make_pair(make_pair(i,j),6));
			}
		}
		while(Q.size()){
			int row=Q.front().first.first;
			int col=Q.front().first.second;
			int t=Q.front().second;
			Q.pop();
			if(t==1)continue;
			for(int i=0;i<5;i++){
				int nx=row+dx[i];int ny=col+dy[i];
				if(nx<0||nx>=a||ny<0||ny>=b||!c[nx][ny])continue;
				int T=t-1;
				if(c[nx][ny]==4)T=6;
				if(!~bfs[nx][ny][T]){
					bfs[nx][ny][T]=bfs[row][col][t]+1;
					Q.push(make_pair(make_pair(nx,ny),T));
				}
			}
		}
		int ret=99999999;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			if(c[i][j]==3){
				for(int k=0;k<=6;k++)if(~bfs[i][j][k])ret=min(ret,bfs[i][j][k]);
			}
		}
		if(ret>888888)printf("-1\n");
		else printf("%d\n",ret);
	}
}

Measured memory_bytes: 1048
import heapq

N, K = map(int, input().split())
S = []
for i in range(N):
    t, d = map(int, input().split())
    heapq.heappush(S, (-d, t))

sum_d = 0
types = set()
surplus = []
for i in range(K):
    _d, t = heapq.heappop(S)
    sum_d += -_d
    if t in types:
        heapq.heappush(surplus, -_d)
    else:
        types.add(t)
len_types = len(types)
ans = sum_d + len_types * len_types

while S and surplus:
    _d, t = heapq.heappop(S)
    if t in types:
        continue
    types.add(t)
    removed_d = heapq.heappop(surplus)
    sum_d += -_d - removed_d
    len_types += 1
    ans = max(ans, sum_d + len_types * len_types)
print(ans)


Measured memory_bytes: 19236
#include <iostream>
#include <stdio.h>
#include <string> 
#include <cctype>

int array[26];

int main()
{
	char c;
	bool end = false;

		while ((c = getchar()) != EOF)
		{
		
			int n = -1;
			if (isupper(c))n = c - 'A';
			if (islower(c))n = c - 'a';
			if (n >= 0)
			{
				array[n]++;
			}
		}

	
	
	
	for (int i = 0; i < 26; i++)
	{
		char cc = 'a' + i;
		std::cout << cc << " : " << array[i] << std::endl;
	}
}


Measured memory_bytes: 3100
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
 freopen("input","r",stdin);
 freopen("output","w",stdout);
*/

int L[3010][3010];
int X[3010][3010][2];
int Y[3010][3010][2];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    memset(L, 0, sizeof(L));
    memset(X, 0x7f, sizeof(X));
    memset(Y, 0x7f, sizeof(Y));
    cin >> s >> t;
    for (int i = 0;i < s.size();i++) {
        for (int j = 0;j < t.size();j++) {
            if (s[i] == t[j]) {
                if (i > 0 && j > 0) {
                    L[i][j] = L[i - 1][j - 1] + 1;
                    X[i][j][0] = i;
                    X[i][j][1] = j;
                    Y[i][j][0] = X[i - 1][j - 1][0];
                    Y[i][j][1] = X[i - 1][j - 1][1];
                } else {
                    L[i][j] = 1;
                    X[i][j][0] = i;
                    X[i][j][1] = j;
                }
            } else {
                if (i > 0 && L[i - 1][j] > L[i][j]) {
                    L[i][j] = L[i - 1][j];
                    X[i][j][0] = X[i - 1][j][0];
                    X[i][j][1] = X[i - 1][j][1];
                }
                if (j > 0 && L[i][j - 1] > L[i][j]) {
                    L[i][j] = L[i][j - 1];
                    X[i][j][0] = X[i][j - 1][0];
                    X[i][j][1] = X[i][j - 1][1];
                }
            }
        }
    }
    int a = s.size() - 1;
    int b = t.size() - 1;
    vector<char> ans;
    int l = L[s.size() - 1][t.size() - 1];
    while (true) {
        int c, d;
        if (X[a][b][0] == a && X[a][b][1] == b) {
            ans.push_back(s[a]);
            l--;
            c = Y[a][b][0];
            d = Y[a][b][1];
        } else {
            c = X[a][b][0];
            d = X[a][b][1];
        }
        swap(a, c);
        swap(b, d);
        if (l == 0) break;
    }
    for (int i = ans.size() - 1;i >= 0;i--) cout << ans[i];
    cout << endl;
    return 0;
}


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

int main(){
	
	int c[3] ;
	double sum , count ;
	
	while(1){
		sum = 0 ;
		count = 0 ;
		cin >> c[0] ;
		if( cin.eof() ) break ;
		cin >> c[1] >> c[2] ;
		
		sum = c[0] + c[1] ;
		
		for( int i=1 ; i<=10 ; i++ ){
			if( c[0] != i && c[1] != i && c[2] != i ){
				if( sum+i > 20 ) count++;
			}
		}
		
		if( count/7*100 >= 50 ) cout << "NO" << endl ;
		else cout << "YES" << endl ;
		
		
	}
return 0 ;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	long long a,b;
	string s;
	cin>>a>>s>>b;
	if(s=="+"){
		a += b;
	}
	else{
		a -=b;
	}
	cout<<a<<endl;
}

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

namespace PastQuestions
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new Input(Console.In));
        }

        public void Solve(Input input)
        {
            var n = input.ReadInt;
            List<int> d = new List<int>();
            for (var i = 0; i < n; ++i)
            {
                d.Add(input.ReadInt);
            }

            Console.WriteLine(d.Distinct().ToArray().Length);
        }
    }

    public class Input
    {
        private TextReader Stream { get; }
        private char Separator { get; }
        private Queue<string> InputStream { get; }

        public Input(TextReader stream, char separator = ' ')
        {
            Stream = stream;
            Separator = separator;
            InputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (InputStream.Count != 0) return InputStream.Dequeue();
                string[] tmp = Stream.ReadLine().Split(Separator);
                for (int i = 0; i < tmp.Length; ++i)
                    InputStream.Enqueue(tmp[i]);
                return InputStream.Dequeue();
            }
        }

        public string ReadLine => Stream.ReadLine();
        public int ReadInt => int.Parse(Read);
        public long ReadLong => long.Parse(Read);
        public double ReadDouble => double.Parse(Read);
        public int[] ReadIntArray => Stream.ReadLine().Split(Separator).Select(i => int.Parse(i)).ToArray();
        public long[] ReadLongArray => Stream.ReadLine().Split(Separator).Select(l => long.Parse(l)).ToArray();
    }
}


Measured memory_bytes: 13280
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let mut a: Vec<i64> = sc.vec(n);

    if a.iter().all(|&a| a >= 0) {
        a.sort();
        let mut ans = vec![];
        let mut cur = a[0];
        for i in 1..(n - 1) {
            ans.push((cur, a[i]));
            cur -= a[i];
        }
        ans.push((a[n - 1], cur));
        let m = a[n - 1] - cur;
        sc.write(format!("{}\n", m));
        for (x, y) in ans.into_iter() {
            sc.write(format!("{} {}\n", x, y));
        }
    } else if a.iter().all(|&a| a <= 0) {
        a.sort();
        a.reverse();
        let mut cur = a[0];
        let mut ans = vec![];
        for i in 1..n {
            ans.push((cur, a[i]));
            cur -= a[i];
        }
        sc.write(format!("{}\n", cur));
        for (x, y) in ans.into_iter() {
            sc.write(format!("{} {}\n", x, y));
        }
    } else {
        let mut negative = vec![];
        let mut non_negative = vec![];
        for a in a.into_iter() {
            if a < 0 {
                negative.push(a);
            } else {
                non_negative.push(a);
            }
        }
        let mut positive = non_negative.pop().unwrap();
        let mut cur = negative.pop().unwrap();
        let mut ans = vec![];
        for non_negative in non_negative.into_iter() {
            ans.push((cur, non_negative));
            cur -= non_negative;
        }
        for negative in negative.into_iter() {
            ans.push((positive, negative));
            positive -= negative;
        }
        ans.push((positive, cur));
        positive -= cur;

        sc.write(format!("{}\n", positive));
        for (x, y) in ans.into_iter() {
            sc.write(format!("{} {}\n", x, y));
        }
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 10492
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
A = list(map(int, input().split()))

for i in range(N):
    A[i] -= i + 1

A.sort()
central = A[N // 2]

ans = 0
for i in range(N):
    ans += abs(central - A[i])
print(ans)

Measured memory_bytes: 31996
#include <bits/stdc++.h> 
using namespace std; 
int main() 
{
int n,W; 
cin>>n>>W;
vector<int>v(n),w(n);
vector<vector<long long int>> dp; 
dp.assign(n+1,vector<long long int> (W+1,0));
for(int i=0; i<n; i++) cin>>w[i]>>v[i];
for(int i=0; i<n; i++) for(int k=0; k<=W; k++) if (k<w[i]) dp[i+1][k]=dp[i][k]; else dp[i+1][k]=max(dp[i][k-w[i]]+v[i],dp[i][k]); 
//DEBUG: for(int i=0; i<=n; i++){ for(int k=0; k<=W; k++) cout<<dp[i][k]<<" "; cout<<endl; }
cout<<dp[n][W];
return 0; 
} 


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

int main() {
  int N;
  cin >> N;
  int count = 0;
  int max = 100000000;

  for (int i = 0; i < N; i++){
    count = 0;
    int A;
    cin >> A;
    while (A % 2 == 0){
      A /= 2;
      count++;
    }
    if(count < max){
      max = count;
    }
  }
  cout << max << endl;
}


Measured memory_bytes: 256
import math 
k=int(input())

ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        a=math.gcd(i,j)
        for l in range(1,k+1):
            b=math.gcd(a,l)
            ans+=b
    
print(ans)    

Measured memory_bytes: 9164
from bisect import bisect_left
import sys
sys.setrecursionlimit(10 ** 9)
n = int(input())
a = list(map(int, input().split()))

result = [-1 for _ in range(n)]
tree = [[] for _ in range(n)]
for _i in range(n-1):
    u, v = map(int, input().split())
    u, v = u-1, v-1
    tree[u].append(v)
    tree[v].append(u)
INF = float('inf')
dp = [INF for _i in range(n+1)]


def dfs(p, x):
    i = bisect_left(dp, a[p])
    old = dp[i]
    dp[i] = a[p]
    result[p] = bisect_left(dp, INF)
    for j in tree[p]:
        if j != x:
            dfs(j, p)
    dp[i] = old
    

dfs(0, -1)
print(*result)

Measured memory_bytes: 346536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define endl "\n"
#define ar array
#define deb(x) cout << #x << " = " << x << endl
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

template <class T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
inline ll add(ll a, ll b) { return ((a % mod) + (b % mod)) % mod; }
inline ll sub(ll a, ll b) { return ((a % mod) - (b % mod) + mod) % mod; }
inline ll mul(ll a, ll b) { return ((a % mod) * (b % mod)) % mod; }
struct comp
{
    bool operator()(const pair<ll, ll> &x, const pair<ll, ll> &y) const
    {
        return x.first < y.first;
    }
};
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll pwr(ll x, ll n)
{
    if (n == 0)
        return 1;
    if (n & 1)
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    else
        return pwr(mul(x, x), n / 2);
}
ll modInv(ll n)
{
    return pwr(n, mod - 2);
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}
ll a[4000];
int main()
{
    int t = 1;
    //cin >> t;
    while (t--)
    {
        double d, s, t;
        cin >> d >> t >> s;
        if (t >= d / s)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}

Measured memory_bytes: 3724
// Garg's Code
#include <bits/stdc++.h>
#include <string.h>
using namespace std;

#define ll long long
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++)
#define rf(i,x,n) for(ll i = x; i >= x; i--)
#define all(c) c.begin(),c.end()
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const ll MAX = LLONG_MAX, MOD = 1000000007, MODA = 1e9 - 1;
const ll MIN = LLONG_MIN;
const long double PI = 3.1415926535;
const ll N = 100009;

int main()
{
  fast();

  ll t=1;
  //cin >> t;
  while(t--)
  {
    string s;
    cin >> s;
    ll k;
    cin >> k;
    ll n = s.length();
    string abc = "";
    f(i,0,n)
    {
      abc += '0';
    }
    ll ans = 0;
    if(k == 1)
    {
      f(i,0,n)
      {
        if(i == 0)
          ans += s[i] - '0';
        else
          ans += 9;
      }
    }
    if(k == 2)
    {
      if(n<2)
      {
        cout << 0;
        return 0;
      }
      f(i,0,n-1)
      {
        if(i == 0)
        {
          ans += (s[i]-'1')*(9*((n-1)-i));
          abc[0] = s[0];
          f(j,1,n)
          {
            f(k,1,10)
            {
              abc[j] = k + '0';
              if(abc <= s)
              {
                //cout << abc << endl;
                ans++;
              }
            }
            abc[j] = '0';
          }
        }
        else
        {
          ans += (9)*(9*((n-1)-i));
        }
      }
    }
    if(k==3)
    {
      if(n < 3)
      {
        cout << 0;
        return 0;
      }
      f(i,0,n-2)
      {
        if(i == 0)
        {
          ans += (s[i]-'1')*(81)*(((n-1-i)*(n-2-i))/2);
          abc[0] = s[0];
          f(j,1,n-1)
          {
            f(k,1,10)
            {
                abc[j] = k + '0';
                f(l,j+1,n)
                {
                  f(m,1,10)
                  {
                    abc[l] = m + '0';
                  if(abc <= s)
                    ans++;
                  }
                  abc[l] = '0';
                }
                
            }
            abc[j] = '0';
          }
        }  
        else
        {
          ans += (9)*(81)*(((n-1-i)*(n-i-2))/2);
        }
      }
    }
    cout << ans ;
  }
  return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

double dp[301][301][301];
int n;

double rec(int i, int j,int k){
  if(dp[i][j][k] >= 0) return dp[i][j][k];
  if(i==0 && j==0 && k==0)return 0.0;

  double result=0.0;
  if(i>0) result += rec(i-1, j, k) * i;
  if(j>0) result += rec(i+1, j-1, k) * j;
  if(k>0) result += rec(i, j+1, k-1) * k;

  result += n;
  result /= (i+j+k);
  return dp[i][j][k]=result;
}

int main(){
  cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];

  map<int, int> counts;
  rep(i, n){
    counts[a[i]]++;
  }

  memset(dp, -1, sizeof(dp));
  double result = rec(counts[1], counts[2], counts[3]);
  cout<<fixed<<setprecision(12)<<result<<endl;

  return 0;
}

Measured memory_bytes: 213376
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,D;
	cin >> N >> D;
	vector<int> d(N+1,0);
	for(int i=1;i<=N;++i){
		cin >> d[i];
	}
	vector<int> A(N+1);//d[i]後の位置
	A[0] = D;
	for(int i=1;i<=N;++i){
		int res = abs(A[i-1] - d[i]);
		if( res < A[i-1] ){
			A[i] = res;
		}else{
			A[i] = A[i-1];
		}
	}
	//////
	vector<int> B(N+1);
	B[N] = 1;
	for(int i=N;i>=1;--i){//
		if( 2*B[i] <= d[i] ){//近づけない
			B[i-1] = B[i];
		}else{//B[i] > d[i]/2, [0<di<2Bi],近づけるので増える
			B[i-1] = B[i] + d[i];
		}
	}
	//////
	int Q;
	cin >> Q;
	while(Q--){
		int q;
		cin >> q;
		if( A[q-1] >= B[q] ){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
map<pair<int,int>,int>mp;
int row[(int)3e5+9],col[(int)3e5+9];
int main()
{
    int r,c,m;
    cin>>r>>c>>m;
    int x,y;
    for (int i=0; i<m; i++)
    {
        cin>>x>>y;
        row[x]++;
        col[y]++;
        mp[ {x,y}]=1;
    }
    int mxr=0,mxc=0,ans=0,pr,pc;
    for (int i=1; i<=3e5; i++)
    {
        if (mxr<row[i])
        {
            mxr=row[i];
            pr=i;
        }
        if (mxc<col[i])
        {
            mxc=col[i];
            pc=i;
        }
    }
    for (int i=1; i<=3e5; i++)
    {
        if (mxc==col[i])
            ans=max(ans,mxr+mxc-mp[ {pr,i}]);
        if (mxr==row[i])
            ans=max(ans,mxr+mxc-mp[ {i,pc}]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 62160
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int>(1000,10000)(rng)

ll binpow(ll a, ll b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

ll gcd(ll a,ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,x=0;
    cin>>n;
    int a[n];
    for (int i=0;i<n;++i)
    {
        cin>>a[i];
        x^=a[i];
    }
    for (int i=0;i<n;++i)
        cout<<(x^a[i])<<" ";
    return 0;
}

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

using P = pair<int,int>;
using P3 = pair<P, int>;
using ll = long long int;
constexpr int INF = 1<<30;
constexpr ll MOD = (1e9)+7;


int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int> > a(n, vector<int>(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
            a[i][j]--;
        }
    }
    int ans = n;
    vector<int> cnt(m), idx(n);
    vector<bool> used(m);
    for(int i=0;i<n;i++){
        cnt[a[i][0]]++;
    }
    for(int i=0;i<m-1;i++){
        int cmax = 0, id = -1;
        for(int j=0;j<m;j++){
            if(cnt[j] > cmax){
                cmax = cnt[j];
                id = j;
            }
        }
        ans = min(ans, cmax);
        used[id] = true;
        fill(cnt.begin(), cnt.end(), 0);
        for(int j=0;j<n;j++){
            while(idx[j]<m && used[a[j][idx[j]]]) idx[j]++;
            cnt[a[j][idx[j]]]++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

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


Measured memory_bytes: 256
while True:
    a,b=map(int,input().split())
    sum=0
    e=[]
    if a==0 and b==0:
        break
    else:
        for i in range(1,a+1):
            for j in range(1,a+1):
                for k in range(1,a+1):
                    if i+j+k==b:
                            d=[i,j,k]
                            d.sort()
                            e.append(d)
    #print(e)
    uniqued = []
    for x in e:
        if not x in uniqued:
            uniqued.append(x)
    for i in range(len(uniqued)):
        for j in range(2):
            for k in range(2-j):
                if uniqued[i][j]==uniqued[i][2-k]:
                    sum+=1
                    break
            if uniqued[i][j]==uniqued[i][k]:
                break           
    print(len(uniqued)-sum)


Measured memory_bytes: 6432
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int t=n,s=0;
	while(t)
	{
		s+=t%10;
		t=t/10;
	}
	if(n%s==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, x, ans;
	cin >> n >> k;
	map<int, int> ct;
	for (i = 0; i < n; i++) {
		cin >> x;
		ct[x]++;
	}
	vector<int> a;
	for (auto p : ct) a.push_back(p.second);
	sort(a.begin(), a.end());
	if (a.size() < k) ans = 0;
	else {
		ans = 0;
		for (i = 0; i < a.size() - k; i++) ans += a[i];
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 10744
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        
        String[] str_array = br.readLine().split(" ");

        int ans = Integer.parseInt(str_array[0]) * Integer.parseInt(str_array[1]);
        
        pw.println(ans);
        br.close();
        pw.close();
    }
}

Measured memory_bytes: 32936
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

r,d,x = na()

for i in range(10):
    x = r*x-d
    print(x)

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#define rep(i, n) for(int i=0; i<(n); ++i)

int parent[100005];

int find(int x){
   if( parent[x] == x )return x;
   return parent[x] = find( parent[x] );
}

void unite(int x, int y)
{
   x = find(x);
   y = find(y);

   if(x == y)return;
   parent[x] = y;
}

int main()
{
   int N, M;
   int x, y, tmp;
   scanf("%d%d", &N, &M);
   std::iota(parent, parent + N, 0);

   rep(i, M){
      scanf("%d%d", &x, &y);
      unite(x, y);
   }

   int Q;
   scanf("%d", &Q);
   while(Q--){
      scanf("%d%d", &x, &y);
      puts( find(x) == find(y) ? "yes" : "no" );
   }
}



Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int N,K;
const int MN=100000;
ll a[MN];
ll asum[MN+1];
ll lmx[MN+1];
ll rmx[MN+1];
int main(){
	cin>>N>>K;
	rep(i,N) cin>>a[i];
	rep(i,N) asum[i+1]=asum[i]+a[i];
	rep(i,N){
		lmx[i+1]=lmx[i];
		if(a[i]>0) lmx[i+1]+=a[i];
	}
	rep(i,N){
		rmx[i+1]=rmx[i];
		if(a[N-1-i]>0) rmx[i+1]+=a[N-1-i];
	}
	ll ans=-1e18;
	rep(i,N-K+1){
		ll val=asum[i+K]-asum[i];
		if(val<0) val=0;
		val+=lmx[i];
		val+=rmx[N-K-i];
		chmax(ans,val);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
#define int ll

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> have(n + 1);
	vector<vector<char>> a(n + 1, vector<char>(m + 1));
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> a[i][j];
			//cout << a[i][j] << ' ';
			if (a[i][j] == '#') {
				have[i].pb(j);
			}
		}
		if (have[i].empty()) {
			cout << "Impossible\n";
			exit(0);
		}
		if (have[i].back() - have[i][0] + 1 != SZ(have[i])) {
			cout << "Impossible\n";
			exit(0);
		}
	}  
	for (int i = 1; i < n; i++) {
		if (have[i].back() != have[i + 1][0]) {
			cout << "Impossible\n";
			exit(0);
		}
	}
	cout << "Possible\n";
} 

Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, k; cin >> n >> k;
	if (k > (n - 1)*(n - 2) / 2)cout << -1 << endl;
	else
	{
		cout << n - 1 + (n - 1)*(n - 2) / 2 - k << endl;
		for (int i = 2; i <= n; ++i)
		{
			cout << 1 << " " << i << endl;
		}
		int now = (n - 1)*(n - 2) / 2;
		for (int i = 2; now > k&&i < n; ++i)
		{
			for (int j = i + 1; now > k&&j <= n; ++j)
			{
				cout << i << " " << j << endl;
				--now;
			}
		}
	}
}

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

int main(void){

    int N; cin>>N;
    set<int> st;
    for (int i = 0; i < N; ++i) {
        int tmp; cin>>tmp;
        st.insert(tmp);
    }

    cout<<st.size()<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
n=int(input())
A=[]
for i in range(n):
  A.append([int(i) for i in input().split()])
nn=n*(n-1)//2
F=[[0]*(n+1) for _ in range(n+1)]
cur=0
for i in range(1,n):
  for j in range(i+1,n+1):
    F[i][j]=cur
    F[j][i]=cur
    cur+=1
Edge=[[] for _ in range(nn)]
Deg=[0]*nn
for i in range(n):
  s=F[i+1][A[i][0]]
  for j in range(1,n-1):
    t=F[i+1][A[i][j]]
    Edge[s].append(t)
    Deg[t]+=1
    s=t
ans=0
S=[i for i in range(nn) if Deg[i]==0]
D=deque()
DD=deque(S)
while DD:
  D=DD
  DD=deque()
  while D:
    d=D.popleft()
    for g in Edge[d]:
      Deg[g]-=1
      if Deg[g]==0:
        DD.append(g)
        S.append(g)
  ans+=1
print(-1 if len(S)<nn else ans)

Measured memory_bytes: 152332
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef vector <int> vi;
typedef vector <vi> vvi;
#define REP(i,n) for(i=0;i<n;i++)
int K=1024,N=331,B[]={1,2,4,8,16,32,64,128,256,512},C[1024]={0};
vvi D(K,vi(N));
int init(){
	int i,tmp,tmp2,n,dp,i2,j,k;
	REP(i,K){
		REP(j,N)D[i][j]=0;
		tmp=i,tmp2=0,n=0;
		while(tmp){
			n+=tmp&1;
			tmp2++;
			tmp/=2;
		}
		C[i]=n;
		if(n==1)D[i][find(B,B+10,i)-B]=1;
		else{
			tmp=i;
			REP(j,tmp2){
				if(tmp&1){
					dp=n*j,i2=i-B[j];
					REP(k,N-dp)D[i][k+dp]+=D[i2][k];
				}
				tmp/=2;
			}
		}
	}
	return 0;
}
int main(){
	init();
	int n,s,i,x;
	while(1){
		cin>>n>>s;
		if(cin.eof())break;
		x=0;
		if(s<N)
			REP(i,K)if(C[i]==n)x+=D[i][s];
		cout<<x<<endl;
	}
}

Measured memory_bytes: 2328
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int MAX = 200000;
class shuturyoku_unko {
public:
	char C[100], D[100];
	constexpr shuturyoku_unko() : C(), D() {
		for (int i = 10; i < 100; i++) {
			C[i] = '0' + i / 10;
			D[i] = '0' + i % 10;
		}
	}
} f;

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X < 10) {
		*di++ = '0' + X;
		*di++ = '\n';
		return;
	}
	*di++ = '0' + f.C[X];
	*di++ = '0' + f.D[X];
	*di++ = '\n';
}

char S[200010];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = 0;
	char c;
	while ((c = getchar_unlocked()) >= '0') N = N * 10 + c - '0';
	fread(S, 1, 200000, stdin);
	

	int cnt = 0;
	rep(i, N) cnt += S[i] - '0';

	int mod1 = cnt + 1;
	int mod2 = cnt - 1;

	if (cnt == 0) {
		rep(i, N) putint(1);
		fwrite(dn, 1, di - dn, stdout);
		Would you please return 0;
	}
	if (cnt == 1) {
		rep(i, N - 1) putint('1' - S[i]);
		putint(('1' - S[N - 1]) * 2);
		fwrite(dn, 1, di - dn, stdout);
		Would you please return 0;
	}

	ll kazu1 = 0;
	ll kazu2 = 0;
	const ll ma = (1ll << 5) - 1;
	rep(i, N) {
		kazu1 = kazu1 * 2 + (S[i] - '0');
		kazu2 = kazu2 * 2 + (S[i] - '0');
		if (!(i & ma)) {
			kazu1 %= mod1;
			kazu2 %= mod2;
		}
	}
	int k1 = kazu1 % mod1;
	int k2 = kazu2 % mod2;

	int are1 = 1;
	int are2 = 1;
	for (int i = N - 1; i >= 0; i--) {
		if (S[i] == '0') {
			int tmp = k1 + are1;
			if (tmp >= mod1) tmp -= mod1;
			int kotae = 1;
			while (tmp) {
				int k = __builtin_popcount(tmp);
				tmp = tmp % k;
				kotae++;
			}
			S[i] = kotae;
		}
		else {
			int tmp = k2 - are2 + mod2;
			if (tmp >= mod2) tmp -= mod2;
			int kotae = 1;
			while (tmp) {
				int k = __builtin_popcount(tmp);
				tmp = tmp % k;
				kotae++;
			}
			S[i] = kotae;
		}
		are1 *= 2;
		if (are1 >= mod1) are1 -= mod1;
		are2 *= 2;
		if (are2 >= mod2) are2 -= mod2;
	}

	rep(i, N) putint(S[i]);

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
using Graph = vector<vector<ll>>;
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);


int main(){
    ll n;
    cin >> n;
    if(n < 1200) cout << "ABC" << endl;
    else if(n < 2800) cout <<"ARC" << endl;
    else cout <<"AGC" << endl;
}


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

using namespace std;

typedef long long ll;

const int N = 1e2+5;

int n;
bool f[N][6][3];
int p[N][11];

int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= 5; j++){
            for(int k = 1; k <= 2; k++){
                cin >> f[i][j][k];
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= 10; j++){
            cin >> p[i][j];
        }
    }
    ll ans = -2e18;
    for(int mask = 1; mask < (1 << 10); mask++){
        ll cnt = 0 , open = 0;
        for(int i = 1; i <= n; i++){
            ll C = 0;
            for(int j = 0 , X = 1; j < 20; j += 2 , X++){
                C += ( (mask & (1 << j)) > 0 && f[i][X][1]);
                C += ( (mask & (1 << (j + 1))) > 0 && f[i][X][2]);
            }
            if(C >= 1)
                open ++;
            cnt += p[i][C];
        }
        if(open >= 1)
            ans = max(ans , cnt);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3552
#include<cstdio>
    #include<cmath>
    #define mod (1000000007)
    using namespace std;
    int prime[1100],cnt[1100],tot=0;
    int check(int k)
    {
    	for(int i=2;i<=sqrt(k);i++)
    	if(k%i==0) return 0;
    	return 1;
    }
    void work(int k)
    {
    	if(k==1) return;
    	for(int i=1;i<=tot;i++)
    	if(k%prime[i]==0)
    	{
    		cnt[i]++;
    		work(k/prime[i]);
    		break;
    	}
    }
    int main()
    {
    	int n;
    	scanf("%d",&n);
    	if(n==1) {printf("1\n");return 0;}
    	for(int i=2;i<=n;i++)
    	if(check(i)) prime[++tot]=i,cnt[tot]=1;
    	else work(i);
    	long long ans=1;
    	for(int i=1;i<=tot;i++) ans*=(cnt[i]+1),ans%=mod;
    	printf("%lld\n",ans);
    	return 0;
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
  int N;
  cin>>N;
  vector<int> a(N);
  vector<int> b(N);
  vector<int> d(N);
  int suma=0;
  for (int i=0;i<N;i++){
    cin>>a[i];
    suma=suma+a[i];
  }
  int sumb=0;
  for (int i=0;i<N;i++){
    cin>>b[i];
    sumb=sumb+b[i];
    d[i]=a[i]-b[i];
  }  
  if(suma<sumb){
    cout<<-1<<endl;
    return 0;
  }
  sort(d.begin(),d.end());
  int sumd=0;
  int count=0;
  while(d[count]<0){
    sumd=sumd+d[count];
    count++;
  }
  int j=0;
  while(sumd<0){
    sumd=sumd+d[N-1-j];
    j++;
  }
  cout<<count+j<<endl;
  
  return 0;
}

  

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const int maxn = 666;
vector <int> e[maxn];
double dp[maxn][maxn];
int main(void) {
    int n, m; scanf("%d%d",&n,&m);
    for (int i=0;i<m;i++) {
        int u, v; scanf("%d%d",&u,&v);
        e[u].push_back(v);
    }
    dp[n][0]=dp[n][n]=0;
    for (int i=n-1;i>=1;i--) {
        double s=0,mx=0;
        int l = e[i].size();
        for (int j=0;j<l;j++) {
            int v=e[i][j];
            s += dp[v][0];
            mx = max(mx, dp[v][0]);
        }
        dp[i][0] = s/l + 1;
        if (l >= 2) dp[i][i] = (s-mx)/(l-1)+1;
        else dp[i][i] = dp[i][0];
        for (int u=i+1;u<=n;u++) {
            dp[i][u] = dp[i][0];
            double s=0;
            for (int j=0;j<l;j++) {
                int v=e[i][j];
                if (v <= u) s += dp[v][u];
                else s += dp[v][0];
            }
            dp[i][u]=min(dp[i][u], s/l+1);
        }

//        for (int j=0;j<l;j++) printf("%d ",e[i][j]); puts("");
//        printf("i = %d, 0 : %f, 1 : %f\n",i,dp[i][0],dp[i][1]);
    }
    double ans=n+1;
    for (int i=0;i<=n;i++) ans=min(ans, dp[1][i]);
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 4480
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int x;
    double sum=0;
    cin>>x;
    int a[x],b[x];
    for(int i=0;i<x&&cin>>a[i]>>b[i];i++){
    }
    for(int i=0;i<x-1;i++){
       for(int j=i+1;j<x;j++){
          sum+=sqrt((a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j]));
       }
    }
    printf("%.10f",sum*2/x);
}

Measured memory_bytes: 256
q = int(input())
S = set()

for i in range(q):
    query = input()

    # insert
    if query[0] == "0":
        _, x = list(map(int, query.split()))
        S.add(x)
        print(len(S))

    # find
    elif query[0] == "1":
        _, x = list(map(int, query.split()))
        if x in S:
            print(1)
        else:
            print(0)

    # delete
    elif query[0] == "2":
        _, x = list(map(int, query.split()))
        S.discard(x)

    # dump
    else:
        _, L, R = list(map(int, query.split()))
        
        if len(S) > (R - L):
            for i in range(L, R + 1):
                if i in S:
                    print(i)
        else:
            answer = []
            for SItem in S:
                if L <= SItem <= R:
                    answer.append(SItem)

            [print(answerItem) for answerItem in sorted(answer)]




Measured memory_bytes: 23368
S = input()
a = int(S[:2])
b = int(S[2:])

def ismonth(x):
    return 0 < x and x < 13

if ismonth(a) and ismonth(b):
    print("AMBIGUOUS")
elif ismonth(a):
    print("MMYY")
elif ismonth(b):
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	vector<int> x(3);
	rep(i, 3) {cin >> x[i];}
	sort(x.begin(), x.end());
	cout << x[0] + x[1] << endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int a, b;
    cin >> a >> b;

    if (a <= 8 && b <= 8)
        OP("Yay!");
    else
        OP(":(");

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++)
	{
		if (1 <= i && i <= 9) ans++;
		if (100 <= i && i <= 999) ans++;
		if (10000 <= i&&i<=99999) ans++;
	}

	cout << ans << endl;

	return 0;
}


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

N, M = map(int, input().split())

ship = []
keiyu = []

for _ in range(M):
    a, b = map(int, input().split())
    ship.append((a, b))
    if b == N:
        keiyu.append(a)

keiyu = set(keiyu)
for a, b in ship:
    if (a in keiyu and b == 1) or (b in keiyu and a == 1):
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Measured memory_bytes: 33816
function main()
  
  N = parse(Int, readline())
  
  ans = 0
  
  for i in 1:round(Int,sqrt(N))
    
    if N % i == 0
      ans = i
    end

  end
  
  S = split(string(div(N,ans)),"")

  println(length(S))
  
end

main()

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

void solve(long long K, long long N, std::vector<long long> A)
{
    vector<long long> B(N, 0);
    for (int i = 0; i < N - 1; i++)
    {
        B[i] = A[i + 1] - A[i];
    }
    B[N - 1] = K + A[0] - A[N - 1];
    sort(B.begin(), B.end());

    cout << K - B[N - 1] << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long K;
    scanf("%lld", &K);
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(K, N, std::move(A));
    return 0;
}


Measured memory_bytes: 3328