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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e17;


vector<pii> edge[100005];
bool used[2][100005];
ll memo[2][100005];
bool ans_zero;
void dfs(int n, int sign=0, int val=0){
	if( memo[sign][n] == INF ){
		memo[sign][n] = val;
	}else if(memo[sign][n] != val){
		ans_zero = true;
	}
	if( used[sign][n] ) return;
	used[sign][n] = true;
	for(auto p: edge[n]){
		dfs(p.X, sign^1, p.Y - val);
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	int N, M, ans=0;

	cin >> N >> M;
	rep(i,M){
		int u, v, s;
		cin >> u >> v >> s;
		u--; v--;
		edge[u].emplace_back(v, s);
		edge[v].emplace_back(u, s);
	}

	Fill(memo, INF);
	dfs(0);

	ll mn = 1, mx = INF;
	rep(i,N){
		//cout << i << ": " << memo[0][i] << " " << memo[1][i] << endl;
		chmax(mn, 1 - memo[0][i]);
		chmin(mx, memo[1][i]);
		if( memo[0][i] < INF && memo[1][i] < INF ){
			ll val = (memo[1][i] - memo[0][i]) / 2;
			chmax(mn, val);
			chmin(mx, val+1);
			//cout << "eq: " << val << endl;
		}
	}
	//cout << mn << " " << mx << endl;

	if( ans_zero ){
		cout << 0 << endl;
	}else{
		cout << max(0ll, mx-mn) << endl;
	}

	return 0;
}

Measured memory_bytes: 14848
#include <iostream>
#include <cstdio>
#include <map>
#include <vector>
#include <cstring>
#include <algorithm>
//

using namespace std;
typedef long long ll;
int n,m;
struct P
{
    int l,r;
}p[100000+5];
bool cmp(const P &p1,const P &p2)
{
    if(p1.l==p2.l) return p1.r<p2.r;
    return p1.l<p2.l;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {
        scanf("%d%d",&p[i].l,&p[i].r);
    }
    sort(p,p+m,cmp);
    int sum=1;
    int l=p[0].l,r=p[0].r;
    for(int i=1;i<m;i++)
    {
        if(p[i].l<r)
        {
            l=p[i].l;
            r=min(r,p[i].r);
        }
        else {sum++;l=p[i].l;r=p[i].r;}
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vec vector <ll>
ll n;
vec arr;
ll dp[3001][3001][2];
ll func(ll l,ll r,bool turn) {
	if(l > r)
		return 0;
	if(dp[l][r][turn] != -1)
		return dp[l][r][turn];
	ll v1 = func(l + 1,r,!turn);
	ll v2 = func(l,r -1,!turn);
	if(turn) {
		dp[l][r][turn] = max(v1 + arr[l],v2 + arr[r]);
	}
	else
		dp[l][r][turn] = min(v1,v2);
	return dp[l][r][turn];
}	
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	arr.resize(n);
	ll i,j,k;
	for(i = 0 ; i <= n ; i++)
		for(j = 0 ; j <= n ; j++)
			for(k = 0; k < 2 ; k++)
				dp[i][j][k] = -1;
	for(i = 0 ; i < n ; i++)
		cin >> arr[i];
	ll x = func(0,n-1,true);
	ll y = func(0,n-1,false);
	cout << x - y;
	return 0;
}

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

#define pb push_back
#define S second
#define F first
#define sz size()
#define eps 0.000001
#define oo 2000000007
#define endl '\n'
#define bg begin()
#define nd end()
#define up upper_bound
#define lw lower_bound
#define debug(x) #x << " = " << x << "; "
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

string s;
int D, N, MOD = 1e9+7;
const int MAX = 10e4+3;
int dp[MAX][101][2];

int f(int i, int mod, bool menor){
	if(i == N) return (mod == 0);
	int &ans = dp[i][mod][menor];
	if(ans != -1) return ans;
	ans = 0;
	if(menor){
		for(int d = 0; d < 10; d++){
			ans = (ans + f(i + 1, (mod + d)%D, menor)%MOD)%MOD;
		}
	}else{
		int p = s[i] - '0';
		for(int d = 0; d < p; d++){
			ans = (ans + f(i + 1, (mod + d)%D, !menor)%MOD)%MOD;
		}
		ans = (ans + f(i + 1, (mod + p)%D, menor)%MOD)%MOD;
	}
	return ans;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> s >> D;
	N = s.size();
	memset(dp, -1, sizeof(dp));
	int ans = f(0, 0, 0);
	cout << (ans - 1 + MOD)%MOD << endl;
}

Measured memory_bytes: 80128
# -*- coding: utf-8 -*-
 
n,t = map(int, raw_input().split())
a = map(int, raw_input().split()) 
 
m = 10**9+1
num = 0
diff = 0
for i in range(n):
    if(a[i]<m):
        m = a[i]
    if(a[i]-m > diff):
        diff = a[i]-m
        num = 1
    elif(a[i]-m == diff):
        num += 1
print(num)

Measured memory_bytes: 11328
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():

    N, M, V, P = geta(int)
    A = [-10**15] + list(geta(int))
    A.sort()

    target = A[N - P + 1]

    def c(x):
        """
        return True iff Problem x has chance to be chosen 
        """
        if x >= N - P + 1:
            return True

        v_left = M * max(V - x - P + 1, 0)

        Ax = A[x] + M
        if Ax < A[N - P + 1]:
            return False

        ok = False
        for i in range(x + 1, N - P + 1 + 1):
            ad = min(M, Ax - A[i])
            v_left -= ad
            if v_left <= 0:
                ok = True
                break

        return ok

    left, right = 0, N
    while left + 1 < right:
        middle = (left + right) // 2
        if c(middle):
            right = middle
        else:
            left = middle

    print(N - right + 1)


if __name__ == "__main__":
    main()

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

int main(){
	int n, AliceC = 0, BobC = 0, i, num;
	vector<int> v;
	cin >> n;
	for (i = 0; i < n; i++){
		cin >> num;
		v.insert(v.begin() + i, num);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());

	for (i = 0; i < n; i++){
		if (i % 2 == 0){
			AliceC += v[i];
		}
		else{
			BobC += v[i];
		}
	}
	cout << AliceC - BobC << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;
struct edge { ll to, cost; };

const int MAX_V =1000000;
const ll INF = 1LL<<60;

int V;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(ll s) {
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        rep(i,G[v].size()) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int H, W, Ch, Cw, Dh, Dw;
    cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
    V = H * W;
    vector<string> S(H);
    rep(i, H) cin >> S[i];
    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '#') continue;
            int x = i * W + j;
            rep(k, 5) {
                rep(l, 5) {
                    if (k == 2 && l == 2) continue;
                    int ni = i + k - 2, nj = j + l - 2;
                    if (ni < 0 || ni > H - 1 || nj < 0 || nj > W - 1) continue;
                    if (S[ni][nj] == '#') continue;
                    if (abs(ni - i) + abs(nj - j) == 1) {
                        G[x].push_back({ni * W + nj, 0});
                    } else {
                        G[x].push_back({ni * W + nj, 1});
                    }
                }
            }
        }
    }
    dijkstra((Ch - 1) * W + Cw - 1);
    ll ans = d[(Dh - 1) * W + Dw - 1];
    if (ans == INF) ans = -1;
    cout << ans << "\n";
    /*
    rep(i, H) {
        rep(j, W) {
            cout << d[i * W + j];
        }
        cout << "\n";
    }
    */
}

