akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n, l; cin >> n >> l;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    sort(all(s));

    rep(i, n) cout << s[i];
    cout << endl;

return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < int(n); ++ (i))
#define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = int(n) - 1; (i) >= int(m); -- (i))
#define ALL(x) begin(x), end(x)
#define dump(x) cerr << #x " = " << x << endl
#define unittest_name_helper(counter) unittest_ ## counter
#define unittest_name(counter) unittest_name_helper(counter)
#define unittest __attribute__((constructor)) void unittest_name(__COUNTER__) ()
using ll = long long;
using namespace std;

vector<int> realize(int n, vector<int> const & a, vector<bool> const & used) {
    vector<int> s;
    REP (i, n) if (used[i]) {
        s.push_back(i);
    }
    return s;
}

vector<int> solve(int n, vector<int> const & a) {
    vector<bool> used(n);
    int minus_two = 0;
    bool minus_one = false;
    REP (i, n) {
        switch (a[i]) {
            case  2: used[i] = true; break;  // use 2
            case  1: /* nop */ break;
            case  0: /* nop */ break;
            case -1: minus_one = true; break;
            case -2: minus_two += 1; break;
            default: assert (false);
        }
    }
    if (minus_two % 2 == 0) {
        minus_one = false;
    } else {
        if (not minus_one) {
            minus_two -= 1;
        }
    }
    // use -2
    int i = 0;
    while (minus_two --) {
        while (a[i] != -2) ++ i;
        used[i] = true;
        ++ i;
    }
    // use -1
    if (minus_one) {
        vector<bool> nused;
        REP (i, n) if (a[i] == -1) {
            if (nused.empty() or realize(n, a, used) < realize(n, a, nused)) {
                nused = used;
                nused[i] = true;
            }
        }
        used = nused;
    }
    return realize(n, a, used);
}

int main() {
    int n; scanf("%d", &n);
    vector<int> a(n); REP (i, n) scanf("%d", &a[i]);
    vector<int> result = solve(n, a);
    printf("%d\n", int(result.size()));
    for (int i : result) printf("%d\n", i + 1);
    return 0;
}



Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
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; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto e : s) os << e << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  cin >> T;
  while (T--) solve();
}

