akhauriyash/Code-Regression huggingface dataset:
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const ll INF = 10000000000;//INFinity
using namespace std;//namespace

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}//transform
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//#define int long long // yabai

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    // kokoni kaku

    ll x;
    cin>>x;
    ll quot =ldiv(x,11).quot*2;
    ll rem =ldiv(x,11).rem;
    if(rem!=0)quot+=(rem>6?2:1);
    cout<<quot<<endl;
    
    
    return 0;
}


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


int main() {
int x;
cin >> x;
if (x >= 30) cout << "Yes" << endl;
else cout << "No" << endl;


return 0;
}



Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


bool isPrime(int n) { //素数ならtrue
    for (int i=2; i*i<=n; i++) {
        if (n%i == 0) return false;
    }
    return n != 1;
}

int main() {
    int q; cin >> q;
    vector<int> l(q),r(q);
    rep(i,q) cin >> l[i] >> r[i];

    vector<int> sum(100001,0); //sum[i]:iまでの似た数の個数
    for (int i=1; i<=100000; i++) {
        if (i%2==0) {
            sum[i]=sum[i-1];
            continue;
        }
        bool check = isPrime(i)&isPrime((i+1)/2);
        if (check) sum[i]=sum[i-1]+1;
        else sum[i]=sum[i-1];
    }

    rep(i,q) {
        cout << sum[r[i]]-sum[l[i]-1] << endl;
    }

}

Measured memory_bytes: 4548
# 二か所で買ったものを一か所で売ることはあり得ない（安いほうで買いたい）
# 一か所で買ったものを二か所で売ることはあり得ない（高いほうで買いたい）
# 売る場所の数 = 買う場所の数
# ans = 売って最大利益になる場所の数（or 買う場所の数。どっちでもいい）
# Tは関係ない

N,T=map(int,input().split())
A=list(map(int,input().split()))

# 売る場所を一つず右にずらす
# それより前の場所の最安値を持っておく
# 差分のmaxvalを満たす回数をカウント、maxvalが更新されたら回数は1に戻す

INF=10**9+1
maxval=0
minval=INF
ans=0
for i in range(1,len(A)):
  minval=min(A[i-1],minval)
  diff=A[i]-minval
  if diff>maxval:
    maxval=diff
    ans=1
  elif diff==maxval:
    ans+=1

print(ans)

Measured memory_bytes: 14252
#include<iostream>
#include<cstring>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<utility>
#include<cstdio>
using namespace std;
typedef long long LL;
#define RI register int
const int MAX=10e7;


int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a==b&&a!=c)||
       (a==c&&a!=b)||
       (c==b&&a!=c))cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N;
string S;

typedef long long ll;

int main() {
  ll ans = 0;

  ll count_R = 0;
  ll count_G = 0; 
  ll count_B = 0;

  cin >> N >> S;
  for(int i = 0; i < N; i++) {
    if(S[i] == 'R') count_R++;
    if(S[i] == 'G') count_G++;
    if(S[i] == 'B') count_B++;
  }

  for(int i = 0; i < N; i++) {
    //cout << count_R << " " << count_G << " " << count_B << endl;
    //cout << "i " << i << " ans " << ans << endl;

    if(S[i] == 'R') count_R--;
    if(S[i] == 'G') count_G--;
    if(S[i] == 'B') count_B--;

    ll count_R_ = count_R;
    ll count_G_ = count_G;
    ll count_B_ = count_B;

    for(int j = i+1; j < N; j++) {
      if(S[j] == 'R') count_R_--;
      if(S[j] == 'G') count_G_--;
      if(S[j] == 'B') count_B_--;
      
      if(S[j] == S[i]) continue;

      if(S[i] == 'R' && S[j] == 'G') {
        //cout << "RG adding " << count_B << endl;
        ans += count_B_;
      }
      if(S[i] == 'R' && S[j] == 'B') {
        //cout << "RB adding " << count_G_ << endl;
        ans += count_G_;
      }
      if(S[i] == 'G' && S[j] == 'R') {
        ans += count_B_;
      }
      if(S[i] == 'G' && S[j] == 'B') {
        //cout << "GB adding " << count_R_ << endl;
        ans += count_R_;
      }
      if(S[i] == 'B' && S[j] == 'R') {
        ans += count_G_;
      }
      if(S[i] == 'B' && S[j] == 'G') {
        ans += count_R_;
      }
      int delta = j-i;
      if(j+delta < N && S[i] != S[j] && S[i] != S[j+delta] && S[j] != S[j+delta]) {
        // cout << "i j k " << i << " " << j << " " << " " << j+delta << endl;
        ans--;
      }

      // cout << " j " << j << " ans " << ans << endl;
    }
  }
  cout << ans << endl;


}


