akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
  ll n,p[100];
  cin>>n;
  for(int i=0;i<n;i++)cin>>p[i];
  sort(p,p+n);
  ll ans=p[n-1]/2;
  for(int i=0;i<n-1;i++)ans+=p[i];
  cout<<ans<<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();
        int[] B = new int[100005];
        int sumA = 0;

        B[0] = 9999999;
        for (int i = 1; i < N; i++) {
            B[i] = sc.nextInt();
        }
        B[N] = 9999999;

        for (int i = 1; i < N + 1; i++) {
            if (B[i - 1] <= B[i]) {
                sumA += B[i - 1];
            } else {
                sumA += B[i];
            }
        }


        System.out.println(sumA);


    }
}





Measured memory_bytes: 21972
#include<stdio.h>
int main(){
    char s[3];
    int i,flag = 0;
    
    for(i = 0 ; i < 3 ; i++) scanf("%c",&s[i]);
    
    for(i = 0 ; i < 2 ; i++){
        if(s[i] != s[i+1]) flag = 1;
    }
    
    if(flag == 1) printf("Yes\n");
    else printf("No\n");
    
    return 0;
}


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

using namespace std;

int main(){
    int k,a,b;
    cin >> k >> a >> b;
    if(a%k==0 || b%k==0){
        cout << "OK" << endl;
    }else if(b/k!=a/k){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }

    return 0;
}


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

int n;
vector<int> a;
template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	readVector(n, a);
	for(int i=0; i<n; ++i)
		a[i] -= i+1;
	sort(a.begin(), a.end());
	// 0 ~ 2n-1 2n 0 ~ n-1 n
	// 0 ~ 2n 2n+1 0 ~ n-1 n
	int b = a[n/2];
	long long ans = 0;
	for(int i=0; i<n; ++i)
		ans += abs(a[i] - b);
	cout << ans << "\n";
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    const char B = 'B';
    string S;
    cin >> S;
    ll ans = 0;
    int bc = 0;
    REP(i,S.size()) {
        if (S[i] == B) bc++;
        else ans += bc;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  string s;
  cin >> s;
  cout << s;
  if(*s.rbegin() == 's') cout << "es" << endl;
  else cout << "s" << endl;

  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(void){
    
    string t;
    cin >> t;
    t = t + t;
    
    string x;
    cin >> x;
    
    if( t.find(x,0) != string::npos){
        cout << "Yes" << endl;
    }
    else{
       cout << "No" << endl;
    }    
}

Measured memory_bytes: 1192
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	vector<bool> b(26, false);
	string S;
	cin>>S;
	bool d = false;
	REP(i, S.size()) {
		if(b[S[i] - 'a']) {
			d = true;
			break;
		} else {
			b[S[i] - 'a'] = true;
		}
	}
	if(!d)cout<<"yes"<<endl;
	else cout<<"no"<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

ll A[200000];

int main()
{
	int N;
	ll mid, ans = 0;

	cin >> N;
	rep(i, N) cin >> A[i];
	repc(i, 1, N) A[i - 1] -= i;

	sort(A, A + N);
	mid = A[N / 2];

	rep(i, N) ans += abs(A[i] - mid);
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1792
using System;   
 class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long ans = new long();
           
                if (N % 2 == 0){ ans = N; }
                else { ans = N * 2; }

            Console.WriteLine(ans);

            return;
        }
    }

Measured memory_bytes: 13140
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,ans=0;
multiset <int> s;

int main()
{
	cin>>n;
	rep(i,n)
	{
		int x;
		scanf("%d",&x);
		s.insert(x);
	}
	while(!s.empty())
	{
		multiset <int>::iterator it=s.end();
		it--;
		s.erase(it);
		int pw=1;
		for(;pw<=*it;pw*=2);
		if(s.find(pw-*it)!=s.end())
		{
			s.erase(s.find(pw-*it));
			ans++;
		}
	}
	cout<<ans<<endl;
	rt0;
}

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

