akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
lint mod = 1000000007;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int app() {
  int n,k;
  cin>>n>>k;

  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }

  sort(a.begin(), a.end(), [](int a,int b){
    return abs(a)>abs(b);
  });

  bool isp=true;
  int lastp=-1,lastn=-1;
  rep(i,k){
    if(a[i]<0){
      isp=!isp;
      lastn=i;
    }else{
      lastp=i;
    }
    if(a[i]==0) return 0;
  }
  int nextp=-1,nextn=-1;
  bool exist0=false;
  rep_range(i,k,n){
    if(a[i]<0){
      if(nextn==-1) nextn=i;
    }else if(a[i]>0){
      if(nextp==-1) nextp=i;
    }else{
      exist0=true;
    }
  }

  if(isp){
    lint ans=1;
    rep(i,k){
      ans=ans*a[i]%mod;
    }
    return ans;
  }

  bool pn;
  if(lastn>0&&nextp>0){
    if(lastp>0&&nextn>0){
      pn=(lint)a[lastn]*a[nextn]>(lint)a[lastp]*a[nextp];
    }else{
      pn=false;
    }
  }else{
    if(lastp>0&&nextn>0){
      pn=true;
    }else{
      if(exist0) return 0;
      lint ans=1;
      rep(i,k){
        ans=ans*a[n-1-i]%mod;
      }
      return (ans+mod)%mod;
    }
  }

  lint ans=1;
  rep(i,k){
    if(i==(pn?lastp:lastn)) continue;
    ans=ans*a[i]%mod;
  }
  ans=ans*a[pn?nextn:nextp]%mod;
  return ans;

}

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


Measured memory_bytes: 3992
#include <iostream>

using namespace std;

int main(){
    bool isIncluded[26] = {false};
    string str;

    cin >> str;

    for(int i = 0; i < str.size(); i++){
        isIncluded[str[i] - 'a'] = true;
    }

    for(int i = 0; i < 26; i++){
        if(isIncluded[i] == false){
            char ans = 'a' + i;
            cout << ans << endl;
            return 0;
        }
    }

    cout << "None" << endl;

    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int A[3];
	while(cin >> A[0] >> A[1] >> A[2]){
		if(A[0]<A[1]) swap(A[0],A[1]);
		if(A[0]<A[2]) swap(A[0],A[2]);
		int a = (A[0]-A[1]),b = (A[0]-A[2]);
		if( (a%2) == (b%2) ) cout << (a+b)/2<< endl;
		else cout << (a+b+3)/2 << endl;
	}
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;
constexpr int MAX = 2000200;

using namespace std;

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

	int a = n - k;

	if (k == 1) {
		cout << 0 << endl;
	}
	else {
		cout << a << endl;
	}
}




Measured memory_bytes: 256
#include<iostream>
#include<iterator>
#include<sstream>
#include<vector>
#include<cstdio>
const int A_SIZE=26;
using namespace std;
bool is_the(string str){
  if(str.size()!=3){return false;}
  if((str[0]-str[1]+A_SIZE)%A_SIZE!=('t'-'h'+A_SIZE)%A_SIZE){return false;}
  if((str[1]-str[2]+A_SIZE)%A_SIZE!=('h'-'e'+A_SIZE)%A_SIZE){return false;}
  return true;
}
bool is_that(string str){
  if(str.size()!=4){return false;}
  if((str[0]-str[1]+A_SIZE)%A_SIZE!=('t'-'h'+A_SIZE)%A_SIZE){return false;}
  if((str[1]-str[2]+A_SIZE)%A_SIZE!=('h'-'a'+A_SIZE)%A_SIZE){return false;}
  if((str[2]-str[3]+A_SIZE)%A_SIZE!=('a'-'t'+A_SIZE)%A_SIZE){return false;}
  return true;
}
bool is_this(string str){
  if(str.size()!=4){return false;}
  if((str[0]-str[1]+A_SIZE)%A_SIZE!=('t'-'h'+A_SIZE)%A_SIZE){return false;}
  if((str[1]-str[2]+A_SIZE)%A_SIZE!=('h'-'i'+A_SIZE)%A_SIZE){return false;}
  if((str[2]-str[3]+A_SIZE)%A_SIZE!=('i'-'s'+A_SIZE)%A_SIZE){return false;}
  return true;
}
bool is_clue(string str){
  return is_the(str) || is_that(str) || is_this(str);
}

