akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using o_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) find_by_order(i)
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vl ft(1, 1LL);

/*======================================================================*/
ll power(ll x, ll y) {
    ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
void solve(){
    fact(2000005);
    int k;
    string s;
    cin >> k >> s;
    int ans = 0, n = s.size();
    rep(i, 0, k+1){
        ans += (ncr(n+k, i+n)*power(25, k-i))%mod;
        if(ans >= mod)ans -= mod;
    }
    cout << ans;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 20872
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N,X,T;
    cin >> N >> X >> T;
    cout << (N+X-1)/X * T << "\n";
    return 0;
}

Measured memory_bytes: 3608
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      int n = int.Parse(Console.ReadLine());
      List<int> a = Console.ReadLine().Split().ToList().ConvertAll(x=>int.Parse(x));
      a.Sort();
      int alice=0;
      int bob=0;
      
      for (int i=0;i<n;i++)
      {
        if (i%2==0)
        {
          alice+=a[i];
        }
        else
        {
          bob+=a[i];
        }
        
      }
      Console.WriteLine(Math.Abs(alice-bob));
    }
}


Measured memory_bytes: 28256
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int N=200;
int c[N], n, m;

int ok() {
    int i;
    for(i=0; i<=m; i++) c[max(i, m-i)]--;
    for(i=1; i<n; i++) {
        if(c[i]<0) return 0;
        if(i<=(m+1)/2 && c[i]>0) return 0;
    }
    return 1;
}

int main() {
    int i, t;
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf("%d", &t);
        c[t]++;
        m=max(m, t);
    }
    printf(ok()? "Possible\n" : "Impossible\n");
    return 0;
}

Measured memory_bytes: 256
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())
    E = int(input())
    print(ceil(N/min([A,B,C,D,E]))+4)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3952
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] line = br.readLine().split(" ");
		
		int h = Integer.parseInt(line[0]);
		int n = Integer.parseInt(line[1]);
		
		line = br.readLine().split(" ");
		br.close();		
		boolean flg = false;
		
		for(String s: line) {
			if((h -= Integer.parseInt(s))<=0) {
				flg=true;
				break;
			}
		}

		if(flg) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		

	}
}


Measured memory_bytes: 33500
n = int(input())
lis=[input() for i in range(n)]
import collections
ans = []
c = collections.Counter(lis)
clis = c.most_common()
for i in range(len(clis)):
    if clis[i][1] == clis [0][1]:
        ans.append(clis[i][0])
ans.sort()
for j in ans:
    print(j)

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

#define INF (2e9)
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

template<class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<ll>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;
using vai = va<ll>;

using pii = pair<ll, ll>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void DumpRow(const T& A) {
    for (const auto& value : A)
        cout << value << "\n";
}

template<class T>
void DumpColumn(const T& A) {
    auto isFirst = true;
    for (const auto& value : A) {
        if (isFirst) {
            cout << value;
            isFirst = false;
        } else {
            cout << " " << value;
        }

    }
    cout << endl;
}

ll SmallerThanWeekP(ll a, ll b, ll c) {
    //if (c <= a) return 1;
    if (7 * a < c) return 7;
    else if (c % a != 0) return ll(c / a) + 1;
    else return c / a;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;

    int n;
    cin >> n;
    auto x = Read(n);
    int  m;
    cin >> m;
    auto a = Read(m);

    REP(i, m) {
        if (x[a[i]-1] + 1 != x[a[i]] && x[a[i]-1] != 2019) x[a[i]-1] += 1;
    }

    DumpRow(x);

    return 0;
}



Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n;
	int mod = 1e9+7;
	cin>>n;
	int arr[(n/3)+1][n+1];
	int sums[n+1];
	memset(sums,0,sizeof(sums));
	memset(arr,0,sizeof(arr));
	for(int i=3;i<=n;i++){
		arr[0][i]=1;
		sums[i] = arr[0][i] + sums[i-1];
	}
	for(int i=1;i<n/3;i++)
	{

		for(int j=3*(i+1);j<=n;j++)
		{
			/*for(int k=3;k<j;k++){
				arr[i][j] = (arr[i-1][j-k] + arr[i][j])%mod;
				if(arr[i-1][j-k]==0)
					break;
			}*/
			arr[i][j] = (arr[i][j] + sums[j-3])%mod;
		}
		for(int k=1;k<=n;k++)
			sums[k]=(sums[k-1] + arr[i][k])%mod;
	}
	/*for(int i=0;i<n/3;i++){
		for(int j=0;j<=n;j++){
			cout<<arr[i][j]<<" ";
		}
	cout<<"\n";}*/
	ll sum=0;
	for(int i=0;i<n/3;i++)
	{
		sum = (sum + arr[i][n])%mod;
	}
	cout<<sum<<"\n";


	
}