int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    vector<vector<bool>> A(4, vector<bool>(N, false));
    A[0][0] = 1, A[0][1] = 1, A[0][2] = 1;
    A[1][0] = 0, A[1][1] = 1, A[1][2] = 1;
    A[2][0] = 1, A[2][1] = 1, A[2][2] = 0;
    A[3][0] = 0, A[3][1] = 1, A[3][2] = 0;
    for (int P = 0; P < 2; P++) {
        for (int i = 0; i < 4; i++) {
            for (int j = 2; j < N - 1; j++) {
                if ((P && s[j] == 'o' && !A[i][j]) ||
                    (P && s[j] == 'x' && A[i][j]) ||
                    (!P && s[j] == 'o' && A[i][j]) ||
                    (!P && s[j] == 'x' && !A[i][j])) {
                    A[i][j + 1] = A[i][j - 1];
                } else {
                    A[i][j + 1] = !(A[i][j - 1]);
                }
            }
            bool check = true;
            for (int j = 0; j < N; j++) {
                if (((P && s[j] == 'o' && !A[i][j]) ||
                     (P && s[j] == 'x' && A[i][j]) ||
                     (!P && s[j] == 'o' && A[i][j]) ||
                     (!P && s[j] == 'x' && !A[i][j])) &&
                    A[i][(N + j - 1) % N] != A[i][(N + j + 1) % N]) {
                    check = false;
                    break;
                } else if (((P && s[j] == 'x' && !A[i][j]) ||
                            (P && s[j] == 'o' && A[i][j]) ||
                            (!P && s[j] == 'x' && A[i][j]) ||
                            (!P && s[j] == 'o' && !A[i][j])) &&
                           A[i][(N + j - 1) % N] == A[i][(N + j + 1) % N]) {
                    check = false;
                    break;
                }
            }
            if (check) {
                for (int k = 0; k < N; k++) {
                    if ((!P && A[i][k]) || (P && !A[i][k])) {
                        cout << 'S';
                    } else {
                        cout << 'W';
                    }
                }
                cout << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

string s;
int cnt[26];
int main() {
    cin >> s;
    int n = s.length();
    for (int i = 0; i < n; ++i) {
        ++cnt[s[i] - 'a'];
    }
    for (int i = 0; i < 26; ++i) {
        if (cnt[i] & 1) {
            cout << "No" << endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3608
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int r,d,x; cin >> r >> d >> x;
    
    rep(i,10){
        x = r*x - d;
        cout << x << ln;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

int main()
{
	int32_t a, b, c;
	cin >> a >> b >> c;

	cout << (b - a == c - b ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

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

const int INF = 1<<30;

int dx[] = {0, -1, 0, 1}, dy[] = {-1, 0, 1, 0};
int main(){
  int h, w;cin>>h>>w;
  vector<vector<char>> field(h, vector<char>(w));
  rep(i, h)rep(j, w){
    cin>>field[i][j];
  }
  int ans=-1;
  char c[] = {'.', '*'};
  int mark=0;
  rep(i, h)rep(j, w){
  	if(field[i][j]!=c[mark])continue;
    queue<pair<int, P>> que;que.push(make_pair(0, P(i, j)));
    field[i][j]=c[(mark+1)%2];
    while(!que.empty()){
      pair<int, P> p = que.front();que.pop();
      int dis=p.first;P pos=p.second;
      ans = max(ans, dis);
      rep(k, 4){
      	int nx=pos.first+dx[k], ny=pos.second+dy[k];
        if(0<=nx && nx<h && 0<=ny && ny<w && field[nx][ny]==c[mark]){
          field[nx][ny]=c[(mark+1)%2];
          que.push(make_pair(dis+1, P(nx, ny)));
        }
      }
    }
    mark = (mark+1)%2;
  }
  cout<<ans<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
  return 0;
}


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

	//for(i=0;i<n;++i){}
	
	int main()
	{
		ios_base::sync_with_stdio(0);
		cin.tie(0);
		//int t; cin>>t; while(t--){	}
		int n,k,s=0; cin>>n>>k; int a[n];for(int i=0;i<n;++i){cin>>a[i];}
		sort(a,a+n);
		for(int i=0;i<k;++i){
			s=s+a[i];
		}
		cout<<s<<"\n";
	    return 0;
	
	}

Measured memory_bytes: 3620
n = input()
N = int(n)

count = 0
Acount = 0
AScount = 0
Bcount = 0
BScount = 0
BAcount = 0

for i in range(N):
    s = input()
    if 1 < len(s):
        if 'AB' in s:
            count += s.count('AB')
        if s[0] == 'B' and s[-1] == 'A':
            BAcount += 1
        elif s[0] == 'B':
            Bcount += 1
        elif s[-1] == 'A':
            Acount += 1
    else:
        if s == 'B':
            BScount += 1
        if s == 'A':
            AScount += 1

BAcount += min(BScount, AScount)

if BScount <= AScount:
    Acount += AScount - BScount
else:
    Bcount += BScount - AScount

if 0 < BAcount:
    count += BAcount - 1
    BAcount = 1

if 0 < Acount and 0 < BAcount:
    count += 1
    Acount -= 1

if 0 < Bcount and 0 < BAcount:
    count += 1
    Bcount -= 1

count += min(Bcount, Acount)
print(count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    ll N,K;
    cin >> N >> K; 
    vector<ll> HList;
    HList.resize(N);
    for (int i=0; i<N; i++) cin >> HList.at(i);

    //resolve
    sort(HList.begin(),HList.end());
    ll ans=0;
    for (int i=0; i<N-K; i++) ans += HList[i];

    // output
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
use std::io;
use std::str::FromStr;
static MOD: u64 = 998244353;

fn input_tuple() -> (u64, u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}

fn binary_power(x: u64, n: u64) -> u64 {
    if n == 0 {
      return 1;
    }
    if n % 2 == 0 {
      return (binary_power(x, n / 2) % MOD).pow(2) % MOD;
    } else {
      return binary_power(x, n - 1) % MOD * x % MOD;
    }
}
  
fn inverse_mod(n: u64) -> u64 {
    binary_power(n, MOD-2)
}

fn main() {
    let (n, m, k) = input_tuple();

    // 同じ色が隣り合っている組が0の場合
    let mut combination_buf = 1;
    let mut ans = m % MOD * binary_power(m - 1, n - 1) % MOD;

    for i in 1..(k+1) {
        combination_buf = combination_buf * (n - i) % MOD * inverse_mod(i) % MOD;
        // println!("{}", combination_buf);
        let num = combination_buf * m % MOD * binary_power(m - 1, n - 1 - i) % MOD; 
        ans += num;
        ans %= MOD;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)

using namespace std;

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

int main(void)
{
        int n;
        string s;
        cin >> n >> s;

        int it = 0;
        int cnt = 0;
        while(it != s.size()){
                if(s[it] == ')') cnt--;
                else if(s[it] == '(') cnt++;
                if(cnt < 0){
                        s.insert(s.begin(),'(');
                        it++;
                        cnt = 0;
                }
                it++;
        }

        it = s.size()-1;
        cnt = 0;
        while(it >= 0){
                if(s[it] == '(') cnt--;
                else if(s[it] == ')') cnt++;
                if(cnt < 0){
                        s.insert(s.end(),')');
                        cnt = 0;
                }
                it--;
        }
        cout << s << endl;
        return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 100000
int height(int);
struct Node{
  int parent;
  int left;
  int right;
};
struct Node T[N];
int H[N];
int main(){
  
  int n,j,p,i,d,s,t,a,id,b,k,l,r,re,re1,sum,ty,MAX=0;
  
  scanf("%d",&n);
  
  

  for(i=0;i<n;i++){
    T[i].right=T[i].left=T[i].parent=-1;
  }
  
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d%d",&l,&r);
    T[id].left=l;
    T[l].parent=id;
    T[id].right=r;
    T[r].parent=id;
    
  }

  for(i=0;i<n;i++){
    if(T[i].parent==-1)
      ty=i;
  
  }
  
  height(ty);
  
  for(i=0;i<n;i++){
    if(T[i].parent==-1){
      printf("node %d: parent = -1, sibling = -1, degree = ",i);
      if(T[i].left!=-1&&T[i].right!=-1)
	printf("2, ");
      else if(T[i].left!=-1&&T[i].right==-1)
	printf("1, ");
      else if(T[i].left==-1&&T[i].right!=-1)
	printf("1, ");
      else printf("0, ");

      printf("depth = 0, height = ");

     
 
      printf("%d, root\n",H[i]);
    }
    
    else if(H[i]==0){
      s=0;
      b=T[i].parent;
      printf("node %d: parent = %d, sibling = ",i,T[i].parent);
      if(i==T[b].right)
	printf("%d, ",T[b].left);
      else printf("%d, ",T[b].right);

      printf("degree = ");
      if(T[i].left!=-1&&T[i].right!=-1)
	printf("2, ");
      else if(T[i].left!=-1&&T[i].right==-1)
	printf("1, ");
      else if(T[i].left==-1&&T[i].right!=-1)
	printf("1, ");
      else printf("0, ");
      printf("depth = ");
	
      a=T[i].parent;
      while(a!=-1){
	s++;
	a=T[a].parent;
      }
      printf("%d, height = ",s);
      
      
      printf("%d, leaf\n",H[i]);
    }
    
    else{
      s=0;
      b=T[i].parent;
      
      printf("node %d: parent = %d, sibling = ",i,T[i].parent);
      if(i==T[b].right)
	printf("%d, ",T[b].left);
      else printf("%d, ",T[b].right);
      printf("degree = ");
      if(T[i].left!=-1&&T[i].right!=-1)
	printf("2, ");
      else if(T[i].left!=-1&&T[i].right==-1)
	printf("1, ");
      else if(T[i].left==-1&&T[i].right!=-1)
	printf("1, ");
      else printf("0, ");
      printf("depth = ");
	
      a=T[i].parent;
      while(a!=-1){
	s++;
	a=T[a].parent;
      }
      
      printf("%d, height = ",s);
      

      printf("%d, internal node\n",H[i]);
    }
  }
  return 0;
}

int height(int pp){
  int a=0,b=0;

  if(T[pp].right!=-1)
    a=height(T[pp].right)+1;
  if(T[pp].left!=-1)
    b=height(T[pp].left)+1;
  if(a>b)
    H[pp]=a;
  else
    H[pp]=b;

  return H[pp];
}

Measured memory_bytes: 608
#include<stdio.h>
int main()
{
  int a=0;
  char s[3];
  int i;
  scanf("%s", s);
  for(i=0;i<3;i++){
    if(s[i]=='1'){
      a++;
    }
  }
  
  printf("%d", a);
  return 0;
}


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

int main() {
  int A,B;
  cin>>A>>B;
  int ans=0;
  int reverse;
  for (int i=A; i<=B; i++) {
    int x=i;
    reverse=0;
    while (x!=0) {
      int remaind=x%10;
      reverse=reverse*10+remaind;
      x/=10;
    }
    if (reverse==i) {
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n, x = map(int, input().split())
a_list = list(map(int, input().split()))
time_list = [0] * n
ans = float("inf")
for k in range(n):
    candidate = k * x
    for i in range(n):
        if k == 0:
            time_list[i] = a_list[i]
        else:
            time_list[i] = min(time_list[i], a_list[i-k])
        candidate += time_list[i]
    ans = min(ans, candidate)
print(ans)

Measured memory_bytes: 42476
#include<bits/stdc++.h>
using namespace std;
const int N=100;
int a[N],b[N],c[N];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,ans=0,i;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<n;i++)
	{
		cin>>b[i];
		ans+=b[i];
	}
	for(i=1;i<n;i++)
		cin>>c[i];
	for(i=1;i<n;i++)
		if(a[i-1]+1==a[i])ans+=c[a[i-1]];
	cout<<ans<<'\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 1e5 + 7;
int n, x[N], m, k, p[N], d[N], resp[N];
int ans[N];
void mult(int p[], int add[]) {
    for (int i = 1; i < n; ++i) ans[i] = p[add[i]];
    for (int i = 1; i < n; ++i) p[i] = ans[i];
}   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> x[i];    
    for (int i = 1; i < n; ++i) d[i] = x[i + 1] - x[i];
    cin >> m >> k;
    for (int i = 1; i < n; ++i) p[i] = i;
    while (m--) {
        int i; cin >> i;
        swap(p[i - 1], p[i]);
    }   
    for (int i = 1; i < n; ++i) resp[i] = i;
    for (int pw = 0; (1ll << pw) <= k; ++pw) {
        if ((k >> pw) & 1) mult(resp, p);
        mult(p, p);
    }   
    mult(d, resp);
    ans[1] = x[1];
    for (int i = 1; i < n; ++i) {
        ans[i + 1] = ans[i] + d[i];
    }   
    for (int i = 1; i <= n; ++i) cout << ans[i] << '\n';
}

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

int main(){
  int n,a[100],cnt=0;
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i];
  bool flag=true;
  while(flag){
   flag = false;
   for(int i=0;i<n-1;i++){
    if(a[i]>a[i+1]){
     swap(a[i],a[i+1]);
     flag=true;
     cnt++;
    }
   }
 }
 for(int i=0;i<n;i++){cout << a[i] ; if(i!=n-1)cout << " ";}
 cout << endl << cnt << endl;
}

Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
    ll N,A;cin >> N;
    vector<ll> C,D;
    rep(i,N){
        cin >> A;
        C.push_back(A);
    }
    rep(i,N){
        for(ll j=N-i-1;j>=0;j--){
            if(C[j]==j+1){
                D.push_back(C[j]);
                C.erase(C.begin()+j);
                break;
            }
            if(j==0){
                cout << -1 << endl;
                return  0;
            }
        }
    }
    reverse(ALL(D));
    rep(i,N){
        cout << D[i] << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <limits>
#include <cmath>

using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  int c = max(0, a-2*b);
  
  cout << c << endl;
}

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

int main(){
    int x,y;
    cin>>x>>y;
    if(x<y){
        cout<<"a"<<" < "<<"b"<<endl;
    }else if(x>y){
        cout<<"a"<<" > "<<"b"<<endl;
    }else{
        cout <<"a == b"<< endl;
    }
    return 0;
}

Measured memory_bytes: 3076
N = gets.to_i
H = gets.split.map(&:to_i)

H.each_with_index do |h,i|
  if i == 0
    H[i] -= 1
    next
  end

  if h - 1 >= H[i-1]
    H[i] -= 1
  end
end

H.each_with_index do |h,i|
  break if i == N-1

  if h > H[i+1]
    puts "No"
    exit
  end
end

puts "Yes"


Measured memory_bytes: 8580
'use strict'
function main(input) {
  input = input.trim().split('\n')
  input.shift()
  let count = 0
  let firstB = 0
  let lastA = 0
  let bothAB = 0
  input.forEach(val => {
    let match = val.match(/AB/g)
    if (match) count += match.length
    let matchB = val.match(/^B/)
    let matchA = val.match(/A$/)
    if (matchB) firstB++
    if (matchA) lastA++
    if (matchA && matchB) bothAB++
  })
  let min = Math.min(lastA, firstB)
  if (lastA === firstB && lastA === bothAB && min > 0) min--
  console.log(count + min)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 13364
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = LI()

    cnt = collections.Counter(A)
    # print(cnt)
    # 同じ数字3枚引いて1, 2枚になるまで減らす
    for i in cnt.keys():
        if cnt[i] % 2 == 0:
            cnt[i] = 2
        else:
            cnt[i] = 1

    ans = 0
    even_num = [i for i in cnt.keys() if cnt[i] == 2]
    # 2枚の数字の種類が3以上の奇数ならば、1種類まで減らせる
    # 2枚の数字の種類が4以上の偶数ならば、0種類まで減らせる(残り4種類は互い違いに食べる)
    if len(even_num) % 2 == 0:
        ans = len(cnt)
    else:
        ans = len(cnt) - 1

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 22756
n,t=map(int,input().split())
T=list(map(int,input().split()))
cur=0
sho=0
for i in range(n-1):
    cur=T[i]
    if cur+t<T[i+1]:
        sho+=t
        cur=T[i+1]
    else:
        sho+=T[i+1]-cur
        cur=T[i+1]
print(sho+t)

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

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	string s,t;
	cin>>s>>t;

	cout<<t<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	cnt := 0
	ans := 0
	for i := len(s) - 1; i >= 0; i-- {
		if s[i] == 'W' {
			cnt++
		} else {
			ans += cnt
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
const int N = 2e5 + 5;
ll n;
ll nxt[N], st[4*N];
ll dp[N];
const ll MOD = 998244353;
ll compute(ll i)
{
    if( i == n ) return 1;
    if(dp[i] != -1) return dp[i];
    ll ans =  0;
    // take 
    ans += compute(nxt[i]);
    ans %= MOD;
    // dont take
    ans += compute(i+1);
    ans %= MOD;
    return dp[i] = ans;
}
int left(int i)
{
    return i<<1;
}
int right(int i)
{
    return (i<<1)+1;
}
void update(int p, int l, int r, int pos, int val)
{
    if(r < pos || pos < l) return;
    if(l==r){st[p]=val;return ;}
    int mid= (l+r)/2;
    update(left(p), l, mid, pos, val);
    update(right(p), mid+1, r, pos, val);
    st[p] = MAX2(st[left(p)], st[right(p)]);
}
int rmq(int p,int l, int r, int i , int j)
{
    if(i>r|| j<l)
        return ninf;
    if(l>=i&&r<=j)
        return st[p];
    int mid=(l+r)/2;
    return MAX2(rmq(left(p), l, mid, i, j), rmq(right(p), mid+1, r, i, j));
}

vector< pll > rob;
int main()
{
    she_told_me_dont_worry
    cin>>n;
    int i;
    FOR0(i, n )
    {
        pll cur;
        cin>>cur.ff>>cur.ss;
        rob.pb(cur);
    }
    sort(rob.begin(), rob.end());
    FOR0(i, n)
    {
        nxt[i] = i+1;
        update(1, 0, n-1, i, i+1);
    }
    FORD(i, n-1, 0)
    {
        int pos = int(lower_bound(rob.begin(), rob.end(), pll(rob[i].ff+rob[i].ss, 0) ) - rob.begin());
        int npos = rmq(1, 0, n-1, i, pos-1);
        update(1, 0, n-1, i, npos);
        nxt[i] = npos;
    }
    FOR0(i, n+3) dp[i] = -1;
    cout<<compute(0)<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    long double a,b;
    cin >> a >> b;
    long double c=a*b;
    ll d=floor(c);
    cout << d << endl;
    
    return 0;
}











Measured memory_bytes: 3724
import sys
from collections import defaultdict

N = int(input())
C = [0]
for _ in range(N):
    c = int(sys.stdin.readline())
    if C[-1] == c:
        continue
    else:
        C.append(c)

ans = 1
dic = defaultdict(lambda: 0)
for c in C:
    a = dic[c]
    dic[c] += ans
    ans += a

print(ans % (10 ** 9 + 7))

Measured memory_bytes: 31200
<?php
fscanf(STDIN, "%d", $n);
$a = explode(' ', trim(fgets(STDIN)));
$cs = array_count_values($a);
krsort($cs);
$x = $y = 0;
foreach ($cs as $b => $c) {
	if ($c > 1) {
		if ($x > 0) {
			$y = $b;
			break;
		} else {
			$x = $b;
			if ($c >= 4) {
				$y = $b;
				break;
			}
		}
	}
}
echo $x * $y;

Measured memory_bytes: 19444
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;

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

int main(){
    int n; cin >> n;
    if(n%2!=0){out("No"); return 0;}
    string s; cin >> s;
    rep(i, n/2){
        if(s[i]!=s[i+n/2]){out("No"); return 0;}
    }
    out("Yes"); return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def main():
    N = int(input())
    a = list(map(int, input().split()))
    t = round(sum(a)/N)
    ans = 0
    for i in range(N):
        ans += (a[i] - t)**2
    print(ans)

if __name__ == '__main__':
    main()


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

using namespace std;

long long N;

vector<int> ans;

int m;
deque<int> q;

void get(long long N) {
	if(N == 0) return;
	if(N & 1) {
		get(N >> 1);
		q.push_back(q.size() + 1);
	} else {
		get(N - 1);
		q.push_front(q.size() + 1);
	}
}

int main() {
	cin >> N;
	get(N);
	int n = q.size();
	ans.resize(n * 2);
	for(int i = 0; i < n; ++i) {
		ans[i] = *q.begin();
		q.pop_front();
		ans[i + n] = i + 1;
	}
	printf("%d\n", n * 2);
	for(int i = 0; i < n * 2; ++i) {
		printf("%d%c", ans[i], " \n"[i==n*2]);
	}
	return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  A.erase(unique(A.begin(),A.end()),A.end());
  if (A.size()==N){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 3992
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

int32_t main(){_
    //freopen("input","r",stdin);
	int n,m;
	cin >> n >> m;
	if(n == 1 && m == 1) rc(1);
	else if(min(n,m) == 1) rc(max(n,m) - 2);
	rc((n - 2) * (m - 2));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define int long long
using namespace std;
typedef pair<int,int> P;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
struct edge{
    int to,cost;
};
class dijkstra{
    int V;
    int d[100002];
    priority_queue<P,vector<P>,greater<P>>que;
    void update(int s,vector<edge> G[]){
        fill(d,d+V+1,100000000000ll);
        d[s]=0;
        que.push(make_pair(0,s));
        while(!que.empty()){
            P p=que.top();
            que.pop();
            int v=p.second;
            if(d[v]<p.first)continue;
            rep(i,G[v].size()){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(make_pair(d[e.to],e.to));
                }
            }
        }
    }
public:
    dijkstra(int v,int s,vector<edge> G[]){
        V=v;
        update(s,G);
    }
    int find(int e){
        return d[e];
;    }
};
signed main(){
    int n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    cout<<5+(n-1)/(min(a,min(b,min(c,min(d,e)))));
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    vector<int> v(3); cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());
    if(v[0] == 5 && v[1] == 5 && v[2] == 7)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}


Measured memory_bytes: 256
def main():
	H, W = [int(x) for x in input().split(" ")]
	S = []
	S.append(["X"] * (W + 2))
	h = 0
	w = 0
	for i in range(H):
		row = list(input())
		S.append(["X"] + row + ["X"])
		if not h and not w and row.count(".") > 0:
			h = i + 1
			w = row.index(".") + 1
	S.append(["X"] * (W + 2))

	ans = []
	for i in range(H):
		for j in range(W):
			ans.append(BFS(S, i + 1, j + 1, H + 2, W + 2))
	print(max(ans))

def BFS(M, i, j, H, W):
	if M[i][j] != ".":
		return 0
	to_visit = [{"row": i, "col": j, "step": 0}]
	checked = [[0] * W for x in range(H)]
	checked[i][j] = 1
	z = [[0] * W for x in range(H)]
	while len(to_visit):
		visiting = to_visit.pop(0)
		r0 = visiting["row"]
		c0 = visiting["col"]
		s0 = visiting["step"]
		z[r0][c0] = s0
		for d in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
			r = r0 + d[0]
			c = c0 + d[1]
			s = s0 + 1
			if checked[r][c] == 0 and M[r][c] == ".":
				to_visit.append({"row": r, "col": c, "step": s})
				checked[r][c] = 1
	a = 0
	for i in range(len(z)):
		for j in range(len(z[i])):
			if a < z[i][j]:
				a = z[i][j]
	return a

main()


Measured memory_bytes: 9316
#include <bits/stdc++.h>
using namespace std;
#define loop(i,b,e) for(int i=b;i<=e;i++)
#define loop2(i,e,b) for(int i=e;i>=b;i--)
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6 + 5;
const ll mod = 1e9 + 7;
const int oo = 1e9;
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

ll a, b, c, k;

int main() {
	cin >> a >> b >> c >> k;
	if (k % 2 != 0) {
		ll aa =  b + c;
		ll bb = a + c;
		cout << aa - bb;
	}
	else cout << a - b;
}

Measured memory_bytes: 256
n = int(input())
count = 0
#print(len(str(n)))
'''
if len(str(n)) % 2 == 1:
    print("yas")
else :
    print("no")
'''
for i in range(1,n+1):
    if len(str(i))%2==1:
        count += 1
print(count)

Measured memory_bytes: 2940
arr = []
arr2 = []
for i in range(int(input())):
    a = int(input())
    if a%10 == 0:
        arr2.append(a)
    else:
        arr.append(a)

arr.sort()
j = sum(arr)+sum(arr2)
if j%10 != 0:
    print(j)
else:
    k = 0
    while j%10 == 0 and k<len(arr):
        j -= arr[k]
        k += 1
    if j%10 == 0:
        print(0)
    else:
        print(j)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define ll long long int
#include<list>
#include<algorithm>
#define ld long double
#define pb push_back
#define FF first
#define SS second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repr(a,b,c) for(a=b-1;a>=c;a--)
#define PLL pair<ll, ll>
#define inf 100000001
#define mod 1000000007
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define PQ priority_queue
#define rep1 for(i=1;i<=n;i++)
#define VLL vector<ll>
#define EF else if
const double pi  =3.141592653589793238463;
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define UMP unordered_map
#define MAX LLONG_MAX
#define MIN LLONG_MIN
// #define endl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
/*
    //string with spaces
    std::string str;
    std::getline(std::cin >> std::ws, str);
*/
ll myXOR(unsigned long long int x, unsigned long long int y)
{
    return (x|y)&(~x|~y);   
}
ll powerLL(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    }
    return result; 
}
map<string, vector<string>>mp;
map<string, bool>visited;
// string visited[3];
ll res = 0;
string initial;
bool ok = false;
void find(string val)
{
    if(initial==val){
        ok = true;
        return;
    }
    if(!visited[val]){
        res++;
        visited[val] = true;
        for(auto &x:mp[val])
            find(x);
    }
    else
        return;
}
int main()
{
    fastio
    ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r, t,u,w,x,y,z;
    string str, ss, str1;

    cin>>a>>b;
    ll res = a*b;
    cout<<res;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	int x = sqrt(n);
	cout << x * x << endl;
	return 0;
}

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

int main() {
  int A,B,C,X,Y,P,score;
  cin >> A >> B >> C >> X >> Y;
  score=X*A+Y*B;
  for(int i=0;i<max(X,Y)+1;i++){
    P= 2*i*C + max(0,(X-i)*A) + max(0,(Y-i)*B);
    score=min(score,P);
  }
  cout << score << endl;
}

Measured memory_bytes: 256
// Jai Mata Di
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
void solveTest(){
  int d, t, s;
  cin>>d>>t>>s;
  if(d<= t*s){
    cout<<"Yes\n";
  }
  else{
    cout<<"No\n";
  }
}
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t=1, i=1;
  //cin>>t;//Comment if only one test case
  while(i<=t){
    //cout<<"Case #"<<i<<": ";
    solveTest();
    i++;
  }
  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
using t = tuple<int, int>;
using tt = tuple<int, int, int>;
map<int, vector<int>> e[200005];
vector<t> ee[200005];

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m), q(m), c(m);
  rep(i, m) {
    cin >> p[i] >> q[i] >> c[i];
    p[i]--, q[i]--, c[i]--;
    e[p[i]][c[i]].push_back(q[i]);
    e[q[i]][c[i]].push_back(p[i]);
    ee[p[i]].push_back(make_tuple(q[i], c[i]));
    ee[q[i]].push_back(make_tuple(p[i], c[i]));
  }
  priority_queue<tt, vector<tt>, greater<tt>> que;
  // dist, pos, last use company
  map<int, map<int, int>> dist;
  int start = 0, goal = n - 1;
  que.push(make_tuple(0, start, -1));
  int d, pos, comp, to, company;
  vector<int> mins(n, 1e8);
  while (!que.empty()) {
    tie(d, pos, comp) = que.top();
    // cout << pos << " " << d << " " << comp << endl;
    que.pop();
    if (pos == goal) {
      cout << d << endl;
      return 0;
    }
    if (dist[pos][comp] != 0 && pos != start) {
      // すでに訪れたことがある
      continue;
    }
    dist[pos][comp] = d;
    if (comp == -1) {
      // 改札の外
      // 1払って改札に乗る
      for (auto s : ee[pos]) {
        tie(to, company) = s;
        if (dist[to][company] != 0 and dist[to][company] < d + 1)
          continue;
        que.push(make_tuple(d + 1, to, company));
      }
    } else {
      // 改札の中
      // 降りるか同じ会社内で乗り換える
      company = comp;
      // 乗り換え
      for (auto to : e[pos][comp]) {
        if (dist[to][company] != 0 and dist[to][company] < d + 1)
          continue;
        que.push(make_tuple(d, to, company));
      }
      // 降りる
      if (dist[pos][-1] == 0)
        que.push(make_tuple(d, pos, -1));
    }
  }
  cout << -1 << endl;
}


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

using namespace std;

int main(void){
 int N;
 cin >> N;
 int m = N / 7;
 int count = 0;
 for(int i = 0;i < m+1;i++){
  int k =(N-(7*i))%4;
  if(k == 0){
    cout << "Yes" << endl;
    count++;
    break;
  }

 }
 if(count == 0){
  cout << "No" << endl;
 }
 
}

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

int main(){

string s;
cin >> s;

if(s=="Sunny")cout << "Cloudy" << endl;
else if(s=="Cloudy")cout << "Rainy" << endl;
else cout << "Sunny"<< endl;

return 0;

}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
const ll mod =1e9+7;

int main()
{
    int m,k;
    scanf("%d%d",&m,&k);
    if(m==0)
    {
        puts(k==0?"0 0":"-1");
    }
    else if(m==1)
    {
        puts(k==0?"0 0 1 1":"-1");
    }
    else
    {
        int ma=pow(2,m)-1;
        if(k<0 || k>ma)
            puts("-1");
        else
        {
            for(int i=ma;i>=0;i--)
            {
                if(i!=k)
                    printf("%d ",i);
            }
            printf("%d ",k);

            for(int i=0;i<=ma;i++)
            {
                if(i!=k)
                    printf("%d ",i);
            }
            printf("%d ",k);
        }
    }
    return 0;
}


Measured memory_bytes: 1792
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        s: Chars,
    }

    let mut count = 0;
    // let mut prev_colour = s[0];
    for i in 0..s.len() - 1 {
        if s[i] != s[i + 1] {
            count += 1;
            // prev_colour = s[i + 1];
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2480
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define int long long
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main() {
  
    int x,y;
    cin >> x >>y;
    if(y%2==0&&2*x<=y&&y<=4*x)cout << "Yes";
      else cout <<"No";
}

Measured memory_bytes: 3632
x,n = map(int, input().split())
P = sorted(list(map(int, input().split())))
tmp = 0
for i in range(100):
    if x-tmp not in P:
        print(x-tmp)
        exit()

    elif x + tmp not in P:
        print(x+tmp)
        exit()
    tmp +=1


Measured memory_bytes: 61776
s=input()
t=input()
q=int(input())
n=len(s)
pre=[0]*(n+1)
for i in range(n):
    if s[i]=="A":
        pre[i]=pre[i-1]+1
    else:
        pre[i]=pre[i-1]
m=len(t)
p=[0]*(m+1)
for i in range(m):
    if t[i]=="A":
        p[i]=p[i-1]+1
    else:
        p[i]=p[i-1]

for _ in range(q):
    a,b,c,d=map(lambda x:int(x)-1,input().split())

    aa=(pre[b]-pre[a-1])
    co=(b-a+1-aa)
    co+=aa*2

    bb=(p[d]-p[c-1])
    do=(d-c+1-bb)
    do+=bb*2
   # print(aa,bb,co,do)
    co%=3
    do%=3
    if co==do:
        print("YES")
    else:
        print("NO")


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

int main(void){
  int w,h,x,y,b;
  scanf("%d%d%d%d", &w, &h, &x, &y);
  double a;
  a= ((double)w*(double)h)/2;
  if(x+x==w && y+y==h){
    b=1;
    printf("%f %d",a,b);
  }else{
    b=0;
    printf("%f %d",a,b);
  }
}


Measured memory_bytes: 128
N,K = gets.split.map(&:to_i)

h = Hash.new(0)

K.times do |k|
  d = gets.to_i
  a = gets.split.map(&:to_i)
  a.each do |aa|
    h[aa-1] += 1
  end
end

cnt = 0
N.times do |n|
  cnt += 1 if h[n] == 0
end

p cnt

Measured memory_bytes: 14416
N, x = map(int, input().split())
a = list(map(int, input().split()))

cnt = 0
for i in range(1, N):
    if a[i - 1] + a[i] > x:
        cnt += (a[i - 1] + a[i]) - x
        if x >= a[i - 1]:
            a[i] = x - a[i - 1]
        else:
            a[i] = 0
            a[i - 1] = x
print(cnt)

Measured memory_bytes: 14540
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    map<string, int> ball;
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;

    ball[s] = a;
    ball[t] = b;
    ball[u]--;

    cout << ball.at(s) << " " << ball.at(t) <<  endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def f():
  n=int(input())
  l=tuple(tuple(map(int,input().split())) for i in range(n-1))
  for i in range(n):
    now=0
    for a,s,d in l[i:]:
      now=a+s-(-max(0,now-s)//d)*d
    print(now)
if __name__=="__main__":
  f()


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N, K;
	cin >> N >> K;
	vl A(N);
	rep(i, N)
		cin >> A[i];
	rep(i, N - K) {
		string ans = (A[i]<A[i+K]) ? "Yes" : "No";
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4840