akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#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 ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 998244353;

const int maxn = 1e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int k;
    cin >> k;
    int ans[n][m];
    int x = 0, y = 0;
    for (int i = 1 ; i <= k ; i++) {
        int t;
        cin >> t;
        while(t--) {
            ans[x][y] = i;
            if (x%2==0) {
                if (y == m - 1) {
                    x++;
                }
                else {
                    y++;
                }
            }
            else {
                if (y == 0) {
                    x++;
                }
                else {
                    y--;
                }
            }
        }
    }
    f(n) {
        fr (j, 0, m) {
            cout << ans[i][j] << ' ';
        }
        cout << '\n';
    }
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
typedef long long ll;
ll f(ll a,ll b,int cnt){
  if(cnt==0){
    if(a%b==0) return 2*a;
    else return ((a/b)*2+1)*b+f(b,a%b,1);
  }
  else{
    if(a%b==0) return 2*a-b;
    else return (a/b)*b*2+f(b,a%b,1);
  }
}
int main(){
  ll n,k;
  cin>>n>>k;
  if(n-k>k) k=n-k;
  cout<<k+f(k,n-k,0)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool k[100];
int main(void){
    int a,b,c,d; cin>>a>>b>>c>>d;
    k[a]=true; k[b]=true; k[c]=true; k[d]=true;
    if(k[1]&&k[9]&&k[7]&&k[4]){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	
    
}


Measured memory_bytes: 256
a,b = map(int,input().split())
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
#最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)
print(lcm(a,b))

Measured memory_bytes: 2940
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
int main()
{
	int n, p, t, x, o;
	cin >> n;
	queue<int> cpp[n];
	cin >> p;
	while (p--)
	{
		cin >> o >> t;
		if (o > 0)
		{
			if ((o == 1)&&(!cpp[t].empty()))			
					cout << cpp[t].front() << endl; 

			if (o == 2 && !cpp[t].empty())
					cpp[t].pop(); 				
		}
		else 
		{
			cin >> x;
			cpp[t].push(x);
		}
	}
	return 0;
}


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

int main() {
  int n; cin >> n;
  map<ll, int> cnt;
  ll sum = 0, res = 0;
  cnt[0] = 1;
  while (n--) {
    int x; cin >> x;
    res += cnt[sum+=x]++;
  }
  cout << res << endl;
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;

char a[111][111];

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

	int h , w;
	cin >> h >> w;
	
	map<char , int> mp;
	
	rep(i , h){
		rep(j , w){
			cin >> a[i][j];
			++mp[a[i][j]];
		}
	}
	
	if((h % 2) + (w % 2) == 0){
		repf(i , 'a' , 'z' + 1){
			if(mp[i] % 4 != 0){
				dier("No");
			}
		}
		dier("Yes");
	}

	
	if((h % 2) + (w % 2) == 1){
		int can = ((h % 2) ^ 1) * h + ((w % 2) ^ 1) * w;
		repf(i , 'a' , 'z' + 1){
			if(mp[i] % 4 == 1 || mp[i] % 4 == 3)dier("No");
			if(mp[i] % 4 == 2)can -= 2;
		}
		if(can < 0 || (can % 4 != 0))dier("No");
		dier("Yes");
	}
	
	bool ck = 0;
	int can = h + w - 2;
	repf(i , 'a' , 'z' + 1){
		if(mp[i] % 4 == 1){
			if(ck)dier("No");
			ck = 1;
		}else if(mp[i] % 4 == 3){
			if(ck)dier("No");
			ck = 1;
			can -= 2;
		}else if(mp[i] % 4 == 2){
			can -= 2;
		}
	}
	
	if(can < 0 || (can % 4 != 0))dier("No");
	if(ck == 0)dier("No");
	cout << "Yes";
	



	return 0;
}

Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
ll  MOD = (1e9+7);
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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 Abel> struct BIT {
    const Abel UNITY_SUM = 0;
    vector<Abel> dat;
    /* [1, n] */
    BIT(int n) : dat(n+1, UNITY_SUM) {}
    void init(int n) { dat.assign(n+1, UNITY_SUM); }
    /* a is 1-indexed */
    inline void add(int a, Abel x) {
        for (int i=a; i<(int)dat.size(); i+=i & -i)
            dat[i] = dat[i] + x;
    }
    /* [1, a], a is 1-indexed */
    inline Abel sum(int a) {
        Abel res = UNITY_SUM;
        for (int i=a; i>0; i-=i & -i)
            res = res + dat[i];
        return res;
    }
    /* [a, b), a and b are 1-indexed */
    inline Abel sum(int a, int b) {
        return sum(b-1) - sum(a-1);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n; cin >> n;
    vector<int> p(n);
    rep(i, n) {
        int x; cin >> x;
        p[--x] = i;
    }
    ll ans = 0;
    rep(i, n) {
        ll cnt = 0, now = p[i];
        while (i < n && now <= p[i]) {
            now = p[i]; ++cnt; ++i;
        }
        if (i != n) --i;
        chmax(ans, cnt);
    }
    cout << n-ans << endl;
    return 0;
}

Measured memory_bytes: 1024
/*  ex7_3
    pptenshi  */

#include<stdio.h>
#include<stdlib.h>

int main(void) {
    int height,         // H
        width,          // W
        *is_row_del,    // 取り除く行 
        *is_column_del; // 取り除く列 
    char **grid;        // マス目 
    
    //--- input height, width ---//
    scanf("%d%d", &height, &width);


    //--- メモリ確保 ---//

    is_row_del = (int*)calloc(height, sizeof(int));
    if (is_row_del == NULL) exit(1);
    // 1で初期化
    for (int i = 0; i < height; i++) is_row_del[i] = 1;   
    

    is_column_del = (int*)calloc(width, sizeof(int));
    if (is_column_del == NULL) exit(1);
    // 1で初期化
    for (int i = 0; i < width; i++) is_column_del[i] = 1;

    grid = (char**)calloc(height, sizeof(char*));
    if (grid == NULL) exit(1);
    for (int i = 0; i < height; i++) {
        grid[i] = (char*)calloc(width, sizeof(char));
        if (grid[i] == NULL) exit(1);
    }


    //--- input grid ---//
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            scanf(" %c", &grid[i][j]);
        }
    }


    //--- 圧縮できる列, 行を求める ---//
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            if (grid[i][j] == '#') {
                is_row_del[i] = 0;
                is_column_del[j] = 0;
            }
        }
    }
    

    //--- output ---//
    for (int i = 0; i < height; i++) {
        if (is_row_del[i]) continue;  // 取り除く行

        for (int j = 0; j < width; j++) {
            if (is_column_del[j]) continue;  // 取り除く列

            printf("%c", grid[i][j]);
        }
        putchar('\n');   
    }


    //--- メモリ解放 ---//
    free(is_row_del);
    free(is_column_del);
    for (int i = 0; i < height; i++) {
        free(grid[i]);
    }
    free(grid);

    return 0;
}

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

