akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3") 
#include<bits/stdc++.h>
#define ll      				long long int
#define vi      				vector<int>
#define ii      				pair<int,int>
#define iii     				pair<ii,int>
#define iiii    				pair<ii,ii>
#define fi      				first
#define se      				second

#define pb      				push_back
#define pob     				pop_back

#define all(x)  				x.begin(), x.end()
#define len     				length()

#define db(x)					  cout << "!!!!!! " << #x << " => " << x << "\n"

#define fori(i, s, N)     for (int i = s; i <= N; i++)
#define fd(i, s, N)     for (int i = s; i >= N; i--)
using namespace std;

void init(int precision){
  	ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

ll n,sum;
int main(){
	init(10);
	cin>>n;
	sum = 0;
	for(int i = 1;i<=n;i++){
		if(i%15 == 0){
			continue;
		}else if(i %3 == 0){
			continue;
		}else if(i%5 == 0){
			continue;
		}else sum+=i;
	}
	cout<<sum<<"\n";
	return 0;
}

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

bool check(vector<char> word) {
    if (word.size() % 2 != 0) {
        return false;
    }
    
    int half = word.size()/2;
    for (int i=0; i<half; i++) {
        if (word[i] != word[i+half]) {
            return false;
        }
    }

    return true;
}

int main() {
    vector<char> word;
    int n;

    cin >> n;
    for (int i=0; i<n; i++) {
        char letter;
        cin >> letter;
        word.push_back(letter);
    }

    
    if (check(word)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

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

int main(){
  string s;
  cin >> s;
  //cout << s << endl;
  bool ans = true;
  // cout << ans << endl;
  for(int i=0; i<s.size(); i++){
    if(i % 2 == 0){
      if(s.at(i) == 'L'){
        ans = false;
        break;
      }
    }
    else{
      if(s.at(i) == 'R'){
        ans = false;
        break;
      }
    }
  }
  
  //cout << ans <<endl;
  
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
#define REP(i, a, b) for(long long int i = a; i < b; i++)

int main(void) {
    char s[20], a[20] = "";
    int co = 0;
    scanf("%s", s);
    REP(i, 0, strlen(s)) {
        if (s[i] == '0') {
            strcat(a, "0");
            co++;
        } else if (s[i] == '1') {
            strcat(a, "1");
            co++;
        } else if (s[i] == 'B' && co != 0) {
            co--;
            a[co] = '\0';
        }
    }
    puts(a);
    return 0;
}

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

#define INF 2e9

#define REP(i,n) for(int i = 0; i < n;++i)
#define REPA(i,a,n) for(int i = a; i < n; ++i)
#define REPR(i,a) for(int i = a; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

int gcd(int a, int b){ return b ? gcd(b, a % b) : a; }
template<typename A> void printsn(A a){ cout << a << endl; }
template<typename A, typename... B> void printsn(A a, B... b){ cout << a << ' '; printsn(b...); }

int main() {

    int N;

    cin >> N;

    REP(i, 9){
        REPA(j, i, 9){
            if((i + 1) * (j + 1) == N) {
                printsn("Yes");
                return 0;
            }
        }
    }

    printsn("No");

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
as = gets.split.map(&:to_i)
as.sort!
flag = as.each_with_index.any? do |a, i|
  (n.even? ? (i / 2 * 2 + 1) : ((i + 1) / 2 * 2)) != a
end
if flag
  puts 0
  exit
end
mod = 10 ** 9 + 7
puts Array.new(n / 2, 2).inject(1) { |a, b| a * b % mod }

Measured memory_bytes: 8840
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, Q; cin >> N >> Q;
	string S; cin >> S;
	int num[N] = {};
	for (int i = 0; i < N - 1; i++) {
		if (S[i] == 'A'&&S[i + 1] == 'C') num[i + 1]++;
		num[i + 1] += num[i];
	}
	for (int i = 0; i < Q; i++) {
		int l, r;cin>>l>>r;
		cout << num[r-1] - num[l-1] << endl;
	}
}


Measured memory_bytes: 1408
def main
  w, h, x, y = gets.split.map(&:to_i)

  if w / 2.0 == x && h / 2.0 == y
    result = 1
  else
    result = 0
  end

  puts "#{w * h / 2.0} #{result}"
end

main if $0 == __FILE__


Measured memory_bytes: 1788
# include "bits/stdc++.h"

using namespace std;

#define endl "\n"
typedef long long int ll;
#define f first
#define s second

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}

//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;

ll INF = 1e10;
int MOD = 1e9+7;

int main(){
    #ifndef ONLINE_JUDGE
        freopen("debug.txt", "w", stderr);
    #endif
    fastio();
    
    string s;
    cin >> s;
    if(s == "SSS")
        cout << 0;
    if(s == "SSR")
        cout << 1;
    if(s == "SRS")
        cout << 1;
    if(s == "SRR")
        cout << 2;
    if(s == "RSS")
        cout << 1;
    if(s == "RSR")
        cout << 1;
    if(s == "RRS")
        cout << 2;
    if(s == "RRR")
        cout << 3;
    return 0;
}


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

#define MOD 1000000007

int dp[100005], A[100005];

int main()
{
    ios::sync_with_stdio(0);
    
    int N, M;
    cin >> N >> M;

    while(M--)
    {
        int x;
        cin >> x;

        A[x] = 1;
    }

    dp[0] = 1;

    for(int i=1; i<=N; i++)
    {
        if(A[i])
            continue;
        
        if(i == 1)
            dp[i] = dp[i-1];
        else
            dp[i] = (dp[i-1] + dp[i-2]) % MOD;
    }
    
    cout << dp[N] << "\n";
    return 0;
}


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


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

int main(){
    string s;cin>>s;
    string ans="";
    rep(i,0,s.size()-1){
        if(i%2==0){
            ans=ans+s[i];
        }
    }
    cout<<ans<<endl;
    
    return 0;
}







Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
    int n,x;
    
    while(1){
        int a=0;
        cin >>n >>x;
        
        if (n==0 && x==0){
            break;
        }
        for (int i=1; i<n-1; i++){
            for (int j=i+1; j< n; j++){
                for(int k=j+1; k<n+1; k++){
                    if(i+j+k == x){
                        a += 1;
                        
                    }
                }
            }
            
        }cout<<a<<endl;
    }
}


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


int main(){
	int a,b;
	string s;

	cin>>a>>b>>s;
	if(s.size()==a+b+1&&s[a]=='-'){
		for(int i=0;i<a;i++){
			if(0>s[i]-'0'||s[i]-'0'>=10){
				cout<<"No"<<endl;
				return 0;
			}
		}
		
		for(int i=a+1;i<a+b+1;i++){
			if(0>s[i]-'0'||s[i]-'0'>=10){
				cout<<"No"<<endl;
				return 0;
			}
		}
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
H, n = map(int, input().split())
magics = []
for _ in range(n):
    a, b = map(int, input().split())
    magics.append((a, b))

# 体力をn削るために必要なmpの最小値
dp = [0] * (H+1)
for h in range(1, H+1):
    dp[h] = min([dp[max(h-a, 0)] + b for (a, b) in magics])

print(dp[-1])


Measured memory_bytes: 42460
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;

	int a[N];
	rep(i, N) cin >> a[i];
	sort(a, a + N);
	int size = a[0];
	int combo = 1;
	REP(i, 1, N-1) {
		if (size * 2 >= a[i]) {
			combo++;
		}
		else {
			combo = 1;
		}
		size += a[i];

	}
	cout << combo << endl;




    return 0;
}


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

int main() 
{
    int N;
    cin >> N;
    int A[N+1], B[N];
    for (int i = 0; i < N+1; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];  

    long long total = 0;
    int tmp = 0;
    for (int i = 0; i < N; i++) 
    {
        tmp = min(A[i], B[i]);
        A[i] -= tmp;
        B[i] -= tmp;
        total += tmp;
        tmp = min(A[i+1], B[i]);
        A[i+1] -= tmp;
        B[i] -= tmp;
        total += tmp;
    }
    cout << total << endl;
}

Measured memory_bytes: 1024
class Array
  def +(other)
    zip(other).map {|x, y| x + y }
  end
end
m, n = gets.split.map(&:to_i)
a = (1..m).map { gets.split.map(&:to_i) }
a << a.inject(:+).dup
a.each do |row|
  row << row.inject(:+)
  puts row * " "
end


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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int n;
    cin >> n;

    vs32 w(n);
    vs32 A(n);
    vector< bool > done(n, false);
    rep (i, n)
    {
      cin >> w[i];
      A[i] = w[i];
    }

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

    map<int, int> m;
    int gmin = A[0];
    rep (i, n)
    {
      m[A[i]] = i;
    }

    int ans = 0;
    rep (i, n)
    {
      if (done[i]) continue;
      int first = w[i];
      int now = w[m[first]];

      int lmin = first;
      int cnt = 0;

      ans += first;
      done[m[first]] = true;
      while (now != first)
      {
	ans += now;
	done[m[now]] = true;
	lmin = MIN(lmin, now);
	now = w[m[now]];
	++cnt;
      }
      if (cnt - 1 > 0)
      {
	ans += MIN((cnt - 1) * lmin, (cnt + 2) * gmin + lmin);
      }
      else
      {
	ans += (cnt - 1) * lmin;
      }
      done[i] = true;
    }

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




Measured memory_bytes: 3244
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

struct P {
  string s;
  int p, n;
};

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

  vector<P> A(N);
  REP(i, N){
    cin >> A[i].s >> A[i].p;
    A[i].n = i+1;
  }

  sort(ALL(A), [&](P const & l, P const & r){
      if(l.s == r.s) return l.p > r.p;
      return l.s < r.s;
      });

  REP(i, N){
    cout << A[i].n << "\n";
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int k,x;
    cin>>k>>x;
    for(int i=-300;i<=300;i++){
        if(abs(i-x)<k){
            cout << i;
            if(i-x==k-1){
                cout << endl;
            }else{
                cout << " ";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int n,m;
bool path[8][8];
int ans=0;

void dfs(vi v,int num){
	vi tmp=v;
	tmp.push_back(num);
	sort(ALL(tmp));
	if(tmp.size()==n){
		ans++;
		return;
	}
	REP(i,n){
		if(path[num][i]){
			if(!binary_search(ALL(tmp),i)){
				dfs(tmp,i);
			}
		}
	}
}

int main(){
	cin>>n>>m;
	
	REP(i,8)REP(j,8) path[i][j]=false;
	REP(i,m){
		int a,b;
		cin>>a>>b;
		path[a-1][b-1]=path[b-1][a-1]=true;
	}
	
	vi v;
	dfs(v,0);
	
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    int N, K; cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    sort(A.begin(), A.end());
    int s = accumulate(A.begin(), A.begin() + K, 0);
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3624
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N,X = inpl()
xx = inpl()
sum_xx = [0]
tmp = 0
for x in xx:
    tmp += x
    sum_xx.append(tmp)

ans = INF
for k in range(1,N+1):  #ゴミ箱に戻る回数
    tmp = X*(k+N)
    i = 0
    l = N-k
    r = N
    while True:
        if i <= 1: cost = 5
        else: cost = 3 + i*2
        if l >= 0:
            tmp += (sum_xx[r] - sum_xx[l])*cost
        else:
            tmp += (sum_xx[r] - sum_xx[0])*cost
            break
        l -= k
        r -= k
        i += 1
    ans = min(ans,tmp)

print(ans)


Measured memory_bytes: 28496
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

////////////////////////////////////////////////////////

int main() {
    ll x; cin >> x;
    if(x >= 30) co("Yes");
    else co("No");

    return 0;
}




Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	while (1)
	{
		

	
	int n;
	cin >> n;
	if(n==0)break;
	int sum = 0;
	vector<int> s(n);
	for(int i = 0;i < n;i++)cin >> s[i];
	for(int i = 0;i < n;i++)
	{
		sum += s[i];
	}
	double ave = (double)sum/(double)n; 
	double ans = 0;
	for(int i=0;i<n;i++)
	{
		ans += ((double)s[i]-ave)*((double)s[i]-ave);
	}
	
	ans /= (double)n;
	ans = sqrt(ans);
	printf("%.7lf\n",ans);
	}
	return 0;
}


Measured memory_bytes: 3220
#include<iostream>

#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

int main(void) {
	int w, h, x, y, r;
	bool flag1 = false;
	bool flag2 = false;
	bool flag3 = false;
	bool flag4 = false;

	CI w >> h >> x >> y >> r;

	if ((w - (x + r)) >= 0) {
		flag1 = true;
	}

	if (r <= x) {
		flag2 = true;
	}
		
	if (r <= y) {
		flag3 = true;
	}
			
	if ((h - (r + y)) >= 0) {
		flag4 = true;	
	}
	if (x < 0 || y < 0) {
		flag1 = false;
	}
		
	

	if (flag1 == true && flag2 == true && flag3 == true && flag4 == true) {
		CO "Yes" E
	}
	else {
		CO "No" E
	}
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(){
    int x;
    scanf("%d",&x);
    if (x >= 400 && x <= 599)
        puts("8");
    if (x >= 600 && x <= 799)
        puts("7");
    if (x >= 800 && x <= 999)
        puts("6");
    if (x >= 1000 && x <= 1199)
        puts("5");
    if (x >= 1200 && x <= 1399)
        puts("4");
    if (x >= 1400 && x <= 1599)
        puts("3");
    if (x >= 1600 && x <= 1799)
        puts("2");
    if (x >= 1800 && x <= 1999)
        puts("1");
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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 main() {
    ll N; cin >> N;
    vector<ll> T(N + 1, 0), X(N + 1, 0), Y(N + 1, 0);
    reps(i, N) {
        cin >> T[i] >> X[i] >> Y[i];
    } 

    bool ans = true;
    for (ll i = 0; i < N; i++) {
        ll dt = T[i + 1] - T[i], distance = abs(X[i + 1] - X[i]) + abs(Y[i + 1] - Y[i]);
        if (dt < distance) ans = false;
        if (dt % 2 != distance % 2) ans = false;
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 5580
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int N, M;
    cin >> N >> M;

    priority_queue<int> A;
    int total = 0;
    REP(i, N) {
        int a;
        cin >> a;
        total += a;
        A.push(a);
    }
  
    while (M > 0) {
        int value = A.top();
        A.pop();
        value /= 2;
        A.push(value);
        --M;
    }
    ll ans = 0;
    while (!A.empty()) {
        int value = A.top();
        A.pop();
        ans += value;
    }
    print(ans);

}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <string.h>
#include <stdio.h>

using namespace std;

int main(void){
  // op: + - * /
  // input: a op b
  int a, b;
  string op;
  int result;
  while(1){
    cin >> a >> op >> b;
    if(op == "?") break;
    if(op == "+") result = a + b;
    if(op == "-") result = a - b;
    if(op == "*") result = a * b;
    if(op == "/") result = a / b;

    cout << result << endl;
  }
  return 0;
}


Measured memory_bytes: 3164
s = input()

dp = [0] * (len(s) + 1)
dp[0] = 1

for i in range(len(s) + 1):
    # check s[:i]
    if i >= 5 and s[i-5:i] == 'dream' and dp[i-5]:
        dp[i] = 1
    if i >= 7 and s[i-7:i] == 'dreamer' and dp[i-7]:
        dp[i] = 1
    if i >= 5 and s[i-5:i] == 'erase' and dp[i-5]:
        dp[i] = 1
    if i >= 6 and s[i-6:i] == 'eraser' and dp[i-6]:
        dp[i] = 1
if dp[-1]:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3956
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template <class T> void swap(T& a, T& b) { T t = std::move(a); a = std::move(b); b = std::move(t); }

// 最大公約数
ll gcd(ll a, ll b)
{
    if(a%b == 0){
        return(b);
    }
    else{
        return(gcd(b, a%b));
    }
}

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

int main(void)
{
    ll N, i, T[101], ans;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> T[i];
    }

    if(N==1){
        cout << T[1] << endl;
    }

    else{
        ans = lcm(T[1],T[2]);

        if(N>=3){
            for(i=3; i<=N; i++){
                ans = lcm(ans,T[i]);
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 256
import math

def main():
    max_len = 10 ** 5 + 1
    sosuu_hantei = [0 for i in range(max_len)]

    for i in range(2, max_len):
        flg = 1
        for j in range(int(i ** 0.5) + 1):
            if sosuu_hantei[j]:
                if i % j == 0:
                    flg = 0
                    break
        if flg:
            sosuu_hantei[i] = 1

    # print(sosuu_hantei[:10])

    for i in range(max_len)[::-1]:
        if sosuu_hantei[i] == 0:
            continue
        if sosuu_hantei[(i + 1) // 2]:
            pass
        else:
            sosuu_hantei[i] = 0

    # print(sosuu_hantei[:10])

    now_count = 0
    for i in range(max_len):
        if sosuu_hantei[i]:
            now_count += 1
        sosuu_hantei[i] = now_count

    # print(sosuu_hantei[:10])

    num = int(input())
    for i in range(num):
        a, b = map(int, input().split())
        print(sosuu_hantei[b] - sosuu_hantei[a - 1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 53024
#include <iostream>

using namespace std;

int main(){
   int a, b;

   cin >> a >> b;
   if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
      cout << "Possible" << endl;
   }else{
      cout << "Impossible" << endl;
   }
}

Measured memory_bytes: 3616
import sys
s = input()
for i,c in enumerate(s[1:-1],1):
  if s[i-1]!=s[i+1]:
    break
else:
  print('Second')
  sys.exit()
if s[0]==s[-1]:
  if len(s)%2==0:
    print('First')
  else:
    print('Second')
if s[0]!=s[-1]:
  if len(s)%2==0:
    print('Second')
  else:
    print('First')
    

Measured memory_bytes: 39792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong a;
string s;

int main() {
    cin >> a;
    cin >> s;

    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;

    return 0;
}


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

typedef pair<int, string> P;

map<string, string> change;
string input, output;

string Replace(string s, string from, string to){
  string::size_type pos = 0;
  while(pos = s.find(from, pos), pos != string::npos){
    s.replace(pos, from.size(), to);
    pos += to.size();
  }
  return s;
}

int bfs(){
  set<string> ever;
  ever.insert(input);
  P start(P(0, input));
  queue<P> que;
  que.push(start);
  while(!que.empty()){
    P tmp = que.front();
    que.pop();

    int cnt = tmp.first;
    string in = tmp.second;
    if(in == output) return cnt;
    
    for(map<string, string>::iterator it = change.begin() ; it != change.end() ; it++){
      string after = Replace(in, it->first, it->second);
      int count = cnt+1;
      if(after.size() > output.size()) continue;
      if(ever.find(after) != ever.end()) continue;
      ever.insert(after);
      que.push(P(count, after));
    }
  }
  return -1;
}

void init(){
  change.clear();
}
      
int main(){
  int n;
  while(cin >> n, n){
    init();
    string a, b;
    for(int cs = 0 ; cs < n ; cs++){
      cin >> a >> b;
      change[a] = b;
    }
    cin >> input >> output;
    cout << bfs() << endl;
  }
  return 0;
}

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

int main() {
    int N,M;
    cin>>N>>M;
    int a[M],b[M];
    for(int i=0;i<M;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=1;i<N+1;i++){
        int x=0;
        for(int j=0;j<M;j++){
            if(i==a[j]||i==b[j])
                x++;

        }
        cout<<x<<endl;
        
    }

    
}

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

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#define ll long long
#define vi vector <int>
#define pb push_back
using namespace std;

#define bs 1000000007

int tests;
map<int,int> mapp;
int n;
vector<int> order;
map<int,int> ::iterator it;

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

    ll n1;cin>>n1;
    cout<<3.14*2*n1<<endl;

}



Measured memory_bytes: 3812
import sys

h, w = map(int, sys.stdin.readline().split())
canvas = ['.' * (w + 2)] + ['.' + sys.stdin.readline().rstrip() + '.' for _ in range(h)] + ['.' * (w + 2)]


def main():
    res = [[0] * (w + 1) for _ in range(h + 1)]
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if canvas[i][j] == '#':
                res[i][j] = '#'
                continue
            for di in range(-1, 2):
                for dj in range(-1, 2):
                    y = i + di
                    x = j + dj
                    if canvas[y][x] == '#':
                        res[i][j] += 1
    
    for i in range(1, h+1):
        yield ''.join(list(map(str, res[i][1:])))

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 3064
require 'matrix'
require 'mathn'

n, q = gets.split.map(&:to_i)

obs = (1..n).map { gets.split.map(&:to_i) }
q.times do
    x1, y1, z1, x2, y2, z2 = gets.split.map(&:to_i)
    v1 = Vector[x2 - x1, y2 - y1, z2 - z1]
    sum = 0
    obs.each do |x, y, z, r, l|
        v2 = Vector[x - x1, y - y1, z - z1]
        d2 = v1.inner_product(v2) ** 2 / (v1.to_a.map{|t| t * t}.inject(:+))
        if v1.inner_product(v2) < 0
            sum += l if (x - x1) ** 2 + (y - y1) ** 2 + (z - z1) ** 2 <= r * r
        elsif d2 > (v1.to_a.map{|t| t * t}.inject(:+))
            sum += l if (x - x2) ** 2 + (y - y2) ** 2 + (z - z2) ** 2 <= r * r
        else
            sum += l if v2.to_a.map{|t| t * t}.inject(:+) - d2 <= r * r
        end
    end
    p sum
end

Measured memory_bytes: 9540
package main

import (
	"fmt"
	"math"
)

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	s := make([]int64, n+1)
	w := make([]int64, n+1)
	for i := 0; i < n; i++ {
		s[i+1] = s[i] + int64(a[i])
		w[i+1] = w[i] + int64(max(a[i], 0))
	}
	ans := int64(math.MinInt64)
	for i := 0; i <= n-k; i++ {
		x := w[n] - (w[i+k] - w[i])
		x += max64(s[i+k]-s[i], 0)
		ans = max64(ans, x)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
S=input()
for bit in range(1<<3):
    f=int(S[0])
    s=S[0]
    for i in range(3):
        if bit&(1<<i):
            f+=int(S[i+1])
            s+="+"+S[i+1]
        else :
            f-=int(S[i+1])
            s+="-"+S[i+1]
    if f==7:
        print(s+"=7")
        exit()

Measured memory_bytes: 38256
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    while True:
        if m==-1 or f==-1:
            print("F")
            break
        sum=m+f
        
        
        if sum>=80:
            print("A")
            break
        elif 65<=sum<80:
            print("B")
            break
        elif 50<=sum<65:
            print("C")
            break
        elif 30<=sum<50:
            if r>=50:
                print("C")
                break
            print("D")
            break
        else:
            print("F")
            break
    



Measured memory_bytes: 5596
k, n = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
kyori = []
n.times do |i|
    if i < n - 1
        kyori << a[i+1] - a[i]
    else
        kyori << k - a[i] + a[0]
    end
end
puts kyori.inject(:+) - kyori.max

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


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


    if(a == 0) cout << 0 << endl;
    else if(b == 0) cout << n << endl;
    else{
        if( n%(a+b) > a) cout << n/(a+b)*a + a << endl;
        else cout << n/(a+b)*a + n%(a+b) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    cout << abs(A[0] - A[N - 1]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int x, i, j, k, n, max=0;

    scanf("%d", &x);

    for(i=1; i<=x; i++){
        n=i;
        for(j=0; j<x; j++){
            n *= i;
            if(n > x)
                break;
            if(max < n)
                max = n;
        }
    }

    printf("%d\n", max);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}
 
 
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 	
 	ll n;
 	cin >> n;

 	ll ans = 0;
 	for(ll i = 2; i * i <= n; i++){
 		ll cnt = 0;
 		ll cur = 1;
 		while(n % i == 0){
 			cnt++;
 			n /= i;

 			if(cnt == cur){
 				ans++;
 				cur++;
 				cnt = 0;
 			}
 		}
 	}

 	if(n > 1)
 		ans++;

 	cout << ans << endl;

	return 0;	
}

Measured memory_bytes: 3648
#include<iostream>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    int A[N];
    for(int i = 0; i < N; i++)cin >> A[i];
    
    int i = 0;
    while(A[i] != 1)i++;

    int ans = i/(K-1) + (N-(i+1))/(K-1);
    if(i%(K-1)==0 &&  (N-(i+1))%(K-1) == 0)cout << ans;
    else if(i%(K-1)==0 ||  (N-(i+1))%(K-1) == 0)cout << ans + 1;
    else if(i%(K-1)+(N-(i+1))%(K-1) < K)cout << ans + 1;
    else cout << ans + 2;
    
}

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

int h,w,n;

inline int origin(int a, int b){
  int left = (a&1)==(b&1) ? 1 : 0;
  int rem = left ? b : w-1-b;
  //cout << left << " " << rem << endl;
  if(rem >= a){
    if(left)return rem-a;
    else return b+a;
  }
  a -= rem;

  int rev = (a/w)&1;
  rem = a%w;
  //cout << rem << " " << rev << endl;
  if(left == 1-rev)return max(0,rem-1);
  else return min(w-1,w-rem);
}

int main(){
  cin >> h >> w >> n;
  vector< pair<int,int> > bars(n);
  for(int i=0;i<n;i++){
    int a,b; cin >> a >> b; a--; b--;
    bars[i] = make_pair(a,b);
  }
  sort(bars.begin(),bars.end());


  vector<int> perm(w);
  for(int i=0;i<w;i++)perm[i] = i;

  for(int i=0;i<n;i++){
    int a = origin(bars[i].first, bars[i].second);
    int b = origin(bars[i].first, bars[i].second+1);
    //cout << a << " " << b << endl;
    swap(perm[a],perm[b]);
  }
  //for(int i=0;i<w;i++)cout << origin(h,i) << endl;

  vector<int> inv_perm(w);
  for(int i=0;i<w;i++)inv_perm[perm[origin(h,i)]] = i;

  for(int i=0;i<w;i++)cout << inv_perm[i]+1 << endl;
}

Measured memory_bytes: 4164
// Contest: AtCoder Beginner Contest 146 (https://atcoder.jp/contests/abc146)
// Problem: B: ROT N (https://atcoder.jp/contests/abc146/tasks/abc146_b)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    int n; string s; cin >> n >> s;
    trav(c, s)
        c = ((c - 'A' + n) % 26) + 'A';
    cout << s << '\n';

    return 0;
}

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

int main() {
	int r, g, b;
	cin >> r >> g >> b;
	if ((2 * g + b) % 4 == 0) cout << "YES";
	else cout << "NO";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

実際に4の倍数か判定すれば良い
ところで、3桁の整数をxとするとx=100r+10g+b=4(25r+2g)+2g+bになるよね
ここで4(25r+2g)は絶対に4の倍数なので、判定に使うのは2g+bだけで大丈夫だよ
*/

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 105
using namespace std;

typedef long long ll;
ll h, w, n, d[N][9];
ll M = 1e9 + 7;
int main()
{
	ll i, j, k;
	cin >> h >> w >> n;
	d[0][0] = 1;
	for (i = 1; i <= h; i++) {
		for (j = 0; j < 1 << w - 1; j++) {
			if (j & j >> 1) continue;
			for (k = 0; k < w; k++) {
				if (j & 1 << k - 1) d[i][k] = (d[i][k] + d[i - 1][k - 1]) % M;
				else if (j & 1 << k) d[i][k] = (d[i][k] + d[i - 1][k + 1]) % M;
				else d[i][k] = (d[i][k] + d[i - 1][k]) % M;
			}
		}
	}
    cout << d[h][n - 1] << endl;
    return 0;
}

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

int main() {
  int N,i,k=0;
  cin >> N;
  vector<int> a(N);
  for(i=0;i<N;++i)
    cin >> a.at(i);
  i=0;
  do{
    ++k;
    i=a.at(i)-1;
    if(i==1)
      break;
  }while(--N);
  if(N)
    cout << k << endl;
  else
    cout << -1 << endl;
    
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};



int main(){
  int X,A,B;cin>>X>>A>>B;
  if(A>=B){
    cout<<"delicious"<<endl;
  }else if(X+A>=B){
    cout<<"safe"<<endl;
  }else{
    cout<<"dangerous"<<endl;
  }
  return 0;
}


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

int max(int a, int b){
	return a >= b ? a : b;
}

int min(int a, int b){
	return a <= b ? a : b;
}

int main(){
	int N, A, B;
	scanf("%d%d%d", &N, &A, &B);
	printf("%d %d\n", min(A, B), max(0, A + B - N));
	return 0;
}

Measured memory_bytes: 128
use std::io::Read;

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    if n == 1 {
        println!("Hello World");
    } else {
        let a: usize = iter.next().unwrap().parse().unwrap();
        let b: usize = iter.next().unwrap().parse().unwrap();
        println!("{}", a + b);
    }
}


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

using namespace std;


int TakeQueue[25];

void judge(const int n) {
	int sum,i;
	bool flag;

	sum = 32;
	i = 0;
	flag = true;
	while (sum != 1) {
		if (flag) {
			sum -= (sum - 1) % 5;
			cout << sum << endl;
			flag = false;
		}
		else {
			sum -= TakeQueue[i];
			i = (i + 1) % n;
			cout << sum << endl;
			flag = true;
		}
	}
	cout << "0" << endl;
}


int main(void) {
	int n;

	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> TakeQueue[i];
		}
		judge(n);
	}

	return 0;
}


Measured memory_bytes: 3004
import math
n = int(input())
A = list(map(int,input().split()))

cnt = 0

def merge(A, left, mid, right):

  global cnt
  L = A[left:mid]
  L.append(math.inf)
  R = A[mid:right]
  R.append(math.inf)
  i = 0
  j = 0
  for k in range(left,right):
    if L[i] < R[j]:
      A[k] = L[i]
      i = i + 1
    else:
      A[k] = R[j]
      j = j + 1
      cnt += len(L) -1 -i


def mergeSort(A,left,right):

    if left +1 < right:
        mid = (left+right) // 2
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)

mergeSort(A,0,n)

print(cnt)


Measured memory_bytes: 28952
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

vector<pair<ll,ll> > ans;
ll K;
ll X,Y;
ll dx,dy;
pair<ll,ll> modify;

pair<ll,ll> strategy(ll x,ll y,ll K){
  //x,yは残りの距離、Kは移動可能距離
  // cout<<"remain "<<x<<" "<<y<<endl;
  if(x<0){
    modify = strategy(-x,y,K);
    return mp(-modify.first,modify.second);
  }
  if(y<0){
    modify = strategy(x,-y,K);
    return mp(modify.first,-modify.second);
  }
  if(x>y){
    modify = strategy(y,x,K);
    return mp(modify.second,modify.first);
  }
  //ここでは0<=x<=yであるはず
  ll L = x+y;
  //まだまだだからとりあえず近ずく
  if(L>2*K){
    dx = min(x,K);
    dy = K - dx;
    return mp(dx,dy);
  }
  //lastの移動
  if(L==K){
    return mp(x,y);
  }
  if((x+y)%2==0){
    //2回でいける
    ll t = (y-x)/2;
    dx = K-t;
    dy = t;
    return mp(dx,dy);
  }
  //3回でいける
  dx = min(K,x);
  dy = K-dx;
  return mp(dx,dy);
}

int main(){
  cin>>K;
  cin>>X>>Y;
  ll x=0,y=0;
  pair<ll,ll> move;

  if(K%2==0 and (X+Y)%2!=0){
    cout<<-1<<endl;
    return 0;
  }

  else{
    while(x!=X or y!=Y){
      move = strategy(X-x,Y-y,K);
      x += move.first;
      y += move.second;
      ans.pb(mp(x,y));
    }
    cout<<ans.size()<<endl;
    rep(i,ans.size()) cout<<ans[i].first<<" "<<ans[i].second<<endl;
  }

}


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

int main(){
	int x,y;
  	int a[20]={0,1,3,1,2,1,2,1,1,2,1,2,1};
  	cin >> x >>y;
  	if (a[x]==a[y])cout << "Yes" <<endl;
  	else cout << "No" <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int lcm(int x, int y) { return x / gcd(x, y) * y; }

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

  string s;
  cin >> s;

  int n = s.length();
  int count = 0;
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[n - i - 1]) ++count;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define p 20
using namespace std;

int main(){
	int N,M,C;
	int A[p];
	int B[p];
	int i,j;
	int sum;
	int x=0;
	
	cin >> N >> M >> C;
	
	for(i=0;i<M;i++)
		cin >> A[i];
	
	for(j=0;j<N;j++){
		sum=0;
		for(i=0;i<M;i++){
			cin >> B[i];
			sum+=(A[i]*B[i]);
		}
		if(sum+C>0)
			x++;
	}
	
	cout << x << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        boolean ans = true;
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < N; i++) {
            int A = sc.nextInt();
            if (set.contains(A)) {
                ans = false;
                break;
            }
            set.add(A);
        }
        System.out.println(ans ? "YES" : "NO");
    }
}



Measured memory_bytes: 98540
<?php
fscanf(STDIN, "%s", $n);
if(($n[0] == $n[1] && $n[0] == $n[2]) ||
   ($n[1] == $n[2] && $n[1] == $n[3])) {
    echo 'Yes'."\n";
} else {
    echo 'No'."\n";
}

Measured memory_bytes: 4728
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
using namespace std;
typedef long long ll;
const int maxn = 100005;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int a,b,c;
  cin>>a>>b>>c;
  cout<<min(c,b/a)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
    cin>>n;
	vector<int>vec(n*2);
    for(int i=0;i<n*2;i++){
    	cin>>vec.at(i);
    }
    sort(vec.begin(),vec.end());
    int x=0;
    for(int i=0;i<n;i++){
      x=x+vec.at(i*2);
      }
    cout<<x<<endl;
}

Measured memory_bytes: 256
use proconio::input;
use proconio::fastout;

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        mut a: [f64; n],
    }

    a.sort_by(|x, y| x.partial_cmp(y).unwrap());
    a.reverse();
    let mut ok = 1000000000.0;
    let mut ng = 0.0;
    let exp = 0.0000000000000009;
    for _ in 0 .. 100 {
        let mid = (ok + ng) / 2.0;
        let mut count: usize = 0;
        for v in &a {
            count += (v / mid - exp).floor() as usize;
        }
        if count <= k {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    println!("{}", (ok - exp).ceil());

}


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

int main() {
  int N;
  int counter = 1;
  int temp = 1;
  cin >> N;
  vector<int> buttons(N);
  
  for(int i=0; i<N; i++){
    cin >> buttons.at(i);
  }
  
  for(int i=0; i<N; i++){
    temp = buttons.at(temp-1);
    if (temp == 2){
      cout << counter << endl;
      return 0;
    }else{
     counter++;
    }
    if (i == N-1){
      cout << -1;
    }
  }
}


Measured memory_bytes: 640
import java.util.Scanner;

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

            long min = (long) 1e18;
            long sqrt = (long) Math.sqrt(N) + 10;
            for (long A = 1; A < sqrt; A++) {
                if (N % A != 0) {
                    continue;
                }
                long B = N / A;

                min = Math.min(min, F("" + A, "" + B));
            }

            System.out.println(min);
        }
    }

    private static long F(String a, String b) {
        return Math.max(a.length(), b.length());
    }
}


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

using namespace std;

int main() {
	string a, b, s;
  	int a1, b1;
  	cin >> a >> b;
  	cin >> a1 >> b1;
  	cin >> s;
  	if(a == s) {
      a1--;
    } else {
      b1--;
    }
  	cout << a1 << ' ' << b1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <numeric> 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define int long long int
#define mod 1000000007
#define INT_BITS 16
#define inf 1000000099
#define pi 3.141592
#define watch(x) cout<<(#x)<<"="<<(x)<<"\n" 
#define pb push_back


 set<int> primeFactors(int n) 
{ 
     set<int>us;
    // Print the number of 2s that divide n 
    while (n%2 == 0) 
    { 
        us.insert(2);
        n = n/2; 
    } 
  
    // n must be odd at this point.  So we can skip  
    // one element (Note i = i +2) 
    for (int i = 3; i <= sqrt(n); i = i+2) 
    { 
        // While i divides n, print i and divide n 
        while (n%i == 0) 
        { 
            us.insert(i);
            n = n/i; 
        } 
    } 
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2 
    if (n > 2) 
        us.insert(n); 

    return us;
}


int32_t main()
{
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
  #endif
      int n;
      cin>>n;
     set<int>us=primeFactors(n);
     unordered_map<int,vector<int>>um;
     for(auto x:us)
     {
        for(int i=1;i<=10;i++)
        {
            um[x].push_back(pow(x,i));
        }
     }
     int count=0;
      for(auto x:us)
      {
        int val=pow(x,1);
        int i=0;
        while(val <= n)
        {
            i++;
            if(n%val==0)
            {
                n/=val;
                count++;
                val=um[x][i];
                //watch(val);
            }
            else
              break;
            
        }
        //cout<<x<<" ";
      }
      cout<<count<<endl;
      
}

Measured memory_bytes: 4112