akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

class Bipartite_matching {
    int n;
    vvi G;
    vi match;
    vb used;
    bool dfs(int v) {
        used[v] = true;
        for(int u : G[v]) {
            int w = match[u];
            if(w < 0 || !used[w] && dfs(w)) {
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }

public:
    Bipartite_matching(int n):n(n),G(n),match(n),used(n) {}
    void add_edge(int v,int u) {
        G[v].pb(u);
        G[u].pb(v);
    }
    int max_matching() {
        int res = 0;
        match.assign(n,-1);
        rep(i,n) {
            if(match[i] >= 0) continue;
            used.assign(n,false);
            if(dfs(i)) res++;
        }
        return res;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int H,W;
    cin >> H >> W;
    vvi h(H,vi(W));
    cin >> h;
    rep(_,2) {
        Bipartite_matching bp(2*H);
        vb v(H,true);
        rep(i,H) rep(j,H) {
            if(i == j) continue;
            bool ok = true;
            rep(k,W) if(h[i][k] > h[j][k]) ok = false;
            if(ok) bp.add_edge(i,j+H);
            else v[j] = false;
        }
        bool flag = false;
        rep(i,H) if(v[i]) flag = true;
        if(!flag) {
            YES(false);
            return 0;
        }
        if(H-bp.max_matching() > 2) {
            YES(false);
            return 0;
        }
        vvi nh(W,vi(H));
        rep(i,H) rep(j,W) nh[j][i] = h[i][j];
        swap(H,W);
        swap(h,nh);
    }
    YES(true);
}



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

int main(void) {
    int k;
    string order;
    priority_queue<int> S;
    while(true){
        cin >> order;
        if(order == "end") break;
        if(order == "insert"){
            cin >> k;
            S.push(k);
        }
        if(order == "extract"){
            cout << S.top() << endl;
            S.pop();
        }
    }
    return 0;
}

Measured memory_bytes: 7036
#include <stdio.h>

int main(void) {
	int n,m,p;
	while(scanf("%d%d%d",&n,&m,&p)==3 && (n|m|p)!=0) {
		int t;
		int i,j,k,l;
		int board[7][7][7]={{{0}}};
		int result=0;
		int end_turn=0;
		for(t=0;t<p;t++) {
			int x,y;
			if(scanf("%d%d",&x,&y)!=2)return 1;
			x--;
			y--;
			if(result!=0)continue;
			for(i=0;i<n;i++) {
				if(board[x][y][i]==0) {
					board[x][y][i]=t%2+1;
					break;
				}
			}
			for(i=0;i<n;i++) {
				for(j=0;j<n;j++) {
					for(k=0;k<n;k++) {
						int dx,dy,dz;
						if(board[i][j][k]==0)continue;
						for(dx=-1;dx<=1;dx++) {
							for(dy=-1;dy<=1;dy++) {
								for(dz=-1;dz<=1;dz++) {
									if((dx|dy|dz)==0)continue;
									for(l=1;l<m;l++) {
										int xx=i+dx*l;
										int yy=j+dy*l;
										int zz=k+dz*l;
										if(xx<0 || n<=xx || yy<0 || n<=yy || zz<0 || n<=zz) {
											break;
										}
										if(board[xx][yy][zz]!=board[i][j][k]) {
											break;
										}
									}
									if(l>=m) {
										result=board[i][j][k];
										end_turn=t+1;
									}
								}
							}
						}
					}
				}
			}
		}
		if(result==0) {
			puts("Draw");
		} else if(result==1) {
			printf("Black %d\n",end_turn);
		} else if(result==2) {
			printf("White %d\n",end_turn);
		} else {
			puts("ERROR");
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

#define MOD (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()

ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}



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

int n;
cin>>n;

stringstream ss;
ss<<n;
string s=ss.str();

for(char x:s)
  {
    if(x=='9')x='1';
    else if(x=='1')x='9';
    cout<<x;
  }

  //cout<<s<<"\n";

return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N;
    cin >> N;
    cout << (int)(N/3) << "\n";
    return 0;
}

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

int main(){
    ll x;
    cin >> x;
    ll ans = 0;
    ll t = x % 11;
    ans += (x / 11) * 2;
    if (t >= 1 && t <= 6) ans += 1;
    else if (t >= 7) ans += 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int X,Y,A,B,C; cin >> X >> Y >> A >> B >> C;
    vecl p(A);
    vecl q(B);
    vecl r(C);
    REP(i,A) cin >> p[i];
    REP(i,B) cin >> q[i];
    REP(i,C) cin >> r[i];
    sort(p.begin(),p.end(),greater<ll>());
    sort(q.begin(),q.end(),greater<ll>());
    sort(r.begin(),r.end(),greater<ll>());
    vecl res;
    REP(i,X) res.push_back(p[i]);
    REP(i,Y) res.push_back(q[i]);
    REP(i,C) res.push_back(r[i]);
    sort(res.begin(),res.end(),greater<ll>());
    ll ans = 0;
    REP(i,X+Y) ans += res[i];
    cout << ans << endl;
}


Measured memory_bytes: 8816
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())
ans = 0
for i in range(105,N+1,2):
    ans += 1 if len(make_divisors(i)) == 8 else 0
print(ans)

Measured memory_bytes: 3316
#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos and *pos <= '9') n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos and *pos <= '9') m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos and *pos <= '9') k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos and *pos <= '9') a[i + 1] = a[i + 1] * 10 + *pos++ - '0';
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos and *pos <= '9') pos++;
                pos++;
            }
            break;
        }
    }
    while(*pos and *pos <= 32) pos++;
    rep(i, m) {
        while('0' <= *pos and *pos <= '9') b[i + 1] = b[i + 1] * 10 + *pos++ - '0';
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    int now = nn;
    int ans = now;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


Measured memory_bytes: 7840
#include<iostream>
#include<vector>
#include<map>
using namespace std;
vector<vector<int>>niv;
vector<vector<int>>dat;
string k;
int m(int n,int r){
    if(n>=niv.size())return 0;
    if(dat[n][r]!=0)return dat[n][r];
    dat[n][r]=0;
    for(int i=0;i<3;i++){
        if(i!=r){
            int l=m(n+1,i);
           dat[n][r]=max(dat[n][r],l+niv[n][r]);
        }
    }
    return dat[n][r];
}

int main(){
    int a,aux;
    cin>>a;
    dat=vector<vector<int>>(a+1,vector<int>(4,0));
    vector<int> aux2(4,0);
    niv.push_back(aux2);
    for(int i=0;i<a;i++){
        aux2.clear();
        for(int j=0;j<3;j++){
            cin>>aux;
            aux2.push_back(aux);
        }
        niv.push_back(aux2);
    }
    cout<<m(0,3)<<endl;
    return 0;
}


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

int main(){

string n;
cin >> n;
int sum=0;
rep(i,n.size()) sum += n[i]-'0';
if(sum%9==0) cout << "Yes" << endl;
else cout << "No" << endl;

}

Measured memory_bytes: 3648
// Panasonic_2020_C

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

int main()
{
	ll a, b, c;
	cin >> a >> b >> c;

	ll m = 4 * a * b;
	ll n = (c - a - b) * (c - a -b);

	//cout << m << "\n";
	//cout << n << "\n";

	if((c - a -b > 0) && m < n) cout << "Yes" << "\n";
	else cout << "No";

	return 0;
}                                

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i32 n; cin >> n;
    vi a(n); rep(i,n) cin >> a[i];
    a.push_back(0);

    i32 ans = 0, tmp = 0;
    for(i32 i = 0; i < n+1; ++i) {
        tmp += a[i];
        if(a[i] == 0) {
            ans += tmp/2;
            tmp = 0;
        }
    }

    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 1792
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=4e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const long double PI = acos(-1),eps=1.0e-14;

void solve(){
    int n;
    cin>>n;
    int mx=0,res=0;
    loop(n,i,0){
        int x;
        cin>>x;
        if(x>=mx)
            res++;
        max_self(mx,x);
    }
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3608
package main

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

type operation struct {
	from, to point
}

type point struct {
	y, x int
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	var H, W int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &H)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &W)

	var mp [][]int
	mp = make([][]int, H+1)
	for i := 0; i < len(mp); i++ {
		mp[i] = make([]int, W+1)
	}

	for i := 1; i <= H; i++ {
		for j := 1; j <= W; j++ {
			scanner.Scan()
			fmt.Sscanf(scanner.Text(), "%d", &mp[i][j])
		}
	}

	operations := make([]operation, 0)
	for i := 1; i <= H-1; i++ {
		for j := 1; j <= W; j++ {
			if mp[i][j]%2 == 1 {
				mp[i][j]--
				mp[i+1][j]++
				operations = append(operations, operation{
					point{i, j},
					point{i + 1, j},
				})
			}
		}
	}

	for j := 1; j <= W-1; j++ {
		if mp[H][j]%2 == 1 {
			mp[H][j]--
			mp[H][j+1]++
			operations = append(operations, operation{
				point{H, j},
				point{H, j + 1},
			})
		}
	}

	fmt.Println(len(operations))
	for _, op := range operations {
		fmt.Println(op.from.y, op.from.x, op.to.y, op.to.x)
	}

	/*
		for i := 1; i <= H; i++ {
			for j := 1; j <= W; j++ {
				fmt.Print(mp[i][j], " ")
			}
			fmt.Println()
		}
	*/

}


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


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


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

  int mini = 10000000;

  for(int i = 1; i < num; ++i){
    int b = num - i;
    if(mini > digit_of_sum(i) + digit_of_sum(num - i) && b > 0){
      mini = digit_of_sum(i) + digit_of_sum(num - i);
    }
    else continue;
  }

  cout << mini << endl;

  return 0;
  
}


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

