akhauriyash/Code-Regression huggingface dataset:
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val x = sc.nextInt()
    val y = sc.nextInt()
    println(problem160d(n, x, y))
}

fun problem160d(n: Int, x: Int, y: Int): String {
    val routes = Array(n) { mutableListOf<Int>() }
    for (i in 0 until n - 1) {
        routes[i].add(i + 1)
        if (i in x-1..y-1) {
            routes[i + 1].add(i)
        }
    }
    routes[x - 1].add(y - 1)
    routes[y - 1].add(x - 1)

    val distances= Array(n - 1) { IntArray(n) { -1 } }
    val counts = hashMapOf<Int, Int>()

    for (i in 0 until n - 1) {
        val queue = ArrayDeque<Int>()
        queue.offer(i)
        distances[i][i] = 0

        while(!queue.isEmpty()) {
            val current = queue.poll()
            for (j in 0 until routes[current].size) {
                val next = routes[current][j]
                if (distances[i][next] != -1) continue
                distances[i][next] = distances[i][current] + 1
                queue.offer(next)
            }
        }
        distances[i] = distances[i].drop(i + 1).toIntArray()
        for (j in 0 until distances[i].size) {
            counts[distances[i][j] + 1] = (counts[distances[i][j] + 1] ?: 0) + 1
        }
    }

    val ans = Array(n - 1) { 0 }
    var cnt = 0
    for (i in counts) {
        ans[cnt] = i.value
        cnt++
    }

    return ans.joinToString("\n")
}

Measured memory_bytes: 87068
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int mat[200][200];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int r,c,n,x=1,y=1,f=0;
    cin>>r>>c>>n;
    for(int i=1; i<=n; i++)
    {
        int a;
        cin>>a;
        while(a--)
        {
            mat[x][y]=i;
            if(!f)
                y++;
            else
                y--;
            if(y>c)
            {
                x++;
                f^=1;
                y=c;
            }
            else if(y==0){
                y=1;
                x++;
                f^=1;

            }
        }
    }
    for(int i=1; i<=r; i++)
    {
        for(int j=1; j<=c; j++)
        {
            cout<<mat[i][j];
            if(j!=c)
                cout<<" ";
        }
        cout<<endl;
    }

    return 0;
}


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

