akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
int N;
int p[20001];
int a[20001];
int b[20001];
const int MAXN = 20000;

int main() {
  cin >> N;

  for(int i = 1; i <= N; i++) {
    int tmp;
    cin >> tmp;
    p[tmp] = i;
  }
  for(int i = 1; i <= N; i++) {
    a[i] = MAXN * i;
    b[i] = MAXN * (N-i);
  }

  for(int i = 1; i <= N; i++) {
    cout << a[i] + p[i] <<" ";
  }
  cout << endl;

  for(int i = 1; i <= N; i++) {
    cout << b[i] + p[i]<<" ";
  }
  cout << endl;
}
  
  


Measured memory_bytes: 896
//be nam KHODA
//biaeed manteghi bashim
#include <bits/stdc++.h>
using namespace std;
const int rad=320;
deque<int>q[rad];
int n;
int mp[rad][100001];
void upd(int l,int r){
	//cout<<l<<" "<<r<<"hj"<<endl;
	if(l/rad==r/rad){
		//cout<<l<<" "<<r<<"hj"<<endl;
		//int g=q[l/320][r%320];
		for(int i=(r%rad);i>l%rad;i--){
			//cout<<i<<" "<<i-1<<endl;
			swap(q[l/rad][i],q[l/rad][i-1]);
		}
		//q[l/320][l%320]=g;
		return ;
	}
	int g=q[r/rad][r%rad];
	for(int i=rad-1;i>l%rad;i--){
		swap(q[l/rad][i],q[l/rad][i-1]);
	}
	int f=q[l/rad][l%rad];
	q[l/rad][l%rad]=g;
	for(int i=(l/rad)+1;i<r/rad;i++){
		q[i].push_back(f);
		mp[i][f]++;
		f=q[i].front();
		q[i].pop_front();
		mp[i][f]--;
	}
	for(int i=r%rad;i>0;i--){
		swap(q[r/rad][i],q[r/rad][i-1]);
	}
	mp[r/rad][q[r/rad][0]]--;
	mp[r/rad][f]++;
	q[r/rad][0]=f;
	return;
}
int get(int l,int r,int k){
	long long int res=0;
	if(l/rad==r/rad){
		//long long int res=0;
		for(int i=l%rad;i<=r%rad;i++){
			if(q[l/rad][i]==k){
				res++;
			}
		}
		return res;
	}
	for(int i=rad-1;i>=l%rad;i--){
		if(q[l/rad][i]==k){
			res++;
		}
	}
	for(int i=(l/rad)+1;i<r/rad;i++){
		res+=mp[i][k];
	}
	for(int i=0;i<=r%rad;i++){
		if(q[r/rad][i]==k){
			res++;
		}
	}
	return res;
}
int valid(int l,int lastans){
	l=l+lastans-1;
	l%=n;
	return l+1;
}
int main(){
	ios_base:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int x;
	int y;
	cin>>x>>y;
	cout<<x+(y/2);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  int h,w,n;
  cin>>h>>w>>n;
  int l=max(h,w);
 cout<<(l+n-1)/l<<endl;
}

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

#define int long long
typedef pair<int,int> P;
const int INF=1e9;
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}

