akhauriyash/Code-Regression huggingface dataset:
use proconio::input;
use std::io::Write;

pub trait Echo {
    fn echo(&self);
    fn echo_b(&self, out: &mut std::io::Stdout) -> Result<(), std::io::Error>;
}

macro_rules! impl_echo {
    ($($t:ty),*) => {
        $(
            impl Echo for $t {
                fn echo(&self){
                    self.echo_b(&mut std::io::stdout()).unwrap();
                }

                fn echo_b(&self, out: &mut std::io::Stdout) -> Result<(), std::io::Error>{
                    writeln!(out,"{}", &self)?;
                    Ok(())
                }
            }
        )*
    };
}

macro_rules! impl_echo_f {
    ($($t:ty),*) => {
        $(
            impl Echo for $t {
                fn echo(&self){
                    self.echo_b(&mut std::io::stdout()).unwrap();
                }

                fn echo_b(&self, out: &mut std::io::Stdout) -> Result<(), std::io::Error>{
                    writeln!(out,"{:.12}", &self)?;
                    Ok(())
                }
            }
        )*
    };
}

impl_echo!(u8, u16, u32, u64, u128, usize);
impl_echo!(i8, i16, i32, i64, i128, isize);
impl_echo!(&str, String, char);
impl_echo_f!(f32, f64);

impl<T: Echo> Echo for Vec<T> {
    fn echo(&self) {
        self.echo_b(&mut std::io::stdout()).unwrap();
    }
    fn echo_b(&self, out: &mut std::io::Stdout) -> Result<(), std::io::Error> {
        for i in self {
            i.echo_b(out).unwrap();
        }
        Ok(())
    }
}

fn main() {
    input! {
        n: usize,
    };
    let res = if n % 1000 == 0 { 0 } else { 1000 - n % 1000 };
    res.echo();
}