Measured memory_bytes: 3636
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int cnt = 1;
        int n = 0;
        while ((n = sc.nextInt()) != 0) {
            System.out.println("Case " + cnt++ + ": " + n);
        }
    }
}


Measured memory_bytes: 45184
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N); // N個の数学の点数データ
 vector<int> B(N-1); // N個の数学の点数データ
   
  for (int i = 0; i < N-1; i++) {
    cin >> B.at(i); 
  }
    A.at(0)=B.at(0);
    A.at(N-1)=B.at(N-2);
  for (int i = 1; i < N-1; i++) {
     A.at(i) = min(B.at(i),B.at(i-1));
  }
  int answer;
  for (int i = 0; i < N; i++) {
       answer +=A.at(i);
  }
  
  
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr array<int, 4> dx = {1, 0, -1, 0};
constexpr array<int, 4> dy = {0, 1, 0, -1};
constexpr int MOD = 100000000 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(10);

    int a, b, x;
    cin >> a >> b >> x;

    double ans;

    if (x / a > a * b / 2)
    {
        // daikei
        double b1 = 2.0 * x / (double)a / a - (double)b;
        double rad_angle = atan((b - b1) / (double)a);
        double deg_angle = rad_angle * 180.0 / M_PI;
        ans = deg_angle;
    }
    else
    {
        // sankakukei
        double a1 = (x * 2.0) / ((double)a * b);
        double rad_angle = atan(b / a1);
        double deg_angle = rad_angle * 180.0 / M_PI;
        ans = deg_angle;
    }
    cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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; }

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

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

  vi a(n), b(n), c(m), d(m);
  rep(i,n) cin >> a[i] >> b[i];
  rep(i,m) cin >> c[i] >> d[i];
  
  vi min_d(n,MOD),ans(n,51);

  rep(i,n){
    rep(j,m){
      int dis = (abs(c[j]-a[i]) + abs(d[j]-b[i]));
      if(dis<min_d[i]){
        min_d[i] = dis;
        ans[i] = j+1;
      }
    }
  }

  rep(i,n)cout << ans[i] << endl;
  return 0;
} 

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

void knapsack_search(const ll pos, const ll W, const vll& w, const vll& v, vvll& dp){
  if(pos>=v.size()) return;
  if(pos==v.size()-1){
    for(ll i=0; i<min(w[pos], W+1); ++i){
      dp[pos][i] = 0;
    }
    for(ll i=w[pos]; i<=W; ++i){
      dp[pos][i] = v[pos];
    }
    return;
  }
  knapsack_search(pos+1, W, w, v, dp);
  for(ll i=0; i<min(w[pos], W+1); ++i){
    dp[pos][i] = dp[pos+1][i];
  }
  for(ll i=w[pos]; i<=W; ++i){
    dp[pos][i] = max(dp[pos+1][i-w[pos]] + v[pos], dp[pos+1][i]);
  }

  return;
}

void knapsack_search2(const ll pos, const ll W, const vll& w, const vll& v, vll& dp){
  if(pos>=v.size()) return;
  if(pos==v.size()-1){
    for(ll i=0; i<min(w[pos], W+1); ++i){
      dp[i] = 0;
    }
    for(ll i=w[pos]; i<=W; ++i){
      dp[i] = v[pos];
    }
    return;
  }
  knapsack_search2(pos+1, W, w, v, dp);
  vll dp_copy = dp;
  for(ll i=0; i<min(w[pos], W+1); ++i){
    dp[i] = dp_copy[i];
  }
  for(ll i=w[pos]; i<=W; ++i){
    dp[i] = max(dp_copy[i-w[pos]] + v[pos], dp_copy[i]);
  }

  return;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, W;
  cin >> N >> W;
  vll w(N), v(N);
  rep(i, 0, N){
    cin >> w[i] >> v[i];
  }

  //vvll dp(N, vll(W+1, 0));
  //knapsack_search(0, W, w, v, dp);

  vll dp(W+1, 0);
  knapsack_search2(0, W, w, v, dp);

  cout << dp[W] << "\n";

  return 0;
}

Measured memory_bytes: 1804
from collections import deque

def doubly(n):
    list = deque()
    for i in range(n):
        line = input().split()
        p = line[0]
        while True:
            try:
                key = line[1]
                break
            except IndexError:
                break
        if p == "insert":
            list.appendleft(key)
        elif p == "deleteFirst":
            list.popleft()
        elif p == "deleteLast":
            list.pop()
        else:
            while True:
                try:
                    list.remove(key)
                    break
                except ValueError:
                    break
    print(' '.join(list))

if "__main__" == __name__:
    n = int(input())
    doubly(n)