signed main(){
  int n;cin>>n;
  vector<P> v(n);
  for(int i=0;i<n;i++){
    int x,y;cin>>x>>y;
    v[i]=P(x,y);
  }
  int mnu=INF,mxu=-INF,mnv=INF,mxv=-INF;
  for(P p:v){
    int u=p.first-p.second,v=p.first+p.second;
    chmin(mnu,u);
    chmin(mnv,v);
    chmax(mxu,u);
    chmax(mxv,v);
  }
  cout<<max(mxu-mnu,mxv-mnv)<<endl;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()

int64_t N;
vector<int64_t> A;

int main() {
  std::cout << std::fixed << std::setprecision(20);

  cin >> N;
  A = vector<int64_t>(N,0);

  REP(i, N){
    cin >> A[i];
  }

  int64_t ans = 0;

  FOR(i, 1, N){
    if(A[i-1] > A[i]){
      ans += A[i-1] - A[i];
      A[i] = A[i-1];
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 4772
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);

        int a,b,c;
        a=scan.nextInt();
        b=scan.nextInt();
        c=scan.nextInt();
        System.out.println(c+" "+a+" "+b);
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int (i)=(a);(i)<(int)(b);(i)++)
#define RREP(i,a,b) for(int (i)=(a);(i)>=(int)(b);(i)--)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;



int main(){
    string s;
    cin >> s;
    int n = s.size();

    ll ans = 0;
    for (int bit = 0; bit < 1 << (n - 1); bit++){
        ll temp = s[0] - '0';
        for (int i = 0; i < n - 1; i++){
            if (bit >> i & 1){
                ans += temp;
                temp = s[i + 1] - '0';
            }else{
                temp *= 10;
                temp += s[i + 1] - '0';
            }
        }
        ans += temp;
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int , int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18 


int main (){
    string s ;
    cin >> s; 
    int n = s.size() ;
    int ans = 0 ;
    for(int i = 0; i < n;){
        int num = 0;
        for(int j = i; j < n; j++){
            if(s[j] != 'A' && s[j] != 'C' && s[j] != 'G' && s[j] != 'T'){
                break ;
            }
            else {
                num++ ;
            }
        }
        ans = max(ans, num) ;
        i +=  num + 1;
    }
    cout << ans << endl ;
}


Measured memory_bytes: 3600
#include <stdio.h>

int Sum(int N);

int main(){
    int N;
    scanf("%d", &N);
    printf(N % Sum(N) == 0 ? "Yes\n" : "No\n");
  
    return 0;
}

int Sum(int N){
    int sum = 0;

    for(int i = N; i > 0; i /= 10){
        sum += i % 10;
    }

    return sum;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

template< typename T >
struct Edge {
	int from,to;
	T cost;

	Edge(int to,T cost):from(-1),to(to),cost(cost) {}
	Edge(int from,int to,T cost):from(from),to(to),cost(cost) {}
};

template< typename T >
using Edges=vector< Edge<T> >;

template< typename T >
using WeightedGraph=vector< Edges<T> >;

template< typename T >
T prim(WeightedGraph<T> &G,set<int> edges_cost) {
	using P=pair<T,int>;

	T res=LINF;
	int V=(int)G.size(),cnt=0;

	for(auto limit:edges_cost) {
		vector<bool> visited(V,false);
		priority_queue< P,vector<P>,greater<P> > Q;
		Q.emplace(0,0);
		T ma=0;
		while(!Q.empty()) {
			P p=Q.top();Q.pop();
			int v=p.second;
			if(visited[v]) continue;
			visited[v]=true;
			ma=max(ma,p.first);
			for(auto e:G[v]) if(e.cost>=limit) Q.emplace(e.cost,e.to);
		}
		bool ok=true;
		REP(i,V) {
			if(!visited[i]) {
				ok=false;
				cnt++;
				break;
			}
		}
		if(ok) res=min(res,ma-limit);
	}
	if(cnt==(int)edges_cost.size()) res=-1;
	return res;
}

using Weight=long long;

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

	int V,E;
	while(true) {
	cin>>V>>E;
	if(V==0&&E==0) break;
	WeightedGraph<Weight> G(V);
	set<int> edges_cost;
	for(int i=0;i<E;i++) {
		int s,t;Weight w;
		cin>>s>>t>>w;
		s--,t--;
		G[s].emplace_back(t,w);
		G[t].emplace_back(s,w);
		edges_cost.insert(w);
	}
	cout<<prim(G,edges_cost)<<endl;
	}

	return 0;
}



Measured memory_bytes: 3948
H, W, A, B = map(int, input().split())
mod = 10**9 + 7

fact = [1] * (H+W+1)
fact_inv = [1] * (H+W+1)
for i in range(1, H+W+1):
    fact[i] = i * fact[i-1] % mod
fact_inv[H+W] = pow(fact[H+W], mod-2, mod)
for i in range(1, H+W+1)[::-1]:
    fact_inv[i-1] = i * fact_inv[i] % mod
comb = lambda n, k: fact[n] * fact_inv[k] * fact_inv[n-k] % mod

ans = 0
for i in range(B+1, W+1):
    ans += comb((i-1) + (H-A-1), i-1) * comb((W-i) + (A-1), W-i) % mod
    ans %= mod
print(ans)


Measured memory_bytes: 44268
#include <string.h>
#include<stdio.h>
int main()
{
    int a,b;
    char s[10],t[10],u[10];
  
  // 文字列の入力
    scanf("%s",s);
    scanf("%s",t);
    // 整数の入力
    scanf("%d", &a);
    scanf("%d", &b);
  // 文字列の入力
    scanf("%s",u);
  
  
  
  if(strcmp(s, u) == 0){
	a = a -1;
  }else{
    b = b -1;
  }

    
    // 出力
    printf("%d %d",a,b);//printf("%c",s[0])//文字一つ分のみを出力

    return 0;
}

Measured memory_bytes: 128
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  string s,t;
  cin >> s;
  t = s;
  reverse(all(s));

  int cnt = 0;
  rep(i,(sz(s) + 1 )/ 2)
  {
    if(s[i] != t[i])
      cnt++;
  }

  cout << cnt;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
program nearest_card_game
  implicit none
  integer :: n, q, i, l, h, m
  integer(8) :: x, a(100000), s(0:100000), e(0:100000)
  a = 0_8
  s = 0_8
  e = 0_8
  read(*,*) n, q
  read(*,*) a(1:n)
  if (n.le.2) then
    do i = 1, q
      write(*,'(i0)') a(n)
    end do
    stop
  end if
  do i = 1, n
    s(i) = s(i-1)+a(i)
  end do
  e(1) = a(1)
  do i = 2, n
    e(i) = e(i-2)+a(i)
  end do
  do i = 1, q
    read(*,*) x
    h = (n-1)/2
    if (abs(x-a(n-2*h)).le.abs(x-a(n-h))) then
      write(*,'(i0)') s(n)-s(n/2)
      cycle
    end if
    l = -1
    do while (h-l.gt.1)
      m = (h+l)/2
      if (abs(x-a(n-2*m)).gt.abs(x-a(n-m))) then
        h = m
      else
        l = m
      end if
    end do
    write(*,'(i0)') e(n-2*h)+s(n)-s(n-h)
  end do
  stop
end program nearest_card_game

Measured memory_bytes: 4736
#include <iostream>

using namespace std;

int v[200000];

int main()
{
    int n, i, x;
    cin>>n;

    for (i=0 ; i<n-1 ; i++)
    {
        cin>>x;
        v[x]++;
    }
    for (i=1 ; i<=n ; i++)
    {
        cout<<v[i]<<'\n';
    }
    return 0;
}


Measured memory_bytes: 4360
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>

using namespace std;

using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}


ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

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

    for(int i=1;i<10;i++){
        if(n%i == 0 && (n/i) < 10){
            cout<<"Yes"<<endl;
            return 0;
        }
    } 

    cout<<"No"<<endl;   


    return 0;
}

Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define P pair<int,int>
//P pa(114,514);   ,vector<P>vec(N,0);
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
//cout << setprecision(123);

int main(){
  int N;
  string X;
  cin>>N;
  vector<pair<string,pair<int,int>>>v(N);
  
  REP(i,N){
    cin>>v[i].first>>v[i].second.first;
    v[i].second.second=i+1;
  }
  
  sort(v.begin(),v.end());
  int i=0;
  while(i<N){
    X=v[i].first;
    int k=N,l=N;
     REP(j,N-i-1){
       if(v[i+j+1].first!=X){
         k=i+j;
         l=i+j;
         break;
       }
     }
    while(k>=i){
      if(v[k].second.second!=0){
       cout<<v[k].second.second<<endl;
       }
      k--;
    }
    i=l;
    i++;
  }
         
}

Measured memory_bytes: 256
N, M = map(int, input().split())
S = []
for _ in range(M):
    ipt = [int(i) for i in input().split()]
    S.append([True if i in ipt[1:] else False for i in range(1, N+1)])
P = [int(p) for p in input().split()]

ans = 0
for cmb in range(0, 2**N):
    b = list(str(bin(cmb)))[2:]
    cmb_b = ["0"]*(N-len(b)) + b
    cur_cnd = [0]*M
    for s_cnd, i in zip(reversed(cmb_b), range(N)):
        for s, j in zip(S, range(M)):
            if s_cnd == "1" and s[i]:
                cur_cnd[j] = (cur_cnd[j]+1) % 2
    if P == cur_cnd:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
int main() {
	double a;
	double c = 0;
	cin >> a;
	vector<int> b(a);
	for (int i = 0;i < a;i++) {
		cin >> b[i];
		c += b[i];
	}
	int x=*max_element(b.begin(), b.end());
	int y=*min_element(b.begin(), b.end());
	if((x+y)%2==0) cout << (x+y)/2 -y<< endl;
	else cout << (x + y+1) / 2-y << endl;
}



Measured memory_bytes: 3204
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt(),b = sc.nextInt();
    int c = sc.nextInt(),d = sc.nextInt();
    int train,bus;
    if(a < b){
      train = a;
    }else{
      train = b;
    }
    if(c < d){
      bus = c;
    }else{
      bus = d;
    }
    System.out.println(train + bus);
  }
}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int X=scan.nextInt();
		int count1=X/500;
		int nokori=X-500*count1;
		int count2=nokori/5;
		int uresisa=1000*count1+5*count2;
		System.out.println(uresisa);
	}

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000;
const int mod = 1e9+7;
int n, k, dp[maxn+10][maxn+10], sum[maxn*maxn+10];
int powe(int base, int p) {
	int res = 1;
	for (; p; p >>= 1, base = 1ll*base*base%mod)
		if (p&1) res = 1ll*res*base%mod;
	return res;
}
int C(int n, int m) {
	int k = 1ll*sum[m]*sum[n-m]%mod;
	return 1ll*sum[n]*powe(k, mod-2)%mod;
}
int main() {
	scanf("%d%d", &n, &k);
	sum[0] = 1;
	for (int i = 1; i <= n*k; ++i) 
		sum[i] = 1ll*sum[i-1]*i%mod;
	if (k == 1) {
		printf("%d\n", 1); return 0;
	}
	for (int i = 0; i <= n; ++i)
		dp[i][0] = 1;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= i; ++j)
			dp[i][j] = (dp[i-1][j]+1ll*dp[i][j-1]*C(n*k-i-(j-1)*(k-1)-1, k-2))%mod;
	printf("%d\n", 1ll*dp[n][n]*sum[n]%mod);
	return 0;
}