int main()
{
  int n;
  string s;
  cin >>n>>s;
  
  int b =0,r=0;
  for(int i=0;i<n;i++)
  {
    if (s[i]=='R')
      r++;
    else
      b++;
  }
  if (b<r)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
    


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

using namespace std;

int main() {
  int Tc; cin >> Tc;
  int H, M;
  
  while(Tc --) {
    scanf("%d:%d", &H, &M);
    
    double h = H*30.0 + M/2.0, m = M*6;
    
    int ang = abs(h - m);
    if(ang > 180) ang = 360 - ang;
    if(0 <= ang && ang < 30) {
      cout << "alert" << endl;
    }
    else if(90 <= ang && ang <= 180) {
      cout << "safe" << endl;
    }
    else cout << "warning" << endl;
  }
  
  return 0;
}

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

int main()
{
    int N, K, a[100010];
    scanf("%d %d", &N, &K);
    for (int i = 0; i < N; i++) scanf("%d", a + i);

    int ans = 1 << 29;
    for (int i = 0; i <= N - K; i++) {
        ans = min(ans, a[i + K - 1] - a[i] + min(abs(a[i]), abs(a[i + K - 1])));
    }
    printf("%d\n", ans);

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define Vsort(v) sort(All(v))
#define VsortR(v) sort(All(v), std::greater<__typeof(v[0])>())

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int n;

	cin >> n;

	ll a;
	ll mi = LLONG_MAX;
	ll ma = -1;

	int i;

	rep(i, n) {
		cin >> a;

		Min(mi, a);
		Max(ma, a);
	}

	Out(ma - mi);
	
	return 0;
}


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

int main(){

    ll N;
    ll r[3][2];
    cin >> N;
    for(ll i = 0; i < 2; i++){
        for(ll j = 0; j < 3; j++){
            cin >> r[j][i];
        }
    }
    vector<ll>ab(N + 1, -1);
    ab[0] = 0;
    for(ll i = 0; i < N; i++){
        if(ab[i] < 0)continue;
        for(ll j = 0; j < 3; j++){
            if(r[j][0] > r[j][1])continue;
            ll w = r[j][0];
            ll v = r[j][1];
            if(i + w > N)continue;
            ab[i + w] = max(ab[i + w], ab[i] + v);
        }
    }
    ll N2 = N;
    for(ll i = 0; i <= N; i++){
        if(ab[i] < 0)continue;
        N2 = max(N2, N - i + ab[i]);
    }
    vector<ll>ba(N2 + 1, -1);
    ba[0] = 0;
    for(ll i = 0; i < N2; i++){
        if(ba[i] < 0)continue;
        for(ll j = 0; j < 3; j++){
            if(r[j][1] > r[j][0])continue;
            ll w = r[j][1];
            ll v = r[j][0];
            if(i + w > N2)continue;
            ba[i + w] = max(ba[i + w], ba[i] + v);
        }
    }
    ll N3 = N2;
    for(ll i = 0; i <= N2; i++){
        if(ba[i] < 0)continue;
        N3 = max(N3, N2 - i + ba[i]);
    }
    cout << N3 << endl;

    return 0;
}

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

using namespace std;

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

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

    vector <int> a(n);
    for(int& x : a) scanf("%d", &x);

    vector <pii> b(m);
    for(pii& p : b) scanf("%d%d", &p.second, &p.first);

    sort(b.begin(), b.end(), greater <pii> ());

    ll Ans = 0;
    multiset <int> st;

    for(int x : a)  st.insert(x);

    for(int i = 0; i < m; i++)
    {
        int x = b[i].first;
        int y = b[i].second;

        while(!st.empty() && (*st.rbegin()) >= x)   Ans += (ll) (*st.rbegin()), st.erase(--st.end());

        while(!st.empty() && y > 0)
        {
            y--;
            Ans += (ll) x;
            st.erase(st.begin());
        }
    }

    while(!st.empty())  Ans += (ll) (*st.begin()), st.erase(st.begin());

    cout << Ans << endl;
}