Measured memory_bytes: 69816
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <array>
#include <random>
#include <functional>
#include <sstream>
#include <queue>
#define rep(i, N) for(int i = 0; i < (N); i++)
#define repr(i, N) for(int i = N; i >= 0; i--)
#define all(v) v.begin(), v.end()
#define inf 1e9
#define idx(vec, element_iter) distance((vec).begin(), element_iter)
#define copy(vec1, vec2) copy(ALL(vec1), back_inserter(vec2)) //vec1をvec2にコピーする vec2は空にしておく必要がある

using namespace std;
typedef long long ll;

int main() {
    int N;
    int a[100];
    cin >> N;
    rep(i, N) cin >> a[i];
    int res = 0;
    rep(i, N) {
        if(i%2 == 0 && a[i]%2 == 1) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <math.h>
int judge(int);

int main(){
  int count=0, i, n, a[10000]={};
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
    count+=judge(a[i]);
  }
  printf("%d\n", count);
  return 0;
}

int judge(int a){
  int i;
  if(a==2){
    return 1;
  }
  if(a<2||a%2==0){
    return 0;
  }
  for(i=3;i<=(int)sqrt(a);i+=2){
    if(a%i==0){
      return 0;
    }
  }
  return 1;
}



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

int main(){
  int n;
  cin >> n;
  vector <int> v(n);
  int a,b;
  for(int i=0;i<n;i++){
    cin >> v.at(i);
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  a=v.at(0);
  vector< pair<double,int> > vp(n);
  for(int i=0;i<n;i++){
  vp.at(i).first=fabs(double(a)/2-v.at(i));
  vp.at(i).second=v.at(i);
 }
 sort(vp.begin(),vp.end());
 b=vp.at(0).second;
 cout << a << " " << b << endl;
 return 0;

}


Measured memory_bytes: 2176
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out)) {
            int r = in.nextInt(), s = in.nextInt(), p = in.nextInt();
            int[] d = new int[p];
            for (int i = 0; i < p; i++) {
                int y = in.nextInt(), x = in.nextInt();
                d[i] = (r - y + 1) + (x <= s ? s - x + 1 : x - s);
            }
            Arrays.sort(d);
            //System.out.println(Arrays.toString(d));

            for (int i = 1; i < p; i++) {
                d[i] = Math.max(d[i], d[i - 1] + 1);
            }
            out.println(d[p - 1]);
        }
    }
}



Measured memory_bytes: 252060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
/*
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
*/

int cnt_n(int x, int n) {
	int res = 0;
	while (x > 0) {
		res += x % n;
		x /= n;
	}	
	return res;
}

