akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    long a = sc.nextLong();
    String b = sc.next();
    long bn = Long.parseLong(b.replace(".", ""));
    System.out.println((a * bn) / 100L);
  }
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 22;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, k; cin >> n >> k;
  vi h(n);
  REP(i, n) {
    cin >> h[i];
  }
  sort(ALL(h));

  int ans = INF;
  FOR(i, k-1, n) {
    ans = min(ans, h[i] - h[i-k+1]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;
int main(){
    int ABCD;
    cin >> ABCD;
    int A,B,C,D;
    A = (ABCD/1000)%10;
    B = (ABCD/100)%10;
    C = (ABCD/10)%10;
    D = ABCD % 10;
    string s1,s2,s3;
    s1 ="+";
    s2 ="+";
    s3 ="+"; 
    map<int,char> syn;
    syn[0] ='+';
    syn[1] ='-';
    for(int temp=0;temp < (1<<3);temp++){
        bitset<3> s(temp);
        int S = A+B* (1-2*s[0])+C *(1-2*s[1])+D *(1-2*s[2]);
        if(S == 7){
            cout<<A<<syn[s[0]]<<B<<syn[s[1]]<<C<<syn[s[2]]<<D<<"=7"<<endl;;
            break;
        }
    }    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int cost[102],val[102];
long long int dp[102][100202];
long long int func(int in,int value)
{
	if(in<0)
	{
		if(value==0)
			return 0;
		return (1LL<<40);
	}
	long long int &ans = dp[in][value];
	if(ans!=-1)
		return ans;
	ans = func( in-1, value);
	if(value>=val[in])
		ans = min(ans, cost[in]+ func(in-1, value-val[in]));
	return ans;
}
int main()
{
	int i,n,w;
	cin>>n>>w;
	for(i=0;i<n;i++)
		cin>>cost[i]>>val[i];
	memset(dp,-1,sizeof(dp));
	for(i=100000;i>=0;i--)
	{
		long long int val = func(n-1,i);
		if(val<=w)
		{
			cout<<i;
			return 0;
		} 
	}
	return 0;
}

Measured memory_bytes: 80128
L = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
A, B = map(int, input().split())
Alice = L.index(A)
Bob = L.index(B)
if (Alice > Bob):
    print('Alice')
elif (Alice < Bob):
    print('Bob')
else:
    print('Draw')


Measured memory_bytes: 2940
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		ans += max(0, a[i - 1] - a[i]);
		a[i] = max(a[i], a[i - 1]);
	}
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << endl;
	}
}

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

int main(){
	double N;
  cin>>N;
  double x=ceil(N/1.08);
  
  
  if(int(x*1.08) == N){
  	cout<<x;
  }else{
    cout<<":(";
  }
}




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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

template<class T>
bool umin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

void solve() {
    int n;
    read(n);
    vt<int> a(n);
    read(a);
    
    vt<int> b(8);
    int t = 0;
    FOR(n) {
        if (a[i] >= 3200) {
            t++;
        }
        else{
            b[a[i] / 400]++;
        }
    }
    
    int ans = 0;
    EACH(x, b) {
        if (x > 0) {
            ans++;
        }
    }
    if (ans >= 1)
        print(ans, ans + t);
    else
        print(1, n);
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
    //read(tt);
    FOR(tt) {
        //write("Case #", i + 1, ": ");
        solve();
        
    }
    
}



Measured memory_bytes: 3664
N = input()
a = map(int, raw_input().split())

ans = []
if abs(min(a))<=max(a):
  ans += [(a.index(max(a)), 0)]
  ans += [(a.index(max(a)), 0)]
  for i in range(1, N):
    ans += [(i-1, i)]
    ans += [(i-1, i)]
else:
  ans += [(a.index(min(a)), N-1)]
  ans += [(a.index(min(a)), N-1)]
  for i in range(N-1)[::-1]:
    ans += [(i+1, i)]
    ans += [(i+1, i)]
print len(ans)
for t in ans:
  print t[0]+1, t[1]+1


Measured memory_bytes: 2696
// https://qiita.com/drken/items/fd4e5e3630d0f5859067
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	a := make([]int, N)
	for i := range a {
		fmt.Scan(&a[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	A := 0
	B := 0
	for i := 0; i < len(a); i += 2 {
		A += a[i]
		if i+1 < len(a) {
			B += a[i+1]
		}
	}
	fmt.Println(A - B)
}


Measured memory_bytes: 512
from bisect import*
s=input()
t=input()
if set(t)<=set(s):
    d={}
    for k,j in enumerate(s*2):
        if j in d:
            d[j].append(k)
        else:
            d[j]=[k]
    now=-1
    ans=0
    for i in t:
        nex=d[i][bisect_right(d[i],now)]
        ans+=nex-now
        if nex>=len(s):
            now=nex-len(s)
        else:
            now=nex
    print(ans)

else:
    print(-1)


Measured memory_bytes: 53360
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,i=0,x=0;
    cin>>a>>b>>c;
    while(1){
        i++;
        x=x+a;
        if(i%7==0){
            x=x+b;
        }
         if(c<=x){
            break;
        }
    }
    cout<<i<<endl;
}



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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int m,d,dem=0;

void process()
{
    for (int i=1;i<=m;++i)
    {
        for (int j=1;j<=d;++j)
        {
            if (j%10>=2 && j/10>=2 && (j%10)*(j/10)==i) dem++;
        }
    }
    cout<<dem;
}

int main()
{
    scanf("%d %d",&m,&d);
    process();
    return 0;
}


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

int main() {
    int n, m;
    cin >> n;
    m = n;
    int s = 0;
    while (m) {
        s += m % 10;
        m /= 10;
    }
    printf("%s\n", n % s? "No" : "Yes");
}

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

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

  int *r;
  r = new int[num];
  for (int i=0; i<num; i++) {
    cin >> r[i];
  }

  int maxProfit = r[1] - r[0];
  int min = r[1];
  if (r[1] > r[0]) {
    min = r[0];
  }
  for (int i=2; i<num; i++) {
    if ((r[i] - min) > maxProfit) {
      maxProfit = r[i] - min;
    }
    if (r[i] < min) {
      min = r[i];
    }
  }

  cout << maxProfit << endl;
}


