akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<bits/stdc++.h>
#include<vector>
#include<math.h>

using namespace std;

int main()
{
   long long n, x, total = 0;

   cin >> n >> x;

   vector<long long> hp;

   for(int i = 0; i < n; i++)
   {
      long x;
      cin >> x;
      hp.push_back(x);
   }

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

   for(int i = 0; i < n; i++)
   {
      total = total + hp[i];
   }

   if(total < x)
      cout << n - 1;
   else if(total == x)
   {
      cout << n;
   }

   else
   {
      long long i = 0;
      while(x < total)
      {
         total = total - hp[n-1-i];
         i++;
      }

      cout << n - i;
   }
   
   
}

Measured memory_bytes: 3544
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
    int A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;
    
    vector<int> x,y;
    for (int i=0; 100*A*i<=F; i++) {
        for (int j=0; (100*B*j)+(100*A*i)<=F; j++) {
            if ((100*B*j)+(100*A*i)!=0) {
                x.push_back((100*B*j)+(100*A*i));
            }
        }
    }
    
    for (int i=0; C*i<=F; i++) {
        for (int j=0; (D*j)+(C*i)<=F; j++) {
            //if ((D*j)+(C*i)!=0) {
                y.push_back((D*j)+(C*i));
            //}
        }
    }
    int ans_x_plus_y=0, ans_y=0;
    float genkai_nodo=(float)E/((float)E+100.0),max_nodo=0.0;
    int x_size=x.size();
    int y_size=y.size();
    for (int index_x=0; index_x<x_size; index_x++) {
        for (int index_y=0; index_y<y_size; index_y++) {
            if (x[index_x]+y[index_y]<=F) {
                float nodo=(float)y[index_y]/((float)x[index_x]+(float)y[index_y]);
                if (genkai_nodo>=nodo && max_nodo<=nodo) {
                    max_nodo=nodo;
                    ans_x_plus_y=x[index_x]+y[index_y];
                    ans_y=y[index_y];
                }
            }
            
        }
    }
    
    cout << ans_x_plus_y << " " << ans_y << " " << endl;
}


Measured memory_bytes: 1400
#include <stdio.h>

int main(){
	
	int a;
	int b;
	int total;
	scanf("%d", &a);
	scanf("%d", &b);
	total=a+b;
	
	if(total>=24){
	total=total-24;
	printf("%d", total);}
	else{
	printf("%d", total);}
	
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 1e5 + 5;
struct pfs{
	int IndexPre;
	int IndexPreCity;
};
pfs pf[maxn];
void out(pfs a)
{
	printf("%06d%06d\n",a.IndexPre,a.IndexPreCity);
}
priority_queue< pair<int,int> , vector< pair<int,int> > , greater< pair<int,int> > > a[maxn];
int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	for(int i = 0;i < m; ++i)
	{
		int x,y;
		cin>>x>>y;
		a[x].push({y,i + 1});
	}
	for(int i = 1;i <= n; ++i)
	{
		int cnt = 0;
		while(!a[i].empty())
		{
			auto now = a[i].top();
			a[i].pop();
			cnt++;
			pf[now.second].IndexPre = i;
			pf[now.second].IndexPreCity = cnt;
		}
	}
	for(int i = 1;i <= m; ++i)
	{
		out(pf[i]);
	}
	return 0;
}

