akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val mod: Long = 1000000007L
    val s: Scanner = new Scanner(input)
    val n = s.nextInt
    var result = 1L
    for (i <- 1 to n) {
      result = (result * i) % mod
    }
    result.toString
  }

  val tests = List(
    "3" -> "6",
    "10" -> "3628800",
    "100000" -> "457992974"
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

Measured memory_bytes: 25652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const int N = 2E5+10;
ll h,w,a,b;
ll f[N];
ll qpow(ll x,ll n) {
    ll s=1;
    while(n) {
        if(n&1) s=(s*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return s;
}
ll C(ll n , ll m ) {
    ll a = f[n];
    ll b = (f[m]*f[n-m]) % mod;
    return (a*qpow(b,mod-2)) %mod;
}
int main () {
    f[0]=1;
    for(ll i=1;i<N;++i) f[i]=(f[i-1]*i)%mod;
    cin >> h >> w >> a >> b;
    ll res=0;
    for(ll i=b+1;i<=w;++i) {
        ll tmp=(C(i-1+h-a-1,h-a-1)*C(w-i+a-1,w-i))%mod;
        res=(res+tmp)%mod;
    }
    cout <<res;
}

Measured memory_bytes: 1792
/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-12-3 12:51:34
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

char s[5] = {'a', 'e', 'i', 'o', 'u'};

int main()
{
  char c;
  cin >> c;
  for (auto i = 0; i < 5; i++)
  {
    if (s[i] == c)
    {
      cout << "vowel" << endl;
      return 0;
    }
  }
  cout << "consonant" << endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
S = [list(input()) for i in range(h)]

for i in range(h):
  for j in range(w):
    if S[i][j]=='#':
      continue
    cnt = 0
    for x in [-1, 0, 1]:
      for y in [-1, 0, 1]:
        if not 0 <= i+y < h or not 0 <= j+x < w:
          continue
        if S[i+y][j+x]=='#':
          cnt += 1
    S[i][j] = str(cnt)
for s in S:
  print(''.join(s))

Measured memory_bytes: 41456
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <map>
#include <string>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))


//struct moji {
//    int 
//    string name;
//};

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int N;
    cin >> N;
    map<string, int> mp;
    string tmp;
    for (int i = 0; i < N; i++) {
        cin >> tmp;

        ++mp[tmp];
    }

    int maxCount = 0;
    for (auto x : mp) {
        if (maxCount < x.second) maxCount = x.second;
    }

    for (auto x : mp) {
        if (x.second == maxCount) {
            cout << x.first << endl;
        }
    }

 	return 0;
}


Measured memory_bytes: 17664
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;

using namespace std;

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   cout<<(n*n*n);
   
   return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int h,w,k;
char grid[10][10];
int count(vector<int>a,vector<int>b)
{
	int cnt = 0;
	for(int i : a){
		for(int j : b){
			if(grid[i][j] == '#')cnt++;
		}
	}
	return cnt;
}

int main()
{
	cin>>h>>w>>k;
	for(int i=0;i<h;i++)
	  for(int j=0;j<w;j++)cin>>grid[i][j];
	ll ans = 0;
	for(int i=0;i<(1<<h);i++){
		for(int j=0;j<(1<<w);j++){
			vector<int>a,b;
			for(int m = 0;m < h;m++)if((i & (1<<m)) == 0)a.pb(m);
			for(int m = 0;m < w;m++)if((j & (1<<m)) == 0)b.pb(m);
			if(count(a,b) == k)ans++;
		}
	}
	cout<<ans;
	
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
using namespace std;

int main(){
    int n;
    int card[4][13];
    char ch;
    int number;

    cin>>n;
    rep(i,4)rep(j,13)card[i][j]=0;

    rep(i,n){
    cin>>ch>>number;
    if(ch=='S')card[0][number-1]=1;
    if(ch=='H')card[1][number-1]=1;
    if(ch=='C')card[2][number-1]=1;
    if(ch=='D')card[3][number-1]=1;
    }

    rep(i,4)rep(j,13)if(card[i][j]==0){
    if(i==0)cout<<'S' space j+1<<endl;
    else if(i==1)cout<<'H' space j+1<<endl;
    else if(i==2)cout<<'C' space j+1<<endl;
    else if(i==3)cout<<'D' space j+1<<endl;
    }
    }





Measured memory_bytes: 3080
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

template <typename T>
constexpr bool chmin(
    T a, T b, function<bool(T, T)> f = [](T a, T b) { return a > b; }) {
  // when f is true, b is more 'smaller'
  if (f(a, b)) {
    swap(a, b);
    return true;
  }
  return false;
}
template <typename T> constexpr bool chmax(T a, T b) {
  return chmin(a, b, [](T a, T b) { return a < b; });
}
template <typename ite> void print_ite(ite start, ite end, char c = ' ') {
  for (auto i = start; i != end; i++)
    cout << i << c;
  cout << endl;
}
template <typename ite> void scan_ite(ite start, ite end) {
  for (auto i = start; i != end; i++)
    cin >> (*i);
}
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  ll x;
  cin >> x;
  cout << 1000 * (x / 500) + (x - (x / 500) * 500) / 5 * 5 << endl;
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    vector<string> s(3);
    rep(i, 3) cin >> s[i];

    vector<int> pos(3);
    int who = 0;
    while (pos[who] < s[who].size()) {
        pos[who]++;
        who = s[who][pos[who] - 1] - 'a';
    }
    cout << "ABC"[who] << endl;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

const int MAX_UF = 110000;
struct PotentialUnionFind{
    typedef ll TYPE;
    const TYPE SUM_UNITY = 0;
    TYPE par[MAX_UF],rank[MAX_UF];
    TYPE diff_weight[MAX_UF];
    int N;
    PotentialUnionFind(int n = 0):N(n){ for(int i = 0; i < n;i++){ par[i] = i; rank[i] = 0; diff_weight[i] = SUM_UNITY; } }
    void init(){ for(int i = 0; i < N;i++){ par[i] = i; rank[i] = 0; diff_weight[i] = SUM_UNITY; } }
    void init(int n){ for(int i = 0; i < n; i++){ par[i] = i; rank[i] = 0; diff_weight[i] = SUM_UNITY; } }
    
    TYPE root(TYPE x){
        if(par[x] == x) return x;
        else {
            TYPE r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }
    TYPE weight(TYPE x){ root(x); return diff_weight[x]; }
    bool same(TYPE x,TYPE y){
        return root(x) == root(y);
    }
    bool merge(TYPE x,TYPE y,TYPE w){
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) {swap(x, y); w = -w; }
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x; diff_weight[y] = w;
        return true;
    }
    
    TYPE diff(TYPE x,TYPE y){ return weight(y) - weight(x); }
};

void solve(){
    int N,M; cin >> N >> M;
    PotentialUnionFind PUF(N);
    for(int i = 0; i < M; i++){
        int com; cin >> com;
        if(com == 0){
            int l,r,d; cin >> l >> r >> d;
            PUF.merge(r,l,d);
        }else{
            int l,r; cin >> l >> r;
            if(!PUF.same(l,r)){
                cout << "?" << endl;
            }else{
                cout << PUF.diff(r,l) << endl;
            }
        }
    }
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    solve();
    return 0;
}




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

int main()
{
	int h, w;
	while (cin >> h >> w, h || w)
	{
		for (int i = 0; i < h; i++)
		{
			for (int j = 0; j < w; j++) cout << (i == 0 || i == h - 1 || j == 0 || j == w - 1 ? '#' : '.');
			cout << endl;
		}
		cout << endl;
	}
}


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

int main(){

    array<int,1000> a;
    int out = 0;

    cin >> a[0];

    int i = 1;

    while(out == 0){

        if(a[i-1]%2 == 0)a[i] = a[i-1]/2;
        else a[i] = a[i-1]*3 + 1;

        for(int j = 0; j < i; j++){

            if(a[i] == a[j])out = i+1;

        }

        i++;
    }

    cout << out << endl;

    return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
/*
  a[0] ^ a[2] = a[1];
  a[1] ^ a[3] = a[2];

      a[0] ^ a[2] ^ a[1] ^ a[3] = a[1] ^ a[2];
  <=> a[0] ^ a[1] ^ a[2] ^ a[3] = a[1] ^ a[2];

   a[0] ^ a[1] ^ a[2] ^ a[3] = a[1] ^ a[2];
   a[2] ^ a[3] ^ a[4] ^ a[5] = a[3] ^ a[4];
   ...
^) a[n-2] ^ a[n-1] ^ a[0] ^ a[1] = a[n-1] ^ a[0]
-------------------------------------------------
   0 = a[0] ^ a[1] ^ ... ^ a[n-1]
*/
  int N; cin >> N;
  int s = 0;
  rep(i, N) {
    int a; cin >> a;
    s ^= a;
  }
  cout << (s == 0 ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
fn main() {
    let scan = std::io::stdin();
    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    let v: Vec<&str> = line.split_whitespace().collect();
    let a: i32 = v[0].parse().unwrap();
    let b: i32 = v[1].parse().unwrap();
    let a = if a == 1 { 14 } else { a };
    let b = if b == 1 { 14 } else { b };
    println!("{}", if a > b {"Alice"} else if b > a {"Bob"} else {"Draw"});
}

Measured memory_bytes: 4352
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		int dataset =   sc.nextInt();
		while(dataset-- > 0){
			int nowx = 0, nowy = 0;
			int maxdis = 0, ansx = 0, ansy = 0;
			while(true){
				int x = sc.nextInt();
				int y = sc.nextInt();
				if((x | y) == 0) break;
				nowx += x;
				nowy += y;
				int dis = nowx * nowx + nowy * nowy;
				if(maxdis < dis){
					maxdis = dis;
					ansx = nowx;
					ansy = nowy;
				}
				else if(maxdis == dis && (ansx < nowx)){
					ansx = nowx;
					ansy = nowy;
				}
			}
			System.out.println(ansx + " " + ansy);
		}
	}
	

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 26312
#include "bits/stdc++.h"

using namespace std;

const long long MOD = 1000000007;
const long long MAX = 100010;

long long fac[MAX], finv[MAX], inv[MAX];

void Cinit() {
    fac[0] = 1;
    fac[1] = 1;
    finv[0] = 1;
    finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; ++i) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;
    }
}

long long nCr(long long n, long long r) {
    if (n < r) {
        return 0;
    }
    if (n < 0 || r < 0) {
        return 0;
    }
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

void Main() {
    long long n;
    cin >> n;
    map<long long, long long> indexes;
    long long l, m;
    for (long long i = 0; i < n + 1; ++i) {
        long long a;
        cin >> a;
        if (indexes.count(a) == 0) {
            indexes.emplace(a, i);
        }
        else {
            l = indexes[a];
            m = n - i;
        }
    }

    Cinit();
    for (long long k = 1; k <= n + 1; ++k) {
        long long ans = nCr(n + 1, k);
        ans -= nCr(l + m, k - 1);
        ans %= MOD;
        while (ans < 0) {
            ans += MOD;
        }
        cout << ans << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 12068
#include <stdio.h>
int main()
{
    char S[5];
    int days=0;
    scanf("%s",S);
    switch(S[0])
    {
        case'M':
            days=6;
            break;
        case'W':
            days=4;
            break;
        case'F':
            days=2;
            break;
        case'S':
            if(S[1]=='A')
                days=1;
            else
                days=7;
            break;
        case'T':
            if(S[1]=='U')
                days=5;
            else
                days=3;
    }
    printf("%d\n",days);
                
            
            
    
}


Measured memory_bytes: 128
//By Ralif Rakhmatullin
#include<iostream>
#include<fstream>
#include<string>
#include<cstring>
#include<math.h>
#include<cassert>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<ctime>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<bitset>
#include<valarray>
#include<iterator>
#include<list>
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define S second
#define ld long double
#define F first
#define y1 LOL
#define ld long double
#define pb push_back
#define len length
#define sz size
#define beg begin
const ll INF = (ll)1e18 + 123;
const int inf=(int)2e9 + 123; 
const int mod=1e9+7;
using namespace std;
int n, m, g[16][16];
ll f[(1 << 15) + 123], dp[(1 << 15) + 123][16];
int main(){
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  	srand(FOR);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	memset(dp, -1, sizeof(dp));
	cin >> n >> m;
	ll sum = 0;
	for(int i = 1; i <= m; i ++){
		int a, b, c;
		cin >> a >> b >> c;
		sum += c;
		g[a][b] = g[b][a] = c;
	}
	for(int mask = 0; mask < (1 << n); mask ++){
		for(int i = 1; i <= n; i ++){
			if((mask & (1 << (i - 1))) == 0)
				continue;
			for(int j = i + 1; j <= n; j ++){
				if((mask & (1 << (j - 1))) > 0)
					f[mask] += g[i][j];
			}
		}
	}
	dp[1][1] = 0;
	for(int mask = 1; mask < (1 << n); mask ++){
		for(int i = 1; i <= n; i ++){
			if(dp[mask][i] == -1)
				continue;
			for(int j = 1; j <= n; j ++){
				if((mask & (1 << (j - 1))) > 0 || g[i][j] == 0)
					continue;
				dp[mask | (1 << (j - 1))][j] = max(dp[mask | (1 << (j - 1))][j], dp[mask][i] + g[i][j]);
			}
			int w = ((1 << n) - 1) ^ mask;
			for(int s = w; s > 0; s = (w & (s - 1))){
				dp[mask | s][i] = max(dp[mask | s][i], dp[mask][i] + f[s | (1 << (i - 1))]);
			}
		}
	}
	cout << sum - dp[(1 << n) - 1][n];			 	
	return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	scanf("%d", &n);
	vector<int > a(n);

	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &a[i]);
	}

	long long dp[n][n];
	memset(dp, 0, sizeof(n));

	for (int i = n-1; i >= 0; --i)
	{
		for (int j = i; j < n; ++j)
		{
			if(i==j){
				dp[i][j] = a[i];
			}
			else{
				dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1]);
			}
		}
	}

	
	// for(int i =0;i <n ;i++){
	// 	for(int j =0; j<n ;j++){
	// 		printf("%lld ", dp[i][j]);
	// 	}
	// 	printf("\n");
	// }

	printf("%lld\n", dp[0][n-1]);

	return 0;
}

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

int main(){
  int X;
  bool dp[100999];
  cin >> X;
  dp[0] = true;
  for(int i=1;i<=X;i++)dp[i]=false;
  for(int i=0;i<=X;i++){
    if(dp[i]){
      dp[i+100]=true;
      dp[i+101]=true;
      dp[i+102]=true;
      dp[i+103]=true;
      dp[i+104]=true;
      dp[i+105]=true;
    }
  }
  if(dp[X]){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 384
class SegmentTree():
    def __init__(self, array, f, ti):
        """
        Parameters
        ----------
        array : list
            to construct segment tree from
        f : func
            binary operation of the monoid
        ti : 
            identity element of the monoid
        """
        self.f = f
        self.ti = ti
        self.n = n = 2**(len(array).bit_length())
        self.dat = dat = [ti] * n + array + [ti] * (n - len(array))
        for i in range(n - 1, 0, -1):  # build
            dat[i] = f(dat[i << 1], dat[i << 1 | 1])

    def update(self, p, v):  # set value at position p (0-indexed)
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        f, ti, n, dat = self.f, self.ti, self.n, self.dat
        res = ti
        l += n
        r += n
        while l < r:
            if l & 1:
                res = f(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = f(dat[r], res)
            l >>= 1
            r >>= 1
        return res


I = [int(_) for _ in open(0).read().split()]
N, M = I[:2]
L, R, C = I[2::3], I[3::3], I[4::3]
ti = float('inf')
ST = SegmentTree([0] * 2 + [ti] * (N - 1), min, ti)
for l, r, c in sorted(zip(L, R, C)):
    ST.update(r, min(ST.query(r, r + 1), ST.query(l, r) + c))
ans = ST.query(N, N + 1)
print(-1 if ans == ti else ans)


Measured memory_bytes: 143640
#include <stdio.h>

int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i = 0;i < n;i++){
        scanf("%d",&a[i]);
    }
    for(int i= n - 1;i >= 0;i--){
        if (i == 0){
            printf("%d",a[i]);
        }
        else{
            printf("%d ",a[i]);
        }

    }
    printf("\n");
    return 0;

}


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


void solve(long long N, long long K, std::vector<long long> a){
    vector<bool> dp(K+1,-1);
    //trueなら先手がwin;
    for(int i=0;i<a[0];i++){
        dp[i] = false;
    }

    for(int i=0;i<=K;i++){
        bool winFirst = false;
        for(int j=0;j<N;j++){
            if(i-a[j] <0){
                continue;
            }
            if(!dp[i-a[j]]){
                winFirst = true;
            }
        }
        dp[i] = winFirst;

    }
    
    
    if(dp[K]){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }
}

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


Measured memory_bytes: 256
code = """

# distutils: language=c++
# distutils: include_dirs=[/home/USERNAME/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False

from libc.stdio cimport getchar, printf
from libcpp.vector cimport vector
cdef inline vector[int] readint(int n) nogil:
    cdef int b, c
    cdef vector[int] *v = new vector[int]()
    for i in range(n):
        c = 0
        while 1:
            b = getchar() - 48
            if b < 0: break
            c = c * 10 + b
        v.push_back(c)
    return v[0]

cpdef vector[int] readInt(int n):
    return readint(n)
cdef extern from "<atcoder/fenwicktree>" namespace "atcoder" nogil:
    cdef cppclass fenwick_tree[T]:
        fenwick_tree(int n)
        void add(int p, T x)
        T sum(int l, int r)

cdef class FenwickTree:
    cdef fenwick_tree[long long] *_thisptr
    def __cinit__(self, int n):
        self._thisptr = new fenwick_tree[long long](n)
    cpdef void add(self, int p, long long x):
        self._thisptr.add(p, x)
    cpdef long long sum(self, int l, int r):
        return self._thisptr.sum(l, r)
"""


import os, sys, getpass

if sys.argv[-1] == 'ONLINE_JUDGE':
    code.replace("USERNAME", getpass.getuser())
    open('atcoder.pyx','w').write(code)
    os.system('cythonize -i -3 -b atcoder.pyx')
    sys.exit(0)


from atcoder import readInt, FenwickTree

n, q = readInt(2)
bit = FenwickTree(n)
*map(bit.add, range(n), readInt(n)),
res = []
for i in range(q):
    t, u, v = readInt(3)
    if t: res.append(bit.sum(u, v))
    else: bit.add(u, v)
print('\n'.join(map(str, res)))

Measured memory_bytes: 78988
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then Enum.empty ()
  else
    List.map (fun _ -> scan fmt f) (1 ++ n)
    |> List.enum

let scan_list sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);
  arr

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let permutations l =
  let rec aux l =
    let rec interleave x = function
      | [] -> [[x]]
      | (hd::tl) as lst ->
        (x::lst) ::
        (ListL.map ~f:(List.cons hd)  @@ interleave x tl)
    in
    match l with
    | [] -> [[]]
    | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in
  let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in
  List.enum % ListL.map ~f:List.enum @@ l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let (h, w)  = scan "%d %d" Tuple.Tuple2.make
let g = scan_matrix h w "." id
let m = Array.make_matrix h w (-1)
let ds = [(-1,0);(1,0);(0,-1);(0,1)]

let rec bfs visited queue =
  if Queue.is_empty queue then ()
  else
    let (i, j, n) = Queue.pop queue in
    if visited.(i).(j) then bfs visited queue
    else
      (visited.(i).(j) <- true;
       m.(i).(j) <- n;
       ListL.iter ds ~f:(fun (di, dj) ->
           let x, y = i + di, j + dj in
           if between 0 x h && between 0 y w && not visited.(x).(y)
              && g.(x).(y) = "." then
             Queue.push (x,y, succ n) queue);
       bfs visited queue)

let () =
  let visited = Array.make_matrix h w false in
  let q = Queue.create () in
  Queue.push (0,0,1) q;
  bfs visited q;
  let n = m.(h-1).(w-1) in
  (if n = -1 then -1
   else
     h*w -
     (ArrayL.map g
        ~f:(fun line ->
            ArrayL.filter line ~f:((=) "#")
            |> Array.length)
      |> Array.sum) - n)
  |> Printf.printf "%d\n"


Measured memory_bytes: 2176
import math
def comb(n,r):
    return math.factorial(n)//math.factorial(r)//math.factorial(n-r)

s = int(input())
mod=10**9+7
ans=0
for i in range(1,s//3+1):
    tmp = s-i*3
    ans+=comb(tmp+i-1,i-1)
    ans%=mod
print(ans)

Measured memory_bytes: 9184
#include <stdio.h>
#define N 100
int n;

//function to sort and print array using insertion
void insertionSort (int arr[], int n)
{
    int i, key, j, print;
        for (i=1; i<n; i++){
            key = arr[i];
            j = i-1;
            while (j>=0 && arr[j]>key){
                arr[j+1] = arr[j];
                j--;
            }
            arr[j+1] = key;
            
            for (print=0; print<n;print++){
                printf("%d",arr[print]);
                if(print<n-1)
                	printf(" ");
                else
            		printf("\n");
            }
        }
}

//test sort
int main()
{
    int i;
    
    scanf("%d", &n);
   
    int a[N];
    for(i=0; i<n; i++)
        scanf("%d", &a[i]);
        
    for(i=0; i<n; i++){
    	printf("%d", a[i]);
    	if(i<n-1)
    		printf(" ");
    	else 
    		printf("\n");
    }
    
    insertionSort(a,n);
    
    return 0;
}


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

using namespace std;

int main()
{
    int n,cnt=0;
    string s;
    cin>>n>>s;
    for(int i=0;i<n;i++)
    {
       if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
            cnt++;
    }
    cout<<cnt<<"\n";
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int ll;
  double l = 0.0;
  double ans = 0.0;
  string s;

  cin >> ll;

  cout << fixed;
  cout << setprecision(12);

  l = (double)ll;
  if(ll%3 == 0){
    double l3 = 0.0;
    l3 = l/3.0;
    cout << l3*l3*l3 << endl;
    return 0;
  }else{
    double l3 = 0.0;
    l3 = l/3.0;
    cout << l3*l3*((double)ll-l3*2.0) << endl;
    return 0;
  }
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
    int n,k;cin>>n>>k;
    if (k==1)
    {
        /* code */
        cout<<'0'<<endl;
    }
    else
    {
        /* code */
        cout<<n-k<<endl;
    }
    
    
    }

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

using namespace std;

const int N = 234567, mod = 1e9 + 7;

int n, a[N], dp[N], pre[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  dp[0] = 1;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    dp[i] = dp[i - 1];
    if (pre[a[i]] && pre[a[i]] < i - 1) {
      dp[i] = (dp[i] + dp[pre[a[i]]]) % mod;
    }
    pre[a[i]] = i;
  }
  cout << dp[n] << '\n';
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    int A[N][M];
    int b[M];
    for(int i = 0; i < N; ++i)
    {
        for(int j = 0; j < M; ++j)
        {
            int a; cin >> a;
            A[i][j] = a;
        }
    }
    for(int i = 0; i < M; ++i)
    {
        int a; cin >> a;
        b[i] = a;
    }
    
    for(int i = 0; i < N; ++i)
    {
        
        int ans = 0;
        for(int j = 0; j < M; ++j)
        {
            ans += A[i][j] * b[j];
        }
        cout << ans << endl;
    }
    
    
}


Measured memory_bytes: 3124
#include <iostream>

//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <tuple>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
// #define dump(x) cerr << #x << " = " << (x) << endl;
// #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
//                       << " " << __FILE__ << endl;

int main()
{
    string dances;

    cin >> dances;

    int counter = 1;
    EACH(dance, dances)
    {
        if (counter % 2 == 1)
        {
            if (*dance == 'L')
            {
                cout << "No" << endl;
                return 0;
            }
        }
        else
        {
            if (*dance == 'R')
            {
                cout << "No" << endl;
                return 0;
            }
        }
        counter++;
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 888
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N;
int A[100010];

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

	cin >> N;

	rep(i, 0, N)
	{
		cin >> A[i];
	}

	multiset<int> aset;
	rep(i, 0, N)
	{
		auto itr = aset.lower_bound(A[i]); 
		if (itr != aset.begin())
		{
			aset.erase(--itr);
		}
		aset.insert(A[i]);
	}

	cout << SZ(aset) << endl;

	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a+b<c+d)
    cout << "Right" <<endl;
  else if(a+b==c+d)
    cout << "Balanced" << endl;
  else
    cout << "Left" <<endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>

using	namespace std;

int main() {
	
	string s;
	char str[4];
	int count = 0;

	cin >> s;

	for (int i = 1; i < s.size(); i++) {
		if (s[i] == s[i - 1]) {
			s[i] ^= 1;
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 512
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    rep(i,n){
        cout << s[i] << t[i];
    }
    cout << endl;
}


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

int s(long long n) {
  int sum = 0;
  while (n) {
	sum += n % 10;
  	n /= 10;
  }
  return sum;
}

int main () {
  int k;
  cin >> k;
  long long a = 0, d = 1;
  while (k--) {
    if(d*s(a+d)<a+d) d *= 10;
    a += d;
    cout << a << endl;
  }
}


Measured memory_bytes: 256
from heapq import heappop, heappush
V, E, r = map(int, input().split())
edge = [[] for _ in range(V)]
for _ in range(E):
    s,t,d = map(int, input().split())
    edge[s].append((d, t))

dp = [-1] * V

q = []
heappush(q, (0, r))

while len(q) > 0:
    d, x = heappop(q)
    if dp[x] > -1: continue
    dp[x] = d
    for nd, nt in edge[x]:
        heappush(q, (d+nd, nt))

for i in dp:
    print(i if i > -1 else "INF")



Measured memory_bytes: 107188
#include<stdio.h>

int main(){
  int n,i,A[100000],r,q,j,cnt=0,left,right,mid,key,minj;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }
  /*for(i=0; i<n-1; i++){
    minj=i;
    for(j=i; j<n; j++){
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    r=A[i];
    A[i]=A[minj];
    A[minj]=r;
    }*/

  scanf("%d",&q);
  for(j=0; j<q; j++){
    //binarysearch
    scanf("%d",&key);
    left=0;
    right=n;
    while(left<right){
      mid=(left+right)/2;
      if(A[mid]==key){
	cnt++;
	break;
      }
      else if(key<A[mid])right=mid;
      else left=mid+1;
      //printf("cnt:%d key:%d A[mid]:%d j:%d left:%d mid:%d right:%d\n",cnt,key,A[mid],j,left,mid,right);
    }
  }

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

  return 0;
}



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

#define mp make_pair
#define pb push_back
const int INF = 1000000000;

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;

vector<long long> freq(300, 0);
int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        freq[s[i]] ++;
    }
    ll tot = 1;
    for(int i = 0 ; i < 300; i++){
        for(int j = i + 1; j < 300; j++){
            tot += freq[i] * freq[j];
        }
    }
    cout << tot << endl;
}

Measured memory_bytes: 640
import scala.io.StdIn._

import Math._
object Main extends App {
  val eps0 = 1e-12

  val q = readLine.toInt

  val xs = new Array[Int](q)
  val ys = new Array[Int](q)
  for (i <- 0 until q) {
    val Seq(x, y) = readLine.split(' ').map(_.toInt).toList
    xs(i) = x
    ys(i) = y
  }

  val subarea = for (i <- 2 until q) yield {
    val xs1 = xs(i-1) - xs(0)
    val ys1 = ys(i-1) - ys(0)
    val xs2 = xs(i) - xs(0)
    val ys2 = ys(i) - ys(0)

    xs1 * ys2 - ys1 * xs2
  }

  println("%.1f".format(subarea.sum.toDouble / 2))
}


Measured memory_bytes: 44552
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int p,q,r;
    cin >> p >> q >> r;
    int a = min(p+q,q+r);
    a = min(a,r+p);
    cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

int main(){
    int a, b;

    cin >> a >> b;
    cout << b*2 - a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;

int main()
{
    LL tt = 1, aa = 1;
    int n;
    std::cin >> n;
    for (int _ = 0; _ < n; ++ _) {
        LL t, a;
        std::cin >> t >> a;
        LL r = std::max((tt + t - 1) / t, (aa + a - 1) / a);
        tt = r * t; aa = r * a;
    }
    printf("%lld\n", tt + aa);

}

Measured memory_bytes: 256
from math import floor
import decimal
x,k,d=map(int,input().split())
if x==0:
	if k%2==0:
		print(0)
	else:
		print(d)
	exit(0)
t=decimal.Decimal(abs(x))//decimal.Decimal(d)
if (k<t):
	if (x>0):
		print(abs(x-k*d))
	else:
		print(abs(x+k*d))
else:
	if (x>0):
		x=x-t*d
		k-=t
		if k%2==0:
			print(abs(x))
		else:
			print(abs(x-d))
	else:
		x=x+t*d
		k-=t
		if k%2==0:
			print(abs(x))
		else:
			print(abs(x+d))

Measured memory_bytes: 89800
import heapq
N,M = list(map(int, input().split()))
A = list(map(int, input().split()))
A =[-i for i in A]
heapq.heapify(A)
for i in range(M):
    minA = heapq.heappop(A)
    heapq.heappush(A, -(-minA//2))
print(-1*sum(A))

Measured memory_bytes: 73068
S = input()
if S == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()
import string
if len(S) < 26:
    tmp = sorted(list(set(list(string.ascii_lowercase))-set(list(S))))
    print(S+tmp[0])
    exit()
for i in range(26,-1,-1):
    tmp1 = S[:i]
    tmp2 = sorted(list(S[i:]))
    for t in tmp2:
        if S < tmp1+t:
            print(tmp1+t)
            exit()

Measured memory_bytes: 3768
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef long double R;
typedef complex<R> P;

const R EPS = 1e-10;
const R PI = acos((R)(-1));

R radNorP(R x) {
    return fmod(fmod(x, 2*PI)+2*PI, 2*PI);
}

const int MN = 330;

P p[MN];
typedef pair<R, int> Pi;

bool solve() {
    int n;
    cin >> n;
    if (!n) return false;

    for (int i = 0; i < n; i++) {
        R x, y;
        cin >> x >> y;
        p[i] = P(x, y);
    }

    int res = 1;
    for (int i = 0; i < n; i++) {
        vector<Pi> v;
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            if (2.0 < abs(p[j]-p[i])) continue;
            R th = acos(abs(p[j]-p[i])/2.0);
            R l = radNorP(arg(p[j]-p[i])-th-EPS);
            R r = radNorP(arg(p[j]-p[i])+th+EPS);
            if (r < l) {
                v.push_back(Pi(l-EPS, 1));
                v.push_back(Pi(2*PI+EPS, -1));
                v.push_back(Pi(0-EPS, 1));
                v.push_back(Pi(r+EPS, -1));
            } else {
                v.push_back(Pi(l-EPS, 1));
                v.push_back(Pi(r+EPS, -1));
            }

        }

        sort(v.begin(), v.end());
        int sm = 1;
        for (Pi p: v) {            
            sm += p.second;
            res = max(res, sm);
        }
    }
    cout << res << endl;
    return true;
}

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

Measured memory_bytes: 1300
#include <iostream>
#include <string>
#include <map>

using namespace std;

int n;
string s;

int main() {
  cin >> n >> s;
  long long int ans = 0;
  map<string, int> mp;
  for (int t = 0; t < (1 << n); t++) {
    string a = "", b = "";
    for (int i = 0; i < n; i++) {
      if (t & (1 << i)) a += s[i];
      else b += s[i];
    }
    string c = a + "." + string(b.rbegin(), b.rend());
    mp[c]++;
  }
  
  for (int t = 0; t < (1 << n); t++) {
    string a = "", b = "";
    for (int i = 0; i < n; i++) {
      if (t & (1 << i)) a += s[i + n];
      else b += s[i + n];
    }
    string c = string(a.rbegin(), a.rend()) + "." + b;
    ans += mp[c];
  }
  cout << ans;
}


Measured memory_bytes: 67968
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, K;
  cin >> N >> K;
  unordered_map<int, vector<int>> am;
  F0R(i, N) {
    int t, d;
    cin >> t >> d;
    am[t].push_back(d);
  }

  vector<int> as, bs;
  for (auto& p : am) {
    auto& v = p.second;
    sort(rng(v));
    as.push_back(v.back());
    v.resize(v.size() - 1);
    bs.insert(bs.end(), rng(v));
  }

  sort(rrng(as));
  sort(rrng(bs));
  //Print(as);
  //Print(bs);

  i64 d = 0;
  int ai, bi = 0;
  F0R(i, min(K, sz(as))) {
    d += as[i];
    ai = i;
  }
  F0R(i, min(K - sz(as), sz(bs))) {
    d += bs[i];
    bi = i + 1;
  }
  
  i64 result = 0;
  for (; ai >= 0; ai--, bi++) {
    chmax(result, d + (i64)(ai + 1) * (ai + 1));
    d -= as[ai];
    if (bi < bs.size()) d += bs[bi];
  }
  cout << result;
}
#endif


Measured memory_bytes: 12916
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define MAXN 21010
#define Scan(a) scanf("%I64d", &a)
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

int n, m;
char a[55][55], b[55][55];

bool check(int i, int j)
{
    FOR(I,1,m)
        FOR(J,1,m)
            if (a[i+I-1][j+J-1] != b[I][J]) return false;
    return true;
}

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n >> m;
    FOR(i,1,n)
        FOR(j,1,n) cin >> a[i][j];
    FOR(i,1,m)
        FOR(j,1,m) cin >> b[i][j];
    FOR(i,1,n-m+1)
        FOR(j,1,n-m+1) {
            if (check(i,j)) {
                cout << "Yes";
                return 0;
            }
        }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int H, A;

int main() {
  cin >> H >> A;
  int ans = 0;
  while (H > 0) {
    H -= A;
    ++ans;
  }

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


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

using namespace std;

bool A[105];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N, K;
    cin >> N >> K;
    for(int i = 1; i <= K; i++) {
        int x;
        cin >> x;
        for(int i = 1; i <= x; i++) {
            int y;
            cin >> y;
            A[y] = true;
        }
    }

    int ans = 0;
    for(int i = 1; i <= N; i++) {
        if(A[i] == false) {
            ans++;
        }
    }

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


Measured memory_bytes: 3656