int main() {
	int N; cin >> N;
	int ans = 100000;
	rep(x, N + 1) {
		// db(cnt_n(x, 6)); dbl(cnt_n(N - x, 9));
		ans = min(ans, cnt_n(x, 6) + cnt_n(N - x, 9));
	}
	cout << ans << endl;
}

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

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

  string N= (bufN%10==0) ? to_string(bufN-1)
                         : to_string(bufN);
  const int lenN= N.size();
  const int Nhead= N.at(0) - '0';
  const int Ntail= N.back()- '0';

  int pat_common= 0;
  int diff= 1;
  for(int len=2; len <= lenN-1; len++){
    pat_common+= diff;
    diff*= 10;
  }

  int Pmiddigit= (lenN > 2) ? 1+ stoi(N.substr(1, lenN-2))
                :(lenN ==2) ? 1
                            : 0;

  auto pattern= [&](int head, int tail){
    int pat_len1= (head==tail && (head <= Nhead || lenN > 1)) ? 1
                                                              : 0;
    int pat_lenN=  (head < Nhead)                  ? diff
                  :(head== Nhead && tail <= Ntail) ? Pmiddigit
                  :(head== Nhead && tail >  Ntail) ? Pmiddigit-1
                                                   : 0;
    int ret= (head==0) ? 0
            :(lenN==1) ? pat_len1
                       : pat_len1+ pat_common+ pat_lenN;
    return ret;
  };

  int ans= 0;
  for(int head=1; head <= 9; head++){
    for(int tail=1; tail <= 9; tail++){
      ans+= pattern(head, tail)* pattern(tail, head);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;
    if(b%a == 0) cout << a+b << endl;
    else cout << b-a << endl;
    return 0;
}

Measured memory_bytes: 256
def LI():
  return [int(s) for s in input().split()]

N = int(input())

B_s = LI()

A_count = B_s[0]

for i in range(1,N):
  if i < (N-1):
  	A_count += min(B_s[i],B_s[i-1])
  else:
    A_count += B_s[i-1]
  
print(A_count)

Measured memory_bytes: 3060
#include <stdio.h>
int main(){

  int X1,Yuy,Yul,Yaddl,P,X,Y,Yaddy;

  scanf("%d %d %d %d %d",&X1,&Yuy,&Yul,&Yaddl,&P);

  X=P*X1;

  Yaddy=Yaddl*(P-Yul);

  if(Yaddy < 0)	Yaddy=0;

  if(X > Yuy+Yaddy) printf("%d\n",Yuy+Yaddy);
  else printf("%d\n",X);

  return 0;

}

Measured memory_bytes: 596
import math
while True:
    n=int(input())
    if n==0:
        break
    s=0
    lst=input().rstrip().split()
    lst=[int(s) for s in lst]
    m=sum(lst)/n
    for i in range(n):
        s+=(lst[i]-m)**2
    print("{:.8f}".format(math.sqrt(s/n)))


Measured memory_bytes: 5708
h,w = map(int,input().split())
grid = []
grid.append(["."]*(w+2))
for i in range(h):
    a = ["."]
    s = list(input())
    a.extend(s)
    a.append(".")
    grid.append(a)
grid.append(["."]*(w+2))
for i in range(1, h+1):
    for j in range(1, w+1):
        if grid[i][j] == ".":
            ans = 0
            for k in range(i-1, i+2):
                for l in range(j-1, j+2):
                    if grid[k][l] == "#":
                        ans += 1
            grid[i][j] = str(ans)
for i in range(1, h+1):
    print("".join(grid[i][1:-1]))



Measured memory_bytes: 40560
// Tazoe

#include <iostream>
using namespace std;

int main()
{
while(true){
	int n;
	cin >> n;
if(n==0)  break;
	int m = 1000-n;

	int sum = 0;

	sum += m/500;
	m %= 500;

	sum += m/100;
	m %= 100;

	sum += m/50;
	m %= 50;

	sum += m/10;
	m %= 10;

	sum += m/5;
	m %= 5;

	sum += m;

	cout << sum << '\n';
}
	return 0;
}

Measured memory_bytes: 0
N, M = map(int,input().split())
PY = [list(map(int,input().split())) + [0] for i in range(M)]
sort_PY = sorted(PY, key = lambda x: x[1])
city = {}
for py in sort_PY:
  if(py[0] not in city):
    city[py[0]] = 1
  else:
    city[py[0]] += 1
  py[2] = city[py[0]]
for py in PY:
  print(str(py[0]).zfill(6) + str(py[2]).zfill(6))

Measured memory_bytes: 30096
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#include<cstring>
#define ll long long
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>QUE;//きゅー
pair<pair<string, int>, int> p[110];//pair型
int length(char* str) {
    int len = strlen(str);
    return len;
}
ll GCD(ll a, ll b)
{

    ll 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;
}
ll LCM(ll a, ll b)
{

    ll r, x, tmp;
    ll i, j;
    ll lcm;
    i = a;
    j = b;

    /* 自然数 a > b を確認・入替 */
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    lcm = (i / b) * j;

    return lcm;
}
ll t[200020];
int main()
{
    char S[100010], T[100010];
    cin >> S >> T;
    int i = 0;
    while (T[i] != '\0') {
        cout << T[i];
        i++;
    }
    i = 0;
    while (S[i] != '\0') {
        cout << S[i];
        i++;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
int S,S1,S2,h,m,s;
scanf("%d",&S);

h=S/3600;
S1=h*3600;

m=(S-S1)/60;
S2=m*60;

s=(S-S1)-S2;

printf("%d:%d:%d\n",h,m,s);

return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;



int main(){
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    int y = ty - sy, x = tx - sx;
    string ans = "";
    for(int i = 0; i < y; i++) ans += "U";
    for(int i = 0; i < x; i++) ans += "R";
    for(int i = 0; i < y; i++) ans += "D";
    for(int i = 0; i < x; i++) ans += "L";

    ans += "L";
    for(int i = 0; i < y+1; i++) ans += "U";
    for(int i = 0; i < x+1; i++) ans += "R";
    ans += "D";
    ans += "R";
    for(int i = 0; i < y+1; i++) ans += "D";
    for(int i = 0; i < x+1; i++) ans += "L";
    ans += "U";
    cout << ans << endl;

}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200000 + 5;
int n, a[N];

ll absLL(ll x) {
	if(x < 0) return -x;
	return x;
}

ll calc(ll x) {
	ll ret = 0;
	for(int i=0; i<n; ++i)
		ret += absLL(a[i] - x);
	return ret;
}

int main() {
	scanf("%d", &n);
	for(int i=0; i<n; ++i) {
		scanf("%d", a+i);
		a[i] -= i+1;
	}

	ll l = -2e9, r = 2e9, m1, m2, r1, r2, res = 1e18;
	while(l <= r) {
		m1 = (l+l+r)/3;
		m2 = (l+r+r)/3;
		r1 = calc(m1);
		r2 = calc(m2);
		if(r1 <= r2) {
			r = m2-1;
			res = min(r1, res);
		} else {
			l = m1+2;
			res = min(r2, res);
		}
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 1024
W, H, x, y = map(int, input().split())
if x == (W/2):
    if y == (H/2):
        men = W*H/2
        print(men)
        print(1)
    else:
        men = W*H/2
        print(men)
        print(0)
else:
        men = W*H/2
        print(men)
        print(0)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define int int64_t
#define watch(x) cout << (#x) << " is " << (x) << endl

const int32_t MAX=1e9+7;
typedef vector<int> vi;
typedef vector<int64_t> vll;

int32_t main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed;

    //Problem code start

    string s;
    int sum{0};
    cin >> s;
    for(char c:s){
        sum+=((int)(c-'0'));
    }
    if(sum%9==0)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

typedef pair<int, int> PII;
typedef long long ll;

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

	int n;
	cin >> n;
	int a[100003];
	memset(a,0,sizeof(a));
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	a[0]=a[1];
	int dp[100003];
	dp[0]=0;
	for (int i = 0; i < n; i++) {
		dp[i+1]=min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
		dp[i+2]=dp[i]+abs(a[i]-a[i+2]);
	}
	cout << dp[n] << "\n";
}

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

int main(){
    long long  n,m,k;
    cin>>n>>m>>k;
    for(long long i=0; i<=n; i++){
        for(long long j=0; j<=m; j++){
            if(n*j+m*i-2*i*j==k){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOREACH(element, vec_name) for (auto &(element) : (vec_name))

#define VECCIN(vec_name) for (auto &element : (vec_name)) cin >> element

#define dump(x) cout << #x << " = " << (x) << endl;

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

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }//最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }//最小公倍数

int GCD(vector<int> vec){ //多入力のGCD．入力はvectorとして与える
    int g = vec[0];
    FOREACH(element, vec){
        g = gcd(g, element);
    }
    return g;
}


int main()
{
    ll h;
    cin >> h;
    int beki = 0;
    ll s = 1;
    if(1 == h){
        beki =0;
    }else{
        while (s <= h)
        {
            beki++;
            s = pow(2, beki + 1);
        }
    }
    //dump(beki);
    //dump(s);
    ll ans;
    ans = pow(2,beki +1) -1;
    cout << ans << endl;

    return 0;
}

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

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] a = Input.ScanIntArray();
          int[] town = new int[a[0]];
          for(int i=0;i<a[1];i++){
            int[] b = Input.ScanIntArray();
            town[b[0]-1]++; town[b[1]-1]++;
          }
          foreach(var k in town)
          Out(k);
        }
        static public void Out(object s) { Console.WriteLine(s); }
    }
    
    static class Input {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(); }
    }

    static class MyMath {
        public static int DistanceL1(int[] a, int[] b){
            if(a.Length != b.Length) return -1;
            int[] c = new int[a.Length];
            for(int i=0;i<a.Length;i++)
              c[i] = Math.Abs(a[i]-b[i]);
            return c.Sum();
        }

        public static double DistanceL2(int[] a, int[] b){
            if(a.Length != b.Length) return -1;
            int[] c = new int[a.Length];
            for(int i=0;i<a.Length;i++)
              c[i] = (a[i]-b[i])*(a[i]-b[i]);
            return Math.Sqrt(c.Sum());
        }
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13396
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

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

bool isProperXY(int x, int y, int N) {
	if(0 <= x && 0 <= y && x+y<N) {
		return true;
	} else {
		return false;
	}
}

int main() {
	int N, C;
	while(cin >> N >> C, N) {
		vvi board(N, vi(N));
		vector<pii> emptyPoint;
		REP(i, N) {
			REP(j, i+1) {
				cin >> board[i-j][j];
				if(board[i-j][j] == 0) {
					emptyPoint.push_back(pii(i-j, j));
				}
			}
		}

		int size = emptyPoint.size(), ans = -INF;
		REP(i, size) {
			vvi field = board;
			field[emptyPoint[i].first][emptyPoint[i].second] = C;
			vvi visited(N, vi(N));
			int pts = 0;
			REP(i, N) {
				REP(j, i+1) {
					if(!visited[i-j][j] && field[i-j][j] != 0) {
						int num = field[i-j][j], node = 0;
						bool live = false;
						queue<pii> Q;
						Q.push(pii(i-j, j));
						visited[i-j][j] = 1;
						while(!Q.empty()) {
							pii p = Q.front();
							Q.pop();
							node++;
							REP(d, 6) {
								int ny = p.first+dy[d], nx = p.second+dx[d];
								if(isProperXY(nx, ny, N) && !visited[ny][nx]) {
									if(field[ny][nx] == 0) {
										live = true;
									} else if(field[ny][nx] == num) {
										visited[ny][nx] = 1;
										Q.push(pii(ny, nx));
									}
								}
							}
						}
						if(!live) {
							if(num == C) {
								pts -= node;
							} else {
								pts += node;
							}
						}
					}
				}
			}
			ans = max(ans, pts);
		}
		cout << ans << endl;
	} 

	return 0;
}

Measured memory_bytes: 1220
# coding: utf-8
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# x * xをどう評価するか、heapに「おいしさ」の高い順に入れていく
N, K = lr()
TD = [lr() for _ in range(N)]
heap = []
kind = 0
happy = 0
used = set()
TD.sort(key=lambda x: x[1], reverse=True)
for t, d in TD[:K]:
    if t not in used:
        used.add(t)
        kind += 1
    else:
        heappush(heap, d)
    happy += d

cand = [happy+kind**2]
for t, d in TD[K:]:
    if not heap:
        break
    if t in used:
        continue
    h = heappop(heap)
    happy += (d-h)
    kind += 1
    used.add(t)
    cand.append(happy+kind**2)

answer = max(cand)
print(answer)


Measured memory_bytes: 31000
import java.util.Scanner;

public class Main {

    static int count = 0;

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();

        int[] s = new int[n];

        for (int i = 0; i < n; i++) {

            s[i] = scanner.nextInt();

        }

        

        mergeSort(s, 0, n);

        

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

            System.out.print(s[i] + " ");

        }

        System.out.println(s[n-1]);

        

        System.out.println(count);

    }

    

    static void mergeSort(int[] a, int left, int right) {

        if (left + 1 < right) {

            int mid = (left + right) / 2;

            

            mergeSort(a, left, mid);

            mergeSort(a, mid, right);

            

            merge(a, left, mid, right);

        }

    }

    

    static void merge(int[] a, int left, int mid, int right) {

        int n1 = mid - left;

        int n2 = right - mid;

        int[] aL = new int[n1 + 1];

        int[] aR = new int[n2 + 1];

        for (int i = 0; i < n1; i++) {

            aL[i] = a[left + i];

        }

        for (int i = 0; i < n2; i++) {

            aR[i] = a[mid + i];

        }

        

        aL[n1] = Integer.MAX_VALUE;

        aR[n2] = Integer.MAX_VALUE;

        

        int i = 0;

        int j = 0;

        for (int k = left; k < right; k++) {

            count++;

            if (aL[i] <= aR[j]) {

                a[k] = aL[i];

                i++;

            } else {

                a[k] = aR[j];

                j++;

            }

        }

    }

}




Measured memory_bytes: 167732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){ 
  int n;
  cin >> n;
  string s = "";
  while(n) {
    int d = n % 2;
    if (d < 0) d += 2;
    n = (n - d) / (-2);
    s += d + '0'; 
  }
  reverse(s.begin(), s.end());
  if (s.empty()) s = '0';
  cout << s << endl;
  return 0;
} 

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

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

#define fr(i,n)     for(int i=0;i<n;i++)
#define frr(i,n)    for(int i=1;i<=n;i++)

#define ms(x,i) memset(x,i,sizeof(x))
#define dbg(x)  cout << #x << " = " << x << endl
#define all(x)  x.begin(),x.end()

#define gnl cout << endl
#define chapa cout << "oi meu chapa" << endl
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
//cout << setprecision(9)<<fixed;

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef pair<ll,ll> pll;

const int INF = 0x3f3f3f3f;
const ll llINF = (long long)(1e18) + 100;   
const int MAXN = 100100;
const int MAXM = 1001000;
const ll mod=1e9+7;
const int LMAXN = 25;
ll n, k;
vector<pll> v;

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

	ll a, b;
	fr(i, n){
		cin>>a>>b;
		v.pb({a, b});
	}
	
	sort(all(v));

	ll pos = 0;

	fr(i,n){
		if (pos <= k and k <= pos + v[i].snd){
			cout<<v[i].fst<<endl;
			return 0;
		}
		pos += v[i].snd;
	}

}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,nrdivs[10000007],suma;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
        nrdivs[i]=1;
    for(ll i=2;i<=n;i++)
        if(nrdivs[i]==1)
    {
        nrdivs[i]=2;
        for(ll j=i*2;j<=n;j+=i)
        {
            ll x=j;
            ll p=0;
            while(x%i==0)
            {
                p++;
                x/=i;
            }
            nrdivs[j]*=(p+1);
        }
    }
    for(ll i=1;i<=n;i++)
        suma+=i*nrdivs[i];
    cout<<suma;
    return 0;
}