void solve() {
  int n;
  cin >> n;

  ll ans = 0;
  vector<vector<int> > x(n), y(n);
  rep(i, n) {
    int k, l, r;
    cin >> k >> l >> r;
    k--;
    ans += min(l, r);
    if (l > r) {
      x[k].eb(l - r);
    } else if (l < r) {
      y[k].eb(r - l);
    }
  }

  {
    priority_queue<int> q;

    for (int i = n - 1; i >= 0; --i) { // どんどん解禁されていく
      for (int j : x[i]) q.emplace(j);
      if (sz(q)) {
        ans += q.top();
        q.pop();
      }
    }
  }

  {
    priority_queue<int> q;
    rep3(i, 1, n) {
      for (int j : y[i - 1]) q.emplace(j);
      if (sz(q)) {
        ans += q.top();
        q.pop();
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 17100
from sys import stdin

def main():
    n = int(stdin.readline().rstrip())
    xs = [int(stdin.readline().rstrip()) for _ in range(n)]

    max_1 = max(xs)
    key_max = xs.index(max_1)

    for i in range(n):
        if key_max != i:
            print(max_1)
        elif i == 0:
            print(max(xs[i+1:]))
        elif i == n-1:
            print(max(xs[0:i]))
        else:
            print(max(max(xs[0:i]),max(xs[i+1:])))

if __name__ == '__main__':
    main()


Measured memory_bytes: 14044
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { std::cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll k; cin >> k;
    priority_queue<ll,vector<ll>,greater<ll>> que;
    rep(i,9){
        que.push(i+1);
    }
    Rep(i,k-1){
        ll x = que.top();
        que.pop();
        for(ll j = -1; j<=1; j++){
            ll add = (x%10) + j;
            if(add>=0 && add<=9){
                que.push(x*10+add);
            }
        }
    }
    cout << que.top() << endl;
}

Measured memory_bytes: 2420
#include<stdio.h>
 
#define	H	20
#define	W	20
 
int main(void){
 
	//int squ[H][W];
	int i,j;
	int h,w;
	int h_1,w_1;
	int cnt;
	scanf("%d %d",&h,&w);
 	scanf("%d %d",&h_1,&w_1);
 	cnt=h*w-(h_1*w+w_1*h-+h_1*w_1);
  /*
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			squ[i][j]=0;
		}
	}
	scanf("%d %d",&h_1,&w_1);
	for(i=0;i<h_1;i++){
		for(j=0;j<w_1;j++){
			squ[i][j]=1;
		}
	}
	for(i=0;i<h_1;i++){
		for(j=0;j<w_1;j++){
			if(squ[i][j]==1)	cnt++;
		}
	}
    */
	printf("%d",cnt);
 
return 0;
}

Measured memory_bytes: 128
import numpy as np
import math

def bigger_devisor(n):
  s = np.sqrt(n)
  i = math.ceil(s)
  while(n % i != 0):
    i += 1
  return i

n = int(input())
if bigger_devisor(n) > 9:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 12496
package main

import "fmt"

func match(idx int, s, t string) bool {
	for i := 0; i < len(t); i++ {
		if s[idx+i] != t[i] && s[idx+i] != '?' {
			return false
		}
	}
	return true
}

func fill(idx int, s, t string) string {
	tmp := []byte(s)
	for i := 0; i < len(t); i++ {
		tmp[idx+i] = t[i]
	}
	for i := 0; i < len(s); i++ {
		if tmp[i] == '?' {
			tmp[i] = 'a'
		}
	}
	return string(tmp)
}

func main() {
	sd, t := "", ""
	fmt.Scan(&sd, &t)
	//
	f := -1
//ln := len(sd) - len(t) + 1
//for i := 0; i < ln; i++ {
	ln := len(sd) - len(t)
	for i := ln ; i >= 0; i-- {
		if match(i, sd, t) {
			f = i
			break
		}
	}

	if f == -1 {
		fmt.Println("UNRESTORABLE")
	} else {
		fmt.Println(fill(f, sd, t))
	}

}


Measured memory_bytes: 512
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   1000000007
#define PI 2*acos(0.0)
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define N 2000010
int n;
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

vi prime;
bitset<N> ck;

void seive()
{
    for(int i = 3; 1LL*i*i <= N; i+=2)
        if(ck[i] == 0)
            for(int j = i*i; j<= N; j+= 2*i)
                ck[j] = 1;
    prime.pb(2);
    for(int i = 3; i<= N; i+=2)
        if(!ck[i])
            prime.pb(i);
}




vi fac(N+1);
void fact()
{
    fac[0] = 1;
    for(int i = 1; i<= N; i++)
        fac[i] = 1LL*fac[i-1]*i%mod;
}


ll bigmod(ll x, ll p)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}


ll ncr(int n, int r)
{
    ll res = (fac[n] * bigmod(1LL*fac[r] * fac[n-r]%mod, mod - 2))%mod;
    return res;
}



//=============================================ASIFAZAD==============================================//

int32_t main()
{
    io;
    fact();
    int n;
    cin>>n;
    ll ans = 0;
    for(int i = 2; i<= n; i++)
        ans = (ans + ncr(n, i)*(bigmod(2, i) - 2)%mod * bigmod(8, n-i)%mod)%mod;
    cout<<ans;

    return 0;
}


Measured memory_bytes: 11032
#define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MIN 39
#define MAX 150
int main(void)
{
	char *C[] = { "light fly" ,"fly","bantam","feather","light","light welter","welter","light middle","middle","light heavy","heavy" };
	double x, w[12] = { MIN,48,51,54,57,60,64,69,75,81,91,MAX };
	while (scanf_s("%lf",&x) != EOF) {
		for (int i = 1; i < 12; ++i) {
			if (w[i - 1] < x && x <= w[i]) {
				printf("%s\n", C[i - 1]);
				break;
			}
		}
	}
}

Measured memory_bytes: 1192
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
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;}
const ll INF = 1e18+1;


/*
きれいさはマイナスに振る、おいしさはプラスに振る...
など高々8通り考えればよい


したらそれぞれの場合でxとyとzを反転するかしないかで
マイナスしたものの各和のプライオリティキューにぶち込みM個取る
*/

int main() {
    int N, M;
    cin >> N >> M;
    vector<ll> x(N), y(N), z(N);
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i] >> z[i];

    ll res = -1;
    for (int s = 0; s < 8; s++) {
        ll sum=0, xm=1, ym=1, zm=1;
        if (s & 1) xm = -1;
        if (s & 2) ym = -1;
        if (s & 4) zm = -1;
        priority_queue<ll> que;
        for (int i = 0; i < N; i++) 
        que.push(xm*x[i]+ym*y[i]+zm*z[i]);

        for (int i = 0; i < M; i++) {
            sum += que.top(); que.pop();
        }
        chmax(res,sum);
    }
    cout << res << endl;

}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;
const ll MOD = 1000000007LL;

  
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

void solve()
{
  ll n;
  cin >> n;
  vector<mint> a(n);
  vector<mint> sum(n, 0);
  mint ans = 0;
  for(int i = 0; i < n; ++i)
  {
    cin >> a[i];
  }
  sum[0] = a[0];
  for(int i = 1; i < n; ++i)
  {
    sum[i] = a[i] + sum[i - 1];
  }

  for(int i = 0; i < n - 1; ++i)
  {
    ans += (sum.back() - sum[i]) * a[i];
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int main(){
  int N;
  cin >> N;
  for(int i=1;i<10;i++){
    if(N%i==0 && 1 <= N/i && N/i <= 9){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;
int N,Q;
int par[100010]; //親
int deep[100010]; //木の深さ

//ｎ要素で初期化
void init(int n) {
	for(int i = 0;i < n;i++) {
		par[i] = i;
		deep[i] = 0;
	}
}

//木の根を求める
int find(int x) {
	if(par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

//ｘとｙの属する集合を併合
void unite(int x,int y) {
	x = find(x);
	y = find(y);
	if(x == y) {
		return;
	}
	if(deep[x] < deep[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if(deep[x] == deep[y]) {
			deep[x]++;
		}
	}
}

//ｘとｙが同じ集合の属するか否か
bool same(int x,int y) {
	return find(x) == find(y);
}

signed main() {
	cin >> N >> Q;
	init(N);
	for(int i = 0;i < Q;i++) {
		int A,B,C;
		cin >> A >> B >> C;
		if(A == 0) {
			unite(B,C);
		}
		else {
			if(same(B,C) == true) {
				cout << 1 << endl;
			}
			else {
				cout << 0 << endl;
			}
		}
	}
}


Measured memory_bytes: 3220
K,N = map(int,input().split())
A = list(map(int,input().split()))

if A[-1]>A[0]:
    longdis = abs(K-A[-1]+A[0])
else:
    longdis = abs(A[-1]-A[0])

for i in range(N-1):
    longdis = max(longdis,abs(A[i]-A[i+1]))
print(K-longdis)

Measured memory_bytes: 26444
#include<iostream>
#include<string>
typedef long long ll;

using namespace std;

int main()
{
    ll i,ans=1e9,j;
    string s,t;
    cin>>s>>t;
    for(i=0; i<=s.size()-t.size(); i++)
    {
        ll cnt=0;
        for(j=0; j<t.size(); j++)
        {
            if(s[i+j]!=t[j])
            {
                cnt++;
            }
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3152
class Dice:
    same_dice_index = ((0, 1, 2, 3, 4, 5), (0, 2, 4, 1, 3, 5), (0, 3, 1, 4, 2, 5),
                       (0, 4, 3, 2, 1, 5), (1, 0, 3, 2, 5, 4), (1, 2, 0, 5, 3, 4),
                       (1, 3, 5, 0, 2, 4), (1, 5, 2, 3, 0, 4), (2, 0, 1, 4, 5, 3),
                       (2, 1, 5, 0, 4, 3), (2, 4, 0, 5, 1, 3), (2, 5, 4, 1, 0, 3),
                       (3, 0, 4, 1, 5, 2), (3, 1, 0, 5, 4, 2), (3, 4, 5, 0, 1, 2),
                       (3, 5, 1, 4, 0, 2), (4, 0, 2, 3, 5, 1), (4, 2, 5, 0, 3, 1),
                       (4, 3, 0, 5, 2, 1), (4, 5, 3, 2, 0, 1), (5, 1, 3, 2, 4, 0),
                       (5, 2, 1, 4, 3, 0), (5, 3, 4, 1, 2, 0), (5, 4, 2, 3, 1, 0))

    def __init__(self, str_list):
        self.faces = str_list

    def is_same(self, dice):
        for i in Dice.same_dice_index:
            for n, j in enumerate(i):
                if dice.faces[n] != self.faces[j]:
                    break
            else:
                return True
        return False

    def is_unique(self, dices_list):
        for i in dices_list:
            if self.is_same(i):
                return False
        return True

def solve():
    from sys import stdin
    f_i = stdin
    
    ans_list = []
    
    while True:
        n = int(f_i.readline())
        
        if n == 0:
            break
        
        dices = [Dice(f_i.readline().split()) for i in range(n)]
        
        ans = 0
        while dices:
            tmp_dices = []
            d1 = dices.pop()
            for d2 in dices:
                if d1.is_same(d2):
                    ans += 1
                else:
                    tmp_dices.append(d2)
            dices = tmp_dices
        
        ans_list.append(ans)
    
    print('\n'.join(map(str, ans_list)))

solve()


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






int main(){

  

  int n,m;
  cin>>n>>m;
  
  vector<vector<pair<int,int>>> data(n+1,vector<pair<int,int>>(0));
  
  for (int i=1;i<=m;i++){
    int p,y;
    cin>>p>>y;
    
    pair<int,int> tmp=make_pair(y,i);
    
    data.at(p).push_back(tmp);
  }
  
  for (int i=1;i<=n;i++){
    sort(data.at(i).begin(),data.at(i).end());
  }


  
  
  vector<string> answer(m+1);
  
  for (int i=1;i<=n;i++){
    int provsize=int(data.at(i).size());
    
    for (int j=0;j<provsize;j++){
      
      string formerstring="";
      string latterstring="";
      
      string formernumber=to_string(i);
      string latternumber=to_string(j+1);
      
      
      for (int k=0;k<(6-int(formernumber.size()));k++){
        formerstring+="0";
      }
      formerstring+=formernumber;
      for (int k=0;k<(6-int(latternumber.size()));k++){
        latterstring+="0";
      }
      latterstring+=latternumber;
      

      
      answer.at(data.at(i).at(j).second)=(formerstring+latterstring);
      
    }
  }
  
  for (int i=1;i<=m;i++){
    cout<<answer.at(i)<<endl;
  }
  


  
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
int main() {
	int n;
	cin >> n;
	int a;
	double ans = 0;
	REP(i, n) {
		cin >> a;
		ans += (double)1 / a;
	}
	cout << setprecision(9) << 1 / ans;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        int N, ans = 1;
        int[] A;
        List<Integer> compressed = new ArrayList<>();
        int diff;

        void solve(InputReader in, PrintWriter out) {
            N = in.nextInt();
            A = in.nextIntArray(N);

            int prev = -1;
            for (int a : A) {
                if (a != prev) {
                    compressed.add(a);
                }
                prev = a;
            }

            if (compressed.size() > 2) {
                diff = 0;
                for (int i = 0; i < compressed.size() - 1; ++i) {
                    if (diff > 0 && compressed.get(i + 1) < compressed.get(i) || diff < 0 && compressed.get(i + 1) > compressed.get(i)) {
                        diff = 0;
                        ans++;
                    } else {
                        diff = compressed.get(i + 1) - compressed.get(i);
                    }
                }
            }

            out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }

        long nextLong() { return Long.parseLong(next()); }

        int[] nextIntArray(int n) {
        	int[] arr = new int[n];
        	for (int i = 0; i < n; ++i) {
        		arr[i] = nextInt();
        	}
        	return arr;
        }

        long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; ++i) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 43876
global six
six = []
global nine
nine = []
ans = 1145141919810


def init():
	s = 6
	while (1):
		if s > 100000:
			break

		six.append(s)
		s *= 6

	n = 9
	while (1):
		if n > 100000:
			break

		nine.append(n)
		n *= 9

	six.reverse()
	nine.reverse()


def dfs(zan, did):
	global ans
	global six
	global nine
	if zan < 6:
		res = did + zan
		if res < ans:
			ans = res

		return

	for val in six:
		if val > zan:
			continue

		dfs(zan - val, did + 1)
		break

	for val in nine:
		if val > zan:
			continue

		dfs(zan - val, did + 1)
		break


init()
n = int(input())
dfs(n, 0)

print(ans)



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

const int INF = 1e9;
const int MOD = 1e9 + 7;

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

    int n, k;
    cin >> n >> k;
    vector<int> snuke(n, 0);
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            snuke[a - 1]++;
        }
    }
    int count = 0;
    for (int i = 0; i < n; i++) {
        if (snuke[i] == 0) count++;
    }
    cout << count << endl;

	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<unordered_set>
#include<math.h>
#include<utility>
#include<iomanip>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b, c;
	cin >> a >> b >> c;
	unordered_set<int> s;
	s.insert(a); s.insert(b); s.insert(c);
	if (s.size() == 2) cout << "Yes";
	else cout << "No";

}

Measured memory_bytes: 384
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), is_sorted(),

int n,m;
vi adj[100001];
int vis[100001];

void dfs(int i){
    vis[i]=1;
    for(int ch:adj[i]){
        if(vis[ch])continue;
        dfs(ch);
    }
}

signed main(){
    FASTER;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int a,b,c;cin>>a>>b>>c;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(vis[i])continue;
        dfs(i);
        cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 12916
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<algorithm>
const int N = 100000;
int par[N];
int rank[N];

void init(int n){
	for (int i = 0; i < n; ++i){
		par[i] = i;
		rank[i] = 0;
	}
}

int find(int x){
	if (par[x] == x)return x;
	return par[x] = find(par[x]);
}

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank[x] < rank[y]){
		par[x] = y;
	}
	else{
		par[y] = x;
		if (rank[x] == rank[y])rank[x]++;
	}
}

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

struct edge {
	int u, v, cost;
};

bool comp(const edge& e1, const edge& e2){
	return e1.cost < e2.cost;
}

edge es[1000000];
int V, E;

int kruskal(){
	std::sort(es, es + E, comp);
	init(V);
	int res = 0;
	for (int i = 0; i < E; ++i){
		edge e = es[i];
		if (!same(e.u, e.v)){
			unite(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}

int main(){
	while (1){
		scanf("%d", &V);
		if (V == 0)break;
		scanf("%d", &E);
		for (int i = 0; i < E; ++i){
			int a, b, c;
			scanf("%d,%d,%d", &a, &b, &c);
			es[i].u = a, es[i].v = b, es[i].cost = c;
		}
		int ans = kruskal();
		printf("%d\n", ans / 100 - V + 1);
	}
	return 0;
}

Measured memory_bytes: 3296
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws Exception {
		String[] list = br.readLine().split(" ");
		int n = Integer.parseInt(list[0]);
		int q = Integer.parseInt(list[1]);
		
		Deque<ALDS1_3_B_Process> deque = new ArrayDeque<>();
		
		for(int i = 0; i < n; i++){
			list = br.readLine().split(" ");
			String name = list[0];
			int time = Integer.parseInt(list[1]);
			deque.addLast(new ALDS1_3_B_Process(name, time));
		}
		
		int timer = 0;
		
		while(!deque.isEmpty()){
			ALDS1_3_B_Process process = deque.pollFirst();
			int time = process.getTime();
			if(time <= q){
				timer += time;
				System.out.println(process.getName() + " " + timer);
			}else{
				timer += q;
				time -= q;
				process.setTime(time);
				deque.offerLast(process);
			}
		}
		
	}
}

class ALDS1_3_B_Process{
	private String name;
	private int time;
	
	public ALDS1_3_B_Process(String name, int time) {
		this.name = name;
		this.time = time;
	}

	public String getName() {
		return name;
	}

	public int getTime() {
		return time;
	}
	
	public void setTime(int time){
		this.time = time;
	}
}


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

using ll = long long; 
using P = pair<int,int>;

int main() {

  string S;
  cin >> S;

  int ans = 0;
  if (S=="SUN"){
    ans = 7;
  }
 else if (S=="MON"){
    ans = 6;
 }
 else if (S=="TUE"){
    ans = 5;
 }
 else if (S=="WED"){
    ans = 4;
 }
 else if (S=="THU"){
    ans = 3;
 }
 else if (S=="FRI"){
    ans = 2;
 }
 else if (S=="SAT"){
    ans = 1;
 }
  
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[25],b[25],c[25],ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)cin>>b[i];
	for(int i=1;i<=n-1;i++)cin>>c[i];
	ans+=b[a[1]];
	for(int i=2;i<=n;i++){
		ans+=b[a[i]];
		if(a[i]==a[i-1]+1)ans+=c[a[i-1]];
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int minDist(const vector<string>& plane, char wall, int y1, int x1, int y2, int x2)
{
    int dy[] = {0, 0, -1, 1};
    int dx[] = {-1, 1, 0, 0};

    int h = plane.size();
    int w = plane[0].size();

    queue<pair<int, int> > q;
    vector<vector<bool> > check(h, vector<bool>(w, false));
    q.push(make_pair(y1, x1));
    check[y1][x1] = true;
    int ret = 0;
    while(!q.empty()){
        queue<pair<int, int> > q1;
        while(!q.empty()){
            int y = q.front().first;
            int x = q.front().second;
            q.pop();
            if(y == y2 && x == x2)
                return ret;
            for(int i=0; i<4; ++i){
                int y0 = y + dy[i];
                int x0 = x + dx[i];
                if(0 <= y0 && y0 < h && 0 <= x0 && x0 < w && plane[y0][x0] != wall && !check[y0][x0]){
                    q1.push(make_pair(y0, x0));
                    check[y0][x0] = true;
                }
            }
        }
        ++ ret;
        q = q1;
    }
    return -1;
}

int main()
{
    int w, h, n;
    cin >> w >> h >> n;

    vector<string> s(2*h+1, string(2*w+1, '#'));
    for(int i=1; i<2*h; ++i){
        for(int j=1; j<2*w; ++j){
            if(i % 2 == 1 || j % 2 == 1)
                s[i][j] = ' ';
        }
    }

    for(int i=0; i<n; ++i){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;

        if(x1 == x2){
            if(y1 > y2)
                swap(y1, y2);
            for(int i=y1; i<y2; ++i)
                s[2*i+1][2*x1] = '#';
        }else{
            if(x1 > x2)
                swap(x1, x2);
            for(int i=x1; i<x2; ++i)
                s[2*y1][2*i+1] = '#';
        }
    }

    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;

    int ret = 0;
    for(int i=1; i<2*h; ++i){
        for(int j=1; j<2*w; ++j){
            if((i + j) % 2 == 0 || s[i][j] == '#')
                continue;
            s[i][j] = '#';
            ret = max(ret, minDist(s, '#', 2*sy+1, 2*sx+1, 2*gy+1, 2*gx+1) / 2);
            s[i][j] = ' ';
        }
    }

    if(ret != 0)
        ret -= minDist(s, '#', 2*sy+1, 2*sx+1, 2*gy+1, 2*gx+1) / 2;
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1268
// 2019/07/02
// AtCoder Beginner Contest 079 - A

import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // Input
        int n = sc.nextInt();
        int s = (int)(n / 1000);
        int h = (int)(n / 100 % 10);
        int t = (int)(n / 10 % 10);
        int o = (n % 10);
        String ans = "";

        // Check
       if((s == h && h == t) || (h == t && t == o)){
           ans = "Yes";
       } else {
           ans = "No";
       }
       
       // Output
       System.out.println(ans);
    }
}

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

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

    string s, t;
    cin >> s >> t;

    int n = s.size();
    map<char, vector<int>> mp1, mp2;
    REP(i, n){
        mp1[s[i]].push_back(i);
        mp2[t[i]].push_back(i);
    }

    if(mp1.size() != mp2.size()){
        cout << "No" << endl;
        return 0;
    }

    vector<vector<int>> A, B;
    vector<int> T;
    for(auto x : mp1){
        T.clear();
        for(auto y : x.second){
            T.push_back(y);
        }
        A.push_back(T);
    }
    for(auto x : mp2){
        T.clear();
        for(auto y : x.second){
            T.push_back(y);
        }
        B.push_back(T);
    }

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

    int m = A.size();
    REP(i, m){
        if(A[i].size() == B[i].size()){
            REP(j, int(A[i].size())){
                if(A[i][j] == B[i][j]);
                else{
                    cout << "No" << endl;
                    return 0;
                }
            }
        }else{
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    /* check
    for(auto x : A){
        for(auto y : x){
            cout << y << " ";
        }
        cout << endl;
    }
    for(auto x : B){
        for(auto y : x){
            cout << y << " ";
        }
        cout << endl;
    }
    */

    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define MOD 1000000007
#define mo 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

const int SIZE = 1010;

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

ll comb(ll N_, ll C_) {
	const int NUM_ = 400001;
	static ll fact[400002], factr[400002], inv[400002];
	if (fact[0] == 0) {
		inv[1] = fact[0] = factr[0] = 1;
		for (int i = 2; i <= NUM_; ++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i%mo, factr[i] = factr[i - 1] * inv[i] % mo;
	}
	if (C_<0 || C_>N_) return 0;
	return factr[C_] * fact[N_] % mo*factr[N_ - C_] % mo;
}
ll modpow(ll a, ll n = mo - 2) {
	ll r = 1;
	while (n) r = r * ((n % 2) ? a : 1) % mo, a = a * a%mo, n >>= 1;
	return r;
}

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

	make();

	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;

	int dp[1010][1010] = { 0 };
	REP(i, 1010)dp[i][0] = 1;

	eFOR(i, A, B) {
		eREP(j, N) {
			if (dp[i][j] == 0)continue;

			if (j != 0) (dp[i + 1][j] += dp[i][j]) %= mod;

			int p = 1;

			for (int k = 1; k <= D && j + i * k <= N; k++) {

				(p *= comb(N - j - i * (k - 1), i)) %= mod;
				(p *= inv[k]) %= mod;

				if (k >= C)(dp[i + 1][j + i * k] += dp[i][j] * p%mod) %= mod;


			}
			//cout << dp[i][j] << endl;
		}
	}



	cout << dp[B + 1][N] << endl;

	return 0;
}



Measured memory_bytes: 17664
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;


bool f(long n){
    cout << "? " << n << endl;
    char c;cin >> c;
    //if((n<=stol(p)&&to_string(n)<=p)||(n>stol(p)&&to_string(n)>p)) c='Y';
    //else c='N';
    //cout << " " << c << endl;
    return c=='Y'?true:false;
}

int main(){
    //string p;cin >> p;
    long k=1;
    int s;
    long n=0;
    for (int i = 0; i <= 8; i++) {
        if(!f(k*10)){
            s=i;
            int l=0,r=10;
            while(abs(r-l)>1){
                int m=(l+r)/2;
                if(f(k*m*10)){
                    r=m;
                }
                else{
                    l=m;
                }
            }
            n=k*l;
            break;
        }
        if(i==8){
            k=1;
            for (long a = 2; a < 10000000000l; a=a*10+2) {
                if(f(a)){
                    cout << "! " << k << endl;
                    return 0;
                }
                k*=10;
            }
            return 0;
        }
        k*=10;
    }
    k/=10;
    if(s==1) k=1;
    for (int i = 0; i < s; i++) {
        int l=0,r=10;
        while(abs(r-l)>1){
            int m=(l+r)/2;
            if(f((n+k*m)*10)){
                r=m;
            }
            else{
                l=m;
            }
        }
        n+=l*k;
        k/=10;
    }
    cout << "! " << n+1 << endl;
    return 0;
}




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

int main() {
	// your code goes here
	int n;
	cin >> n; // the number of cards is 2*n.
	int m;
	cin >> m; // following m shuffle.
	vector<int> cards;
	for(int i=0;i<2*n;i++)//initialization of cards.
		cards.push_back(i+1);
	for(int i=0;i<m;i++){
		int k;
		cin >> k; //when k is 0,the order is liffle shuffle.otherwise cut by k.
		if(k>0){
			//--------prepareing--separating-------------
			vector<int>::iterator kp1thcard=cards.begin();
			for(int j=0;j<(k-1)+1;j++)kp1thcard++;
			vector<int> upper(cards.begin(),kp1thcard)
					   ,lower(kp1thcard,cards.end());
			//--------writing new cards vector -------------
			cards.clear();
			cards=lower;
			cards.insert(cards.end(),upper.begin(),upper.end());
		}
		if(k==0){
			//---------preparing---separating-----------------
			vector<int>::iterator np1thcard=cards.begin();
			for(int j=0;j<(n-1)+1;j++)np1thcard++;
			vector<int> upper(cards.begin(),np1thcard)
					   ,lower(np1thcard,cards.end());
			//---------start writing new vector ---------------
			cards.clear();
			vector<int>::iterator itu=upper.begin(),itl=lower.begin();
			for(int j=0;j<n;j++){
				cards.push_back(*itu);itu++;
				cards.push_back(*itl);itl++;// i dont know push_back(*itu++);;;;;;;;;
			}//after this loop,itu and itl must be upper.end() and lower.end(),respectively.
		}
	}
	//output phase
	for(int i=0;i<2*n;i++){
		cout << cards.at(i) << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#coding:utf-8

from __future__ import division, print_function
try:
    input = raw_input
    range = xrange
except NameError:
    pass


def solve(cnt, W, N, treasures):
    dp = [0] + [-1] * W
    for v, w in treasures:
        for j in range(W, w - 1, -1):
            if dp[j - w] >= 0:
                dp[j] = max(dp[j], dp[j - w] + v)

    ans = max(dp)
    print('Case %d:\n%d\n%d' % (cnt, ans, dp.index(ans)))

cnt = 1
while True:
    W = int(input())
    if W == 0:
        break
    N = int(input())
    
    treasures = [tuple(map(int, input().split(','))) for _ in range(N)]
    solve(cnt, W, N, treasures)

    cnt += 1

Measured memory_bytes: 4288
#include "cstdio"
int i,j,n,m,ss,sss;
int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		getchar();
		for(j=1;j<=m;j++){
			char c=getchar();
			if(c=='#')ss++;
		}
	}
	if(ss!=n+m-1)printf("Impossible\n");
	else printf("Possible\n");
	return 0;
}

Measured memory_bytes: 128
import sys
from pprint import pprint
from heapq import heappop, heappush

V, E, r = map(int, sys.stdin.readline().strip().split())
edges = [[] for _ in range(V)]
for _ in range(E):
    s, t, d = map(int, sys.stdin.readline().strip().split())
    edges[s].append((t, d))
# pprint(edges)

dist = [float("inf") for _ in range(V)]
prev = [None] * V

q = []
dist[r] = 0
heappush(q, (dist[r], r))
while q:
    du, u = heappop(q)
    # print(u, du)
    if dist[u] < du:
        continue

    for v, weight in edges[u]:
        alt = du + weight
        if dist[v] > alt:
            dist[v] = alt
            prev[v] = u
            heappush(q, (alt, v))

for d in dist:
    print("INF" if d == float("inf") else d)


Measured memory_bytes: 93124
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    if(a % 2 == 1 && b % 2 == 1)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls signed
#define give main()
const int mod = 1000000007;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

#pragma endregion

const int N = 200005;

int n, arr[N], dp[N][3], vis[N][3];

int f(int pos, int skips) {
    if (pos == 0 and !skips) return arr[0];
    if (pos == 0) return max(0ll, arr[0]);
    if (pos < 0) return 0;
    if (vis[pos][skips]) return dp[pos][skips];
    vis[pos][skips] = 1; 
    if (!skips) return dp[pos][skips] = arr[pos] + f(pos-2, 0);
    else return dp[pos][skips] = max(arr[pos]+f(pos-2, skips), f(pos-1, skips-1));
}

pls give {
    AC;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> arr[i];
    }
    cout << f(n-1, 1+(n%2)) << nl;
}

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

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

    int n;
    cin >> n;

    if(n%10==9 || n/10==9) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <map>
#define MX 999999999
using namespace std;

multimap<double,int> mp;

struct bir {
	double x,y,m;
	int to[1001],fr;
};

bir b[1000];

multimap<double,int>::iterator it;

int search(int s,int e) {
	int n,i;
	double m,k;
	b[s].m=0; b[s].fr=-1; 
	mp.insert(multimap<double,int>::value_type(0,s));
	while(!mp.empty()) {
		it=mp.begin();
		n=(*it).second; m=(*it).first;
		mp.erase(it);
		if (b[n].m<m) continue;
		for (i=0;b[n].to[i]>=0;i++) {
			k=sqrt((b[n].x-b[b[n].to[i]].x)*(b[n].x-b[b[n].to[i]].x)+(b[n].y-b[b[n].to[i]].y)*(b[n].y-b[b[n].to[i]].y));
			if (b[b[n].to[i]].m>b[n].m+k) {
				mp.insert(multimap<double,int>::value_type(b[n].m+k,b[n].to[i]));
				b[b[n].to[i]].fr=n; b[b[n].to[i]].m=b[n].m+k;
			}
		}
	}
    if (b[e].m==MX) return 0;
	return 1;
}

int main() {
 int bn,i,j,k,n,s,e,an[1000],num[1001],rn[1001];
 while(cin >> bn) {
	 if (bn==0) break;
	 for (i=0;i<bn;i++) { cin >> num[i] >> b[i].x >> b[i].y; rn[num[i]]=i;}
	 for (i=0;i<bn;i++) {
		 for (j=0,k=0;j<bn;j++) if (i!=j) if ((b[i].x-b[j].x)*(b[i].x-b[j].x)+(b[i].y-b[j].y)*(b[i].y-b[j].y)<=2500) b[i].to[k++]=j; 
		 b[i].to[k]=-1; 
	 }
     cin >> n;
	 for (i=0;i<n;i++) {
		 cin >> s >> e;
		 s=rn[s]; e=rn[e];
		 for (k=0;k<1000;k++) b[k].m=MX;
		 if (search(s,e)==1) {
			 j=0;
			 while(e>=0) {an[j++]=num[e]; e=b[e].fr;}
			 for (;j>0;j--) { cout << an[j-1]; if (j>1) cout << ' ';}
			 cout << endl;
		 } else cout << "NA" << endl;
	 }
 }
return 0;
 }

Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using vvpi = vector<vpi>;
const ull MOD = 998244353;
#ifdef LOCAL
#include "../../pp.hpp"
#define debug pp::debug
#else
#define debug(args...)
#endif

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

    int n, k; cin >> n >> k;
    vi h(n+1);
    for (int i = 0; i < n; ++i) cin >> h[i+1];
    vi dp(n+1, INT_MAX);
    dp[1] = 0;
    for (int i = 2; i <= n; ++i) {
        for (int j = i - 1; j >= max(1, i - k); --j) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }

    cout << dp[n] << '\n';
}


Measured memory_bytes: 1024