Measured memory_bytes: 168560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1, class T2>ostream& operator<<(ostream& os, const pair<T1, T2>&a)
{
   return os << "(" << a.first << "," << a.second << ")";
}
template<class T>void pv(T a, T b)
{
   for(T i = a; i != b; ++i)
      cout << (*i) << " ";
   cout << endl;
}
template<class T>void chmin(T&a, const T&b)
{
   if(a > b)
      a = b;
}
template<class T>void chmax(T&a, const T&b)
{
   if(a < b)
      a = b;
}

int nextInt()
{
   int x;
   scanf("%d", &x);
   return x;
}

const int maxn = 207;
int n,m;//n个点，m条边
bool col[maxn];//对点进行染色
bool vis[maxn];//标记点
int link[maxn];//将两点进行连接

vector<int> edge[maxn];
void addedge (int u, int v) {//加边，根据题意双向还是单向
    edge[u].push_back(v);
    edge[v].push_back(u);
}


bool color (int u) {//染色判断是否是二分图，如果不是返回false
    for (auto v : edge[u]) {
        if (!col[v]) {//如果这个点没有被染过色
            col[v] = !col[u];//将这个点染成和他父节点相反的颜色
            if (!color(v)) return false;//然后再从这个点出发继续染色，如果染色失败返回false
        } else if (col[v] == col[u]) return false;
        //如果这个点已经染色而且和它的父节点一样，说明不是二分图，返回false
    }
    return true;
}