Measured memory_bytes: 81764
#include<math.h>
#include<stdio.h>

int main()
{
    int a,b,c,d,n,cnt;
    while(scanf("%d",&n)!=EOF){
    cnt=0;
    for(a=0;a<10;a++){
        for(b=0;b<10;b++){
            for(c=0;c<10;c++){
                for(d=0;d<10;d++){
                    if(a+b+c+d==n)cnt++;
                    }
                }
            }
        }
    printf("%d\n",cnt);
    }
    return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;
public class Main{
    static int[][] mat = new int[3][3];
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int i, j;
        for(i = 0; i < 3; i++){
            for(j = 0; j < 3; j++){
                mat[i][j] = sc.nextInt();
            }
        }
        
        System.out.println(
        (mat[0][0] - mat[0][1] == mat[1][0] - mat[1][1] && mat[1][0] - mat[1][1] == mat[2][0] - mat[2][1] &&
         mat[0][1] - mat[0][2] == mat[1][1] - mat[1][2] && mat[1][1] - mat[1][2] == mat[2][1] - mat[2][2] &&
         mat[0][0] - mat[1][0] == mat[0][1] - mat[1][1] && mat[0][1] - mat[1][1] == mat[0][2] - mat[1][2] &&
         mat[1][0] - mat[2][0] == mat[1][1] - mat[2][1] && mat[1][1] - mat[2][1] == mat[1][2] - mat[2][2])
        ? "Yes" : "No");
    }
}

