akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;

double kitaichi(ll N){
	double d=0,t;
	for(ll i=1;i<=N;i++){
		t=i/(double)N;
		d=d+t;
	}
	return d;
}

int main()
{
	ll N,K,t;
	double ANS=0;
	vector<ll>Dice;
	vector<pair<ll,ll>>V;
	cin>>N>>K;
	rep(i,N){
		cin>>t;
		Dice.push_back(t);
	}
	rep(i,N-K+1){
		ll t=0;
		rep(j,K){
			t=t+Dice[i+j];
		}
		V.push_back(make_pair(t,i));
	}
	sort(V.begin(),V.end());
	rep(i,K){
		ANS=ANS+kitaichi(Dice[V.back().second+i]);
	}
	cout << fixed << setprecision(20) << ANS << endl;
}

Measured memory_bytes: 8468
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int MAX = 16;

vector<vector<ll>> solve(vector<ll> a, int offset = 0) {
    int n = a.size();
    vector<vector<ll>> dp(n + 1, vector<ll>(MAX, INF));
    for (int j = 0; j < MAX; ++j) dp[0][j] = 0, dp[1][j] = j * 2 + offset;
    for (int i = 1; i < n; ++i) {
        ll s = a[n - i - 1];
        for (int j = 0; j < MAX; ++j) {
            ll t = a[n - i];
            int need = 0;
            while (s > t) ++need, t *= 4;
            ll add = 0;
            if (need >= MAX) {
                add = (need - MAX + 1) * i * 2;
                need = MAX - 1;
            }
            cmin(dp[i + 1][j], dp[i][need] + j * 2 + add + offset);
            s *= 4;
        }
    }
    return dp;
}

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    for (ll &l:v) cin >> l;

    auto right = solve(v, 0);
    reverse(v.begin(), v.end());
    auto left = solve(v, 1);
    ll res = INF;
    for (int i = 0; i <= n; ++i) cmin(res, left[i][0] + right[n - i][0]);
    cout << res << endl;
}


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

