akhauriyash/Code-Regression huggingface dataset:
//By Sho10 aka JuniorMonster
#include <bits/stdc++.h>
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
using namespace std;
int32_t main(){
  double a,b;
  cin>>a;
  cin>>b;
  cout<<setprecision(10)<<a/b;
return 0;}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

const int MOD = 1e+9 + 7;

int main()
{
    int N, K;
    cin >> N >> K;
    
    // i 個選ぶとき
    long long ans = 0;
    FOR(i, K, N+2){
        ans += (long long) (2*N-i+1)*i/2 - (long long) i*(i-1)/2 + 1;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3192
/** Author: Dwai
 *  Omae wa mou shindeiru!
**/

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

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define fr(i,a,b) for (i = a; i <= b; i++)
#define frr(i,a,b) for (i = a; i >= b; i--)
#define rep(i,n) for (i = 0 ; i < n; i++)
#define repr(i,n) for (i = n - 1; i >= 0; i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define flushinput   cin.ignore(numeric_limits<streamsize>::max(),'\n');

void debug_out() { cerr << endl; }

void clock_out(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}

void fileio(){
  freopen("/home/dwai/Desktop/cp/input.txt","r", stdin);
  freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
  freopen("/home/dwai/Desktop/cp/debug.txt", "w", stderr);
}

void ofileio(){
  freopen("input.txt","r", stdin);
  freopen("output.txt", "w", stdout); 
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define fio() fileio()
#define ofio() fileio()
#define clock() clock_out()
#else
#define debug(...) 42
#define fio() 42
#define ofio() ofileio()
#define clock() 42
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef map<ll,ll> mll;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

void solve(){
	ll n,m;
	cin>>n>>m;

	ll a[n+1][m+1],i,j;
	fr(i,1,n)
	{
		fr(j,1,m){
			char x;cin>>x;
			if(x=='.') a[i][j]=0;
			else a[i][j]=1;
		}
	}
	ll dp[n+1][m+1];
	memset(dp,0,sizeof(dp));

	dp[1][1]=1;
	fr(i,1,n)
	{
		fr(j,1,m)
		{
			if(a[i][j]==1)
				continue;
			if(i>1)
			{
				if(a[i-1][j]==0)
					dp[i][j]+=dp[i-1][j];
			}
			if(j>1)
			{
				if(a[i][j-1]==0)
					dp[i][j]+=(dp[i][j],dp[i][j-1]);
			}
			dp[i][j]%=MOD;
		}
	}

	cout<<dp[n][m];
}

int main(){
	//fio();
	fast

	solve();
	return 0;
}

Measured memory_bytes: 15872
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

//#define int ll

using namespace std;



signed main(void)
{
	//変数の宣言
	int n,m;
	int h,w;
	static char s[20];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	static int vec[1010];
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	static char stemp[100010];
	
	//データの読み込み


//	scanf("%d %d %d",&h,&w,&m);
//	scanf_s("%d %d %d",&h,&w,&m);


	scanf("%s",&s);
//	scanf_s("%s",&s,20);




/*	//scanf("%c",&dummy);
	scanf_s("%c",&dummy);
	for(i=0;i<n;i++){
//		scanf("%c",&s[i]);
		scanf_s("%c",&s[i]);
	}*/


/*	for(i=0;i<h;i++){
//		scanf("%s",&s[i]);
		scanf_s("%s",&s[i],1010);
	}*/


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

//	clock_t start=clock();

	if(s[2]==s[3]&&s[4]==s[5]){
		printf("Yes");
	}else{
		printf("No");
	}


//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力
	
	//printf("%d",(d[i-1][j-1]+1)/2);

//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define vi vector<int>
#define vb vector<bool>
#define lli long long int
#define vvi vector<vector<int>>
#define loop(n) for (int i = 0; i < n; i++)
using namespace std;

auto SpeedUp = []() {
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

int arr[100005], dp[100005];
int n;
int solve()
{
    memset(arr, 0, sizeof(arr));
    memset(dp, 0, sizeof(dp));
    cin >> n;
    loop(n) cin >> arr[i];

    vi dp(n, 0);
    dp[n - 2] = abs(arr[n - 2] - arr[n - 1]);
    for (int i = n - 3; i >= 0; i--)
    {
        dp[i] = min(dp[i + 1] + abs(arr[i + 1] - arr[i]), dp[i + 2] + abs(arr[i + 2] - arr[i]));
    }

    // for(int ele :dp)
    //     cout << ele << " ";
    return dp[0];
}

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

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

int main(){
	int A,B,C,K;
	cin>>A>>B>>C>>K;

	int xa = min(K,A);
	int Kd = K-xa;
	int xb = min(Kd,B);
	int Kdd = Kd-xb;

	int ans = xa-Kdd;

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int D,E;
    cin >> D >> E;
    while(D!=0){
        double mn = inf;
        double ans;
        for(int i=0; i<=100; i++){
            for(int j=0; j<=100; j++){
                if(i+j != D) continue;
                chmin(mn,abs(sqrt(i*i+j*j)-double(E)));
            }
        }
        cout << fixed << setprecision(10) << mn << endl;
        cin >> D >> E;
    }
    return 0;
}


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


#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define FILE_IO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
//#define int long long
using namespace std;


signed main() {
	FAST_IO;
	//FILE_IO;

	string a, b;
	cin >> a >> b;
	int x = a.length(), y = b.length();
	a = " " + a;
	b = " " + b;

	int dp[x + 1][y + 1];
	for (int i = 0; i <= x; i++) dp[i][0] = 0;
	for (int i = 0; i <= y; i++) dp[0][i] = 0;
	for (int i = 1; i <= x; i++) {
		for (int j = 1; j <= y; j++) {
			if (a[i] == b[j]) dp[i][j] = dp[i - 1][j - 1] + 1;
			else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	/*
	for (int i = 0; i <= x; i++) {
		for (int j = 0; j <= y; j++)
			cout << dp[i][j] << " ";
		cout  << "\n";
	}
	*/
	vector<char> lcs;
	int i = x, j = y;
	while (i && j) {
		if (a[i] == b[j]) {
			lcs.push_back(a[i]);
			i--, j--;
		}
		else dp[i - 1][j] > dp[i][j - 1] ? i-- : j--;
	}
	for (auto it = lcs.rbegin(); it != lcs.rend(); it++) cout << *it;

	return 0;
}

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

using namespace std;

int main(){
	while(true){
	int n;
	cin >> n;
	if(n==0)break;
	vector<int> list(n,0);
	double ave=0;
	for(int z=0;z<n;z++){
		cin >> list[z];
		ave += (double)list[z];
	}
	ave /= n;
	double a=0;
	for(int i=0;i<n;i++){
		a += pow(list[i]-ave,2.0);
	}
	a /= n;
	printf("%f\n",sqrt(a));
	}
	return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  // 最も長くても、K≦5なので、aaaaaのように5文字以下になる。
  // 5文字以下を列挙すれば良い説。
  set<string> sstr;
  for (int i = 1; i <= 5; i++) {  // i文字ぶんを列挙
    for (int j = 0; j + i <= s.size(); j++) {
      sstr.insert(s.substr(j, i));
    }
  }
  int i = 1;
  for (auto x : sstr) {
    if (i == k) {
      cout << x << endl;
      return 0;
    }
    i++;
  }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  ll N, K;
  cin >> N >> K;
  ll res;

  res = -N % K;
  if(res<0) res += K;
  res = min(res, N % K);

  cout << res << endl;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		sc.close();
		
		if(A+B > C+D)
			System.out.println("Left");
		else if(A+B < C+D)
			System.out.println("Right");
		else
			System.out.println("Balanced");
	}
}


Measured memory_bytes: 21844
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    cin >> p[0];
    int minP = p[0];
    int cnt = 1;
    for(int i = 1; i < n; i++){
        cin >> p[i];
        if(minP >= p[i]){
            minP = p[i];
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

int main()
{
  int R, G, B, N; cin >> R >> G >> B >> N;

  int ans = 0;
  for (int i = 0; i <= 3000; i++)
  {
    for (int j = 0; j <= 3000; j++)
    {
      int ball = N - i * R - j * G;
      if (ball >= 0 and ball % B == 0) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>

using namespace std;

int main() {
	int argN, argL;
	cin >> argN >> argL;

	vector<string> argS(argN);
	for (int i = 0; i < argN; ++i) {
		cin >> argS.at(i);
	}

	sort(argS.begin(), argS.end());
	string ret = "";
	for (int i = 0; i < argN; ++i) {
		ret += argS.at(i);
	}

	cout << ret << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int f, m, r;
  
  while (1){
    scanf("%d%d%d", &m, &f, &r);

    if ( m==-1 && f==-1 && r==-1) break;
    
    if ( f==-1 || m==-1 ) printf("F\n");
    else if ( f+m >= 80 ) printf("A\n");
    else if ( f+m >= 65 ) printf("B\n");
    else if ( f+m >= 50 ) printf("C\n");
    else if ( f+m >= 30 ) {
      if ( r >= 50 ) printf("C\n");
      else printf("D\n");
    }
    else printf("F\n");
  }
  
  return 0;
}



Measured memory_bytes: 2088
str = input()
S = list(str)
N = len(S)
count = 0
for x in range(N):
    if x % 2 == 0 and S[x] == "0":
        count += 1
    elif x % 2 == 1 and S[x] == "1":
        count += 1
if count > N / 2:
    print(N - count)
else:
    print(count)


Measured memory_bytes: 3956
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		
		int N = sc.nextInt();
		
		List<Integer> cards = new ArrayList();
		
		for(int i = 0; i < N; i++) {
			int a = sc.nextInt();
			cards.add(a);
		}
		
		Collections.sort(cards);
		Collections.reverse(cards);
		
		
		int Alice = 0;
		int Bob = 0;
		
		for(int i = 0; i < cards.size(); i = i + 2) {
			Alice += cards.get(i);
			if(i+1 < cards.size()) {
				Bob += cards.get(i+1);	
			}
		}
		
		
		
		int sum = Alice - Bob;
		
		System.out.println(sum);
		
		
	}

}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int i,n;cin>>n;
  vector<int> a(n);
  for(i=0; i<n; ++i) cin>>a[i];
  long long dis,cnt=0;
  for(i=1; i<n; ++i) if(a[i]<a[i-1]) {dis=a[i-1]-a[i]; cnt+=dis; a[i]+=dis;}
  cout<<cnt<<endl;
  return 0;
}


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

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, a, b; cin >> n;
    int mx = 0, cnt = 0;

    for(int i=0; i<n; ++i)
    {
        cin >> a >> b;

        if(a == b) cnt++;
        else cnt = 0;

        mx = max(cnt,mx);
    }
    cout << ((mx>=3)? "Yes" : "No") << endl;


    return 0;
}


Measured memory_bytes: 3688
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  ll N,K,R,S,P,ans=0;
  string T;
  cin>>N>>K>>R>>S>>P>>T;
  
  ll CAN=1;
  
  for(int i=0; i<K; ++i){
    CAN=1;
    for(int j=0; j<=N/K+1; ++j){
      if(i+j*K<N){
        if(j>0 && T.at(i+(j-1)*K)==T.at(i+j*K)) CAN*=-1;
        if(j>0 && T.at(i+(j-1)*K)!=T.at(i+j*K)) CAN=1;
        if(T.at(i+j*K)=='r' && CAN>0) ans+=P;
        if(T.at(i+j*K)=='s' && CAN>0) ans+=R;
        if(T.at(i+j*K)=='p' && CAN>0) ans+=S;
      }
    }
  }
  
  co(ans);
  return 0;
}

Measured memory_bytes: 512
import java.util.*;

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

        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();
        int zero = 0;

        long left = A - K;
        if(A+B > K){
            if (left > 0) {
                System.out.printf("%d %d",left,B);
            } else {
                long left2 = B + left;
                System.out.printf("%d %d",zero,left2);
            }
        } else System.out.printf("%d %d",zero,zero);   
    }
}

Measured memory_bytes: 23764
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void)
{
	int i,n,k,p[1000],sum=0;
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++)	scanf("%d",&p[i]);
	sort(p,p+n);
	for(i=0;i<k;i++)	sum+=p[i];
	printf("%d\n",sum);
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	cout << fixed << setprecision(15);
	int n, k;
	cin >> n >> k;
	double ans = 0.0;
	for(int i = 1; i <= n; i++) {
		ans += 1.0/n * pow(0.5, max(ceil(log2((double)k/i)), 0.0));
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long ll;

vector<vector<ll>> memo(51, vector<ll>(51, -1));

ll comb(ll n, ll r) {
    if(memo[n][r] > 0){
        return memo[n][r];
    }
    if(n <= r){
        return 1;
    }
    if(r == 0){
        return 1;
    }
    return memo[n][r] = comb(n - 1, r - 1) + comb(n - 1, r);
}

int main(void) {
    int n, a, b;
    cin >> n >> a >> b;

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

    sort(v.begin(), v.end());

    vector<ll> acc(v);  // sum of [i, n)
    for (int i = n - 1; i > 0; i--) {
        acc[i - 1] += acc[i];
    }

    ll opt_num = -1;
    for (int i = a; i <= b; i++) {
        if (opt_num == -1 || acc[n - i] * opt_num > acc[n - opt_num] * i) {
            opt_num = i;
        }
    }

    cout << std::fixed << std::setprecision(8);
    cout << (1.0 * acc[n - opt_num] / opt_num) << endl;

    ll cnt = 0;
    for (int i = a; i <= b; i++) {
        if (acc[n - i] * opt_num != acc[n - opt_num] * i) {
            continue;
        }
        ll key = v[n - i];
        ll cntIn = 0;
        for (int j = n - i; j < n; j++) {
            if (v[j] == key) {
                cntIn++;
            }
        }

        ll cntOut = 0;
        for (int j = 0; j < n - i; j++) {
            if (v[j] == key) {
                cntOut++;
            }
        }
        cnt += comb(cntIn + cntOut, cntIn);
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <functional>

using namespace std;

vector<long long> A, B, C, AB, ABC;
int X, Y, Z, K;

int main()
{
    cin >> X >> Y >> Z >> K;
    A.resize(X);
    B.resize(Y);
    C.resize(Z);
    for (int i = 0; i < X; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < Y; i++)
    {
        cin >> B[i];
    }
    for (int i = 0; i < Z; i++)
    {
        cin >> C[i];
    }
    for (int i = 0; i < X;i++)
    {
        for (int j = 0; j < Y;j++)
        {
            AB.push_back(A[i] + B[j]);
        }
    }
    sort(AB.begin(), AB.end(), greater<long long>());
    int len = min((int)AB.size(), K);
    for (int i = 0; i < len; i++)
    {
        for (int j = 0; j < Z; j++)
        {
            ABC.push_back(AB[i] + C[j]);
        }
    }
    sort(ABC.begin(), ABC.end(), greater<long long>());
    for (int i = 0; i < K;i++)
    {
        cout << ABC[i] << endl;
    }
    return 0;
}

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

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

    char[] s = S.toCharArray();
    Arrays.sort(s);
    String result = String.valueOf(s).equals("abc") ? "Yes" : "No";

    System.out.println(result);

  }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int sx,sy,tx,ty;cin >> sx >> sy >> tx >> ty;
  int nx=sx,ny=sy;
  string s;
  while(ny<ty){++ny;s.push_back('U');}
  while(nx<tx){++nx; s.push_back('R');}
  while(ny>sy){--ny;s.push_back('D');}
  while(nx>sx){--nx; s.push_back('L');}
  --nx;s.push_back('L');
  while(ny<ty+1){++ny;s.push_back('U');}
  while(nx<tx){++nx; s.push_back('R');}
  --ny;s.push_back('D');
  ++nx;s.push_back('R');
  while(ny>sy-1){--ny;s.push_back('D');}
  while(nx>sx){--nx; s.push_back('L');}
  ++ny;s.push_back('U');
  cout << s << endl;
  return 0;
}


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

int main(){
    long long int a,b,n,x;
    cin>>a>>b>>n;
    if(b>n){
        x=n;
    }
    else{
        x=b-1;
    }
    cout<<a*x/b<<endl;

    return 0;
}

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

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

#define ll long long

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll n;cin>>n;
  vector<ll> a(n), dp;

  rep(i, n)cin>>a[i];

  rep(i, n){
    // 後ろから見ていった時に、a[i]以上の大きさの最初の要素のiterator
    auto it = lower_bound(dp.rbegin(), dp.rend(), a[i]);
    // a[i]よりも大きい値はなかったので末尾に追加する
    if(it == dp.rbegin()) dp.push_back(a[i]);
    else {
      // a[i]以上の大きさの値が見つかったので、「そのイテレータの一つ前の要素と入れ替える」
      // a[i]以上の最初の要素の一つ前、ということはa[i]未満の要素ということ、
      // a[i]未満なのでその単調増加数列はa[i]を末尾に追加可能
      it--;
      *it = a[i];
    }

//rep(i, dp.size()) cout<<dp[i]<<' ';cout<<endl;
  }

//rep(i, dp.size()) cout<<dp[i]<<' ';cout<<endl;

  cout<<dp.size()<<endl;

  return 0;
}


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

int n, m;
int a[10][10];

const long mod = 2019;
int main() {
  long l, r;
  cin >> l >> r;
  
  long mn = mod;
  for (long i = l; i <= min(r, l + mod); ++i) {
    for (long j = i + 1; j <= min(r, i + 1 + mod); ++j) {
      mn = min(mn, i * j % mod);
    }
  }
  cout << mn << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <deque>
#include <algorithm>
#include <map>
#include <string>
#include <set>
#include <iostream>
#include <fstream>
#include <iterator>
#include <math.h>
#include <stdlib.h>

using namespace std;

vector<int> makeRandomVec(int n, int max){
    vector<int> vec;
    srand((int)time(0));
    for(int i = 0; i < n; i++){
        vec.push_back(rand() % (max + 1));
    }
    return vec;
}

// ???????±??§£??°???????????§??°
int findMaxNumWithRec(vector<int> nums,int l , int r){
    if(l==r){
        return nums[l];
    }
    int m = (l + r) /2;
    int maxNum;
    maxNum = max(findMaxNumWithRec(nums,l,m), findMaxNumWithRec(nums,m+1,r));
    return maxNum;
}

int solve(int i, int m,int arr[],int n){
    if(m == 0){
        return 1;
    }
    if(i>= n){
        return 0;
    }
    int res = solve(i+1,m,arr,n) || solve(i+1,m-arr[i],arr,n);
    return res;
}


int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i = 0; i < n; i++){
        cin>>arr[i];
    }
    int q;
    cin>>q;
    int m;
    while(q--){
        cin>>m;
        if(solve(0,m,arr,n)){
            printf("yes\n");
        }else {
            printf("no\n");
        }


    };










}

Measured memory_bytes: 3076
N=gets.to_i
a1=gets.split.map(&:to_i)
a2=gets.split.map(&:to_i)

i = 1
s1 = a1[0]
s2 = a1[0]+a2[0]
while i < N
    s1 += a1[i]
    s2 = [s1,s2].max + a2[i]
    i += 1
end

puts s2


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

#define endl '\n'
#define ll long long
#define int long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

#define db  long double;
#define pll pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

long long  powmod(long long  x, long long  k)
{
	long long  ans = 1;
	for (; k; k >>= 1, x = (x * x) % hell)
		if (k & 1)
			ans = (ans * x) % hell;
	return ans % hell;
}


ll f[200009], inv[200009];

ll ncr(ll n, ll r) {
	ll z = f[n];
	z *= inv[r];
	z %= hell;
	z *= inv[n - r];

	z %= hell;
	return z;
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t, i, x, j, y, 	z, k, n;
	cin >> n >> k;
	// n++;
	// f[0] = 1;
	// inv[0] = powmod(1, hell - 2);
	// rep(i, 1, n + 2, 1)	{
	// 	f[i] = ( f[i - 1] * i) % hell;
	// 	inv[i] = powmod(f[i], hell - 2);
	// }
	z = 0;

	i = k - 1, j = n - k ;

	rep(k, k, n + 2, 1) {

		x = (i * i + i) / 2;
		y = (n * n + n) / 2 - (j * j + j) / 2;
		// ce(x << " " << y)
		j--, i++;
		t = y - x + 1;
		z = z + t;

		z %= hell;
		// z += hell ;
	}
	z %= hell;
	ce(z)
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    string S;
    int N;
    cin >> S >> N;
    for(char &c:S){
        if(c != 'a' && 'z'-c+1 <= N){
            N -= 'z' - c + 1;
            c = 'a';
        }
    }
    S.back() = (S.back()-'a'+N%26)%26+'a';
    cout << S << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;
const int MOD=1e9+7;
typedef long long ll;
int q;
int H,W,K;
ll dp[105][10];
//bool accros[105][10];
int main(int argc,char const* argv[])
{
  memset(dp,0,sizeof(dp));
  dp[0][0]=1;
  cin >> H >> W >> K;
  for(int i=0;i<H;i++)
    {
      for(int j=0;j<W;j++)
	{
	  if(dp[i][j]==0) continue;
	  for(int bit=0;bit<(1<<(W-1)); bit++)//横線の置き方は2^(W-1)通り
	    {
	      //横線が隣り合うパターンも含め全列挙
	      bool ok=true;
	      for(int i=0;i<W-2;i++)
		{
		  if((bit >> i & 1) and (bit >> (i+1) & 1)) ok=false;
		  //横線が隣り合うパターンは無視される
		}
	      if(ok)//横線が隣合わないパターンだけ確認
		{
		  //cerr << "bit = " << bitset<10>(bit).to_string() << endl;
		  if(j>0 and (bit >> (j-1) & 1))
		    {
		      dp[i+1][j-1]=(dp[i+1][j-1]+dp[i][j])%MOD;
		    }
		  else if(bit >> j & 1)
		    {
		      dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%MOD;
		    }
		  else
		    {
		      dp[i+1][j]=(dp[i+1][j]+dp[i][j])%MOD;
		    }
		}
	    }
	}
    }
  cout << dp[H][K-1] << endl;
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    set<int> S;
    set<int> T;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        S.insert(a);
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int a;
        cin >> a;
        T.insert(a);
    }
    set<int> result;
    set_intersection(S.begin(), S.end(), T.begin(), T.end(),
                     inserter(result, result.end()));
    cout << result.size() << endl;
    return 0;
}

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

int main(){
	const int MAX = 20;
	const int MIN = 0;
	
	int num;
	std::cin >> num;

	std::vector< std::vector<long int> > equation((num - 1), std::vector<long int>((MAX + 1), 0));
	int value;
	std::cin >> value;
	equation[0][value] = 1;	//最初に等式の数を1とセットする．
	for(int i = 0; i < (num - 2); ++i){
		std::cin >> value;
		for(int j = 0; j <= MAX; ++j){
			if((j + value) <= MAX){
				equation[i + 1][j] += equation[i][j + value];
			}
			if((j - value) >= MIN){
				equation[i + 1][j] += equation[i][j - value];
			}
		}
	}
	std::cin >> value;
	std::cout << equation[num - 2][value] << std::endl;
	return 0;
}

Measured memory_bytes: 1228
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			if(n==0)break;
			int sum=0;
			for(int i=0;i<n/4;i++){
				int h=sc.nextInt();
				sum+=h;
			}
			System.out.println(sum);
		}
	}

}