Measured memory_bytes: 23764
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

int a[M+4];
int pre[M+4];
int lft[M+4];
int rgt[M+4];

 main()

{
    fast
    int n,k;
    cin>>n>>k;
    int ses=0;
    f(i,1,n)
    {
        cin>>a[i];
        ses+=a[i];
        pre[i]=a[i]+pre[i-1];
        lft[i]=lft[i-1];
        if(a[i]>0)lft[i]+=a[i];
    }
    ses=max(ses,0LL);
    rf(i,n,1)
    {
        rgt[i]=rgt[i+1];
        if(a[i]>0)rgt[i]+=a[i];
    }
    for(int i=1;i<=n-k+1;i++)
    {
        int l=i;
        int r=i+k-1;
        int sum=pre[r]-pre[l-1];
        sum=max(sum,0LL);
        sum+=rgt[r+1];
        sum+=lft[l-1];
        ses=max(ses,sum);
    }
    cout<<ses<<endl;
    return 0;

}













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

int main(){
    int n,ans=0;
    string ss;
    cin>>n>>ss;
    for(int i=0;i<n;i++){
        if(ss[i]=='A')
            if(ss[i+1]=='B' && ss[i+2]=='C')
                ans++;
    }
    cout<<ans;
    return 0;
}


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

int main()
{
    int H, W;
    cin >> H >> W;
    bool s[H + 1][W + 1] = {};
    bool visited[H + 1][W + 1] = {};
    int ans = H * W;
    string S;
    for (int i = 1; i <= H; i++)
    {
        cin >> S;
        for (int j = 0; j < W; j++)
        {
            if (S[j] == '.')
            {
                s[i][j + 1] = true;
            }
            else
            {
                ans--;
                s[i][j + 1] = false;
            }
        }
    }

    queue<int> x;
    x.push(1);
    int dx[4] = {1, 0, -1, 0};

    queue<int> y;
    y.push(1);
    int dy[4] = {0, 1, 0, -1};

    queue<int> distance;
    distance.push(1);
    visited[1][1] = true;

    while (x.size() * y.size() > 0)
    {
        int current_x = x.front();
        x.pop();
        int current_y = y.front();
        y.pop();
        int current_distance = distance.front();
        distance.pop();
        for (int i = 0; i < 4; i++)
        {
            int new_x = current_x + dx[i];
            int new_y = current_y + dy[i];

            if (new_x == W && new_y == H)
            {
                cout << ans - (current_distance + 1) << endl;
                return 0;
            }
            if (1 <= new_x && new_x <= W)
            {
                if (1 <= new_y && new_y <= H)
                {
                    if (!visited[new_y][new_x])
                    {
                        if (s[new_y][new_x])
                        {
                            x.push(new_x);
                            y.push(new_y);
                            visited[new_y][new_x] = true;
                            distance.push(current_distance + 1);
                        }
                    }
                }
            }
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    vi a(5);
    in(5,a);
    rep(i,5) if(i+1 != a[i]) cout << i+1 << endl;
    
    

    return 0;
}


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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s, s1, s2;
    cin >> s;
    int q;
    cin >> q;
    int t, f;
    bool is_rev = false;
    while(q--){
        char ch;
        cin >> t;
        if(t == 1){
            is_rev = !is_rev;
        }else{
            cin >> f >> ch;
            if(f == 1){
                if(is_rev){
                    s2.push_back(ch);
                }else{
                    s1.insert(s1.begin(), ch);
                }
            }else{
                if(is_rev){
                    s1.insert(s1.begin(), ch);
                }else{
                    s2.push_back(ch);
                }
            }
        }
    }
    if(is_rev){
        reverse(s.begin(), s.end());
        reverse(s1.begin(), s1.end());
        reverse(s2.begin(), s2.end());
        cout << s2 << s << s1 << endl;
    }else{
        cout << s1 << s << s2 << endl;
    }
}

Measured memory_bytes: 1040
import sys
N = int(input())
H = list(map(int,input().split()))
H[0] -= 1
for i in range(N-1):
  if H[i+1] > H[i]:
    H[i+1] -= 1
   
  if H[i+1] < H[i]:
    print('No')
    sys.exit()

print('Yes')
  

Measured memory_bytes: 63984
// ~/Remember,remember the 6th of March

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-8;
const ll MOD = 1000000007;
const int N = 100000 + 7;

int main()
{
    int a,b;
    cin>>a>>b;
    b+=b;
    if(b>=a)
        cout<<0<<endl;
    else
        cout<<a-b<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

int main(void){

    int a,b,c;
    
    scanf("%d %d %d",&a,&b,&c);
    
    if(a+b+c>=22)
        printf("bust");
    
    else
        printf("win");
   
    }
        


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;


int main()
{
    int n;
    cin >> n;
    vector<P> l;
    rep(i, n){ int tmpx, tmpy; cin >> tmpx >> tmpy; l.emplace_back(tmpx, tmpy);}


    double ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            double dx = l[i].first - l[j].first;
            double dy = l[i].second - l[j].second;
            ans += sqrt((dx * dx) + (dy * dy));
        }        
    }
    double mut = 1;
    rep(i, n-1){
        mut *= (i + 1);
    }
    ans *= (2.0 / (double)n);
    
    printf("%4.10lf", ans);
}