int main(){
  char str[80];
  while(cin.getline(str,80)!=0){
    istringstream iss{str};
    vector<string> strs;
    copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter(strs));
    int offset=0;
    for(string a : strs){
      if(is_clue(a)){
	offset = 't'-a[0];
	break;
      }
    }
    for(char c : str){
      if(c=='\0'){putchar('\n');break;}
      if(c<'a'||c>'z'){putchar(c);}
      else if(c+offset>'z'){putchar(c+offset-A_SIZE);}
      else if(c+offset<'a'){putchar(c+offset+A_SIZE);}
      else{putchar(c+offset);}
    }
  }
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  for(int ii=1;ii<=n;ii++){
    int ans=0;
  for(int i=1;6*i*i<=ii;i++){
    for(int j=i;3*j*j+2*i*j+i*i<=ii;j++){
      for(int k=j;i*i+j*j+k*k+i*j+j*k+k*i<=ii;k++){
        if(i*i+j*j+k*k+i*j+j*k+k*i==ii){
          if((i==j)&&(j==k)){
            ans+=1;
          }
          else if(((i==j)&&(j!=k))||((j==k)&&(j!=i))){
            ans+=3;
          }
          else ans+=6;
        }
      }
    }
  }
  cout <<ans<<endl;
  }
}

Measured memory_bytes: 3520
//temp##############################################

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void strInit(char str[]){
    int len=strlen(str);
    for(int i=0;i<len;i++){
        str[i]=0;
    }
}

void extIntStr(char str[],int data[]){
    int length=strlen(str);
    str[length-1]=' ';
    char buff[12];
    int j,index;
    index=j=0;
    for(int i=0;i<length;i++){
        if(str[i]!=' '){
            buff[j++]=str[i];
        }else{
            data[index++]=atoi(buff);
            strInit(buff);
            j=0;
        }
    }
}

void incsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]>data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void decsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]<data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void printIntArray(int data[],int len){
    for(int i=0;i<len;i++){
        printf("%d\n",data[i]);
    }
}

//temp##############################################

int main(){
    int N;
    scanf("%d ",&N);
    int *data;
    char *str;
    data=(int*)malloc(sizeof(int)*N);
    str=(char*)malloc(sizeof(char)*N*10+1);
    fgets(str,N*10+N+1,stdin);
    extIntStr(str,data);
    incsort(data,N);
    double *ddata;
    ddata=(double*)malloc(sizeof(double)*N);
    for(int i=0;i<N;i++){
        ddata[i]=(double)data[i];
    }
    for(int i=0;i<N-1;i++){
        ddata[i+1]=(ddata[i]+ddata[i+1])/2;
    }
    printf("%f",ddata[N-1]);
    free(ddata);
    free(str);
    free(data);
    return 0;
}


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

int main(){
int N, i, j;
  cin>>N;
  vector<pair<int, int> >r(N), b(N);
  for(i=0; i<N; i++){
   cin>>r[i].second>>r[i].first; }
  for(i=0; i<N; i++){
   cin>>b[i].first>>b[i].second; }
  
  sort(r.begin(), r.end());
  sort(b.begin(), b.end());
  
  vector<int>a(N);
  int mj, ans=0;
  for(i=0; i<N; i++){
   bool f=false;
    for(j=0; j<N; j++){
     if(r[j].second<b[i].first && r[j].first<b[i].second){
      if(a[j]==0){f=true;
                 mj=j;}
     }
    }
    if(f){ans++; a[mj]=1;} // 最小のペアを探索し、jをa[mj]=1で管理
  } // することで、2度以上そのペアが使われるのを防ぐ
  
  cout<<ans;
}

Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
//#include <ostream>


using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N)cin >> A[i];

  vector<int> wa(N+10,0);
  vector<int> sa(N+10,0);
  for(int i = 1;i <= N;i++){
    if(i + A[i-1] < 300000 && i + A[i-1] >= 0)wa[i] = i + A[i-1];
    if(i - A[i-1] >= 0 && i - A[i-1] < 300000)sa[i] = i - A[i-1];
  }



  vector<int> cnt1(300000,0);
  for(int i = 1;i <= N;i++){
    cnt1[wa[i]]++;
  }
  vector<int> cnt2(300000,0);
  for(int i = 1;i <= N;i++){
    cnt2[sa[i]]++;
  }
  ll ans = 0;
  rep(i,300000){
    if(i==0)continue;
    ll plus = 1ll*cnt1[i]*cnt2[i];
    ans += plus;
  }
  cout << ans << endl;

 }


