akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

void build(ll node, ll start, ll end){
	if(start == end)
		segtree[node] = A[start];
	else{
		ll mid = (start + end)/2;
		build(left(node), start, mid);
		build(right(node), mid+1, end);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

void update(ll node, ll start, ll end, ll l, ll r, ll val){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start > end or l > start or r < end)
		return ;
	else if(start >= l and r >= end){
		segtree[node] += val;
		if(start != end){
			lazy[left(node)] += val;
			lazy[right(node)] += val;
		}
	}
	else{
		ll mid=(start + end)/2;
		update(left(node), start, mid, l, r, val);
		update(right(node), mid+1, end, l, r, val);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

ll sums(ll node, ll start, ll end, ll l, ll r){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > end or r < start or start > end)
		return 0;
	if(l <= start and r >= end)
		return segtree[node];
	ll mid = (start+end)/2;
	return sums(left(node), start, mid, l , r) + sums(left(node), mid + 1, end, l , r);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll a, b;
	cin >> a >> b;
	if(a%500 <= b)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define M 2550
#define LL long long
#define int LL
const int mo = 1e9 + 7;
int dp[52][5201][52]; // 放到第i位 在我 之前 的空位有h位.

void Add(int &res,int x) {
	res += x;
	if(res > mo) res -= mo;
	return ;
}
#define debug(x) cout << #x <<" " << x << endl;
main () {
	int n,k;
	cin >> n >> k;
	dp[1][M][0] = 1;
  	for(int i=1;i<=n;i++) {
		for(int j=0;j<=M*2;j++) {
			for(int h=i-1;h>=0;h--) {
				if(!dp[i][j][h]) continue;
				Add(dp[i+1][j][h],dp[i][j][h]); // 放自己.
				Add(dp[i+1][-2*i+j][h+1],dp[i][j][h]); // 放后面. 且当前位不放先.
				Add(dp[i+1][j][h],1LL*dp[i][j][h]*h%mo); // 放后面. 且当前位放前面空出来的.
				Add(dp[i+1][j][h],1LL*dp[i][j][h]*h%mo); // 放前面. 且当前位不放先.
				if(h) Add(dp[i+1][j+2*i][h-1],1LL*dp[i][j][h]*h%mo*h%mo); // 放前面 且当前位放前面空出来的.
			}
		}
	}
	cout<<dp[n+1][M+k][0];
	return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b; 
    int counter = 0;
    int answer = 1;
    while (answer < b) {
        counter++;
        answer = answer + a;
        answer = answer - 1;
    }
    cout << counter;
}


Measured memory_bytes: 3596
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	s := next()

	a, z := 0, 0
	for i := 0; i < len(s); i++ {
		if s[i] == 'A' {
			a = i
			break
		}
	}
	for i := len(s) - 1; i >= 0; i-- {
		if s[i] == 'Z' {
			z = i
			break
		}
	}

	fmt.Println(z - a + 1)
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

vector<int> v;
int n, N;
typedef multiset<int> msi;
typedef msi::iterator msii;
set<vector<int> > ans;

void solve(msi ms, vector<int> pos);

void solve2(msi ms, vector<int> pos, int now) {
  msi tmpms(ms);
  bool dame = 0;
  REP(i, pos.size()) {
    msii jt = tmpms.find(abs(pos[i]-now));
    if (jt == tmpms.end()) {
      dame = 1;
      break;
    }
    tmpms.erase(jt);
  }
  if (!dame) {
    vector<int> npos(pos);
    npos.push_back(now);
    sort(ALL(npos));
    solve(tmpms, npos);
  }
}

void solve(msi ms, vector<int> pos) {
  if (ms.size() == 0) {
    vector<int> v;
    REP(i, pos.size()-1)
      v.push_back(pos[i+1]-pos[i]);
    ans.insert(v);
    return;
  }
  msii it = ms.end();it--;
  solve2(ms, pos, pos[pos.size()-1]-*it);
  solve2(ms, pos, *it);
}

int main() {
  while(cin>>n,n) {
    N = n*(n-1)/2;
    multiset<int> ms;
    ms.clear();
    int a[N];
    REP(i,N) {
      cin >> a[i];
      if (i)
        ms.insert(a[i]);
    }
    vector<int> pos;
    pos.push_back(0);
    pos.push_back(a[0]);
    ans.clear();
    solve(ms, pos);
    FOR(it, ans) {
      FOR(jt, *it) {
        if (jt!=it->begin()) cout << " ";
        cout << *jt;
      }
      cout << endl;
    }
    
    cout << "-----" << endl;
  }
}

Measured memory_bytes: 0
#pragma GCC optimize "trapv" 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define inarr(arr,n)   rep(i,a,n)cin>>arr[i]
#define ll             long long int
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define IOS            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ret            return 0
#define pi             3.1415926536
#define hell           1000000007
#define narak          998244353
#define elasped_time 1.0 * clock() / CLOCKS_PER_SEC
const int inf1=1e9;
const ll inf2=1e18;
const int N=100000;
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
int dirs[4][2] ={{1,0},{-1,0},{0,1},{0,-1}};
int dp[101][N+5];
int solve(){
    
 int n,w;cin>>n>>w;           
 dp[0][0]=w;
 for(int i=1;i<=N;i++)dp[0][i]=-inf1;
 for(int i=1;i<=n;i++){
     int v;cin>>w>>v;
     for(int j=0;j<=N;j++){
         dp[i][j]=-inf1;
         if(j>=v)dp[i][j]=max(dp[i-1][j],dp[i-1][j-v]-w);
         else dp[i][j]=dp[i-1][j];
     }  
 }
 for(int i=N;i>=0;i--){
     if(dp[n][i]>=0){
         cout<<i<<endl;ret;
     }
 }        
 ret;
}
int main(){
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef cat
    cat();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    ret;
}
 

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}


// Problem Specific Parameter:

ll a[100010];

int main(void){
	ll n,x;
	cin >> n >> x;
	rep(i,n) cin >> a[i];

	ll ans=0LL;
	rep(i,1,n){
		{
			ll eat=min(max(0LL,a[i]+a[i-1]-x),a[i]);
			ans+=eat,a[i]-=eat;
		}

		{
			ll eat=min(max(0LL,a[i]+a[i-1]-x),a[i-1]);
			ans+=eat,a[i-1]-=eat;
		}
	}

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

Measured memory_bytes: 1024
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
double dp[3010][3010] = {};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    double p[3010];
    rep(i,0,N) cin >> p[i];
    dp[0][0] = 1.0;
    rep(i,0,N){
        rep(j,0,i+1){
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
        }
    }
    double ans = 0.0;
    rep(i,(N+1)/2,N+1){
        ans += dp[N][i];
    }
    cout << setprecision(12) << ans << endl;

    

}

Measured memory_bytes: 69120
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[15][15];
string ss[15];
int h[15], l[15], n, m;

void dfs_l(int x, bool flag) {
	if(x == m+1) {
		cout<<"YES";
		exit(0);
	} 
	else if(l[x]) dfs_l(x+1, flag);
	else {
		for(int i=x+1; i<=m; i++) {
			if(l[i]) continue;
			int j;
			for(j=1; j<=n; j++)
				if(s[j][x] != s[h[j]][i]) break;
			if(j == n+1) {
				l[x] = i, l[i] = x;
				dfs_l(x+1, flag);
				l[x] = l[i] = 0;
			}
		}
	}
	if(flag) {
		int i;
		for(i=1; i<=n; i++) 
			if(s[i][x] != s[h[i]][x]) break;
		if(i == n+1) {
			l[x] = x;
			dfs_l(x+1, 0);
			l[x] = 0;
		}
	}
}

void dfs_h(int x, bool flag) {
	if(x == n+1) dfs_l(1, m&1);
	else if (h[x]) dfs_h(x+1, flag);
	else {
		for(int i=x+1; i<=n; i++) {
			if(h[i]) continue;
			if(ss[i] != ss[x]) continue;
			h[i] = x, h[x] = i;
			dfs_h(x+1, flag);
			h[i] = h[x] = 0;
		}
	}
	if(flag) {
		h[x] = x;
		dfs_h(x+1, 0);
		h[x] = 0;
	}
}

int main()
{
	cin>>n>>m;
	for(int i=1; i<=n; i++) scanf("%s",s[i]+1);
	for(int i=1; i<=n; i++) {
		string tmp;
		tmp.clear();
		for(int j=1; j<=m; j++) tmp+=s[i][j];
		sort(tmp.begin(), tmp.end());
		ss[i]=tmp;
	}
	dfs_h(1, n&1);
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N), b(N);
  for (int i = 0; i < N; i++){
    cin >> a[i] >> b[i];
  }
  vector<int> d(100003, 0);
  for (int i = 0; i < N; i++){
    d[a[i]]++;
    d[b[i] + 1]--;
  }
  for (int i = 0; i < 100002; i++){
    d[i + 1] += d[i];
  }
  int ans = 0;
  for (int i = 1; i < 100003; i++){
    if (d[i] + 1 >= i){
      ans = i - 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3888
def main():
  string = input()
  flg=0
  while len(string)!=0:
    if(string.count(string[0])%2==0):
      string=string.replace(string[0],'')
    else:
      flg=1
      break
  if flg==0:
    print('Yes')
  else:
    print('No')  
main()

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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

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

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  ll a, b;
  cin >> a >> b;
  cout << a * b / __gcd(a, b) << '\n';
  return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>
#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

//#define solvsh
//#define multi
#ifdef solvsh

const int MAXN = 3e2 + 1e2;

const int M = 54;

vector<int> g;

bool bit(int num, int i){
    return (num >> i) & 1;
}

void add_row(int row){

    g.push_back(row);


    for (int i = 20; i >= 0; --i){
        if (bit(row, i)){

        }
    }


    sort(all(g));
    while (g.back() == 0)
        g.pop_back();
}

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> v;
    for (int i = 0; i < n; ++ i){
        int curr;
        cin >> curr;
        v.push_back(curr);
    }

}

#else

void solve(){
    ld r;
    cin >> r;
    ld pi = acos(-1.);
    cout << pi * 2 * r;
}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        cout << "Case #" << (i++) << ": ";
        solve();
        cout << endl;
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif

}

Measured memory_bytes: 3808
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(i, first, last) for (int i = (first); i < (last); ++i)
#define REP(i, n) FOR(i, 0, n)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) std::cerr << #x << " = " << (x) << std::endl;
#define DUMPR(v) REP(_i,v.size()){std::cerr<< #v << "[" << _i << "] = " << (v[_i]) << std::endl;}
#define CIN_VEC(v,N) {v.clear(); v.reserve(N); REP(i,N){typename decltype(v)::value_type x; cin>>x; v.emplace_back(x);}};

inline int to_int(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string to_string(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

typedef unsigned long long ull;
typedef unsigned long ul;

static const int NMAX = 2999;

double p[NMAX];

// dp[i][j] ... i枚目まで投げてj枚表の確率
double dp[NMAX+1][NMAX+1];
int N;

int main() {
  memset(dp, 0, sizeof(dp));

  cin>>N;
  REP(i,N)cin>>p[i];

  dp[0][0] = 1;
  for(int i=1;i<=N;i++) {
    for(int j=0;j<=i;j++) { // 高々i回しか表出ない
      double prob = p[i-1]; // i番目のコインで表を出す確率
      // iで裏を出す
      dp[i][j] = dp[i-1][j] * (1-prob);

      // iで表を出す
      if(j>=1)
        dp[i][j] += dp[i-1][j-1] * prob;
    }
  }

  double ans = 0;
  for(int j=N; j >= N-j; --j) {
    ans += dp[N][j];
  }
  printf("%.12lf\n", ans);

  return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,k;cin>>n>>k;
    int arr[n];
    for (int i=0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n);
    int ans=0;
    for (int i=1;i<=k;i++){
        ans+=arr[n-i];
    }cout<<ans<<endl;
    return 0;
}

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

int dp[1010][1010];

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

    string s1,s2;
    cin>>s1>>s2;
    for(int i=0;i<=s1.size();i++)dp[i][0]=i;
    for(int j=0;j<=s2.size();j++)dp[0][j]=j;
    for(int i=1;i<=s1.size();i++){
        for(int j=1;j<=s2.size();j++){
            if(s1[i-1]==s2[j-1])dp[i][j]=min(dp[i-1][j-1],min(dp[i-1][j]+1,dp[i][j-1]+1));
            else dp[i][j]=min(dp[i-1][j-1]+1,min(dp[i-1][j]+1,dp[i][j-1]+1));
        }
    }
    cout<<dp[s1.size()][s2.size()]<<endl;

}


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

const long long M = 1e9+7;

int main() {
  int n,m;

  cin >> n >> m;

  vector<int> a(n+1,0);

  for(int i=0;i<m;i++) {
    int x;
    cin >> x;
    a[x]=1;
  }

  vector<long long> dp(n+1,0);
  dp[0] = 1;

  for(int i=0;i<n;i++) {
    if(a[i]==0) {
      if(a[i+1] == 0) {
        dp[i+1]+=dp[i];
        dp[i+1]%=M;
      }
      if(i+2<=n) {
        if(a[i+2] == 0) {
          dp[i+2]+=dp[i];
          dp[i+2]%=M;
        }
      }
    }
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 1408
import math

n, k = map(int, input().split(" "))
pL = [0 for _ in range(n)]

for i in range(k):
    d = int(input())
    aL = list(map(int, input().split(" ")))
    for a in aL:
        pL[a - 1] += 1

ans = 0

for p in pL:
    if p == 0:
        ans += 1

print(ans)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,k;
    cin >> t;
    k=t;
    vector <long long> side;
    long long n;
    while(k--)
    {
        cin >> n;
        side.push_back(n);
    }
    sort(side.begin(),side.end(),greater<long long>());
    long long a=0,b=0,i;
    for(i=0;i<t-1;i++)
    {
        if(side[i]==side[i+1])
        {
            if(a==0) a=side[i];
            else b=side[i];
            i++;
        }
        if(a>0 && b>0) break;
    }
    cout << a*b << endl;
}

Measured memory_bytes: 4144
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int foo(int n)
{
    int ans=0;
    for(int i = 1;i<=n;i++)
    {
        if(n%i==0)
          ans++;
    }
    return ans;
}
int main()
{
    int n,ans=0;
    cin>>n;
    for(int i =1;i<=n;i++)
    {
        
        if(foo(i)==8&&i%2==1)
        {
            ans++;
            ///cout<<i<<endl;
        }
        
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

typedef pair<int, int> P;





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

	vector<vector<P>> ps;
	rep(i, N)
	{
		vector<P> tmp;
		int a;
		cin >> a;
		rep(j, a)
		{
			int x, y;
			cin >> x >> y;
			tmp.emplace_back(--x, y);
		}

		ps.push_back(tmp);
	}

	int count = 0;
	for (int bit = 0; bit < (1 << N); ++bit)
	{
		map<int, set<int>> g;
		g[0] = {};
		g[1] = {};

		rep(i, N)
		{
			int y = (bit & (1 << i)) >> i;

			g[y].insert(i);
		}

		//矛盾がないか確認
		bool flg = true;
		rep(i, N)
		{
			int y = (bit & (1 << i)) >> i;

			if (y == 0) continue;

			for (auto p : ps[i])
			{
				if (p.second == 1)
				{
					if (g[0].count(p.first) > 0)
					{
						flg = false;
						break;
					}
				}
				else
				{
					if (g[1].count(p.first) > 0)
					{
						flg = false;
						break;
					}
				}
			}
		}

		if (!flg) continue;
		count = max(count, (int)g[1].size());
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

#define abs(x) ((x)>0?(x):-(x))

int main ()
{
	int a , b , c ;
	scanf("%d%d%d",&a,&b,&c);
	if ( a>b ) swap(a,b);
	if ( b>c ) swap(b,c);
	if ( a>b ) swap(a,b);
	printf("%d\n",abs(a-b)+abs(b-c));
	return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)

int main(){

  while(1){
    int N;
    cin >> N;
    if(N==0)break;
    int ans=0;
    rep(i,0,N){
      rep(j,i,N){
	int sum=0;
	for(int k =i+1;k<j+1;k++){
	  sum += k;
	}
	if(sum == N) ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstring>
#include <cstdio>
#define maxn 1005
#define LL long long
#define mod 1000000007

using namespace std;

LL pow_mod(LL a,LL b)
{
    LL ret=1;
    while (b)
    {
        if (b&1) ret=ret*a%mod;
        b>>=1;
        a=a*a%mod;
    }
    return ret;
}

LL C(LL n,LL m)
{
    LL ret=1;
    if (m>n) return 0;
    m=min(m,n-m);
    for (LL i=1;i<=m;i++) ret=ret*(n-i+1)%mod*pow_mod(i,mod-2)%mod;
    return ret;
}

int main()
{
    LL n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    LL ans=((pow_mod(2,n)-C(n,a)-C(n,b)-1)%mod+mod)%mod;

    cout <<ans;
    return 0;
}


Measured memory_bytes: 764
# coding: utf-8
import numpy as np

if __name__ == "__main__":
	n, t = map(int, input().split())
	tn = list(map(int, input().split()))

	clusters = [[0, 0]]
	for i in range(0, len(tn)-1):
		if tn[i+1] - tn[i] <= t:
			clusters[-1][1] = i+1
		else:
			clusters.append([i+1, i+1])

	tsum = 0
	for s, e in clusters:
		tsum += tn[e] - tn[s] + t

	print(tsum)


Measured memory_bytes: 34148
import sys
import numpy as np
import math

from collections import deque 
from functools import reduce
from functools import lru_cache

@lru_cache(maxsize=None)
def gc(a, b):
    if (a % b == 0):
        return b
    return(gc(b, a%b))
# input = sys.stdin.readline

n = int(input())

sum = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        g = gc(i, j)
        for k in range(1, n+1):
            sum += gc(g, k)
print(sum)

Measured memory_bytes: 30680
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define TOP 0
#define BOTTOM 2
#define RIGHT 1
#define LEFT 3

int dx[] = {3,-1,-3,1};
int pt[] = {TOP,RIGHT,BOTTOM,LEFT};
int my[] = {BOTTOM,LEFT,TOP,RIGHT};

vector<string> puz(9);
vector<string> cur(9);
bool done[9];
int ret;


/*string change(string s,int l){
	switch(l){
	case 0:
		return s;
	case 1:
		swap(s[0],s[2]);
		return s;
	case 2:
		swap(s[1],s[3]);
		return s;
	case 3:
		swap(s[0],s[2]);
		swap(s[1],s[3]);
		return s;
	}
	return "";
}*/
void view(){
	rep(i,3){
		printf(" %c  %c  %c \n",cur[i*3+0][TOP],cur[i*3+1][TOP],cur[i*3+2][TOP]);
		printf("%c %c%c %c%c %c\n",cur[i*3+0][LEFT],cur[i*3+0][RIGHT],cur[i*3+1][LEFT],cur[i*3+1][RIGHT],cur[i*3+2][LEFT],cur[i*3+2][RIGHT]);
		printf(" %c  %c  %c \n",cur[i*3+0][BOTTOM],cur[i*3+1][BOTTOM],cur[i*3+2][BOTTOM]); 
	}
	puts("---");
	return;
}
bool check(char a,char b){
	if(a != b && tolower(a) == tolower(b))return true;
	return false;
}
bool check(int p){
	rep(i,4){
		if( p%3==0 && i == 1)continue;
		if( p%3==2 && i == 3)continue;
		
		int t = p+dx[i];
		if(t<0 || t>=9)continue;
		if(cur[t]== "")continue;
		
		if(!check(cur[t][pt[i]],cur[p][my[i]])){
			if( p > 7){
			}
			return false;
		}
	}
	return true;
}
void bt(int x){
	//cout << ret << endl;

	if( x == 9){
		ret++;
		return;
	}
	
	rep(i,9){
		if(done[i])continue;
		
		rep(l,4){
			rotate(puz[i].begin(),puz[i].begin()+1,puz[i].end());
			cur[x] = puz[i];
			done[i] = true;
			if(check(x))bt(x+1);
			done[i] = false;
			cur[x] = "      ";
			cur[x] = "";
		}
	}
	return;
}


int main(){
	int n; cin >> n;
	while(n--){
		ret = 0;
		rep(i,9)cin >> puz[i];
		
		bt(0);
		
		cout << ret << endl;
	}
}

Measured memory_bytes: 932
fn main() {
    proconio::input! {
        mut n: usize,
    }
    let mut v = vec![];
    let alphas = [
        'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
        's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
    ];
    loop {
        n -= 1;
        v.push(alphas[n % 26]);
        n /= 26;
        if n == 0 {
            break;
        }
    }
    v.reverse();
    println!("{}", v.iter().collect::<String>());
}


Measured memory_bytes: 2152
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
hl = []
for _ in range(n):
    hl.append(int(input()))
hl.sort()

res = 10**9
for i in range(n-k+1):
    hmin,hmax = hl[i],hl[i+k-1]
    res = min(res, hmax-hmin)

print(res)


Measured memory_bytes: 7384
/*

                                  In the name of Allah, Most Gracious, Most Merciful


*/
#include<bits/stdc++.h>
#include<numeric>
using namespace std;

//*** constant value ***
const long double PI = 3.141592653589793238;
const double EPS = 1e-6 ;
//*** constant value ***

//****** define ********
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define dd double
#define vll vector<ll>
#define vs vector<string>
#define fn(i,n) for(ll i = 0; i<n; i++)
#define f(i,a,b) for(i=a;i<b;i++)
#define f1(i,a,b) for(i=b-1;i>=a;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define vpl vector<pll>
#define pb push_back
#define mk make_pair
#define x first
#define y second
#define tt cout<<"Came here"<<endl;
//****** define ********
void solve()
{
    ll n;
   cin>>n;

   cout<<n+(n*n)+(n*n*n)<<endl;

}

int main()
{
    IOS;
    ll tc = 1;
    while(tc--)
    {
        solve();
    }


return 0;
}



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

int L, tot, T, E;
vector<pair<int, int> > g[100];

int main(void) {
  scanf("%d", &L);
  int tot = 1;
  //L++;
  while(L > 1) {
    if((L & 1)) g[tot].push_back(make_pair(0, L - 1)), ++E;
    g[tot].push_back(make_pair(tot + 1, L / 2)), ++E;
    g[tot].push_back(make_pair(tot + 1, 0)), ++E;
    tot++;
    L = L / 2;
  }
  T = tot;
  cout << T << " " << E << endl;
  for(int i = 1; i <= T; i++) {
    for(int j = 0; j < g[i].size(); j++) {
      pair<int, int> v = g[i][j];
      cout << i << " " << (!v.first ? T : v.first) << " " << v.second << endl;
    }
  }
  return 0;
}


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

typedef long long ll;
#define ABSOL(a) (a<0 ? (a*(-1)) : a)
#define rep(i, a, b) for(i = a; i < b; i++)
#define REP(i, a, b) for(i = a; i <= b; i++ )
#define scanstr(str) getline(cin, str)
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int d ,t, s;
	
	cin >> d >> t >> s;
	
	if (s * t >= d){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3636
from sys import stdin
import math
import itertools

N, K = [int(x) for x in stdin.readline().rstrip().split()]
data = [stdin.readline().rstrip().split() for _ in range(N)]
for idx in range(N):
    data[idx] = [int(n) for n in data[idx]]

data_tmp = list(itertools.combinations(data,2))
cnt = 0
for idx, item in enumerate(data_tmp):
    dst = 0
    for n in range(K):
        dst = dst + pow(item[0][n] - item[1][n], 2)
    dst = math.sqrt(dst)
    i = int(dst)
    f = dst - i
    if f == 0.0:
        cnt = cnt + 1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    map<char,int> mp;
    string s;
    string c = "YES";
    cin >> s;
    for(int i=0;i<s.size();i++) mp[s[i]]++;
    int a = min({mp['a'],mp['b'],mp['c']});
    mp['a']-=a;
    mp['b']-=a;
    mp['c']-=a;
    int b = max({mp['a'],mp['b'],mp['c']});
    if(2<=b) c = "NO";
    cout << c << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
map<long, long> prime_factorization(long long n) {
  // map<long,long> first=素因数 second=first素因数の数
  map<long, long> res;
  for (ll i = 2; i <= n / i; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
long long longpow(long long n, long long a, long long mod) {
  if (a == 0) return 1;
  if (a == 1) return n % mod;
  if (a % 2 == 1) return (n * longpow(n, a - 1, mod)) % mod;
  ll t = longpow(n, a / 2, mod) % mod;
  return (t * t) % mod;
}
int main() {
  ll N, P;
  cin >> N >> P;
  map<long, long> mp = prime_factorization(P);

  long mx = 1;
  for (auto p : mp) {
    mx *= longpow(p.first, p.second / (ll)N, 1e+17);
  }
  cout << mx << endl;
}

Measured memory_bytes: 256
from collections import  deque

H, W = map(int, input().split())
maze = [list(input()) for _ in range(H)]

def bfs():
    d =  [[float('inf')] * W for _ in range(H)]
    dx = [1,0,-1,0]
    dy= [0,1,0,-1]
    que=deque([])
    que.append((sx,sy))
    d[sx][sy] =  0
    while que:
        p = que.popleft()
        if p[0] == gx and p[1] == gy:
            break
        for i in range(4):
            nx = p[0] + dx[i]
            ny =  p[1] +  dy[i]
            if 0 <= nx < H  and 0 <= ny < W and maze[nx][ny] !='#' and d[nx][ny] == float('inf'):
                d[nx][ny] = d[p[0]][p[1]] + 1
                que.append((nx, ny))
    return d[gx][gy]
    

sx, sy = 0, 0
gx, gy = H - 1,  W - 1

white = 0
for t in maze:
    for s in t:
        if  s == '.':
            white += 1
            
res = bfs()
if 0 < res < float('inf'):
    print(white - res - 1)
else:
    print(-1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e18;
using Graph = vector<vector<int>>;

signed main() {
  string N;
  cin >> N;

  int keta = (int)N.size();

  //dp[i][fg] = i桁目までの支払いで最小の札数と、余分に支払っているかどうか
  vector<vector<int>> dp(keta+10, vector<int>(2));
  dp[0][1] = 1;
  for( int i = 0; i < keta; i++ ){
    int num = N[i]-'0';
    dp[i+1][0] = min(dp[i][0]+num, dp[i][1]+(10-num));
    dp[i+1][1] = min(dp[i][0]+num+1, dp[i][1]+(10-num-1));
  }
  cout << dp[keta][0]<< endl;
}

Measured memory_bytes: 58860
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
const int Max=100+9;
char a[Max][Max];
bool vis[Max][Max];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int n,m;
int ans=1;
void dfs(int x,int y){
    vis[x][y]=1;
    for(int i=0;i<4;i++){
        int nx=x+dx[i];
        int ny=y+dy[i];
        if(nx>n||nx<1||ny>m||ny<1||vis[nx][ny]){
            //cout<<x<<"!!"<<y<<"!!!"<<nx<<"!!!!"<<ny<<"!!!"<<a[x][y]<<"!"<<a[nx][ny]<<endl;
            continue;
        }
        
        if(a[x][y]==a[nx][ny]){
            vis[nx][ny]=1;
            dfs(nx,ny);
        }
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    while(1){
        memset(vis,0,sizeof(vis));
        ans=0;
        cin>>n>>m;
        if(!n&&!m){
            break;
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                cin>>a[i][j];
            }
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(!vis[i][j]){
                    ans++;
                    dfs(i,j);
                    //cout<<i<<"!!"<<j<<endl;
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3732
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<iomanip>
using namespace std;

int main(void) {
	int A, B;
	cin >> A >> B;
	if (A*B % 2 == 1) {
		if (A*B == 2)cout << "No";
		
		else cout << "Yes";
	}
	else if (A*B &2 == 0)cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = n; i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	int n;
	string s;
	cin >> n >> s;
	vector<int> alph(26, 0);
	int ans = 0;
	rep(i, n-1) {
		string l = s.substr(0, i+1), r = s.substr(i+1,n-i-1);
		int now = 0;
		for (int c = 'a'; c <= 'z'; c++) {
			if (l.find(c) != -1 && r.find(c) != -1) now++;
		}
		ans = max(ans,now);
	}
	cout << ans << endl;
	return 0;
}

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



int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    bool ok = true;
    int Max = a[0];
    for (int i = 1; i < n; i++)
        if (a[i] < Max - 1){
            ok = false;
            break;
        }
        else Max = max(Max, a[i]);
    if (ok) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main()
{
int N,xi,yi,map[21][21],m,x,y,r,i,t,temp;
char to[2];
for(scanf("%d",&N);N!=0;scanf("%d",&N))
{
 x=10,y=10,temp=0;
 for(i=0;i<21;i++)
  for(t=0;t<21;t++)
   map[i][t]=0;
 for(i=1;i<=N;i++)
 {scanf("%d%d",&xi,&yi);
  map[xi][yi]=1;}
 scanf("%d",&m);

 for(t=0;t<m;t++)
 {

   scanf("%s%d",to,&r);
	if(to[0]=='N')for(i=1;i<=r;i++)if(map[x][++y]==1){temp++;map[x][y]=0;}
	if(to[0]=='S')for(i=1;i<=r;i++)if(map[x][--y]==1){temp++;map[x][y]=0;}
	if(to[0]=='E')for(i=1;i<=r;i++)if(map[++x][y]==1){temp++;map[x][y]=0;}
	if(to[0]=='W')for(i=1;i<=r;i++)if(map[--x][y]==1){temp++;map[x][y]=0;}


 }




if(temp==N)printf("Yes\n");else printf("No\n");





}


return 0;
}


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

#define PQ priority_queue
#define P pair<int,int>
#define CLA(array) memset(array,0,sizeof array)
#define CLINF(array) memset(array,0x3f,sizeof array)
#define CLF(array) memset(array,-1,sizeof array)
#define DB(a) cout << "DEBUG " << a << endl;
#define rep(i,a,b) for(int i=(int)a;i<b;i++)
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 100000 + 50;
const int INF = 1 << 30;

int main(){
    string a;
    cin>>a;
    if(a[0]==a[2])
        cout<<" Yes\n";
    else cout<<"No\n";

    return 0;
}

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

using namespace std;

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

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, k;
	cin >> n >> k;
	int even = n / 2;
	int odd = n - even;

	cout << (odd >= k || even >= k ? "YES" : "NO") << endl;
	return 0;
}


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

int main()
{
    long long int i,j,count=0;
    string s,t;
    cin>>s>>t;
    for(i=0,j=0; i<s.size(),j<t.size();i++,j++)
        if(s[i]!=t[j])
            count++;
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3912
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
constexpr long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

constexpr double EPS = 1e-5;
using Vector = vector<double>;
using Matrix = vector<Vector>;

// Ax = b, make sure A.size() == b.size()
// return x
Vector gaussian_elimination(const Matrix &A, const Vector &b) {
    // A is m * n matrix
    int m = A.size();
    int n = A[0].size();

    // make augmented matrix B
    Matrix B(m, Vector(n + 1));
    for(int i = 0; i < m; ++i) 
        for(int j = 0; j < n; ++j) B[i][j] = A[i][j];
    for(int i = 0; i < m; ++i) B[i][n] = b[i];

    
    Vector x(m);
    for(int i = 0; i < m; ++i) {
        int pivot = i;
        for(int j = i + 1; j < m; ++j) if(abs(B[j][i]) > abs(B[pivot][i])) pivot = j;
        swap(B[i], B[pivot]);

        if(abs(B[i][i]) < EPS) return Vector(0);

        for(int j = i + 1; j <= n; ++j) B[i][j] /= B[i][i];

        for(int j = 0; j < m; ++j) {
            if(i == j) continue;
            for(int k = i + 1; k <= n; ++k) {
                B[j][k] -= B[j][i] * B[i][k];
            }
        }
    }

    for(int i = 0; i < m; ++i) x[i] = B[i][n];
    return x;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false); 
    int d;
    while(cin >> d, d) {
        Vector vec(d+3); REP(i,d+3) cin >> vec[i];

        // 選ばないふたつ
        for(int i=0; i < d+3; ++i) {
            for(int j=i+1; j < d+3; ++j) {

                // matを構築
                Matrix A(d+1, Vector(d+1));
                Vector b(d+1);
                for(int row = 0, cnt = 0; row < d+3; ++row) {
                    if(row == i || row == j) continue;
                    for(int col = 0; col < d+1; ++col) {
                        A[cnt][col] = pow(row, col);
                        b[cnt] = vec[row];
                    }
                    ++cnt;
                }

                Vector x = gaussian_elimination(A, b);
                // i, jを再現
                double y = 0.0, z = 0.0;
                for(int k=0; k < d+1; ++k) y += pow(i, k) * x[k];
                for(int k=0; k < d+1; ++k) z += pow(j, k) * x[k];
                // 片方あってて片方間違ってたら、間違ってた方が答え
                if(abs(y-vec[i]) < EPS && abs(z-vec[j]) > EPS) {
                    cout << j << '\n';
                    goto end;
                }
                if(abs(y-vec[i]) > EPS && abs(z-vec[j]) < EPS) {
                    cout << i << '\n';
                    goto end;
                }
            }
        }
end:
        continue;
    }
    return 0;
}


Measured memory_bytes: 3416
#include<stdio.h>

int main(void)
{
	int N,M,X,Y,x[100],y[100];
	int xMax=-100,yMin=100,i;
	
	scanf("%d %d %d %d",&N,&M,&X,&Y);
	
	for(i=0;i<N;i++){
		scanf("%d",&x[i]);
		if(x[i]>xMax) xMax=x[i];
	}
	
	for(i=0;i<M;i++){
		scanf("%d",&y[i]);
		if(y[i]<yMin) yMin=y[i];
	}
	
	if(xMax+1>X){
		if(yMin<=Y){
			if(xMax<yMin){
				printf("No War");
			}
			else printf("War");
		}
		else printf("War");
	}
	else printf("War");
	
	return 0;
}

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

int main(){
	int N, D;
	cin >> N >> D;

	int cnt = N / (D * 2 + 1);

	if(N % (D * 2 + 1) != 0) {
		cnt += 1;
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
tl = [0] * n
at = 0
bt = 0
for i in range(n):
    at += a[i]
    bt += b[-i-1]
    tl[i] += at
    tl[-i-1] += bt
print(max(tl))


Measured memory_bytes: 3060
#include <stdio.h>
int v;
int parent[100001];
int sibling[100001];
int degree[100001];
int Depth(int i);
int Height(int i);
int main(){
  int i,j;
  int id, l, r;
  scanf("%d", &v);
  for(i = 0; i < v; ++i) {
    parent[i] = -1;
    sibling[i] = -1;
    degree[i] = 0;
  }
  for(i = 0; i < v; ++i) {
    scanf("%d %d %d", &id, &l, &r);
    if(l != -1){
      parent[l] = id;
      sibling[l] = r;
      ++degree[id];
    }
    if(r != -1){
      parent[r] = id;
      sibling[r] = l;
      ++degree[id];
    } }
  for(i = 0; i < v; ++i) {
    int depth = Depth(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, parent[i], sibling[i], degree[i], depth, Height(i));
    if(depth == 0) {
      printf("root\n");
    } else if(degree[i] == 0) {
      printf("leaf\n");
    } else {
      printf("internal node\n");
    } }
  return 0; }
           
           
           
int Depth(int i){
  if(parent[i] == -1) return 0;
  return Depth(parent[i]) + 1;
}
int Height(int i){
  int j, h;
  h = 0;
  for(j = 0; j < v; ++j){
    if(parent[j] == i){
      int tmp = Height(j) + 1;
      if(tmp > h){
	h = tmp;
      } }
  }
    return h; }



Measured memory_bytes: 2052
#include <stdio.h>
int a[200000];
int tag;
int main()
{
	int i,j,n,sum=0;
	tag=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		if(a[i]<=a[tag])
		{
			sum++;
			tag=i;
		}
	}
	printf("%d",sum);
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long ,long long>pll;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
   int n,m;
   cin >> n >> m;
   vector<int>a(m);
   vector<int>k(m,0);
   for(int i = 0;i<m;i++){
    int b;
    cin >> a[i] >> b;
    for(int j = 0;j<b;j++){
        int c;cin >> c;
        c--;c = 1<<c;
        k[i] = (k[i]|c);
    }
   }
   vector<vector<int>>dp(m+1,vector<int>((1<<n),INF32));
   for(int i = 0;i<=m;i++) dp[i][0] = 0;
   for(int i = 1;i<=m;i++){
    for(int j = 0;j<(1<<n);j++){
        dp[i][j] = min(dp[i-1][j],dp[i][j]);
        dp[i][(j|k[i-1])] = min(dp[i-1][j]+a[i-1],dp[i][(j|k[i-1])]);
    }
   }
   if(dp[m][(1<<n)-1] == INF32) cout << -1;
   else cout << dp[m][(1<<n)-1];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 19264
N=int(input())
LA=list(map(int,input().split()))

Minus=0
Zero=0
L_absolute=[]

for i in LA:
    if i<0:
        L_absolute.append(i*(-1))
        Minus+=1
    elif i==0:
        Zero=1
    else:
        L_absolute.append(i)
        
L_absolute.sort()

if Zero==1:
    ans=sum(L_absolute)
elif Minus%2==1:
    ans=sum(L_absolute)-2*L_absolute[0]
else:
    ans=sum(L_absolute)
    
print(ans)

Measured memory_bytes: 14224
#include<iostream>
#include<algorithm>
 
using namespace std;
 
int res[100000];
 
int main(){
 
    int n,m,temp;
    cin >> n >> m;
    int num[m];
    for(int i=0;i<m;i++){
    cin >> num[i];
    res[num[i]] = 1;
    }
    bool flag=true;
    while(flag){
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
        if(res[i] > 0 ){
            if(res[i+num[j]] == 0) res[i+num[j]] = res[i]+1;
            else{res[i+num[j]] = min(res[i+num[j]],res[i]+1);
            if(i+num[j] == n) flag = false;
            }
        }
        }
    }
    }
     
    cout << res[n]<< endl;
 
    return 0;
}

Measured memory_bytes: 1392
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	i64 ans1 = 0;
	ans1 += x * a;
	ans1 += y * b;

	i64 ans2 = 0;
	ans2 += (max(x, y)) * 2 * c;

	i64 ans3 = 0;
	int tmp = min(x, y);
	ans3 += (min(x, y)) * 2 * c;
	x -= tmp;
	y -= tmp;
	ans3 += x * a;
	ans3 += y * b;
	cout << min(min(ans1, ans2), ans3) << endl;
	return 0;
}

Measured memory_bytes: 256
def answer(n):
    _except = 0
    stack = 0
    arr = []
    i = 0
    while(True):
        if stack == n:
            break
        if stack > n:
            _except = stack - n
            break
        i += 1
        arr.append(i)
        stack += i
    for a in arr:
        if a == _except:
            continue
        print(a)

n = int(input())
answer(n)

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

#define for_(i,a,b) for(int i=a;i<b;i++)
#define for_d(i,a,b) for(int i=a-1;i>=b;i--)
#define minit(a,b) memset(a,b,sizeof(b));

string board[8];
int dx[8] = {-1,-1,-1,0,1,1,1,0};
int dy[8] = {1,0,-1,-1,-1,0,1,1};

int getnum(char c, int x, int y) {
	int res = 0;
	char target = (c == 'o') ? 'x' : 'o';
	
	for_(d,0,8) {
		int cnt = 0;
		bool able = false;
		
		for (int i = 0; i < 8 && !able; i++) {
			int _x = x + (i + 1) * dx[d], _y = y + (i + 1) * dy[d];
			if (!(0 <= _x && _x < 8 && 0 <= _y && _y < 8)) break;
				
			if (board[_y][_x] == c) able = true;
			if (board[_y][_x] == target) cnt++;
			if (board[_y][_x] == '.') break;
		}
		
		if (able) res += cnt;
	}
	
	return res;
}

void simulate(char c, int x, int y) {
	board[y][x] = c;
	char target = (c == 'o') ? 'x' : 'o';
	
	for_(d,0,8) {
		int cnt = 0;
		bool able = false;
		
		for (int i = 0; i < 8 && !able; i++) {
			int _x = x + (i + 1) * dx[d], _y = y + (i + 1) * dy[d];
			if (!(0 <= _x && _x < 8 && 0 <= _y && _y < 8)) break;
				
			if (board[_y][_x] == c) able = true;
			if (board[_y][_x] == target) cnt++;
			if (board[_y][_x] == '.') break;
		}
		
		if (able) {
			for_(i,0,cnt) {
				int _x = x + (i + 1) * dx[d], _y = y + (i + 1) * dy[d];
				board[_y][_x] = c;
			}
		}
	}
	/*
	for_(i,0,8) cout << board[i] << endl;
	cout << endl;
	*/
}

bool MAMI() {
	int x = -1, y = -1;
	int maxi = 0;
	
	for_(i,0,8) {
		for_(j,0,8) {
			if (board[i][j] != '.') continue;
			int gn = getnum('o', j, i);
			if (maxi < gn) {
				maxi = gn;
				x = j; y = i;
			}
		}
	}
	
	if (x == -1) return false;
	simulate('o', x, y);
	return true;
}

bool CHARLOTTE() {
	int x = -1, y = -1;
	int maxi = 0;
	
	for_d(i,8,0) {
		for_d(j,8,0) {
			if (board[i][j] != '.') continue;
			int gn = getnum('x', j, i);
			if (maxi < gn) {
				maxi = gn;
				x = j; y = i;
			}
		}
	}
	
	if (x == -1) return false;	
	simulate('x', x, y);
	return true;
}

void solve() {
	bool run = true;
	while (run) {
		run &= MAMI();
		run |= CHARLOTTE();
	}
	//cout << "answer\n\n";
	for_(i,0,8) cout << board[i] << endl;
}

int main() {
	for_(i,0,8) cin >> board[i];
	solve();
	return 0;
}

Measured memory_bytes: 1184
#![allow(unused_imports)]

use itertools::Itertools;
use num::*;
use proconio::*;
use std::cmp::*;
use std::collections::*;
use std::process::exit;
use text_io::*;

fn main() {
    let h: usize = read!();
    let w: usize = read!();

    let mut m = vec![vec![' '; w]; h];
    for i in 0..h {
        let s: String = read!();
        let s = s.chars().collect_vec();
        for j in 0..w {
            m[i][j] = s[j];
        }
    }

    let mut bomb = vec![vec![0; w]; h];

    for i in 0..h {
        for j in 0..w {
            if m[i][j] == '#' {
                let (i, j) = (i as isize, j as isize);
                for (i, j) in [
                    (i - 1, j - 1),
                    (i - 1, j),
                    (i - 1, j + 1),
                    (i, j - 1),
                    (i, j + 1),
                    (i + 1, j - 1),
                    (i + 1, j),
                    (i + 1, j + 1),
                ]
                    .iter()
                    .filter(|(i, j)| (0..h as isize).contains(i) && (0..w as isize).contains(j))
                    .map(|&(i, j)| (i as usize, j as usize))
                {
                    bomb[i][j] += 1;
                }
            }
        }
    }

    for i in 0..h {
        for j in 0..w {
            if m[i][j] == '#' {
                print!("#");
            } else {
                print!("{}", bomb[i][j]);
            }
        }
        println!();
    }
}


Measured memory_bytes: 2200