akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    long long w, h, x, y;
    cin >> w >> h >> x >> y;
    int maxv = 0;
    if (2 * x == w && 2 * y == h)
    {
        maxv = 1;
    }

    double ans = (double)(w * h / 2.0);
    printf("%.9lf %d\n ", ans, maxv);
    //cout << ans << " " << maxv << endl;
}

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

using namespace std;

void solve()
{
	int n;
	cin >> n;
	vector< vector<int> > a(n + 1, vector<int>(n + 1));
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= n; ++j)
		{
			cin >> a[i][j];
		}
	}
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= n; ++j)
		{
			a[i][j] += a[i][j - 1];
		}
	}

	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= n; ++j)
		{
			a[j][i] += a[j - 1][i];
		}
	}
	
	int max_val = -100000000;
	for(int i = 0; i < n; ++i)
	{
		for(int j = 0; j < n; ++j)
		{
			for(int k = i + 1; k <= n; ++k)
			{
				for(int l = j + 1; l <= n; ++l)
				{
					max_val = max(max_val, a[i][j] - a[i][l] - a[k][j] + a[k][l]);
				}
			}
		}
	}
	cout << max_val << endl;
}

int main()
{
	solve();
	return(0);
}

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

ll ifpower(ll n){
    ll s = log10(n);
    if (pow(10, s) == n){
        return true;
    } else {
        return false;
    }
}
int main(){
    ll n;
    cin>>n;
    if(ifpower(n)== true){
        cout<<10<<endl;
    } else {
        ll ans = 0;
        while(n != 0){
            int a = n % 10;
            ans += a;
            n -= a;
            n = n/10;
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 512
n,k=map(int,input().split())
l=[0]*(10**5+1)
for i in range(n):
  a,b=map(int,input().split())
  l[a]+=b
sm=0
for i in range(1,10**5+1):
  sm+=l[i]

  if sm>=k:
    print(i)
    break

Measured memory_bytes: 11864
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0); 
int k,n;
int a[1000];
int ans;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n >> k;
    rep1(i,0,n){
        cin >> a[i];
    }
    sort(a,a+n);
    rep1(i,0,k) ans += a[i];
    cout << ans;
	return 0;
}


Measured memory_bytes: 3652
using System.Collections.Generic;
using System.Linq;
using System;
class Program
{
    static void Main()
    {
        string line = Console.ReadLine();
        string[] strs = line.Split(' ');
        int[] nums = new int[3];
        for (int i = 0; i < 3; i++)
        {
            nums[i] = int.Parse(strs[i]);
        }
        int distanceA = Math.Abs(nums[0] - nums[1]);
        int distanceB = Math.Abs(nums[0] - nums[2]);
        if (distanceA < distanceB)
        {
            Console.WriteLine("A");
        }
        else
        {
            Console.WriteLine("B");
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
long long int lcm(long long int x, long long int y){
  return x*y/gcd(x, y);
}
long long int factorial(long long int x){
  return x==0 ? 1 : x*factorial(x-1);
}
int main(){
  int i, j, n, ans=0;
  cin >> n;
  int p[n];
  for(i=0; i<n; i++)
    cin >> p[i];
  for(i=1; i<n-1; i++)
    if((p[i]<p[i+1]&&p[i]>p[i-1])||(p[i]>p[i+1]&&p[i]<p[i-1]))
      ans++;
  cout << ans;
  return 0;
}

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


int main()
{
  int n, k;
  map<char, int> mp;
  string t;
  cin >> n >> k >> mp['s'] >> mp['p'] >> mp['r'] >> t;
  vector<bool> win(n);
  int ans = 0;
  rep(i, n)
  {
    if (i >= k && t[i] == t[i-k] && win[i-k])
      win[i] = false;
    else
    {
      win[i] = true;
      ans += mp[t[i]];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b
  
def solve():
    N = int(single_input())
    ab = 0
    startB, endA, both = set(), set(), set()
    for i in range(N):
        s = str(single_input())
        for j in range(len(s) - 1):
            if s[j:j+2] == "AB": ab += 1
        if s[0] == "B" and s[-1] == "A": both |= {i}
        elif s[0] == "B": startB |= {i}
        elif s[-1] == "A": endA |= {i}

        
    ab += max(len(both) - 1, 0)
    if len(startB) == 0 and len(endA) == 0: print(ab)
    else:
        single = min(len(startB), len(endA))
        if len(both) > 0: single += 1
        ab += single
        print(ab)
    
    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 4204
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 401
ll f[N][N], s[N][N];
int a[N], n;
int main() {
    memset(f, 0x3f, sizeof(f));
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        f[i][i] = 0, s[i][i] = a[i];
    }
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++) s[i][j] = s[i][j - 1] + a[j];
    for (int len = 1; len < n; len++) {
        for (int i = 1; i + len <= n; i++) {
            int j = i + len;
            for (int k = i; k < j; k++)
                f[i][j] = min(f[i][j], f[i][k] + f[k + 1][j] + s[i][j]);
        }
    }
    printf("%lld\n", f[1][n]);
    return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;

ll powmod(ll x,ll y,ll mod){
    map<ll, ll> Z;
    Z[0] = 1;
    Z[1] = x;
    ll nowy = 1;
    ll nowx = x;
    while (nowy*2<y){
        nowy *= 2;
        nowx = nowx * nowx % mod;
        Z[nowy] = nowx;
    }
    ll nowz = nowy/2;
    while (nowy<y){
        if (nowz+nowy<=y){
            nowy += nowz;
            nowx = (nowx * Z[nowz]) % mod;
        }
        nowz /= 2;
    }
    return nowx;
}


int main(){
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    vector<ll> kaijo(H + W+1, 0);
    kaijo[0] = 1;
    repf(i,1,H+W+1){
        kaijo[i] = (kaijo[i-1] * i) % mod;
    }
    vector<ll> gyaku(H + W + 1, 0);
    gyaku[H + W] = powmod(kaijo[H + W], mod - 2, mod);
    for (int i = H + W; i > 0;i--){
        gyaku[i - 1] = (gyaku[i] * i) % mod;
    }
    /*
    rep(i,H+W+1){
        cout << kaijo[i] << " ";
    }
    cout << endl;

    rep(i, H + W + 1)
    {
        cout << gyaku[i] << " ";
    }
    cout << endl;
     */
    ll ans = 0;
    repf(i,B,W){
        //cout << ans << endl;
        ll res = 0;
        res = kaijo[i + H - A - 1];
        res = (res * gyaku[i]) % mod;
        res = (res * gyaku[H - A - 1]) % mod;
        res = (res * kaijo[W - i - 1 + A - 1]) % mod;
        res = (res * gyaku[W - i - 1]) % mod;
        res = (res * gyaku[A - 1]) % mod;
        ans = (ans + res) % mod;
    }
    cout << ans << endl;

}


Measured memory_bytes: 3328
/*
* Author: Anmol Choudhary
*/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int ll
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
													 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1e9+7;
const ll maxn = 1000005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
   ll res = 1;
   //x = x % mod;
   while (y > 0)
   {
       if (y & 1)
            res = (res*x);// %mod;
       y = y>>1;
       x = (x*x);// %mod;
   }
   return res;
}
set<int>s;
vector<int>f(int n){
    vector<int>v;
    v.pb(n);
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){
            v.pb(i);
            if(i!=n/i) v.pb(n/i);
        }
    }
    return v;
}
void solve()
{
    int n;
    cin>>n;
    if(n==2){
        cout<<1;
        return;
    }
    s.in(n-1);
    for(int i=2;i<=sqrt(n-1);i++){
        if((n-1)%i==0){
            s.in(i);
            if(i!=(n-1)/i) s.in((n-1)/i);
        }
    }
    vector<int>v=f(n);
    for(auto x:v){
        int z=n;
        while(z%x==0){
            z/=x;
        }
        if(z%x==1) s.in(x); 
    }
    cout<<s.si;
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 384
/*
  AOJ 1503

 */
#include <stdio.h>
// product of prime numbers under 1500 + 2
char u1500pp[]="100011775713705647342085876224360975961797385167350897112376838062839491706403647724797055114806863470526629265119013875729405872094348125336381177862315327337756031471587052331292418383036726372482033490351693487501409230172344128596112472095563271632363268545398961225854310999688208619313591547489806687667965084046501989049434026219938309572724551027466561881176834038780124568086124532342939117388224911695272555071630768591659766497862348377588582570253697963217670223561610427535259257647559986077636129283752115320063847932948216884266137873300503611682909412640192452523004992140524801473407384694287272469624328179700053211532";

int primes1500[]={
2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499 };

main()
{
  int n;
  int i,j;
  while(EOF != scanf("%d",&n))
    {
      printf("%s\n",u1500pp);
      for(i=0;i<n;i++)
	{
	  //printf("%d\n",i);
	  {
	    for(j=0;j<sizeof(primes1500)/sizeof(int);j++)
	      if(((i + 2) % primes1500[j]) == 0)
		{
		  printf("%d\n",primes1500[j]);
		  break;
		}
	  }
	}
    }
  return(0);
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  ll n;
  cin >> n;
 
  ll aij;
  vector<queue<ll>> a(n);
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < n - 1; j++) {
      cin >> aij;
      a[i].push(aij - 1);
    }
  }

  ll games_max = n * (n - 1) / 2;
  ll games = 0;
  ll days = 0;

  queue<ll> q, q_next;
  for (ll i = 0; i < n; i++) q_next.push(i);

  while (!q_next.empty()) {
    // cout << "day" << endl;

    vector<bool> done(n, false);
    q.swap(q_next);
    queue<ll>().swap(q_next);

    while (!q.empty()) {
      ll i = q.front(); q.pop();
      ll j = a[i].front();

      if (done[i] || a[i].empty()) continue;
      if (done[j] || a[j].empty()) continue;

      if (a[j].front() == i) {
        // cout << i << " " << j << endl;

        done[i] = true;
        done[j] = true;

        a[i].pop();
        a[j].pop();

        if (!a[i].empty()) q_next.push(i);
        if (!a[j].empty()) q_next.push(j);
        games++;
      }
    }
    days++;
  }
 
  if (games == games_max) {
    cout << days << endl;
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 8960
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
using namespace std;

int dp_search(int x, vector<int> w, vector<int> v) {
    int dp[x + 1];
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;

    for (int i = 0; i < w.size(); i++) {
        for (int j = 0; j <= x; j++) {
            if (j + w[i] > x || dp[j] < 0) continue;
            dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
        }
    }

    int best_val = -1e9;
    for (int i = 0; i <= x; i++) {
        if (dp[i] < 0) continue;
        best_val = max(best_val, x - i + dp[i]);
    }

    return best_val;
}

int main() {
    int n, d, x;
    cin >> n >> d >> x;
    vector<vector<int>> p(d, vector<int>(n));
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < n; j++) {
            cin >> p[i][j];
        }
    }

    for (int i = 1; i < d; i++) {
        x = dp_search(x, p[i-1], p[i]);
    }
    cout << x << endl;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    string s;
    cin >> n >> s;
    if(n&1) cout << "No";
    else {
        bool ok = true;
        for(int i = 0; i < n / 2; i++) {
            if(s[i] != s[i + n / 2]) {
                ok = false;
                break;
            }
        }
        if(ok) cout << "Yes";
        else cout << "No";
    }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int x;
    cin >> x;
    cout << 3*x*x;
}

Measured memory_bytes: 256
/*
ACL Beginner Contest - C - Connect Cities
https://atcoder.jp/contests/abl/tasks/abl_c
*/

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

#include <atcoder/dsu>
using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

double EPS=1e-9;
int INF=1000000005;
long long INFF=1000000000000000005ll;
double PI=acos(-1);
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 };
const ll MOD = 1000000007;

ll sum() { return 0; }
template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }

#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define OUT(x) cout << x << endl
#define OUTH(x) cout << x << " "
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a))
#define EACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define MAX(a, b) a=max(a, b)
#define MIN(a, b) a=min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define what_is(x) cerr << #x << " is " << x << endl;


// AC - 62 ms
// without using ACL
void solve() {
	int n,m,a,b;
    const int mxN=2e5;
    vvi adj(mxN);
	vi vis(mxN),ans;
    cin >> n >> m;
    REP(i,m){
    	cin >> a >> b;
    	--a,--b;
    	adj[a].pb(b);
    	adj[b].pb(a);
	}
	function<void(int)> dfs = [&](int u){
	  vis[u]=1;
	  EACH(v, adj[u]) if(!vis[v]) dfs(v);
	};
	REP(i,n){
		if(!vis[i]){
			ans.pb(i+1);
			dfs(i);
		}
	}
	int sz = ans.size();
	OUT(sz-1);
}

// with ACL
void solve2() {
	int n,m,a,b;
    cin >> n >> m;
    dsu d = dsu(n);
    int ans = n;
    REP(i,m){
    	cin >> a >> b;
    	--a,--b;
    	if(!d.same(a,b)){
    		d.merge(a,b);
    		ans--;
		}
	}
	OUT(ans-1);
}

