akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
const int N=1005;
int n,cnt=0,k;
int arr[10005];
ll num[1000010],ans=0;
vector<ll> vec[105];
bool flag[105];
void get_ans(int key)
{
	if(key==-1) return;
	int sz=vec[key].size();
	if(sz<k){
		get_ans(key-1);
		return;
	}
	flag[key]=true;
	for(int i=0;i<key;++i) vec[i].clear();
	for(int i=0;i<sz;++i){
		for(int j=0;j<key;++j)
			if((1ll<<j)&vec[key][i]) vec[j].push_back(vec[key][i]);
	}
	get_ans(key-1);
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;++i) cin>>arr[i];
	//for(int i=1;i<=n;i++) cout<<arr[i]<<' ';
	//cout<<endl;
	for(int i=1;i<=n;++i){
		ll sum=0;
		for(int j=i;j<=n;++j){
			sum+=arr[j];
			num[++cnt]=sum;
		}
	}
	//for(int i=1;i<=n;i++) cout<<num[i]<<' ';
	for(int i=1;i<=cnt;++i){
		for(int j=0;(1ll<<j)<=num[i];++j)
			if((1ll<<j)&num[i]) vec[j].push_back(num[i]);
	}
	get_ans(100);
	for(int i=0;i<100;++i)
		if(flag[i]) ans+=(1ll<<i);
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 80272
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <regex>

using namespace std;
using ll = long long int;
const ll MOD = 1e9 + 7;

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

	if (m >= n) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    string s;cin>>s;
    string a;
    a="qwertyuiopasdfghjklzxcvbnm";
    sort(a.begin(),a.end());
    //cout<<a<<endl;
    ll ans=-1;
    bool bb=false;
    rep(i,0,25){
        bb=false;
        rep(j,0,s.size()-1){
            if(a[i]==s[j]){
                bb=true;
                break;
            }
        }
        if(bb==false){
            ans=i;
            break;
        }
        
    }
    if(ans>=0){
        cout<<a[ans]<<endl;
    }else{
        cout<<"None"<<endl;
    }
    
    return 0;
}







Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

  vector<int> ans(4,0);
  for(int i = 0;i < N;i++) {
    string S;
    cin >> S;
    if(S == "AC") ans[0]++;
    else if(S == "WA") ans[1]++;
    else if(S == "TLE") ans[2]++;
    else ans[3]++;
  }

  cout << "AC x " << ans[0] << endl;
  cout << "WA x " << ans[1] << endl;
  cout << "TLE x " << ans[2] << endl;
  cout << "RE x " << ans[3] << endl;

  
}


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

int main(){
    int N;
    cin>>N;
    std::set<int> m;
    for(int i=0;i<N;++i){
        int size;
        cin>>size;
        m.insert(size);
    }
    cout<<m.size()<<endl;
}

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

Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int h,w,n;
    cin>>h;
    cin>>w;
    cin>>n;
    int x = max(h,w);
    cout<<(n+x-1)/x<<endl;
    return 0;
}



Measured memory_bytes: 256
//
//  main.cpp
//  A_RGBCards
//
//  Created by user1 on 2017/06/10.
//  Copyright © 2017年 user1. All rights reserved.
//


#include <iostream>
int r, g, b;

void solve(){
    std::cin >> r;
    std::cin >> g;
    std::cin >> b;
    
    if((r*100 + g*10+b)%4 == 0){
        printf("YES\n");
    }else printf("NO\n");
}