int par[MAX_N + 1], ran[MAX_N + 1];

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

int find(int x) {
    if (x == par[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 (ran[x] < ran[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (ran[x] == ran[y])
            ran[x]++;
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    int p[n];
    init(n);
    for (int i = 0; i < n; i++)
        cin >> p[i];
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        unite(x, y);
    }
    unordered_set<int> xs[n + 1];
    for (int i = 1; i <= n; i++) {
        xs[find(i)].insert(i);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int k = find(i + 1);
        if (xs[k].find(p[i]) != xs[k].end())
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13184
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int sum1=a+b;
    int sum2=a-b;
    int sum3=a*b;
    int maxn=max(sum1,max(sum2,sum3));
    cout<<maxn<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
	int q; cin>>q;
	while(q--) 
	{
		int n; cin>>n;
		set<int> used;
		int ans=0;
		while(used.find(n)==used.end()&&9<n)
		{
			int next=0,r=0;
			used.insert(n);
			int mul=1;
			while(1)
			{
				r+=n%10*mul;
				n/=10;
				mul*=10;
				if(n==0) break;
				next=max(next,r*n);
			}
			n=next;
			ans++;
		}
		if(n<=9) cout<<ans<<endl;
		else cout<<-1<<endl;
	}
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int N,M;cin>>N>>M;
  std::vector<char> v(N*M),w(N*M);
  int ans=0;
  for(int i=0;i<N*M;i++)cin>>v[i];
  for(int i=0;i<N*M;i++)cin>>w[i];
  for(int i=0;i<N*M;i++)ans+=v[i]!=w[i];
  fin(ans);
}



Measured memory_bytes: 10936
#include <iostream>
using namespace std;
int main(void){
    int H,W;
    while(1){
        cin>>H>>W;
        if(H==0&&W==0)break;
        for(int i=1;i<=W;i++)cout<<"#";
        cout<<endl;
        for(int i=1;i<=H-2;i++){
            cout<<"#";
            for(int j=1;j<=W-2;j++){
                cout<<".";
            }
            cout<<"#"<<endl;
        }
        for(int i=1;i<=W;i++)cout<<"#";
        cout<<endl<<endl;
    }
    return 0;
}

Measured memory_bytes: 3084
#[allow(dead_code)]
fn rd() -> String {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().to_owned()
}

/// 1行の文字を空白で分割してVec<T>にする。
#[allow(dead_code)]
fn rd_vec<T : std::str::FromStr>() -> Vec<T> {
    rd().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

/// 1つの要素を入力で受け取る
#[allow(dead_code)]
fn rd_one<T : std::str::FromStr>() -> T {
    rd().parse().ok().unwrap()
}

/// 複数回read_splitを行う
#[allow(dead_code)]
fn rd_vec_mul<T : std::str::FromStr>(count : i32) -> Vec<Vec<T>> {
    (0..count).map(|_| rd_vec()).collect()
}

/// Vecを1列で出力する
#[allow(dead_code)]
fn op_vec<T : std::fmt::Display>(item : Vec<T>, splitter : char) {
    let cnt = item.len();
    let mut c = 0;
    for i in item.iter() {
        c+=1;
        if cnt > c {print!("{}{}", i, splitter);} else {println!("{}", i);}
    }
}

fn main() {
    let input : Vec<i64> = rd_vec();
    let mut a : Vec<i64> = vec![0; input[0] as usize];
    for _ in 0..input[2] {
        let u : usize = rd_one();
        a[u - 1] += 1;
    }
    for t in a {
        println!("{}", if input[2] - t < input[1] {"Yes"} else {"No"});
    }
}


Measured memory_bytes: 4732
N = int(input())
ans = 0
if N >= 9:
  ans += 9
else:
  ans += N
if N >= 999:
  ans += 900
elif N >= 100:
  ans += N - 99
if N >= 99999:
  ans += 90000
elif N >= 10000:
  ans += N - 9999
print(ans)

Measured memory_bytes: 3060
import math, itertools
n = int(input())
X = list(list(map(int,input().split())) for _ in range(n))
L = list(itertools.permutations(range(n),n))
ans = 0

for l in L:
  dist = 0
  for i in range(n-1):
    s,t = l[i],l[i+1]
    vx = X[s][0] - X[t][0]
    vy = X[s][1] - X[t][1]
    dist += math.sqrt(vx**2 + vy**2)
  ans += dist

print(ans/len(L))

Measured memory_bytes: 13952
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)			(x).begin(),(x).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF				(int)2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))	
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)	
#define FloorN(x, n)	((x)-(x)%(n))			
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long			ll;
typedef unsigned long long	ull;
typedef pair<ll, ll>		P;
typedef vector<ll>			VLL;
typedef vector<VLL>			VVLL;
typedef vector<VVLL>		VVVLL;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N, Q;
	string S;
	cin >> N >> S >> Q;
	
	vector<set<int>> strPos(26);
	REP(i, N) {
		int strOne = S[i] - 'a';
		strPos[strOne].insert(i);
	}

	REP(i, Q) {
		int q;
		cin >> q;
		if (q == 1) {
			int l;
			char r;
			cin >> l >> r;
			l--;;

			int strOne = S[l] - 'a';
			strPos[strOne].erase(l);
			strOne = r - 'a';
			strPos[strOne].insert(l);
			S[l] = r;
		} else {
			int l, r;
			cin >> l >> r;
			l--; r--;

			int ansOne = 0;
			REP(j, 26) {
				set<int> &posOne = strPos[j];
				auto idx1 = posOne.lower_bound(l);
				auto idx2 = posOne.lower_bound(r);
				if (idx1 != posOne.end()) {
					int lPos = *idx1;
					int rPos;
					if (idx2 != posOne.end()) {
						rPos = *idx2;
					} else {
						rPos = INF;
					}
					if ((l <= lPos && lPos <= r) || (l <= rPos && rPos <= r)) {
						ansOne++;
					}
				}
			}

			cout << ansOne << endl;
		}
	}

	return 0;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 2000000000000000000LL
#define EPS 1e-9
#define debug(a) cerr<<#a<<"="<<(a)<<"\n"
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 1e9+7;
const double PI = acos(-1);

int n,i,j,k,t;
int d;
char s[10005];
int dp[10005][2][100];

int solve(int idx, int ub, int val){
    int &ans = dp[idx][ub][val];
    if(ans == -1){
        ans = 0;
        if(ub){
            int ma = s[idx]-'0';
            ans = solve(idx-1, 1, (val+ma)%d);
            for(i=0;i<ma;++i)
                ans = (ans + solve(idx-1, 0, (val+i)%d)) % mod;
        }
        else{
            for(int i=0;i<10;++i)
                ans = (ans + solve(idx-1, 0, (val+i)%d)) % mod;
        }
    }
    return ans;
}

int main(){
    memset(dp, -1, sizeof dp);
    scanf("%s", s+1);
    n = strlen(s+1);
    scanf("%d", &d);
    reverse(s+1, s+n+1);
    memset(dp[0], 0, sizeof dp[0]);
    dp[0][1][0] = dp[0][0][0] = 1;
    int ans = (mod + solve(n, 1, 0) - 1)%mod;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[110];
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a,a + n,greater<int>());
    int alice = 0;
    int bob = 0;
    for (int i = 0; i < n; i++){
        if(i % 2 == 0)
            alice += a[i];
        else 
            bob += a[i];
    }
    cout << alice - bob << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<functional>
#include<queue>
#include<map>
using namespace std;
int main(){
	int q,p;
	int n;
	while(cin>>p>>q,p){
		int m=0,x,t;
		map<int,int> mp;
		priority_queue<int,vector<int>,greater<int> > que;
		for(int j=0;j<p;j++){
			cin>>t;
			for(int i=0;i<t;i++){
				cin>>x;
				if(!mp[x])que.push(x);
				mp[x]++;
				m=max(m,mp[x]);
			}
		}
		if(m<q)
		cout<<0<<endl;
		else{
			while(!que.empty()){
				int qq=que.top();
				que.pop();
				if(m==mp[qq]){
					cout<<qq<<endl;
					break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 920
#include<stdio.h>
int main(){
    int H,W,h,w;
    while(1){
        scanf("%d %d",&W,&H);
        if(H==0&&W==0){
            break;
        }
        for(w=0;w<W;w++){
            for(h=0;h<H;h++){
                if((h+w)%2==0){
                    printf("#");
                }
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
        }
    return 0;
}


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

typedef long long int ll;
typedef long double ld;

#define Pb push_back
#define Mp make_pair

#define ff first
#define ss second

#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define db1(x) cout<<#x<<" : "<<x<<endl;
#define db2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define db3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;

void solve()
{
   ll n;
   cin >> n;
   string ans = "";
   while(n > 0)
   {
      n--;
      ll x = n%26;
      ans = (char)('a'+x) + ans;
      n = (n-x)/26;
   }
   cout << ans << " ";
}

signed main()
{
  IOS;
  //freopen("input.txt", "rt", stdin);
  //freopen("output.txt", "wt", stdout);
  int t=1;
  //cin >> t;
  while(t--)
  {
    solve();
  }
  return 0;
}
/*==============================================================================================================================================================*/


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

void solve(ll sx, ll sy, ll tx, ll ty, vector<Pll> &path) {
  vector<Pll> ds = {
    {0, 1},
    {0, -1},
    {1, 0},
    {-1, 0},
  };
  vector<vector<ll>> dist(2011, vector<ll>(2011, 1e18));
  each (i, path) {
    dist[i.first][i.second] = -100;
  }
  dist[sy][sx] = 0;
  dist[ty][tx] = 1e18;
  queue<Pll> q;
  q.push(mkp(sy, sx));
  while (!q.empty()) {
    auto pos = q.front();
    q.pop();
    auto y = pos.first;
    auto x = pos.second;

    each (d, ds) {
      auto dy = y + d.first;
      auto dx = x + d.second;
      if (dy < 0 || dy > 2010) continue;
      if (dx < 0 || dx > 2010) continue;
      if (dist[dy][dx] == -100) continue;
      if (dist[dy][dx] < 1e18) continue;
      dist[dy][dx] = dist[y][x]+1;
      q.push(mkp(dy, dx));
    }
  }

  vector<Pll> pp;
  pp.push_back(mkp(ty, tx));
  queue<Pll> qq; 
  qq.push(mkp(ty, tx));
  while (!qq.empty()) {
    auto pos = qq.front();
    qq.pop();
    auto y = pos.first;
    auto x = pos.second;

    each(d, ds) {
      auto dy = y + d.first;
      auto dx = x + d.second;
      if (dy < 0 || dy > 2010) continue;
      if (dx < 0 || dx > 2010) continue;
      if (dist[dy][dx] == -100) continue;
      if (dist[dy][dx] == dist[y][x]-1) {
        pp.push_back(mkp(dy, dx));
        qq.push(mkp(dy, dx));
        break;
      }
    }
  }
  reverse(pp.begin(), pp.end());
  
  path.insert(path.end(), pp.begin(), pp.end());
}

int main() {
  ll sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  sx += 1005;
  sy += 1005;
  tx += 1005;
  ty += 1005;

  vector<Pll> path;
  solve(sx, sy, tx, ty, path);
  solve(tx, ty, sx, sy, path);
  solve(sx, sy, tx, ty, path);
  solve(tx, ty, sx, sy, path);
  
  for (ll i = 1; i < path.size(); ++i) {
    auto p_y = path[i-1].first;
    auto p_x = path[i-1].second;
    auto y = path[i].first;
    auto x = path[i].second;
    if (p_y == y && p_x == x) continue;
    if (p_y == y) {
      if (x-p_x > 0) cout << "R";
      else cout << "L";
    } else {
      if (y-p_y > 0) cout << "U";
      else cout << "D";
    }
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 33920
#include<bits/stdc++.h>
#define F(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RF(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
/*----------------------------------------------------------------------*/

const int N = 1e5+5;
int h[N],dp[N];

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

    int n;
    cin>>n;
    F(i, 1, n+1) {
    	cin>>h[i];
    	dp[i]=INF;
    }
    dp[1]=0; dp[2]=abs(h[2]-h[1]);
    F(i, 3, n+1) {
    	dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
    }
    cout<<dp[n];


    return 0;
}/*

*/


Measured memory_bytes: 1024
while True:
    height, width = map(int, input().split())
    if height == 0 or width == 0:
        break

    for h in range(0, height):
        for w in range(0, width):
            if (h + w) % 2:
                print('.', end='')
            else:
                print('#', end='')
        print()
    print()




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

set<string> a;
int main(){
    int n,ans=0;
    string tmp;
    scanf("%d",&n);
    while(n--){
        cin>>tmp;
        if(a.count(tmp)!=0) continue;
        else {
            a.insert(tmp);
            ans++;
        }
    }
    printf("%d",ans);
}


Measured memory_bytes: 19384
<?php

fscanf(STDIN, '%d', $n);
$arr = array();
for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, '%d %d', $a, $v);
    $arr[$a] = $v;
}
ksort($arr);
$v = max($arr);
$a = array_search($v, $arr);
echo "$a $v\n";

Measured memory_bytes: 6564
S=input()
def func(S):
  target="keyence"
  if S[:7]==target or S[-7:]==target:
    return True
  for i in range(7):
    a=target[:i]
    b=target[i:]
    if S[-len(b):]==b and S[:i]==a:
      return True
  return False

if func(S):
  print('YES')
else:
  print('NO')


Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	char a[4010],b[4010];
	while(scanf("%s",a)!=EOF){
		scanf("%s",b);
		int i,j,k;
		int max=0;
		for(i=0;i<strlen(a);i++){
			k=0;
			for(j=0;j<strlen(b)&&j<strlen(a)-i;j++){
				if(a[i+j]==b[j])k++;
				else{
					chmax(max,k);
					k=0;
				}
			}
			chmax(max,k);
		}
		for(i=0;i<strlen(b);i++){
			k=0;
			for(j=0;j<strlen(a)&&j<strlen(b)-i;j++){
				if(a[j]==b[i+j])k++;
				else{
					chmax(max,k);
					k=0;
				}
			}
			chmax(max,k);
		}
		cout<<max<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll cnt[100005];

int main() {
    init();
    ll N, Q;
    cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];
    cin >> Q;
    sort(all(A));

    ll S = accumulate(all(A), 0ll);

    rep(i, N) cnt[A[i]]++;

    rep(_, Q){
        ll b, c;
        cin >> b >> c;

        S += (c - b) * cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;

        cout << S << '\n';
    }
}

Measured memory_bytes: 4844
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main(){
    string s,t;
    int n,m;
    
    while(1){
        cin >> s;
        if(s == "-") break;
        t = "";
        cin >> n;
        rep(i,0,n){
            cin >> m;
            
            t = "";
            
            rep(i,m,s.size()){
                t += s[i];
            }    
            rep(i,0,m){
                t += s[i];   
            }
            
            rep(i,0,s.size()){
                s[i] = t[i];
            }
            
        }
        cout << t << endl;
    }
    return 0;
}


Measured memory_bytes: 3208
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  int n;
  int i,j;
  int k=0;
  int *a;
  int minj;
  int temp;
  
  scanf("%d",&n);
  
  a = (int *)malloc(sizeof(int) *n);

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

  for(i=0; i<n; i++){
    minj = i;
    for(j=i; j<n; j++){
      if(a[j] < a[minj]){
	minj = j;
      }
    }
    temp = a[i];
    a[i] = a[minj];
    a[minj] = temp;
    if(i != minj){
      k++;
    }
  }

  for(i=0; i<n; i++){
    printf("%d",a[i]);
    if(i != (n-1)){
      printf(" ");
    }
  }
  printf("\n%d\n",k);
  
  free(a);
  
  return(0);
}

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

using namespace std;
const int N = 100001;
bool is_prime[N];
int c[N] = {};

void sieve() {
	is_prime[0] = is_prime[1] = false; // The numbers 0 and 1 are not prime
	for (int i = 2; i < N; i++) is_prime[i] = true;
	for (int i = 2; i < N; i++) {
		if (is_prime[i]) {
			for (int j = 2; j * i < N; j++) is_prime[j * i] = false;	
		}
	}	
}

int main() {
	sieve();
	for (int i = 1; i < N; i++) {
		if (is_prime[i] && is_prime[(i+1)/2]) {c[i] = c[i-1] + 1;}
		else {c[i] = c[i-1];}
	}
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		int l, r; cin >> l >> r;
		// int c = 0;
		cout << c[r] - c[l-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 4036
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll tests;
  cin >> tests;
  while(tests--){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a < b){ Pr(0); continue; }
    if(d < b){ Pr(0); continue; }
    if(c + 1 >= b){ Pr(1); continue; }
    if(a % b > c){ Pr(0); continue; }
    if(d % b == 0){ Pr(1); continue; }
    ll g = GCD(b, d);
    if(g <= b - c - 1){ Pr(0); continue; }
    ll x = (b - a%b + g - 1) / g - 1;
    Pr(a%b + x*g <= c);
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
    string str;
    int N;
    std::ostringstream oss;
    cin >> N;
    oss << N;
    str = oss.str();
    if (str.find("7") == std::string::npos)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3588
N, M = map(int, input().split())
A = list(map(int, input().split()))

vote = []
all = 0

for j in range(N):
    all += A[j]

for i in range(N):
    if A[i] >= all / (4 * M):
        vote.append(A[i])

if len(vote) >= M:
    print("Yes")

else:
    print("No")

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	char a,b;
	cin >>a>>b;

	if(a ==b && a == 'H')
		cout << "H" << endl;
	else if(a == b && a == 'D')
		cout << "H" << endl;
	else
		cout << "D" << endl;

	return 0;
}

Measured memory_bytes: 256
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let n = read int
    let hs = reads int |> List.toArray

    let dp = Array.create n 0
    for i = 1 to n - 1 do
        if i - 2 < 0 then
            dp.[i] <- dp.[i-1] + abs (hs.[i] - hs.[i-1])
        else
            dp.[i] <- min
                (dp.[i-2] + abs (hs.[i] - hs.[i-2]))
                (dp.[i-1] + abs (hs.[i] - hs.[i-1]))

    printfn "%i" dp.[n-1]
    0

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

int w, h;
vector<vector<int> > mp;
vector<vector<int> > d;

int dfs(int x, int y){
  vector<int> dx = {1, 1, 1, 0, 0, -1, -1, -1};
  vector<int> dy = {1, 0, -1, 1, -1, 1, 0, -1};
  stack<pair<int, int> > st;
  st.push({x, y});
  d[x][y] = 1;
  while(!st.empty()){
    auto cur = st.top(); st.pop();
    REP(i, 8){
      int nx = cur.first + dx[i];
      int ny = cur.second + dy[i];
      if(nx < 0 || nx > h-1 || ny < 0 || ny > w-1) continue;
      if(mp[nx][ny] == 0 || d[nx][ny] == 1) continue;
      st.push({nx, ny});
      d[nx][ny] = 1;
    }
  }
  return 1;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> A;
  while(1){
    cin >> w >> h;
    if(w == 0 && h == 0){
      break;
    }else{
      mp.assign(h, vector<int>(w, 0));
      d.assign(h, vector<int>(w, 0));
      REP(i, h){
        REP(j, w){
          cin >> mp[i][j];
        }
      }
      int ans = 0;
      REP(i, h){
        REP(j, w){
          if(mp[i][j] == 0 || d[i][j] == 1) continue;
          ans += dfs(i, j);
        }
      }
      A.push_back(ans);
    }
  }
  for(auto i : A){
    cout << i << endl;
  }
}


Measured memory_bytes: 3180
import sys

N, M = map(int, input().split())
set_a = set([int(sys.stdin.readline()) for _ in range(M)])
MOD = 10**9 + 7

dp = [0] * (N + 1)
dp[0] = 1
dp[1] = 0 if 1 in set_a else 1
for i in range(2, N+1):
    dp[i] = 0 if i in set_a else (dp[i-1] + dp[i-2]) % MOD
ans = dp[N]
print(ans)

Measured memory_bytes: 13216
import scala.io.StdIn
import scala.annotation.tailrec

object Main extends App {

  val Array(_, quantum) = StdIn.readLine().split(" ").map(_.toInt)

  val queue = Iterator.continually(StdIn.readLine()).takeWhile(_ != null).foldLeft(Queue.empty) {
    (queue, line) => {
      line.split(" ") match {
        case Array(name: String,time: String) => queue.enqueue(Process(name, time.toInt))
      }
    }
  }

  @tailrec
  def loop(queue: Queue, out: Vector[Process] = Vector(), curTime: Int = 0): Vector[Process] = {
    if(queue.isEmpty) out
    else {
      val(process, nextQueue) = queue.dequeue
      if(process.time > quantum){
        loop(nextQueue.enqueue(process.copy(time = process.time - quantum)), out, curTime + quantum)
      }else{
        loop(nextQueue,
          out :+ process.copy(time = curTime + process.time),
          curTime + process.time)
      }
    }
  }

  println(loop(queue).mkString("\n"))
}

class Queue private(val in: List[Process], val out: List[Process]){
  def enqueue(elem: Process) = new Queue(elem :: in, out)

  def dequeue: (Process, Queue) = out match {
    case Nil if !in.isEmpty => val rev = in.reverse ; (rev.head, new Queue(Nil, rev.tail))
    case x :: xs            => (x, new Queue(in, xs))
    case _                  => throw new NoSuchElementException("dequeue on empty queue")
  }

  def isEmpty: Boolean = in.isEmpty && out.isEmpty

  override def toString() = in.toString
}

object Queue {
  def empty: Queue = new Queue(Nil, Nil)
  def apply(xs: Process*): Queue = new Queue(Nil, xs.toList)
}

case class Process(name: String, time: Int){
  override def toString(): String = s"$name $time"
}

Measured memory_bytes: 155996
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        while ((n > 0) && (m > 0)){
            int[] x = new int[m];
            for (int i = 0; i < n; i++){
                for (int j = 0; j < m; j++){
                    int a = sc.nextInt();
                    if (a == 1){
                        x[j]++;
                    }
                }
            }
            for (int i = 0; i < m; i++){
                int max = -1;
                int tmp = 0;
                for (int j = 0; j < m; j++){
                    if (x[j] > max){
                        max = x[j];
                        tmp = j + 1;
                    }
                }
                System.out.print(tmp);
                x[tmp - 1] = -2;
                if (i < m - 1){
                    System.out.print(" ");
                }
                else {
                    System.out.println();
                }
            }
            n = sc.nextInt();
            m = sc.nextInt();
        }
    }
}


Measured memory_bytes: 81140
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var p="";
var max=0;
for(var i=0;i<Arr.length;i++){
   var arr=Arr[i].split(" ").map(Number);
   if(arr.length==1){
      if(i==0)continue;
      console.log(p+" "+max);
      if(arr[0]=="0")break;
      p="";
      max=0;
   }else{
      var sum=arr[1]+arr[2];
      if(max<=sum){
         max=sum;
         p=arr[0];
       }
   }
}

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

int main()
{
  int N;
  int a;
  int flag = 0;

  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    if (a % 2 == 0)
    {
      if ((a % 3 != 0) && (a % 5 != 0))
        flag = 1;
    }
  }
  if (!flag)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
}

Measured memory_bytes: 256