Measured memory_bytes: 18356
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)



int main(){
    int n,b; cin >> n;
    int A[n];
    rep(i,n){
        cin >> A[i];
        A[i] -= (i+1);
    }
    sort(A,A+n);
    long long ans = 0;
    b = A[n/2];
    rep(i,n){
        ans += abs(A[i] - b);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
str_n = str(n)
n_1 = str_n[0]
tmp = int(n_1+"9"*(len(str_n)-1))
ans = int(n_1) + 9*(len(str_n)-1)

if n == tmp:
    print(ans)
else:
    print(ans-1)


Measured memory_bytes: 2940
#include <stdio.h>          // printf(), scanf()
#include <string.h>         // strlen()

#define L_MAX 1000
#define min(a, b) ((a) < (b) ? (a) : (b))

int
main(int argc, char** argv)
{
	char s[L_MAX + 1];
	char t[L_MAX + 1];
	int dp[L_MAX + 1][L_MAX + 1];
	int i, j;

	scanf("%s", s);
	scanf("%s", t);

	int u = strlen(s);
	int v = strlen(t);
	for (i = 0; i <= u; ++i)
		dp[i][0] = i;

	for (j = 1; j <= v; ++j)
		dp[0][j] = j;

	for (i = 1; i <= u; ++i)
	{
		for (j = 1; j <= v; ++j)
		{
			int cost = (s[i - 1] == t[j - 1]) ? 0 : 1;
			dp[i][j] = min(dp[i - 1][j] + 1, dp[i][j - 1] + 1);
			dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + cost);
		}
	}

	printf("%d\n", dp[u][v]);
	return 0;
}

Measured memory_bytes: 4452
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
double cross(const Pd &o, const Pd &a, const Pd &b){
  return (a.first - o.first) * (b.second - o.second) - (a.second - o.second) * (b.first - o.first);
}

vector<Pd> convex_hull(vector<Pd> vec){
  int n = vec.size(), k = 0;
  if(n < 3)return vec;

  vector<Pd> ch(2 * n);
  sort(vec.begin(), vec.end());

  // lower
  for(int i = 0; i < n; i++){
    while(k >= 2 && cross(ch[k-2], ch[k-1], vec[i]) <= 0.)k--;
    ch[k++] = vec[i];
  }

  // upper
  for(int i = n - 1, t = k + 1; i > 0; --i){
    while(k >= t && cross(ch[k-2], ch[k-1], vec[i-1]) <= 0.)k--;
    ch[k++] = vec[i-1];
  }

  ch.resize(k - 1);
  return ch;

}

int main(int argc, char const* argv[])
{
  double x[8];
  string s;
  while(cin >> s){
    s += ",";
    string tmp = "";
    int at = 0;
    rep(i, s.size()){
      if(s[i] == ','){
        x[at] = stod(tmp);
        at++;
        tmp = "";
      }else{
        tmp += s[i];
      }
    }
    vector<Pd> vec;
    rep(i, 4){
      vec.pb(mk(x[2 * i], x[2 * i + 1]));
    }
    vector<Pd> ch = convex_hull(vec);
    if(ch.size() == 4)cout << "YES" << endl;
    else cout << "NO" << endl;
  }
	return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n, k; cin >> n >> k;
  ++k;
  int D = Log2(k);

  Vll a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];

  ll ans = 0;
  rep(d, D) {
    ll csum = 0;
    rep(i, n) {
      int x = a[i]>>d;
      int y = k>>d;
      if ((x|y) != y) continue;
      if ((x&1) >= (y&1)) continue;
      csum += b[i];
    }
    chmax(ans, csum);
  }

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


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

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

    vector<long long> a(n+1);
    vector<long long> b(n);
    for (long long i = 0; i < n+1; i++) cin >> a[i];
    for (long long i = 0; i < n; i++) cin >> b[i];

    long long beaten1 = 0;
    for (long long i = n; i >= 1; i--) {
        long long diff = min(a[i], b[i-1]);
        long long diff2 = min(a[i-1], abs(b[i-1] - diff));
        beaten1 += diff;
        beaten1 += diff2;
        a[i-1] -= diff2;
    }

    // int beaten2 = 0;
    // for (int i = 0; i < n+1; i++) {
    //     int diff = min(a[i], b[i]);
    //     int diff2 = min(a[i+1], abs(b[i] - diff));
    //     beaten2 += diff;
    //     beaten2 += diff2;
    //     a[i+1] -= diff2;
    // }

    // cout << beaten1 << " " << beaten2 << endl;

    cout << beaten1 << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  int D;
  cin >> D;
  vector<int>c (26);
  for(int i = 0;i < 26;i++){
    cin >> c.at(i);
  }
  vector<vector<int>> s(D, vector<int>(26));
  for(int i = 0;i < D;i++){
    for(int j = 0;j < 26;j++){
      cin >> s.at(i).at(j);
    }
  }
  long long int Sa = 0;
  int d = 0;
  vector<int>last (26);
  for(int i = 0;i < 26;i++){
    last.at(i) = 0;
  }
  for(int i = 0;i < D;i++){
    int type = -1;
    d += 1;
    //ここにプログラムを追記
    cin >> type;
    last.at(type - 1) = d;
    Sa += s.at(d - 1).at(type - 1);
    for(int i = 0;i < 26;i++){
      Sa -= c.at(i) * (d - last.at(i));
    }
    //ここから先は変更しない
    cout << Sa << endl;
  }
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int main(){
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if(s == u) cout << a-1 << " " << b << "\n";
    else cout << a << " " << b-1 << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n=0,count=0,max=0;
	string s;
	cin>>n>>s;
	for(int j=0;j<n;j++){
		if(s[j]=='I')
		   count++;
		else
		   count--;
		if(max<count)
		    max=count;      
	}
	cout<<max;
}

Measured memory_bytes: 384
N, M = map(int, input().split())
data = [[] for _ in range(N + 1)]
for i in range(M):
    x, y = map(int, input().split())
    data[x].append(y)
    data[y].append(x)

for i in range(1, N + 1):
    print(len(data[i]))


Measured memory_bytes: 9128
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        long[] A = new long[N];
        long[] S = new long[N+1];
        long[] T = new long[N+1];
        long sum = 0;
        S[0] = 0;
        T[0] = 0;
        Map<Long,Long> map = new HashMap<>();
        map.put(T[0],0L);
        int i=0;
        Long tmp;
        while (i<N) {
            A[i] = Integer.parseInt(sc.next());
            S[i+1] = S[i] + A[i];
            T[i+1] = ((S[i+1] - i-1)%K+K)%K;
            if(i+1<K){
                if((tmp=map.get(T[i+1]))!=null){
                    map.put(T[i+1],tmp+1);
                }else{
                    map.put(T[i+1],0L);
                }
            }
            i++;
        }
        sum+= map.get(T[0]);
        for(i=1;i<N;i++){
            tmp = map.get(T[i-1]);

            if(tmp==0){
                map.put(T[i-1],null);
            }else{
                map.put(T[i-1],tmp-1);
            }
            if(i+K-1<=N){
                if((tmp=map.get(T[i+K-1]))!=null){
                    map.put(T[i+K-1],tmp+1);
                }else{
                    map.put(T[i+K-1],0L);
                }
            }
            sum+=map.get(T[i]);
        }
        System.out.println(sum);
      System.out.flush();
    }
}