bool dfs(int u) {
    //进行dfs增广，一旦找到一个未匹配的点或者是可以进行增广的点就返回true
    for(auto v = edge[u].begin() ; v!=edge[u].end() ; v++) {
        if(!vis[*v]) {
            vis[*v] = true;//这里不要忘了将点标为已访问避免死循环
            if(link[*v] == -1 || dfs(link[*v])) {
                //如果这个点没有被配对，说明这是一条增广路
                //或者是从这个点所在边的另一点可以找到增广路
                link[*v] = u;
                link[u] = *v;
                //将两点进行连接
                return true;
            }
        }
    }
    return false;//这里不要忘了写
}

int match() {
    int ans = 0;
    CLR(link, -1);//将所有的点置为未连接
    for (int i = 1; i <= n; i++)
        if (link[i] == -1) {//如果这个点没有和其它点连边
            CLR(vis, 0);//初始化
            if (dfs(i)) ans++;//如果找到增广路说明最大匹配+1
        }
    return ans;
}

void init () {
    CLR(col,0);
    //不要忘了对vector的初始化
    for(int i=1 ; i<=n ; i++) edge[i].clear();
}
int main()
{   
   int _n;
   int red[100][2], blue[100][2];

   while(cin >> _n){
      n = 2 * _n;
      init();
      for(int i = 1; i <= _n; i++)
         cin >> red[i][0] >> red[i][1];
      for(int i = 1; i <= _n; i++)
         cin >> blue[i][0] >> blue[i][1];
      for(int i = 1; i <= _n; i++)
      for(int j = 1; j <= _n; j++){
         if(red[i][0] < blue[j][0] && red[i][1] < blue[j][1]){
            addedge(i, j + _n);
         }
      }
      printf("%d\n", match());

   }

   return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  string s;
  cin >> n >> s;
  ll res = 0;
  rep(i, 10) {
    rep(j, 10) {
      rep(k, 10) {
        bool a = 0, b = 0, c = 0;
        rep(l, n) {
          if (ctoi(s.at(l))==i && !a) {
            a = 1;
            continue;
          }
          if (ctoi(s.at(l))==j && a && !b) {
            b = 1;
            continue;
          }
          if (ctoi(s.at(l))==k && a && b && !c) {
            c = 1;
            continue;
          }
        }
        if (c) res++;
      }
    }
  }
  cout << res << endl;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;
#define debug(x) cerr << #x << ": " << (x) << "\n";

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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 ll mod = 1e9+7;
vl table(200005);
void init() {
  table[0] = 1ll;
  rep(i, 1, 200005) {
    table[i] = 2ll * table[i-1];
    table[i] %= mod;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  ll c;
  vl C(n);
  rep(i, 0, n) {
    cin >> C[i];
  }
  sort(All(C));
  init();

  ll ans = 0ll;
  rep(i, 0, n) {
    ll ci = C[i];
    int l = i;
    int r = n-1-i;
    ll ll_r = (ll) r;
    ll tmp;
    if (r == 0) {
      tmp = 0ll;
    } else {
      tmp = table[r-1] * ll_r;
      tmp %= mod;
    }
    ll tmp2 = ((table[r] + tmp) % mod) * table[l] % mod;
    tmp2 *= ci;
    tmp2 %= mod;
    ans += tmp2;
    ans %= mod;
  }
  ans *= table[n];
  ans %= mod;
  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 3456
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1LL << 62
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i, m) for (int i = 0; i < m; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ALL(v) v.begin(),v.end() 
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main(){
  int a, b;
  cin >> a >> b;
  int ans = 0;
  FOR(i, a, b+1){
    string s = to_string(i);
    if(s[0] == s[4] && s[1] == s[3]) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

struct Node {
  int key;
  Node *prev, *next;
};
Node *nil;

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

void printList() {
  Node *cur = nil->next;
  bool addSpace = false;
  for (Node *cur = nil->next; cur != nil; cur = cur->next) {
    if (addSpace) cout << " ";
    cout << cur->key;
    addSpace = true;
  }
  cout << endl;
}

Node* listSearch(int key) {
  Node *cur;
  for (cur = nil->next; cur != nil; cur = cur->next) {
    if (cur->key == key) break;
  }
  return cur;
}

void deleteNode(Node *t) {
  if (t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

int main() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    char q[10]; int a;
    scanf("%s%d", q, &a);
    if (q[0] == 'i') {
      insert(a);
    } else if (q[6] == 'F') {
      deleteFirst();
    } else if (q[6] == 'L') {
      deleteLast();
    } else {
      deleteKey(a);
    }
  }
  printList();
}


Measured memory_bytes: 34376
#create date: 2020-07-05 10:44

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    a, b = na()
    if a > b:
        a, b = b, a
    if (b - a) % 2 != 0:
        print("IMPOSSIBLE")
        quit()
    else:
        print(a + (b-a)//2)
if __name__ == "__main__":
    main()

Measured memory_bytes: 9196
#include<iostream>
#include<vector>

using namespace std;

int main() {
	int n, k, t = 0;
	cin >> n;
	vector<int> a;
	a.push_back(0);
	for (int i = 1; i <= n + 1; i++) {
		if (i == n + 1) a.push_back(0);
		else {
			cin >> k;
			a.push_back(k);
		}
		if (a[i] - a[i - 1] >= 0) t += a[i] - a[i - 1];
		else t += a[i - 1] - a[i];
	}
	for (int i = 1; i <= n; i++) {
		if (a[i-1] <= a[i] && a[i] <= a[i+1]) cout << t << endl;
		else if (a[i-1] <= a[i+1]&&a[i+1] <= a[i]) cout << t - (a[i] + a[i] - a[i-1] - a[i+1]) + (a[i+1] - a[i-1]) << endl;
		else if (a[i] <= a[i-1]&&a[i-1] <= a[i+1]) cout << t - (a[i+1] + a[i-1] - a[i] - a[i]) + (a[i+1] - a[i-1]) << endl;
		else if (a[i+1] <= a[i]&&a[i] <= a[i-1]) cout << t << endl;
		else if (a[i+1] <= a[i-1]&&a[i-1] <= a[i]) cout << t - (a[i] + a[i] - a[i+1] - a[i-1]) + (a[i-1] - a[i+1]) << endl;
		else if (a[i] <= a[i+1]&&a[i+1] <= a[i-1]) cout << t - (a[i-1] + a[i+1] - a[i] - a[i]) + (a[i-1] - a[i+1]) << endl;
	}
}

Measured memory_bytes: 1784
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<string>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, a[1001000];
int G[110];

int insertionSort(int g){
    int cnt = 0;
    for(int i = g; i < N; i++){
        int v = a[i];
        int j = i - g;
        while(j >= 0){
            if(a[j] <= v)break;
            a[j + g] = a[j];
            j -= g;
            cnt++;
        }
        a[j + g] = v;
    }
    return cnt;
}

signed main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    int g = 1;
    int m = 0;
    while(g <= N){
        G[m++] = g;
        g = g * 3 + 1;
    }
    int cnt = 0;
    for(int i = m - 1; i >= 0; i--){
        cnt += insertionSort(G[i]);
    }
    printf("%lld\n", m);
    for(int i = m - 1; i >= 0; i--){
        cout << G[i] << ((i == 0) ? "\n" : " ");
    }
    printf("%lld\n", cnt);
    for(int i = 0; i < N; i++){
        printf("%lld\n", a[i]);
    }


    return 0;
}

/*

*/


Measured memory_bytes: 11032
N,x=map(int,input().split())
A=list(map(int,input().split()))
A_1=sorted(A)
num=0
total=0
if A_1[0]>x:
    num=0
elif sum(A_1)>=x:
    for i in range(N):
        total+=A_1[i]
        if total==x:
            num+=1
            break
        elif total>x:
            break
        else:
            num+=1

else:
    num=N-1
print(num)
    

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

#define cc(x) cout << (x) << endl
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); ++i)
typedef long long ll;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

const ll inf = 1LL<<58;
const int iinf = 1<<30;



int main(){
    ll n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    vector<int> sakadachi = {0};
    int tmp=0;
    int ichi=0;
    int zerocount=0;
    int ichicount=0;
    rep(i,s.length()){
        if(ichi==1&&s[i]=='1'){
            ichicount++;
        }else if(ichi==1&&s[i]=='0'){
            rep(j,sakadachi.size()){
                sakadachi[j]+=ichicount;
            }
            if(sakadachi.size()==k+1 && tmp<sakadachi[0]){
                tmp=sakadachi[0];
                sakadachi.erase(sakadachi.begin());
            }else if(sakadachi.size()==k+1){
                sakadachi.erase(sakadachi.begin());
            }
            ichi=0;
            ichicount=0;
            zerocount=1;
        }else if(ichi==0&&s[i]=='0'){
            zerocount++;
        }else if(ichi==0&&s[i]=='1'){
            rep(j,sakadachi.size()){
                sakadachi[j]+=zerocount;
            }
            sakadachi.push_back(0);
            ichi=1;
            zerocount=0;
            ichicount=1;
        }
    }

    if(ichi==0){
        sakadachi[0]+=zerocount;
        amax(tmp,sakadachi[0]);
    }else{
        sakadachi[0]+=ichicount;
        amax(tmp,sakadachi[0]);
    }
    cc(tmp);
}

Measured memory_bytes: 640
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}
vector<pint> A;
bool cmp(pint a, pint b) { return a.second > b.second; }


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll h,w;
  cin>>h>>w;
  ll n;
  cin>>n;
  vector<pint> v(n);
  rep(i,n){
    v[i].first=i+1;
    cin>>v[i].second;
  }
  sort(ALL(v),cmp);
  vector<ll> ans;
  rep(i,n){
    rep(j,v[i].second){
      ans.push_back(v[i].first);
    }
  }
  bool flag=true;
  ll cnt=0;
  rep(i,h){
    if(flag){
      rep(j,w){
        cout<<ans[j]<<' ';
      }
      cout<<endl;
      ans.erase(ans.begin(),ans.begin()+w);
    }else{
      rep(j,w){
        cout<<ans[w-j-1]<<' ';
      }
      cout<<endl;
      ans.erase(ans.begin(),ans.begin()+w);
    }
    flag=!flag;
  }
}

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

using namespace std;

int main(){
 int n;
 string s1, s2;
 int a=0, b=0;
 cin>>n;
 for(int i=0; i<n; i++){
  cin >> s1 >> s2;
  if(s1> s2) a+=3;
  else if(s1 < s2) b+=3;
  else{
   a++; b++;
  }
 }
 cout <<a << " " << b << endl;
 return 0;
}


Measured memory_bytes: 3208
#include <iostream>

using namespace std;

int main(){
    char c;

    cin >> c;
    if(c == 'A'){
        cout << 'T' << endl;
    }else if(c == 'T'){
        cout <<  'A' << endl;
    }else if(c == 'G'){
        cout << 'C' << endl;
    }else{
        cout << 'G' << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main()
{
    string S;

    cin >> S;

    int N = S.length();

    int red = 0;
    int blue = 0;

    for (int i = 0; i < N; i++)
    {
        if (S[i] == '0')
        {
            red++;
        }
        else
        {
            blue++;
        }
    }

    int ans = min(red, blue) * 2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys
from collections import Counter
sys.setrecursionlimit(10**8)
INF = float("inf")


def eratosthenes_sieve(n):
    table = [0] * (n + 1)
    prime_list = []

    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1

    return prime_list


def main():
    N = int(input())

    table = [0] * (N + 1)
    table[0] = 0
    table[1] = 1
    prime_list = []

    for i in range(2, N + 1):
        if table[i] == 0:
            prime_list.append(i)
            table[i] = 2
            for j in range(i + i, N + 1, i):
                c = j
                cnt = 0
                while c % i == 0:
                    c //= i
                    cnt += 1
                table[j] = table[c]*(cnt+1)
    # print(table)
    ans = 0
    for i in range(N+1):
        ans += i*table[i]
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 184984
#include<iostream>

using namespace std;

int main(){
  for(int n;cin>>n,n>=0;){
    bool m[9][9][9][9]={};
    while(n--){
      char d;
      int x,y;
      cin>>d>>x>>y;
      m[y][x][y+(d=='y')][x+(d=='x')]=true;
    }
    int y=1,x=2,d=1;
    for(;;){
      if(m[y/2][x/2][y/2+y%2][x/2+x%2]){
	d^=(y%2)?3:1;
      }else if(y==0||x==0||y==16||x==16){
	cout<<x*100/2<<' '<<y*100/2<<endl;
	break;
      }
      static int dy[]={-1,1,1,-1};
      static int dx[]={1,1,-1,-1};
      int ny=y+dy[d];
      int nx=x+dx[d];
      if(y+ny==1&&x+nx==3){
	cout<<"75 25"<<endl;
	break;
      }
      y=ny;
      x=nx;
    }
  }
}

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

int main(){

	int N;
	cin >> N;

	int league[100];
	for(int i=0;i<N;i++){
		league[i] = 0;
	}

	for(int i=0;i<N*(N-1)/2;i++){
		int Ai,Bi,Ci,Di;
		cin >>  Ai >> Bi >> Ci >> Di;
			if(Ci < Di){
				league[Bi-1] += 3;
			}

			else if(Ci > Di){
				league[Ai-1] += 3;
			}

			else{
				league[Ai-1]++;
				league[Bi-1]++;
			}
	}

	int sorted[100];
	for(int i=0;i<N;i++){
		sorted[i] = league[i];
	}

	sort(sorted,sorted+N);
	reverse(sorted,sorted+N);

	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(league[i] == sorted[j]){
				league[i] = j+1;
				break;
			}
		}
	}

	for(int i=0;i<N;i++){
		cout << league[i] << endl;
	}

	return 0;
}


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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    if(s[0] != s[1] || s[1] != s[2]){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}


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

using namespace std;

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n, a[1000005], cnt = 0, ans = 0;
string s;
int main () {
	cin >> s;
	for(int i = 0; i < s.size();i++) {
		for(int j = i + 1; j < s.size(); j++) {
			if(s[i] == s[j]) {
				cnt++;
			}
		}
	}
	if(cnt == 2) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		d--;
		x += n;
		for(int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			x += d / tmp;
		}
		System.out.println(x);
	}

}


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

vector<int> solve(ll D, ll M, vector<ll>& C, vector<vector<ll>>& S) {
    vector<int> T(D);
    vector<ll> L(M);
    for ( int d = 0; d < D; d++ ) {
        int t = 0;
        ll dv = -(1LL<<60);
        for ( int i = 0; i < M; i++ ) {
            L[i] += C[i];
            if ( dv < S[d][i] - L[i] ) {
                dv = S[d][i] - L[i];
                t = i;
            }
        }
        L[t] = 0;
        T[d] = t;
    }
    return T;
}

int main() {
    ll D, M = 26;
    cin >> D;
    vector<ll> C(M);
    for ( int i = 0; i < M; i++ ) {
        cin >> C[i];
    }
    vector<vector<ll>> S(D, vector<ll>(M));
    for ( int i = 0; i < D; i++ ) {
        for ( int j = 0; j < M; j++ ) {
            cin >> S[i][j];
        }
    }
    vector<int> T = solve(D, M, C, S);
    for ( int i = 0; i < D; i++ ) {
        cout << T[i]+1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 3736
#include<stdio.h>

int main(){
	int nn;
	scanf("%d",&nn);
	char a[300];

	int jdl=0;  // judge number left
	int jdr=0;  // judge number right

	scanf("%s",a);

	int i;
	for(i=0;i<nn;i++){
		if(a[i]=='(')
			jdr++;
		else if(jdr>0)
			jdr--;
		else
			jdl++;
	}

	for(i=nn-1;i>=0;i--){
		a[i+jdl]=a[i];
	}
	for(i=0;i<jdl;i++){
		a[i]='(';
	}

	for(i=0;i<jdr;i++){
		a[i+nn+jdl]=')';
	}

	a[nn+jdl+jdr]='\0';

	printf("%s\n",a);

	return 0;
}


Measured memory_bytes: 128
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
bool vi[ohara], mode;

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

  cin >> n >> m;
  // if (m < 1 || n > 100000 || m * 2 + 1 > n) return -1;
  if (n % 2 == 1) {
    ans = 1;
    tmp = n;
    rep(i, m) {
      cout << ans << " " << tmp << "\n";
      ans++;
      tmp--;
    }
  } else {
    ans = 1;
    tmp = n;
    ll lim = (n - 1) / 2;
    rep(i, m) {
      if (i + 1 <= (lim + 1) / 2)
        cout << i + 1 << " " << n - i << "\n";
      else
        cout << i + 1 << " " << n - i - 1 << "\n";
    }
  }
  // Cout(ans);
  return 0;
}


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

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define MP(a,b) make_pair((a), (b))
#define ROUNDUP(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second
#define DEBUG(a) cout << #a << ": " << a << "\n"
// #define DEBUG(a) {}

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

template<typename T>
T debug(T x) {
	DEBUG(x);
	return x;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
  int n;
	cin >> n;
	cout << n / 3 << "\n";
	return 0;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t r, g, b, n;
  std::cin >> r >> g >> b >> n;
  int64_t c = 0;

  for (int64_t i = 0; i <= n / r; i++) {
    for (int64_t j = 0; j <= n / g; j++) {
      const auto le = n - i * r - j * g;
      if (0 <= le && le % b == 0) {
        c++;
      }
    }
  }
  std::cout << c << std::endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n; cin >> n;
    string s; cin >> s;
    if(n<3200)s = "red";

    cout << s << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    long N = sc.nextInt();
	    long M = sc.nextInt();
	    long count = N;
	    for(int i = 0; i < M; i++) {
	        count -= sc.nextLong();
        }
	    if(count < 0) {
            System.out.println(-1);
        }else {
            System.out.println(count);
        }
	}
}

Measured memory_bytes: 46336
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

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

  ll ans = 0;
  ans += pow(n / k, 3);
  if (!(k & 1)) {
    n += k / 2;
    ans += pow(n / k, 3);
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

void call(int n);

int main(){
    int n;
    cin >> n;
    call(n);
    return 0;
}

void call(int n){
    for(int i = 1; i <= n; ++i){
        int x = i;
		if(0 == x % 3){
            cout << " " << i;
        }else{
			while(x){
				if(3 == x % 10){
            		cout << " " << i;
                    break;
                }else{
                    x /= 10;
                }
			}
		}
	}
    cout << endl;
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll INF = 1101101101101;
typedef pair<int, int> P;

int main() {
  int n;
  cin >> n;
  int f[n][10];
  rep(i, n) rep(j, 10) cin >> f[i][j];
  int p[n][10];
  rep(i, n) rep(j, 11) cin >> p[i][j];
  ll ma = -INF;

  for (int bit = 0; bit < (1 << 10); ++bit) {
    bool ok = true;
    vector<int> a(n);
    for (int i = 0; i < 10; ++i) {
      rep(t, n) {
        if (bit & (1 << i) && f[t][i] == 1) {
          ok = false;
          a[t]++;
        }
      }
      ll total = 0;
      rep(i, n) total += p[i][a[i]];
      if (ok) continue;
      ma = max(total, ma);
    }
  }
  cout << ma << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int a[100000][3],dp[100000][3];

int main()
{
	int n,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++){
        for(j=0;j<3;j++)
            scanf("%d",&a[i][j]);
	}
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
	}
	printf("%d\n",max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]));
	return 0;
}