Measured memory_bytes: 256
import math
K=int(input())
def f(n):
    return sum([math.gcd(n,i) for i in range(2,K+1)])
dic={i:f(i) for i in range(1,K+1)}
s=K**3-(K-1)**3
for a in range(2,K+1):
    for b in range(2,K+1):
        s+=dic[math.gcd(a,b)]
print(s)

Measured memory_bytes: 9200
n, m, x = gets.chomp.split(" ").map(&:to_i)
a=[]
a=gets.chomp.split(" ").map(&:to_i)
cnt0=0
cntN=0
for i in 0..x do
  for j in cnt0...m do
    if i==a[j] then
      cnt0+=1
    end
  end
end
for i in x..n do
  for j in cntN...m do
    if i==a[j] then
      cntN+=1
    end
  end
end
if cnt0<=cntN then
  p cnt0
else
  p cntN
end


Measured memory_bytes: 1788
import heapq
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]
count_black = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            count_black += 1
is_visited = [[False for j in range(W)] for i in range(H)]
q = []
heapq.heappush(q, (1, (0, 0)))
is_visited[0][0] = True
lrud = [[0, -1], [0, 1], [-1, 0], [1, 0]]
while q:
    cost, (x, y) = heapq.heappop(q)
    if x == H-1 and y == W-1:
        break
    for dx, dy in lrud:
        if 0 <= x + dx < H and 0 <= y + dy < W and \
            S[x+dx][y+dy] == '.' and not is_visited[x+dx][y+dy]:
            heapq.heappush(q, (cost+1, (x+dx, y+dy)))
            is_visited[x+dx][y+dy] = True