Measured memory_bytes: 83604
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr char sp=' ';
constexpr ll mod=1000000007;

ll H,W;

int main(){
	cin>>H>>W;
	if(H==1||W==1){
		cout<<1<<endl;
	}
	else{
		cout<<(H*W+1)/2<<endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int x,y,z,k;
  cin>>x>>y>>z>>k;
  LL a[x], b[y], c[z];
  REP(i, x) cin>>a[i];
  sort(a, a+x, greater<LL>());
  REP(i, y) cin>>b[i];
  sort(b, b+y, greater<LL>());
  REP(i, z) cin>>c[i];
  sort(c, c+z, greater<LL>());

  vector<LL> ans;
  vector<LL> combo;

  REP(i, x){
    REP(j, y){
      combo.push_back(a[i]+b[j]);
    }
  }

  sort(combo.begin(), combo.end(), greater<LL>());

  int s = combo.size();
  s = min(s, k);
  REP(i, s){
    REP(j, z){
      ans.push_back(combo[i] + c[j]);
    }
  }
  sort(ans.begin(), ans.end(), greater<LL>());


  REP(i, k) cout<<ans[i]<<endl;

  return 0;
}


Measured memory_bytes: 43360
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;
        static void Main(string[] args)
        {
            var ABCD = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var A = ABCD[0];
            var B = ABCD[1];
            var C = ABCD[2];
            var D = ABCD[3];

            var divC = B / C - (A - 1) / C;
            var divD = B / D - (A - 1) / D;
            var l = Lcm(C, D);
            var divCD = B / l - (A - 1) / l;
            var ret = (B - A + 1) - (divC + divD - divCD) ;
            Console.WriteLine(ret);
        }
        public static long Lcm(long a, long b)
        {
            return a * (b / Gcd(a, b));
        }
        public static long Gcd(long a, long b)
        {
            if (a < b)
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

    }
}