Measured memory_bytes: 6144
n=int(input())
z=[]
aa=[]
for i in range(n):
     z.append(list(map(int,input().split())))
for cx in range(101):
    for cy in range(101):
        ans=set()
        for i in range(n):
            x,y,h=z[i][0],z[i][1],z[i][2]
            if h!=0:
                tmp=h+abs(x-cx)+abs(y-cy)
                ans.add(tmp)
        if len(ans)==1:
            ans=list(ans)
            aa.append((ans[0],cx,cy))

for a,cx,cy in aa:
    flg=True
    for i in range(n):
        x,y,h=z[i][0],z[i][1],z[i][2]
        if h!=max(a-abs(x-cx)-abs(y-cy),0):
                flg=False
    if flg:
        print(cx,cy,a)
        exit()

Measured memory_bytes: 74056
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  int h,w,n;
  cin >> h >> w >> n;
  cout << min( n/h + (n%h != 0) , n/w + (n%w != 0) ) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf INT_MAX-5;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
using namespace std;

ostream& operator << (ostream &out, vector<int> &v) { for(auto a:v) out << a<<" "; out<<endl; }
const int Wm=100005;
int a[105][2];

ll dp[105][Wm];
int n,mW;

ll ks(int i, int cap)
{
  if(i>=n)
    return 0;
  if(dp[i][cap]!=0)
    return dp[i][cap];
  ll r1=0;
  if(cap-a[i][0]>=0)
    r1=a[i][1]+ks(i+1,cap-a[i][0]);
  ll r2=ks(i+1,cap);
  return dp[i][cap]=max(r1,r2);
}
int main()
{
  cin >> n >> mW;
  for(int i=0;i<n;i++) cin >> a[i][0]>>a[i][1]; //a[i][0] - weight. a[i][1] - value
  ll res=ks(0,mW);
  cout << res<<endl;
}


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

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

/*-------------------------------------------*/

string key="keyence";
string s;