Measured memory_bytes: 31616
#include<iostream>
#include<bits/stdc++.h>
#include<climits>

#define forn(x,n,s) for(int i = x; i < n; i += s )
#define forr(x,n,s) for(int i = x; i>=n; i -= s)

using namespace std;

void go(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
  #endif
} 
long long int mod = 1e9+7;

int main(){
    go(); 

    // code here
    int k;cin>>k; 
    string s;cin>>s;
    if(s.length() <= k) cout<<s;
    else cout<<s.substr(0,k)+"...";
}






Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int h, w;
  string a;
  cin >> h >> w;
  cout << string(w + 2, '#') << endl;
  REP(i, h) {
    cin >> a;
    cout << "#" << a << "#" << endl;
  }
  cout << string(w + 2, '#') << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a, b, r;
    
    scanf("%d %d", &a, &b);
    
    if (a < b) {
        r = a;
        a = b;
        b = r;
    }
    
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    
    printf("%d\n", b);
    
    return 0;
}



Measured memory_bytes: 2064
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pi;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N >> M;
    vector<int>P(M),Y(M);
    vector<vector< Pi > > table(N);
    rep(i,0,M){
        cin >> P[i] >> Y[i];
    }
    rep(i,0,M){
        table[P[i] - 1].push_back( Pi(Y[i],i) );
    }
    rep(i,0,N){
        sort(table[i].begin(), table[i].end());
    }
    vector<string> ans(M);
    rep(i,0,N){
        rep(j,0,table[i].size()){
        //for(auto p:table[i]){
            //cout << p.first << endl;
            //for(auto p:v){
                Pi p = table[i][j];
                stringstream ss1,ss2;
                string s1,s2;
                ss1 << setw(6) << setfill('0') << (i + 1);
                ss2 << setw(6) << setfill('0') << (j + 1);
                s1 = ss1.str();
                s2 = ss2.str();
                ans[p.second] = s1 + s2;
            //}
        }
    }
    rep(i,0,M){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 13184
#include <stdio.h>

int main(){
        int N;
        scanf("%d", &N);
        int M;
        M=N;
        int sum=0;
        if(N==1){
                printf("Yes\n");
                goto fin;
        }
        int dig=0;
        while(N){
                dig = N % 10;
                sum += dig;
                N /= 10;
        }
        if(M % sum == 0){
                printf("Yes\n");
        }else{
                printf("No\n");
        }
fin: return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  String str = sc.next();
  int i = 0;
  if(str.equals("SUN")){
    i = 7;
  }else if(str.equals("MON")){
    i=6;}
    else if(str.equals("TUE")){
      i=5;}
      else if(str.equals("WED")){
        i=4;}
  else if(str.equals("THU")){
    i=3;}
  else if(str.equals("FRI")){
    i=2;}
  else{
    i=1;}
  System.out.print(i);
  }
  }