Measured memory_bytes: 8020
#include<bits/stdc++.h> 
#define inf 1e18
using namespace std;
typedef long long int ll;
char a[105];
int k;
int main()
{
	cin>>a;cin>>k;
	int cnt=0; 
	if(k==1)
	{
		for(int i=1;i<strlen(a);i++)
		{
			if(a[i]==a[i-1]&&a[i-1]!='*')cnt++,a[i]='*';
		}
		printf("%d\n",cnt); 
	}
	else
	{
		int n=strlen(a),i;ll ans=0;
		for(i=1;i<n;i++)if(a[i]!=a[i-1])break;
		if(i==n)
		{
			printf("%lld\n",(ll)k*n/2);
			return 0;
		}
		ans+=i/2;
		int pos=i;
		for(;i<n+pos;)
		{
			int j;
			for(j=i+1;j<n+pos;j++)if(a[j%n]!=a[(j-1+n)%n])break;
			cnt+=(j-i)/2;
			i=j;
		}
		ans+=(ll)cnt*(k-1);
		for(i=pos;i<n;)
		{
			int j;
			for(j=i+1;j<n;j++)if(a[j%n]!=a[(j-1+n)%n])break;
			ans+=(j-i)/2;
			i=j;
		} 
//		for(i=n-2;i>=pos;i--)if(a[i]!=a[i+1])break;
//		ans+=(n-i-1)/2;
		printf("%lld\n",ans);
	}
} 

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

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

const int mod = 1e9+7;
using mint = ModInt< mod >;

const int N = 100002;
mint f[N];
mint inv[N];

mint C(int n, int r){
    if(n<r) return 0;
    return f[n]*inv[r]*inv[n-r];
}