Measured memory_bytes: 13396
#include<iostream>
using namespace std;
int gcd(int a, int b) { if (b == 0)return a; return gcd(b, a%b); }
int main() {
	int n, p, t, a; cin >> n >> p; t = n;
	for (int i = 0; i < p; i++) {
		cin >> a; t = gcd(t, a);
	}
	if (t >= 2)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3100
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

void solve(){
    int n;
    cin>>n;
    ll t,a;
    cin>>t>>a;
    ll x=t,y=a;
    rep(i,n-1){
        cin>>t>>a;
        ll maxv=max((x+t-1)/t,(y+a-1)/a);
        x=maxv*t;
        y=maxv*a;
    }
    cout<<x+y<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

// ABC 48-C
// http://abc048.contest.atcoder.jp/tasks/arc064_a

public class Main {
	
	static int MOD = 1000000007;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		long[] candies = new long[n];
		long x = in.nextLong();
		
		for (int i = 0; i < n; i++) {
			candies[i] = in.nextLong();
		}
		
		long answer = 0;
		for (int i = 1; i < n; i++) {
//			int sum = candies[i - 1] + candies[i];
//			if (sum > x) {
//				int diff = sum - x;
//				answer += diff;
//				if (diff <= candies[i]) {
//					candies[i] -= diff;
//				} else {
//					candies[i] = 0;
//				}
//			}
			long sum = candies[i - 1] + candies[i];
			long k = Math.max(0, sum - x);
			answer += k;
			candies[i] = Math.max(0, candies[i] - k);
		}
		
		System.out.println(answer);
	}
}

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

int isPrime(int x)
{
    for(int i=2; i*i<x; i++){
        if(x%i == 0){
            return false;
        }
    }
    return true;
}

int main()
{
    int X;
    cin >> X;
    for(;!isPrime(X);X++);
    cout << X << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	int k, x;
	cin >> k >> x;
	for(int i=x-k+1; i<x+k; ++i)
		cout << i << " ";
	cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main( void ) {

  while( 1 ) {
    int i, digit;
    char ch[ N ];
    double stack[ N ];
    int top = 0;
    int num;

    for( i = 0; i < N; i++ ) {
      if( scanf( "%c", &ch[ i ] ) != 1 )  break;
      if( ch[ i ] == '\n' )               break;
    }
    if( i == 0 ) break;

    digit = i;

    for( i = 0; i < digit; i++ ) {
      if( '0' <= ch[ i ]  && ch[ i ] <= '9' ) {
        num = ch[ i ] - '0';
        for( i++; ( i < digit ) && ( '0' <= ch[ i ] && ch[ i ] <= '9' ); i++ ) {
          num *= 10;
          num += ch[ i ] - '0';
        }
        stack[ top++ ] = ( double )num;
      } else if( ch[ i ] == '+' ) { stack[ top-2 ] += stack[ top-1 ]; top--;
      } else if( ch[ i ] == '-' ) {
        if( '0' <= ch[ i+1 ] && ch[ i+1 ] <= '9' ) {
          num = ch[ i+1 ] - '0';
          for( i++; ( i+1 < digit ) && ( '0' <= ch[ i+1 ] && ch[ i+1 ] <= '9' ); i++ ) {
            num *= 10;
            num += ch[ i+1 ] - '0';
          }
          stack[ top++ ] = ( double )-num;
        } else {
          stack[ top-2 ] -= stack[ top-1 ]; top--;
        }
      } else if( ch[ i ] == '*' ) { stack[ top-2 ] *= stack[ top-1 ]; top--;
      } else if( ch[ i ] == '/' ) { stack[ top-2 ] /= stack[ top-1 ]; top--;
      }
    }

    printf( "%f\n", stack[ 0 ] );
  }

  return( 0 );
}

Measured memory_bytes: 0