Measured memory_bytes: 21844
n = int(input())
count = 0

for i in reversed(range(1, n+1)):
    if i // 10 == 0:
        count += 1
    elif i // (10 ** 2) >= 1 and i // (10 ** 2) <= 9:
        count += 1
    elif i // (10 ** 4) >= 1 and i // (10 ** 4) <= 9:
        count += 1

print(count)

Measured memory_bytes: 3064
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var nums = new[] { int.Parse(input[0]), int.Parse(input[1]), int.Parse(input[2]) };

            Array.Sort(nums);

            Console.WriteLine("{0} {1} {2}",nums[0],nums[1],nums[2]);
            
        }
    }
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long P = 1000000007L;

long long SumModP(long long n, long long p){
	long long u = n;
	long long v;
	long long ret;

	v = (u + 1) % p;
	u = u % p;
	ret = (u * v) / 2;
	ret = ret % p;
	if(ret < 0) ret += p;
	return ret;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long N, K;
	cin >> N >> K;
	long long ans = 0;
	for(int m=K; m<=N+1; m++){
		long long v = 0;
		v = m % P;
		v = (v * N) % P;
		v -= SumModP(m-1, P);
		v = v % P;
		v -= SumModP(m-1, P);
		v = v % P;
		v += 1;
		v = v % P;
		ans += v;
		ans = ans % P;
		if(ans < 0) ans += P;
	}
	cout << ans << endl ;
	return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(all(h));
  int l = 0, r = k - 1;
  int ans = h[r] - h[l];
  while(r < n) {
    ans = min(ans, h[r] - h[l]);
    l++, r++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
  int n,m,l;
  int i,j,k;
  long x;
  int a[100][100],b[100][100];
  scanf("%d%d%d",&n,&m,&l);
  for(i=0;i<n;i++)
    {
      for(j=0;j<m;j++)
	{
	  scanf("%d",&a[i][j]);
	}
    }
  for(i=0;i<m;i++)
    {
      for(j=0;j<l;j++)
	{
	  scanf("%d",&b[i][j]);
	}
    }
  for(i=0;i<n;i++)
    {
      for(j=0;j<l;j++)
	{
	  x=0;
	  for(k=0;k<m;k++)
	    {
	      x+=a[i][k]*b[k][j];
	    }
	  printf("%ld",x);
	  if(j!=l-1) printf(" ");
	}
      printf("\n");
    }
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, K;
    cin >> N >> K;
    ll Ai;
    vector<ll> A;
    for(int i=0;i<N;i++){
        cin >> Ai;
        A.push_back(Ai);
    }
    vector<int> dp(2000, 0);
    for(int i=0; i<N; i++){
        dp[A[i]-1]++;
    }
    vector<int> n_less(2000, 0);
    for(int i=1; i<2000; i++){
        n_less[i] = n_less[i-1] + dp[i-1];
    }
    ll res = 0;
    for(int i=N-1; i>=0; i--){
        ll tmp = 0;
        for(int j=N-1; j>=i+1; j--){
            if(A[i] > A[j]) tmp++;
        }
        tmp *= K;
        tmp += ((K*(K-1)/2)%1000000007) * n_less[A[i]-1];
        tmp %= 1000000007;
        res += tmp;
        res %= 1000000007;
    }
    cout<<res<<endl;

    return 0;
}

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

int main(){
    int x, y, z;
    cin >> x >> y >> z;

    int sum = x + y + z;
    sum -= max({x, y, z});
    cout << sum;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int main(){
	int k,n;
	scanf("%d%d",&n,&k);
	int a[n]={};
	int b[200001]={};
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		b[a[i]]++;
	}
	std::sort(b,b+200001);
	int ans=0;
	for(int i=200000-k;i>=0;i--){
		ans+=b[i];
	}
	printf("%d\n",ans);
	return 0;
}
	

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int t; cin >> t; for(int cs = 1; cs <= t; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";

//input space ---> scanf("%[^\n]%*c",s);

int main() {
	IOS
	ld a,b,x;
	cin >> a >> b >> x;
	cout << fixed << setprecision(10);
	if(2.0*x <= a*a*b) {
		cout << atan(b*b*a/2/x)*180/acos(-1) << endl;
	} else  {
		cout << atan(2.*(b/a-x/pow(a,3)))*180/acos(-1) << endl;
	}
}


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

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x, long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }
        public static long keta(long x)
        {
            var z = 1;
            while (x > 0)
            {
                x /= 10;
                z++;
            }
            return z;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var n = Read();
         
            var d = new Dictionary<long, long>();
            for (int i = 0; i < n; i++)
            {
                var a = Read();
                if (d.ContainsKey(a)) d[a]++;
                else d.Add(a, 1);
            }
            long ans = 0;
            foreach (var item in d)
            {
                if (item.Value > 0 && item.Value % 2 != 0) ans++;
            }
            WriteLine(ans);

            

            Console.Out.Flush();
        }
    }
}