int main(int argc, const char * argv[]) {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    string s; cin >> s;
    int q; cin >> q;

    map<int,int> M[26];

    rep(i,n) {
        int num = s[i] - 'a';
        M[num][i]++;
    }

    rep(i,q) {
        int a, b; cin >> a >> b;
        b--;
        char c;
        int ci;
        if(a==1) cin >> c;
        else cin >> ci;

        if(a==1) {
            int pre = s[b] - 'a';
            int nex = c - 'a';
            M[pre].erase(b);
            M[nex][b] = 1;
            s[b] = c;
        }
        else {
            ci--;
            int ans = 0;
            rep(j,26) {
                auto l = M[j].lower_bound(b);
                auto r = M[j].upper_bound(ci);
                ans += (!(l==r));
            }
            cout << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 24220
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/*
 * AtCoder Beginner Contest 085 B "Kagami Mochi"
 *   https://abc085.contest.atcoder.jp/tasks/abc085_b/
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int N = in.nextInt();
		int[] d = in.nextIntArray(N);

		Set<Integer> set = new HashSet<Integer>();
		for (int i : d) {
			set.add(i);
		}

		out.println(set.size());

		in.close();
		out.close();
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return scanner.nextInt();
		}

		public long nextLong() {
			return scanner.nextLong();
		}

		public double nextDouble() {
			return scanner.nextDouble();
		}
		public String next() {
			return scanner.next();
		}

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

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

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

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, String split) {
			String[][] ret = new String[h][];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <set>
#include <numeric>
#include <algorithm>
#include <cstdlib>
#include <vector>

using namespace std;
int main() {
    int a, b, k;
    cin >> a >> b >> k;
    for(int i = 0; i < k; i++){
        if(i % 2 == 0){
            if(a % 2 == 1){
                a--;
            }
            a = a / 2;
            b += a;
        }
        else{
            if(b % 2 == 1){
                b--;
            }
            b = b / 2;
            a += b;
        }
    }
    cout << a << ' ' << b << endl;
}

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

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    for (int i = 0; i < N; i++)
        cin >> v[i] >> w[i];

    int dp[101][10001];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= 10001; j++) {
            if (j < w[i]) {
                dp[i + 1][j] = dp[i][j];
            } else {
                dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


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

#define F first
#define S second
#define int long long
#define pb push_back
#define endl '\n'

using namespace std;

int32_t main()
{
    ios_base :: sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n, k;
	cin >> n>> k;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a , a + n);
	int sum = 0;
	for (int i = 0; i < k ; i++) sum += a[i];
	cout << sum << endl;
}



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

int main() {
    int N,M,X;
    vector <int> A(100);
    cin >> N >> M >> X;
    for (int i=0;i<M;i++){
        cin >> A.at(i);
    }
    for (int i=0;i<M;i++){
        if (A.at(i) > X){
            if (i < M-i){
                cout << i << endl;
            }else{
                cout << M-i << endl;
            }
            break;
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

ll INF = LONG_LONG_MAX / 2;

vector<int> to;
vector<ll> score;

ll solve(const int start, const int N, const int K) {
    vector<ll> loop;
    ll max_for_loop = -INF;
    ll sum_for_loop = 0;
    int k1 = 0;
    {
        int cur = start;
        while (1) {
            cur = to[cur];
            sum_for_loop += score[cur];
            chmax(max_for_loop, sum_for_loop);
            k1++;
            if (cur == start || k1 == K) {
                break;
            }
        }
    }

    // in the case K is smaller than loop or repeating loop decreases the score
    if (k1 == K) {
#ifdef DEBUG
        printf("loop is small: %d\n", k1);
#endif
        return max_for_loop;
    }
    if (sum_for_loop <= 0) {
#ifdef DEBUG
        printf("negative loop: %lld\n", sum_for_loop);
#endif
        return max_for_loop;
    }

    assert(max_for_loop > 0);
    assert(sum_for_loop > 0);

    // repeating loop increases the score, so do it as many as possible
    // -> this is actually not true. see the comment of loop_cnt.
    const int loop_size = k1;

    /*
     * Have to decrease 1 from loop_cnt otherwise it fails with a test case like:
     * 5 7
     * 2 3 4 5 1
     * 3 3 3 -4 -4
     * The score of a loop is only 1, but we can get 9 by traveling 5 -> 1 -> 2 -> 3.
     */
    // const int loop_cnt = K / loop_size;
    const int loop_cnt = K / loop_size - 1;

#ifdef DEBUG
    printf("loop size is %d\n", loop_size);
#endif
    ll s = sum_for_loop * loop_cnt;

    ll ans = s;
    int k2 = loop_cnt * loop_size;
    if (k2 < K) {
        int cur = start;
        while (1) {
            cur = to[cur];
            s += score[cur];
            chmax(ans, s);
            k2++;
            if (k2 == K) {
                break;
            }
        }
    }

    assert(ans >= 0);

    return ans;
}

int main(void) {
    int N, K;
    cin >> N >> K;

    to.resize(N);
    for (int i = 0; i < N; i++) {
        int p;
        cin >> p;
        p--;
        to[i] = p;
    }

    score.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> score[i];
    }

    ll ans = -INF;
    for (int start = 0; start < N; start++) {
        ll cand = solve(start, N, K);
#ifdef DEBUG
        printf("maximum is %lld from %d\n", cand, start);
#endif
        chmax(ans, cand);
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
	int n,ret = 0;
	int l[200] = {};
	cin >> n;
	for(int i = 0;i < n * 2;i++){
		cin >> l[i];
	}
	sort(l,l + n * 2);
	for(int i = 0;i < n;i++){
		ret += l[i * 2];
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	if(n<10)
		printf("%d\n",n);
	else {
		for(int i=n;; i++) {
			int d=i,r=d%10,f=1;
			d/=10;
			while(d) {
				int rr=d%10;
				d/=10;
				if(rr!=r)
				{
					f=0;
					break;
				}
					
			}
			if(f==1) {
				printf("%d\n",i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int,input().split())
x = tx - sx
y = ty - sy
ans = ''
ans += 'U' * y
ans += 'R' * x
ans += 'D' * y
ans += 'L' * x
ans += 'L'
ans += 'U' * (y + 1)
ans += 'R' * (x + 1)
ans += 'D'
ans += 'R'
ans += 'D' * (y + 1)
ans += 'L' * (x + 1)
ans += 'U'
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ll inf = 1e18;

int main() {
    string s;
    ll k;
    cin >> s >> k;
    int ct;
    char x;
    rep(i,s.size()) {
        if (s[i] == '1') ct++;
        else {
            x = s[i];
            break;
        }
    }
    if (k <= ct) {
        cout << '1' << endl;
    } else cout << x << endl;
}

Measured memory_bytes: 256
*G=gets
$<.map{|l|x=l.split.map &:to_i;x.map{|a|G[a]||=[];G[a].push *x}}
puts G[1]&&(d,*v=->i{a=[[i,1]];(i,l=a.pop;v[i]=l;G[i].map{|j|v[j]||a<<[j,l+1]})while a[0]},0;d[1];a=v.index v.max;*v=0;d[a];v.max%3>1)?:Second: :First

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

int main() {
    int h, w;
    char s[101];
    scanf("%d %d",&h, &w);
    for(int i=0;i<w+2;i++) {
        printf("#");
    }
    for(int i=0;i<h;i++){
        scanf("%s",s);
        printf("\n#%s#",s);
    }
    printf("\n");
    for(int i=0;i<w+2;i++) {
        printf("#");
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

bool finder(vector<string> vec,string str)
{
    for(int i=0;i<vec.size();i++)
    {
        if(vec[i]==str) return false;
    }
    return true;
}

int main()
{
    vector<string> w(100);

    int n;
    scanf("%d",&n);
    int judge=true;
    for(int i=0;i<n;i++)
    {
        string str;
        cin>>str;
        if(find(w.begin(),w.end(),str)!=w.end())
        {
            judge=false;
            // printf("No\n");
            // return 0;
        }
        if(i!=0&&str.front()!=w[i-1].back())
        {
            judge=false;
            // printf("No\n");
            // return 0;
        }
        w[i]=str;
    }
    if(judge) printf("Yes\n");
    else printf("No\n");
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define MOD 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MAXX 9000000000000000000
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> > 
#define vvpi vector<vector<pair<int,int> > >


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int n,m;
	cin >> n >> m;
	if(m >= 2 * n && m <= 4 * n && m % 2 == 0)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	
	
	return 0;
}

Measured memory_bytes: 3636
//////////////////////////
//      _        ____   //
//  U  /"\  u U /"___|  //
//   \/ _ \/  \| | u    //
//   / ___ \   | |/__   //
//  /_/   \_\   \____|  //
//   \\    >>  _// \\   //
//  (__)  (__)(__)(__)  //
//  Compro by NULL_CT©  //
//////////////////////////
// STL libs
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

// Boost
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/irange.hpp>

#define REP(I, LIM) for (int I = 0; I < (LIM); I++)
#define ALL(LIST) (LIST.begin()), (LIST.end())

using namespace std;
using boost::irange;
using boost::multiprecision::cpp_int;

typedef long long ll;

const int MOD = 1000000007;

vector<ll> divisor(ll &_n) {
  vector<ll> head, tail;
  for (long i = 1; i * i <= _n; i++) {
    if (_n % i == 0) {
      head.push_back(i);
      if (i * i != _n)
        tail.push_back(_n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return head;
}

ll kadanes(vector<ll> &_ls) {
  ll highestMax = 0, currentMax = 0, length = _ls.size();
  for (ll i = 0; i < length; i++) {
    currentMax = max(_ls[i], currentMax + _ls[i]);
    highestMax = max(highestMax, currentMax);
  }
  return highestMax;
}

class UnionFind {
public:
  vector<ll> par;

  UnionFind(ll N) : par(N) {
    for (ll i = 0; i < N; i++)
      par[i] = i;
  }
  ll root(ll x) {
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }
  void unite(ll x, ll y) {
    ll rx = root(x);
    ll ry = root(y);
    if (rx == ry)
      return;
    par[rx] = ry;
  }
  bool same(ll x, ll y) {
    ll rx = root(x);
    ll ry = root(y);
    return rx == ry;
  }
};

void execution();

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  // cout<<fixed<<setprecision(20);

  execution();
  return 0;
}

/*----------------------------*/

void execution(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout <<
        max(max(a*c,a*d),max(b*c,b*d))
      <<"\n";
}


Measured memory_bytes: 3160
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
    int x;
    cin>>x;
    if(x==3 || x==5 || x==7)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    

}

Measured memory_bytes: 256
S = input()

def saiki(i,s = S[0]):
    _sum = 0
    if i == len(S) - 1:
        ans = eval(s)
        return ans
    _sum += saiki(i + 1, s + "+" + S[i+1])
    _sum += saiki(i + 1, s + S[i+1])
    
    return _sum
        
print(saiki(0))


Measured memory_bytes: 3060
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front priority_queue
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const ll mod = 1e9 + 7 ;
const ll inf =
 1e9 + 5 ;
 //1e18L + 5;
const ll nax = 2e5 + 5;
void min_self(ll&a , ll b){a=min(a,b);}
void max_self(ll&a , ll b){a=max(a,b);}
void add_self(ll&a , ll b){a=(a+b)%mod;}
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll n , d , a; 
cin >> n >> d >> a ; 
vector<pair<ll,ll>> v(n) ; 
for(ll i = 0 ; i<n ; i++){
	ll k , l ; cin >> k>>  l  ;
	l = (a-1+ l)/a ; 
	// cout << l << endl;
	v[i] = {k,l};
}
sort(all(v)) ;

ll base = 1; 
while(base <= n)base *= 2; 
vector<ll> tree(2*base) ,lazy(2*base); 
for(ll i = 0 ; i<n ; i++){
	ll x = base + i ; 
	while(x>0){
		tree[x]+=v[i].second;
		// cout << x << " " << tree[x] << endl;
		x/=2;
	}
}


ll ans = 0 ; 
ll x = 0 ; 
while(x<n){
	// cout << x  << endl;
	ll ok = -1 ;

// if(tree[x + base] <= 0  )continue ;
ll j = x + base ; 
ll con = tree[j] ;
while(j>0){
	con += lazy[j];
	j/=2;
}
// cout << x << " " << con << " " << v[x] .second <<  endl;
if(con <= 0){x++;continue;}

ll low = x , high = n-1 ; 
while(low<=high){
	ll mid = low + (high - low) /2 ;

	if(v[mid].first <= v[x].first + 2*d ){
		ok= mid ; 
		low = mid + 1 ;
	}
	else high = mid -1 ;
}

// dec health x ..... ok  by v[x].first 
// cout << "ok " <<  x << " " << ok << endl;
ll l = x+base , r = ok + base ;
lazy[l] -= v[x].second ;
if(l!=r) lazy[r]-=con; 
while(l+1<r){
	if(!(l&1))lazy[l+1]-=con;
	if(r&1)lazy[r-1] -=con; 
	l/=2;
	r/=2;
}

ans += con;

x++;





}
cout << ans ;



	
}

Measured memory_bytes: 11648
n = int(input())
a = list(int(x) for x in input().split())
key = sum(a)

value = a[0]
for i in range(1, n):
    judge = value + a[i]
    if judge <= key/2:
        value = judge
    else:
        ans = min([abs(key-value*2), abs(key-judge*2)])
        break
print(ans)

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

int main() {
  int N,K,x,s_length;
  cin >> N >> K;
  s_length = 0;
  for(int i=0; i<N; i++){
    cin >> x;
    if(x < (K-x)){
      s_length += x*2;
    }else{
      s_length += (K-x)*2;
    }
  }
  cout << s_length << endl;
}

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

int main(){
  int D,N,S;
  cin>>D>>N;
  S=pow(100,D);
  
  if(N<=99){
     cout<<S*N<<endl;
  }else{
    cout<<S*101<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int main() {
    string s;
    cin >> s;
    string t = "ACGT";
    int ans = 0;
    int now = 0;
    for(int i = 0;i < s.size();i++) {
        bool isACGT = false;
        for(int j = 0; j < 4;j++) {
            if(s[i] == t[j]) isACGT = true;
        }
        if(!isACGT) {
            now = 0;
        }
        else {
            now ++;
            ans = max(now,ans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from bisect import bisect_left, bisect_right
INF = float("inf")


def solve(N: int, M: int, V: int, P: int, A: "List[int]"):

    A.sort()

    # 二分探索で探す
    left = -1
    right = len(A)-1
    while right - left > 1:
        mid = (right + left)//2

        if N-P <= mid:
            right = mid
            continue

        if A[mid]+M < A[N-P]:
            left = mid
            continue

        # 入れられても構わない票をカウントする
        tot = 0
        for i in range(mid+1, N-P+1):
            tot += A[mid]+M-A[i]
        tot += (P-1)*M
        tot += mid*M
        tot += M

        if tot < M*V:
            left = mid
            continue
        else:
            right = mid
            continue

    print(N-bisect_left(A, A[right]))
    # Yがわかったときの答え

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    V = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, V, P, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 59680
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
        int N;
        cin >> N;
        int cnt = 0;
        for (int i = 1; i <= N; ++i) {
                if (i % 2 != 0) ++cnt;
        }
        double ans = double(cnt) / N;
        cout << setprecision(20) << ans << endl;
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define repl(k,n) for(k=0;k<n;++k)

int main() {
	int N;
	cin >> N;
	vector<long long int>A(N);
	int i;
	long long int sum1=0;
	long long int sum2=0;
	long long int ans = 0;
	long long int sum;
	rep(i, N) {
		cin >> A[i];
		sum1 =sum1+ A[i];
		sum = A[i] * A[i];
		sum = sum % 1000000007;
		sum2 =sum2+ sum;
	}
	sum1 = sum1 % 1000000007;
	sum2 = sum2 % 1000000007;
	sum1 = (sum1 * sum1) % 1000000007;
	if (sum1 < sum2) {
		sum1 = sum1 + 1000000007;
	}
	ans = (sum1 - sum2) % 1000000007;
	if (ans % 2 != 0) {
		ans = ans + 1000000007;
	}
	ans = ans / 2;
	cout << ans;
	return 0;
}

Measured memory_bytes: 4764
N = input()
L = input().split()
L_int = [int(l) for l in L]


L_max = max(L_int)

max_index = L_int.index(max(L_int))
L_int[max_index] = 0

if int(L_max) < int(sum(L_int)):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

import sys

price = []
quantity = []
n = 0
for line in sys.stdin:
    p, q = map(int, line.split(','))
    price.append(p)
    quantity.append(q)
    n += 1
sum = ave_q = 0
for i in range(n):
    sum += price[i]*quantity[i]
    ave_q += quantity[i]
ave_q = int(round(float(ave_q)/n, 0))
print sum
print ave_q

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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string a,b;
    cin>>a>>b;
    for(int i=0;i<a.size();i++){
        if(a[i]!=b[i]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>

int main()
{
    using namespace std;
    int32_t N, K, result;
    cin >> N >> K;
    
    result = K;
    
    for (auto j = 0; j < N-1; j++) {
        result *= K-1;
    }
    
    cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;
typedef pair<P,int>Pi;

struct edge
{
    int to,cost;
};

const int MAX_N = 22;
const int dx[] = {1,-1,0,0};
const int dy[] = {0,0,1,-1};

char c[MAX_N][MAX_N];
P robot_dust[12];
int flag[MAX_N*MAX_N];
int d[MAX_N][MAX_N];
int dp[(1 << 11)][MAX_N];
int w,h;

void bfs(P cor)
{
    queue<Pi> que;
    que.push(Pi(cor,0));
    while(!que.empty()){
        Pi nw = que.front();
        que.pop();
        rep(i,4){
            int ni = (nw.first).first + dy[i];
            int nj = (nw.first).second + dx[i];
            int dir = nw.second;
            if(c[ni][nj] != 'x' && 0 <= ni && ni < h && 0 <= nj && nj < w){
                if(flag[ni*w + nj] > dir + 1){
                    flag[ni*w + nj] = dir + 1;
                    que.push(Pi(P(ni,nj),dir+1));
                }
            }
        }
    }
}

int main()
{
    while(1){
        scanf("%d%d",&w,&h);
        if(w == 0 && h == 0){
            break;
        }
        int dust_cnt = 1;
    	rep(i,h){
            char hoge;
            scanf("%c",&hoge);
            rep(j,w){
                scanf("%c",&c[i][j]);
                if(c[i][j] == '*'){
                    robot_dust[dust_cnt++] = P(i,j);
                }else if(c[i][j] == 'o'){
                    robot_dust[0] = P(i,j);
                }
            }
    	}
        rep(i,dust_cnt){
            rep(j,dust_cnt){
                d[i][j] = INF;
            }
        }
        rep(i,dust_cnt){
            fill(flag,flag+w*h,INF);
            flag[robot_dust[i].first*w + robot_dust[i].second] = 0;
            bfs(robot_dust[i]);
            rep(j,dust_cnt){
                if(flag[robot_dust[j].first*w + robot_dust[j].second] < INF){
                    d[i][j] = flag[robot_dust[j].first*w + robot_dust[j].second];
                }
            }
        }
        rep(i,(1 << (dust_cnt - 1))){
            rep(j,dust_cnt){
                dp[i][j] = INF;
            }
        }
        for(int i = 1;i < dust_cnt; i++){
            dp[(1 << (dust_cnt - 1)) - 1][i] = 0;
        }
        for(int i = (1 << (dust_cnt - 1)) - 2 ; i >= 0; i--){
            for(int j = 1;j < dust_cnt; j++){
                for(int k = 0;k < dust_cnt - 1; k++){
                    if(!(i & (1 << k))){
                        dp[i][j] = min(dp[i][j],dp[i | (1 << k)][k+1] + d[j][k+1]);
                    }
                }
            }
        }
        int res = INF;
        for(int i = 1; i < dust_cnt; i++){
            res = min(res,dp[0][i] + d[0][i]);
        }
        if(res < INF){
            printf("%d\n",res);
        }else{
            printf("-1\n");
        }
    }

	return 0;
}

Measured memory_bytes: 3228
import java.util.Scanner;

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

        sc.close();

        System.out.println(s.substring(0, 1) + s.substring(1, s.length() - 1).length() + s.substring(s.length() - 1,
                s.length()));

    }
}

Measured memory_bytes: 22608
#include <stdio.h>

int main(){
    int i,x,y;
    while(1){
        scanf("%d%d",&x,&y);
        if(x==0&&y==0)break;
        else if(x<y)printf("%d %d\n",x,y);
        else if(x>=y)printf("%d %d\n",y,x);
    }
    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define x first
#define y second

typedef long long ll;

const int N = 1e3 + 10;
const int INF = 0x3f3f3f3f;

typedef pair<int, int> PII;

map<int, int> num;

int main ()
{
	int n, m, x;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &x);
		num[x]++;
	}
	
	scanf("%d", &m);
	bool f = 1;
	for(int i = 0; i < m && f; i++){
		scanf("%d", &x);
		if(!num.count(x) || num[x] == 0)
			f = 0;
		else num[x]--;
	}
	
	printf("%s\n", f ? "YES" : "NO");
	
	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    string s;
    cin>>s;
    ll ans=0;
    if(s=="SSS")
    {
        cout<<0<<endl;
    }
    else if(s=="RRR")
    {
        cout<<3<<endl;
    }
    else if(s=="RRS"||s=="SRR")
    {
        cout<<2<<endl;
    }
    else
    {
        cout<<1<<endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

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

int main(){
	int n;
	cin>>n;
	vector<int>c(n),s(n),f(n);
	for(int i=0;i<n-1;i++)cin>>c[i]>>s[i]>>f[i];
	for(int i=0;i<n-1;i++){
		int tmp=s[i]+c[i];
		for(int j=i;j<n-2;j++){
			if(tmp<s[j+1])tmp=s[j+1];
			else if((tmp-s[j+1])%f[j+1]!=0){
				while((tmp-s[j+1])%f[j+1]!=0){
					tmp++;
				}
			}
			tmp+=c[j+1];
		}
		cout<<tmp<<endl;
	}
	cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();

		long minAB = Math.min(a, b);
		int i = 1;
		while (minAB * i / a <= 0
			|| minAB * i / b <= 0
			|| minAB * i % a != 0
			|| minAB * i % b != 0) {
			i++;
		}
		System.out.println(minAB * i);
		sc.close();
	}
}


Measured memory_bytes: 21844
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    g = gcd(a, b)
    return a // g * b

N = int(input())
T = [int(input()) for _ in range(N)]

ans = 1

for i in range(N):
    ans = lcm(ans, T[i])

print(ans)

Measured memory_bytes: 9128
n=int(input())
l=[*map(int,input().split())]
a=1000
c=0
for i in range(n-1):
  if l[i]>l[i+1]:
    a+=c*l[i]
    c=0
  if l[i]<l[i+1]:
    while a>=l[i]:
      t=a//l[i]
      a-=t*l[i]
      c+=t
print(a+c*l[n-1])

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

vector<int> l(8),p(3);

int min_MP(int a,int b,int c,int i,int m){

    if(i==l.size()){
        vector<int> p0 = {a,b,c};
        sort(p0.begin(),p0.end());
        if(!p0[0]) return 1e8;
        else return m + abs(p0[0]-p[0]) + abs(p0[1]-p[1]) + abs(p0[2]-p[2]);
    }
    return min(min(min_MP(a+l[i],b,c,i+1,a==0?m:m+10),min_MP(a,b+l[i],c,i+1,b==0?m:m+10))
                ,min(min_MP(a,b,c+l[i],i+1,c==0?m:m+10),min_MP(a,b,c,i+1,m)));
}

int main(){
    int n,ans=1e8;
    cin >> n;
    cin >> p[0] >> p[1] >> p[2];
    sort(p.begin(),p.end());
    for(int i = 0;i < n;i ++){
        cin >> l[i];
    }

    ans = min_MP(0,0,0,0,0);

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

Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
#include <algorithm>
#include <utility>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
queue<pii> q;
pii arr[200001];
int main(){
    int N,D,A;scanf("%d %d %d",&N,&D,&A);
    for(int i=0;i<N;i++){
        int a,b;scanf("%d %d",&a,&b);
        arr[i]={a,b};
    }
    sort(arr,arr+N);
    ll sum=0,cnt=0;
    for(int i=0;i<N;i++){
        while((!q.empty()) && q.front().first<arr[i].first){
            cnt-=q.front().second;
            q.pop();
        }
        ll cha = (arr[i].second - cnt*A);
        if(cha>0){
            cnt += cha/A + (cha%A>0);
            sum += cha/A + (cha%A>0);
            q.push({arr[i].first+2*D,cha/A + (cha%A>0)});
        }
    }
    printf("%lld",sum);
}


Measured memory_bytes: 2560
n = gets.to_i
words = Hash.new(0)
n.times { words[gets.chomp] += 1 }
array = words.to_a.sort {|a, b| (b[1] <=> a[1]).nonzero? || (a[0] <=> b[0])}
max = array.first[1]
array.each do |word, num|
  if num < max
    exit
  else
    puts word
  end
end


Measured memory_bytes: 38248
import numpy as np

def abc069_d():
    H, W = map(int, input().split())
    _ = int(input())
    A = list(map(int, input().split()))

    # いったん1次元に並べる
    flat = []
    for i, a in enumerate(A):
        flat += [i+1] * a

    # 2次元に変形して、1行飛ばしで反転(折り返して往復すればつながる)
    grid = np.array(flat, dtype=int).reshape((H, W))
    for i in range(H):
        if i % 2 == 0:
            print(*grid[i], sep=' ')
        else:
            print(*grid[i, ::-1], sep=' ')

abc069_d()

Measured memory_bytes: 21528
#include<iostream>
#include<string>

using namespace std;

int main(){
	int dp[20][20];
	int n;
	int a, b;
	int x, y;
	while(cin >> a >> b && a&&b){
		cin >> n;
		for (int i = 0; i < 20; i++) {
			for (int j = 0; j < 20; j++) {
				dp[i][j] = 0;
			}
		}
		for (int i = 0; i < n; i++) {
			cin >> x >> y;
			dp[y][x] = -1;
		}
		dp[1][1] = 1;
		for (int i = 1; i <= b; i++) {
			for (int j = 1; j <= a; j++) {
				if ((i == 1)&&(j == 1)) {
					continue;
				}
				if (dp[i][j] != -1) {
					dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
				}
				else {
					dp[i][j] = 0;
				}
			}
		}
		cout << dp[b][a] << endl;
	}
	

	return 0;
}

Measured memory_bytes: 2996
#include <climits>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

const int INF = 0xfffffff, MAX_W = 30, MAX_H = 60;
const int LEFT = 0, RIGHT = 1;
int w, h;
char field[MAX_H][MAX_W];

struct state {
	int x, y, dist;
	bool right;

	state(int x, int y, bool right, int dist):x(x), y(y), right(right), dist(dist){};
	bool operator>(const state& s) const {
		return dist > s.dist;
	}
};


int dijkstra() {
	vector<vector<vector<int> > > dist(h, vector<vector<int> >(w, vector<int>(2, INT_MAX)));
	priority_queue<state, vector<state>, greater<state> > que;

	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j) {
			if(field[i][j] == 'S') {
				dist[i][j][LEFT] = dist[i][j][RIGHT] = 0;
				que.push(state(j, i, LEFT, 0));
				que.push(state(j, i, RIGHT, 0));
			}
		}
	}

	while(!que.empty()) {
		const state s = que.top();
		que.pop();

		if(dist[s.y][s.x][s.right] < s.dist)
			continue;

		if(field[s.y][s.x] == 'T')
			return s.dist;

		const int sign = (s.right ? -1 : 1);

		for(int i = 1; i <= 3; ++i) {
			const int nx = s.x + sign * i;
			if(nx < 0 || nx >= w)
				continue;

			for(int j = -3 + i; j + i <= 3; ++j) {
				const int ny = s.y + j;
				if(ny < 0 || ny >= h || field[ny][nx] == 'X')
					continue;

				const bool n_right = !s.right;
				const int n_dist = s.dist + (isdigit(field[ny][nx]) ? field[ny][nx] - '0' : 0);
				if(dist[ny][nx][n_right] > n_dist) {
					dist[ny][nx][n_right] = n_dist;
					que.push(state(nx, ny, n_right, n_dist));
				}
			}
		}
	}

	return -1;
}

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

	while(cin >> w >> h, w) {
		for(int i = 0; i < h; ++i)
			for(int j = 0; j < w; ++j)
				cin >> field[i][j];

		cout << dijkstra() << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1344
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main(){
  ll n,k;
  cin >> n >> k;
  ll res = 0;
  res += pow((int)n / k,3);
  //cout << res << endl;
  if(k % 2 == 0){
    int memo = n - k / 2;
    if(n >= k / 2)res += pow(memo / k + 1,3);
    else if(memo > 0)res += pow(memo / k,3);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
use std::io::*;

fn main() {
  let input = {
    let mut buf = vec![];
    stdin().read_to_end(&mut buf);
    unsafe { String::from_utf8_unchecked(buf) }
  };
  let line = input.split('\n').nth(1).unwrap();

  let (mut cnt, mut max) = (0, 0);
  for s in line.split(' ') {
    if s == "1" {
      cnt += 1;
      if cnt > max { max = cnt; }
    }
    else { cnt = 0; }
  }

  println!("{}", max + 1);
}


Measured memory_bytes: 5020
function Main(input){
    i=input.split(" ").map(Number);
    r=[];
    for(a = 1;a<=Math.min(i[0],i[1]);a++){
        if(i[0]%a===0&&i[1]%a===0){
            r.push(a);
        }
    }
    console.log(r[r.length-i[2]]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main()
{
	long long modular = 1000000007;

	size_t N = 0;

	std::cin >> N;

	std::vector<long long> numbers(N, 0);
	std::vector<long long> sums(N - 1, 0);

	for (auto& number : numbers)
	{
		std::cin >> number;
	}

	long long answer = 0;

	for (size_t index = 0; index < N - 1; ++index)
	{
		if (index == 0)
		{
			sums.at(index) = numbers.at(N - 1);

			continue;
		}

		sums.at(index) = (numbers.at(N - index - 1) + sums.at(index - 1)) % modular;

		sums.at(index) %= modular;
	}

	for (size_t index = 0; index < N -1; ++index)
	{
		long long sum = 0;

		answer += (numbers.at(index) * sums.at(N - index - 2)) % modular;

		answer %= modular;
	}

	std::cout << answer << std::endl;
}



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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

int calc(ll x) { return x == 0 ? 0 : calc(x / 10) + 1; }

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	ll n; read(n);
	int ans = 0x3f3f3f3f;
	for (ll i = 1; i * i <= n; i++) if (n % i == 0) {
		ans = min(ans, max(calc(i), calc(n / i)));
	}
	die(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define prl(x) cout<<(x)<<endl
int main(void){string s,t;map<char,vl>c;cin>>s>>t;ll n=s.length(),cur=0;rep(i,n)c[s[i]].push_back(i);for(char a:t){vl& v=c[a];if(!v.size()){prl(-1);return 0;}auto it=lower_bound(v.begin(),v.end(),cur%n);(cur=cur/n*n+1)+=it==v.end()?*(v.begin())+n:*it;}prl(cur);return 0;}

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

int main() {
  vector<int> s = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k; cin >> k;
  cout << s.at(k-1);
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(int argc, char const *argv[]) {

  char s[210000];
  char t[210000];
  scanf("%s", s);
  scanf("%s", t);
  char ok[26];
  bool ok2[26];
  for (int i = 0; i < 26; i++) {
    ok[i] = -1;
  }
  for (int i = 0; s[i] != 0; i++) {
    // printf("%d", ok[s[i] - 'a']);
    if (ok[s[i] - 'a'] == -1) {
      ok[s[i] - 'a'] = t[i];
    } else if (ok[s[i] - 'a'] != t[i]) {
      printf("No\n");
      return 0;
    }
  }
  // for (int i = 0; i < 26; i++) {
  //   printf("%c\n", ok[i]);
  // }
  for (int i = 0; i < 26; i++) {
    if (ok[i] == -1) {
      continue;
    } else if (ok2[ok[i] - 'a']) {
      printf("No\n");
      return 0;
    }
    ok2[ok[i] - 'a'] = true;
  }
  printf("Yes\n");
  return 0;
}


// #include <cstdio>
// #include <algorithm>
// #include <vector>
// #include <string>
//
// using namespace std;
//
// int main(int argc, char const *argv[]) {
//   //
//   char s[210000];
//   char t[210000];
//   scanf("%s", s);
//   scanf("%s", t);
//   string ss = s;
//   string tt = t;
//   bool oks[ss.size()];
//   // sort(s[])
//   for (int i = 0; ss[i] != 0; i++) {
//     if (oks[i] == 0 && ss[i] != tt[i]) {
//       // printf("%c\n", ss[i]);
//       // if(binary_search(pairs.begin(), pairs.end(), make_pair(2, 4))){
//       char x = ss[i];
//       char y = tt[i];
//       oks[i] = 1;
//       while (1) {
//         int c = ss.find(y);
//         if (c == -1) {
//           break;
//         }
//         y = tt[c];
//         oks[c] = 1;
//         if (y == ss[c]) {
//           printf("No\n");
//           return 0;
//         }
//         if (y == x) {
//           break;
//         }
//       }
//     }
//   }
//   printf("Yes\n");
//   return 0;
// }


Measured memory_bytes: 512
k,n = list(map(int, input().split())) 
i= list(map(int, input().split())) 
ans=0
for j in range(n):
    if j==0:
        x=i[n-1]-i[0]
        y=(k-i[1])+i[0]
        ans=min(x,y)
    elif j==n-1:
        x=(k-i[j])+i[j-1]
    
        if ans>x:
            ans=x
    else:
        x=(k-i[j])+i[j-1]
        y=i[j]+(k-i[j+1])
        if ans>min(x,y):
            ans=min(x,y)
print(ans)

Measured memory_bytes: 26444
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n,m; cin >> n >> m;
    ll sum=0;
    rep(i,m){
        int a; cin >> a;
        sum+=a;
    }
    if(sum>n) cout << -1 << endl;
    else cout << n-sum << endl;
}



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


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Integer N = sc.nextInt();
		ArrayList<Integer> data = new ArrayList<>();
		data.add(0);
		for (int i = 0; i < N; i++) {
			data.add(sc.nextInt());
		}
		int counter = 0;
		for (int i = 1; i <= N; i++) {
			// current = i
			int pair = data.get(i);
			if (data.get(pair) == i) {
				counter++;
			}
		}
		System.out.println(counter / 2);
	}

}


Measured memory_bytes: 47980