int main()
{
    FAST_INP;
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt","r", stdin);
//    freopen("output.txt","w", stdout);
//    #endif

//    int tc; cin >> tc;
//    TC(tc) solve();
	// solve();
	solve2();
    return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

string S;
// vector<int> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> S;
  // A.resize(N);
  // for (int i = 0; i < N; i++) {
  //   int tmp;
  //   cin >> tmp;
  //   A[i] = tmp;
  // }

  for (int i = 0; i < S.size(); i++) {
    cout << 'x';
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long N,K,S;
  cin>>N>>K>>S;
  int x=0;
  vector<long> a(N);


  for(int i=0;i<K;i++){
    a[i]=S;
  }
  int high=1000000000, low=1;
  int p=0;
  int mid;
  while(high-low>1){
    mid = (low+high)/2;

    if(mid!=S &&S%mid!=0) {
      p=mid;
      break;

  }
      low=mid;
}
  if(low==1000000000){
    high=1000000000, low=1;
    p=0;
    mid=1000000000/2;
    while(high-low>1){
      mid = (low+high)/2;
      if(mid!=S&& S&mid!=0) {
        p=mid;
        break;

    }
      high=mid;
  }
  }
  for(int i=K;i<N;i++){
    a[i]=p;
  }
  for(int i=0;i<N;i++){
    if(i!=N-1)cout<<a[i]<<" ";
    else cout<<a[i]<<endl;
  }

}


Measured memory_bytes: 2048
use std::io;
use std::io::prelude::*;

fn main() {
    let scan = io::stdin();
    for line in scan.lock().lines() {
        let mut c: u32 = 0;
        let uline = line.unwrap();
        let vec: Vec<&str> = uline.split_whitespace().collect(); 
        let n:i32 = vec[0].parse().unwrap_or(0);
        let x:i32 = vec[1].parse().unwrap_or(0);
        if n == 0 && x == 0 {
            break;
        }
        for i in 1..x {
            for j in i+1..x {
                let k:i32 = x - i - j;
                if j >= k || k > n {
                    continue;
                } else {
                    c += 1;
                }
            }
        }
        println!("{}", c);
    }
}



Measured memory_bytes: 5032
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    LL q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    LL qq = 8 * q;
    LL hh = 4 * h;
    LL ss = 2 * s;
    VL v{qq, hh, ss, d};
    SORT(v);
    LL ans = (n / 2) * v[0];
    n %= 2;
    v = VL{qq / 2, hh / 2, ss / 2};
    SORT(v);
    ans += n * v[0];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

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

    if(N % 2 == 1){
        cout << 0 << endl;
        return 0;
    }

    N /= 2;

    ll ans = 0;
    ll div = 5;
    for(int i = 1; i <= 60; i++){
        if(div > N) break;
        ans += N / div;
        div *= 5;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      (int)1e9+7
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;

int main(){
	int a;
	string s;
	cin>>a>>s;
	
	if(a>=3200) cout<<s<<endl;
	else cout<<"red"<<endl;
	return 0;
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main(){
    int N;cin>>N;
    set<int> s;
    REP(i,N){
        int d;cin>>d;
        s.insert(d);
    }
    int ans=0;
    for(auto itr=s.begin();itr!=s.end();++itr)ans++;
    cout<<ans;
}



Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
    if(ch=='A') return 1;
    else if(ch=='C') return 2;
    else if(ch=='G') return 3;
    else if(ch=='T') return 4;
    else return 0;
}
long long getKey(char str[]){
    long long sum = 0, p = 1, i;
    for(i=0;i<strlen(str);i++){
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}
int h1(int key){
    return key%M;
}
int h2(int key){
    return 1+(key%(M-1));
}
int find(char str[]){
    long long key, i, h;
    key = getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key)) % M;
        if(strcmp(H[h],str)==0) return 1;
        else if(strlen(H[h])==0) return 0;
    }
    return 0;
}
int insert(char str[]){
    long long key, i, h;
    key=getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key)) % M;
        if(strcmp(H[h],str)==0) return 1;
        else if(strlen(H[h])==0){
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}