Measured memory_bytes: 2560
{-# LANGUAGE OverloadedStrings #-}

import           Data.Char
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed   as U
import qualified Data.IntMap           as M

main :: IO ()
main = do
  abs <- U.unfoldrN 6 (B.readInt . B.dropWhile isSpace) <$> B.getContents
  B.putStrLn $ if solve abs then "YES" else "NO"

solve :: U.Vector Int -> Bool
solve = (<= 2) . M.size . M.filter odd  . U.foldr (\k mp -> M.insertWith (+) k 1 mp) M.empty

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

#define ll long long

int main(){
	ll n, k;
	cin >> n >> k;
	ll a[n];
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = k; i < n; i++){
		if (a[i] > a[i-k]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}

}

Measured memory_bytes: 5188
#include<bits/stdc++.h> 
#include<map>
using namespace std; 
map< string,int >mp;
char temp1[12],a[200000][10];

int n,temp,flag=0,i,k=0,sum=0,j,max11[200000];


int main(){

	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]]++;
		if(mp[a[i]]>1){
			i--;
			n--;
		}
	    
	}
	int mx = 0;
    map<string,int>::iterator it;
   
	for( it=mp.begin();it!=mp.end();it++)
		mx = max(mx, it->second);
	for(it=mp.begin();it!=mp.end();it++){
		if(mx == it->second)
			cout << it->first << "\n";
	}
}