Measured memory_bytes: 28188
w,h,n = map(int,input().split())
W,H = [1]*w,[1]*h

for i in range(n):
	x,y,a = map(int,input().split())
	if a == 1:
		W = [0]*x+W[x:]
	elif a == 2:
		W = W[:x]+[0]*(w-x)
	elif a == 3:
		H = [0]*y+H[y:]
	else:
		H = H[:y]+[0]*(h-y)
	# print(W)
	# print(H)
print(sum(W)*sum(H))

Measured memory_bytes: 3064
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.io.PrintWriter;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        final String S;

        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            S = reader.readLine();
        }

        PrintWriter out = new PrintWriter(System.out);

        final int MAX_S = S.length();
        final int MAX_POS = (int)Math.pow(2, MAX_S) - 1;

        long ans = 0;

        for (int i = (int)Math.pow(2, MAX_S - 1); i <= MAX_POS; i++) {
            int pos = 0;

            for (int j = 0; j < MAX_S; j++) {
                if ((i >> j & 1) == 1) {
                    long tmp = Long.parseLong(S.substring(pos, j + 1));
                    pos = j + 1;
                    ans += tmp;
                }
            }
        }

        out.println(ans);

        out.flush();
    }
}


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

using namespace std;

const int MX = 100000;
bool sieve[MX];

int main() {
    vector<int> vp;
    for (int i=2; i<=MX; ++i) {
        if (sieve[i]) continue;
        vp.push_back(i);
        for (int j=i*i; 0<j && j<=MX; j+=i) {
            sieve[j] = true;
        }
    }

    long long m, a, b;
    while (cin >> m >> a >> b && (m && a && b)) {
        long long mx = 0;
        pair<int,int> ans;
        for (int i=0; i<(int)vp.size(); ++i) {
            if (vp[i] * vp[i] > m) break;
            for (int j=i; j<(int)vp.size(); ++j) {
                if (vp[i] * vp[j] > m || a * vp[j] > b * vp[i]) break;
                if (mx < vp[i] * vp[j]) {
                    mx = vp[i] * vp[j];
                    ans = make_pair(vp[i], vp[j]);
                }
            }
        }
        cout << ans.first << " " << ans.second << endl;
    }
    return 0;
}

Measured memory_bytes: 1420
import java.util.Scanner;
 public class Main{
   public static void main(String[]args){
     Scanner sc = new Scanner(System.in);
     int n = sc.nextInt();
     int m = sc.nextInt();
     if(n==m){
     	System.out.println("Yes");
     }else{
        System.out.println("No");
     }
   }
 }

Measured memory_bytes: 22868
//Mahmudul Alam
#include <iostream>
#define ll long long
using namespace std;