int main(void){
    int i, n, h;
    char str[L], com[9];
    for(i=0;i<n;i++) H[i][0]='\0';
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%s %s", com, str);
        if(com[0] == 'i'){
            insert(str);
        }else{
            if(find(str)){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 16928
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
string s;

int calc(char c){
    int ret = 0;
    string t = s;
    while(count(t.begin(), t.end(), t[0]) != t.size()){
        ret++;
        string new_t;
        for(int i = 0 ; i + 1 < (int)t.size() ; i++){
            if(t[i] == c || t[i + 1] == c) new_t += c;
            else new_t += t[i];
        }
        t = new_t;
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    n = s.size();
    int ans = 1e9;
    for(char c = 'a' ; c <= 'z' ; c++){
        ans = min(ans, calc(c));
    }
    cout << ans << endl;
}


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

using namespace std;

int main()
{
    int N, W;
    cin>>N>>W;
    vector<int> w(N), v(N);
    for (int i=0; i<N; i++)
        cin>>w[i]>>v[i];
    vector<vector<int>> T(N, vector<int>(100001, 1000000001));
    T[0][0] = 0;
    T[0][v[0]] = w[0];
    for (int i=1; i<N; i++)
        for (int j=0; j<=100000; j++)
        {
            T[i][j] = min(T[i][j], T[i-1][j]);
            if (j+v[i]<=100000)
                T[i][j+v[i]] = min(T[i][j+v[i]], T[i-1][j]+w[i]);
        }
    int ans = 0;
    for (int i=100000; i>=0; i--)
        if (T[N-1][i] <= W)
        {
            cout<<i<<endl;
            break;
        }
}


Measured memory_bytes: 39808
#include <stdio.h>

int main() {
  int X;
  scanf("%d", &X);
  
  if (X == 3) {
    printf("YES");
  } else if (X == 5) {
    printf("YES");
  } else if (X == 7) {
    printf("YES");
  } else {
    printf("NO");
  }
  
  return 0;
  
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>

int main() {
	int k, act, p1, x1, x2;
	bool carry = false, first;
	std::cin >> k;
		if (k <= 12) std::cout << k << '\n';
		else {
			act = 12;
			std::string s = "12";
			while (act < k) {
				p1 = s.size() - 2;

				first = true;
				while (p1 >= 0) {
					if (carry) {
						carry = false;
						while (p1 >= 0 && s[p1] == '9') --p1;
						if (p1 >= 0) {
							s[p1] = char(s[p1] + 1);
							for (int i = p1 + 1; i < s.size(); ++i) s[i] = char(std::max(int('0'), s[p1] - (i - p1)));
						}
						else {
							s = "1" + s;
							for (int i = 1; i < s.size(); ++i) s[i] = '0';
						}

					--p1;
					}
					else {
						if (first) {
							first = false;
							x2 = s[p1+1] - '0' + 1;
						}
						else x2 = s[p1+1] - '0';
						x1 = s[p1] - '0';
						if (x1 == 9 && x2 == 10) carry = true;
						else if (x2 - x1 <= 1) s[p1+1] = char('0' + x2);
						else {
							++x1;
							s[p1] = char('0' + x1);
							for (int i = p1+1; i < s.size(); ++i) s[i] = char(std::max(int('0'), s[p1] - (i - p1)));
						}

						--p1;
					}
				}
				if (carry) {
					carry = false;
					s = "1" + s;
					for (int i = 1; i < s.size(); ++i) s[i] = '0';
				}

			++act;
			}

			std::cout << s << '\n';
		}
return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	for(int m,c,n;scanf("%d%d%d",&m,&c,&n),m;){
		queue<int> Q[100];
		rep(i,n){
			int sz; scanf("%d",&sz);
			rep(j,sz){
				int a; scanf("%d",&a);
				Q[i].push(a);
			}
		}

		int ans=0;
		deque<int> dai[10];
		while(1){
			bool end=true;
			rep(i,n) if(!Q[i].empty()) {
				end=false;

				// 本を取る
				int book=Q[i].front(); Q[i].pop();
				int pos=m;
				rep(j,m) if(count(dai[j].begin(),dai[j].end(),book)>0) {
					pos=j;
					break;
				}
				if(pos<m){
					dai[pos].erase(find(dai[pos].begin(),dai[pos].end(),book));
				}
				ans+=pos+1;

				// 本を置く
				if(dai[0].size()<c){
					dai[0].push_back(book);
					ans+=1;
				}
				else{
					// step 1
					int pos2=m;
					for(int j=1;j<m;j++) if(dai[j].size()<c) {
						pos2=j;
						break;
					}
					if(pos2<m){
						dai[pos2].push_back(book);
					}
					ans+=pos2+1;

					// step 2
					int sub=dai[0].front(); dai[0].pop_front();
					ans++;

					// step 3
					int pos3=m;
					for(int j=1;j<m;j++) if(dai[j].size()<c) {
						pos3=j;
						break;
					}
					if(pos3<m){
						dai[pos3].push_back(sub);
					}
					ans+=pos3+1;

					// step 4
					if(pos2<m){
						dai[pos2].erase(find(dai[pos2].begin(),dai[pos2].end(),book));
					}
					ans+=pos2+1;

					// step 5
					dai[0].push_back(book);
					ans++;
				}
			}
			if(end) break;
		}

		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 1132
H, W = map(int, input().split())
Smin = 10**5 * 10**5
for i in range(1, H):
    S1 = i * W
    S2 = (H-i) * (W//2)
    S3 = (H-i) * (W-W//2)
    Smin = min(Smin, max(S1, S2, S3)-min(S1, S2, S3))
    S2 = (H-i)//2 * W
    S3 = ((H-i)-(H-i)//2) * W
    Smin = min(Smin, max(S1, S2, S3)-min(S1, S2, S3))
for i in range(1, W):
    S1 = i * H
    S2 = (W-i) * (H//2)
    S3 = (W-i) * (H-H//2)
    Smin = min(Smin, max(S1, S2, S3)-min(S1, S2, S3))
    S2 = (W-i)//2 * H
    S3 = ((W-i)-(W-i)//2) * H
    Smin = min(Smin, max(S1, S2, S3)-min(S1, S2, S3))
print(Smin)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	string S; cin >> S;
	int zero = 0, one = 0;
	for(int i = 0; i < S.size(); ++i){
		if(S[i] == '0') ++zero;
		if(S[i] == '1') ++one;
	}
	cout << min(zero, one) * 2 << endl;
	//cerr << zero << ' ' << one << endl;
}


Measured memory_bytes: 512
from scipy.sparse import*
(n,m),*t=[map(int,t.split())for t in open(0)]
a,b,c=zip(*[(i,j+n-1,1)for i,(*t,)in enumerate(t)for j in t[1:]])
print('YNEOS'[1in csgraph.connected_components(csr_matrix(((c,(a,b))),[n+m]*2))[1][:n]::2])

Measured memory_bytes: 61164
n,a,b=gets.split.map &:to_i
s=gets.chop.chars
x,y=0,0
(0...n).map{|i|
  p=false
  p=(x+y<a+b)?(x+=1;true):false if s[i]=='a'
  p=(x+y<a+b and y<b)?(y+=1;true):false if s[i]=='b'
  puts p ? 'Yes':'No'
}

Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

map<ll, ll> primeFactor(ll n) {
  map<ll, ll> res;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}

int main() {
  ll n;
  cin >> n;
  auto pf = primeFactor(n);
  ll ans = 0;
  for(auto v : pf) {
    ll e = v.second;
    ll cnt = 1;
    while(e >= cnt) {
      ans++;
      e -= cnt;
      cnt++;
    }
  }
  cout << ans << endl;
}

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

int main(){
  int a,b,c;
  cin>>a>>b;
  if(a==0 ||b==0){
    c=0;
  }
  else if(b<10){
    c=a*10+b;
  }
  else if(b<100){
    c=a*100+b;
  }
  else if(b==100){
    c=a*1000+b;  
  }
  bool ad=false;
  for(int i=1;i<=1000;i++){
    if(i*i==c){
      ad=true;
    }
  }
  if(ad) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
    
  


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt(), m = scanner.nextInt();
		int[] counts = new int[n];
		Arrays.fill(counts, 0);
		for (int i = 0; i < m; i++) {
			counts[scanner.nextInt()-1]++;
			counts[scanner.nextInt()-1]++;
		}
		for (int i = 0; i < counts.length; i++) {
			System.out.println(counts[i]);
		}
		
		
		scanner.close();
	}
}

Measured memory_bytes: 21972
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        System.out.println(X+Y/2);
    }
}

Measured memory_bytes: 21460
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var K = one[1];
  var mod = 998244353;
  var dp = new Array(N).fill(0);
  var ruiseki = new Array(N).fill(0);
  dp[0] = 1;
  ruiseki[0] = 1;
  var list = new Array(K);
  for(var i = 0; i < K; i++){
    var tmp = nextIntArray();
    list[i] = {
      L : tmp[0],
      R : tmp[1]
    };
  }
  for(var i = 1; i < N; i++){
    for(var j = 0; j < K; j++){
      var check =  list[j];
      if(i - check.L < 0){
        continue;
      }
      if(check.L == check.R){
        dp[i] += dp[i - check.L];
      }else if(i - check.R - 1 < 0){
        dp[i] += ruiseki[i - check.L];
      }else{
        dp[i] += ruiseki[i - check.L] - ruiseki[i - check.R - 1];
      }
      if(dp[i] < 0){
        dp[i] += mod;
      }
      dp[i] %= mod;
    }
    ruiseki[i] = dp[i] + ruiseki[i - 1];
    ruiseki[i] %= mod;
  }
  myout(dp[N - 1]);
}


Measured memory_bytes: 36828
n = int(input())
t, a = map(int, input().split())
for i in range(n-1):
  ti, ai = map(int,input().split())
  ma=max(t, a)
  if ti==1 and ai ==1:
    t=ma
    a=ma
  else:
    temp=[0]*7
    temp[1] = t%ti
    if temp[1]!=0:
      temp[1] = ti-temp[1]
    temp[2] = t+temp[1]       #takahashiをt1で割れる最小に
    temp[3] = (temp[2]//ti)*ai #その時のaoki
    
    temp[4] = a%ai
    if temp[4] != 0:
      temp[4] = ai-temp[4]
    temp[5] = a+temp[4]
    temp[6] = (temp[5]//ai)*ti
    #print(temp[1:])
    if temp[3]-a<0 and temp[4]+temp[6]-t>=0:
      a=temp[5]
      t=temp[6]
    elif temp[1]+temp[3]-a>=0 and temp[6]-t<0:
      a=temp[3]
      t=temp[2]
    elif temp[1]+temp[3]-a<temp[4]+temp[6]-t:
      a=temp[3]
      t=temp[2]
    else:
      a=temp[5]
      t=temp[6]
  #print("t "+str(t)+" a "+str(a))
#print(" ")
print(int(a+t))
    

Measured memory_bytes: 9284
#include <stdio.h>
void shellSort(int*,int);
void insertionSort(int*,int,int);
int cnt = 0;

int main(){
  int i,A[1000000],n;
    scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  
  shellSort(A,n);
  for(i = 0; i < n; i++){
    printf("%d\n",A[i]);
  }
  
  return 0;
  
}

void insertionSort(int* A, int n, int g){
  int i,j,k;
  for(i = g; i < n; i++){
    k = A[i];
    j = i - g;
    while(j >= 0 && A[j] > k){
      A[j+g] = A[j];
      j = j - g;
      cnt++;
      A[j+g] = k;
    }
  }
}

void shellSort(int* A, int n){
  int m=1,i,G[1000000];
  G[0] = 1;
  for(i = 0;;i++){
    G[i+1] = 3*G[i] + 1;
    if(G[i+1] > n) break;
    m++;
  }
  
  for(i = m-1; i >= 0; i--){
    insertionSort(A,n,G[i]);
  }
  
  printf("%d\n",m);
  for(i = m-1; i > 0; i--){
    printf("%d ",G[i]);
  }
  
  printf("%d\n",G[i]);
  printf("%d\n",cnt);
  
}




Measured memory_bytes: 5640
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long  t,r=1,r1=0,r2=0,k=0,a,b,c=0,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    vector<tuple<string,int,
           int>>mp;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>s1;
    if(s1[s1.size()-1]=='s')
    {
        cout<<s1+"es"<<endl;
    }
    else
    {
        cout<<s1+"s"<<endl;
    }

}


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

using namespace std;

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  } else cout << "consonant" << endl;
}

Measured memory_bytes: 256
A,B=map(int,input().strip().split())

e=[]
t=[]
for n in range(2000):
	if n*8//100==A:
		e.append(n)
for m in range(2000):
	if m//10==B and m in e:
		t.append(m)

if t==[]:
	print(-1)
else:
	print(t[0])

		

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;

    vector<ll>a(n, 0);
    REP(i, n) cin >> a[i];

    vector<ll>ct(3, 0);

    REP(i, n){
        if (a[i]%2 != 0){// not a multiple of 2{}
            ct[0]++;
        }
        else if (a[i]%4 == 0){
            ct[2]++;
        } // is a multiple of 4

        else{ // is a multiple of 2 but not 4
            ct[1]++;
        }
    }

    if (ct[0] > ct[2]+1){
        cout << "No" << endl;
        return 0;
    }
    if (ct[0] == ct[2]+1 && ct[1] != 0){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 4012
#include<iostream>
#include<vector>
#include<queue>

using namespace std;
int n, v[10009];
pair<int,int> R[10009];
vector<int> r[10009];
priority_queue<int> c;

void solve(){
    priority_queue<pair<int,int> > Q;
    int mx=0, sm=0;
    int mx_r_ind=-1;
    for(int i=0;i<n;i++){
        R[i]=make_pair(r[i].size(), i);
        if(R[i].first > mx){
            mx=R[i].first;
            mx_r_ind=i;
        }
    }
    
    Q.push(R[mx_r_ind]);
    while(!Q.empty()){
        int tmp_ind =Q.top().second;Q.pop();
        v[tmp_ind]=c.top();c.pop();
        for(int i=0;i<r[tmp_ind].size();i++){
            if(v[r[tmp_ind][i]]==0){
                Q.push(R[r[tmp_ind][i]]);
            }
            else{
                sm += min(v[r[tmp_ind][i]], v[tmp_ind]);
            }
        }
    }

    cout << sm << endl;

    for(int i=0;i<n;i++){
        cout << v[i] << ' ';
    }
}

int main(){
    cin >> n;
    int tmpa, tmpb, tmpc;
    for(int i=0;i<n-1;i++){
        cin >> tmpa >> tmpb;
        tmpa--;tmpb--;
        r[tmpa].push_back(tmpb);
        r[tmpb].push_back(tmpa);
    }
    for(int i=0;i<n;i++){
        cin >> tmpc;
        c.push(tmpc);
    }

    solve();
}

Measured memory_bytes: 1280
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;



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

	int X, Y, Z, x, y, z;
	cin >> X >> Y >> Z >> x >> y >> z >> K;
	vector<long long int>v(K);
	vector<long long int>w(K);
	for (int i = 0; i < X; i++) {
		v[abs(x - i) % K]++;
	}
	for (int i = 0; i < Y; i++) {
		w[abs(y - i) % K]++;
	}
	vector<long long int>nv(K, 0);
	for (int i = 0; i < K; i++) {
		for (int j = 0; j < K; j++) {
			nv[(i + j) % K] += v[i] * w[j];
		}
	}
	v = nv;
	for (auto &i : nv)i = 0;
	for (auto &i : w)i = 0;
	for (int i = 0; i < Z; i++) {
		w[abs(z - i) % K]++;
	}
	for (int i = 0; i < K; i++) {
		for (int j = 0; j < K; j++) {
			nv[(i + j) % K] += v[i] * w[j];
		}
	}
	v = nv;
	for (int i = 0; i < K; i++) {
		if (i)cout << " ";
		cout << v[i];
	}
	cout << endl;
}


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

double dp[1 << 15][15];
int prv[1 << 15][15], c[15], d[15], v[15];
int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d%d%d", &c[i], &d[i], &v[i]), v[i] *= 20;
	fill(dp[0], dp[1 << n], INF);
	rep(i, n)dp[1 << i][i] = 0;
	rep(i, 1 << n)rep(j, n) {
		int w = 0;
		rep(k, n) {
			if (i >> k & 1)w += v[k];
		}
		rep(k, n) {
			if (i >> k & 1)continue;
			double cost = dp[i][j] + abs(d[j] - d[k]) / (2000. / (70 + w));
			if (dp[i | 1 << k][k] > cost) {
				dp[i | 1 << k][k] = cost; prv[i | 1 << k][k] = j;
			}
		}
	}
	int Min = INF, id;
	rep(i, n) {
		if (Min > dp[(1 << n) - 1][i]) {
			Min = dp[(1 << n) - 1][i]; id = i;
		}
	}
	vector<int>v;
	int s = (1 << n) - 1;
	while (s) {
		v.push_back(c[id]);
		int k = id;
		id = prv[s][id];
		s ^= 1 << k;
	}
	reverse(v.begin(), v.end());
	rep(i, v.size()) {
		if (i)printf(" ");
		printf("%d", v[i]);
	}
	printf("\n");
}

Measured memory_bytes: 9012
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define infll 0x3f3f3f3f3f3f3f3fll
using namespace std;
typedef long long ll;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int N, D, A[1005][1005], k; ll ans = infll;
int f[2005][2005], g[2005][2005], sf[2005][2005], sg[2005][2005]; 

inline bool check(int a[][2005], const int &lx, const int &ly, const int &rx, const int &ry){
	if(lx > rx || ly > ry) return 1;
	return a[rx][ry] - (ly ? a[rx][ly - 1] : 0) - (lx ? a[lx - 1][ry] : 0) + (lx && ly ? a[lx - 1][ly - 1] : 0)
	   == (rx - lx + 1) * (ry - ly + 1);
}
 
inline bool check(const int &x, const int &y, const int &b){
	return check(sf, x + b + 1, y + b + 1, x + D - 1, y + D - 1)
	    && check(sg, x, y + b + 1, x + D - 1, y + D - 1)
	    && check(sg, x + b + 1, y, x + D - 1, y + D - 1);
}

inline ll calc(const int &x, const int &y){
	int l = 0, r = D - 1;
	while(l < r){
		const int mid = l + r >> 1;
		if(check(x, y, mid)) r = mid; else l = mid + 1;
	}
	return k * (ll)D + l;
}
 
int main(){
	getint(N), getint(D); if(N == 1) return puts("0"), 0;
	for(register int i = 1, x, y; i <= N; i++) getint(x), getint(y), A[x % D][y % D]++;
	for(register int i = 0; i < D; i++)
		for(register int j = 0; j < D; j++) k = max(k, A[i][j]);
	k = (int)sqrt(k - 0.5);
	for(register int i = 0, F = k * k, G = k * (k + 1); i < D; i++)
		for(register int j = 0; j < D; j++){
			f[i][j] = f[i + D][j] = f[i][j + D] = f[i + D][j + D] = A[i][j] <= F;
			g[i][j] = g[i + D][j] = g[i][j + D] = g[i + D][j + D] = A[i][j] <= G;
		}
	sf[0][0] = f[0][0], sg[0][0] = g[0][0];
	for(register int i = 1; i < (D << 1); i++){
		sf[0][i] = sf[0][i - 1] + f[0][i], sg[0][i] = sg[0][i - 1] + g[0][i];
		sf[i][0] = sf[i - 1][0] + f[i][0], sg[i][0] = sg[i - 1][0] + g[i][0];
	}
	for(register int i = 1; i < (D << 1); i++)
		for(register int j = 1; j < (D << 1); j++){
			sf[i][j] = sf[i][j - 1] + sf[i - 1][j] - sf[i - 1][j - 1] + f[i][j];
			sg[i][j] = sg[i][j - 1] + sg[i - 1][j] - sg[i - 1][j - 1] + g[i][j];
		}
	for(register int i = 0; i < D; i++)
		for(register int j = 0; j < D; j++) ans = min(ans, calc(i, j));
	return printf("%lld\n", ans), 0;
}

Measured memory_bytes: 66944