Measured memory_bytes: 25856
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, b, f, r, v, room[4][3][10] = {0};
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    room[b - 1][f - 1][r - 1] = room[b - 1][f - 1][r - 1] + v;
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 9; k++) {
        cout << " " << room[i][j][k];
      }
      cout << " " << room[i][j][9] << endl;
    }
    if (i != 3) {
      cout << "####################" << endl;
    }
  }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

string hw[101];

int main() {
    int h, w;
    cin >> h >> w;
    rep(i, h) cin >> hw[i];
    for (int i = 0; i < h+2; ++i) {
        for (int j = 0; j < w+2; ++j) {
            if (i == 0 or i == h+1 or j == 0 or j == w+1) cout << "#";
            else cout << hw[i-1][j-1];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d", $N);
  $arrayA = explode(" ",trim(fgets(STDIN)));

  $count=0;
  for($i=0;$i<$N-1;$i++)
  {
    if($arrayA[$i] == $arrayA[$i+1])
    {
      if($N>$i+2 && $arrayA[$i] == $arrayA[$i+2])
      {
        $i++;
      }
      $count++;
    }
  }
  echo $count;
 ?>

Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
const int maxn = 250005;

void go() {
    int n, k;
    cin >> n >> k;
    vector<int>v(n);
    for (auto &i : v) {
    	cin >> i;
    }
    int dp[n] = {};
    dp[n - 1] = 0;
    for (int i = n - 2 ; i >= 0 ; i--) {
    	int mi = INT_MAX;
    	for (int j = i + 1 ; j <= min(i + k, n - 1) ; j++) {
    		mi = min(mi, dp[j] + abs(v[i] - v[j]));
    	}
    	dp[i] = mi;
    }
    cout << dp[0] << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}


Measured memory_bytes: 4040
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  map<string,int> mp;
  rep(i,n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  int mx = 0;
  for( auto p : mp) mx = max(mx, p.second);
  for(auto p : mp) {
    if(p.second != mx) continue;
    cout << p.first << endl;
  }
  return 0;
}


Measured memory_bytes: 25216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = Enumerable.Range(0, 10).Select(_ => int.Parse(Console.ReadLine())).ToList();

            list.Sort();
            Console.WriteLine(
                list.AsEnumerable()
                    .Reverse()
                    .Take(3)
                    .Select(_ => _.ToString())
                    .Aggregate((a, b) => a + Environment.NewLine + b));
        }
    }
}