#[allow(dead_code)]
fn yn(i: bool) {
    if i {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int x[200000],y[200000],t[200000];
signed main(){
	int n;scanf("%d",&n);
	rep(i,n){
		scanf("%d%d%d",&t[i+1],&x[i+1],&y[i+1]);
	}
	rep(i,n){
		int d=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
		if(!(d<=t[i+1]-t[i]&&(t[i+1]-t[i]-d)%2==0)){
			puts("No");return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 1408
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i32 = read();
    println!("{}", if n < 1000 { "ABC" } else { "ABD" });
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,int(n)+1)
#define RREP(i,n) RFOR(i,0,n)
#define RREPS(i,n) RFOR(i,1,int(n)+1)
#define ALL(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl
 
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
#define MOD (1000000007)
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void pvp(T a, T b) { for (T i = a; i != b; ++i) cout << "(" << i->first << ", " << i->second << ") "; cout << endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int in() { int x; scanf("%d", &x); return x; }
 
using ll = long long;
#define int ll
 
//**********

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

    int n, m, l, q, s, t;
    cin >> n >> m >> l;

    vector<vector<int>> G(301, vector<int>(301, INF));

    REP(i,301){
        G[0][0] = 0;
    }

    REP(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        G[a-1][b-1] = c;
        G[b-1][a-1] = c;
    };

    REP(k,n){
        REP(i,n){
            REP(j,n){
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }

    vector<vector<int>> H(301, vector<int>(301, INF));

    REP(i, n){REP(j, n){
        if (G[i][j] <= l) {
            H[i][j] = 1;
        }
    }}

    REP(k, n){
        REP(i,n){
            REP(j,n){
                H[i][j] = min(H[i][j], H[i][k] + H[k][j]);
            }
        }
    }

    cin >> q;
    REP(i, q){
        cin >> s >> t;
        if (H[s-1][t-1] == INF) {
            cout << -1 << endl;
        } else {
            cout << H[s-1][t-1] - 1 << endl;
        }   
    };

    return 0;
    
};


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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> ar(n);
  for(int i=0;i<n;i++)
    cin>>ar[i];
  sort(ar.begin(),ar.end());
  vector<int> dp(k+1,-1);
  for(int i=0;i<ar[0];i++)
    dp[i]=false;
  for(int i=ar[0];i<=k;i++)
  {
    bool win=false;
    for(int j=0;j<n;j++)
    {
      int next=i-ar[j];
      if(next>=0)
      {
        if(dp[next]==false)
          win=true;
      }
    }
    dp[i]=win;
  }
  if(dp[k])
    cout<<"First";
  else
    cout<<"Second";
}

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

int osiri(int ketsu){
    int ass=0;
    while (ketsu > 0){
            ass += ketsu % 10;
            ketsu /= 10;
        }
    return ass;
}

int main(){
    int N,A,B,ans=0,mem;
    cin >> N >> A >> B;
    for (int i = 1;i <= N;i++){
        if (A <= osiri(i) && osiri(i) <= B){
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
lfl={}
l1=0
l2=0
n=int(input().strip())
a=list(map(int, input().split()))

for i in range(n):
    if a[i] in lfl:
        lfl[a[i]]+=1
    else:
        lfl[a[i]]=1
    if lfl[a[i]]>=2:
        if l1<a[i]:
            l2=l1
            l1=a[i]
            lfl[a[i]]-=2
        elif l2<a[i]:
            l2=a[i]
            lfl[a[i]]-=2
print(l1*l2)



Measured memory_bytes: 18316
#include <iostream>
#include<string>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int  found=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='C') found=1;
        if(found&&s[i]=='F') {found=2; break;}
    }
    if(found==2) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#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>
#include <functional>
#include <chrono>
 
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;
const double EPS = 1e-9;
 
const int MAX = 1e5 + 10;
int N, M;
vector<int> graph[MAX];
set<int> se;
 
bool check(deque<int> &path) {
    //for (int e : path) cerr<<e+1<<" ";cerr<<endl;
    const int st = *path.begin();
    const int ed = *path.rbegin();
    for (int e : graph[st]) {
        if (se.count(e) == 0) return false;
    }
    for (int e : graph[ed]) {
        if (se.count(e) == 0) return false;
    }
    return true;
}
 
int main() {
    scanf("%d%d", &N, &M);
    for (int i = 0; i < M; ++i) {
        int a, b; scanf("%d%d", &a, &b);
        --a;--b;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }
    deque<int> deq;
    deq.emplace_back(N / 2);
    se.insert(N / 2);
    auto func = [&](int now, bool back) {
        for (int e : graph[now]) {
            if (se.count(e) == 0) {
                if (back) deq.emplace_back(e);
                else deq.emplace_front(e);;
                se.insert(e);
                return true;
            }
        }
        return false;
    };
    while (!check(deq)) {
        if (func(*deq.rbegin(), true)) continue;
        if (func(*deq.begin(), false)) continue;
        assert(false);
    }
    printf("%d\n", deq.size());
    for (int e : deq) {
        printf("%d ", e + 1);
    }puts("");
}

Measured memory_bytes: 11392
def getLargestSquare(H, W, G):
    maxWidth = 0
    dp = [[None] * W for i in range(H)]
    for i in range(H):
        for j in range(W):
            dp[i][j] = (G[i][j] + 1) % 2
            maxWidth |= dp[i][j]

    for i in range(1, H):
        for j in range(1, W):
            if G[i][j] == 1:
                dp[i][j] = 0
            else:
                dp[i][j] = min(dp[i-1][j-1], dp[i-1][j], dp[i][j-1]) + 1
                maxWidth = max(maxWidth, dp[i][j])

    return maxWidth * maxWidth


if __name__ == '__main__':
    h, w = [int(v) for v in input().split()]
    c = []
    for i in range(h):
        c.append([int(v) for v in input().split()])

    print(getLargestSquare(h, w, c))


Measured memory_bytes: 55836
var
	S:Array[-200000..300000]of Char;
	ins:String;
	i,Q,d,id,F,l,r:Longint;
	c:Char;
begin
	readln(ins);
	for i:=1 to length(ins)do S[i]:=ins[i];
	r:=length(ins);
	l:=1;
	read(Q);
	for i:=1 to Q do begin
		read(id);
		if id=1 then d:=1-d else begin
			read(F,c,c);
			if (d+F)mod 2=0 then begin
				inc(r);
				S[r]:=c;
			end else begin
				dec(l);
				S[l]:=c;
			end;
		end;
	end;
	if d=0 then for i:=l to r do write(S[i])else for i:=r downto l do write(S[i]);
	writeln;
end.


Measured memory_bytes: 768
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("36");
            WillReturn.Add("24");
            //GREATER
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("850");
            WillReturn.Add("3777");
            //LESS
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("9720246");
            WillReturn.Add("22516266");
            //LESS
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("123456789012345678901234567890");
            WillReturn.Add("234567890123456789012345678901");
            //LESS
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string A = InputList[0];
        string B = InputList[1];

        int MaxLength = Math.Max(A.Length, B.Length);
        A = A.PadLeft(MaxLength, '0');
        B = B.PadLeft(MaxLength, '0');

        if (A.CompareTo(B) > 0) Console.WriteLine("GREATER");
        if (A.CompareTo(B) == 0) Console.WriteLine("EQUAL");
        if (A.CompareTo(B) < 0) Console.WriteLine("LESS");
       
    }
}


Measured memory_bytes: 13280
#define _GLIBCXX_DEBUG

#include "iostream"
#include "vector"
#include "algorithm"
#include "string"

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    
    string s;
    cin >> s;

    
    ll n = s.size();
    REP(i,n-1){
        if(s[i]=='B' && s[i+1]=='C'){
            s[i] = 'D';
            s[i+1] = 'd';
        }
    }
    
    ll ans=0, cnta=0;
    REP(i,n){
        if(s[i]=='B'||s[i]=='C'){
            cnta=0;
        }
        else if(s[i]=='A'){
            cnta++;
        }
        else if(s[i]=='D'){
            ans += cnta;
        }
    }
    cout << ans << endl;

    /*
    ll count=0;
    while(1){
        ll itr = s.find("ABC");
        if(itr == string::npos){
            break;
        }
        //cout << itr << endl;
        s.replace(itr,3,"BCA");
        count++;
    }
    cout << count << endl;
    */
    return 0;
}

Measured memory_bytes: 3712
void main()
{
    dchar[] s = readln.chomp.to!(dchar[]);

    reverse(s);
    string[] words = ["dream", "dreamer", "erase", "eraser"];
    dchar[][] rev = new dchar[][](4);
    foreach (i, x; words)
    {
        rev[i] = x.to!(dchar[]);
        reverse(rev[i]);
    }

    long index;
    bool ok = true;
    while (index < s.length)
    {
        bool check;
        foreach (x; rev)
        {
            long len = x.length;
            if (index + len > s.length) continue;

            if (s[index..index+len] == x)
            {
                check = true;
                index += len;
                break;
            }
        }

        if (!check)
        {
            ok = false;
            break;
        }
    }

    writeln(ok ? "YES" : "NO");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 2712
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int a = rint;
	(a * a).writeln;
	
	
}


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

using namespace std;

#define int long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pb emplace_back
#define pf emplace_front
#define mp make_pair
#define ld long double
#define all(x) (x).begin(), (x).end()

const int MAXN = 1e5 + 9;

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int x, y;
    cin >> x >> y;
    int ans = (8 - min(4ll, x) - min(4ll, y)) * 100000;
    if (x == 1 && y == 1)
        ans += 400000;
    cout << ans;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,k;
  unsigned long count=0;
  unsigned long abs_s=0;
  unsigned long abs_t=0, abs_u=0;
  scanf("%d %d", &n, &k);
  
  for(int a=1;a<n+1;a++){
    if((2*a)%k==0){
      abs_s++;
      if(a%k==0)
        abs_t++;
    }
  }

  abs_u = abs_s - abs_t;

  count = abs_s + (abs_u*(abs_u-1))*3 + (abs_t*(abs_t-1))*3 + (abs_u*(abs_u-1)*(abs_u-2)) + (abs_t*(abs_t-1)*(abs_t-2));

  printf("%lu\n", count);

  return 0;
}

Measured memory_bytes: 128
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int m,f,r;

	while (1){
		cin>>m>>f>>r;
		if (m==-1&&f==-1&&r==-1)break;
		if (m==-1||f==-1)cout<<"F"<<endl;
		else if ((m+f)>=80)cout<<"A"<<endl;
		else if ((m+f)>=65&&(m+f)<80)cout<<"B"<<endl;
		else if ((m+f)>=50&&(m+f)<65)cout<<"C"<<endl;
		else if ((m+f)>=30&&(m+f)<50&&r>=50)cout<<"C"<<endl;
		else if ((m+f)>=30&&(m+f)<50&&r<50)cout<<"D"<<endl;
		else if ((m+f)<30)cout<<"F"<<endl;
	}


	return 0;
}

Measured memory_bytes: 3080
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(long long int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); vect(A);for(long long i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;
    x = x % p;
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll a,ll p)
{
   return power(a,p-2,p);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
int main()
{
    // #ifndef ONLINE_JUDGE
    //    freopen ("input.txt" , "r" , stdin);
	// 	// freopen ("OUTPUT.txt" , "w" , stdout);
	// #endif
    fio;
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        ll n;
        cin>>n;
        ll ans=0;
        forin(i,1,n)
        {
            forin(j,1,n)
            {
                forin(k,1,n)
                {
                    ll num=__gcd(i,j);
                    ans+=__gcd(k,num);
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;

int main() {
  int X,Y,A,B,C;
  cin>>X>>Y>>A>>B>>C;
  vector<int>p(A),q(B),r(C);
  vector<int>ans;
  for(int i=0;i<A;i++){cin>>p[i];}
  for(int i=0;i<B;i++){cin>>q[i];}
  for(int i=0;i<C;i++){cin>>r[i];ans.push_back(r[i]);}
  sort(p.rbegin(),p.rend());
  sort(q.rbegin(),q.rend());
  for(int i=0;i<X;i++){ans.push_back(p[i]);}
  for(int i=0;i<Y;i++){ans.push_back(q[i]);}
  sort(ans.rbegin(),ans.rend());
  int64_t sum=0;
  for(int i=0;i<X+Y;i++){
    sum+=ans[i];
  }
  cout<<sum<<endl;
  return 0;  
}

Measured memory_bytes: 6460
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n; cin >> n;

    bool ans = false;
    RANGE(i, 1, 9) RANGE(j, 1, 9) {
        if (n == i * j) {
            ans = true;
        }
    }
    cout << Yes(ans) << endl;
    
}

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

int n, a[200005];
long long ans;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        if (a[i] < a[i-1]){
            ans += a[i-1]-a[i];
            a[i] = a[i-1];
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 4408
from collections import Counter
n = int(input())
list = list(map(int,input().split()))
list_o = list[::2]
list_e = list[1::2]

cnt_o = Counter(list_e).most_common(2)
cnt_e = Counter(list_o).most_common(2)

if cnt_o[0][0] == cnt_e[0][0]:
    if len(cnt_o) == 1 and len(cnt_e) == 1:
        print(int(n/2))
    else:
        print(n-cnt_o[0][1]-max(cnt_o[1][1],cnt_e[1][1]))
else:
    print(n-cnt_o[0][1]-cnt_e[0][1])

Measured memory_bytes: 15972
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        int n = stdIn.nextInt();
        int c = stdIn.nextInt();

        int[] v = new int[n];
        int[] w = new int[n];
        for(int i=0; i<n; i++){
            v[i] = stdIn.nextInt();
            w[i] = stdIn.nextInt();
        }

        int[][] dp = new int[n+1][c+1];
        
        for(int i=1; i<=n; i++){
            for(int j=1; j<=c; j++){
                if(j < w[i-1]){
                    dp[i][j] = dp[i-1][j];
                }else{
                    int a = v[i-1] + dp[i-1][j-w[i-1]];
                    int b = dp[i-1][j];
                    dp[i][j] = (a > b) ? a : b;
                }
            }
        }

        System.out.println(dp[n][c]);
    }
}


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

int main(){
	string s;
	long long k;
	cin >> s >> k;

	for(int i=0; i<k; i++){
		if(s[i] != '1' || i==k-1){
			cout << s[i] << endl;
			break;
		}
	}
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int n;
    cin >> n;
    
   int res = 0;
    res = mod_pow(10,n);
    res = (res - mod_pow(9,n))%MOD;
    res = (res - mod_pow(9,n))%MOD;
    res = (res + mod_pow(8,n))%MOD;
    
    res%=MOD;
    if(res < 0) res+=MOD;
    cout <<res;
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

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

string S;


int main(void) {
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (((i+1) % 2) == 0) {
			if (!(S[i] == 'L' || S[i] == 'U' || S[i] == 'D')) {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (!(S[i] == 'R' || S[i] == 'U' || S[i] == 'D')) {
				cout << "No" << endl;
				return 0;
			}
		}

	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
def setHeapDown_max(heap, pos):
    targetkey = heap[pos]
    while pos > 0:
        parentpos = (pos - 1) >> 1
        parent = heap[parentpos]
        if parent < targetkey:
            heap[pos] = parent
            pos = parentpos
            continue
        break
    heap[pos] = targetkey

def setHeapUp_max(heap, pos):
    endpos = len(heap)
    targetkey = heap[pos]
    childpos = 2*pos + 1
    while childpos < endpos:
        rightpos = childpos + 1
        if rightpos < endpos and not heap[rightpos] < heap[childpos]:
            childpos = rightpos
        heap[pos] = heap[childpos]
        pos = childpos
        childpos = 2*pos + 1
    heap[pos] = targetkey
    setHeapDown_max(heap, pos)

def heapPush_max(heap, key):
    heap.append(key)
    setHeapDown_max(heap, len(heap) - 1)

def heapPop_max(heap):
    lastkey = heap.pop()
    if heap:
        returnkey = heap[0]
        heap[0] = lastkey
        setHeapUp_max(heap, 0)
        return returnkey
    return lastkey


import sys

S = []

ans = []

for x in sys.stdin.readlines():
    if x[0] == 'i':
        k = int(x[7:])
        heapPush_max(S, k)
    elif x[1] == 'x':
        ans.append(heapPop_max(S))
    else:
        pass

print(*ans, sep = '\n')

Measured memory_bytes: 208372
#include <stdio.h>

int main(void)
{
	int g;
	char b[3];
	int data[4];
	int i;
	
	for (i = 0; i < 4; i++){
		data[i] = 0;
	}
	
	while (scanf("%d,%s", &g, &b) != EOF){
		if (b[0] == 'A' && b[1] == 'B'){
			data[2]++;
		}
		else if (b[0] == 'A'){
			data[0]++;
		}
		else if (b[0] == 'B'){
			data[1]++;
		}
		else {
			data[3]++;
		}
	}
	
	for (i = 0; i < 4; i++){
		printf("%d\n", data[i]);
	}
	
	return (0);
}

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

int main(){
  int n;
  int count = 0;
  cin>>n;
  for(int i=0;i<n;i++){
    int num;
    bool flag = false;
    cin>>num;
    for(int j = 2;j<=sqrt(num);j++){
      if(num%j==0){
	flag = true;
	break;
      }
    }
    if(!flag) count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstring>
 
using namespace std;
 
typedef long long LL;
 
const int N = 5000 + 5;
const int M = 200 + 5;
const int INF = 1000000000 + 5;
 
int n, m;
int x[N];
int a[M];
LL tag[N << 2];
LL maxv[N << 2];
vector<pair<int, int> > st[M];
 
void modify(int t, int l, int r, int a, int b, LL v)
{
    if (b < l || r < a) return;
    if (a <= l && r <= b) {
        tag[t] += v;
        maxv[t] += v;
        return;
    }
    if (tag[t]) {
        tag[t << 1] += tag[t];
        maxv[t << 1] += tag[t];
        tag[t << 1 | 1] += tag[t];
        maxv[t << 1 | 1] += tag[t];
        tag[t] = 0;
    }
    int mid = (l + r) >> 1;
    modify(t << 1, l, mid, a, b, v);
    modify(t << 1 | 1, mid + 1, r, a, b, v);
    maxv[t] = max(maxv[t << 1], maxv[t << 1 | 1]);
}
 
LL query(int t, int l, int r, int a, int b)
{
    if (b < l || r < a) return 0;
    if (a <= l && r <= b) {
        return maxv[t];
    }
    if (tag[t]) {
        tag[t << 1] += tag[t];
        maxv[t << 1] += tag[t];
        tag[t << 1 | 1] += tag[t];
        maxv[t << 1 | 1] += tag[t];
        tag[t] = 0;
    }
    int mid = (l + r) >> 1;
    return max(query(t << 1, l, mid, a, b), query(t << 1 | 1, mid + 1, r, a, b));
}
 
void solve()
{
    cin >> n >> m;
    for(int i = 0; i < n - 1; ++ i) {
        scanf("%d", x + i);
    }
 
    long long ans = 0;
    for(int j = 0; j < m; ++ j) {
        st[j].push_back(make_pair(INF, -1));
    }
 
    for(int i = 0; i < n; ++ i) {
        long long tmp = 0;
        for(int j = 0; j < m; ++ j) {
            scanf("%d", a + j);
            tmp += a[j];
        }
        ans = max(ans, tmp);
 
        for(int j = 0; j < m; ++ j) {
              while (a[j] >= st[j].back().first) {
                    int r = st[j].back().second;
                    int v = st[j].back().first;
                    st[j].pop_back();
                    int l = st[j].back().second + 1;
                    modify(1, 0, n - 1, l, r, -v);
               }
            modify(1, 0, n - 1, st[j].back().second + 1, i, a[j]);
            st[j].push_back(make_pair(a[j], i));
        }
 
        if (i > 0) {
            modify(1, 0, n - 1, 0, i - 1, -x[i - 1]);
        }
        ans = max(ans, query(1, 0, n - 1, 0, i));
    }
    cout << ans << endl;
}
 
int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d;
string n;
int main()
{
	cin>>a;
	if(a==0){cout<<0<<endl;return 0;}
	while(a)
	{
		n=char(abs(a%(-2))+'0')+n;
		a=(a-abs(a%(-2))) / (-2);
	}
	cout<<n<<endl;
}

Measured memory_bytes: 256
N = int(input())
c = input()

R = 0
W = 0
for ci in c:
    if ci == 'R':
        R += 1

ans = max(R,W)
for ci in c:
    if ci == 'R':
        R -= 1
    else:
        W += 1
    tmp = max(R,W)
    ans = min(ans,tmp)

print(ans)

Measured memory_bytes: 9356
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int a;
    cin>>a;
    vector<string> vec(a);
    for(int i=0;i<a;i++){
        cin>>vec.at(i);
    }
    sort(vec.begin(),vec.end());
    if(a==1){
        cout<<1<<endl;
        return 0;
    }
    int x=0;
    for(int i=0;i<a-1;i++){
        if(vec.at(i)!=vec.at(i+1)){
            x++;
        }
    }
    cout<<x+1<<endl;
}

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

int main(){

    int N;
    cin >> N;
    string S;
    cin >> S;

    int count = 0;
    rep(i,N-2){
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C'){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    ll mi = LINF;
    int odd = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        if(a<0) {
            odd = ~odd;
        }
        a = abs(a);
        ans += a;
        mi = min(mi, a);
    }

    if(odd) {
        ans -= 2*mi;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 1000000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    map<string,ll>m;
    ll q;cin>>q;
    while(q--){
        ll a;string key;cin>>a>>key;
        if(a==0){
            ll x;cin>>x;
            m[key]=x;
            //cout<<m[key]<<endl;
        }
        else if(a==1){
            cout<<m[key]<<endl;
        }
        else if(a==2){
            m[key]=0;
        }
        else{
        }
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































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


long long b(long long a,long long n){
    if(n==0){
        return 1;
    }else if(n%2==0){
        return b(a*a,n/2);
    }else{
        return a*b(a,n-1);
    }
}

int main() {
long long n,p,m=0,c=0;
cin>>n>>p;
for(int i=0;i<n;i++){
    int a;
    cin>>a;
    if(a%2==1){
        m++;
    }
}
if(m==0&&p==1){
    cout<<0<<endl;
}else if(m==0&&p==0){
    cout<<b(2,n)<<endl;
}else{
    cout<<b(2,n-1)<<endl;
}

	return 0;
}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

ll power(ll a, ll b){
    if(b<1) return 1;
    if(b==1) return a;
    if(b%2!=0) return a * power(a,b-1) % MOD;
    ll t = power(a,b/2) % MOD;
    return t * t % MOD;
}

int main(void){

    int N; cin>>N;
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin>>A[i];
    }

    ll ans = 0;
    for (int i = 0; i < 60; ++i) {
        ll cnt=0;
        for (int j = 0; j < N; ++j) {
            if(A[j]>>i & 1) cnt++; //1を数える
        }
        ll now = cnt * (N-cnt) % MOD;
        now *= power(2,i);
        ans += now;  // ans += now % MODだとダメ
        ans %= MOD;
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 2560
#include <algorithm>
#include <cstdio>

bool keta_odd(int n) {
	int keta = 0;
	for(int i = 1; i <= n; i *= 10) {
		keta++;
	}
	return keta % 2;
}

int main() {
	int n;
	scanf("%d", &n);

	int result = 0;

	for(int i = 1; i <= n; i++) {
		result += keta_odd(i) ? 1 : 0;
	}

	printf("%d\n", result);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

typedef long long ll;

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

int main(){
    int N,M;

    cin >> N >> M;

    if(N == M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    


    return 0;

}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int q; cin >> q;
    for(int i=0; i<q; i++){
        int k; cin >> k;
        int l = 0, r = 0;
        ll d = 0, m = 0, dm = 0, dmc = 0;
        while(r < n){
            if(r - l == k){
                l++;
                if(s[l-1] == 'D'){
                    dm -= m; d--;
                }
                else if(s[l-1] == 'M'){
                    m--;
                }
            }
            r++;
            if(s[r-1] == 'D'){
                d++;
            }
            else if(s[r-1] == 'M'){
                m++;
                dm += d;
            }
            else if(s[r-1] == 'C'){
                dmc += dm;
            }
        }
        cout << dmc << endl;
    }
    return 0;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  ll X,A,B;
  cin >> X;
  rep2(a,1,120) {
    rep(b,a) {
      if(a*a*a*a*a-b*b*b*b*b==X) {
        A=a,B=b;
        break;
      } else if(a*a*a*a*a+b*b*b*b*b==X) {
        A=a,B=-b;
        break;
      }
    }
  }
  cout << A << ' ' << B << endl;
}

Measured memory_bytes: 3596
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define int long long
#define endl '\n'

const int N = 200005;
int n, m;
#define double long double
priority_queue<double> pq;

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for(int i = 1 ; i <= n ; i ++){
		double x;
		cin >> x;
		pq.push(x);
	}
	while(m --){
		double u = pq.top();
		pq.pop();
		u *= 0.5;
		pq.push(u);
	}
	int sum = 0;
	while(pq.size()){
		sum += ((int)pq.top());
		pq.pop();
	}
	cout << sum;
}


Measured memory_bytes: 2420
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N = int(input())

A = []
for i in range(1,10):
    for j in range(1,10):
        A.append(i*j)

if N in A:
    print("Yes")
else:
    print("No")

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

int main(){
  string query,strconv,str,p;
  int q,a,b;

  cin>>str;
  cin>>q;
  
  for(int i=0; i<q; i++){
    cin>>query;
    cin>>a>>b;
    if(query == "print"){
      cout<<str.substr(a,b-a+1)<<endl;
    }else if(query == "reverse"){
      reverse(str.begin()+a,str.begin()+b+1);
    }else if(query == "replace"){
      cin>>p;
      str.replace(a,b-a+1,p);
    }
  }
}




Measured memory_bytes: 3192
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cassert>
#include<map>
#include<set>
#include<deque>
using namespace std;

#define sz(x) (int)(x.size())
#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define fk(a, b) for(int k=a;k<b;++k)
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
/////////////////

void print(vector<int> &v){
	//fi(0, sz(v)) cerr << v[i] << " ";
	//cerr << endl;

}

int cnt(vector<int> &ans){
	int n = sz(ans);
	int m = (1<<n);
	int ret = 0;
	fj(1, m){
		vector<int> v;
		fi(0, n){
			if((1<<i)&j){
				v.pb(ans[i]);
			}
		}
		if(sz(v) % 2 == 1) continue;
		int t = sz(v) / 2;
		bool ok = true;
		fk(0, t) if(v[k] != v[k + t]) ok = false;
		if(ok) ++ret, print(v);
	}
	return ret;
}

vector<int> mul(vector<int> v, int &c){
	vector<int> ret;
	ret.pb(c);
	fi(0, sz(v)) ret.pb(v[i]);
	ret.pb(c);
	++c;
	return ret;
}

vector<int> add(vector<int> v, int &c){
	vector<int> ret;

	fi(0, sz(v)-1){
		ret.pb(v[i]);
	}
	ret.pb(c);
	if(sz(v)) ret.pb(v.back());
	ret.pb(c);
	++c;

	return ret;
}

void solve(){
	ll n;
	cin >> n;
	vector<int> b;
	ll v = n +1;
	int c = 1;
	while(v){
		b.pb(v&1);
		v /= 2;
	}
	deque<int> ans1, ans2;
	for(int i=b.size()-1;i>=0;--i){
		if(sz(ans2)){
			ans1.push_front(c);
			ans2.push_front(c);
			++c;
		}
		if(b[i]){
			if(i == sz(b) - 1){
				ans1.pb(c);
				ans2.pb(c+1);
				c += 2;
			}else{
				ans1.push_front(c);
				ans2.push_back(c);
				++c;
			}
		}
	}
	vector<int> ans;
	while(sz(ans1)){
		ans.pb(ans1.front());
		ans1.pop_front();
	}

	while(sz(ans2)){
		ans.pb(ans2.front());
		ans2.pop_front();
	}

	printf("%d\n",sz(ans));
	fi(0, sz(ans)) printf("%d ",ans[i]);
	///cerr << cnt(ans) << endl;
}

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

	solve();

	return 0;
}

Measured memory_bytes: 764
use std::io::BufRead;

fn main() {
  let stdin = std::io::stdin();
  let mut buf = String::new();
  stdin.read_line(&mut buf).unwrap();

  let mut ite1 = buf.trim().split_whitespace()
    .map(|x| x.parse::<usize>().unwrap());

  let r = ite1.next().unwrap();
  let c = ite1.next().unwrap();

  let sums = &mut vec![0; c + 1];

  for line in stdin.lock().lines() {
    let line = line.unwrap();

    let vec = line.trim().split_whitespace()
      .map(|x| x.parse().unwrap())
      .collect::<Vec<i32>>();

    for i in 0..c {
      sums[i] += vec[i];
      print!("{} ", vec[i]);
    }

    let sum = vec.iter().sum::<i32>();
    sums[c] += sum;
    println!("{}", sum);
  }

  println!("{}", sums.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(" "));
}


Measured memory_bytes: 5036
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int M,N,X;
  cin >> N >> M >> X;
  
  vector<vector<int>> data(N,vector<int>(M + 1));
  
  for(int i = 0 ; i < N ; i++){
    cin >> data.at(i).at(0);
    for(int j = 1 ; j <= M ; j++){
      cin >> data.at(i).at(j);
    }
  }
  
  int min = 2147483647;
  
  for(int i = 0 ; i < (1 << N) ; i++){
    vector<int> sum(M + 1,0);
    for(int j = 0 ; j < N ; j++){
      if((i & (1 << j)) != 0){
        for(int k = 0 ; k <= M ; k++){
          sum.at(k) += data.at(j).at(k);
        }
      }
      bool flag = true;
      for(int k = 1 ; k <= M ; k++){
        if(sum.at(k) < X){
          flag = false;
          break;
        }
      }
      if(flag){
        if(min > sum.at(0)){
          min = sum.at(0);
        }
      }
    }
  }
  
  if(min == 2147483647){
    cout << -1 << endl;
  }else{
    cout << min << endl;
  }
}

Measured memory_bytes: 3628
import sys


def fast_input():
    return sys.stdin.readline()[:-1]

def solve(masus: str):
    masu_list = map(int, list(masus))
    bdama_count = 0
    for masu in masu_list:
        if masu == 1:
            bdama_count += 1
    return bdama_count

def main():
    result = solve(fast_input())
    print(result)

main()


Measured memory_bytes: 9068
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
int INF=2e+9;
int main(){
	int Q;
	scan(Q);
	rep(i,Q){
		ll A,B;
		scan(A);scan(B);
		ll small=min(A,B);
		ll big=max(A,B);
		if(small+1>=big){
			prin(2*small-2);
		}
		else{
			ll C=(int)sqrt(small*big);
			if(C*C==small*big) prin(2*C-3);
			else if(C*(C+1)>=small*big) prin(2*C-2);
			else prin(2*C-1);
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
    unsigned int a, b;
    while (cin >> a >> b)
    {
        int r = 1;
        unsigned int g = 1, l = 1;
        if (a < b)
        {
            unsigned int _a = a, _b = b;
            while (_b % _a != 0)
            {
                r = _b % _a;
                _b = _a;
                _a = r;
            }
            g = _a;
            a = a / g;
            b = b / g;
            l = g * a * b;
        }
        else if (b < a)
        {
            unsigned int _a = a, _b = b;
            while (_a % _b != 0)
            {
                r = _a % _b;
                _a = _b;
                _b = r;
            }
            g = _b;
            a = a / g;
            b = b / g;
            l = g * a * b;
        }
        cout << g << ' ' << l << endl;
    }
}



Measured memory_bytes: 3000
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=100,O=1000000007;
bool num[N];
int f[N][2][3];//[u avail][v avail]
int pw3[N];
inline void gmath(int n){
	pw3[0]=1;
	for(int i=1;i<=n;i++){
		pw3[i]=(lint)pw3[i-1]*3%O;
	}
}
int main(){
	lint n=next_num<lint>();
	int sh=0;
	memset(num,0,sizeof(num));
	for(;n;num[sh]=n&1,sh++,n>>=1);
	gmath(sh);
	memset(f,0,sizeof(f));
	f[sh][0][0]=1;
	for(int i=sh-1;i>=0;i--){
		for(int a=0;a<2;a++){//u avail
			for(int b=0;b<3;b++){//v avail
				int F=f[i+1][a][b];
				if(F==0)continue;
				int ra=(a<<1)|num[i],rb=(b<<1)|num[i];
				for(int c=0;c<=ra&&c<=1;c++){
					if(c==1){
						int fa=min(1,ra-1),fb=min(2,rb-1);
						if(fa>=0&&fb>=0){
							(f[i][fa][fb]+=F)%=O;
						}
					}else for(int d=0,td=min(rb,2);d<=td;d+=2){
						int fa=min(1,ra),fb=min(2,rb-d);
						(f[i][fa][fb]+=F)%=O;
					}
				}
			}
		}
	}
	lint ans=0;
	for(int a=0;a<2;a++){
		for(int b=0;b<3;b++){
			ans+=f[0][a][b];
		}
	}
	printf("%lld\n",ans%O);
	return 0;
}

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

int main()
{
	int K;

	cin >> K;

	if (K % 2 == 0) {
		cout << (K / 2) * (K / 2) << endl;
	}

	else if (K % 2 == 1) {
		cout << ((K + 1) / 2)*((K - 1) / 2) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a[]={1,3,5,7,8,10,12},b[]={4,6,9,11},c[]={2};
	set<int> ast(a,a+7),bst(b,b+4),cst(c,c+1);
	int x,y;
	cin>>x>>y;
	if(ast.count(x)==1&&ast.count(y)==1)cout<<"Yes"<<endl;
	else if(bst.count(x)==1&&bst.count(y)==1)cout<<"Yes"<<endl;
	else if(cst.count(x)==1&&cst.count(y)==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 256