int main()
{
  int n;
  while (cin >> n, n){
    bool f = false;
    map<int, long> mil;
    vector<int> vi;
    int e, p, q;
    for (int i = 0; i < n; i++){
      cin >> e >> p >> q;
      if (mil[e] == 0) vi.push_back(e);
      mil[e] += p * q;
    }

    int m = vi.size();
    for (int i = 0; i < m; i++){
      if (mil[vi[i]] >= 1000000) {
        cout << vi[i] << "\n";
        f = true;
      }
    }
    if (!f) cout << "NA\n";
  }
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K;
    vector<int> L(N); rep(i, N) cin >> L[i];
    sort(L.rbegin(),L.rend());
    int ans = 0; rep(i, K) ans += L[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define ll long long
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
using namespace std;
const int N=2003;
ll a[N],b[N],x,ans=0;
ll n,m;
int main()
{
	  
	  cin>>n>>x;
	  FOR(i,1,n)
	    cin>>a[i],ans+=a[i],b[i]=a[i];
	  FOR(i,1,n-1)
	  {
	  	ll sum=0;
	    FOR(j,1,n)
		  {
		       ll k=(j-i>0)?j-i:j-i+n;
			   if(a[k] < b[j]) sum+=a[k],b[j]=a[k];
			   else sum+=b[j];
		  }    
		 sum+=i*x;
	//	 cout<<sum<<endl;
		 ans=min(ans,sum); 
	  }
	  cout<<ans;
 	  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin>>n;
	cout<<arr[n-1];
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

const ll N_MAX = 1005;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];
void make(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll) i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

ll combination(ll C, ll D){
    if(C<D||C<1) return 0;
    return fac[C]*(finv[D]*finv[C-D]%mod)%mod;
}

ll dp[2][505][1005];

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

    ll N, X;
    cin >> N >> X;
    dp[0][0][0] = 1;

    REP(i, X+1){
    	REP(j, 505)REP(k, 1005) dp[(i+1)%2][j][k] = 0;
    	REP(j, X+1){
    		REP(k, 1005){
    			if((k^i)<1005){
    				dp[(i+1)%2][j+1][k^i] += dp[i%2][j][k];
    				dp[(i+1)%2][j+1][k^i] %= mod;
    			}

    			dp[(i+1)%2][j][k] += dp[i%2][j][k];
    			dp[(i+1)%2][j][k] %= mod;
    		}
    	}
    }

    ll res = 0;
    for(int i=0;i<=N;i++){
    	if((N-i)%2==0){
    		ll r = (N-i)/2;
    		res += (dp[(X+1)%2][i][X] * combination(X+r, r))%mod;
    		res %= mod;
    	}
    }
    cout << res << endl;

    /*
    REP(i, 10){
    	REP(j, 10){
    		cout << dp[X+1][i][j] << " ";
    	}
    	cout << endl;
    }
    */
    return 0;
}


Measured memory_bytes: 11172
#include<bits/stdc++.h>
using namespace std;
int a,b,c,ans;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	if(a==b)ans++;
	if(a==c)ans++;
	if(b==c)ans++;
	if(ans==1)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;


int main(){
  int n,m,h,k;
  while(scanf("%d%d%d%d",&n,&m,&h,&k),(n|m|h|k)){
    vector<pair<int,int> > p(m);
    vector<int> point(n);
    vector<int> memo(n);
    vector<int> rev(n);
    vector<int> buff(n);

    REP(i,n){
      scanf("%d",&point[i]);
      memo[i] = buff[i] = i;
    }

    REP(i,m) scanf("%d%d", &p[i].s, &p[i].f);
    sort(p.begin(),p.end());
    
    REP(i,m){
      int a = p[i].s - 1;
      swap(memo[a], memo[a+1]);
    }
    REP(i,n) rev[memo[i]] = i;

    int ans = 0;
    /* no change */
    REP(i,n) if(memo[i] < k)
      ans += point[i];

    //printf("nodelete: %d\n",ans);

    REP(i,m){
      int a = p[i].s - 1;
      int s1 = buff[a];
      int s2 = buff[a+1];
      
      int ss1 = rev[s1];
      int ss2 = rev[s2];
      
      swap(memo[ss1], memo[ss2]);
      
      int anst = 0;
      REP(j,n) if(memo[j] < k)
	anst += point[j];
      ans = min(ans, anst);
      
      //printf("delete (a=%d,b=%d): %d\n",p[i].s,p[i].f,anst);
      
      swap(memo[ss1], memo[ss2]);
      swap(buff[a], buff[a+1]);
    }
    
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1788
#include<stdio.h>

#define MAX 1000
#define VMAX 10000

int A[MAX],B[MAX],T[VMAX+1];
int n,s;
int merge(int A[],int left,int mid,int right)
{
	int L[500000],R[500000];
	int n1,n2,i,j,k;
	n1=mid-left;
	n2=right-mid;
	for(i=0;i<n1;i++)
	{
		L[i]=A[left+i];
	}
	for(i=0;i<n2;i++)
	{
		R[i]=A[mid+i];
	}
	L[n1]=999999999;
	R[n2]=999999999;
	i=0;
	j=0;
	for(k=left;k<right;k++)
	{
		if(L[i]<=R[j])
		{
			A[k]=L[i];
			i=i+1;
		}
		else
		{
			A[k]=R[j];
			j=j+1;
		
		}
	}
}
int mergesort(int A[],int left,int right)
{
	int mid;
	if(left+1<right)
	{
		mid=(left+right)/2;
		mergesort(A,left,mid);
		mergesort(A,mid,right);
		merge(A,left,mid,right);
	}
	else
	{
		return 0;
	}
}
int min(int a,int b)
{
	if(a<=b)
	{
		return a;
	}
	else 
	{
		return b;
	}
}

int solve()
{
	int V[MAX];
	int result=0;
	int i;
	for(i=0;i<n;i++)
	{
		B[i]=A[i];
		V[i]=0;
	}
	mergesort(B,0,n);
	for(i=0;i<n;i++)
	{
		T[B[i]]=i;
	}
	for(i=0;i<n;i++)
	{
		if(V[i])
		{
			continue;
		}
		int cur=i;
		int S=0;
		int m=VMAX;
		int a=0;
		while(1)
		{
			V[cur]=1;
			a++;
			int v=A[cur];
			m=min(m,v);
			S+=v;
			cur=T[v];
			if(V[cur])
			{
				break;
			}
		}
		result+=min(S+(a-2)*m,m+S+(a+1)*s);
	}
	return result;
}
int main(void)
{	
	int i;
	s=VMAX;
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
		s=min(s,A[i]);
	}
	int result=solve();
	
	printf("%d\n",result);
	
	return 0;
}
	


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, A; cin >> N >> A;
  vector<int> X(N); REP(i, N) cin >> X[i];
  int S = accumulate(ALL(X), 0);
  vector<vector<ll>> dp(N+1, vector<ll>(S+1, 0));
  dp[0][0] = 1;
  REP(k, N) {
    for (int i = N-1; i >= 0; i--) {
      for (int j = S-1; j >= 0; j--) {
        if (j + X[k] <= S) dp[i+1][j+X[k]] += dp[i][j];
      }
    }
  }

  ll ans = 0;
  FOR(i, 1, N+1) if (i * A <= S) ans += dp[i][i * A];
  cout << ans << endl;

  //REP(i, S+1) cout << dp[N][i] << (i == S ? '\n' : ' ');

  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    int x[3][3];
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> x[i][j] ;
        }
        
    }
    int a[3], b[3];
    a[0] = 0;
    b[0] = x[0][0];
    b[1] = x[0][1];
    b[2] = x[0][2];
    a[1] = x[1][0] - b[0];
    a[2] = x[2][0] - b[0];
    bool flag = true;
    for (int k = 0; k < 3; ++k) {
        for (int i = 0; i < 3; ++i) {
            if(x[k][i] != a[k] + b[i]) {
                flag = false;
                break;
            }

        }

    }
    if(flag) cout << "Yes";
    else cout << "No";
    cout << endl;

    return 0;
}


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