Measured memory_bytes: 6056
l = [1, 2, 4, 8, 16, 32, 64]
n = int(input())
if n in l:
    l.append(n)
    l.sort()
    print(l[l.index(n)])
else:
    l.append(n)
    l.sort()
    print(l[l.index(n)-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define w(t) int t;cin>>t;while(t--)
#define pb   push_back
#define mk   make_pair
typedef long long ll;
const ll mod=1e9+7;

int solve(vector<int>A,int k,int n){
	vector<int>dp(n+1);
	dp[1]=0;
	for(int i=2;i<=n;i++){
		dp[i] =INT_MAX;
        for(int j=i-1;j>=1 && (i-j)<=k;j--){
            dp[i]=min(dp[i],abs(A[i]-A[j])+dp[j]);
        }
	}
	return dp[n];
}
int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr);
    int n;cin>>n;
    vector<int>A(n+1);
    int k;cin>>k;
    for(int i=1;i<=n;i++)cin>>A[i];
    cout<<solve(A,k,n);

   
    return 0;
  
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,K;
  cin>>N>>K;
  vector<int64_t>h(N);
  for(int i=0;i<N;i++)
    cin>>h.at(i);
  sort(h.begin(),h.end());
  int64_t Min=h.at(K-1)-h.at(0);
  
  for(int i=0;i<=N-K;i++)
     if(h.at(i+K-1)-h.at(i)<=Min)
       Min=h.at(i+K-1)-h.at(i);
  cout<<Min<<endl;
return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef pair<int, int> P;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N + 1, 0), B(M + 1, 0);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];

    sort(all(A));
    reverse(all(A));
    sort(all(B));
    reverse(all(B));

    ll ans = 1;
    ll a = 0, b = 0;

    for (ll num = N * M; num > 0; num--) {
        ll cal;
        if ((A[a] > num) || (B[b] > num)) {
            ans = 0;
            break;
        }
        if (A[a] == num && B[b] == num) {
            cal = 1;
            a++;
            b++;
        }
        else if (A[a] == num) {
            cal = b;
            a++;
        }
        else if (B[b] == num) {
            cal = a;
            b++;
        }
        else {
            cal = a * b - (N * M - num);
            if (cal <= 0) {
                ans = 0;
                break;
            }
        }
        ans *= cal;
        ans %= MOD;
        // cout << num << " " << ans << endl;
    }

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

Measured memory_bytes: 256