Measured memory_bytes: 3888
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
/******************************define**********************************/

/*****************************functions********************************/
int grid[10][10];
int p[10];
/****************************main function*****************************/
int main(void){
    ll n,m;cin>>n>>m;
    vector<string> S(1 << n); //2進数にした文字列を格納するstring
    for (int i = 0; i < 1<<n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            int x = 1 << j;
            x &= i;
            S[i].push_back('0' + (x >> j)); 
        }
    }
    for(int i = 0;i < m;i++){
        int k;cin>>k;
        for(int j = 0;j < k;j++){
            int s;cin >> s; grid[i][--s] = 1;
        }
    }
    rep(m) cin >> p[i];
    int ans = 0;
    for(int i = 0;i <= (1<<n)-1;i++){
        bool check = true;
        for(int j  = 0;j < m;j++){
            //電球０からｍ－１まで
            int cnt = 0;
            for(int k = 0;k < 10;k++){
                if(grid[j][k] == 1 && S[i][k] == '1') cnt++;
            }
            if(cnt%2 != p[j]){
                check = false;
                break;
            }
        }
        if(check) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
num = int(input())
answer = num2alpha(num)
print(answer.lower())

Measured memory_bytes: 9124
#include <cmath>
#include <vector>
#include <complex>
#include <iostream>
#include <algorithm>
using namespace std;
const double pi = acos(-1);
void discrete_fourier_transform(std::size_t n, std::complex<double> *v, bool rev) {
	for (std::size_t i = 0, j = 1; j < n - 1; ++j) {
		for (std::size_t k = n >> 1; k > (i ^= k); k >>= 1);
		if (i > j) std::swap(v[i], v[j]);
	}
	for (std::size_t b = 1; b < n; b <<= 1) {
		std::complex<double> wr = std::polar(1.0, (rev ? -1.0 : 1.0) * pi / b);
		for (std::size_t i = 0; i < n; i += 2 * b) {
			std::complex<double> w = 1.0;
			for (std::size_t j = 0; j < b; ++j) {
				std::complex<double> v0 = v[i + j];
				std::complex<double> v1 = w * v[i + j + b];
				v[i + j] = v0 + v1;
				v[i + j + b] = v0 - v1;
				w *= wr;
			}
		}
	}
	if (!rev) return;
	for (std::size_t i = 0; i < n; i++) v[i] /= n;
}
double prob[54][65555]; complex<double> tmp[65555];
int main() {
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int b = 1;
	while (b < 2 * (N + 1)) b *= 2;
	prob[0][0] = 1.0; prob[0][1] = 1.0;
	for (int i = 0; i < 50; ++i) {
		for (int j = 0; j < b; ++j) {
			tmp[j] = (j <= N ? prob[i][j] : 0.0);
		}
		discrete_fourier_transform(b, tmp, false);
		for (int j = 0; j < b; ++j) {
			tmp[j] *= tmp[j];
		}
		discrete_fourier_transform(b, tmp, true);
		prob[i + 1][0] = 1.0;
		for (int j = 0; j < N; ++j) {
			prob[i + 1][j + 1] = tmp[j].real() / (j + 1);
		}
	}
	cout.precision(7);
	for (int i = 0; i < N; ++i) {
		cout << fixed << (i > 50 ? 0.0 : max(prob[i][N] - (i > 0 ? prob[i - 1][N] : 0.0), 0.0)) << '\n';
	}
	return 0;
}


Measured memory_bytes: 16536
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>
#include <tuple>
#include <numeric>
#include <queue>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <regex>
#include <stack>
#include <limits>

using namespace std;

map<int, int> readToMap(int n) {
	map<int, int> res;
	for (int i = 0; i < n; ++i) {
		int j;
		cin >> j;
		res[j]++;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n; 
	map<int, int> a = readToMap(n);
	map<int, int> b = readToMap(n);

	typedef pair<int, int> item;
	priority_queue<item> q;
	for (auto& it : a) {
		if (b.count(it.first) > 0) {
			q.push({it.second + b[it.first], it.first});
		}
	}

	vector<pair<int, int>> res;
	while (!q.empty()) {
		int cnt, num;
		tie(cnt, num) = q.top(); q.pop();
		if (cnt > n) { cout << "No\n"; return 0; }
		if (!q.empty()) {
			int num2, cnt2;
			tie(cnt2, num2) = q.top(); q.pop();
			a[num]--;
			b[num2]--;
			res.emplace_back(num, num2);
			if (a[num] != 0) {
				q.push({ cnt - 1, num });
			} else {
				a.erase(num);
			}

			if (b[num2] != 0) {
				q.push({ cnt2 - 1, num2 });
			} else {
				b.erase(num2);
			}
		} else {
			auto it = begin(b);
			if (it->first == num) {
				++it;
			}
			int num2 = it->first;
			a[num]--;
			b[num2]--;
			res.emplace_back(num, num2);
			if (a[num] != 0) {
				q.push({ cnt - 1, num });
			} else {
				a.erase(num);
			}

			if (b[num2] == 0) {
				b.erase(num2);
			}
		}
	}

	int c = res.size();
	for (auto& it : a) {
		for (int i = 0; i < it.second; ++i) {
			res.emplace_back(it.first, 0);
		}
	}

	for (auto& it : b) {
		for (int i = 0; i < it.second; ++i) {
			res[c].second = it.first;
			++c;
		}
	}

	sort(begin(res), end(res));
	cout << "Yes\n";
	for (int i = 0; i < n; ++i) {
		cout << res[i].second << ' ';
	}
	cout << endl;

	return 0;
}


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

using namespace std;

int main()
{
    ///{}
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);
    int n,z,w;
    cin>>n>>z>>w;
    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    if(n==1){
        cout<<abs(v[0]-w);
        return 0;
    }
    int ans;
    ans=max(abs(v[n-1]-w),abs(v[n-1]-v[n-2]));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <bitset>

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

using namespace std;

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

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define ep emplace_back
#define pb push_back
#define mp( a, b ) make_pair( a, b )

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()

#define MOD ( 1e9 + 7 )


int main()
{
	string S;
	cin >> S;

	long a = atoi( S.c_str() );

	bool yymm = false, mmyy = false;
	if ( ( ( a / 100 ) <= 12 ) && ( ( a / 100 ) >= 1 ) )
	{
		mmyy = true;
	}
	if ( ( ( a % 100 ) <= 12 ) && ( ( a % 100 ) >= 1 ) )
	{
		yymm = true;
	}

	if ( yymm && mmyy )
	{
		cout << "AMBIGUOUS" << endl;
	}
	else if ( yymm )
	{
		cout << "YYMM" << endl;
	}
	else if ( mmyy )
	{
		cout << "MMYY" << endl;
	}
	else
	{
		cout << "NA" << endl;
	}

	return ( 0 );
}


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

int main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  
  int i,j,k,match_count = 0;
  for( i = 0 ; i <= a ; i++ ){
    for( j = 0 ; j <= b ; j++ ){
      for(  k = 0 ; k <= c ; k++ )	if( 500 * i + 100 * j + 50 * k == x)	match_count++;
    }
  }
  
  cout << match_count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
vector<vector<char>> grid;
vector<vector<long long int>> dp;
int main(void){
  long long int h,w;
  cin>>h>>w;
  long long int ch,cw;
  cin>>ch>>cw;
  ch--;
  cw--;
  long long int dh,dw;
  cin>>dh>>dw;
  dh--;
  dw--;
  grid=vector<vector<char>>(h,vector<char>(w));
  dp=vector<vector<long long int>>(h,vector<long long int>(w,99999999999999999));
  for(long long int i=0; i<h; i++){
    for(long long int j=0; j<w; j++){
      cin>>grid.at(i).at(j);
    }
  }

  dp.at(ch).at(cw)=0;
  queue<pair<long long int,long long int>> que;
  que.push(make_pair(ch,cw));
  queue<pair<long long int,long long int>> jump;
  while(!que.empty()||!jump.empty()){
    if(que.empty()){
      que.push(jump.front());
      jump.pop();
    }
    pair<long long int,long long int> np=que.front();
    que.pop();
    long long int nh=np.first;
    long long int nw=np.second;
    for(long long int i=nh-2; i<=nh+2; i++){
      for(long long int j=nw-2; j<=nw+2; j++){
        if(i<0||j<0){
          continue;
        }
        if(i>=h||j>=w){
          continue;
        }
        if(grid.at(i).at(j)=='#'){
          continue;
        }
        if((i==nh&&j==nw-1)||(i==nh&&j==nw+1)||(i==nh-1&&j==nw)||(i==nh+1&&j==nw)){
          if(dp.at(nh).at(nw)<dp.at(i).at(j)){
            dp.at(i).at(j)=dp.at(nh).at(nw);
            que.push(make_pair(i,j));
          }
        }else{
          if(dp.at(nh).at(nw)+1<dp.at(i).at(j)){
            dp.at(i).at(j)=dp.at(nh).at(nw)+1;
            jump.push(make_pair(i,j));
          }
        }
      }
    }
  }
  if(dp.at(dh).at(dw)==99999999999999999){
    cout<<-1<<endl;
  }else{
    cout<<dp.at(dh).at(dw);
  }
}

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

using ll = long long;

int main() {
    int N, D;
    cin >> N >> D;
    int A = D * 2 + 1;
    int ans = (N + A - 1) / A;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline void myassert(bool a,string s){ if(!a)cerr<<s<<endl,exit(0);}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=5e5+20;
const int mod=998244353;
int jc[maxn],jcn[maxn],inv[maxn];

inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=(ll)ans*a%mod;
		b>>=1;
		a=(ll)a*a%mod;
	}
	return ans;
}

inline void prepare()
{
	jc[0]=jc[1]=jcn[0]=jcn[1]=inv[1]=1;
	REP(i,2,5e5+1)jc[i]=(ll)i*jc[i-1]%mod,inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod,jcn[i]=(ll)jcn[i-1]*inv[i]%mod;
}

int n,m;

inline void init()
{
	n=read();m=read();
}

inline int C(int n,int m){ return 1ll*jc[n]*jcn[m]%mod*jcn[n-m]%mod;}

inline void doing()
{
	int ans=0;
	int pron=power(m+1,n),prom=power(n+1,m);
	REP(i,0,min(n,m))
	{
		ans=(ans+(ll)C(n,i)*C(m,i)%mod*jc[i]%mod*pron%mod*prom*(i&1?-1:1))%mod;
		pron=(ll)pron*inv[m+1]%mod;
		prom=(ll)prom*inv[n+1]%mod;
	}
	printf("%d\n",(ans+mod)%mod);
}

int main()
{
	prepare();
	init();
	doing();
	return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n, w;
ll weight[101], value[101];
ll dp[101010];
int main(){
    cin>>n>>w;
    REP(i, 0, n) cin>>weight[i]>>value[i];
    REP(j, 1, 101010) dp[j]=inf;

    dp[0]=0;
    REP(i, 0, n){
        RREP(j, 0, 100001){
            if(dp[j]==inf) continue;
            if(dp[j]+weight[i]>w) continue;

            dp[j+value[i]]=min(dp[j+value[i]], dp[j]+weight[i]);
        }
    }

    RREP(j, 0, 100001){
        if(dp[j]==inf) continue;

        cout<<j<<endl;
        break;
    }
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
string ans="";

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ll n;
	cin >> n;
	while(n){
		n--;
		int cur = n%26;
		ans += char('a'+cur);
		n/=26;
	}
	reverse(all(ans));
	cout << ans;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 3648
if __name__ == '__main__':
    tmp = input().split(' ')
    num = int(''.join(tmp))
    m = 0
    while True:
        m += 1
        if m ** 2 == num:
            print('Yes')
            exit(0)
        elif m ** 2 > num:
            print('No')
            exit(0)

Measured memory_bytes: 2940
// atcoder/abc163/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

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

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

const int N = 2 * 1e5 + 5;
namespace math {
  lli fact[N], finv[N], inv[N];

  void init()
  {
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < N; i++){
      fact[i] = fact[i - 1] * i % mod;
      inv[i] = mod - inv[mod % i] * (mod / i) % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }

  lli mod_comb(int n, int k)
  {
    assert(n < N && k < N);
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fact[n] * (finv[k] * finv[n - k] % mod) % mod;
  }
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  // math::init();

  lli n, k;
  while (cin >> n >> k) {
    lli x = 0;
    lli y = 0;
    for (int i = 0; i < k; ++i) {
      x += i;
      y += n - i;
      x %= mod;
      y %= mod;
    }
    lli sum = 0;
    for (lli i = k; i <= n + 1; ++i) {
      lli z = (y - x + 1 + mod) % mod;
      (sum += z) %= mod;

      x += i;
      y += n - i;
      x %= mod;
      y %= mod;
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 3656
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int a,b;
  cin >>a>>b;
 
  int cnt=0;
  vector<string> p(a);
  rep(i,a){
  cin>>p[i];
    rep(j,b){
    if(p[i][j]=='#')cnt++;
    }
  }
  
  
/*  
  rep(i,a){
    rep(j,b){
      rep(k,a){
        rep(l,b){
          if(p[i][j]=='#' && p[k][l]=='#' && ((i>j && k<l)||(i<j && k>l))){
          cout << "Impossible" << endl;
          return 0;
          }
        }
      }
    }
  }
 
  cout << "Possible" << endl;
*/
  
  cout << (cnt==a+b-1?"Possible":"Impossible") << endl;
  
}


Measured memory_bytes: 256
#include<stdio.h>

void main(){
    int n,x,a=1;
    scanf("%d",&n);
    scanf("%d", &x);
    int l[n];
    int b=0;
    for(int i=1; i<=n;i++){
        scanf("%d ", &l[i]);
    b+=l[i];
     if(b<=x)
        a++;  
    }
   
printf("%d",a);

}

Measured memory_bytes: 128
import collections
A=int(input())
l_after=[]
l=list(map(int,input().split()))
l=collections.Counter(l).most_common()
for i in range(len(l)):
   if l[i][1] > 1:
      l_after.append(l[i][0])
   if l[i][1] > 3:
      l_after.append(l[i][0])
l_after.sort(reverse=True)
if len(l_after) < 2:
   print(0)
   exit()
print(l_after[0]*l_after[1])


Measured memory_bytes: 21384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include<complex>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;


int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a*b, c*d) << endl;
	return 0;
}
//Ctrl+Aを使わない

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

int main(){
  int n,r,l,p,dat[N][2],ans,t;
  char d;
  while(1){
    cin>>n>>l;
    if(!n&&!l) break;
    for(int i=0;i<=l;i++) dat[i][0]=dat[i][1]=0;
    for(int i=0;i<n;i++){
      cin>>d>>p;
      if(d=='L') dat[p][0]=i+1;
      else dat[p][1]=i+1;
    }
    r=n;
    t=0;
    while(1){
      if((r==1&&(dat[0][0]||dat[l][1]))||(r==2&&(dat[0][0]&&dat[l][1]))){
	if(dat[0][0]&&dat[l][1]) ans=dat[0][0];
	else ans=dat[0][0]+dat[l][1];
	break;
      }
      if(dat[0][0]) r--,dat[0][0]=0;
      if(dat[l][1]) r--,dat[l][1]=0;
      for(int i=0;i<l;i++)
	if(dat[i+1][0]) dat[i][0]=dat[i+1][0],dat[i+1][0]=0;
      for(int i=l;i>0;i--)
	if(dat[i-1][1]) dat[i][1]=dat[i-1][1],dat[i-1][1]=0;
      for(int i=0;i<l;i++)
	if(dat[i][0]&&dat[i][1]) swap(dat[i][0],dat[i][1]);
      t++;
    }
    cout<<t<<' '<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define MAXN 200007
using namespace std;
int n;
struct balls
{
	long long val, bag;
}b[2 * MAXN];
long long Rmax, Rmin, Bmax, Bmin, ans;
int ex[MAXN], ou[MAXN];
bool cmp(balls u, balls v)
{
	return u.val < v.val;
}
bool check(int to)
{
	int i;
	memset(ex, 0, sizeof(ex));
	for(i = 2; i <= to; i++)++ex[b[i].bag];
	for(i = 1; i <= n; i++)
	if(!ex[i])return 0;
	return 1;
}
int main()
{
	int i;
	scanf("%d", &n);
	Rmax = Bmax = 0; Bmin = Rmin = 1e9;
	for(i = 1; i <= n; i++)
	{
		scanf("%d%d", &b[2 * i - 1].val, &b[2 * i].val);
		if(b[2 * i - 1].val > b[2 * i].val)swap(b[2 * i - 1], b[2 * i]);
		b[2 * i - 1].bag = b[2 * i].bag = i; 
		Rmax = max(Rmax, b[2 * i].val);
		Bmin = min(Bmin, b[2 * i - 1].val);
	}
	for(i = 1; i <= n; i++)
	{
		Bmax = max(Bmax, b[2 * i - 1].val);
		Rmin = min(Rmin, b[2 * i].val);
	}
	ans = (Bmax - Bmin) * (Rmax - Rmin);

	sort(b + 1, b + 2 * n + 1, cmp);
	Rmin = b[1].val;
	int h = 2, l = 2, r = 2 * n, mid;
	if(b[1].bag != b[2 * n].bag)
	{
		while(l < r - 1)
		{
			mid = (r + l) / 2;
			if(check(mid))r = mid;
			else l = mid;
		}
		++ou[b[1].bag];
		while(ou[b[h-1].bag] < 2&&r <= 2 * n)
		{
			Bmax = b[r].val; Bmin = b[h].val;
			ans = min(ans, (Bmax - Bmin) * (Rmax - Rmin));
			--ex[b[h].bag];
			while(r <= 2 * n && !ex[b[h].bag])++r, ++ex[b[r].bag];
			++ou[b[h].bag];++h;
		}	
	}
	printf("%lld", ans);
	return 0;
}

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

int main()
{
        int N;
        cin >> N;
        vector<string> v;
        for(int i = 0; i < N; i++)
        {
                string s;
                cin >> s;
                v.push_back(s);
        }

        int pp = 0;
        int aa = 0;
        int bb = 0;
        int AB = 0;
        for(int i = 0; i < N; i++)
        {
                if(v[i][0] == 'B' and v[i][v[i].size()-1] == 'A') pp++;
                else if(v[i][v[i].size()-1] == 'A') aa++;
                else if(v[i][0] == 'B') bb++;
                for(int j = 0; j < v[i].size()-1; j++)
                {
                        if(v[i][j] == 'A' and v[i][j+1] == 'B') AB++;
                }
        }

        /*
        cout << "pp:" << pp << endl;
        cout << "aa:" << aa << endl;
        cout << "bb:" << bb << endl;
        */

        while(pp > 1)
        {
                pp--;
                AB++;
        }

        while(pp > 0 and aa > 0 and bb > 0)
        {
                pp--;
                aa--;
                bb--;
                AB += 2;
        }

        while(pp > 0 and aa > 0)
        {
                pp--;
                aa--;
                AB++;
        }

        while(pp > 0 and bb > 0)
        {
                pp--;
                bb--;
                AB++;
        }

        while(aa > 0 and bb > 0)
        {
                aa--;
                bb--;
                AB++;
        }

        cout << AB << endl;

        return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define pb(a) push_back(a)
#define ms(x,y) memset(x,y,sizeof(x))
#define sci(a) scanf("%d",&a) 
#define scl(a) scanf("%lld",&a)
#define scd(a) scanf("%lf",&a) 
#define ll long long 
using namespace std;
/* --------------- fast io --------------- */ // begin
namespace Fread{
const int SIZE=1<<20;
char buf[SIZE],*S,*T;
inline char getchar(){
	if(S==T){
		T=(S=buf)+fread(buf,1,SIZE,stdin);
		if(S==T)return EOF;
	}
	return *S++;
}
}//namespace Fread
namespace Fwrite{
const int SIZE=1<<20;
char buf[SIZE],*S=buf,*T=buf+SIZE;
inline void flush(){
	fwrite(buf,1,S-buf,stdout);
	S=buf;
}
inline void putchar(char c){
	*S++=c;
	if(S==T)flush();
}
struct _{
	~_(){flush();}
}__;
}//namespace Fwrite

#ifdef ONLINE_JUDGE
	#define getchar Fread::getchar
	#define putchar Fwrite::putchar
#endif

template<typename T>inline void read(T& x){
	x=0;int f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))x=x*10+(c-'0'),c=getchar();
	x*=f;
}
template<typename T>inline void write(T x,bool _enter=0,bool _space=0){
	if (!x)putchar('0');else{
		if(x<0)putchar('-'),x=-x;
		static char dig[41];
		int top=0;
		while(x)dig[++top]=(x%10)+'0',x/=10;
		while(top)putchar(dig[top--]);
	}
	if(_enter)putchar('\n');
	if(_space)putchar(' ');
}

namespace Fastio{
struct reader{
	template<typename T>reader& operator>>(T& x){::read(x);return *this;}
	reader& operator>>(char& c){
		c=getchar();
		while(c=='\n'||c==' ')c=getchar();
		return *this;
	}
	reader& operator>>(char* str){
		int len=0;
		char c=getchar();
		while(c=='\n'||c==' ')c=getchar();
		while(c!='\n'&&c!=' ')str[len++]=c,c=getchar();
		str[len]='\0';
		return *this;
	}
}cin;
const char endl='\n';
struct writer{
	template<typename T>writer& operator<<(T x){::write(x,0,0);return *this;}
	writer& operator<<(char c){putchar(c);return *this;}
	writer& operator<<(const char* str){
		int cur=0;
		while(str[cur])putchar(str[cur++]);
		return *this;
	}
}cout;
}//namespace Fastio
#define cin Fastio::cin
#define cout Fastio::cout
#define endl Fastio::endl
/* --------------- fast io --------------- */ // end

const int maxn=100005;
int main(){
		//#define int ll
		int d,t,s;
	while(scanf("%d %d %d",&d,&t,&s)!=EOF){

		
		if(t*s>=d)
			puts("Yes");
		else
			puts("No");
	 }
	return 0;
} 

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

const int N=1e7+20;

long long n,dp[N];

int main()
{
	for(int i=1;i<N;i++)
		for(int j=i;j<N;j+=i)
			dp[j]++;
	for(int i=1;i<N;i++) dp[i]=dp[i-1]+i*dp[i];
	
	cin>>n;
	cout<<dp[n];
}

Measured memory_bytes: 81716
N = int(input())
A = [int(input()) for _ in range(N)]

sum_A = sum(A)
MOD = 998244353

dp1 = [0] * (sum_A + 1)
dp2 = [0] * (sum_A + 1)
dp1[0] = dp2[0] = 1


for a in A:
    for i in reversed(range(sum_A + 1)):
        if i - a >= 0:
            # R に塗れる場合
            dp1[i] = (dp1[i - a] + dp1[i] * 2) % MOD
            dp2[i] = (dp2[i - a] + dp2[i]) % MOD
        else:
            dp1[i] = (dp1[i] * 2) % MOD
            dp2[i] = dp2[i]


ans = pow(3, N, MOD)
for i in range(sum_A + 1):
    if i * 2 >= sum_A:
        ans = (ans - dp1[i] * 3 + MOD * 3) % MOD
    if i * 2 == sum_A:
        ans = (ans + dp2[i] * 3) % MOD
print(ans)


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

int main() {
  
  string S, T, U;
  int A=0, B=0;
  
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  
  if(U==S) {
    
    cout << A-1 << " " << B << endl;
    
  } else if(U==T) {
    
    cout << A << " " << B-1 << endl;
    
  }
  
  return 0;
  
}

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

int main() {
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int d=min(x,y);
  int ans=0;
  if(a+b>2*c) ans+=2*c*d;
  else ans+=d*(a+b);
  if(y>=x){
    y-=d;
    ans+=min(b*y,y*2*c);
  }
  else{
    x-=d;
    ans+=min(a*x,x*2*c);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

void bfs(vector<vector<int>> &g, vector<int> &r, vector<int> &d) {
  r.resize(g.size());
  r.assign(g.size(), -1);
  d.resize(g.size());
  d.assign(g.size(), 0);

  queue<int> q;
  q.push(0);
  r.at(0) = 0;

  while (!q.empty()) {
    int c = q.front();
    q.pop();

    for (int next : g.at(c)) {
      // cout << c + 1 << " -> " << next + 1 << "候補" << endl;
      // 道標を置く
      if (r.at(next) < 0) {
        // cout << c + 1 << " -> " << next + 1 << endl;
        r.at(next) = c;
        q.push(next);
      }
    }
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;

    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<int> r;
  vector<int> d;
  bfs(g, r, d);

  bool allFound = true;
  for (int i = 1; i < n; i++) {
    if (r.at(i) < 0) {
      allFound = false;
    }
  }

  if (allFound) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
    return 0;
  }

  for (int i = 1; i < n; i++) {
    cout << r.at(i) + 1 << endl;
  }
}

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

#define endl '\n'

void solve(){
    int n; cin >> n;
    long long a[n];
    long long zero = 0, qtd = 0;
    for (int i=0; i<n; i++){
        cin >> a[i];
        if (a[i] == 0) zero=1;
        long long temp = a[i]/10, temp2=0;
        while(temp){
            temp2++;
            temp/=10;
        }
        qtd += temp2;
    }
    if (zero){
        cout << 0;
        return;
    }
    if (qtd > 18){
        cout << -1;
        return;
    }
    long long ans = 1, ant = 0;
    for (int i=0; i<n; i++){
        ans *= a[i];
        if (ans < 0 || ans > 1000000000000000000LL || ans < ant){
            cout << -1;
            return;
        }
        ant = ans;
    }
    cout << ans << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1; //cin >> t;
    while(t--) solve();
}

Measured memory_bytes: 4424
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro nlet (name args &body body)
  (labels ((ensure-list (x) (if (listp x) x (list x))))
    (let ((args (mapcar #'ensure-list args)))
      `(labels ((,name ,(mapcar #'car args) ,@body))
         (,name ,@(mapcar #'cadr args))))))

(defmacro split-ints-and-bind (vars string &body body)
  (let ((pos1 (gensym "POS"))
	(pos2 (gensym "POS"))
	(str (gensym "STR")))
    (labels ((expand (vars &optional (init-pos1 t))
	       (if (null vars)
		   body
		   `((let* ((,pos1 ,(if init-pos1 0 `(1+ ,pos2)))
			    (,pos2 (position #\space ,str :start ,pos1 :test #'char=))
			    (,(car vars) (parse-integer ,str :start ,pos1 :end ,pos2)))
		       ,@(expand (cdr vars) nil))))))
      `(let ((,str ,string))
         (declare (string ,str))
	 ,@(expand vars)))))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

;; Hauptteil

(defun main ()
  (let* ((d (read))
         (required-score (floor (read) 100))
         (ps (make-array d :element-type 'uint32))
         (max-scores (make-array d :element-type 'uint32)))
    (dotimes (i d)
      (split-ints-and-bind (p c) (read-line)
        (setf (aref ps i) p
              (aref max-scores i) (+ (floor c 100) (* p (+ i 1))))))
    (let ((min-num most-positive-fixnum))
      (dotimes (bits (expt 2 d))
        (let ((num 0)
              (score 0))
          (dotimes (i d)
            (when (= 1 (ldb (byte 1 i) bits))
              (incf score (aref max-scores i))
              (incf num (aref ps i))))
          (if (>= score required-score)
              (setf min-num (min num min-num))
              (let ((idx -1)
                    (delta most-positive-fixnum))
                (dotimes (i d)
                  (let ((tmp-delta (ceiling (max 0 (- required-score score)) (+ i 1))))
                    (when (and (zerop (ldb (byte 1 i) bits))
                               (< tmp-delta (aref ps i))
                               (< tmp-delta delta))
                      (setf idx i
                            delta tmp-delta))))
                (incf num delta)
                (when (and (/= idx -1)
                           (< num min-num))
                  (setf min-num num))))))
      (println min-num))))

#-swank(main)


Measured memory_bytes: 26596
package main

import (
	"bufio"
	"flag"
	"fmt"
	"io"
	"math"
	"math/big"
	"os"
)

var reader *bufio.Reader
var writer *bufio.Writer

var inputFile = flag.String("input", "", "")

func init() {
	flag.Parse()
	var i io.Reader
	if *inputFile != "" {
		i, _ = os.Open(*inputFile)
	} else {
		i = os.Stdin
	}
	reader = bufio.NewReaderSize(i, 1<<20)
	writer = bufio.NewWriterSize(os.Stdout, 1<<20)
}

func println(a ...interface{}) {
	_, _ = fmt.Fprintln(writer, a...)
}

func printf(format string, a ...interface{}) {
	_, _ = fmt.Fprintf(writer, format, a...)
}

func scanf(format string, a ...interface{}) {
	_, _ = fmt.Fscanf(reader, format, a...)
}

func scan(a interface{}) {
	_, _ = fmt.Fscan(reader, a)
}

func NextInt64() int64 {
	var res int64
	scan(&res)
	return res
}

func NextInt() int {
	var res int
	scan(&res)
	return res
}

func NextIntArray(n int) []int {
	res := make([]int, n)
	for i := range res {
		scan(&res[i])
	}
	return res
}

func NextInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		scan(&res[i])
	}
	return res
}

func NextString() string {
	var res string
	scan(&res)
	return res
}

func NextBigInt() *big.Int {
	n := new(big.Int)
	n, _ = n.SetString(NextString(), 10)
	return n
}

func AbsInt64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func MinInt64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func main() {
	defer writer.Flush()

	n := NextInt()
	k := NextInt()

	h := NextInt64Array(n)

	dp := make([]int64, n)
	for i := 1; i < n; i++ {
		dp[i] = math.MaxInt64
		for j := 1; j <= k && j <= i; j++ {
			dp[i] = MinInt64(dp[i], dp[i - j] + AbsInt64(h[i] - h[i - j]))
		}
		
	}
	println(dp[n - 1])
}


Measured memory_bytes: 3840
#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;

#define MAX_N 1000010
ll inv[MAX_N+10],fac[MAX_N+10],ifac[MAX_N+10];

void setComb(){
  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<MAX_N;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;

    inv[i]=(inv[i]+MOD)%MOD;
    fac[i]=(fac[i]+MOD)%MOD;
    ifac[i]=(ifac[i]+MOD)%MOD;
  }
  return;
}

ll comb(ll n,ll k){
  if(n<k||n<0||k<0) return 0;
  else return ((fac[n]*ifac[k]%MOD*ifac[n-k]%MOD+MOD)%MOD);
}

ll hcomb(ll n,ll r){// this size is really ok??
  if(n==0&&r==0) return 1;
  else if(n<0||r<0) return 0;
  else return comb(n+r-1,r);
}

ll mod_pow(ll x,ll n){
  x%=MOD;
  ll res=1;
  while(n>0){
    if(n&1) res=res*x%MOD;
    x=x*x%MOD;
    n>>=1;
  }
  return res;
}

void add(ll &a,ll b){
  a=(a+b)%MOD;
}

void mul(ll &a,ll b){
  a%=MOD;b%=MOD;
  a=a*b%MOD;
}

int N;
vector<ll> A;

ll dp[202][100010];
int nxt[100010];

ll rec(int now,int val){
    if(now==N) return val;
    if(dp[now][val]) return dp[now][val];

    ll res=0;
    for(int i=now;i<N;i++){
        if(A[i]<=val){
            int tar=val%A[i];
            ll tmp=rec(nxt[tar],tar);
            ll coef=comb(N-(i+1),N-(nxt[tar]));
            mul(coef,fac[nxt[tar]-(i+1)]);
            ll r=comb(N-(now+1),i-now);
            mul(r,fac[i-now]);
            mul(coef,r);
            mul(tmp,coef);
            add(res,tmp);
        }
    }
    return dp[now][val]=res;
}

int main(){
    int X;
    cin>>N>>X;
    A.resize(N);
    rep(i,N) cin>>A[i];

    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());

    for(int i=1;i<=100000;i++) nxt[i]=-1;
    nxt[0]=N;
    rep(i,N) nxt[A[i]]=i;
    for(int i=1;i<=100000;i++){
        if(nxt[i]==-1) nxt[i]=nxt[i-1];
    }

    setComb();

    ll ans=0;
    if(A.back()>X){
        ll tmp=rec(N,X);
        mul(tmp,fac[N]);
        add(ans,tmp);
    }

    int st=nxt[X];
    ll all=comb(N,st);
    mul(all,fac[st]);
    for(int i=0;i<N;i++){
        if(A[i]<=X){
            int tar=X%A[i];
            ll tmp=rec(nxt[tar],tar);
            ll coef=comb(N-(i+1),N-(nxt[tar]));
            mul(coef,fac[nxt[tar]-(i+1)]);
            ll r=comb(N-(st+1),i-st);
            mul(coef,fac[i-st]);
            mul(coef,r);
            mul(tmp,coef);
            add(ans,tmp);
        }
    }

    mul(ans,all);

    cout<<ans<<endl;

    return 0;
}

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

int		main()
{
	int N; cin >> N;
	bool f = true;
	for (int i = 0; i < N; i++)
	{
		int t, x, y; cin >> t >> x >> y;
		if (t < x + y || (x + y) % 2 != t % 2)
		{
			f = false;
		}
	}
	cout << (f ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
A,B,C = map(int,input().split())
if A == B:
    if A!= C:
        print("Yes")
    else:
        print("No")
elif B == C:
    if B != A:
        print("Yes")
    else:
        print("No")
elif C == A:
    if C !=B:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 38384
#include<stdio.h>

int main(void){
	int n,k;
	int s[100],sum[100];
	int b[100][100];
	int i,j;
	int cnt;

	while(1){
		scanf("%d %d",&n,&k);
		if(n==0 && k==0){
			return 0;
		}
		for(i=0;i<100;i++){
			s[i]=0;
			sum[i]=0;
			for(j=0;j<100;j++){
				b[i][j]=0;
			}
		}
		for(i=0;i<k;i++){
			scanf("%d",&s[i]);
		}
		for(i=0;i<n;i++){
			for(j=0;j<k;j++){
				scanf("%d",&b[i][j]);
			}
		}
		for(i=0;i<k;i++){
			for(j=0;j<n;j++){
				sum[i]+=b[j][i];
			}
		}
		cnt=0;
		for(i=0;i<k;i++){
			if(s[i]>=sum[i]){
				cnt++;
			}
		}
		if(cnt==k){
			puts("Yes");
		}else{
			puts("No");
		}
	}
	return 0;
}

Measured memory_bytes: 420