Measured memory_bytes: 8604
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int r,d,x2000; cin >> r >> d >> x2000;
  rep(i, 10){
    x2000 = r*x2000-d;
    cout << x2000 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
I=input
r=range
a=[[['']+[0 for i in r(10)]for j in r(3)]for k in r(4)]
for i in r(int(I())):b,f,r,v=map(int,I().split());a[b-1][f-1][r]+=v
f=0
for i in a:
  if f:print('#'*20)
  else:f=1
  for j in i:print(*j)

Measured memory_bytes: 7784
using System;

namespace Character
{
    class Sum_of_Numbers
    {
        static void Main(string[] args)
        {
            var line="";
            while ((line= Console.ReadLine())!="0")
            {
                var array = line.ToCharArray();
                var sum = 0;
                for (int i = 0; i < array.Length; i++)
                    sum += int.Parse(array[i].ToString());
                Console.WriteLine(sum);
            }
        }
    }
}

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

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

	long long int sum = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			sum += i;
		}
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    while(~scanf("%d",&k)) {
        int ans;
        if(k & 1) ans = (k/2) * (k/2+1);
        else ans = k*k/4;
        printf("%d\n",ans); 
    }   
    return 0; 
}

Measured memory_bytes: 256
hw = STDIN.gets
hw.chomp!
hws = hw.split(" ")
H = hws[0].to_i
W = hws[1].to_i
c = Array.new(10, Array.new(10, 0))
cs = Array.new(10, Array.new(10, 0))
w = Array.new(H, Array.new(W, 0))
ws = Array.new(H, Array.new(W, 0))
pow = Array.new(10, 0)
for i in 0..9
  	s = ""
	s = STDIN.gets
  	#puts s + i.to_s
	s.chomp!
	cs[i] = s.split(" ")
  	c[i] = cs[i].map{|a|a.to_i}
  	#puts cs[i].join(' ') + i.to_s
	#for j in 0..9
		#c[i][j] = cs[i][j]#.to_i
	#end
end
#puts c.join(' ')
for i in 0..(H - 2)
	s = STDIN.gets
	s = s.chomp
	ws[i] = s.split(" ")
    w[i] = ws[i].map{|a|a.to_i}
end

s = STDIN.gets
ws[H - 1] = s.split(" ")
w[H - 1] = ws[H - 1].map{|a|a.to_i}

for n in 0..9
	for j in 0..9
		for i in 0..9
			for m in 0..9
				if c[i][j] > c[i][m] + c[m][j]
					c[i][j] = c[i][m] + c[m][j]
				end
			end
		end
	end
end


for i in 0..9
	pow[i] = c[i][1]
end
r = 0
for i in 0..(H - 1)
	for j in 0..(W - 1)
      	if w[i][j] == -1
          
        else
		  r = r + pow[w[i][j]]
        end
	end
end

puts r
#puts pow.join(' ')
#puts w.join(' ')

Measured memory_bytes: 6140
//package atcoder;
 
import java.util.*;
//import java.math.BigDecimal;
 
public class Main{
	static boolean[] targetNumbers;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A[] = new int[3];
		for(int i=0;i<3;i++) {
			A[i] = sc.nextInt();
		}
		int sum = 0;
		for(int j=0;j<3;j++) {
			sum += A[j];
		}
		if(sum>=22) {
			System.out.println("bust");
		}else {
			System.out.println("win");
		}
	}
}

Measured memory_bytes: 21844
A, B, N = map(int,input().split())
def f(x):
    return (A*x)//B-A*(x//B)
"""
for x in range(N+1):
    print(x,f(x))
"""
if B-1 <= N:
    print(f(B-1))
else:
    print(f(N))


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {return find(x) == find(y);}
    int size(int x) {return -d[find(x)];}
};

int main()
{
    int n, m;
    cin >> n >> m;
    int ans = 0;
    vector<int> a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    auto checkUF = [&](int id) {
        UnionFind uf(n);
        rep(i, m) {
            if (i != id) uf.unite(a[i], b[i]);
        }
        if (uf.size(0) != n) ans ++;
    };
    rep(j, m) checkUF(j);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL){
  x=x->left;
  return x;
  }
}