Measured memory_bytes: 8576
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]
            var line = ReadLine();
            int a = line[0];
            int b = line[1];
            int c = line[2];

            if (CanDivided(a, b, c))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static bool CanDivided(int a, int b, int c)
        {
            if (a + b == c)
            {
                return true;
            }
            else if (a + c == b)
            {
                return true;
            }
            else if (b + c == a)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
while 1:
    n = int(raw_input())
    if (n == 0):
        break
    num = 0

    if (n == 1):
        num = 1
    if (n == 2):
        num = 2
    if (n == 3):
        num = 4
    if (n > 3):
        a1 = 1
        a2 = 2
        a3 = 4
        for i in range(n - 3):
            num = a1 + a2 + a3
            a1 = a2
            a2 = a3
            a3 = num
    
    years = num % 3650
    if (years != 0):
        years = 1
    years = years + num / 3650
    
    print years

Measured memory_bytes: 4224
#include <iostream>
using namespace std;
int main(){ 
    int n; cin >> n;
    bool can=false;
    for (int i=0;i<=n/4;++i){
        for (int j=0;j<=n/7;++j){
            if (4*i+j*7==n) can=true;
        }
    }
    cout << (   (can) ? "Yes" : "No" )<< endl;
}

Measured memory_bytes: 256
n, y = gets.strip.split.map(&:to_i)
_i, _j, _k = -1, -1, -1

(0..n).each do |i|
  (0..n-i).each do |j|
    if i * 10000 + j * 5000 + (n - i -j) * 1000 == y
      _i, _j, _k = i, j, n -i -j
    end
  end
end

puts "#{_i} #{_j} #{_k}"


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

#define YesNo(b) ((b) ? "Yes" : "No")
#define YESNO(b) ((b) ? "YES" : "NO")

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;



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

    vi snuke(N, 0);
    for (int k = 0; k < K; k++)
    {
        int d;
        cin >> d;
        for (int i = 0; i < d; i++)
        {
            int a;
            cin >> a;
            ++snuke[a-1];
        }
    }
    
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (snuke[i] == 0) ++ans;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int H, W;
int c[10][10];
int A[256][256];

int main(void) {
	int i, j, k;
	int answer = 0;
	if (scanf("%d%d", &H, &W) != 2) return 1;
	for (i = 0; i <= 9; i++) {
		for (j = 0; j <= 9; j++) {
			if (scanf("%d", &c[i][j]) != 1) return 1;
		}
	}
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (scanf("%d", &A[i][j]) != 1) return 1;
		}
	}

	for (k = 0; k <= 9; k++) {
		for (i = 0; i <= 9; i++) {
			for (j = 0; j <= 9; j++) {
				if (c[i][j] > c[i][k] + c[k][j]) {
					c[i][j] = c[i][k] + c[k][j];
				}
			}
		}
	}
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (A[i][j] != -1) answer += c[A[i][j]][1];
		}
	}

	printf("%d\n", answer);
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int n, b[110], sum;
  cin >> n;
  for (int i = 0; i < n - 1; ++i) cin >> b[i];
  sum = b[0];
  for (int i = 0; i < n - 1; ++i)
  {
    if (i != n - 2)
    {
      if (b[i] > b[i + 1]) sum += b[i + 1];
      else sum += b[i];
    }
    else
      sum += b[i];
  }
  cout << sum;
}


Measured memory_bytes: 3640
#include<stdio.h>//文章中にその言葉が使われた数を出す//
#include<stdlib.h>
#include<string.h>

int check(char [],int);

int main (void){

	int i,count=0,counter=0,pod;
	char get,search[100];

	for(i=0;;i++){//探す文字を入力//
		get=getchar();
		if(get=='\n'){
			search[i]='\0';
			break;
		}
		search[i]=get;
		count++;

	}
	while(1){
		pod=check(search,count);
		if(pod==-1)
			break;
		counter+=pod;
	}
	printf("%d\n",counter);
	
	return 0;
}
	
int check(char search[],int count){

	int i,j;
	char word[1000],out[100]="END_OF_TEXT";

	scanf("%s",word);
	if(strcmp(out,word)==0){//入力された文字がEND_OF_TEXTなら-1を返して終了する//
		return -1;
	}
	if(strlen(word)!=strlen(search))//探す文字と文章の単語の長さが違ったら0を返す//
		return 0;
	for(i=0;i<count;i++){
		for(j=0;j<count;j++){
			if(word[i] != search[j]&&
			word[i] + 32 != search[j]&&
			word[i] - 32 != search[j]){//探していた文字の大文字でも小文字でもなかったらflagを建てる//
				return 0;
			}
			else i++;
		}
	}
	return 1;
}

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

int main() {
string N;
cin >> N;
string ans;
for (int i = 0; i < N.length(); i++)
{
    if (N.at(i) == '7')
    {

       ans = "Yes";
       break;
       }
    
    else
    {
        ans = "No";
    }
    
}

cout << ans << endl;

}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int array[] = new int[M];
		Integer arrayAbs[] = new Integer[M - 1];

		for (int i = 0; i < M; i++) {
			array[i] = sc.nextInt();
		}
		Arrays.sort(array);

		for (int i = 0; i < M-1; i++) {

				arrayAbs[i] = Math.abs(array[i] - array[i+1]);

		}
		Arrays.sort(arrayAbs);
		
		int min = 0;
		for (int i = 0; i < arrayAbs.length - N + 1; i++) {
			min += arrayAbs[i];
		}

		System.out.println(min);
	}

}


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