int main() {
    ll a, b, c, d;
    cin >> a ;
    if(a%100 <= 12 && a%100 > 0 && a / 100 <= 12 && a / 100 > 0) cout << "AMBIGUOUS" << endl;
    else if(a%100 <= 12 && a%100 > 0) cout << "YYMM" << endl;
    else if(a/100 <= 12 && a / 100 > 0) cout << "MMYY" << endl;
    else cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
d = {}
for ai in a:
  if ai in d:
    d[ai] += 1
  else:
    d[ai] = 1
ans = 0
for c in range(max(a) + 1):
  cand = 0
  for i in [c-1, c, c+1]:
    if i in d:
      cand += d[i]
  ans = max(cand, ans)
print(ans)

      

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    int res = 0;
    for (int i = 1; i < (int)s.size(); i++) {
        res += (s[i] != s[i - 1]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 512
def count(S):
    ans = 0
    for i in range(len(S)):
        if S[i] == "L" and i != 0 and S[i - 1] == "L":
            ans += 1
        if S[i] == "R" and i != len(S) - 1 and S[i + 1] == "R":
            ans += 1

    return ans


def count2(S):
    ans = 0
    for i in range(len(S) - 1):
        if S[i] != S[i + 1]:
            ans += 1

    return ans


N, K = map(int, input().split())
S = list(input())

first = count(S)
rest = count2(S)

ans = first + min(rest, K * 2)

print(ans)


Measured memory_bytes: 4084
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
using namespace std;

int main() {
	long long K;
	int T, i, ma, in,size,ans;
	cin >> K >> T;
	cin >> ma;
	size = ma;
	for (i = 1; i < T; i++) {
		cin >> in;
		size += in;
		ma = max(ma, in);
	}
	size -= ma;
	ans = ma - size;
	ans--;
	if (ans <= 0) {
		ans = 0;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const double EPS =  1e-10;
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point{
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y){}

    Point operator + (Point p){
        return Point(x + p.x, y + p.y);
    }
    Point operator - (Point p){
        return Point(x - p.x, y - p.y);
    }
    Point operator * (Point p){
        return Point(x * p.x, y * p.y);
    }
    Point operator * (double r){
        return Point(x * r, y * r);
    }
    Point operator / (Point p){
        return Point(x / p.x, y / p.y);
    }

    double abs(){
        return sqrt(norm());
    }
    double norm(){
        return x * x + y * y;
    }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }
    bool operator == (const Point &p) const {
        return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
    }
    
    
};



typedef Point Vector;

class Segment : public Point{
    public:
    Point p1, p2;
    Segment(Point p1_, Point p2_){
        p1 = p1_;
        p2 = p2_;
    }
    Segment(double a, double b, double c, double d){
        Point(a, b);
        Point(c, d);
    }
    
};

typedef Segment Line;

double dot(Point a, Point b){
    return a.x * b.x + a.y * b.y;
}
double cross(Point a, Point b){
    return a.x * b.y - a.y * b.x;
}
bool isOrthogonal(Point a, Point b){
    return equals(dot(a, b), 0.0);
}
bool isParallel(Point a, Point b){
    return equals(cross(a, b), 0.0);
}
bool isOrthogonal(Segment s1, Segment s2){
    return equals(dot(s1.p2 - s1.p1, s2.p2 - s1.p1), 0.0);
}
bool isParallel(Segment s1, Segment s2){
    return equals(cross(s1.p2 - s1.p1, s2.p2 - s1.p1), 0.0);
}

Point project(Segment s, Point p){
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / base.norm();
    //Vector tmp = s.p1 + base * r;
    Vector tmp = base * r;
    return s.p1 + base * r;
}

Point reflect(Segment s, Point p){
    return p + (project(s, p) - p) * 2;
}

int main(void){
    Point p, p1, p2;
    
    std::cin >> p1.x >> p1.y >> p2.x >> p2.y;
    Segment s = Segment(p1, p2);
    int q;
    std::cin >> q;
    Point ans;
    for(int i = 0; i < q; i++){
        std::cin >> p.x >> p.y;
        ans = reflect(s, p);
        std::cout << std::fixed << std::setprecision(10) << ans.x << " " << ans.y << std::endl;
    }
}



Measured memory_bytes: 3288
weatherList = list(input())
totalcount = 0

if weatherList[0] == "R":
  totalcount += 1
  if weatherList[1] == "R":
    totalcount += 1
    if weatherList[2] == "R":
      totalcount += 1
      
elif weatherList[1] == "R":
  totalcount += 1
  if weatherList[2] == "R":
    totalcount += 1
    
elif weatherList[2] == "R":
  totalcount += 1

print(totalcount)

Measured memory_bytes: 9116
#include <iostream>
#include <cmath>

using namespace std;



int main(){
  float a, b, c, d;
  cin >> a >> b >> c >> d;
  float x = ceil(a/d);
  float y = ceil(c/b);
  if (y <= x){
    cout << "Yes\n";
  }
  else {
    cout << "No\n";
  }
}

Measured memory_bytes: 3720
n = int(input())

hoge = list(map(int, input().split()))

ans = 1

for i in range(n):
    if(hoge[i] == 0):
        print(0)
        exit()

for i in range(n):
    ans *= hoge[i]
    if(ans > 1000000000000000000):
        print(-1)
        exit()

print(ans)

Measured memory_bytes: 21700
#include<bits/stdc++.h>
using namespace std;
int i,j,k,n,m,a[200007],dp[200007];
int main()
{
	cin>>n>>k;
   for(i=0;i<n;i++)
     cin>>a[i];
   for(i=1;i<=k;i++)
   {
   	  for(j=0;j<n;j++)
      {
      	if(i-a[j]>=0&&dp[i-a[j]]==0)
        {
    		dp[i] = 1;
            break;
        }
      }
   }
  if(dp[k]==1) cout<<"First\n";
  else cout<<"Second\n";
}

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

typedef pair<ll,ll> P;
const ll MO = 1000000007;
int ans;
vector<int> a,b,c,d;
int n,m,q;

void dfs(vector<int> A){
    if(A.size()==n+1){
        //count
        int res=0;
        rep(i,q){
            if(A[b[i]]-A[a[i]]==c[i])res+=d[i];
        }
        ans = max(res,ans);
        return;
    }
    A.push_back(A.back());
    while(A.back()<=m){
        dfs(A);
        A.back()++;
    }
}

int main(){
    cin >> n >> m >> q;
    a=b=c=d = vector<int>(q);
    rep(i,q){        
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1,1));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3572
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define scanf scanf_s


int main()
{
	string s;
	cin >> s;
	if (s == "SUN")
		cout << "7";
	else if (s == "MON")
		cout << "6";
	else if (s == "TUE")
		cout << "5";
	else if (s == "WED")
		cout << "4";
	else if (s == "THU")
		cout << "3";
	else if (s == "FRI")
		cout << "2";
	else if (s == "SAT")
		cout << "1";	
	return 0;
}


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

int main(){
  int a,b;
  int i,count=0;
 char *T;
 char *P;
 T = (char* )malloc(sizeof(char) * 1000000);
 P = (char* )malloc(sizeof(char) * 10000);
  scanf("%s%s",T, P);

  a = strlen(T);
  b = strlen(P);
  for(i = 0;i < a; i++){
    if(strncmp(T+i,P,b) == 0){
      printf("%d\n",i);
    }
  }
  return 0;
}

Measured memory_bytes: 1576
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll v):v(normS(v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll u[]={a,1,0},v[]={b,0,1};
		while(*v){
			ll t=*u/ *v;
			rep(i,3) swap(u[i]-=t*v[i],v[i]);
		}
		if(u[0]<0) rep(i,3) u[i]=-u[i];
		x=u[1],y=u[2];
		return u[0];
	}
	ModInt inv() const{
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<1000000007>;
mint dp[22][1<<21];
int ok[21][21];
bool B(int x,int i){return (x>>i)&1;}
int main(){
	int N;
	cin>>N;
	rep(i,N) rep(j,N) cin>>ok[i][j];
	dp[0][0] = 1;
	rep(i,N) rep(j,1<<N) if(dp[i][j]){
		rep(x,N) if(ok[i][x] && !B(j,x)){
			dp[i+1][j|(1<<x)] += dp[i][j];
		}
	}
	cout<<dp[N][(1<<N)-1]<<endl;
}

Measured memory_bytes: 180608
import math
k=int(input())

tot=k*(k+1)//2

for i in range(1,k+1):
    for j in range(i+1,k+1):
        tot+=math.gcd(i,j)*6

for i in range(1,k+1):
    for j in range(i+1,k+1):
        for l in range(j+1,k+1):
            tot+=math.gcd(i,math.gcd(j,l))*6

print(tot)

Measured memory_bytes: 9208
package main
 
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)
 
var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func main() {
  S := NextLine()
  Sx := ""
  for _, s := range S {
    if s != 'x' {
      Sx += string(s)
    }
  }
  ans := 0
  for i, s := range Sx {
    if Sx[len(Sx) - 1 - i] != byte(s) {
      ans = -1
      break
    }
  }
  if ans == 0 {
    s := 0
    t := len(S) - 1
    for s < t {
      if S[s] == S[t] {
        s++
        t--
      } else if S[s] == 'x' {
        s++
        ans++
      } else {
        t--
        ans++
      }
    }
  }
  Write(ans)
  Output()
}

Measured memory_bytes: 17272
'use strict';
(function(stdin) {
	var lines  = stdin.toString().split('\n');
	var result = (function(data) {
		return data.filter(isValidData)
		.map(function(v) {
			var result = [];
			for (var i =0; i < v[0]; i++)
				result.push(line(v[1]));
			result.push('');
			return result.join('\n');

			function line(num){
				var result = '';
				for (var i = 0; i < num; i++)
					result += '#';
				return result;
			}
		}).join('\n')
	}(lines.map(function(v){return v.split(' ').map(Number);})
	));
	console.log(result);

	function isValidData(line){
		return line.every(function(v) {
			return v != 0;
		});
	}

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

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

int a[5][5], n, x;
map<int, pair<int, int> > mp;
bool f[5][5];

int main() {
	for (int i = 1; i <= 3; i++)
		for (int j = 1; j <= 3; j++) {
			cin >> x;
			mp[x] = make_pair(i, j);
		}
	cin >> n;
	while (n--) {
		cin >> x;
		pair<int, int> p = mp[x];
		f[p.first][p.second] = 1;
	}
	if ((f[1][1] && f[1][2] && f[1][3]) || (f[2][1] && f[2][2] && f[2][3]) || (f[3][1] && f[3][2] && f[3][3]) || 
		(f[1][1] && f[2][1] && f[3][1]) || (f[1][2] && f[2][2] && f[3][2]) || (f[1][3] && f[2][3] && f[3][3]) ||
		(f[1][1] && f[2][2] && f[3][3]) || (f[1][3] && f[2][2] && f[3][1])
	   ) puts("Yes"); else puts("No");
	return 0;
}



Measured memory_bytes: 256
/*package whatever //do not write package name here */

import java.io.*;
import java.util.Scanner;

class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();int mul=1;double sum=0;
		for(int i=0;i<N;i++){
		    double a=sc.nextDouble();
		   // mul=mul*a;
		    sum=sum+1/a;
		}
		//double b=(double)sum/(double)mul;
		System.out.println(1/sum);

	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a , b , w ,d ;
	scanf("%d%d%d",&w,&a,&b);
	if(b>(a+w))
	d=b-(a+w);
	else if(a>b+w)
	d=a-(b+w);
	else
	d=0;
	printf("%d",d);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;

int main(){
  string a, b, c;cin>>a>>b>>c;
  cout<<((a[(int)a.size()-1]==b[0] && b[(int)b.size()-1]==c[0])?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	long long int N, M,ans,cou;
	cou = 0;
	ans = 0;
	cin >> N >> M;
	vint A(N);
	vint B(N);
	map<int, long long int>mp;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
		mp[A[i]] += B[i];
	}
	for (auto shop: mp) {
		ans += min(shop.second, M)*shop.first;
		M -=shop.second;
		if (M <= 0)break;
	}
	cout << ans << endl;
}

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

using namespace std;

typedef long long int lli;

int n;
const lli mod = 1000000007;
vector<vector<int>> tree(100000, vector<int>());
vector<vector<lli>> dp(100000, vector<lli>(2, 0));

lli rec(int prev, int crnt, int color) {
    // cout << prev << " " << crnt << " " << color << endl;
    if (dp[crnt][color]) return dp[crnt][color];
    if (crnt != 0 && tree[crnt].size() == 1) return dp[crnt][color] = 1;

    lli res = 1;
    for (auto a : tree[crnt]) {
        if (a == prev) continue;
        res *= (color) ? rec(crnt, a, 0) : rec(crnt, a, 0)+rec(crnt, a, 1);
        res %= mod;
    }

    return dp[crnt][color] = res;
}

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

    int x, y;

    cin >> n;
    for (int i=0; i<n-1; i++) {
        cin >> x >> y;
        tree[x-1].push_back(y-1);
        tree[y-1].push_back(x-1);
    }

    cout << (rec(-1, 0, 0) + rec(-1, 0, 1)) % mod << endl;

    return 0;
}


Measured memory_bytes: 19584
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

string a;
int main()
{
    cin>>a;
    int ans=0;
    int p=0;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]=='g')
        {
            if(p>0)
            {
                ans++;
                p--;
            }
            else
            {
                p++;
            }
        }
        else
        {
            if(p>0)
                p--;
            else
            {
                p++;
                ans--;
            }

        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

S = list(map(int, list(input())))[::-1]

l = [0]*2019
l[0] = 1

tmp = 0
z = 1

for i, s in enumerate(S):
	tmp += s*z
	z = z*10%2019
	l[tmp%2019] += 1

ans = 0
for v in l:
	ans += v*(v-1)//2

print(ans)

Measured memory_bytes: 13568
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tlll tuple<ll, ll, ll>

ll inf = 1e9+7;
 
ll pw(ll x, ll y) {
    if (y == 0) return 1;
    else if (y == 1) return x % inf;
    else if (y % 2 == 0) {
        ll p = pw(x, y / 2);
        return p * p % inf;
    }
    else {
        ll p = pw(x, y / 2);
        return p * p % inf * x % inf;
    }
}

ll dv(ll x, ll y) {
    return x * pw(y, inf - 2) % inf;
}
 
ll comb(ll cn, ll cr) {
    ll v = 1;
    if (cn < cr || cn < 0 || cr < 0) return 0;
    for (int i = 1; i <= cr; i++) {
        v = v * (cn - i + 1) % inf;
        v = v * dv(1, i) % inf;
    }
    return v;
}

int main() {
    ll n, k, a[100010];
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);

    ll ans = 0, c = comb(n - 1, k - 1);
    for (int i = 0; i <= n - k; i++) {
        //cerr << c << endl;
        ans += a[n - 1 - i] * c % inf;
        ans %= inf;
        c *= dv(n - k - i, n - 1 - i);
        c %= inf;
    }
    //cerr << ans << endl;

    c = comb(n - 1, k - 1);
    for (int i = 0; i <= n - k; i++) {
        ans -= a[i] * c % inf;
        ans = (ans + inf * inf) % inf;
        c *= dv(n - k - i, n - 1 - i);
        c %= inf;
    }

    cout << ans << endl;

}


Measured memory_bytes: 1024
import java.util.Scanner;

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

		String ans = isEcho(sc.next()) ? "Yes" : "No";
		System.out.println(ans);
		sc.close();
	}

	static boolean isEcho(String s) {
		if (s.length() % 2 == 1)
			return false;

		String fh = s.substring(0, s.length() / 2);
		String lh = s.substring(s.length() / 2);

		if (fh.equals(lh))
			return true;
		else
			return false;
	}
}


Measured memory_bytes: 22996