bool isPerfectSquare(long double x){   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
}
int main(){
    int n;
    cin >> n;
    long long int ans=0;
    if(isPerfectSquare(n)){
        for(int i=1; i<=sqrt(n); i++){
            int j=1, count=0;
            while((i*j)<n){
                count++;
                //cout << i << " " << j << endl;
                j++;
            }
            count*=2;
            ans+=count;
        }
        ans+=1;
        ans-=n;
    }
    else{
        for(int i=1; i<sqrt(n); i++){
            int j=1, count=0;
            while((i*j)<n){
                count++;
                //cout << i << " " << j << endl; 
                j++;
            }
            ans+=count;
        }
        for(int i=n; i>sqrt(n); i--){
            int j=1, count=0;
            while((i*j)<n){
                count++;
                //cout << i << " " << j << endl;
                j++;
            }
            ans+=count;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3676
#include<stdio.h>

int main() {

  int a, b, c;
  
  scanf("%d""%d""%d", &a, &b, &c);
  
  int max = a;
  
  if(b > max)
    max = b;
    
  if(c > max)
    max = c;
    
  printf("%d", a + b + c - max);
  
  return 0;
  
}


Measured memory_bytes: 128
#include <iostream>
  #include <string>
  #include <vector>
  #include <algorithm>
  #include <utility>
  using namespace std;
  typedef long long ll;
  #define rep(i,n) for (int i=0;i < (int)(n);i++)

  int main(){
   int n,k;
   int ans;
   cin >> n >> k;
   ans=k;
   rep(i,n-1){
     ans*=(k-1);
   }
   cout << ans << endl;
    return 0;
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,m,n,o;
    scanf("%d %d %d",&a,&b,&c);
    m=a+b;
    n=b+c;
    o=c+a;
    if(m<=n && m<=o)printf("%d",m);
    else if(n<=m && n<=o)printf("%d",n);
    else if(o<=m && o<=n)printf("%d",o);
    return 0;
}


Measured memory_bytes: 256
n, m, l = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
    answer = []
    for j in range(l):
        answer.append(sum([a[i][k]*b[k][j] for k in range(m)]))
    print(*answer)
        


Measured memory_bytes: 6580
while 1:
    n, m = map(int, raw_input().split())
    if n == 0: break
    board = [input() for i in range(n)]
    pos = 0
    dice = [input() for i in range(m)]
    for i in range(m):
        pos += dice[i]
        if pos >= n - 1:
            print i + 1
            break
        pos += board[pos]
        if pos >= n - 1:
            print i + 1
            break

Measured memory_bytes: 6416
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>

namespace {
using namespace std;
using ll = long long;
using ull = unsigned long long;
}

ll N, K;
string S;

void input() {
    cin >> N >> K;
    cin >> S;
}

ll solve() {
    vector<ll> zeropos, onepos;
    if (S[0] == '0')
        zeropos.push_back(0);
    for (int i = 1; i < N; i++) {
        if (S[i-1] == '1' and S[i] == '0') {
            zeropos.push_back(i);
        } else if (S[i-1] == '0' and S[i] == '1') {
            onepos.push_back(i);
        }
    }
    if (K >= zeropos.size())
        return N;
    
    zeropos.push_back(N);
    ll pos = 0;
    ll ans = 0;
    for (int i = 0; i+K < zeropos.size(); i++) {
        ans = max(ans, zeropos[i+K] - pos);
        pos = onepos[i];
    }
    return ans;
}

int main() {
    input();
    cout << solve() << endl;
    
    return 0;
}



Measured memory_bytes: 1404
def main():
    t1,t2=map(int,input().split())
    a1,a2=map(int,input().split())
    b1,b2=map(int,input().split())
    if t1*a1+t2*a2==t1*b1+t2*b2:
        return 'infinity'
    if a1<b1:
        a1,b1=b1,a1
        a2,b2=b2,a2
    if a2>b2:
        return 0
    d1=(a1-b1)*t1
    d2=(b2-a2)*t2
    if d1>d2:
        return 0
    d=d2-d1
    if d1%d==0:
        return d1//d*2
    return d1//d*2+1
    
if __name__=='__main__':
    print(main())

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int test = 1;
    // cin >> test;
    while(test--) {
        string s;
        cin >> s;
        int res = 0;
        for(int i=0;i<s.size();i++) {
            int curr = 0;
            if(s[i]=='R') {
                while(s[i]=='R' && i<s.size()) {
                    curr++;
                    i++;
                }
            }
            res = max(res,curr); 
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 3636
using System;

namespace abc161B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int N = int.Parse(str[0]);
            int M = int.Parse(str[1]);
            long[] a = new long[N];
            str = Console.ReadLine().Split();
            for (int i = 0; i < N; i++)
            {
                a[i] = long.Parse(str[i]);
            }
            int A = 0;
            long K = 0;
            for(int i = 0; i < N; i++)
            {
                K += a[i];
            }
            for(int i = 0; i<N; i++)
            {
                if (a[i]*4*M >=  K) 
                    A += 1; 
            }
            
            if (A >= M)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13140
fn read() -> Vec<i32> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.split_whitespace().map(|x| x.parse().unwrap()).collect()
}

fn main() {
    let mut vec = read();
    vec.sort();
    println!("{}", vec[0] + vec[1])
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
void deal(int i, int j){
    while (i < j) printf("%d %d\n", i++, j--);
}
int main(){
    int n, m; scanf("%d%d", &n, &m);
    deal(1, 1 + m / 2 * 2);
    deal(1 + m / 2 * 2 + 1, 1 + m / 2 * 2 + 1 + (m - m / 2) * 2 - 1);
    return 0;
}

Measured memory_bytes: 3832
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
 
ll N,M;
vector<ll> A;
 
vector<ll> sum;
 
bool judge(ll lim){
  ll res=0;
  int itr=0;
  for(int i=N-1;i>=0;i--){
    while(itr<N&&A[i]+A[itr]>=lim){
      itr++;
    }
    res+=itr;
  }
 
  if(res>=M) return true;
  else return false;
}
 
int main(){
    cin>>N>>M;
    A.resize(N);
    rep(i,N) cin>>A[i];

    // 逆イテレータ使えば降順にソートできるってことか？
    sort(A.rbegin(),A.rend());

    sum.resize(N+1,0);
    rep(i,N) sum[i+1]=sum[i]+A[i];

    ll ok=0,ng=(A[0]*2+1)*M;
    while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        if(judge(mid)) ok=mid;
        else ng=mid;
    }

    ll ans=0;
    ll itr=0;
    ll num=0;
    for(int i=N-1;i>=0;i--){
        while(itr<N && A[i]+A[itr]>=ok) itr++;
        ans+=A[i]*itr+sum[itr];
        num+=itr;
    }
    //↓のはなんで引かないといけないんだっけ
    ans-=ok*(num-M);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1920
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
unsigned euclidean_gcd(unsigned a, unsigned b)
{
    if (a < b)
        return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long e = c * d / euclidean_gcd(c, d);
    cout << (b - a + 1) - (b / c) + ((a - 1) / c) - (b / d) + ((a - 1) / d) + (b / e) - ((a - 1) / e);
}


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

typedef long long ll;
const ll MOD = 1000000007;

using namespace std;

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

    int n, ans = 0;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    for (int i = 1; i < n - 1; i++) {
        if ((v[i] > v[i - 1] && v[i] < v[i + 1]) || (v[i - 1] > v[i] && v[i] > v[i + 1])) ans++;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
using System;
class Program
    {
        static void Main(string[] args)
        {                                           
            Console.WriteLine(new Calu().calu(long.Parse(Console.ReadLine())));
        }
        public class Calu{
            public string calu(long l){
                long L = 0;
                for(long i = 1; i <= l; i++){
                    if (i * i > l) {
                        break;
                    } else if (l % i == 0){
                        L = i;
                    }
                }
                return (l / L).ToString().Length.ToString();
            }
        }
    }

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}

template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==v.size()?"":" ");
    return os;
}


signed main(){
    int n;cin>>n;
    string s;cin>>s;
    int r=0,w=0;
    for(auto c:s){
        if(c=='R')r++;
        else w++;
    }

    string t="";
    rep(i,r)t.push_back('R');
    rep(i,w)t.push_back('W');
    int c=0;
    rep(i,n)if(s[i]!=t[i])c++;
    cout<<(c/2)<<endl;
    return 0;
}


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

long long gcd(long long a,long long b)
{
	 return (!b)?a:gcd(b,a%b);
}
int main()
{
	long long n,m;
	 map<long long ,long long>q;
	 cin>>n>>m;
	 int flag=0;
	 string s,t;
	 cin>>s;
	 cin>>t;
	/* if(n==n*m/gcd(n,m)||m==n*m/gcd(n,m))
	 cout<<"-1"<<endl;
	 else
	 cout<<n*m/gcd(n,m)<<endl;*/
	 long long l=n*m/gcd(n,m);
	 for(long long i=0;i<n;i++)
	 {
	 	 
	 	 	q[i*l/n+1]=s[i]-'a'+1;
		  
	 	 
	 }
	// cout<<endl;
	 
	 for(long long i=0;i<m;i++)
	 {
	 //	 cout<<i*l/m+1<<endl;
	 	 
	 	 	if(q[i*l/m+1]==t[i]-'a'+1||q[i*l/m+1]==0)
	 	 	continue;
	 	 	else
	 	 	{
	 	 		flag=1;
	 	 		break;
			  }
		  
	 }
	 if(flag)printf("-1");
	 else printf("%lld",l);
 } 


Measured memory_bytes: 10880
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	int n, k;
	cin >> n >> k;
	int a = (n - (k - 1)), b = (a == n) ? a : 1;
	cout << a - b << endl;
}

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;
typedef long double LD;
const int mod = 998244353;

struct mint {
    LL x;
    mint(LL x = 0): x((x % mod + mod) % mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(LL t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

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

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
}comb(200005);


int main(){
    int n, m, k;
    cin >> n >> m >> k;
    mint ans = 0;
    mint col = m;
    for (int x = n-1; x >= 0; --x) {
        mint now = col;
        now *= comb(n - 1,x);
        if (x <= k) ans += now;
        col *= m-1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6176
#include<iostream>

using namespace std;

int main(void)
{
  int x,a,b; cin>>x>>a>>b;
  int total=x-a;
  
  for(int i=0;total>0;i++){
    total-=b;
  }
  
  total==0?cout<<total<<endl:cout<<total+b<<endl;
  return 0;
}

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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)

int a, b, c, x, y, z;

int main()
{
	cin >> a >> b >> c;
	fo(t,0,10000000)
	{
		if(a&1) return 0*printf("%d",t);
		if(b&1) return 0*printf("%d",t);
		if(c&1) return 0*printf("%d",t);
		x = a/2; y = b/2; z = c/2;
		a = y + z; b = x + z; c = x + y;
	}
	printf("-1");
	return 0;
}

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

#define set fixed << setprecision(3)

int main() {
	double a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f) {
		double x = (c * e - b * f) / (a * e - b * d);
		double y = (a * f - c * d) / (a * e - b * d);
		if (abs(x) < 1e-03) x = 0;
		if (abs(y) < 1e-03) y = 0;
		cout << set << x << " " << y << endl;
	}
	return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main(void) {
  string s;
  cin >> s;
  int cnt = 0;
  rep(i,s.length()) {
    if(s[i] != s[s.length()-i-1]) {
      cnt++;
    }
  }
  cout <<  cnt/2 << endl;
  return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "abac" ].parse.expand.solve == "YES" );
	assert( [ "aba" ].parse.expand.solve == "NO" );
	assert( [ "babacccabab" ].parse.expand.solve == "YES" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	auto cs = new long[ 3 ];
	foreach( c; s )
	{
		cs[ c - 'a' ]++;
	}
	cs.sort();
	return ( cs[ 2 ] - cs[ 0 ] <= 1 ) ? "YES" : "NO";
}


Measured memory_bytes: 2968
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for (int i=(a); i<(b); i++)
#define per(i,a,b) for (int i=(b-1); i>=(a); i--)
#define de(x) cout << #x << " => " << x << endl
using namespace std;

#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;

#define pb push_back
typedef vector<int> vi;

typedef long long ll;
typedef long double ld;

const int N = 2e5 + 7;
char str[N];
///----------------------------------------------
int num[30];
int main() {
	
	///read
	scanf(" %s", str);
	int len = strlen(str);
	rep(i, 0, len) num[str[i] - 'a']++;
		
	//work
	ll ans = 1 + 1ll * (len + 1) * len / 2 - len;
	//de(ans);
	rep(i, 0, 26) {
		ans -= 1ll * num[i] * (num[i] - 1) / 2;
	}
	cout << ans;


}


Measured memory_bytes: 384
/*
██╗  ██╗ █████╗ ██████╗ ███████╗███████╗███╗   ███╗        ██╗  ██╗██╗  ██╗ █████╗ ██╗     ███████╗██████╗
██║ ██╔╝██╔══██╗██╔══██╗██╔════╝██╔════╝████╗ ████║        ██║ ██╔╝██║  ██║██╔══██╗██║     ██╔════╝██╔══██╗
█████╔╝ ███████║██████╔╝█████╗  █████╗  ██╔████╔██║        █████╔╝ ███████║███████║██║     █████╗  ██║  ██║
██╔═██╗ ██╔══██║██╔══██╗██╔══╝  ██╔══╝  ██║╚██╔╝██║        ██╔═██╗ ██╔══██║██╔══██║██║     ██╔══╝  ██║  ██║
██║  ██╗██║  ██║██║  ██║███████╗███████╗██║ ╚═╝ ██║███████╗██║  ██╗██║  ██║██║  ██║███████╗███████╗██████╔╝
╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═════╝
Believe in yourself ,( try and try and then try ), You can do it
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#define endl "\n"
#define Ceil(x,y) ((x+y-1)/y)
#define clr(arr, x) memset(arr, x, sizeof arr)
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define rt(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define OO 0x3f3f3f3f3f3f3f3fLL
const int oo = 0x3f3f3f3f, Mod = 1e9 + 7;
using namespace std;
typedef long long ll;
int dx[] { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] { 0, 0, 1, -1, 1, -1, 1, -1 };
void K_K(){
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int n, k;
vector<int>arr;
int dp[100001];
int sol(int k){
	if (~dp[k])
		return dp[k];
	dp[k] = 0;
	for (int i = 0; i < n; i++){
		if (arr[i] <= k)
			dp[k] |= !sol(k - arr[i]);
	}
	return dp[k];
}
int main(){
	K_K();
	cin >> n >> k;
	arr.resize(n);
	clr(dp, -1);
	for (auto &it : arr)
		cin >> it;
	cout << (sol(k) ? "First" : "Second");
}

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

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

    long long i,j,k,l,m,n,o,q;

    while(cin>>n)
    {
        string s;
        cin>>s;
        l=s.size();
        int x[2]= {0};
        for(i=0; i<l; i++)
        {
            if(s[i]=='R')
                x[0]++;
            else
                x[1]++;
        }
        j=0;
        for(i=0;i<l&&x[0]>0;i++){
            if(s[i]=='W'){
                j++;
                x[1]--;
                x[0]--;
            }
            if(s[i]=='R')x[0]--;
        }
        cout<<j<<endl;

    }
    return 0;
}


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

int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0;i<n;i++)
        cin >> a[i];
    sort(a.begin(),a.end());
    int m=1000000000;
    for(int i=0;i<n-k+1;i++){
        m=min(m,a[i+k-1]-a[i]);
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 640
use std::mem::swap;
use std::cmp::max;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
    n: usize,
    s: usize,
    vw: [(usize, usize); n]
    }
    let mut dp = vec![0; s + 1];
    for i in 0..n {
        let mut prev = vec![0; s + 1];
        swap(&mut prev, &mut dp);
        for j in 0..s + 1{
            let (v, w) = (vw[i].0, vw[i].1);
            if j >= w {
                dp[j] = max(prev[j], prev[j - w] + v);
            } else {
                dp[j] = prev[j];
            }
        }
    }
    let ans = dp[s];
    println!("{}", ans);
}



Measured memory_bytes: 5032
#include<stdio.h>

int main(void) {

	char date[4];

	scanf("%s", date);

	if (strcmp(date, "SUN") == 0) {
		printf("7\n");
	}
	else if (strcmp(date, "MON") == 0) {
		printf("6\n");
	}
	else if (strcmp(date, "TUE") == 0) {
		printf("5\n");
	}
	else if (strcmp(date, "WED") == 0) {
		printf("4\n");
	}
	else if (strcmp(date, "THU") == 0) {
		printf("3\n");
	}
	else if (strcmp(date, "FRI") == 0) {
		printf("2\n");
	}
	else if (strcmp(date, "SAT") == 0) {
		printf("1\n");
	}
		

	return 0;
}

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

int main() {

int n,k;
cin>>n>>k;
vector<int>vec(n);
rep(i,k)
{int d;cin>>d;
  rep(j,d)
  {int a;
   cin>>a;
   vec[a-1]++;
  }
}
int count=0;
rep(i,n)
{
  if(vec[i]==0)count++;
}
cout<<count<<endl;
}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> s(m);
    vector<int> c(m);

    rep(i,m) cin >> s[i] >> c[i]; //左からｓ番目がc
    rep(i,m){
        if(s[i] == 1 && c[i]==0 && n != 1){
            cout << "-1" << endl;
            return 0; //０以外 一番大きい位に0はこない
        }
        rep(j,m){
        if(s[i] == s[j] && c[i] != c[j]){
            cout << "-1" << endl;
            return 0;
        }//違う数字は入らない
        }
    }
    vector<int> min(n,-1);
    rep(i,m) min[s[i]-1] = c[i];

    rep(i,n){
        if(min[i] == -1){
            min[i] = 0;
        }
    }

    if(min[0] == 0 && n!= 1) min[0]++;
    rep(i,n){
        cout << min[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    int a, b;
    cin >> a >> b;
    // int x = a / 0.08, y = b / 0.1;
    // if (x > y)
    //     swap(x, y);
    for (int i = 1; i <= 10000; ++i) {
        if ((int)(i * 0.08) == a && (int)(i * 0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define N 200005
#define pi 3.14159
#define in insert
#define pb push_back
#define mp make_pair
#define F first
#define pf push_front
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res='1'; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/='2'; } return res;}
ll exp(ll x,ll y){ ll res='1'; while(y) {if(y%2) res=(res*x); x=(x*x); y/='2'; } return res;}



int main(){
    ll n,m; cin>>n>>m;
    ll a[m];
    ll sum=0;
    for(ll i=0;i<m;i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>n)
        cout<<-1;
    else cout<<n-sum;
    return 0;
}
 


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc166/abc166_d.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int X;
  cin >> X;

  // rep(i, 100) { cout << pow(i, 5) << endl; }
  ll a = 0;
  ll b = 0;
  bool ok = false;
  repi(i, -1000, 1001) {
    a = i;
    ll ai = pow(i, 5);
    repi(j, -1000, 1001) {
      b = j;
      ll bi = pow(j, 5);
      if ((ai - bi) == X) {
        ok = true;
        break;
      }
    }
    if (ok) break;
  }

  cout << a << " " << b << endl;
}

Measured memory_bytes: 4104
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = a + c - 1;
        int e = b - c + 1;
        if(d >= e){
            for (int k = a;k <= b;++k){
                System.out.println(k);
            }
        }
        else{
            for (int k = a;k <= d;++k){
                System.out.println(k);
            }
            for (int k = e;k <= b;++k){
                System.out.println(k);
            }
        }
    }
}

Measured memory_bytes: 23764
import sys

stdin = sys.stdin


def na(): return map(int, stdin.readline().split())


def ns(): return stdin.readline().strip()

def bf(es, n, start, ved):
    I = 999999999999999999
    d = [I] * n
    d[start] = 0

    for i in range(n-1):
        updated = False
        for e in es:
            if not ved[e[0]]: continue
            if not ved[e[1]]: continue
            if d[e[0]] + e[2] < d[e[1]]:
                d[e[1]] = d[e[0]] + e[2]
                updated = True
        if not updated: break
    for e in es:
        if not ved[e[0]]: continue
        if not ved[e[1]]: continue
        if d[e[0]] + e[2] < d[e[1]]:
            return None
    return d


n,m = na()
es = []

for i in range(m):
    a,b,c = na()
    es.append([a-1,b-1,-c])

ig = [[] for _ in range(n)]
for e in es:
    ig[e[1]].append(e)

ved = [False] * n
q = [n-1]
j = 0
ved[n-1] = True
while(j < len(q)):
    cur = q[j]
    for e in ig[cur]:
        if not ved[e[0]]:
            ved[e[0]] = True
            q.append(e[0])
    j += 1

res = bf(es, n, 0, ved)
if res:
    print(-res[n-1])
else:
    print("inf")

Measured memory_bytes: 3464
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main() {
	int n;
    string s;
	cin >> n >> s;
    
    if(n%2==1){
      cout << "No" << endl;
      return 0;
    }
    
    int flag=0;
    for(int i =0;i<n/2;++i){
        if(s[i]!=s[i+n/2]){
             flag=1;
             break;
        }
    }
    
    if(flag==0)cout<<"Yes"<<endl;
    else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;
int main()
{
	long long n; cin >> n;
	long long mini = 1e18 + 7;
	for (long long i = 1; i <= sqrt(n); i++) {
		if (n % i == 0) {
			mini = min(mini, n / i + i);
		}
	}
	cout << mini - 2;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

long long N, M, Q;

long long dfs(int i, int v, vector<long long> &A, vector<vector<long long>> &B)
{
    if (v > M)
        return 0;
    if (i == N)
    {
        long long c = 0;
        for (long long j = 0; j < Q; j++)
            if (A[B[j][1] - 1] - A[B[j][0] - 1] == B[j][2])
                c += B[j][3];
        return c;
    }

    long long max_c = 0;
    for (long long j = v; j < M + 1; j++)
    {
        A[i] = j;
        max_c = max(max_c, dfs(i + 1, j, A, B));
    }

    return max_c;
}

int main()
{
    cout.precision(18);

    cin >> N >> M >> Q;

    vector<long long> A(N, 0);
    vector<vector<long long>> B;
    for (long long i = 0; i < Q; i++)
    {
        long long a, b, c, d;
        cin >> a >> b >> c >> d;
        B.push_back(vector<long long>{a, b, c, d});
    }

    cout << dfs(0, 1, A, B) << endl;
}

Measured memory_bytes: 3632
import java.util.*;

class process {
  private String name;
  private int time;

  public process(String name,int time){
    this.name = name;
    this.time = time;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getName() {
    return name;
  }

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

  public int getTime() {
    return time;
  }
}


public class Main {
  int length, front, rear;
  process[] queue;

  // ??????????????????????????????????????????????????????????????????
  Main(int len) {
    queue = new process[len];
  }

  // ??????????????¨????????\???
  void enqueue(process val) {
    if (queue.length == length) {
      System.out.println("Fatal error: the queue is full.");
      System.exit(1);
    }

    queue[rear] = val;
    rear = (rear+1)%queue.length;
    length++;
  }

  // ????????????????????\???
  process dequeue() {
    if (length == 0) {
      System.out.println("Fatal error: the queue is empty.");
      System.exit(1);
    }

    process ret = queue[front];
    front = (front+1)%queue.length;
    length--;
    return ret;
  }

  // main ????????????
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int q = sc.nextInt();

    Main queue = new Main(n);
    for (int i=0; i<n; i++) {
      queue.enqueue(new process(sc.next(), Integer.parseInt(sc.next())));
    }
    Main result = new Main(n);

    int elapsed = 0;
    int n_ = n;
    while (n > 0) {
      process p = queue.dequeue();
      if (p.getTime() - q <= 0) {
        elapsed += p.getTime();
        result.enqueue(new process(p.getName(), elapsed));
        n--;
      } else {
        elapsed += q;
        queue.enqueue(new process(p.getName(), p.getTime()-q));
      }
    }

    while (n_-- > 0) {
      process r = result.dequeue();
      System.out.println(r.getName() + " " + String.valueOf(r.getTime()));
    }
  }
}

Measured memory_bytes: 75892
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ans = 0
    for i in range(N-1):
        if A[i] % 2 == 0:
            ans += A[i] // 2
        elif A[i+1] > 0:
            ans += (A[i] + 1) // 2
            A[i+1] -= 1
        else:
            ans += A[i] // 2
    ans += A[-1] // 2
    return ans


def main():
    N = read_int()
    A = [read_int() for _ in range(N)]
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 70868
#include<cstdio>
 
int main(){
  int x = 1, i = 1;
  while( 1 ){
    scanf("%d", &x);
    if(x == 0) break;
    printf("Case %d: %d\n", i, x);
    i = i + 1;
  }
  return 0;
}

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

int main(){
  string S;
  cin >> S;
  if(S=="Sunny"){
    cout << "Cloudy" << endl;
  }
  if(S=="Cloudy"){
    cout << "Rainy" << endl;
  }
  if(S=="Rainy"){
    cout << "Sunny" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/* Akshat Sharma @akshat98 */
#include <iostream>
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp   make_pair
#define pb   push_back
#define F    first
#define S    second
#define ll   long long
#define MOD  1000000007
#define MAX  1000000001
#define vi   vector<int>
#define vl   vector<ll>
#define vpi  vector<pair<int,int> >
#define vpl  vector<pair<ll,ll> >
#define rep(i,a,b) for(i=a;i<b;i++)
#define reqp(i,a,b) for(i=a;i<=b;i++)
#define ren for(i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;


int main()
{
	#ifndef ONLINE_JUDGE
//	freopen("input_file.txt", "r", stdin);
	//freopen("output_file.txt", "w", stdout);
	#endif
	ll i,j,k,l,n,test_case,m,r;
	test_case=1;
	//cin>>test_case;
	while(test_case--){
		cin>>n;
		vi vec(n+1);
		ll x1=0;
		reqp(i,1,n){
			cin>>vec[i];
			x1+=vec[i]*((i&1)?1:-1);
		}
		int ans[n+1];
		ans[1]=x1;
		ans[n]=2*vec[n]-ans[1];
		for(i=n-1;i>=2;i--){
			// cout<<i<<" "<<vec[i]<<" "<<ans[i+1]<<".\n";
			ans[i]=2*vec[i]-ans[i+1];
		}
		reqp(i,1,n)cout<<ans[i]<<" ";


	}
	
	return 0;
}

Measured memory_bytes: 2048
#include <cstdio>
#include <vector>
#include <numeric>
using namespace std;

int main() {
    vector<int> ans;
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    for(int i = 1; i <= n; i++) {
        int tmp = 0;
        for(int j = i; j > 0; j /= 10) {
            tmp += j % 10;
        }
        if(a <= tmp && tmp <= b) {
            ans.push_back(i);
        }
    }
    printf("%d", accumulate(ans.begin(), ans.end(), 0));
    return 0;
}

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

using namespace std;
const long long INF = 1LL <<60;

int main(void){
  long long n;
  long long i,j,k;
  long long tmp;
  cin>>n;
  
  tmp=n%1000;

  if(tmp==0){
	cout<<0<<endl;
  }
  else{
    cout<<1000-tmp<<endl;
  }
  return 0;
  
}    


Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <algorithm>

#define MEMZERO(x) memset(x, 0, sizeof(x))
#define MEMSET(x, y) memset(x, y, sizeof(x))

using namespace std;

const int SIZE = 101200;
bool isPrime[SIZE];
int prime[SIZE/2], pSize;
int table[5100];

void setPrime( void )
{
	pSize = 0;
	for(int i=2; i < SIZE; ++i) isPrime[i] = true;
	isPrime[0] = isPrime[1] = false;
	for(int i=2; i < SIZE; ++i) {
		if(!isPrime[i]) continue;
		prime[pSize++] = i;
		for(int j=i+i; j < SIZE; j+=i) {
			isPrime[j] = false;
		}
	}
}

int search_index( int num )
{
	int l=0, h = pSize;
	while(l < h) {
		int m = (l + h) / 2;
		if(prime[m] < num) l = m + 1;
		else if(prime[m] > num) h = m;
		else return (m+1);
	}
	return l;
}

int main( void )
{
	setPrime();
	int m, p;
	while(cin >> m >> p, m != -1 || p != -1) {
		MEMZERO(table);
		int ii = search_index(m);
		int count = 0;
		for(int i=0; i < 100; ++i)
			for(int j=i; j < 100; ++j) {
				table[count++] = prime[i+ii] + prime[j+ii];
			}
		sort(table, table+count);
		cout << table[p-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

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

		int n = scan.nextInt();
		int card[][] = new int[4][14];
		char[] m = { 'S', 'H', 'C', 'D' };

		for (int i = 0; i < n; i++) {
			String pic = scan.next();
			int num = scan.nextInt() - 1;
			if ("S".equals(pic)) {
				card[0][num] = 1;
			} else if ("H".equals(pic)) {
				card[1][num] = 1;
			} else if ("C".equals(pic)) {
				card[2][num] = 1;
			} else {
				card[3][num] = 1;
			}
		}		

		for(int i =0;i<=3;i++){
			for(int j =0;j<13;j++){
				if(card[i][j]==0){
					System.out.printf("%s %d%n",m[i],j+1);
				}
			}
		}

	}

}

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

int main(){
int N,M,X;
  cin>>N>>M>>X;
  
  vector<int>A(M);
  for(int i=0; i<M; i++){
   cin>>A[i]; }
  
  int left=0, right=0;
  for(int i=0; i<M; i++){
   if(A[i]<X){left++;}
   if(A[i]>X){right++;} 
  }
  
  cout<<min(left, right);
}


Measured memory_bytes: 256
from fractions import gcd
from functools import reduce


def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


n = int(input())
a = list(map(int, input().split()))
ll = lcm_list(a) - 1
ans = 0
for i in a:
    ans += (ll % i)
print(ans)


Measured memory_bytes: 5372
n, total = map(int, input().split(" "))

x = -1
y = -1
z = -1

num_max_10k = total // 10000

for num_10k in range (0, num_max_10k + 1):
    for num_5k in range(0, (n - num_10k) + 1):
        if (num_10k + num_5k >= n):
            num_1k = 0
        else:
            num_1k = n - (num_10k + num_5k)

        #print(num_10k, num_5k, num_1k, sep=" ")
        if (total == (num_10k * 10000 + num_5k * 5000 + num_1k * 1000)):
            x, y, z = num_10k, num_5k, num_1k

print(x, y, z, sep=" ")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int main(){
  const int N=100000;
  vector<vector<double>> dp(N+1, vector<double>(21,0));
  dp[0][0]=1;
  rep(i,N) rep(j,20){
    dp[i+1][j+1] = dp[i][j] / (1<<j);
    dp[i+1][0] += dp[i][j] - dp[i+1][j+1];
  }
  vector<double> acc(N+1,0);
  rep(i,N) acc[i+1] = acc[i] + (1. - dp[i+1][0]);
  int n;
  while(cin>>n, n){
    printf("%.3f\n", acc[n]);
  }

  return 0;
}

Measured memory_bytes: 22868
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};
const sw=(s,a:any[],op:'='|'>='|'>'|'<='|'<'='=')=>{for(let i=0;i<a.length;i+=2){if(op==='='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};
const main = ()=>{
  let r=nin();
  out(sw(r,[
    1200,'ABC',
    2800,'ARC',
    'AGC'
  ],'<'));
}
main();

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

    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846

    void solve(){
        ll n,m,k;
        cin>>n>>m>>k;
        vector<ll>a(n);
        vector<ll>b(m);
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<m;i++)
            cin>>b[i];
        vector<ll>sumA(n+1);
        vector<ll>sumB(m+1);
        for(int i=0;i<n;i++)
            sumA[i+1]=sumA[i]+a[i];
        for(int i=0;i<m;i++)
            sumB[i+1]=sumB[i]+b[i];
        int total=0;
        for(int i=0;i<=n;i++){
            ll other=k-sumA[i];
            if(other<0)
                continue;
            int l=lower_bound(sumB.begin(),sumB.end(),other)-sumB.begin();
            if(l>m || sumB[l]>other)
                --l;
//            cout<<other<<" "<<l<<" "<<i<<" "<<"\n";
            total=max(total,i+l);
        }
        cout<<total;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 9536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define min(a, b) (a > b ? b : a)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll nck(int n, int k) { ll ret = 1; rep(i, k) {ret *= n - i; ret /= i + 1; } return ret; } // n <= 60
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int n, m;
vector<int> x, y;

int reached[100001];

class UnionFind {
public:
    vector<int> Parent;
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    int size(int A) {
        return -Parent[root(A)];
    }
    bool connect(int A, int B) {
        A = root(A);
        B = root(B);
        if (A == B) {
            return true;
        }
        if (size(A) < size(B)) swap(A, B);
        Parent[A] += Parent[B];
        Parent[B] = A;
        return false;
    }
};

void solve() {
    
    
    UnionFind uni(n);
    
    rep(i, m) {
        uni.connect(x[i], y[i]);
    }
    
    // つながってる集合は1つわかれば全部わかる
    set<int> s;
    rep(i, n) {
        s.insert(uni.root(i));
    }
    
    out(SZ(s));
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n >> m;
    x.resize(m);
    y.resize(m);
    
    int a;
    rep(i, m) { cin >> x[i] >> y[i] >> a; x[i]--; y[i]--; }
    
    solve();
}



Measured memory_bytes: 6144