int main ()
{
    int a, b, x;
    cin >> a >> b >> x;
    if (a <= x && a+b >= x){
        cout << "YES\n";
    }
    else
        cout << "NO\n";
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main( void )
{
    cout << fixed << setprecision(11);
    long double N, K;
    cin >> N >> K;

    long double result = 0;
    if(N >= K){
        result += (N-K+1)/N;

        long double tmp = 0;
        for(int i=1;i<=K-1;i++){
            tmp += pow(0.5L, ceil(log2(K/i))) / N;
        }

        result += tmp;
    }else{

        long double tmp = 0;
        for(int i=1;i<=N;i++){
            tmp += pow(0.5L, ceil(log2(K/i))) / N;
        }

        result += tmp;
    }

    cout << result;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

int main(){
    int n,a;
    cin >>n>>a;
    cout << n*n-a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define P pair<long,long>
#define all(a) a.begin(),a.end()
using namespace std;

signed main(){
    int n; cin>>n;
    vector<int> a(n);
    vector<int> rate(8,0);
    int cnt1=0,cnt2=0;
    rep(i,n){
        cin>>a.at(i);
        if(a.at(i)<3200){
            if(rate.at(a.at(i)/400)==0){
                rate.at(a.at(i)/400)=1;
                cnt2++;
            }
        }else{
            cnt1++;
        }
    }
    if(cnt2==0){
        cout<<1<<' '<<cnt1<<endl;
    }else{
        cout<<cnt2<<' '<<cnt1+cnt2<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[100000],cnt[100000];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n-1;i++){cin>>a[i];cnt[i]=0;}
	int bef,now,z;
	cin>>bef;now=bef;
	for(int i=0;i<bef;i++)cnt[i]++;
	for(int i=0;i<m-1;i++){
		cin>>z;now+=z;
		if(bef<now)for(int j=bef;j<now;j++)cnt[j]++;
		if(bef>now)for(int j=now;j<bef;j++)cnt[j]++;
		bef=now;
	}
	int ans=0;
	for(int i=0;i<n-1;i++){
		ans+=cnt[i]*a[i]%100000;
		ans%=100000;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1940
#n=int(input())
#n,m=map(int,input().split())
#sl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

s=list(input())
n=len(s)

#最初が0のリスト
goal1=["1" if i%2==0 else "0" for i in range(n)]
count1=0
#最初が1のリスト
goal2=["0" if i%2==0 else "1" for i in range(n)]
count2=0
for i in range(n):
    if goal1[i]!=s[i]:
        count1+=1
    if goal2[i]!=s[i]:
        count2+=1

print(min(count1,count2))

Measured memory_bytes: 5420
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n);i>0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+5  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=1000005;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


//////////////////////////////////////
int main(){
    int a,b;
    cin>>a>>b;
    int ans=max(a+b,max(a-b,a*b));
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cmath>
#include <vector>

#define INC(i, a, b) for(int i = a; i < b; ++i)
#define DEC(i, a, b) for(int i = a; i > b; --i)
#define REP(i, n) INC(i, 0, n)

typedef unsigned int uint;
typedef unsigned long ul;
typedef long long  ll;
typedef unsigned long long ull;

using namespace std;

void TFprint(bool b, std::string T, std::string F){
    if(b){
        std::cout << T << std::endl;
    }else{
        std::cout << F << std::endl;
    }
}

typedef struct{
    ll amount;
    double price;
    ll p;
}tea;

bool comp(const tea& lt, const tea& rt)
{
  return lt.price < rt.price;
}

int main(){
    tea q, h, s, d;

    q.amount = -2;
    h.amount = -1;
    s.amount = 0;
    d.amount = 1;

    cin >> q.p, q.price = q.p * 4.0;
    cin >> h.p, h.price = h.p * 2.0;
    cin >> s.p, s.price = s.p * 1.0;
    cin >> d.p, d.price = d.p * 0.5;

    ll n; cin >> n;

    vector<tea> t;
    t.push_back(q), t.push_back(h), t.push_back(s), t.push_back(d);
    sort(t.begin(), t.end(), comp);

    ll ans = 0;

    REP(i, 4){

        if(n == 0){
            break;
        }

        ll buy;
        if(t[i].amount >= 0){
            buy = n >> t[i].amount;
            ans += buy * t[i].p;
            n -= (1 << t[i].amount) * buy;
        }
        else{
            buy = n << (-t[i].amount);
            ans += buy * t[i].p;
            n = 0;
        }

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

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

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

    vector<int> mount(N);
    for(int i=0;i<N;i++){
        cin >> mount.at(i);
    }

    int high = mount.at(0);
    int ans = 1;

    for(int j=0;j<N;j++){
        if(high <= mount.at(j) && j != 0){
            high = mount.at(j);
            ans++;
        }        
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int ans = 0;
  for (int ii=0; ii<4; ++ii) {
    char c;
    cin >> c;

    if (c=='+')
      ++ans;
    else if (c=='-')
      --ans;
  }

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

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("sse3","sse2","sse")
#pragma GCC target("avx","sse4","sse4.1","sse4.2","ssse3")
#pragma GCC target("f16c")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#pragma GCC diagnostic error "-std=c++14"
#include "bits/stdc++.h"
//#include "ext/pb_ds/tree_policy.hpp"
//#include "ext/pb_ds/assoc_container.hpp"
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) (x&(-x))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9+7;
const ll inf = 1e9+7;
const ld eps = 1e-9;
const db PI = atan(1)*4;
template<typename T>
inline int sign(const T&a) {
    if(a<0)return -1;
    if(a>0)return 1;
    return 0;
}

template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;}

template<typename T> inline void in(T &x) {
    x = 0;
    T f = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (isdigit(ch))  {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    x *= f;
}

ll twop(int x) {
    return 1LL<<x;
}

template<typename A,typename B > inline void in(A&x,B&y) {
    in(x);
    in(y);
}
template<typename A,typename B,typename C>inline void in(A&x,B&y,C&z) {
    in(x);
    in(y);
    in(z);
}
template<typename A,typename B,typename C,typename D> inline void in(A&x,B&y,C&z,D&d) {
    in(x);
    in(y);
    in(z);
    in(d);
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
namespace SOLVE {
    void main(){
        
        
        
        ll n;cin>>n;
        ll ans = 0;
        REP(i,0,n){
            ll c;in(c);
            while(c%2==0){ans++;c/=2;}
        }
        cout<<ans;
    }
}


int main() {

    
    
    
    
    
    
    
    
    
    SOLVE::main();
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  print_endline @@
  if
    ( = ) n @@
    List.length @@
    List.sort_uniq compare @@
    Array.to_list as_
  then "YES"
  else "NO"

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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

int main() {
    lld a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

ll spow(int a,int n){
  if(n == 0) return 1;
  return a*spow(a,n-1);
}

int main(){
  ll n,k;
  cin >> n >> k;
  if(k%2) cout << spow(n/k,3) << endl;
  else cout << spow(n/k,3) + spow(2*n/k - n/k,3) << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[] args)throws IOException {
		InputStreamReader read=new InputStreamReader(System.in);
		BufferedReader in=new BufferedReader(read);
		int x=Integer.parseInt(in.readLine());
		long ans=0;
		while(x>=500)
		{
		    ans+=1000;
		    x-=500;
		}
		while(x>=5)
		{
		    ans+=5;
		    x-=5;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  string s;
  cin >> s;
  map<char, int> cnt;
  for(char a : s) cnt[a]++;

  bool ok = true;
  for(auto p : cnt) {
    if(p.second&1) ok = false;
  }
  cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		
		while (sc.hasNextInt()) {
			a[sc.nextInt() - 1]++;
		}
		
		Arrays.sort(a);
		
		for (int i = 0; i < n / 2; i++) {
			int tmp = a[i];
			a[i] = a[n - i - 1];
			a[n - i - 1] = tmp;
		}
		
		int s = 0;
		for (int i = 0; i < k; i++) {
			s += a[i];
		}
		System.out.println(n - s);
	}
}


Measured memory_bytes: 91000
#include <iostream>
#include <vector>
#define MAX_V 1000

using namespace std;
vector<int> G[MAX_V];
int m,V,color[MAX_V],sum1,sum2,c[1000],d[1000],num=0;
bool dp[1000][1000],mp[1000][1000];
bool dfs(int v, int c){
	color[v]= c;
	if(c==1){
		sum1++;
	}else{
		sum2++;
	}
	for(int i=0;i<G[v].size();i++){
		if(color[G[v][i]]==c) return false;
		if(color[G[v][i]]==0 && !dfs(G[v][i],-c)) return false;
	}
	return true;
}

int main(){
	cin >> V >> m;
	int i,j;
	for(i=1;i<=V;i++){
		for(j=1;j<=V;j++){
			mp[i][j] = true;
		}
	}
	for(i=0;i<m;i++){
		int a,b;
		cin >> a >> b;
		mp[a][b] = false;
		mp[b][a] = false;
	}
	
	for(i=1;i<=V;i++){
		for(j=1;j<=V;j++){
			if(mp[i][j] && i!=j){
				G[i].push_back(j);
			}
		}
	}
	
	for(i=1;i<=V;i++){
		color[i] = 0;
	}
	
	for(i=1;i<=V;i++){
		sum1 = 0; sum2 = 0;
		if(color[i]==0){
			if(!dfs(i,1)){
				cout << -1 << endl;
				return 0;
			}
			c[num] = sum1;
			d[num] = sum2;
			num++;
		}
	}
	
	for(i=0;i<710;i++){
		for(j=0;j<710;j++){
			dp[i][j] = false;
		}
	}
	dp[0][0] = true;
	
	for(i=0;i<num;i++){
		for(j=0;j<1000;j++){
			if(dp[i][j]){
				dp[i+1][j+c[i]] = true;
				dp[i+1][j+d[i]] = true;
			}
		}
	}
	
	for(i=V/2;i>=0;i--){
		if(dp[num][i]){
			cout << V*(V-1)/2 - i*(V-i) << endl;
			return 0;
		}
	}
}
	

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define bear ryan
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define ends ' '
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll inf = 1e9;

ll n, ans = 1;

int main(void) {
    fastio;
    cin >> n;
    ll t = n - 1;
    for(ll i = 2; i * i <= t; ++i) {
        int cnt = 0;
        while(t % i == 0) {
            ++cnt;
            t /= i;
        }
        ans *= (cnt + 1);
    }
    if(t != 1)  ans *= 2;
    for(ll i = 2; i * i <= n; ++i) if(n % i == 0) {
        t = n;

        while(t % i == 0)   t /= i;
        ans += (t % i == 1);
        if(i * i == n)  continue;

        t = n;
        ll k = n / i;
        while(t && t % k == 0)   t /= k;
        ans += (t % k == 1);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

typedef long long ll;

int main(){
  ll n, x = 1e15+5, v;
  cin >> n;
  rep(i, 5) {
    cin >> v;
    x = min(v, x);
  }
  cout << (n + (x - 1)) / x + 4 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define A a
#define B b
#define C c
#define D d
#define N n
#define M m
#define H h
#define W w
#define S s
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
int main(){
	int n,T;cin>>N>>T;
	vector<int> vec;
	rep(i,0,n){
		int c,t;cin>>c>>t;
		if(t<=T) vec.push_back(c);
	}
	if(vec.size()==0){
		cout<<"TLE"<<endl;
	}else{
		cout<<*min_element(range(vec))<<endl;
	}
}

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

int main(){
  int N;
  int d[N];
  cin >> N;
  for(int i=0;i<N;i++)cin >> d[i];
  set<int> values;
  for(int i=0;i<N;i++)values.insert(d[i]);
  cout << values.size() << endl;
  return 0;
}

Measured memory_bytes: 256
<?php
//error_reporting(0);
//$N = (int)trim(fgets(STDIN));
$S = trim(fgets(STDIN));
//list($TM,$TA,$AM,$AA) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$s = trim(fgets(STDIN));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

//https://atcoder.jp/contests/abc164/submissions/12370766
//???
$M=2019;
$len = strlen($S);

$rs = array_fill(0,$M,0);
$rs[0]++;
for ($i = $len - 1, $r = 0, $t = 1; $i >= 0; $i--) {
   $r = (($S[$i]) * $t + $r) % $M;
   $t = $t * 10 % $M;
   $rs[$r]++;
}
$sum = 0;
for ($i = 0; $i < $M; $i++) {
  $sum += intdiv($rs[$i] * ($rs[$i] - 1) , 2);
}
printf("%d\n",$sum);


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

int main() {
  string S;
  cin >> S;
  for(int i=0;i<3;i++){
    
    if(S[i]=='1'){cout<<9;}
    else if(S[i]=='9'){cout<<1;}
  }
  
  cout <<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  string s;
  bool flag=true;
  cin>>s;
  map<char,int> mp;
  rep(i,s.size()){
    mp[s[i]]++;
  }
  for(auto c:mp){
    if(c.second>=2){
      flag=false;
      break;
    }
  }
  if(flag){
    cout<<"yes"<<endl;
  }else{
    cout<<"no"<<endl;
  }

}
///////////////////////////

Measured memory_bytes: 256
N = gets.to_i
A, B, C = 3.times.map{gets.split.map(&:to_i).sort}
ans = 0
a = 0
c = 0
N.times do |b|
    a += 1 while a < N && A[a] < B[b]
    c += 1 while c < N && C[c] <= B[b]
    ans += a * (N - c)
end
puts ans

Measured memory_bytes: 24296
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC003_C
{ 
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var a = new int[n];
            var sort = new int[n];
            int count = 0;
            for (int i = 0; i < n; i++)
            {
                int t = int.Parse(Console.ReadLine());
                a[i] = t;
                sort[i] = t;
            }
            Array.Sort(sort);
            for (int i = 0; i < n; i+=2)
            {
                if (Array.BinarySearch(sort, a[i]) % 2 == 1) count++;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 7760
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

#define INF 100000

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

    for (int i = 0; i <= (N + 4 - 1) / 4; i++) {
        for (int j = 0; j <= (N + 7 - 1) / 7; j++) {
            if (4 * i + 7 * j == N) {
                cout << "Yes"<<endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){

  //変数の準備
  string s, t;
  
  //入力
  cin >> s >> t;
  
  //処理
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());

  if(s < t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int a[9][4]={{1,3,-1,-1},{0,2,4,-1},{1,5,-1,-1},
				{0,4,6,-1},{1,3,5,7},{2,4,8,-1},
				{3,7,-1,-1},{4,6,8,-1},{5,7,-1,-1}};
	int i,j,len,flg,f,x,x2,k;
	char s[11];
	for(i=0;i<1000;i++)	{
		flg=1;
		scanf("%s",s);
		len=strlen(s);
		x=s[0]-'A';
		for(j=1;j<len;j++)	{
			x2=s[j]-'A';
			f=0;
			for(k=0;k<4;k++)	{
				if(x2==a[x][k])	{
					f=1;
					break;
				}
			}
			if(f==0)	{
				flg=0;
				break;
			}
			x=x2;
		}
		if(flg==1)	{
			printf("%s\n",s);
		}
	}
	
	return 0;
}


Measured memory_bytes: 948
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using llong = long long;

const int INF = 100100100;
const int MOD = 1e9 + 7;

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

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

    if (N % 2 != 0) {
        cout << "No\n";
        return 0;
    }

    for (int i = 0; i < N / 2; i++) {
        if (S[i] != S[i + N / 2]) {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes"
         << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
int main()
{
	char op;
	ll a,b;
	scanf("%lld %c %lld",&a,&op,&b);
	if(op=='+')
	printf("%lld\n",a+b);
	else if(op=='-')
	printf("%lld\n",a-b);
	return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;

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

		long x = stdIn.nextLong();
		stdIn.close();

		for (int a = -120; a <= 120; a++) {
			for (int b = -120; b <= 120; b++) {
				if(isCollect(a, b, x)) {
					System.out.println(a +" " + b);
					return;
				}

			}

		}



	}

	private static boolean isCollect(long a, long b, long x) {
		return a*a*a*a*a - b*b*b*b*b == x;
	}
}


Measured memory_bytes: 38776
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,d,x;
  cin >> n >> d >> x;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a.at(i);
    x += (d+a.at(i)-1)/a.at(i);
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<set>
#define ll long long 
#include <string>
using namespace std;
int main()
{
	ll int x;
	cin>>x;
	ll int i,j;
	for(i=-140;i<=140;i++)
	{
		for(j=-140;j<=140;j++)
		{
			if (pow(i,5)-pow(j,5)==x)
			{
				cout<<i<<" "<<j<<endl;
				return 0;
			}
		}
	}
	
}



Measured memory_bytes: 4032
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    if sum(a) < sum(b):
        return -1

    diffs = []
    rest = 0
    ans = 0
    for i in range(n):
        if a[i] < b[i]:
            rest += b[i] - a[i]
            ans += 1
        if a[i] > b[i]:
            diffs.append(a[i] - b[i])
            
    diffs.sort()
    while rest > 0:
        diff = diffs.pop()
        rest -= diff
        ans += 1

    return ans


if __name__ == '__main__':
    print(main())

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

int main() {
  int N;
  cin >> N;
  
  int sum;
  for (int i = 0; i < N; i++) {
    int l;
    int r;
    cin >> l >> r;
    sum = sum + r - l + 1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> p2;
ll hell=pow(10,9)+7;
void solve(){
    ll arr[3][3],ch[3][3];
    for(ll i=0;i<3;i++)
    for(ll j=0;j<3;j++){
        cin>>arr[i][j];
        ch[i][j]=0;
    } 
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++){
        ll x;
        cin>>x;
        for(ll j=0;j<3;j++)
        for(ll k=0;k<3;k++)
        if(arr[j][k]==x)
        ch[j][k]=1;
    }
    for(ll i=0;i<3;i++){
        ll j;
        for(j=0;j<3;j++)
        if(ch[i][j]==0)
        break;
        if(j==3){
            cout<<"Yes";
            return;
        }
    }
    for(ll j=0;j<3;j++){
        ll i;
        for(i=0;i<3;i++)
        if(ch[i][j]==0)
        break;
        if(i==3){
            cout<<"Yes";
            return;
        }
    }
    if(ch[0][0]==ch[1][1]&&ch[1][1]==ch[2][2]&&ch[0][0]==1){
        cout<<"Yes";
        return;
    }
    if(ch[0][2]==ch[1][1]&&ch[1][1]==ch[2][0]&&ch[1][1]==1){
        cout<<"Yes";
        return;
    }
    cout<<"No";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    for(ll qc=0;qc<t;qc++)
    solve();
}


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

#define fi first
#define se second

const int N = 200200;
const long long mod = 1e9 + 7;

using namespace std;

int n, a, b;
bool ban[N];

vector < int > get(int b)
{
        int es = -1;
        for(int i = 0; i < n; i++){
                if(b & (1 << i)){
                        es = i;
                }
        }
        vector < int > res;
        res.push_back(0);
        for(int i = 0; i <= n; i++){
                if(ban[i]){
                        continue;
                }
                int x = i;
                if(i == es){
                        continue;
                }
                if(i == n){
                        x = es;
                }
                vector < int > g = res;
                reverse(g.begin(), g.end());
                for(int y: g){
                        res.push_back(y ^ (1 << x));
                }
        }
        return res;
}

vector < int > solve(int b)
{
        vector < int > g;
        for(int i = 0; i < n; i++){
                if(b & (1 << i)){
                        g.push_back(i);
                }
        }
        if(g.size() == 1){
                return get(b);
        }
        ban[g[0]] = 1;
        vector < int > res = get(1 << g[1]);
        b ^= (1 << g[0]);
        b ^= (1 << g[1]);
        vector < int > gg = solve(b);
        for(int x: gg){
                res.push_back(x ^ (1 << g[0]) ^ (1 << g[1]));
        }
        return res;
}

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> n >> a >> b;
        b ^= a;
        if(__builtin_popcount(b) % 2 == 0){
                cout << "NO" << "\n";
                return 0;
        }
        vector < int > res = solve(b);
        cout << "YES" << "\n";
        for(int x: res){
                cout << (x ^ a) << " ";
        }
}


Measured memory_bytes: 1716
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define ms(a,v) memset(a,v,sizeof(a))
#define mp make_pair
#define write(x) cout<<(x)<<endl
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
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; }
inline ll pow2(const int n) { return 1ll << n; }
const int INF = 1 << 28; const ll LINF = 1ll << 60;
const int MAX = 1e5 + 5; const int MOD = 1e9 + 7; const double EPS = 1e-6;
const int dy[4] = { 0,1,0,-1 }; const int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;
// 1. 問題よくよめえええええええええええええええええええええええええ
// 2. intオーバーフロー << * + あたり
// 3. 落ち着け

int main() {
    int N; cin >> N;
    vector<string> W(N); rep(i, N) cin >> W[i];
    char c = W[0].back();
    rep(i, 1, N) {
        if (find(W.begin(), W.begin() + i, W[i]) != W.begin() + i || W[i][0] != c) {
            puts("No"); return 0;
        }
        c = W[i].back();
    }
    puts("Yes");
}

Measured memory_bytes: 256
q, h, s, d = gets.split(" ").map(&:to_i)
n = gets.to_i

min = Float::INFINITY
min_i = nil
min2 = Float::INFINITY
min2_i = nil
a = [q * 4, h * 2, s, d / 2.0]
a.each_with_index do |i, j|
	if i < min
		min2 = min
		min2_i = min_i
		min = i
		min_i = j
	elsif i < min2
		min2 = i
		min2_i = j
	end
end

if min_i == 3
	p (n / 2 * d + n % 2 * min2).to_i
else
	p (n * min).to_i
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x) 
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
char str1[500000];
int main()
{
    string str;
    cin>>str;
    int l = 200000;
    for(int i = l+1,j = 0; j < str.length() ; i++,j++)
    {
        str1[i] = str[j];
    }
    int r = l+1+str.length();
    int n = read<int>(),z = 0,f = 1;
    while(n--)
    {
        int t = read<int>();
        if(t == 1)
        {
            z++;
            f = -f;
        }
        else
        {
            int t2 = read<int>();
            char c;
            cin>>c;
            if(f == 1)
            {
                if(t2 == 1)
                {
                    str1[l] = c;
                    l--;
                }
                else
                {
                    str1[r] = c;
                    r++;
                }
                
            }
            if(f == -1)
            {
                if(t2 == 1)
                {
                    str1[r] = c;
                    r++;
                }
                else
                {
                    str1[l] = c;
                    l--;
                }
                
            }
        }
        
    }
    if(z&1)
    {
        for(int i = r - 1; i >= l + 1; i--) cout<<str1[i];
    }
    else
    {
        for(int i = l + 1; i <= r - 1; i++) cout<<str1[i];
    }
    
    
}

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

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

    int *c = new int[m];
    for (int i=0;i<m;i++){
        c[i] = 0;
    }

    for (int i=0;i<n;i++){
        int k;
        cin >> k;
        for (int j=0;j<k;j++){
            int aij;
            cin >> aij;
            c[aij-1]++;
        }
    }
    int ans = 0;
    for (int i=0;i<m;i++){
        if (c[i]==n){
            ans++;
        }
    }
    cout << ans << endl;
}

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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

int main() {
    int n,m,a,b;

    scanf("%d%d%d%d", &n, &m, &a, &b);

    if(a > m/2 or b > n/2) {
    	printf("-1\n");
    	return 0;
    }

    for(int i = 0; i < b; i++) {
    	for(int j = 0; j < a; j++)
    		printf("0");
    	for(int j = a; j < m; j++)
    		printf("1");
    	printf("\n");
    }

    for(int i = b; i < n; i++) {
    	for(int j = 0; j < a; j++)
    		printf("1");
    	for(int j = a; j < m; j++)
    		printf("0");
    	printf("\n");
    }


    return 0;
}



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

using namespace std;

typedef long long ll;

int main(){
	int n;
	cin >> n;
	double x;
	string u;
	double ans = 0;
	for(int i = 0; i < n; i++){
		cin >> x >> u;
		if(u == "JPY")ans += x;
		else ans += x * 380000.0;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a<b<c){
        if(a==b){printf("No\n");}
        else if(b==c){printf("No\n");}
        else if(a>b){printf("No\n");}
        else {printf("Yes\n");}
    }
    else {
    printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 580
K,N = map(int, input().split())
A =  [int(N) for N in input().split()]

B = []
for i in range(N-1):
    B.append(int(A[i+1] - A[i]))

B.append(int(A[0]+(K-A[N-1])))

B.sort()

Big = B[N-1]

print(K-Big)

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N+1);
  for(int i=1;i<=N;i++){
    cin >> a.at(i);
  }
  int ans=0;
  vector<bool> flag(N+1, false);
  int x=1;
  flag.at(1)=true;
  while(true){
    x=a.at(x);
    ans++;
    if(x==2){
      cout << ans << endl;
      return 0;
    }
    if(flag.at(x)){
      cout << -1 << endl;
      return 0;
    }else{
      flag.at(x)=true;
    }
  }
  return 0;
}


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

typedef long long ll;

ll a[20][20];
ll groupSum[1 << 17];
ll dp[1 << 17];

ll go(int mask) {
    if(dp[mask] != -1) return dp[mask];

    ll ans = 0LL;
    int b = 0;

    do {
        if(b == 0) continue;
        ans = max(ans, groupSum[b] + go(mask ^ b));
    } while (b=(b-mask)&mask);

    return dp[mask] = ans;
}

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }

    for(int i = 0; i < (1 << n); i++) {
        ll sum = 0;
        for(int j = 0; j < n; j++) {
            if(i & (1 << j)) {
                for(int k = j + 1; k < n; k++) {
                    if(i & (1 << k)) {
                        sum += a[j][k];
                    }
                }
            }
        }
        groupSum[i] = sum;
    }

    memset(dp, -1, sizeof dp);

    cout << go((1 << n) - 1) << endl;

}



Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Main main = new Main();
		main.solveD();
	}

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		System.out.println((g * 10 + b) % 4 == 0 ? "YES" : "NO");
	}

	private void solveB() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int min = 1000;
		int max = 0;
		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			if (min > a) {
				min = a;
			}
			if (max < a) {
				max = a;
			}
		}
		System.out.println(max - min);
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] rates = new int[9];
		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			int index = a / 400;
			rates[index > 8 ? 8 : index]++;
		}
		int min = 0;
		for (int j = 0; j < 8; j++) {
			if (rates[j] > 0) {
				min++;
			}
		}
		int max = min + rates[8];
		if (max > 9) {
			max = 9;
		}
		if (rates[8] > 0 && min == 0) {
			min = 1;
		}
		System.out.println(min + " " + max);
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int left = 0;
		int need = 0;
		for (int i = 0; i < N; i++) {
			char c = S.charAt(i);
			if (c == '(') {
				left++;
			} else {
				if (left > 0) {
					left--;
				} else {
					need++;
				}
			}
		}
		for (int n = 0; n < need; n++) {
			System.out.print('(');
		}
		System.out.print(S);
		for (int n = 0; n < left; n++) {
			System.out.print(')');
		}
		System.out.println();
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,x,count=0,j,i,s;
    scanf("%d%d%d%d",&a,&b,&c,&x);
    for(i=0;i<=a;i++)
    for(j=0;j<=b;j++)
    for(s=0;s<=c;s++)
    {
        if(i*500+j*100+50*s==x)
        count++;
    }
    printf("%d\n",count);

    return 0;
}


Measured memory_bytes: 128
while True:
    H,W = map(int,input().split())
    if (H == 0 and W == 0):
        break
    for h in range(1,H+1):
        if h%2==1:
            for j in range(1,W+1):
                if j%2==1:
                    print('#',end = '')
                else:
                    print('.',end = '')
            print('')
        else:
            for i in range(1,W+1):
                if i%2==1:
                    print('.',end = '')
                else:
                    print('#',end = '')
            print('')
    print('')


Measured memory_bytes: 7008
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashMap;
fn main() {
    input!{
        n: u32,
        m: usize,
        ab: [u32; 2*m],
    };
    let mut map = HashMap::new();
    for i in ab {
        *map.entry(i).or_insert(0) += 1;
    }
    for i in 1..n+1 {
        println!("{}", map.get(&i).unwrap_or(&0));
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n=700,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b;
	cout<<(a+b)/2+(a+b)%2;

	







	cout<<endl;
} 


Measured memory_bytes: 256