int main(){
    cin>>s;
    int num=0;
    int i=0,j=s.size()-1,k=6;
    while(i<6&&s[i]==key[i]){
        i++;
        num++;
    }
    while(k>=0&&s[j]==key[k]){
        j--;
        k--;
        num++;
    }
    cout<<(num>=7?"YES\n":"NO\n");
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static Scanner cin = new Scanner();
    static int N = cin.Int();
    static int K = cin.Int();
    static int[] D = cin.ArrayInt(K);
    static List<int> list = new List<int>() { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    static List<int> ANS = new List<int>();
    static void Main() {
        foreach (var x in D) {
            list.Remove(x);
        }
        foreach (var x in list) {
            if(x != 0) hoge(x);
        }

        ANS = ANS.Where(x => x >= N).ToList();
        Console.WriteLine(ANS.Min());
        Console.ReadLine();
    }

    static void hoge(int n) {
        ANS.Add(n);
        if (n >= 11 * N) return;
        foreach (var x in list) {
            hoge(10 * n + x);
        }
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 24928
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
#define DB(x) #x<<" "<<x<<" "
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int dp[110][4][2];
//pos,k,== or <

int32_t main() {
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n,k; cin>>n>>k;
	vector<int> v(n);
	for(auto &i:v)
		cin>>i;
	sort(all(v)); reverse(all(v));
	int ans=0;
	For(i,k,n-1) ans+=v[i];
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int x, a, b;
    cin >> x >> a >> b;
    
    if (x+a < b) cout << "dangerous" << endl;
    else if (a >= b) cout << "delicious" << endl;
    else cout << "safe" << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define IT iterator
#define vi vector<int>
#define TP template<class o>
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=3e5+10,size=1<<20,mod=998244353,inf=2e9;
const ll INF=1e15;

//char buf[size],*p1=buf,*p2=buf;
TP void qr(o &x) {
    char c=gc; x=0; int f=1;
    while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
    while(isdigit(c)) x=x*10+c-'0',c=gc;
    x*=f;
}
TP void qw(o x) {
    if(x/10) qw(x/10);
    putchar(x%10+'0');
}
TP void pr1(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar(' ');
}
TP void pr2(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar('\n');
}

//math
ll gcd(ll a,ll b) {return !a?b:gcd(b%a,a);}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
ll power(ll a,ll b=mod-2) {
    ll c=1;
    while(b) {
        if(b&1) c=c*a%mod;
        b /= 2; a=a*a%mod;
    }
    return c;
}

TP void cmax(o &x,o y) {if(x < y) x=y;}
TP void cmin(o &x,o y) {if(x > y) x=y;}

//dbinom

//ll jc[N],inv[N];
//void init(int n) {
//	jc[0]=1; for(int i=1;i<=n;i++) jc[i]=jc[i-1]*i%mod;
//	inv[n]=power(jc[n]); for(int i=n;i;i--) inv[i-1]=inv[i]*i%mod;
//}
//ll C(int x,int y) {
//	if(x<y || y<0) return 0;
//	return jc[x]*inv[y]%mod*inv[x-y]%mod;
//}

int n,a[N],k;
ll p[N],s[N];

struct rec {
	int val,len;
	rec() {}
	rec operator +(rec b) const {
		rec c; c.len=len+b.len;
		c.val=(val*p[b.len]+b.val)%mod;
		return c;
	}
} v[N<<2];
int tag[N<<2];

void bt(int x,int l,int r) {
	if(l == r) {v[x].val=v[x].len=1; return ;}
	int mid=(l+r)/2;
	bt(lc,l,mid);
	bt(rc,mid+1,r);
	v[x]=v[lc]+v[rc];
}

void upd(int x,int y,int len) {
	tag[x]=y;
	v[x].val=s[len-1]*y%mod;
}

void change(int x,int l,int r,int L,int R,int d) {
	if(L<=l&&r<=R) return upd(x,d,r-l+1);
	int mid=(l+r)/2;
	if(tag[x]) {
		upd(lc,tag[x],mid-l+1);
		upd(rc,tag[x],r-mid);
		tag[x]=0;
	}
	if(L<=mid) change(lc,l,mid,L,R,d);
	if(mid< R) change(rc,mid+1,r,L,R,d);
	v[x]=v[lc]+v[rc];
}

void solve() {
	qr(n); qr(k);
	p[0]=s[0]=1; for(int i=1;i<=n;i++) p[i]=p[i-1]*10LL%mod,s[i]=(s[i-1]+p[i])%mod;
	bt(1,1,n);
	while(k--) {
		int l,r,c; qr(l); qr(r); qr(c);
		change(1,1,n,l,r,c);
		pr2(v[1].val);
	}
}

int main() {
	int T=1;
//	qr(T);
	while(T--)
		solve();
}





Measured memory_bytes: 12900
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int ch[30],ch2[30];
char c1[30],c2[30];
int box[30][30];



int main(){
  int a,i,j,k;
  string s,t;
  cin >> s >> t;
  for(i=0;i<30;i++){
    c1[i]=c2[i]='\0';
    ch[i]=-1;
  }
  for(i=0;i<s.size();i++){
    if(c1[t[i]-'a']=='\0'){
      c1[t[i]-'a']=s[i];
    }else{
      if(t[i]==s[i]||c1[t[i]-'a']==s[i])continue;
      else{
        cout << "No" << endl;
        return 0;
      }
    }

    if(c2[s[i]-'a']=='\0'){
      c2[s[i]-'a']=t[i];
    }else{
      if(t[i]==s[i]){//同じとき
        if(c2[s[i]-'a']!=t[i]){//違うのがはいってたらno
          cout << "No" << endl;
          return 0;
        }
      }else{//違うとき
        if(c2[s[i]-'a']!=t[i]){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  int ans=0,now=1,b;
  for(int i=0;i<n;i++){
    cin >> b;
    if(b!=now)
      ans++;
    else
      now++;
  }
  cout << (ans==n?-1:ans) << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
#define ld long double
int main(){
    int64_t a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    int64_t dis = abs(a-b);
    if(v<=w){
        cout<<"NO"<<endl;
        return 0;
    }
    double time = double(dis)/abs(v-w);
    if(time<=t){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}   

Measured memory_bytes: 3636
#include <algorithm>
#include <climits>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> i_i;
int MOD = 1000000007;

int main() {
	int n; cin >> n;
	vector<int> X, Y;
	while (n--) {
		vector<int> x(6), y(6);
		for (int j = 0; j < 6; j++)
			scanf("%d%d", &x[j], &y[j]);
		for (int j = 0; j < 6; j++) {
			for (int k = 0; k < 3; k++) {
				X.push_back(x[j]);
				Y.push_back(y[j]);
			}
			for (int k = 0; k < 3; k++) {
				X.push_back(x[(j + 1) % 6]);
				Y.push_back(y[(j + 1) % 6]);
			}
		}
	}
	n = X.size() / 6;
	vector<vector<int> > a(n, vector<int>(6, INT_MIN));
	vector<vector<i_i> > p(6, vector<i_i>(n));
	int hoge = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 6; j++) {
			int x = X[hoge], y = Y[hoge]; hoge++;
			a[i][0] = max(a[i][0], x);
			a[i][1] = max(a[i][1], -x);
			a[i][2] = max(a[i][2], y);
			a[i][3] = max(a[i][3], -y);
			a[i][4] = max(a[i][4], x + y);
			a[i][5] = max(a[i][5], -(x + y));
		}
		for (int k = 0; k < 6; k++)
			p[k][i] = i_i(a[i][k], i);
	}
	for (int k = 0; k < 6; k++) {
		sort(p[k].begin(), p[k].end());
		reverse(p[k].begin(), p[k].end());
	}
	vector<int> index(6), cnt(n);
	queue<int> q;
	vector<int> b(6);
	for (;;) {
		for (int k = 0; k < 6; k++)
			for (int& i = index[k]; i < n && -p[k][i].first <= b[k ^ 1]; i++) {
				int j = p[k][i].second;
				if (++cnt[j] == 6) q.push(j);
			}
		if (q.empty()) break;
		int i = q.front(); q.pop();
		for (int k = 0; k < 6; k++)
			b[k] = max(b[k], a[i][k] + 1);
	}
	int k; cin >> k;
	while (k--) {
		int x, y; scanf("%d%d", &x, &y);
		if (x <= b[0] && -x <= b[1] && y <= b[2] && -y <= b[3] && x + y <= b[4] && -(x + y) <= b[5])
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

Measured memory_bytes: 42420
import sys

read = sys.stdin.read
readline = sys.stdin.readline

n = int(readline())
#print(n)
a_list = list([int(x) for x in readline().rstrip().split()])
#print(a_list)
count = 0
for i in a_list[::2]:
    #print(i)
    if i % 2 != 0:
        count += 1

print(count)


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<vector<int>> m(n + 1, vector<int>(2));
  for (int i = 0; i < n; i++) {
    m[i + 1][s[i] == 'E'] = 1;
  }
  for (int i = 0; i < n; i++) {
    m[i + 1][0] += m[i][0];
    m[i + 1][1] += m[i][1];
  }
  int r = n;
  for (int i = 0; i < n; i++) {
    r = min(r, (m[i][0] - m[0][0]) + (m[n][1] - m[i + 1][1]));
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 16900
#include <bits/stdc++.h>
using namespace std;
#define int long long
int a[20],n,s,h;
string v;
main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(0);
	//cout.tie(0);
	a[0]=1;
	for(int i=1;i<=15;i++)
	  a[i]=a[i-1]*10;
	s=0;
	for(int i=10;i>=1;i--)
	  {
		int check = a[i]-1;
		cout << "? " << check << "\n";
		fflush(stdout);
		cin >> v;
		//h++;
		if(v == "N") 
		{
			s = i+1;
		break;
	    }
	  }
	if(s==0)
	  {
	  	for(int i=10;i>=0;i--)
	  	 {
		 int check = a[i];
		 cout << "? " << check << "\n";
		 fflush(stdout);
		 cin >> v;
		 //h++;
		 if(v == "Y"&& i==10) 
		   {
		   	cout << "! " << 1 << "\n";
		    fflush(stdout);
			//s = i+1;
		    exit(0);
		   }
		  if(v=="Y")
		   {
		   	s=i+1;
		   	break;
		   }
	      }
	    
	  }
	int l,r,gi;
	l=a[s];
	r=a[s+1]-10;
	gi=0;
	while(l<r)
	 {
	 	int mid;
	 	mid=(l+r)/2;
	 	if(mid==gi) break;
		 else gi=mid;
	 	cout << "? " << mid << "\n";
		fflush(stdout);
		cin >> v;
		if(v == "Y") r=mid;
		  else l=mid;
	    h++;
	 }
	if(r/10!=0) cout<<"! "<<r/10<<endl;
	  else cout<<"! "<<1<<endl;
    fflush(stdout);
    //cout<<h<<endl;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n; cin>>n;
    vector<ll> a(n);
    for (int i=0; i<n; i++)cin>>a[i];
    ll sum = 0;
    for (int i=0; i<n; i++){
        if (i&1)sum -= a[i];
        else sum += a[i];
    }
    vector<ll> res(n);
    res[0] = sum/2;
    for (int i=1; i<n; i++)res[i] = a[i-1] - res[i-1];
    for (int i=0; i<n; i++)res[i] *= 2;
    for (int i=0; i<n; i++)cout<<res[i]<<" ";
}

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

using namespace std;

#define ll long long
#define endl '\n'
#define pb push_back
#define inf 1e9

int vetor[100005];
int replica[100005];

int main ()
{
    int n, m; cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        int l, r; cin >> l >> r;
        vetor[l]++;
        vetor[r+1]--;
    }

    //O i-ésimo cartão abre vetor[i]+prefix_sum[i]

    int maximo = 0;
    for (int i = 1; i <= n; i++)
    {
        replica[i] = replica[i-1] + vetor[i];
        if (replica[i] == m)
            maximo++;
    }
    cout << maximo << endl;
    return 0;
}


Measured memory_bytes: 1024
def main():
  n, x = map(int, input().split())
  if x == 1 or x == 2*n-1:
    print("No")
    return 0
  print("Yes")
  if n == 2:
    ans = [1, 2, 3]
  elif n >= 3 and (x == 2 or x == 2*n-2):
    if x == 2:
      ans = [3, 2, 1, 4]
      key = [int(x) for x in range(5, 2*n)]
      key, key2 = list(reversed(key[:len(key)//2])), key[len(key)//2:]
      ans = key+ans+key2
    else:
      ans = [2*n-3, 2*n-2, 2*n-1, 2*n-4]
      key = [int(x) for x in range(1, 2*n-4)]
      key, key2 = list(reversed(key[:len(key)//2])), key[len(key)//2:]
      ans = key+ans+key2
  else:
    ans = [x-2, x+1, x, x-1, x+2]
    key = [int(x) for x in range(1, x-2)] + [int(x) for x in range(x+3, n*2)]
    ans = key[len(key)//2:]+ans+key[:len(key)//2]
  for a in ans:
    print(a)
  
if __name__ == "__main__":
  main()



Measured memory_bytes: 19676
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
	int n,m,k,nn;
	scanf("%d%d%d",&n,&m,&k);
	nn=m/n;
	if(nn>k)
	nn=k;
	printf("%d\n",nn);
	
	
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    while(1) {
        ll n;
        cin >> n;
        if(!n) break;
        vector<ll> a(n);
        REP(i, n) cin >> a[i];

        ll ave = 0;
        REP(i, n) ave += a[i];

        ll ret = 0;
        REP(i, n) if(a[i]*n <= ave) ret++;

        cout << ret << endl;
    }

    return 0;
}



Measured memory_bytes: 3252
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, q;
    cin >> n;
    map<int, int> freq;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        freq[x]++;
        ans += x;
    }
    cin >> q;
    while(q--){
        int x, y;
        cin >> x >> y;
        ans += freq[x] * (y - x);
        freq[y] += freq[x];
        freq[x] = 0;
        cout << ans << '\n';
    }

    return 0;
}



Measured memory_bytes: 8016
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

ll solve(ll N, vector<ll> d){
    sort(ALL(d));
    ll ans = 0;
    rep1(K,2e5){
        ll ct = d.end() - lower_bound(ALL(d),K);
        if(ct == N - ct) ans++;
    }
    return ans;
}

int main(){
    ll N; cin >> N;
    vector<ll> d(N); rep(i,N) cin >> d[i];
    print(solve(N,d));
    return 0;
}

Measured memory_bytes: 1792
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Sat May 26 22:02:28 2018
//
package main

import (
	"fmt"
)

var N int
var S string

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	fmt.Scan(&N, &S)
	ans := 0
	for i := 1; i < len(S)-2; i++ {
		s1 := S[:i]
		s2 := S[i:]
		m := map[uint8]bool{}
		for i := range s1 {
			m[s1[i]] = true
		}

		m2 := map[uint8]bool{}
		for i := range s2 {
			m2[s2[i]] = true
		}

		count := 0
		for k, _ := range m2 {
			if _, ok := m[k]; ok {
				count++
			}
		}
		ans = max(ans, count)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, countOne = 0, countTwo = 0;
	cin >> a >> b >> c;

	if(a == b && b == c) {
		cout << "No\n";
		return 0;
	}

	if(a == b) {
		countOne++;
	}
	if(b == c) {
		countOne++;
	}
	if(a == c) {
		countOne++;
	}

	if(countOne == 1) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 998244353;
int si[] = {-1, 0, 1, 0};
int sj[] = {0, -1, 0, 1};

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<int>> a(h,vector<int>(w));
  rep(i,h) rep(j,w) cin >> a[i][j];

  vector<int> p,x,y,z;
  rep(i,h) rep(j,w){
    if (a[i][j]%2 != 0) {
      a[i][j]--;
      if(i == h-1 && j == w-1) break;
      p.push_back(i);
      x.push_back(j);
      if(j != w-1) {
        a[i][j+1]++;
        y.push_back(i);
        z.push_back(j+1);
      }else{
        a[i+1][j]++;
        y.push_back(i+1);
        z.push_back(j);
      } 
    }
  }

  cout << p.size() << endl;
  rep(i,p.size()) cout << p[i]+1 << " " << x[i]+1 << " " << y[i]+1 << " " << z[i]+1 << endl;

  return 0;
}


Measured memory_bytes: 6292
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

#define LET(name, value) __typeof(value) name = value
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define FOREQ(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOREACH(i, c) for (LET(i, (c).begin()); i != (c).end(); ++i)

char floor[110];
char space[110];

int main() {
  int W, Q;
  while (scanf("%d%d", &W, &Q), W|Q) {
    memset(floor, ' ', sizeof(floor));
    memset(space, ' ', sizeof(space));
    map<int, pair<int, int> > id2xw;
    floor[W] = '\0';
    REP(i, Q) {
      char action; scanf(" %c", &action);
      if (action == 's') {
        int id, w; scanf("%d%d", &id, &w);
        space[w] = '\0';
        char* p = strstr(floor, space);
        space[w] = ' ';
        if (p) {
          int x = p - floor;
          printf("%d\n", x);
          REP(j, w) { floor[x+j] = '*'; }
          id2xw.insert(make_pair(id, make_pair(x, w)));
        } else {
          puts("impossible");
        }
      } else if (action == 'w') {
        int id; scanf("%d", &id);
        LET(it, id2xw.find(id));
        int x = it->second.first;
        int w = it->second.second;
        REP(j, w) { floor[x+j] = ' '; }
        id2xw.erase(it);
      } else {
        assert(false);
      }
    }
    puts("END");
  }
}

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

int main()
{
    int n;
    string s;
    //scanf("%d",&n);
    //scanf("%s",s);
    cin>>n;
    cin>>s;
    int c=1;
    if(n%2) c=0;
    else{
        n/=2;
        for(int i=0;i<n;++i){
            if(s[i]!=s[i+n]){
                c=0;
                break;
            }
        }
    }
    if(c) printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 256
import numpy as np
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))
C = np.array([c1,c2,c3])
Ct = np.transpose(C)
ans = C + Ct
fact = "Yes"
for i in range(3):
    for j in range(3):
        if not(ans[i,j] == C[i,i] + C[j,j]):
            fact = "No"
            break
print(fact)


Measured memory_bytes: 27280
#include <bits/stdc++.h>
#define ll long long
#define fastio cin.sync_with_stdio(false); cin.tie(NULL)
using namespace std;
ll findf(ll n, ll b){
  ll re=0;
  while(n>0){
    re+=n%b;
    n/=b;
  }
  return re;
}
int main(){
  fastio;
  ll n,f;
  cin>>n>>f;
  ll ans=-1;
  if (n>=f){
  if (n==f)ans=n+1;
  if (ans==-1)
  for (ll d=2;d*d<=n;d++){
    if(findf(n,d)==f){
      ans=d;
      break;
    }
  }
  if (ans==-1){
    for (ll p=1;p*p<n;p++){
      if ((n-f)%p) continue;
      ll b=(n-f)/p+1;
      if (n/b/b==0&&f-p==n%b)
        ans=b;
    }
  }
  }  
  cout<<ans<<'\n';
  return 0;
}


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

int main(void){
    int N, M;
    cin >> N >> M;
    vector<int> k(M, 0);
    vector<vector<int>> s(M);
    vector<int> p(M, 0);

    // load k and s
    for(int i{0}; i<M; ++i){
        cin >> k.at(i);
        s.at(i) = vector<int>(k.at(i), 0);
        for(int j{0}; j<k.at(i); ++j){
            cin >> s.at(i).at(j);
        }
    }

    // load p
    for(int i{0}; i<M; ++i){
        cin >> p.at(i);
    }

    int n{0};
    for(int biti{0}; biti<(1<<N); ++biti){
        bitset<10> bit(biti);
        bool result{true};
        for(int i{0}; i<M; ++i){
            int sum{0};
            for(int j{0}; j<k.at(i); ++j){
                if(bit.test(s.at(i).at(j)-1)){
                    ++sum;
                }
            }
            if(sum%2 != p.at(i)){
                result = false;
                //break;
            }
        }
        if(result){
            ++n;
        }

    }

    cout << n << endl;
}


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

using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& (a) : (x))
#define all(x) (x).begin (), (x).end ()
#define sz(x) (int) (x).size ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;

typedef pair<int, int> pii;
#define fi first
#define se second
#define mkp(x) make_pair ((x))

typedef vector<int> vi;
#define pb(x) push_back ((x))

#define DEBUG 0
#define ddcout if (DEBUG) cout
#define ddprintf(fmt, ...) if (DEBUG) printf (fmt, ##__VA_ARGS__)

#define ddprintfv(v) if (DEBUG) { trav (a, v) cout << a << " "; cout << "\n"; }

#define EXIT ddprintf ("Time elapsed %lf\n", 1.0 * clock() / CLOCKS_PER_SEC); exit (0)

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x3f3f3f3f3f3f3f3f;
const int  INFi  =  0x3f3f3f3f;
const ll   MAXN  =  1e+6+7;

template <typename T>
T extGcd(T a, T b, T& x, T& y) {
    if (b == 0) {
        x = 1; y = 0; return a;
    }
    else {
        T g = extGcd(b, a % b, y, x);
        y -= a / b * x;
        return g;
    }
}
 
template <typename T>
T modInv(T a, T m) {
    T x, y;
    extGcd(a, m, x, y);
    return (x % m + m) % m;
}
 
template <typename T>
T modDiv(T a, T b, T m) {
    return ((a % m) * modInv(b, m)) % m;
}
 
template<typename T>
T modMul(T a, T b, T m) {
    T x = 0, y = a % m;
    while (b > 0) {
        if (b % 2 == 1) x = (x + y) % m;
        y = (y * 2) % m; b /= 2;
    }
    return x % m;
}

int main ()
{
    int i, j;
    int X, Y;
    scanf ("%d %d", &X, &Y);
    
    if ((X + Y)%3 != 0 || min (X, Y) * 2 < max (X, Y))
    {
        printf ("0\n");
        EXIT;
    }

    ll n = (X+Y)/3;
    ll k = n/2 - abs (X-Y)/2;
    ddprintf ("%lld %lld\n", n, k);
    ll num = 1, den = 1;
    for (i = n; i > max (k, n - k); i--)
        num = (num * i) % MOD;
    for (i = min (k, n - k); i > 0; i--)
        den = (den * i) % MOD;
    ddprintf ("%lld %lld\n", num, den);

    printf ("%lld\n", modDiv (num, den, MOD));

    EXIT;
}

Measured memory_bytes: 256
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>

using namespace std;
const int64_t INF=10000000000000000;

int main(){
	pair<int64_t,int64_t> start;
	pair<int64_t,int64_t> goal;
	const int64_t size=100000001;
	cin>>start.first>>start.second>>goal.first>>goal.second;
	int64_t n;
	cin>>n;
	vector<pair<int64_t,int64_t> > fountains;
	fountains.resize(n);
	for(int64_t i1=0;i1<n;i1++){
		cin>>fountains[i1].first>>fountains[i1].second;
	}
	sort(fountains.begin(),fountains.end());
	if(start.first>goal.first){
		swap(start,goal);
	}
	bool mirror=false;
	if(start.second>goal.second){
		mirror=true;
	}
	vector<pair<int64_t,int64_t> > on_way;
	on_way.reserve(n);
	for(auto i1=fountains.begin();i1!=fountains.end();i1++){
		if(start.first<=i1->first&&i1->first<=goal.first){
			if((start.second<=i1->second&&i1->second<=goal.second)||(start.second>=i1->second&&i1->second>=goal.second)){
				if(mirror){
					on_way.push_back(make_pair(i1->first,size-i1->second));
				}else{
					on_way.push_back((*i1));
				}
			}
		}
	}
	if(mirror){
		start.second=size-start.second;
		goal.second=size-goal.second;
	}
	int64_t f_num=0;
	if(!on_way.empty()){
		int64_t dp[on_way.size()];
		fill(dp,dp+on_way.size(),INF);
		for(int64_t i1=0;i1<on_way.size();i1++){
			*lower_bound(dp,dp+on_way.size(),on_way[i1].second)=on_way[i1].second;
		}
		f_num=lower_bound(dp,dp+on_way.size(),INF)-dp;
	}
	double ans=(goal.second-start.second)*100+(goal.first-start.first)*100;


	if(f_num==min(goal.second-start.second+1,goal.first-start.first+1)){
		ans=ans+(10*M_PI-20)-(f_num-1)*(20-5*M_PI);
	}else{
		ans=ans-f_num*(20-5*M_PI);
	}
	cout<<fixed<<setprecision(15)<<ans<<endl;





}


Measured memory_bytes: 8064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    int ans=n/1000;
    if(n%1000!=0) ans ++;
    ans =1000*ans-n;
    cout<<ans<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll lcm(ll a, ll b){
  return a*b/gcd(a,b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    return Parent[a] = root(Parent[a]);
  }

  bool issame(int a, int b){
    return root(a) == root(b);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);

    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

void dfs(int v, int p, vvi &G, vi &d){
  for(auto nv : G[v]) {
    if(nv == p) continue;
    d[nv] = d[v] + 1;
    dfs(nv, v, G, d);
  }
}

int main(){
  int n, u, v; cin >> n >> u >> v;
  u--; v--;
  vvi G(n);
  rep(i,n-1) {
    int a,b; cin >> a >> b;
    a--; b--;
    G[a].pb(b); G[b].pb(a);
  }

  vi udist(n);
  dfs(u, -1, G, udist);
  vi vdist(n);
  dfs(v, -1, G, vdist);

  // <vからの距離、頂点番号>
  vector<pii> longest(n);
  rep(i,n) {
    longest[i] = mp(vdist[i],i);
  }
  sort(all(longest));
  reverse(all(longest));

  //rep(i,n) cout << longest[i].first << endl;
  rep(i,n) {
    int ndist = longest[i].first;
    int nu = longest[i].second;
    if(udist[nu] < vdist[nu]){
      cout << ndist-1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 13696