int main() {
  int N,K,a=1;
  cin >> N >> K;

  for(int i=0 ; i < N ; i++){
    if(a + K > a * 2)
      a *= 2;
    else
      a += K;
  }

  cout << a << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// 標準入力からデータを読み込む準備
try (Scanner sc = new Scanner(System.in)) {
String line = sc.nextLine();
String answer = "";
int length = line.length();
for (int i = 0; i < length; i++) {
char ch = line.charAt(i);
// Character.isLowerCase で小文字かどうか判断可能
// Character.toUpperCase, Character.toLowerCase で変換
// 記号は上記メソッドで変換にかけても変化しない
if(Character.isLowerCase(ch)==true)answer+=Character.toUpperCase(ch);
else if(Character.isUpperCase(ch)==true)answer+=Character.toLowerCase(ch);
else answer+=ch;
}
System.out.println(answer);
}
}
}



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

int main() {
  string S;
  cin >> S;
  if (S == "Sunny") {
    cout << "Cloudy" << endl;
  }
  else if (S == "Cloudy") {
    cout << "Rainy" << endl;
  }
  else {
    cout << "Sunny" << endl;
  }
}


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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    LL a, b, k;
    cin >> a >> b >> k;

    bool flag = true;

    //even
    if( ( b - a + 1) % 2 == 0){

        if( k > ( b - a + 1) / 2){
            flag = false;
        }
    }
    else{
        if( k >= 1 + ( b - a + 1) / 2 ){
            flag = false;
        }
    }

    if( flag){

        for ( int i = a; i < a + k; i++){
            cout << i << endl;
        }
        for( int i = b - k + 1; i <= b; i++){
            cout  << i << endl;
        }
    }
    else{

        for( int i = a;  i <= b ;i++){
            cout << i << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    long long int n,m,cnt=0;
    cin>>n>>m;
    if(n*2<=m)
    {
        cnt+=n;
        m-=(n*2);
        n=0;
    }
    else
    {
        cnt+=(m/2);
        cout<<cnt<<endl;
        return 0;
    }
    if(m>=4)
    {
        cnt+=(m/4);
        cout<<cnt<<endl;
        return 0;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
program main

  implicit none

  integer :: n, d, i, j, k, flag
  integer, allocatable, dimension ( :, : ) :: x
  real :: r, tmp

  read ( unit = *, fmt = * ) n, d

  allocate ( x ( 1:n, 1:d ) )

  do i = 1, n

     read ( unit = *, fmt = * ) x ( i, 1:d )

  end do

  flag = 0
  
  do i = 1, n

     do j = i + 1, n

        tmp = 0.d0

        do k = 1, d

           tmp = tmp + ( x ( i, k ) - x ( j, k ) )**2

        end do

        r = sqrt ( tmp )

        if ( abs ( real ( int (r) ) - r ) < 1.d-8 ) then

           flag = flag + 1

        end if

     end do

  end do

  print '(i0)', flag
  
  
end program main


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var list = new List<string>();
            var ans = "Yes";

            for (int i = 0; i < n; i++)
            {
                var w = Read();
                if (list.Contains(w))
                {
                    ans = "No";
                    break;
                }

                if (i != 0)
                {
                    var maenoword = list[i - 1];
                    if (maenoword[maenoword.Length-1] != w[0])
                    {
                        ans = "No";
                        break;
                    }
                }

                list.Add(w);
            }
            WriteLine(ans);
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

using namespace std;

int num[]={0,2,5,5,4,5,6,3,7,6};

int main()
{
    int k,n;

    cin>>k>>n;

    vector<int>arr;

    for(int i=0;i<n;i++){
            int a;
    cin>>a;
        arr.push_back(a);
    }


    sort(arr.begin(),arr.end());
    reverse(arr.begin(),arr.end());

   vector<int> dp(k+1, -10);

    dp[0]=0;

        dp[0] = 0;
    for(int i = 1; i <= k; i++) {
        for(int j=0;j<n;j++){
            if(i >= num[arr[j]]) {
                dp[i] = max(dp[i], dp[ i - num[arr[j]] ] + 1);
            }
        }
    }



   // cout<<dp[k]<<endl;
    int nokori = k;
    for(int i=0;i<dp[k];i++) {
    for(int j=0;j<n;j++){
            if(nokori >= num[arr[j]] && dp[ nokori - num[arr[j]] ] == dp[nokori] - 1) {
                cout << arr[j];
                nokori -= num[arr[j]];
                break;
            }
        }
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int h = Integer.parseInt(sc.next());
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		int sum = 0;

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
			sum += a[i];
		}
		if (sum >= h) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}
}

Measured memory_bytes: 47772
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+5;
const ll mod=1e9+7;
int a[N];
int main()
{
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
    scanf("%d",&a[i]);
   sort(a+1,a+1+n);

   int k=a[n/2];
   int kk=a[n/2+1];
   cout<<kk-k<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
int main ()
{
	int N,i;
	scanf("%d",&N);
	char S[10000],a[10000],b[10000];
	scanf("%s",S);
	if(N==1)
	{
		printf("No");
	}
	else if(N%2!=0)
	{
		printf("No");
	}
	else
	{
		for(i=0;i<N/2;i++)
		{
			a[i]=S[i];
			b[i]=S[(N/2)+i];
		}
		int d=strcmp(a,b);
		if(d==0)
		{
			printf("Yes");
		}
		else
		{
			printf("No");
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define abu ios_base::sync_with_stdio(0)
#define said cin.tie(0)
using namespace std;

void yes(){
    cout<<"YES"<<endl;
}

void no(){
    cout<<"NO"<<endl;
}

void solve(){
    ll n;
    cin>>n;
    ll a,b;
    cin>>a>>b;
    ll fa = a*(n/(a+b));
    fa+=min(n%(a+b),a);
    cout<<fa<<endl;
}

int main(){
    abu;
    said;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import defaultdict


class PrimeFactor():

    def __init__(self, n):                  # エラトステネス　O(N loglog N)
        self.n = n
        self.table = list(range(n+1))
        self.table[2::2] = [2]*(n//2)
        for p in range(3, int(n**0.5) + 2, 2):
            if self.table[p] == p:
                self.table[p * p::2 * p] = [p] * ((n - p * p - 1) // (2 * p) + 1)

    def is_prime(self, x):  # 素数判定　O(1)
        if x < 2:
            return False
        return self.table[x] == x

    def prime_factors(self, x):             # 素因数分解 O(logN)
        res = []
        if x < 2:
            return res
        while self.table[x] != 1:
            res.append(self.table[x])
            x //= self.table[x]
        return res

    def prime_counter(self, x):             # 素因数分解（個数のリスト）
        res = defaultdict(int)
        if x < 2:
            return res
        while self.table[x] != 1:
            res[self.table[x]] += 1
            x //= self.table[x]
        return res

    def prime_gcd(self, X):                 # n個の最大公約数　X:n個のリスト
        exponents = self.prime_counter(X[0])
        for x in X[1:]:
            Y = self.prime_counter(x)
            for prime, exp in exponents.items():
                if Y[prime] < exp:
                    exponents[prime] = Y[prime]
        res = 1
        for prime, exp in exponents.items():
            res *= pow(prime, exp)
        return res

    def prime_lcm(self, X, mod=None):       # n個の最小公倍数　X:n個のリスト
        exponents = defaultdict(int)
        for x in X:
            for prime, exp in self.prime_counter(x).items():
                if exp > exponents[prime]:
                    exponents[prime] = exp
        res = 1
        for prime, exp in exponents.items():
            res *= pow(prime, exp, mod)
        if mod == None:
            return res
        else:
            return res % mod

mod = 10 ** 9 + 7

N = int(input())
A = list(map(int, input().split()))
table = PrimeFactor(10**6)
num = table.prime_lcm(A,mod)

res = 0
for a in A:
    res += num * pow(a, mod - 2, mod)

print(res % mod)

Measured memory_bytes: 90212
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int N; std::cin >> N;
  std::string S; std::cin >> S;
  int K; std::cin >> K;

  char t = S[K-1];
  for (char& c : S) {
    if (c != t) c = '*';
  }

  std::cout << S << std::endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = input().split()
a = [int(m) for m in a]
s = []
for i in range(m):#h:高さ
    s.append([int(m) for m in input().split()])
s.sort(key=lambda x:(x[0], x[1]))
class UnionFind():
    #負の値はルートで集合の個数
    #正の値は次の要素を返す
    def __init__(self,size):
        self.table = [-1 for _  in range(size)]

    #集合の代表を求める
    def find(self,x):
        while self.table[x] >= 0:
            #根に来た時,self.table[根のindex]は負の値なのでx = 根のindexで値が返される。
            x = self.table[x]
        return x

    #併合
    def union(self,x,y):
        s1 = self.find(x)#根のindex,table[s1]がグラフの高さ
        s2 = self.find(y)
        if s1 != s2:#根が異なる場合
            if self.table[s1] != self.table[s2]:#グラフの高さが異なる場合
                if self.table[s1] < self.table[s2]:
                    self.table[s2] = s1
                else:
                    self.table[s1] = s2
            else:
                #グラフの長さが同じ場合,どちらを根にしても変わらない
                #その際,グラフが1長くなることを考慮する
                self.table[s1] += -1
                self.table[s2] = s1
        return

class UnionFind2(object):
    def __init__(self, size):
        self.parent = [i for i in range(size)]
        self.rank = [0 for _ in range(size)]


    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            return self.find(self.parent[x])


    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

#print(s[1][0], s[1][1])
u = UnionFind(n)
for i in range(m):
    u.union(s[i][0] - 1, s[i][1] - 1)
    k = u.table
k = u.table
#rt = u.find()
#print(u.parent)
#a = [5,3,1,4,2]
count = 0
for i in range(n):
    if u.find(i) == u.find(a[i] - 1):
        count += 1
print(count)

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

namespace ConsoleApp15
{
    class Class322
    {
        static int N;
        static int M;
        static List<int>[] G;
        static void Main()
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            N = NM[0];
            M = NM[1];
            G = new List<int>[N];
            for (int i = 0; i < N; i++) G[i] = new List<int>();
            for(int i = 0; i < M; i++)
            {
                var ab = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();
                G[ab[0]].Add(ab[1]);
                G[ab[1]].Add(ab[0]);
            }
            bool[] b = new bool[N];
            Console.WriteLine(DFS(0, b));
        }
        static int DFS(int now,bool[] frag)
        {
            bool[] f = new bool[N];
            Array.Copy(frag, f,N);
            f[now] = true;
            if (f.All(x => x == true)) return 1;
            int num = 0;
            foreach(int i in G[now])
            {
                if (frag[i]) continue;
                num += DFS(i, f);
            }
            return num;
        }
    }
}


Measured memory_bytes: 11348
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
	
	private static final int NUM_HAND_CARD = 5;
	public static void main(String[] arg){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int[] hand = new int[NUM_HAND_CARD];
		ArrayList<String> result = new ArrayList<String>();
		try{
			while(true){
				String[] input = br.readLine().split(",");
				for(int i = 0; i < NUM_HAND_CARD; i++){
					hand[i] = Integer.parseInt(input[i]);
				}
				result.add(judgeHand(hand));
			}
		}catch(Exception e){
			//何もしないで出力処理に移る
		}
		
		for(String pair : result){
			System.out.println(pair);
		}
	}
	
	public static String judgeHand(int[] hand){
		Arrays.sort(hand);
		if(isFourCard(hand)){
			return "four card";
		}
		else if(isFullHouse(hand)){
			return "full house";
		}
		else if(isStraight(hand)){
			return "straight";
		}
		else if(isThreeCard(hand)){
			return "three card";
		}
		else if(isTwoPair(hand)){
			return "two pair";
		}
		else if(isOnePair(hand)){
			return "one pair";
		}
		else{
			return null;
		}
	}
	
	private static boolean isFourCard(int[] hand){
		return isPair(hand ,4, 1);
	}
	
	private static boolean isFullHouse(int[] hand){
		if(isOnePair(hand) && isThreeCard(hand)){
			return true;
		}
		else{
			return false;
		}
	}

	private static boolean isStraight(int[] hand){
		int[] tmpHand = new int[NUM_HAND_CARD];
		for(int i = 0; i < NUM_HAND_CARD; i++){
			tmpHand[i] = hand[i];
			if(tmpHand[i] == 1){
				tmpHand[i] = 14;
			}
		}
		Arrays.sort(tmpHand);
		return checkNumbersStraight(hand) || checkNumbersStraight(tmpHand);
	}
	
	private static boolean checkNumbersStraight(int[] hand){
		int numStart = hand[0];
		for(int i = 1; i < NUM_HAND_CARD; i++){
			if(++numStart != hand[i]){
				return false;
			}
		}
		return true;
	}

	private static boolean isThreeCard(int[] hand){
		return isPair(hand, 3, 1);
	}

	private static boolean isTwoPair(int[] hand){
		return isPair(hand, 2, 2);
	}

	private static boolean isOnePair(int[] hand){
		return isPair(hand, 2, 1);
	}
	
	//同じカードnumCard枚のペアがnumPair組あるか判定する
	private static boolean isPair(int[] hand, int numCard, int numPair){
		//Arrays.sort(hand);
		int pairCount = 0;
		for(int n = 1; n <= 13; n++){
			int count = 0;
			for(int i = 0; i < NUM_HAND_CARD; i++){
				if(hand[i] == n){
					count++;
				}
			}
			if(count == numCard){
				pairCount++;
			}
		}
		if(pairCount == numPair){
			return true;
		}
		else{
			return false;
		}
	}

}

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


#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db double
#define eps 1e-6
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define mp(a, b) make_pair(a, b)
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define pi acos(-1.0)
const ll maxn = 1e6 + 10;

const ll N = 2e5 + 5;
ll n;
ll k;
vector<ll> neg, pos;
ll smaller_than(ll mid)
{
    mid++;
    ll ret = 0;
    ll neg_num = neg.size(), pos_num = pos.size();
    if (mid == 0)
    {
        for (ll i = 0; i < pos_num; i++)
            if (pos[i] == 0)
                ret += neg_num;
        ret += (ll)neg_num * (neg_num - 1) / 2;
        ret += (ll)pos_num * (pos_num - 1) / 2;
        ret = (ll)n * (n - 1) / 2 - ret;
       return ret;
    }
    if (mid > 0)
    {
        for (ll i = 0; i < neg_num - 1; i++)
        {
            ll x = mid / neg[i];
            if (mid % neg[i])
                x++;
            ll k = lower_bound(neg.begin() + i + 1, neg.end(), x) - neg.begin();
            ret += neg_num - k;
        }
        for (ll i = 0; i < pos_num - 1; i++)
        {
            if (pos[i] == 0)
                continue;
            ll x = mid / pos[i];
            if (mid % pos[i])
                x++;
            ll k = lower_bound(pos.begin() + i + 1, pos.end(), x) - pos.begin();
            ret += pos_num - k;
        }
        ret = (ll)n * (n - 1) / 2 - ret;
       return ret;
    }
    if (mid < 0)
    {
        mid *= -1;
        ret += (ll)neg_num * (neg_num - 1) / 2;
        ret += (ll)pos_num * (pos_num - 1) / 2;
        for (ll i = 0; i < neg_num; i++)
        {
            ll x = mid / neg[i];
            ll k = upper_bound(pos.begin(), pos.end(), x) - pos.begin() - 1;
            ret += k + 1;
        }
        ret = (ll)n * (n - 1) / 2 - ret;
       return ret;
    }
}
signed main()
{
    scanf("%lld%lld", &n, &k);
    for (ll i = 1; i <= n; i++)
    {
        ll x;
        scanf("%lld", &x);
        if (x < 0)
            neg.push_back(-x);
        else
            pos.push_back(x);
    }
    sort(neg.begin(), neg.end());
    sort(pos.begin(), pos.end());
    ll l = -1e18, r = 1e18, ans;
    while (l <= r)
    {
        ll mid = l + r >> 1;
        if (smaller_than(mid) >= k)
            ans = mid, r = mid - 1;
        else
            l = mid + 1;
    }
    printf("%lld\n", ans);
}
// signed main()
// {
// 	cin >> n >> k;
// 	_rep(i, 1, n)
// 	{
// 		ll tmp;
// 		cin >> tmp;
// 		if (tmp < 0)
// 			neg.push_back(-tmp);
// 		else
// 			pos.push_back(tmp);
// 	}
// 	sort(all(pos));
// 	sort(all(neg));
// 	ll l = -1e18, r = 1e18, ans = 0;
// 	while (r > l)
// 	{
// 		ll mid = l + r >> 1;
// 		if (smaller_than(mid) >= k)
// 		{
// 			r = mid - 1;
// 			ans = mid;
// 		}
// 		else
// 		{
// 			l = mid + 1;
// 		}
// 	}
// 	cout << ans << endl;
// }

Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f1          first
#define f2          second
#define hell        10000007
#define in          for(int i=a;i<b;i++)
using namespace std;
ll a[hell], b[hell];
ll dp[hell];
signed main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	ll i, j, k, l, test, n, c, sum = 0, sum1 = 0, sum2 = 0;
	ll count = 0, count1 = 0, count2 = 0, val = 0, pos = 0, pos1 = 0;
	bool flag = 1;
	
	cin >> n;
	for (i = 1; i <= n; i++) cin >> a[i];

	dp[1] = 0;
	dp[2] = abs(a[2] - a[1]);
	//cout << dp[2] << " ";
	for (i = 3; i <= n; i++) {
		dp[i] = min(dp[i-1] + abs(a[i-1] - a[i]), dp[i-2] + abs(a[i-2] - a[i]));
	}
	//cout << dp[1] + abs(dp[1] - a[3]) << "\n";
	cout << dp[n];
}

Measured memory_bytes: 3072
n,m = map(int,input().split())
a = []
mod = 10**9+7
for i in range(m):
    temp = int(input())
    a.append(temp)

a.append(0)
dp = [0]*(n+1)
dp[0] = 1
if a[0] == 1:
    dp[1] = 0
    l = 1
else:
    dp[1] = dp[0]
    l = 0
    
for i in range(2,n+1):
    if a[l] != i:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i]%=mod 
    else:
        l += 1

print(dp[-1])

Measured memory_bytes: 7848
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p = p[:X]
q = q[:Y]
sumlist = list()
sumlist.extend(p)
sumlist.extend(q)
sumlist.extend(r)
sumlist.sort(reverse=True)
print(sum(sumlist[:X+Y]))

Measured memory_bytes: 23328
#include <stdio.h>


int main(){
    double a, b;
    scanf("%lf", &a);
    scanf("%lf", &b);
    
    if(a > b) {
    printf("GREATER");
    }

    else if(a == b) {
    printf("EQUAL");
    }

    else {
    printf("LESS");
    }

    return 0;
}

Measured memory_bytes: 128
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define debug cout << "here!"
#define pii pair<int , int>
#define pdd pair<double , double>
#define F first
#define S second
const int maxn = 1e5 * 5 + 10 , inf = 1e9 , pi = 3.14159265;
ll n, ans;
void solve(){
    
}
void in(){
    cin >> n;
    for (int i = 1; i < n; i++){
        ans += (n - 1) / i;
    }
    cout << ans << endl;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    in();
    return 0;
}


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

int main() {
   char c;
   cin >> c;

   c += 1;

   cout << c << endl;
}

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

bool solve(){
	int cards[3][9]={0};
	int intbuf[9];
	for(int i=0;i<9;i++){
		cin >> intbuf[i];
		intbuf[i]--;
	}
	for(int i=0;i<9;i++){
		char buf;
		cin >> buf;
		switch(buf){
		case 'R':
			cards[0][intbuf[i]]++;
			break;
		case 'G':
			cards[1][intbuf[i]]++;
			break;
		case 'B':
			cards[2][intbuf[i]]++;
			break;
		}
	}

	for(int i=0;i<3;i++){
		for(int j=0;j<9;j++){
			if(cards[i][j] == 4){
				cards[i][j] = 1;
				j--;
				continue;
			}else if(cards[i][j] == 3){
				cards[i][j] = 0;
			}else if(cards[i][j] > 0){
				if(j<7){
					if(cards[i][j+1] >= cards[i][j] && cards[i][j+2] >= cards[i][j]){
						cards[i][j+1] -= cards[i][j];
						cards[i][j+2] -= cards[i][j];
						cards[i][j] = 0;
					}else{
						return false;
					}
				}else{
					return false;
				}
			}
		}
	}

	for(int i=0;i<3;i++){
		for(int j=0;j<9;j++){
			if(cards[i][j] > 0){
				return false;
			}
		}
	}
	return true;
}

int main(){
	int n;
	cin >> n;
	for(int loop=0;loop<n;loop++){
		if(solve()){
			cout << "1" << endl;
		}else{
			cout << "0" << endl;
		}
	}
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
#define LEN 100005
typedef struct pp
{
    char name[100];
    int t;
}P;
int head,tail,n;
P Q[LEN];
void enqueue(P x)
{
    Q[tail]=x;
    tail=(tail+1)%LEN;
}
P dequeue()
{
    P x = Q[head];
    head = (head+1)%LEN;
    return x;
}
int min(int a,int b)
{
    return a<b?a:b;
}
int main()
{
    int elaps = 0,c;
    int i,q;
    P u;
    scanf("%d %d",&n,&q);
    for(i = 1;i<=n;i++)
    {
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head = 1,tail=n+1;
    while(head != tail)
    {
        u = dequeue();
        c = min(q,u.t);
        u.t-=c;
        elaps+=c;
        if(u.t>0) enqueue(u);
        else{
            printf("%s %d\n",u.name,elaps);
        }
    }
}


Measured memory_bytes: 11864
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; 
typedef vector<int> vi; 
typedef pair<int, int> ii; 
typedef vector<ii> vii; 
typedef set<int> si; 
typedef map<string, int> msi; 
 
  
int main() 
{ 
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
 ll n,x,t,y;
  cin>>n>>x>>t;
  y=n/x;
  if(n%x!=0) y++;
  cout<<y*t;
    return 0; 
} 

Measured memory_bytes: 3648
s=input()
i=len(s)
ans=True
while 3<=i:
    if s[i-7:i]=='dreamer':
        i-=7
    elif s[i-5:i]=='dream':
        i-=5
    elif s[i-6:i]=='eraser':
        i-=6
    elif s[i-5:i]=='erase':
        i-=5
    else:
        ans=False
        break
if ans:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
using namespace std;

int main(){ 
  int n,x=0,y=0,ans=100000,c=0;
  cin>>n;
  rep(i,1,n+1){
    if(1<=i && i<=9) c++;
    if(100<=i && i<=999) c++;
    if(1e4<=i && i<=1e5-1) c++;
  }
  co(c);
  
  return 0;
}

Measured memory_bytes: 256
include Math

a, b, x = gets.chomp.split(" ").map(&:to_f)

h = x / a**2.to_f  # d: 水の深さ
s = a * b.to_f  # s: 水筒の横１面の面積
sw = a * h.to_f # sw: 横から見た際の面積
c = 0.0  # 傾けた水が作る直角三角形の不明な高さ

if  sw == s / 2 then
  puts atan( a / b ) * 180 / PI
elsif sw < s / 2 then
  c = 2 * sw / b
  puts atan( b / c ) * 180 / PI
else
  sw = s - sw
  c = 2 * sw / a
  puts atan( c / a ) * 180 / PI
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    ll N,x,m;
    cin>>N>>x>>m;

    vector<int> ord(m,-1);
    vector<ll> rireki,syu;
    ll res=0;
    rep(n,N){
        if(ord[x]!=-1){
            int p=ord[x];
            for(int i=p;i<n;i++) syu.push_back(rireki[i]);
            break;
        }
        ord[x]=n;
        rireki.push_back(x);
        res+=x;
        x=(x*x)%m;
    }

    N-=rireki.size();
    if(N==0){
        cout<<res<<endl;
        return 0;
    }

    vector<ll> sum(syu.size()+1,0);
    rep(i,syu.size()) sum[i+1]=sum[i]+syu[i];

    ll q=N/syu.size();
    ll r=N%syu.size();
    res+=sum[syu.size()]*q+sum[r];
    cout<<res<<endl;
}

Measured memory_bytes: 4836
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    string s;
    bool runner[4] = {0};
    int score = 0, out = 0;
    while (true) {
      cin >> s;
      if (s == "HIT") {
        for (int j = 0; j <= 4; j++)
          runner[3-j] = (3-j == 0 ? true : runner[2-j]);
        if (runner[3]) {
          runner[3] = false;
          score++;
        }
      } else if (s == "HOMERUN") {
        score++;
        for (int j = 0; j < 3; j++)
          if (runner[j]) {
            runner[j] = false;
            score++;
          }
      } else {
        out++;
      }
      if (out >= 3) {
        cout << score << endl;
        break;
      }
    }
  }
  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vec(n);
  for (int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    vec.at(a-1)++;
    vec.at(b-1)++;
  }
  for (int i = 0; i < n; i++){
    cout << vec.at(i) << endl;
  }
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};


int H, W, cnt = 0;
char A[9][9];

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

    cin >> H >> W;
    rep(i, H) rep(j, W){
        char a;
        cin >> a;
        if(a == '#') cnt++;
    }

    if(cnt == H+W-1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;

    return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  if (A + B >= 10)
    cout << "error" << endl;
  else
    cout << A + B << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//issame:同じか判定
//unite:併合
//findroot:根の検索
//treesize:その木の要素数
struct UnionFind{
    vector<long long> size, par;
    UnionFind(long long n) {
        size.resize(n, 0);
        par.resize(n, 0);
        for (long long i = 0; i < n;i++){
            maketree(i);
        }
    }
    void maketree(long long x){
        par[x] = x;
        size[x] = 1;
    }
    long long findroot(long long x){
        if (x != par[x]) par[x] = findroot(par[x]);
        return par[x];
    }
    bool issame(long long x,long long y){
        return findroot(x) == findroot(y);
    }
    bool unite(long long x,long long y){
        x = findroot(x);
        y = findroot(y);
        if (x == y) return false;  //already united
        if(size[x]>size[y]){
            par[y] = x;
            size[x] += size[y];
        }
        else{
            par[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    long long treesize(long long x){
        return size[findroot(x)];
    }
};

int main(){
ll n,q;
cin >> n >> q;
UnionFind uf(n);
for (ll i = 0; i < q;i++){
    ll com,x,y;
    cin >> com >> x >> y;
    if(com==0){
        uf.unite(x, y);
    }
    else{
        if (uf.issame(x, y)) cout << 1 << endl;
        else
            cout << 0 << endl;
    }
}
}


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ll n,x,d;
	cin >> n >> x >> d;
	if(d==0){
		if(x==0)cout << 1 << endl;
		else cout << n+1 << endl;
		return 0;
	}
	map<ll,vector<pll>>mp;
	for(int siz=0; siz<=n; siz++){
		ll ini = (ll)siz*x;
		ll L = (ll)siz*(siz-1)/2LL;
		ll R = (ll)siz*(2*n-1-siz)/2LL;
		ll div = ini / d;
		mp[ini%d].eb(div+L,div+R);
	}
	ll ans = 0LL;
	for(auto x:mp){
		auto v=x.se;
		sort(all(v));
		if(v.size()==0)continue;
		ll L = v[0].fi;
		ll R = v[0].se;
		for(int i=1; i<(int)v.size(); i++){
			if(v[i].fi<=R){
				R = max(R,v[i].se);
			}else{
				ans += R-L+1;
				L = v[i].fi;
				R = v[i].se;
			}
		}
		ans += R-L+1;
	}
	cout << ans << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


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

int press(int &ans, int &A, int &B)
{
  if (A >= B)
  {
    ans += A;
    A--;
  }
  else
  {
    ans += B;
    B--;
  }
}

int main()
{
  int A, B;

  cin >> A >> B;

  int ans = 0;

  press(ans, A, B);
  press(ans, A, B);

  cout << ans << endl;
}

Measured memory_bytes: 256
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>

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

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
  int n, k;
  cin >> n >> k;
  vl h(n, 0);
  rep(i, n)
  {
    cin >> h[i];
  }
  sort(h.begin(), h.end());
  reverse(h.begin(), h.end());
  rep(i, k)
  {
    if(i >= n) break;
    h[i] = 0;
  }
  ll c = 0;
  rep(i, n)
  {
    c += h[i];
  }
  cout << c << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 200005

int N;
int table[SIZE];

int main(){

	scanf("%d",&N);
	for(int i = 1; i <= N; i++){

		table[i] = 0;
	}

	int tmp;
	for(int i = 2; i <= N; i++){

		scanf("%d",&tmp);
		table[tmp]++;
	}

	for(int i = 1; i <= N; i++){

		printf("%d\n",table[i]);
	}

	return 0;
}


Measured memory_bytes: 4596
#include<stdio.h>
#define MAX 40
#define true 1
#define false 0

typedef struct{
  char alp,num;
}cinfo;

void bubblesort( cinfo c[],int N){
  int i,j;
  for(i=0;i<N;i+=1){
    for(j=N-1;j>=i+1;j--){
      if(c[j].num < c[j-1].num){
	cinfo tmp = c[j];
	c[j] = c[j-1];
	c[j-1] = tmp;
      }
    }
  }
}

 void selectionsort(cinfo c[],int N){
    int i,j,minj;
    cinfo tmp;
    for(i=0;i<N;i++){
      minj = i;
      for(j=i;j<N;j++){
	if(c[j].num < c[minj].num) minj = j;
      }
      tmp = c[i];
      c[i] = c[minj];
      c[minj] = tmp;
    }
 }

void print( cinfo *c, int N){
  int i;
  for(i=0;i<N;i++){
    if(i>0) printf(" ");
    printf("%c %c",(c+i)->alp,(c+i)->num);
	   }
  printf("\n");
}


int isstable( cinfo data1[], cinfo data2[],int N){
  int i;
  for(i=0;i<N;i++){
    if(data1[i].alp != data2[i].alp) return false;
  }
  return true;
}

int main(){
  cinfo data1[MAX],data2[MAX];
  int N,i;
  char ch;

  scanf("%d",&N);
  for(i=0;i<N;i+=1){
    scanf(" %c %c",&data1[i].alp,&data1[i].num);
  }

  for(i=0;i<N;i++) data2[i] = data1[i];

   bubblesort(data1,N);
  selectionsort(data2,N);

  
  for(i=0;i<N;i++){
 if(i>0) printf(" ");
    printf("%c%c",data1[i].alp,data1[i].num);
    // if(i>0) printf(" ");
  }
  printf("\n");
  printf("Stable\n");//バブルソートはつねに安定なソート

  
  for(i=0;i<N;i++){
     if(i>0) printf(" ");
    printf("%c%c",data2[i].alp,data2[i].num);
    // if(i>0) printf(" ");
  }
  printf("\n");
  if(isstable(data1,data2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  
  return 0;
}



Measured memory_bytes: 2104