int main(){
    f[0] = 1;
    for(int i=1; i<N; ++i) f[i] = f[i-1]*i;

    inv[N-1] = f[N-1].inverse();
    for(int i=N-2; i>=0; --i) inv[i] = inv[i+1]*(i+1);

    int n,k;
    cin >>n >>k;
    vector<int> a(n);
    rep(i,n) cin >>a[i];

    sort(all(a));

    mint ans = 0;
    rep(i,n){
        // max
        int x = i;
        ans += C(x,k-1)*a[i];

        // min
        x = n-1-i;
        ans -= C(x,k-1)*a[i];
    }

    cout << ans << "\n";
    return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  cout << (n+1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/agc005/tasks/agc005_a?lang=en

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
  string x;
  cin >> x;
  vector<char> s(0);

  for (ll i=0; i<x.length(); i++) {
    if (x[i] == 'S') {
      s.push_back(x[i]);
    } else {
      if (s.size() > 0 && s[s.size()-1] == 'S') {
        s.pop_back();
      } else {
        s.push_back(x[i]);
      }
    }
  }
  printf("%d\n", s.size());
}


Measured memory_bytes: 772
#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;

int main(void){

	int n;
	cin >> n;

	while(n--){
		int x,y,b,p;
		cin >> x >> y >> b >> p;

		double t=x*b+y*p,u=(x*max(5,b)+y*max(2,p))*0.2,v=x*max(5,b)+y*max(2,p);
		cout << (int)min(t,v-u) <<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
def main():
  n =int(input())
  li = [0] * n
  
  for i in range(1, n+1):
    li[i-1] += i
  
  length = len(li)
  total = 0
  
  for k in range(0, length):
    if li[k] % 3 != 0 and li[k] % 5 != 0:
      total += li[k]
      
  print(total)
      
  
main()


Measured memory_bytes: 48300
import sys

S = sys.stdin.read()

abc = [0 for i in range(26)]
for i in range(len(S)):
    ords = ord(S[i])
    if 65 <= ords < 65+26:
        abc[ords-65] += 1
    elif 97 <= ords < 97+26:
        abc[ords-97] += 1

for i in range(26):
    word = chr(i+97)
    count = abc[i]
    print('{} : {}'.format(word,count))



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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n, ans = 0; cin >> n;
    vector<ll> a(n), b(n), sum(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
        sum[i] = a[i]+b[i];
        ans -= b[i];
    }
    sort(ALL(sum), greater<ll>());
    rep(i, (n+1)/2) {
        ans += sum[2*i];
    }
    cout << ans << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const int MAX_N = 10010, MAX_V = 100010, MAX_W = 10010;

int S[100010], T[100010];

pair <int, int> itv[100010];

int N, M;

void solve()
{
	//pairは辞書順で比較される
	//終了の早い順にしたいため、Sをfirstに、Tをsecondに入れる
	for (int i = 0; i < M; i++)
	{
		itv[i].first = T[i];
		itv[i].second = S[i];
	}
	sort(itv, itv + M);

	//tは最後に選んだ仕事の終了時間
	int ans = 0, t = 0;

	for (int i = 0; i < M; i++)
	{
		if (t <= itv[i].second)
		{
			ans++;
			t = itv[i].first;
		}
	}

	cout << ans << endl;
}

int main()
{
	cin >> N >> M;
	for (int i = 0; i < M; i++)
	{
		cin >> S[i] >> T[i];
	}

	solve();
}

Measured memory_bytes: 1792
import sys


class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x


N, M = map(int, input().split())
info = [tuple(map(int, s.split())) for s in sys.stdin.readlines()]

uf = UnionFind(N)
for a, b in info:
    a -= 1; b -= 1
    uf.union(a, b)

ans = min(uf.parents)

print(-ans)

Measured memory_bytes: 120416
import heapq
X, Y, Z, K = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)
# done = [[[True for _ in range(Z+1)] for _ in range(Y+1)] for _ in range(Z+1)]
done = set()

h = []
heapq.heappush(h, (-(A[0]+B[0]+C[0]), 0, 0, 0))  # リストaのheap化
done.add((0, 0, 0))

for _ in range(K):
    p, i, j, k = heapq.heappop(h)
    # print(h)
    print(-p)

    if (i+1, j, k) not in done and i+1 < X:
        # heap化されたリストaに要素xを追加
        heapq.heappush(h, (-(A[i+1]+B[j]+C[k]), i+1, j, k))
        # print(h)
        done.add((i+1, j, k))

    if (i, j+1, k) not in done and j+1 < Y:
        # heap化されたリストaに要素xを追加
        heapq.heappush(h, (-(A[i]+B[j+1]+C[k]), i, j+1, k))
        # print(h)
        done.add((i, j+1, k))

    if (i, j, k+1) not in done and k+1 < Z:
        # heap化されたリストaに要素xを追加
        heapq.heappush(h, (-(A[i]+B[j]+C[k+1]), i, j, k+1))
        # print(h)
        done.add((i, j, k+1))


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

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

#define INF 2e9
#define ALL(v) v.begin(), v.end()

int main(){
    int k;
    string s;
    cin>>k>>s;
    if(s.size()<=k){
        cout<<s<<endl;
    }
    else{
        rep(i,k){
            cout<<s[i];
        }
        cout<<"...";
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,k;cin >> a >> b >> k;
	vector<int> ans;
	if((b-a+2)/2<=k) for(int i=a;i<=b;++i) cout << i << endl;
	else{
		for(int i=a;i<a+k;++i) ans.pb(i);
		for(int i=b;i>b-k;--i) ans.pb(i);
		sort(ans.begin(),ans.end());
		rep(i,ans.size()) cout << ans.at(i) << endl;
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#define debug cout

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n);i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

int a[110][110],b[60][60];
int n,m,resx,resy,offset;

bool fit(int y,int x){
	rep(i,m)rep(j,m){
		if(b[i][j]==-1)continue;
		if(a[y+i][x+j]!=b[i][j])return false;
	}
	return true;
}

void rotate(){
	int c[60][60];
	rep(i,m)rep(j,m){
		c[i][j]=b[m-j-1][i];
	}
	rep(i,m)rep(j,m)b[i][j]=c[i][j];
}

int main() {
	IL{
		cin>>n>>m;
		if(n==0&&m==0)break;
		rep(i,n)rep(j,n)cin>>a[i][j];
		rep(i,m)rep(j,m)cin>>b[i][j];
		resx=resy=n;
		rep(iii,4){
			rep(i,m)if(b[0][i]!=-1){
				offset=i;
				break;
			}
			rep(i,n-m+1)rep(j,n-m+1){
				if(fit(i,j)){
					if(resy>i||resy==i&&resx>j+offset){
						resx=j+offset;
						resy=i;
					}
				}
			}
			rotate();
		}
		if(resx<n)cout<<resx+1<<" "<<resy+1<<endl;
		else cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int A,B,C,X,ans=0;
int main(void){
	cin>>A>>B>>C>>X;
	for(int i=0;i<=A;i++)for(int j=0;j<=B;j++)for(int k=0;k<=C;k++)if(500*i+100*j+50*k==X)ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define MAXK 26
#define MAXX 15000006
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph emplace
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n,p[20006];
ll magic=25000;
int main()
{
	FAST
	cin>>n;
	FOR(i,0,n){
		ll a; cin>>a;
		p[a-1]=i;
	}
	FOR(i,0,n){
		cout<<(i+1)*magic<<' ';
	}
	cout<<'\n';
	FOR(i,0,n){
		cout<<(n-i)*magic+(p[i]+1)<<' ';
	}
	cout<<'\n';
}


Measured memory_bytes: 768
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 600000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000 大きいとワ―シャルフロイドでオーバーフローを起こす
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0,0 };


int main(void) {
	
	string s;

	cin >> s;

	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}



	
	

	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("03", "unroll-loops")
//#pragma GCC target("avx2")

#include <bits/stdc++.h>

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR(i,n) for(i=0;i<n;i++)
#define FORn(i,j,n) for(i=j;i<n;i++)
#define pb push_back
#define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define vprint(v) for(auto t:v)cout<<t<<" "
#define endl "\n"

using namespace std;

typedef long long int lli;
typedef long int li;
typedef vector<lli> vli; 
typedef vector<int> vi; 
typedef vector<string> vs; 


const lli mod=1000000007;
const lli limit=1000000;


void fc(lli &x)
    {
        bool neg=false;
        register char c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }

int main() {

    fast()
    lli n,q,t;
    lli temp,temp1,temp2,temp3;
    lli i,j,k;
    string str;
    cin>>n;
    cin>>str;
    temp=0;
    lli dp[n+1][3];
    dp[n][0]=0;
    dp[n][1]=0;
    dp[n][2]=0;
    for(i=n-1;i>=0;i--){
        FOR(j,3)dp[i][j]=dp[i+1][j];
        if(str[i]=='R')dp[i][0]++;
        else if(str[i]=='G')dp[i][1]++;
        else dp[i][2]++;
    }
    temp=0;
    FOR(i,n){
        if(str[i]=='R'){
            FORn(j,i,n){
            while(str[j]=='R' && j<n)j++;
            if(j==n)continue;
            if(str[j]=='G'){
                temp+=dp[j][2];
                if(2*j-i<n)if(str[2*j-i]=='B')temp--;
            }
            else{
                temp+=dp[j][1];
                if(2*j-i<n)if(str[2*j-i]=='G')temp--;
            }
            }
        }
        if(str[i]=='G'){
            FORn(j,i,n){
            while(str[j]=='G' && j<n)j++;
            if(j==n)continue;
            if(str[j]=='R'){
                temp+=dp[j][2];
                if(2*j-i<n)if(str[2*j-i]=='B')temp--;
            }
            else{
                temp+=dp[j][0];
                if(2*j-i<n)if(str[2*j-i]=='R')temp--;
            }
            }
        }
        if(str[i]=='B'){
            FORn(j,i,n){
            while(str[j]=='B' && j<n)j++;
            if(j==n)continue;
            if(str[j]=='R'){
                temp+=dp[j][1];
                if(2*j-i<n)if(str[2*j-i]=='G')temp--;
            }
            else{
                temp+=dp[j][0];
                if(2*j-i<n)if(str[2*j-i]=='R')temp--;
            }
            }
        }
    }
    cout<<temp<<endl;;
 
}

Measured memory_bytes: 3752
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

inline double pow2(double x){
	return x * x;
}

int main(){
	ios_base::sync_with_stdio(false);
	cout << setiosflags(ios::fixed) << setprecision(10);
	double xs, ys, xt, yt;
	int n;
	cin >> xs >> ys >> xt >> yt >> n;
	vector<double> xb(n), yb(n), rb(n);
	for(int i = 0; i < n; ++i){
		cin >> xb[i] >> yb[i] >> rb[i];
	}
	vector<vector<double>> mat(n, vector<double>(n));
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			const double d = sqrt(pow2(xb[i] - xb[j]) + pow2(yb[i] - yb[j]));
			mat[i][j] = mat[j][i] = max(0.0, d - rb[i] - rb[j]);
		}
	}
	vector<double> dist(n);
	for(int i = 0; i < n; ++i){
		const double d = sqrt(pow2(xb[i] - xs) + pow2(yb[i] - ys));
		dist[i] = max(0.0, d - rb[i]);
	}
	vector<bool> done(n);
	for(int i = 0; i < n; ++i){
		int u = -1;
		for(int j = 0; j < n; ++j){
			if(done[j]){ continue; }
			if(u < 0 || dist[j] < dist[u]){ u = j; }
		}
		done[u] = true;
		for(int v = 0; v < n; ++v){
			dist[v] = min(dist[v], dist[u] + mat[u][v]);
		}
	}
	double answer = sqrt(pow2(xs - xt) + pow2(ys - yt));
	for(int i = 0; i < n; ++i){
		const double d = sqrt(pow2(xb[i] - xt) + pow2(yb[i] - yt));
		answer = min(answer, dist[i] + max(0.0, d - rb[i]));
	}
	cout << answer << endl;
	return 0;
}



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

int main() {
  while (1) {
    int h, w;
    cin >> h >> w;

    if (h == 0 && w == 0) { break; }

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        int sum = i + j;
        if (sum % 2 == 0) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}

int main(){
    int n;cin >> n;
    map<ll, ll> mp;
    ll ans = 0;
    rep(i,n){
        ll a;cin >> a;
        ans += mp[i - a];
        mp[i + a]++; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 26216
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
t=0
y=[0]

for i in range(n):

    if a[i]-y[i] >= b[i]:
        
        t += b[i]
        y.append(0)
    
    elif a[i]-y[i]+a[i+1] <= b[i]:
        t += a[i]-y[i]+a[i+1]
        y.append(a[i+1])
    else:
        t += b[i]
        y.append(b[i]-a[i]+y[i])

print(t)

Measured memory_bytes: 86500
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7

class UnionFind :
    def __init__(self, size) :
        """
        Parameters
        ---
        size : int
            頂点数
        """
        self.parent = list(range(size))
        self.height = [0] * size
        self.size = [1] * size
        self.component = size

    def root(self, index) :
        """
        親のインデックスの取得

        Parameters
        ---
        index : int
            取得する頂点のインデックス

        Returns
        ---
        rootIndex : int
            指定した頂点の根のインデックス
        """
        if self.parent[index] == index :  # 根の場合
            return index
        rootIndex = self.root(self.parent[index])  # 葉の場合親の根を取得
        self.parent[index] = rootIndex  # 親の付け直し
        return rootIndex

    def union(self, index1, index2) :  # 結合
        """
        木の結合

        Parameters
        ---
        index1 : int
        index2 : int
            結合する頂点のインデックス
        """
        root1 = self.root(index1)
        root2 = self.root(index2)

        if root1 == root2 :  # 連結されている場合
            return

        self.component -= 1  # 連結成分を減らす

        if self.height[root1] < self.height[root2] :
            self.parent[root1] = root2  # root2に結合
            self.size[root2] += self.size[root1]
        else :
            self.parent[root2] = root1  # root1に結合
            self.size[root1] += self.size[root2]
            if self.height[root1] == self.height[root2] :
                self.height[root1] += 1
        return

    def isSameRoot(self, index1, index2) :
        """
        同じ木に属するかを判定する

        Parameters
        ---
        index1 : int
        index2 : int

        Returns
        ---
        boolean
        """
        return self.root(index1) == self.root(index2)

    def sizeOfSameRoot(self, index) :
        """
        指定した頂点の属する木の大きさを取得する
        """
        return self.size[self.root(index)]

    def getComponent(self) :
        """
        連結成分数を取得する
        """
        return self.component

def sol():
    N = int(input())

    tree = UnionFind(N)

    if N % 2 == 0:
        for i in range(N // 2):
            tree.union(i, N - 1 - i)
    else:
        for i in range(N // 2):
            tree.union(i, N - 2 - i)

    ans = []
    for i in range(N):
        for j in range(i + 1, N):
            if not tree.isSameRoot(i, j):
                ans.append([i + 1, j + 1])

    print(len(ans))
    for a in ans:
        print(*a)


sol()

Measured memory_bytes: 4468
def dis(x1,y1,x2,y2):
    return ((x1-x2)**2+(y1-y2)**2)**0.5
N = int(input())
xy = []
rmax = 2000
r = 1000
rmin = 0
eps = 10e-10
for i in range(N):
    x,y = map(int,input().split())
    xy.append((x,y))
for i in range(50):
    intersections = []
    for i in range(N):
        xi,yi = xy[i]
        for j in range(N):
           if i < j:
               xj,yj = xy[j]
               xc = (xi+xj)/2
               yc = (yi+yj)/2
               dc = dis(xc,yc,xi,yi)
               if r > dc:
                   d = (r**2-dc**2)**0.5
                   intersections.append((xc+(yc-yi)*d/dc,yc-(xc-xi)*d/dc))
                   intersections.append((xc-(yc-yi)*d/dc,yc+(xc-xi)*d/dc))
    ans = False
    for x,y in intersections:
        for i in range(N):
            xi,yi = xy[i]
            if dis(x,y,xi,yi) > r+eps:
                break
        else:
            ans = True
    if ans:
        rmax = r
    else:
        rmin = r
    r = (rmax+rmin)/2
print(r)

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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long

int main(){
    string n;
    gets(n)
    if (n[0] == '9' || n[1] == '9') {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
n,a,b = map(int,input().split())
l = [list(map(int,input().split())) for i in range(n)]
INF = 500
dp = [[[INF for i in range(411)] for j in range(411)] for k in range(n+1)]
dp[0][0][0] = 0
for i in range(n):
    for j in range(a*n+1):
        for k in range(b*n+1):
            if j - l[i][0]>=0 and k - l[i][1]>=0:
                dp[i+1][j][k] = min(dp[i][j][k],dp[i][j - l[i][0]][k - l[i][1]]+l[i][2])
            else:
                dp[i+1][j][k] = dp[i][j][k]
i =1
ans = INF
while i*max(a,b)<=400:
    ans = min(ans, dp[n][i*a][i*b])
    i+=1
if ans==INF:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 108508
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func vi(n int, args ...int) []int {
	res := make([]int, n)
	if len(args) == 0 {
		return res
	}
	v := args[0]
	if v == 0 {
		return res
	}
	for i := 0; i < n; i++ {
		res[i] = v
	}
	return res
}

func vvi(n int, args ...int) [][]int {
	res := make([][]int, n)
	m := n
	if len(args) > 0 {
		m = args[0]
	}
	v := 0
	if len(args) > 1 {
		v = args[1]
	}
	for i := 0; i < n; i++ {
		res[i] = vi(m, v)
	}
	return res
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	n := readInt()

	sn := 0
	for tn := n; tn > 0; tn /= 10 {
		sn += tn % 10
	}
	if n%sn == 0 {
		println("Yes")
	} else {
		println("No")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;



int main(){
    ll n;cin>>n;
    ll a[100010];
    rep(i,0,n)cin>>a[i];
    if(a[n-1]!=2){cout<<-1<<endl;return 0;}
    ll l=2,r=2;
    for(ll i=n-1;i>=0;i--){
        l=(l+a[i]-1)/a[i]*a[i];
        r=r/a[i]*a[i]+a[i]-1;
        if(l>r){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<l<<" "<<r<<endl;
}

    









Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <fstream>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b==c+d)
        cout<<"Balanced";
    else if(a+b>c+d)
        cout<<"Left";
    else
        cout<<"Right";
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
N = int(input())
A = [int(x) for x in input().split()]
ans = [0] * H
for i in range(H):
    ans[i] = [0] * W
h_index = 0
A_index = 0
w_index = 0
now_num = 0
while (h_index != H):
    #print(h_index, w_index)
    ans[h_index][w_index] = A_index + 1
    now_num += 1
    if A[A_index] == now_num:
        now_num = 0
        A_index += 1
    if h_index % 2 == 0:
        if w_index == W-1:
            h_index += 1
        else:
            w_index += 1
    else:
        if w_index == 0:
            h_index += 1
        else:
            w_index -= 1
for j in range(H):
    print(*ans[j], sep=" ")


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
//#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pi = pair<int, int>;
template <typename T>
using Pq = priority_queue<T>;
template <typename T>
using pQ = priority_queue<T, vector<T>, greater<T>>;

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
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;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> X;
    if (X) {
        cout << 0 << endl;
    } else
        cout << 1 << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define N int(1e5)+10
#define ll long long int
using namespace std;

int main(){
	ll n, w, current, last, t=0;
	ll knapsack[2][N];
	ll weights[100], values[100];

	cin >> n >> w;
	for(int i=0;i<n;i++){
		cin >> weights[i] >> values[i];
		t+=values[i];
	}

	for(int i=0;i<N;i++){
		knapsack[0][i] = 0;
		knapsack[1][i] = 0;
	}

	for(int i=1;i<=n;i++){
		current = i%2;
		last = (i+1)%2;
		for(int j=0;j<=t;j++){
			//add (i-1)th element if its value doesn't exceed j
			if(values[i-1]<=j&&(knapsack[last][j-values[i-1]]!=0)){
				if(knapsack[last][j]==0){
					knapsack[current][j] = knapsack[last][j-values[i-1]]+weights[i-1];	
				}
				else{
					knapsack[current][j] = min(knapsack[last][j],knapsack[last][j-values[i-1]]+weights[i-1]);
				}
			}
			//can't add (i-1)th element
			else{
				knapsack[current][j] = knapsack[last][j];
			}
		}
		if(knapsack[current][values[i-1]]!=0){
			knapsack[current][values[i-1]] = min(knapsack[current][values[i-1]],weights[i-1]);
		}
		else{
			knapsack[current][values[i-1]] = weights[i-1];			
		} 
	}
	
	for(int j=t;j>=1;j--){
		if(knapsack[current][j]<=w && knapsack[current][j]!=0){
			cout << j << '\n';
			break;
		}
	}

	return 0;
}

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

int main()
{
    int H, W;
    cin >> H >> W;

    for (int i = 0; i < W + 2; i++)
    {
        cout << "#";
    }
    cout << endl;

    string a;
    for (int i = 0; i < H; i++)
    {
        cout << "#";
        cin >> a;
        cout << a;
        cout << "#" << endl;
    }

    for (int i = 0; i < W + 2; i++)
    {
        cout << "#";
    }
    cout << endl;
}


Measured memory_bytes: 256
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 0063
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int res = 0;
		while(sc.hasNext()) {
			String s = sc.next();
			boolean ok = true;
			for (int i = 0; i < s.length() / 2; i++) 
				if (s.charAt(i) != s.charAt(s.length() - i - 1)) ok = false;
			
			if (ok) res++;
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 11000
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int a,b,c,d,x;
int main()
{
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&x);
	printf("%d\n",max(0,c*60+d-a*60-b-x));
	return 0;
}

Measured memory_bytes: 1728
const lines: string[] = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line: string) {
  lines.push(line);
});

reader.on("close", function () {
  const input = lines[0].split("").map(Number);

  const paternArray = [1, -1];
  const strArray = ["+", "-"];

  let ans: number[] = [input[0]];
  for (let i = 0; i < paternArray.length; i++) {
    for (let j = 0; j < paternArray.length; j++) {
      for (let k = 0; k < paternArray.length; k++) {
        let sum =
          input[0] +
          input[1] * paternArray[i] +
          input[2] * paternArray[j] +
          input[3] * paternArray[k];

        if (sum === 7) {
          console.log(
            input[0] +
              strArray[i] +
              input[1] +
              strArray[j] +
              input[2] +
              strArray[k] +
              input[3] +
              "=7"
          );
          return;
        }
      }
    }
  }

  console.log();
});


Measured memory_bytes: 7628
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 310;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

int x, a;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> x >> a;
    if (x < a) cout << 0;
    else cout << 10;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int N = 2*n;
  int k;
  bool can = false;
  for(int i = 1; i*i <= N; i++){
    if(i*(i+1) == N) {
      can = true;
      k = i+1;
    }
  }
  if(!can){
    cout << "No" << endl;
    return 0;
  }
  vector<int> a[k];
  int pos = 1;
  rep(i, k){
    for(int j = i + 1; j < k; j++){
      a[i].push_back(pos);
      a[j].push_back(pos);
      pos++;
    }
  }
  cout << "Yes" << endl;
  cout << k << endl;
  rep(i,k){
    cout << k - 1 << " ";
    rep(j, a[i].size()){
      cout << a[i][j];
      cout << " ";
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
using namespace std;

template<class T>
void in(T& I) {
	cin >> I;
	return;
}

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

void out(string S) {
	cout << S << endl;
	return;
}

template<class T>
void out(T& O) {
	cout << O << endl;
	return;
}

int main() {
	string S;
	in(S);
	for (int i = 0; i < S.size(); i++) {
		if (i % 2 == 1) {
			if (S[i] == 'R')goto fail;
		}
		else {
			if (S[i] == 'L')goto fail;
		}
	}
	out(string("Yes"));
	return 0;
fail:
	out(string("No"));
	return 0;
}

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

const int N = 1e5 + 5;
int n,m;

struct city {
    int p,y;
};

city cities[N];

vector<int> p_city[N];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>m;
    
    for (int i = 0; i < m; i++){
        cin>>cities[i].p>>cities[i].y;
        p_city[cities[i].p].push_back(cities[i].y);
    }
    
    for (int i = 1; i <= n; i++){
        sort(p_city[i].begin(), p_city[i].end());
    }
    
    for (int i = 0; i < m; i++){
        cout<<right<<setw(6)<<setfill('0')<<cities[i].p;
        int pos = lower_bound(p_city[cities[i].p].begin(),p_city[cities[i].p].end(), cities[i].y) - p_city[cities[i].p].begin() + 1;
        cout<<right<<setw(6)<<setfill('0')<<pos<<endl;
    }
    
    
    
    return 0;
}




Measured memory_bytes: 7808