akhauriyash/Code-Regression huggingface dataset:
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return
    if self.parents[x] > self.parents[y]:
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x
  def size(self, x):
    return -self.parents[self.find(x)]
  def same(self, x, y):
    return self.find(x) == self.find(y)
  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]
  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]
  def group_count(self):
    return len(self.roots())
  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}
  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
N,M=map(int,input().split())
U=UnionFind(N)
for m in range(M):
  a,b=map(int,input().split())
  U.union(a-1,b-1)
ans=0
for i in U.roots():
  ans=max(ans,U.size(i))
print(ans)

Measured memory_bytes: 18460
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

struct UnionFind {
    vector<int> r;

    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

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

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

    int size(int x) {
        return -r[root(x)];
    }

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

int main()
{
    int n; cin >> n;
    vector<ll> t(n);
    rep(i,n) cin >> t[i];
    ll ans = t[0];
    rep1(i,n) {
        ans = lcm(ans, t[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n%2==0){cout<<n/2-1<<endl;}
  else{cout<<n/2<<endl;}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


void solve(){
  int N,K; cin >>N >>K;
  vector<ll> X(N),Y(N);
  vector<bool> black(N);
  rep(i, N){
    char c; cin >>X[i] >>Y[i] >>c; black[i] = c == 'B'; 
  }
  rep(i, N){ X[i] = X[i] % (2*K) + 2*K; Y[i] = Y[i] % (2*K) + 2*K; }
  vector<vector<ll>> field(6*K, vector<ll>(5*K, 0));
  // 黒の左上頂点がここなら条件がこれだけ叶うよー
  for (int i=0; i<N; i++){
    int hosei = 0;
    if (!black[i]) hosei = K;
    field[X[i]-K+1 + hosei][Y[i]-K+1]++;
    field[X[i]-K+1 + hosei][Y[i]+1]--;
    field[X[i]+1 + hosei][Y[i]-K+1]--;
    field[X[i]+1 + hosei][Y[i]+1]++;
  }
  // 累積和
  for (int x=0; x<field.size(); x++){
    for (int y=1; y<field[0].size(); y++){
      field[x][y] += field[x][y-1];
    }
  }
  for (int y=0; y<field[0].size(); y++){
    for (int x=1; x<field.size(); x++){
      field[x][y] += field[x-1][y];
    }
  }
  // 情報を2*N, 2*Nのアレにまとめる
  for (int x=0; x<field.size(); x++){
    for (int y=0; y<field[0].size(); y++){
      if (x < 2*K && y < 2*K) continue;
      field[x%(2*K)][y%(2*K)] += field[x][y];
      field[x][y] = 0;
    }
  }
  // 情報を2*N, N のアレにまとめる
  for (int x=0; x<2*K; x++){
    for (int y=0; y<2*K; y++){
      if (x < 2*K && y < K) continue;
      field[(x+K)%(2*K)][y-K] += field[x][y];
      field[x][y] = 0;
    }
  }
  ll res = 0;
  for (int x=0; x<2*K; x++){
    for (int y=0; y<K; y++){
      chmax(res, field[x][y]);
    }
  }
  cout <<res <<endl;
}

int main() {
  solve();
}

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

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int ans = min(A, K);
    K -= A;

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

    K -= B;

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

    ans -= K;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
// 2020-07-25 20:59:52
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int x;
  cin >> x;
  int ans = 0;
  if(400 <= x && x < 600) {
    ans = 8;
  } else if(600 <= x && x < 800) {
    ans = 7;
  } else if(800 <= x && x < 1000) {
    ans = 6;
  } else if(1000 <= x && x < 1200) {
    ans = 5;
  } else if(1200 <= x && x < 1400) {
    ans = 4;
  } else if(1400 <= x && x < 1600) {
    ans = 3;
  } else if(1600 <= x && x < 1800) {
    ans = 2;
  } else if(1800 <= x && x < 2000) {
    ans = 1;
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3636
attrs = $stdin.gets.chomp.split(' ').map(&:to_i)
N = attrs[0]
first_num = attrs[1] - N + 1
size = N * 2 - 1
i = 0
res = []
while i < size
  res << first_num + i
  i += 1
end

print res.join(' ')

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define int long long
#define ld long double
#define sb __builtin_popcount
#define vi vector<int>
#define vc vector<char>
#define ii pair<int, int>
#define pq priority_queue<ii, vector<ii>, greater<ii>>
#define vii vector<ii>
#define sz(a) int((a).size())
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <=n; i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define in(a, b) (b.find(a) != string::npos)
#define minin(a) *min_element(all(a))
#define maxin(a) *max_element(all(a))
#define X first
#define Y second
#define fill(a, x) memset(a, x, sizeof(a))
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define rall(v) reverse(v.begin(), v.end())
#define el "\n"
#define mx3(a, b, c) max(max(a, b), c)
#define mn3(a, b, c) min(min(a, b), c)
#define S(v) accumulate(all(v), (ll)0)
#define SP(n) cout.precision(n)
#define PI = atan(1.0) * 4.0;
#define MOD = 1e9 + 7;
void start() {
    fio;
    SP(10);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {
    start();
    int n, m, k;
    cin >> n >> m >> k;

    char c[n][m];
    int has = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> c[i][j];
            if (c[i][j] == '#')has++;
        }
    }
    int x, ind = 0, ans = 0;
    for (int i = 1; i <= pow(2, n); i++) {
        map<int, int> r;
        x = i;
        ind = 0;
        while (x > 0) {
            if (x % 2)r[ind]++;
            ind++;
            x /= 2;
        }
        for (int j = 1; j <= pow(2, m); j++) {
            map<int, int> cc;
            x = j;
            ind = 0;
            while (x > 0) {
                if (x % 2)cc[ind]++;
                ind++;
                x /= 2;
            }
            int cnt = 0;
            for (int k1 = 0; k1 < n; k1++) {
                for (int k2 = 0; k2 < m; k2++) {
                    if (r[k1] > 0 || cc[k2] > 0) {
                        if (c[k1][k2] == '#')
                            cnt++;
                    }
                }
            }
            if ((has - cnt) == k) {
                ans++;
                //cout << cnt << " " << i << " " << j << el;
            }
        }
    }
    cout << ans << el;
    return 0;
}


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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
#define DRT() int t; si(t); while(t--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//# define M_PI           3.14159265358979323846264338327950288
// DSU
void IO(){
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
}
int h,w,k;
vector< vector< char> > g;
vector< set<int> > sub1;
vector< set<int> > sub2;
void generate(int pos, set<int> formed){
	if(pos == h){
		sub1.PB(formed);
		return ;
	}
	formed.insert(pos);
	generate(pos+1, formed);
	formed.erase(pos);
	generate(pos+1, formed);
}
void generate2(int pos, set<int> formed){
	if(pos == w){
		sub2.PB(formed);
		return ;
	}
	formed.insert(pos);
	generate2(pos+1, formed);
	formed.erase(pos);
	generate2(pos+1, formed);
}
int main(){
	IO();
	cin>>h>>w>>k;
	g.resize(h, vector<char> (w));
	rep(i,0,h){
		rep(j,0,w){
			cin>>g[i][j];
		}
	}
	set<int> formed1;
	generate(0,formed1);
	set<int> arr;
	generate2(0, arr);
	LL ans = 0;
	for(auto a : sub1){
		for(auto b : sub2){
			// a- > rows, b -> columns
			int cnt = 0;
			rep(i,0,h){
				if(a.find(i) != a.end())
					continue;
				rep(j,0,w){
					if(b.find(j) != b.end())
						continue;
					if(g[i][j] == '#')
						cnt++;
				}
			}
			if(cnt == k)
				ans++;
		}
	}
	cout<<ans;
	return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main ()
{
    fastio
    lli num , cnt = 1 , m = 0 ;
    cin >> num ;
    lli a[num] ;
    loopcin(num , a) ;
    m = a[0] ;
    forr(1 , num) {
        if (a[i] >= m){
            cnt ++ ;
            m = a[i] ;
        }
    }

    cout << cnt << endl ;
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;


public class Main {
    public static void main(final String[] args){
        final Scanner s = new Scanner(System.in);
        final int N = Integer.parseInt(s.next());
        final int M = Integer.parseInt(s.next());
        final int X = Integer.parseInt(s.next());
        //final HashSet<Integer> bookInfo= new HashSet<Integer>();
        final HashMap<Integer,ArrayList<Integer>> bookList= new HashMap<Integer,ArrayList<Integer>>();
       for(int i = 0;i<N;i++){
        ArrayList<Integer> bookInfo= new ArrayList<Integer>();
            for( int i2=0; i2<M+1; i2++){
                bookInfo.add(Integer.parseInt(s.next()));
            } 
        bookList.put(i,bookInfo);
       }
       //long price =999999999;
       long price =-1;
       //ビット全検索
       for(int Mnum=0;Mnum<(1<<N);Mnum++){
           int tmpPrice = 0;
           int testFirst =0;
           ArrayList<Integer> targetBookInfo;
            for (int j=0; j<N; j++) {
                //ビットが１かの確認
                if ((1 & Mnum>>j) == 1) {
                        //アルゴリズムA1の習熟度だけ調査
                        targetBookInfo = bookList.get(j);
                        Iterator<Integer> hoge = targetBookInfo.iterator();
                        tmpPrice += hoge.next();
                        testFirst += hoge.next();
                };
            }
            //PA1の習熟度が十分な場合,あと安いとき、あるいはまだ値段が初期値のとき.本格的な計算
            if(testFirst >= X && (price == -1 || tmpPrice<price)  ){
                boolean Hoge = false;
                int argoChecker=0;
                //一つの学習度に着目して
                for(int targetArgo = 2;targetArgo <M+1;targetArgo++){
                    //bitが１かの確認
                    for (int j=0; j<N; j++) {
                        if ((1 & Mnum>>j) == 1) {
                            argoChecker += bookList.get(j).get(targetArgo);
                        }
                    }
                    //学習度がXを超えてるかの確認
                    if(argoChecker <X){
                        argoChecker=0;
                        Hoge = true;
                        break;
                    }else{
                        argoChecker=0;
                    }
                }
                //無事全条件をクリアしたので更新
                if(Hoge ==false){
                    price = tmpPrice;
                }
            }
        }
    System.out.println(price);
    }
}

Measured memory_bytes: 38436
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath> // sqrt
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

static vector<string> ans;
void dfs(string& str, int num, int pos, char mmax) {
    if(num == pos) {
        ans.push_back(str);
        return;
    }
    for(char ch = 'a'; ch <= mmax+1; ch++) {
        str.push_back(ch);
        dfs(str, num, pos+1, max(ch, mmax));
        str.pop_back();
    }
    return;
}

int main(void) {
    int num;
    cin >> num;

    string str;
    str.push_back('a');
    dfs(str, num, 1, 'a');

    debug("size: %d\n", ans.size());
    for(string& s: ans) {
        cout << s << endl;
    }
    return 0;
}

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

using namespace std;

int n, m;
const int N = 1e5 + 7;

int main() {
    std :: ios :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int ans;
    for(int i = 1 ; i <= 5 ; ++i) {
        int p;
        cin >> p;
        if(p == 0) ans = i;
    }
    cout << ans << endl;
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
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;}
ll mod = 1000000007;

int main(){
  ll n;
  cin >> n;
  vvll p(n, vll(3));
  vrep(vec, p) vin(vec);
  vvll dp(n + 1,vll(3, 0));
  rep(i, 1, n + 1)rep(j, 0, 3)rep(k, 0, 3)if(j != k) chmax(dp.at(i).at(j), p.at(i - 1).at(j) + dp.at(i - 1).at(k));
  ll res = 0;
  rep(i, 0, 3) chmax(res, dp.at(n).at(i));
  cout << res << endl;
}

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

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

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

int K;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> K;
    int res = 0;
    for (int i = 1; i <= K; ++i) {
      for (int j = 1; j <= K; ++j) {
        for (int k = 1; k <= K; ++k) {
          res += gcd(gcd(i, j), k);
        }
      }
    }
    cout << res << endl;
    
    return 0;
}


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

int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    if (x-r>=0){
        if (x+r<=W){
            if(y-r>=0){
                if(y+r<=H){
                    cout << "Yes" << endl;
                }
                else{
                    cout << "No" << endl;
                }
            }
            else{
                cout << "No" << endl;
            }
        }
        else{
            cout << "No" << endl;
        }
    }
    else{
        cout << "No" << endl;
    }
    
    return 0;
}




Measured memory_bytes: 3096
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let number: i32 = read();
  
    if (number < 10 && number > 0)
    {
      println!("Yes");
      return;
    }

    for i in 2..10
    {
      if (number % i == 0 && number / i <= 9)
      {
        println!("Yes");
        return;
      }
    }

    println!("No");
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125252];
int v[125252];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  REP(i,n){
    int x = a[i];
    if(x>0)v[x-1]++;
    v[x]++;
    v[x+1]++;
  }
  int ans = 0;
  REP(i,125252)CHMAX(ans,v[i]);
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
#a,b,c = [0]*n,[0]*n,[0]*n
list_act = [[0 for i in range(3)] for j in range(n)]

#list_act_2 = [[0 for i in range(n)] for j in range(3)]
'''
for j in range(n):
    list_act_2[j][0],list_act_2[j][1],list_act_2[j][2] = list(map(int,input().rstrip().split(' ')))

print(list_act_2)
'''

for j in range(n):
    #list_act[day][act]

    #list_act[0][j],list_act[1][j],list_act[2][j] = list(map(int,input().rstrip().split(' ')))
    list_act[j][0],list_act[j][1],list_act[j][2] = list(map(int,input().rstrip().split(' ')))

#list_act_to_yesterday = [list_act[0][0],list_act[1][0],list_act[2][0]]
list_act_to_yesterday = [list_act[0][0],list_act[0][1],list_act[0][2]]

#list_act_to_today = [-1]*3
list_act_to_today = [-1,-1,-1]

import numpy as np

for day in range(1,n):
    for act in range(3):
        acts_yes = [0,1,2]
        del acts_yes[act]
        lst = np.array(list_act_to_yesterday)

        list_act_to_today[act] = max(list_act_to_yesterday[act_yes] for act_yes in acts_yes) + list_act[day][act]
    #list_act_to_yesterday  = list_act_to_today
    list_act_to_yesterday = [list_act_to_today[0],list_act_to_today[1],list_act_to_today[2]]

ans = max(list_act_to_yesterday[act] for act in range(3))

print(ans)

Measured memory_bytes: 33536
N, A, B, C = [int(x) for x in input().split()]
ABC = [A, B, C]
total = [0, 0, 0]
cnt = [0, 0, 0]
T = [int(input()) for _ in range(N)]


def calc():
    if min(cnt) <= 0: return 1e10
    return sum([abs(ABC[i] - total[i]) + (cnt[i] - 1) * 10 for i in range(3)])


def f(i):
    if i >= N: return calc()

    res = 1e10
    for j in range(3):
        total[j] += T[i]
        cnt[j] += 1
        res = min(res, f(i + 1))
        total[j] -= T[i]
        cnt[j] -= 1

    return min(f(i + 1), res)


print(f(0))


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

int main()
{
    int n;
    cin>>n;
    
    char s[101];
    char t[101];
    cin>>s>>t;
    
    std::vector<char> v;
    for(int i=0;i<n;i++){
        v.push_back(s[i]);
        v.push_back(t[i]);
    }
    
    for(auto x:v)
      cout<<x;
      cout<<"\n";
    return 0;
}

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

int parent(int i)
{
    return i / 2;
}
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }

int main()
{
    int H, i, A[MAX + 1];

    cin >> H;
    for (i = 1; i <= H; i++)
    {
        cin >> A[i];
    }

    for (i = 1; i <= H; i++)
    {
        cout << "node " << i << ": key = " << A[i] << ", ";
        if (parent(i) >= 1)
        {
            cout << "parent key = " << A[parent(i)] << ", ";
        }
        if (left(i) <= H)
        {
            cout << "left key = " << A[left(i)] << ", ";
        }
        if (right(i) <= H)
        {
            cout << "right key = " << A[right(i)] << ", ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s1, s2;
	cin >> s1 >> s2;
	reverse(s1.begin(), s1.end());
	if (s1 == s2) {
		cout << "YES" << endl;

	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
<?php
list($N, $M) = ints();
$A = ints();
rsort($A);
$sum = array_sum($A);
if($A[$M-1]*4*$M>=$sum){
    echo "Yes";
}else{
    echo "No";
}

function str(){return trim(fgets(STDIN));}
function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$N = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


Measured memory_bytes: 4604
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
using namespace std;

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

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;

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

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>
 
int main(void) {
    char str[1001], w[11];
    int ans;
    int i;
     
    scanf("%s", w);
     
    for (i = 0; str[i] != '\0'; i++) str[i] = tolower(str[i]);
     
    ans = 0;
    while (scanf("%s", str), strcmp(str, "END_OF_TEXT")) {
        for (i = 0; str[i] != '\0'; i++) str[i] = tolower(str[i]);
         
        if (strcmp(str, w) == 0) ans++;
    }
    printf("%d\n", ans);
     
    return 0;
}


Measured memory_bytes: 2112
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

int main(){

	int N,price_bath,price_pool,num_bath,num_pool,normal,discount;

	scanf("%d",&N);

	for(int i = 0; i < N; i++){
		scanf("%d %d %d %d",&price_bath,&price_pool,&num_bath,&num_pool);

		normal = price_bath*num_bath + price_pool*num_pool;

		if(num_bath >= 5 && num_pool >= 2){
			discount = (normal/10)*8;
		}else if(num_bath >= 5 && num_pool < 2){
			discount = ((normal + (2-num_pool)*price_pool)/10)*8;
		}else if(num_bath < 5 && num_pool >= 2){
			discount = ((normal + (5-num_bath)*price_bath)/10)*8;
		}else{
			discount = ((normal + (5-num_bath)*price_bath + (2-num_pool)*price_pool)/10)*8;
		}
		printf("%d\n",min(normal,discount));
	}
	return 0;
}

Measured memory_bytes: 2684
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include <cstdio>
#include <complex>
#include <queue>
#include <cstring>

using namespace std;

const int N = 100000 + 5;

int X, Y, Z;
int a[N][3];
int id[N];
long long ans;
priority_queue<pair<int, int>> que[3][3];

void change(int i, int to)
{
    id[i] = to;
    for(int j = 0; j < 3; ++ j) {
        if (j == id[i]) continue;
        que[id[i]][j].push(make_pair(a[i][j] - a[i][id[i]], i));
    }
}

void clear(int me, int you) {
    for( ; que[me][you].size();) {
        int x = que[me][you].top().second;
        if (id[x] != me) que[me][you].pop();
        else break;
    }
}

void solve()
{
    cin >> X >> Y >> Z;
    ans = 0;
    for(int i = 0; i < X + Y + Z; ++ i) {
        for(int j = 0; j < 3; ++ j) scanf("%d", &a[i][j]);
        if (i < X) id[i] = 0;
        else if (i < X + Y) id[i] = 1;
        else id[i] = 2;
        ans += a[i][id[i]];
        for(int j = 0; j < 3; ++ j) {
            if (j == id[i]) continue;
            que[id[i]][j].push(make_pair(a[i][j] - a[i][id[i]], i));
        }
    }

    int flag = true;
    while(flag) {
        flag = false;
        for(int me = 0; me < 3; ++ me) {
            int you = (me + 1) % 3;
            clear(me, you);
            clear(you, me);

            if (que[me][you].size() && que[you][me].size()) {
                long long delta = que[me][you].top().first + que[you][me].top().first;
                if (delta > 0) {
                    flag = true;
                    ans += delta;
                    int u = que[me][you].top().second;
                    int v = que[you][me].top().second;
                    change(u, you);
                    change(v, me);
                }
            }
        }

        clear(0, 1); clear(1, 2); clear(2, 0);
        if (que[0][1].size() && que[1][2].size() && que[2][0].size()) {
            long long delta = (long long)que[0][1].top().first + que[1][2].top().first + que[2][0].top().first;
            if (delta > 0) {
                flag = true;
                ans += delta;
                int u = que[0][1].top().second;
                int v = que[1][2].top().second;
                int w = que[2][0].top().second;
                change(u, 1); change(v, 2); change(w, 0);
            }
        }

        clear(0, 2); clear(2, 1); clear(1, 0);
        if (que[0][2].size() && que[2][1].size() && que[1][0].size()) {
            long long delta = (long long)que[0][2].top().first + que[2][1].top().first + que[1][0].top().first;
            if (delta > 0) {
                flag = true;
                ans += delta;
                int u = que[0][2].top().second;
                int v = que[2][1].top().second;
                int w = que[1][0].top().second;
                change(u, 2); change(v, 1); change(w, 0);
            }
        }
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 4724
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <cstring>

using namespace std;

class Solution {
private:
public:
};

int main() {
    int n;
    cin >> n;
    int members[n + 1];
    memset(members, 0, sizeof(members));
    for(int i = 1; i < n; ++i) {
        int boss = -1;
        cin >> boss;
        ++members[boss];
    }
    //output
    for(int i = 1; i <= n; ++i) cout << members[i] << endl;
}

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



int main()
{
	int n;
	string s,t;
	cin>>n;
	cin>>s>>t;
	string tmp="";
	for(int i=0;i<n;i++)
	{
		tmp+=s[i];
		tmp+=t[i];
	}
	cout<<tmp<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

const int mod = 1000000007;

struct mint{
  ll x;
  mint(ll x = 0):x((x % mod + mod) % mod){};
  mint pow(ll y) const {
    mint res(1);
    mint a(x);
    while(y>0){
      if(y&1) res *= a;
      a *= a;
      y >>= 1;
    }
    return res;
  }
  mint inv() const{ return pow(mod-2); }
  mint& operator+= (const mint a) noexcept {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-= (const mint a) noexcept {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*= (const mint a) noexcept {
    (x *= a.x) %= mod;
    return *this;
  }
  mint& operator/= (const mint a) noexcept {
    return (*this) *= a.inv();
  }
  mint operator+ (const mint a) const noexcept {
    mint res(*this);
    return res += a;
  }
  mint operator- (const mint a) const noexcept {
    mint res(*this);
    return res -= a;
  }
  mint operator* (const mint a) const noexcept {
    mint res(*this);
    return res *= a;
  }
  mint operator/ (const mint a) const noexcept{
    mint res(*this);
    return res /= a;
  }
};

ostream& operator<<(ostream& stream, const mint& n){
  stream << n.x;
  return stream;
};

struct comb{
  vector<mint> fact, ifact;
  comb(int n): fact(n+1), ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k) const noexcept{
    if(k < 0 || n < k) return 0;
    return fact[n] * ifact[k] * ifact[n-k];
  }
};

mint dp[100005];

int main(void){
  ll n, m;
  cin >> n >> m;
  set<ll> a;
  REP(i, m){
    ll b;
    cin >> b;
    a.insert(b);
  };

  dp[0] = 1;
  REP(i, n){
    if(a.count(i+1) == 0) dp[i+1] += dp[i];
    if(a.count(i+2) == 0) dp[i+2] += dp[i];
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 8988
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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


	cin >> N;
	int A, B, C;
	cin >> A >> B >> C;
	if (B & 1) {
		cout << 0 << endl;
		return 0;
	}
	B /= 2;
	vector<long long int>by(N + 1, 1);
	vector<long long int>rev(N + 1, 1);
	for (int i = 1; i <= N; i++) {
		by[i] = by[i - 1] * i;
		by[i] %= MOD;
		rev[i] = power(by[i], MOD - 2, MOD);
	}
	long long int ans = by[A + B] * rev[A];
	ans %= MOD;
	ans *= rev[B];
	ans %= MOD;
	//cout << ans << endl;
	long long int ansby = 0;
	for (int i = 0; i <= C; i += 3) {
		for (int j = 0; j <= A; j++) {
			int box = C - i - j;
			if (box < 0)continue;
			if (!B&&box)continue;
			long long int add = 0;
			add = by[A] * rev[j];
			add %= MOD;
			add *= rev[A - j];
			add %= MOD;
			add *= by[A + B + i / 3];
			add %= MOD;
			add *= rev[A + B];
			add %= MOD;
			add *= rev[i / 3];
			add %= MOD;
			if (box) {
				add *= by[B - 1 + box];
				add %= MOD;
				add *= rev[B - 1];
				add %= MOD;
				add *= rev[box];
				add %= MOD;
			}
			ansby += add;
			ansby %= MOD;
		}
	}
	ans *= ansby;
	ans %= MOD;
	cout << ans << endl;
}

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

int main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if ( abs(a -c) <= d || (abs(a -b) <=d && abs(b-c) <= d)) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int main(){
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b_vec;
    for(int i = 0; i < m; ++i){
        int b_input;
        cin >> b_input;
        b_vec.push_back(b_input);
    }

    int ans = 0;
    for(int i = 0; i < n; ++i){
        int sum = c;
        for(int j = 0; j < m; ++j){
            int a;
            cin >> a;
            sum += a * b_vec[j];
        }
        //cout << "sum = " << sum << endl;
        if(sum > 0){
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#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() {
  int n;
  cin >> n;
  vector<string> vec(n);
  for (int i = 0; i < n ; ++i){
    cin >> vec.at(i);
    
  }
  
  int ac=0;
  int wa=0;
  int tle=0;
  int re=0;
  
  for (int i = 0; i < n ; ++i){
    if (vec.at(i)=="AC") {
      ac++;
      continue;
    }
    if (vec.at(i)=="WA") {
      wa++;
      continue;
    }
    if (vec.at(i)=="TLE") {
      tle++;
      continue;
    }
    if (vec.at(i)=="RE") {
      re++;
      continue;
    }
    
  }
  
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
 
  return 0;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n, d;
  cin >> d >> n;
  vector <ll> a(n);
  ll ans = 1e18 + 7;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  ans = a[n - 1] - a[0];
  for (int i = 1; i < n; i++) {
    ll x = a[i] - a[i - 1];
    ans = min(ans, d - x);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

  for (int a = -120; a < 121; a++) {
    for (int b = -120; b < 120; b++) {
      if (x == a*a*a*a*a - b*b*b*b*b) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3204
while (True):
  target = int(input())
  if target == 0:
    break
  answer = 0

  for i in range(target - 1):
    index = i + 2

    if (target - (0.5 * index * (index - 1))) % index == 0 and (target - (0.5 * index * (index - 1))) > 0:
      answer += 1


  print(answer)



Measured memory_bytes: 5604
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Point{
	void set(double arg_x,double arg_y){
		x = arg_x;
		y = arg_y;
	}
	double x,y;
};

Point point[1000000];

Point calc_Cross_Point(double x1,double x2,double x3,double x4,double y1,double y2,double y3,double y4){
	Point ret;
	ret.x = ((x2-x1)*(y3*(x4-x3)+x3*(y3-y4))-(x4-x3)*(y1*(x2-x1)+x1*(y1-y2)))/((y2-y1)*(x4-x3)-(y4-y3)*(x2-x1));
	if(x1 != x2){
		ret.y = ((y2-y1)*ret.x+y1*(x2-x1)+x1*(y1-y2))/(x2-x1);
	}else{
		ret.y = ((y4-y3)*ret.x+y3*(x4-x3)+x3*(y3-y4))/(x4-x3);
	}
	return ret;
}

double calc_S(Point a,Point b,Point c,Point d){
	return fabs((b.x*a.y - b.y*a.x)+(c.x*b.y - c.y*b.x)+(d.x*c.y - d.y*c.x)+(a.x*d.y - a.y*d.x))/2;
}


int main(){

	int N,K;
	scanf("%d %d",&N,&K);

	double base_degree = 360.0/(double)N;

	for(int i = 0; i < N; i++){
		point[i].x = cos((base_degree*i*M_PI)/180.0);
		point[i].y = sin((base_degree*i*M_PI)/180.0);
	}

	Point a,b,c,d,ret;
	a.set(point[0].x,point[0].y);

	ret = calc_Cross_Point(point[0].x,point[K].x,point[1].x,point[N+1-K].x,point[0].y,point[K].y,point[1].y,point[N+1-K].y);
	b.set(ret.x,ret.y);

	c.set(0,0);

	ret = calc_Cross_Point(point[0].x,point[N-K].x,point[N-1].x,point[(N-1+K)%N].x,point[0].y,point[N-K].y,point[N-1].y,point[(N-1+K)%N].y);
	d.set(ret.x,ret.y);

	printf("%.10lf\n",(double)N*calc_S(a,b,c,d));
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int ans = 0;
		if(n % 1000 != 0) {
			ans = 1000 - n % 1000;
		} else {
			ans = 0;
		}
		System.out.println(ans);
	}
}


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


#define FAST_INPUT ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
using namespace std;



void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    int l=0, r=n-1;
    int cnt=0;
    while (true) {
        while (l<n && s[l]!='W') l++;
        while (l<r && s[r]!='R') r--;
        
        if (l>=r || l==n) break;
        if (r<0) {
            // color
            cnt++;
        } else {
            // exchange
            swap(s[l], s[r]);
            cnt++;
        }
        l++;
    }
    cout << cnt << endl;
}

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


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

using namespace std;
const int N = 4010;
long long dp[N];
pair<int,int> s[N];
int main(){
	long long n,T;
	cin>>n>>T;
	for(int i=1;i<=n;i++){
		cin>>s[i].first>>s[i].second;
	}
	sort(s+1,s+n+1);
	dp[0]=0;
	long long ans=0;
	for(int i=1;i<=n;i++){
		ans=max(ans,dp[T-1]+s[i].second);
		for(int j=T-1;j>=s[i].first;j--){
			dp[j]=max(dp[j],dp[j-s[i].first]+s[i].second);
		}
	} 
	cout<<ans<<endl;
	return 0;
}


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

int value[100];
int sp = 0;

void push(const int val)
{
    value[sp++] = val;
}

int pop()
{
    return value[--sp];
}

void operand(const char operand)
{
    int ch, val = operand - '0';
    while( (ch = getchar()) != ' ' ){
        val = val * 10 + (ch - '0'); 
    }
    push(val);
}

void operator(const char operator)
{
    int tmp1 = pop(), tmp2 = pop();

    switch( operator ){
    case '+': push(tmp2 + tmp1); break;
    case '-': push(tmp2 - tmp1); break;
    case '*': push(tmp2 * tmp1); break;
    default : break;
    }
}

int main()
{
    while( 1 ){
        int ch = getchar();
        if( ch == ' ' || ch == '\n' ) continue;
        if( ch == EOF ) break;
        
        switch( ch ){
        case '+': case '-': case '*': operator(ch); break;
        default : operand(ch); break;
        }
    }

    printf("%d\n", pop());

    return 0;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int N = 20;
int c[N], a[N][N], t[N];
int main(void){ 
    IOS;
    int n, m, x;
    cin >> n >> m >> x;
    for (int i = 1; i <= n; ++i){
        cin >> c[i];
        for (int j = 1; j <= m; ++j){
            cin >> a[i][j];
        }
    }
    int ans = inf;
    for (int i = 1; i < (1<<n); ++i){
        memset(t, 0, sizeof t);
        int cost = 0;
        for (int j = 0; j < n; ++j){
            if ((i>>j)&1){
                cost += c[j+1];
                for (int k = 1; k <= m; ++k){
                    t[k] += a[j+1][k];
                }
            }
        }
        bool flag = true;
        for (int k = 1; k <= m; ++k){
            if (t[k] < x){
                flag = false; break;
            }
        }
        if (flag){
            ans = min(ans, cost);
        }
    }
    if (ans == inf) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <vector>
#include <iostream>
#include <string>

using namespace std;

int main()
{
  string S;
  cin >> S;
  string s2 = S.substr(2, 2);
  string s1 = S.substr(0, 2);
  vector<string> vec = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"};
  
  bool can1 = false;
  bool can2 = false;

  for(int i = 0;i < 12;++i)
  {
    if(vec[i] == s1){
      can1 = true;
    }
  }
  for(int k = 0; k < 12;++k)
      {
        if(vec[k] == s2)can2 = true;
      }

  if(can1 && can2)cout << "AMBIGUOUS" << endl;
  if(can1 && !can2)cout << "MMYY" << endl;
  if(!can1 && can2)cout << "YYMM" << endl;
  if(!can1 && !can2)cout << "NA" << endl;

  return 0;
}

Measured memory_bytes: 256