if x == H-1 and y == W-1:
    print(H*W-count_black-cost)
else:
    print(-1)

Measured memory_bytes: 69068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

struct T {
    char c;
    int x;
};

void bubble (vector<T> &a, int n) {
    rep (i, 0, n) {
        per (j, i, n) {
            if (a[j].x < a[j - 1].x) {
                swap (a[j], a[j - 1]);
            }
        }
    }
}

void selection (vector<T> &a, int n) {
    rep (i, 0, n) {
        int minj = i;
        rep (j, i, n) {
            if (a[j].x < a[minj].x) {
                minj = j;
            }
        }
        swap (a[i], a[minj]);
    }
}

bool stable (vector<T> a, vector<T> b, int n) {
    rep (i, 0, n) {
        if (a[i].c != b[i].c) return false;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    vector<T> a (n), b (n);
    rep (i, 0, n) {
        cin >> a[i].c >> a[i].x;
        b[i] = a[i];
    }
    bubble (a, n);
    rep (i, 0, n) {
        if (i) cout << " ";
        cout << a[i].c << a[i].x;
    }
    cout << "\nStable\n";
    selection (b, n);
    rep (i, 0, n) {
        if (i) cout << " ";
        cout << b[i].c << b[i].x;
    }
    if (stable (a, b, n)) cout << "\nStable\n";
    else
        cout << "\nNot stable\n";
}


Measured memory_bytes: 3160