Node treeMaximum(Node x){
  while(x->right!=NIL){
    x=x->right;
    return x;
  }
}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key){
    return u;
  }
  if(k<u->key){
    return treeSearch(u->left,k);
  }
  else{
    return treeSearch(u->right,k);
  }
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL){
    return treeMinimum(x->right);
      }
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  Node a = root;
  if(z->left==NIL || z->right==NIL){
    y=z;
  }
  else{
    y=treeSuccessor(z);
  }
  if(y->left!=NIL){
    x=y->left;
  }
  else{
    x=y->right;
  }
  if(x!=NIL){
    x->parent=y->parent;
  }
  if(y->parent==NIL){
    root = x;
  }
  else if(y == y->parent->left){
      y->parent->left=x;
    }
  else{
    y->parent->right=x;
  }
  if(y!=z){
    z->key=y->key;
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key<y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20484
#include <bits/stdc++.h>
//#include <algorithm>
//#include <stdio.h>
//#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

int a,b,c;

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

	cin>>a>>b>>c;
	cout<<(b-a==c-b?"YES":"NO")<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <cstring>
#include <vector>
#include <climits>
using namespace std;

# define VMAX 100000
#define NMAX 100
#define inf 1e18+3
vector<long long int> w;
vector<long long int> v;
vector<vector<long long int>> dp;
// dp[i][j] is the minimum weight required to carry items with index <= i with value totaling exactly j

long long int find(int i, int val){
    if(dp[i][val]!=-1) return dp[i][val];
    if(val==0){
        dp[i][val] = 0;
        return dp[i][val];
    }
    if(i==0){
        if(v[i]==val){
            dp[i][val] = w[i];
            return dp[i][val];
        }
        else{
            dp[i][val] = inf;
            return dp[i][val];
        }
        
    }
    dp[i][val] = find(i-1,val);
    
    if(v[i]>val){
        return dp[i][val];
    }
    else{
        dp[i][val] = min(find(i-1,val),w[i] + find(i-1,val-v[i]));
        return dp[i][val];
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    while(t--){
        long long int n,k;
        cin >> n >> k;
        w = vector<long long int> (n);
        v = vector<long long int> (n);
        int total_value = 0;
        for(int i=0 ; i<n ; i++){
            cin >> w[i] >> v[i];
            total_value += v[i];
        }
        dp = vector<vector<long long int>> (n,vector<long long int>(total_value+1,-1));
        int output = 0;
        for(int i=0 ; i<=total_value ; i++){ 
            if(find(n-1,i) <= k)
                output = i;
        }
        cout << output << "\n";
    }   
    return 0;
}



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

int main(){
    int N;
    bool flag = false;
    cin >> N;
    long H[N];
    cin >> H[0];
    for(int i=1;i<N;i++){
        cin >> H[i];
        if(H[i-1]<H[i]) H[i]--;
    }

    for(int i=0;i<N-1;i++){
        if(H[i]>H[i+1]){
            flag = true;
            break;
        }
    }
    if(flag) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	for(int i=0; i<3; i++){
		if(n%10 == 7){
			cout << "Yes" << endl;
			return 0;
		}
		n /= 10;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int i=1;
	int flag=0;
	while(i<=9){
		if(n%i==0&&n/i<10){
		cout<<"Yes"<<endl;
		flag=1;
		break;	
	 }
	 i++;
	}
	if(!flag) cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  for (int i = 0; i < N; ++i) cin >> B[i];
  for (int i = 0; i < N; ++i) cin >> C[i];

  sort(A.begin(), A.end());
  sort(C.begin(), C.end());

  long long ans = 0;
  for (int i = 0; i < N; ++i) {
    vector<int>::iterator iterC = upper_bound(C.begin(), C.end(), B[i]);
    vector<int>::iterator iterA = lower_bound(A.begin(), A.end(), B[i]);    
    if (iterC != C.end() && iterA != A.begin()) {
      long long disA = (long long)distance(A.begin(), iterA);
      long long disC = (long long)distance(iterC, C.end());
      ans += disA * disC;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
n = int(input())
a_list = list(map(int,input().split()))
n_len = len(a_list)
left = 0
count = 0
for i in range(1,n+1):
    for j in range(left,n):
        if a_list[j] == i:
            count += 1
            break
    left = j + 1
if count == 0:
    print(-1)
else:
    print(n_len-count)

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

int main()
{
  int a,b;
  cin>>a>>b;
  for(int i=1;i<10001;i++)
  {
      if(int(i*0.08)==a and int(i*0.1)==b)
      {
          cout<<i;
          return 0;
      }
  }
  cout<<"-1"<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N;
int d[200];
bool flg[200] = {};

signed main()
{
	cin >> N;
	
	REP(i, N)
	{
		cin >> d[i];
		flg[d[i]] = true;
	}

	int ans = 0;
	REP(i, 200)
	{
		if (flg[i]) ans++;
	}

	cout << ans << endl;
}



Measured memory_bytes: 888
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;

int N,p[100010];

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

    int i;
    for (i=1; i<=N; i++) cin >> p[i];

    int res=0;
    for (i=N; i>1; i--)
        if (p[i]==i)
            swap(p[i],p[i-1]),res++;

    if (p[1]==1) res++;
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 640
n = int(input())
t, a = map(int, input().split())
h_list = list(map(int, input().split()))
rate = 0.006
dif = 10**10
for i, h in enumerate(h_list):
    if dif > abs(t-rate*h - a):
        ans = i+1
        dif = abs(t-rate*h - a)
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define MAX_A 28
#define MAX_S 500002
int dp[MAX_A][MAX_S];
int dp2[20][MAX_S];
string s;
int S[500002];
int N;
int Q;
int l[100001];
int r[100001];
#define DEBUG if(0)
void init(){
     cin>>s;
     N=s.size();
     REP(i,N){
         S[i]=(s[i]-'a')+1;
     }
     cin>>Q;
     REP(i,Q){
        cin>>l[i]>>r[i];
        l[i]--;
        r[i]--;
     }
     REP(i,MAX_A){
         REP(j,N+2){
             dp[i][j]=N+1;
         }
     }
     REP(i,20){
         REP(j,N+2){
             dp2[i][j]=N+1;
         }
     }
}

void solve(){
     dp[S[N-1]][N-1]=N;
     //各文字のnextを調べる
     for(int i=N-2;i>=0;i--){
         int temp=S[i];
         dp[temp][i]=i+1;
         for(int j=temp+1;j<=26;j++){
             dp[j][i]=dp[j-1][dp[j-1][i]];
         }
         dp[0][i]=dp[26][dp[26][i]];
         //cout<<endl<<"dp[26][i]"<<dp[26][i]<<"dp[26][dp[26][i]]"<<dp[26][dp[26][i]]<<endl;
         if(dp[0][i]<N+1){
            REP(j,temp){
                if(j==0)continue;
                dp[j][i]=dp[j][dp[0][i]];
            }
         }
     }
     /*DEBUG{
      REP(i,N){
         REP(j,27){
             cout<<dp[j][i]<<" ";
         }
         cout<<endl;
     }
     cout<<endl;
     //return ;
     }*/
     //next^2^xを求める
     REP(i,20){
         REP(j,N){
             if(i==0){
                dp2[i][j]=dp[0][j];
                continue;
             }
             dp2[i][j]=dp2[i-1][dp2[i-1][j]];
         }
     }
     DEBUG{
     REP(i,20){
         REP(j,N){
             cout<<" "<<dp2[i][j];
         }
         cout<<endl;
     }
     //return;
     }
     //ここからクエリ処理
     REP(i,Q){
         int temp=l[i];
         for(int j=19;j>=0;j--){
             /*DEBUG{
                cout<<temp<<" "<<j<<" "<<dp2[j][temp]<<endl;
             }*/
             if(dp2[j][temp]<=r[i]+1){
                temp=dp2[j][temp];
             }
         }
         if(temp==r[i]+1){
            cout<<"Yes"<<endl;
         }else{
            cout<<"No"<<endl;
         }
     }
}

int main(){

	init();
	solve();
	return(0);
}

Measured memory_bytes: 97668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
 
const int MAX = 510000;
const int MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
void init_ncr() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
ll ncr(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
 
  ll N,K;cin>>N>>K;
  vector<ll> A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  sort(A.begin(), A.end());
 
  init_ncr();
 
  ll ans=0;
  for(int i=0;i<N;i++){
    if(N-i-1<K-1)break;
    ans += A[N-i-1]%MOD*ncr(N-i-1, K-1)%MOD;
    ans %= MOD;
  }
  for(int i=0;i<N;i++){
    ans -= A[i]%MOD*ncr(N-i-1, K-1)%MOD;
    if(ans<0)ans += MOD;
    ans %= MOD;
  }
  cout<<ans<<endl;
 
  
  return 0;
}

Measured memory_bytes: 15756
#include <stdio.h>

char map[12][13];
int chx[4] = { 1,0,-1,0 };												//4方向チェック用
int chy[4] = { 0,1,0,-1 };												//4方向チェック用

void format(int x, int y);
void hcheck(int x, int y);
int check(void);

int main(void) {
	int i, j;
	char ch[2];
	while (fgets(map[0], 14, stdin)) {
		while (map[0][0] == '\n') {
			fgets(map[0], 14, stdin);
		}
		for (i = 1; i < 12; i++) {
			fgets(map[i], 14, stdin);
		}
		printf("%d\n", check());
		fgets(ch, 1, stdin);
		if (ch[0] == '\n') { getchar(); }
	}
	return 0;
}
int check(void) {
	int i, j, flag, value = 0;
	do {
		flag = 0;
		for (i = 0; i < 12; i++) {										//縦軸
			for (j = 0; j < 12; j++) {									//横軸
				if (map[j][i] == '1') {									//初回のみ処理
					hcheck(j, i);										//マーキング
					value++;
					flag = 1;
				}
			}
		}
	} while (flag != 0);												//処理できなくなるまで繰り返す
	return value;
}
void hcheck(int x, int y) {
	int i, px, py;
	map[x][y] = '0';
	for (i = 0; i < 4; i++) {
		px = x + chx[i], py = y + chy[i];
		if (px < 0 || px > 11) { continue; }							//配列の外は見ない
		if (py < 0 || py > 11) { continue; }							//配列の外は見ない
		if (map[px][py] == '1') { hcheck(px, py); }						//再帰呼び出し
	}
}
void format(int x, int y) {
	int i, j;
	for (i = 0; i < x; i++) {
		for (j = 0; j < y; j++) {
			map[j][i] = '0';
		}
	}
}



Measured memory_bytes: 1940
#include<iostream>
#include<algorithm>
#define MAX 100000
using namespace std;

int n, A[MAX + 1], L[MAX];

int lis(){
	L[0] = A[0];
	int length = 1;

	for(int i = 1; i < n; i++){
		if(L[length - 1] < A[i]){
			L[length++] = A[i];
		}else{
			*lower_bound(L, L + length, A[i]) = A[i];
		}
	}

	return length;
}

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}

	cout << lis() << endl;

	return 0;
}

Measured memory_bytes: 3776
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/abc165/tasks/abc165_c

import numpy as np
from itertools import combinations_with_replacement

# def create_list(tmp_anslist, zan_length, zan_num_list):
#     if zan_length == 0:
#         anslist_candidates.append(tmp_anslist)
#         return
#     
#     for i, num in enumerate(zan_num_list):
#         more_zan_num_list = zan_num_list[i:]
#         create_list(tmp_anslist + [num], zan_length-1, more_zan_num_list)

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

# abcd_array = np.empty((Q, 4), dtype=int)
abcd_array = []
for i in range(Q):
    abcd = map(int, input().split())
    abcd_array.append(list(abcd))
# print(abcd_array)

# anslist_candidates = []
# create_list([], N, [ax for ax in range(1, M+1)])
# print(anslist_candidates)

anslist_candidates = combinations_with_replacement(range(1, M+1), N)


max_anslist_score = 0
for tmp_anslist in anslist_candidates:
    sum_d = 0

    is_valid_anslist = True
    prev_ansitem = tmp_anslist[0]
    for ansitem in tmp_anslist[1:]:
        if prev_ansitem > ansitem:
            is_valid_anslist = False
            break
    if not is_valid_anslist:
        continue

    for ai, bi, ci, di in abcd_array:
        #print('ai:%d, bi:%d, ci:%d, di:%d' % (ai, bi, ci, di))
        #print('tmp_anslist:%s' % (tmp_anslist))
        if ((tmp_anslist[bi-1] - tmp_anslist[ai-1]) == ci):
            sum_d += di
    #print('%s : %d' % (tmp_anslist, sum_d))
    max_anslist_score = max(max_anslist_score, sum_d)

print(max_anslist_score)


Measured memory_bytes: 27148
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                                #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<int,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                  #define VI vector<int>
                                        using namespace std;
                                        
                                  class pas{
                                    	public:
                                    	int x,y;
                                    	pas(int x=0,int y=0):x(x),y(y) {}
                                    	pas operator + (pas p) {return pas(x+p.x,y+p.y);}
                                    	pas operator - (pas p) {return pas(x-p.x,y-p.y);}
                                    	pas operator * (int a) {return pas(x*a,y*a);}
                                    	pas operator / (int a) {return pas(x/a,y/a);}
                                    //	double absv() {return sqrt(norm());}
                                    	int norm() {return x*x+y*y;}
                                    	bool operator < (const pas &p) const{
                                    		return x != p.x ? x<p.x: y<p.y;
                                    	}
                                    	bool operator == (const pas &p) const{
                                    		return x==p.x && y==p.y;
                                    	}
                                    };

int n,h;
int a[100030],b[100030];
           signed main(){
   	//	int pr[3];
set<int> se;
           	cin>>n;
           	
           	for(int i=0;i<n;i++){
           	cin>>h;
           		se.insert(h);
           	}
           	cout<<se.size()<<endl;
           }
             

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,n,t,i;
  cin >> n;
  for(i=0;i<n;i++)
   {
      cin >> a >> b >> c;
      if(a>b)
       {
          t = a;
          a = b;
          b = t;
       }
      if(a>c)
       {
          t = a;
          a = c;
          c = t;
       }
      if(b>c)
       {
          t = b;
          b = c;
          c = t;
       }
     if(a*a + b*b == c*c)
         cout << "YES" << endl;
     else
         cout << "NO"  << endl;
    }
   return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll X;
    cin >> X;
    rep2(i, -200, 200) {
        rep2(j, -200, 200) {
            ll A = i * i * i * i * i;
            ll B = j * j * j * j * j;
            if (A - B == X) {
                cout << i << " " << j << '\n';
                return;
            }
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

sys.setrecursionlimit(10 ** 7)


MOD = 1000000007  # type: int


def solve(N: int, M: int, a: "List[int]"):
    ways_to_stairs = {}
    stairs = []
    for i in range(N + 1):
        stairs.append(True)
    for i in a:
        stairs[i] = False

    routes_to_stairs = {0: 1}
    if 1 not in a:
        routes_to_stairs[1] = 1

    for i in range(N + 1):
        if i <= 1:
            continue
        ways = 0
        if stairs[i]:
            if stairs[i - 1]:
                ways += routes_to_stairs[i - 1]
            if stairs[i - 2]:
                ways += routes_to_stairs[i - 2]
        routes_to_stairs[i] = ways

    print(routes_to_stairs[N] % MOD)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, a)

if __name__ == '__main__':
    main()


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

int main()
{
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A), t(B);
    for(int i = 0;i < A;i++){
        cin >> s[i];
    }
    for(int i = 0;i < B;i++){
        cin >> t[i];
    }
    while(Q--){
        ll x;
        cin >> x;
        auto ns = lower_bound(s.begin(), s.end(), x);
        auto nt = lower_bound(t.begin(), t.end(), x);
        auto ps = upper_bound(s.begin(), s.end(), x);
        auto pt = upper_bound(t.begin(), t.end(), x);
        ll res = LLONG_MAX;
        if(ns != s.end() && nt != t.end()){
            res = min(res, max(*ns, *nt) - x);
        }
        if(ns != s.end() && pt != t.begin()){
            auto mt = prev(pt);
            res = min(res, *ns - *mt + min(*ns - x, x - *mt));
        }
        if(ps != s.begin() && nt != t.end()){
            auto ms = prev(ps);
            res = min(res, *nt - *ms + min(*nt - x, x - *ms));
        }
        if(ps != s.begin() && pt != t.begin()){
            auto mt = prev(pt);
            auto ms = prev(ps);
            res = min(res, x - min(*mt, *ms));
        }
        printf("%lld\n", res);
    }
    return 0;
}


Measured memory_bytes: 2944
#[allow(dead_code)]
fn main() {
    let mut i1 = i::i();
    let mut i2 = i::i();
    let mut i3 = i::i();

    let mut num5 = 0;
    let mut num7 = 0;
    if (i1==5) {
        num5+=1;
    }
    if (i1==7) {
        num7+=1;
    }
    if (i2==5) {
        num5+=1;
    }
    if (i2==7) {
        num7+=1;
    }
    if (i3==5) {
        num5+=1;
    }
    if (i3==7) {
        num7+=1;
    }
    if (num5==2&&num7==1){
        println!("YES");
    }else{
        println!("NO");
    }
}


#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn strv(n: usize) -> Vec<String> {
        (0..n).map(|_| str()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 2116
//AtCoder ABC110 C - String Transformation
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main() {
    string S,T; cin>>S>>T;
    unordered_map<char,char> tbl; //変換 b,a
    unordered_map<char,char> tbl2; //a,b
    unordered_set<char> fixed; //決まったやつ
    bool ans=true;
    for(ll i=0;i<S.size();++i){
        vector<char> sw(2);
        auto a=S[i];
        auto b=T[i];
        auto itb=tbl.find(b);  //tが一致でsが違う場合不可
        if(itb!=tbl.end()&&itb->second!=a){
            ans=false;
            break;
        }
        auto ita=tbl2.find(a);
        if(ita!=tbl2.end()&&ita->second!=b){
            ans=false;
            break;
        }
        tbl.insert(make_pair(b,a));
        tbl2.insert(make_pair(a,b));
        //tbl.insert(make_pair(a,b));
        //tbl.insert(make_pair(b,a));
        //fixed.insert(b);
    }   
    cout<<(ans?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 776
from math import gcd
from functools import reduce

n,m=map(int,input().split())
lst=list(map(lambda x : int(x)//2,input().split()))
divi=0
x=lst[0]
while x%2==0:
    x//=2
    divi+=1

for i in range(1,n):
    divi2=0
    x=lst[i]
    while x%2==0:
        x//=2
        divi2+=1
    if divi!=divi2 :
        print(0)
        exit()

work=reduce(lambda x,y: x*y//gcd(x,y),lst)
print((m//work+1)//2)

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

int main(){
  int n, a[100009], prev=0, sm=0;
  memset(a, 0 , sizeof(a));
  cin >> n;
  for(int i=1;i<=n;i++){
    cin >> a[i];
    sm += abs(a[i] - a[i-1]);
  }
  sm += abs(a[n]);
  for(int i=1;i<=n;i++){
    cout << sm - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]) << endl;
  }
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	ll h,n;
	cin >> h >> n;
	vector <ll> a(n);
	ll sum = 0;
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		sum+= a[i];
	}
	if (sum >= h) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug(){
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

long long lp[M], cnt[M];
vector<long long> pr;

int main(){
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long n, all_gcd = 0; cin >> n;

    vector<long long> a(n);

    for(long long i = 0; i < n; i++){
        cin >> a[i];
        all_gcd = __gcd(all_gcd, a[i]);
    }
    
    for(long long i = 2; i < M; i++){
        if(!lp[i]){
            lp[i] = i;
            pr.append(i);
        }
        for(long long j = 0; j < ll(pr.size()) && pr[j] <= lp[i] && i * 1ll * pr[j] < M; j++){
            lp[i * 1ll * pr[j]] = pr[j];
        }
    }
    
    for(long long i = 0; i < n; i++){
       	long long k = a[i];
        while(k > 1){
       		long long dv = lp[k];
            cnt[dv]++;
           	while(k % dv == 0){
           		k /= dv;
           	}
        }
    }
	
    long long ans = (all_gcd == 1 ? 1 : 0);
    
    for(long long i = 1; i < M; i++){
        if(cnt[i] > 1){
            ans = (all_gcd == 1 ? 2 : 0);
            break;
        }
    }
    
    if(!ans) cout << "not coprime"; 
    else if(ans == 1) cout << "pairwise coprime";
    else cout << "setwise coprime";
    
    return 0;
}


Measured memory_bytes: 27172
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  int key;
  Node *right, *left,* parent;
};
Node *root,*NIL;
Node * find(Node *u,int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;
}

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;
  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root = z;
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}

void inorder(Node *u){
  if(u==NIL) return ;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u==NIL) return ;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  string com;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    cin >> com;
    if(com[0]=='f'){
      scanf("%d",&x);
      Node *t = find(root, x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }else if(com=="insert"){
      scanf("%d", &x);
      insert(x);
    }else if(com=="print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}


Measured memory_bytes: 21964
#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>;

int main() {
  ll n, k;
  cin >> n >> k;
  ll a = n%k;
  ll ans = min(a, k-a);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256