akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String strs=sc.next();
		int i=0;
		while(sc.hasNext()) {
			String str=sc.next();
			if(str.equals("END_OF_TEXT"))break;
			if(str.equalsIgnoreCase(strs)) {
				i+=1;
			}
		}
		System.out.println(i);
		sc.close();
	}
}


Measured memory_bytes: 26192
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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;
}
///////////////////////////////////////////////////////////////

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
	int N; cin >> N;
	vector<ll> A(3*N);
	rep(i,3*N) cin >> A[i];

	vector<ll> B(N+1),C(N+1);
  ll sumB,sumC;
	sumB = sumC = 0;
	priority_queue<ll, vector<ll>, greater<ll>> pqB;
	priority_queue<ll> pqC;
  rep(i,N) {
		sumB += A[i];
		pqB.emplace(A[i]);
		sumC += A[3*N-1-i];
		pqC.emplace(A[3*N-1-i]);
	}
	B[0] = sumB;
	C[N] = sumC;
	rep(i,N) {
		pqB.emplace(A[N+i]);
		sumB = sumB + A[N+i] - pqB.top(); pqB.pop();
		B[i+1] = sumB;
		pqC.emplace(A[2*N-1-i]);
		sumC = sumC + A[2*N-1-i] - pqC.top(); pqC.pop();
		C[N-1-i] = sumC;
	}

	ll ans = -1e18;
	rep(i,N+1) chmax(ans,B[i] - C[i]);

	cout << ans << endl;
}

Measured memory_bytes: 6000
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007
int main(){
	fast;
	int a,b,c;
	cin>>a>>b>>c;
	if(abs(a-b)>abs(a-c))
		cout<<"B";
	else
		cout<<"A";
	return 0;
}



Measured memory_bytes: 3640
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int size = s.size();
  bool dir[4];
  for (int i = 0; i < 4; ++i) dir[i] = false;
  for (int i = 0; i < size; ++i) {
    if (s[i] == 'N') dir[0] = true;
    if (s[i] == 'S') dir[1] = true;
    if (s[i] == 'W') dir[2] = true;
    if (s[i] == 'E') dir[3] = true;
  }
  if (dir[0] != dir[1] || dir[2] != dir[3]) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>


using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const string YES = "POSSIBLE";
const string NO = "IMPOSSIBLE";

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


void solve(long long N, long long K, std::vector<long long> A){
  sort(A.begin(), A.end());
  if(*(A.end()-1) < K)
    std::cout << NO << std::endl;
  else if(binary_search(A.begin(), A.end(), K))
    std::cout << YES << std::endl;
  else {
    ll g = *A.rbegin();
    for(int i=0; i+1<N; i++) {
      g = min(g, gcd(A[i], A[i+1]));
    }
    if(K%g==0)
      std::cout << YES << std::endl;
    else
      std::cout << NO << std::endl;
  }
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, K, std::move(A));
  return 0;
}



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

#define inf  1e18
#define int  long long
#define float double
#define endl  "\n"
#define w(t)  int t;cin>>t;while(t--)
#define str  to_string
#define vci  vector<int>
#define vcs  vector<string> 
#define mp   make_pair
#define pb   push_back
#define pii   pair<int,int>
#define pis   pair<int,string>
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define mod   1000000007
random_device rd;
mt19937 rand_gen(rd());
#define setbits(x)     __builtin_popcountll(x)
#define trailzero(x)   __builtin_ctzll(x)
#define shuffle(vc) shuffle(vc.begin(), vc.end(), rand_gen);
#define decimal(x,value)  cout<<fixed<<setprecision(x)<<value
void io()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("/home/kashif/cp/input.txt","r",stdin);
		
		freopen("/home/kashif/cp/output.txt","w",stdout);
	#endif

}
int n;
int dp[100005];
int h[100005]={0};
int ans(int h[],int k)
{
	
	if(k>=n)
		return dp[k]=0;
	if(k==n-1)
		return dp[k]=abs(h[k]-h[k+1]);
	int &a=dp[k];
	if(a!=-1)
		return a;
	else
	{
		int f=abs(h[k]-h[k+1])+ans(h,k+1);
		int g=abs(h[k]-h[k+2])+ans(h,k+2);
		a=min(f,g);
	}
	return a;

}
//


int32_t main()
{
	
	fastio();
	// io();
	memset(dp,-1,sizeof(dp));
	cin>>n;
	
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
	}
	cout<<ans(h,1)<<endl;


	
	
}


Measured memory_bytes: 13012
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    long n;
    long r=0;
    long g=0;
    long b=0;
    cin>>n;
    char color[n];
    for (int i=0; i<n; i++){
        cin>>color[i];
        if (color[i]=='R') r+=1;
        if (color[i]=='G') g+=1;
        if (color[i]=='B') b+=1;
        
    }
    
    
    long count=0;
    for (int i=0; i<n-1; i++){
        for (int k=i+1; k<n; k++){
            if ((i+k)%2==1){
                continue;
            }
            
            long j=(i+k)/2;
            
            if (color[i]!=color[j] && color[j]!=color[k] && color[i]!=color[k]){
                count+=1;
            }
        }
    }
    long a=r*g*b;
    cout<<a-count<<endl;
}

Measured memory_bytes: 3636
from functools import reduce
n = int(input())

alphabet = "abcdefghij"

cur = [[] for _ in range(10)]
nxt = [[] for _ in range(10)]

cur[0] = ["a"]
for _ in range(1, n):
	for i in range(10):
		for x in cur[i]:
			nxt[i].extend([x + alphabet[j] for j in range(i + 1)])
			nxt[i + 1].append(x + alphabet[i + 1])
	cur = nxt.copy()
	nxt = [[] for _ in range(10)]
ans = reduce(lambda a, b: a + b, cur)
ans.sort()
print(*ans, sep = "\n")


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

#define count_ones __builtin_popcountl
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    vector<vector<long double>> dist(n, vector<long double>(n, 0));
    vector<pair<ll, ll>> pos(n);
    for (ll i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        pos[i] = {x, y};
    }

    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < n; j++) {
            dist[i][j] = sqrt((pos[i].first - pos[j].first) * (pos[i].first - pos[j].first) +
                              (pos[i].second - pos[j].second) * (pos[i].second - pos[j].second));
        }
    }
    vector<ll> towns(n);
    for (ll i = 0; i < n; i++) {
        towns[i] = i;
    }

    long double sum_len = 0.0;
    ll cnt = 0;

    do {
        cnt++;
        for (ll i = 1; i < n; i++) {
            sum_len += dist[towns[i - 1]][towns[i]];
        }
    } while (next_permutation(towns.begin(), towns.end()));

    cout.precision(12);
    cout << sum_len / cnt;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

    String str;
		str = sc.nextLine();

  	int s = 700;
		int i = 0;

		while (i <= 2) {

			if (str.charAt(i) == 'o'){
	    	s = s + 100;
	    }

			i++;

		}

      	System.out.println (s);
    }
}

Measured memory_bytes: 21204
def main():
    s = input()
    t = input()

    ds, dt = {}, {}
    for cs, ct in zip(s, t):
        if (ds.get(cs) is not None and ds.get(cs) != ct) \
                or (dt.get(ct) is not None and dt.get(ct) != cs):
            print('No')
            exit()

        ds[cs] = ct
        dt[ct] = cs

    print('Yes')

if __name__ == "__main__":
    main()


Measured memory_bytes: 41932
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define pause system("pause")


signed main() {
	int N, Y, xa=-1, ya=-1, za=-1,z=0;
	cin >> N>>Y;
	for (int x=0; x <= N; x++) {
		for (int y=0; y <= (N - x); y++) {
			z = N - x - y;
				if (Y == (x * 10000 + y * 5000 + z * 1000)) {
					xa = x;
					ya = y;
					za = z;
			}
		}
	}
	cout << xa << " " << ya << " " << za << endl;
	pause;
}

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

using namespace std;

int main(void){
    long long n, k;
    long long r, s, p;
    long long ans = 0;

    cin >> n >> k;
    cin >> r >> s >> p;
    
    vector<long long> t(n,0), h(n,0);

    string rsp;
    cin >> rsp;
    for(long long i=0; i<n; i++){
        switch(rsp[i]){
        case 'r': t[i] = p; h[i] = 1; break;
        case 's': t[i] = r; h[i] = 2; break;
        case 'p': t[i] = s; h[i] = 3; break;
        default: t[i] = 0; h[i] = 0; break;
        }
    }
    long long max_prs = max(p,max(r,max(n,s)));

    for(long long i=0; i<k; i++){
        ans += t[i];
    }
    for(long long i=k; i<n; i++){
        if(h[i] != h[i-k]){
            ans += t[i];
        }else{
            h[i] = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>
#include <ctype.h>
int main(void){
    int count[26]={0};
    char ch;
    int i,num;
     
    while(scanf("%c",&ch)!=EOF){
        if(islower(ch)){
            num=ch-'a';
        }else if(isupper(ch)){
            num=ch-'A';
        }else{
            continue;
        }
        count[num]++;
    }
    for(i=0;i<26;i++){
        printf("%c : %d\n",'a'+i, count[i]);
    }
    return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	int A[60], B[60];
	cin >> N;
	rep(i, 0, N)
	{
		cin >> A[i];
		B[i] = A[i];
	}

	sort(B, B + N);

	int ans = 0;
	rep(i, 0, N)
	{
		if (A[i] != B[i])ans++;
	}

	if (ans <= 2)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {

  i64 A, B;
  cin >> A >> B;

  i64 d;
  REP(0, 10, d) {
    i64 ans = 10 * B + d;
    if(ans * 8 / 100 == A) {
      cout << ans << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  
  return 0;
}


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

int main() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);

	int cnt = 0;

	int i;
	for (i = a; i <= b; i++) {
		if (c % i == 0) {
			cnt ++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
#define S 4
int n,a[SZ];
ll f[S+1]; char o[SZ];
int main()
{
	memset(f,-127/3,sizeof f);
	scanf("%d",&n);
	for(int i=1;i<n;++i)
		scanf("%d%s",a+i,o+i+1);
	scanf("%d",a+n);
	f[0]=0;
	for(int i=n;i>=2;--i)
	{
		for(int j=1;j<=S;++j)
			f[j]=max(f[j],f[j-1]);
		if(o[i]=='-')
		{
			for(int j=1;j<=S;++j) f[j-1]=max(f[j-1],f[j]);
			for(int j=0;j<=S;++j) f[j]-=(j&1)?(-a[i]):a[i];
		}
		else
			for(int j=0;j<=S;++j) f[j]+=(j&1)?(-a[i]):a[i];
	}
	printf("%lld\n",f[0]+a[1]);
}


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

//F(A) = f(0, A)
long long F(long long A) {
  switch (A % 4) {
    case 0:
      return A;
      break;
    case 1:
      return 1;
      break;
    case 2:
      return A + 1;
      break;
    case 3:
      return 0;
      break;
  }
}

int main() {
  long long A, B;
  cin >> A >> B;
  long long ans = F(B) ^ F(A - 1);
  cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * @author torith
 * @date 2018-10-28
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    ll W,H; cin >> W >> H;

    if(W % 3 == 0 || H % 3 == 0){
        cout << 0 << "\n";
        return 0;
    }


    ll ans = 1e18;
    ll A,B,C;
    // Wを縮めていく
    for (int i = 1; i < W; ++i) {
        A = i * H;
        B = floor((W - i)/2) * H;
        C = (W - i - floor((W - i)/2)) * H;
        ans = min(ans, max(A, C) - min(A, B));

        B = (W - i) * floor(H/2);
        C = (W - i) * (H - floor(H/2));
        ans = min(ans, max(A, C) - min(A, B));
    }

    if(H == W){
        cout << ans << "\n";
        return 0;
    }

    // Hを縮めていく
    for (int i = 1; i < H; ++i) {
        A = i * W;
        B = floor((H - i)/2) * W;
        C = (H - i - floor((H-i)/2)) * W;
        ans = min(ans, max(A, C) - min(A, B));

        B = (H - i) * floor(W/2);
        C = (H - i) * (W - floor(W/2));
        ans = min(ans, max(A, C) - min(A, B));
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
N,K = map(int,input().split(' '))
#print(N,K)

d_list = list()
sunuke_idx_set = set()

for i in range(K):
  d_list.append(int(input()))
  sunuke_idx_set |= set(map(int, input().split(' ')))
  
#print(d_list)
#print(sunuke_idx_set)

print(N - len(sunuke_idx_set))

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

typedef long long ll;
typedef unsigned long long ull;

class ModInt{
public:
    ModInt(){
        x = 0;
    }
    ModInt(int v){
        x = (((v % mod) + mod) % mod);
    }
    ModInt(long long v){
        x = (((v % mod) + mod) % mod);
    }

    ModInt operator-() const {return ModInt(-x);}
    ModInt& operator+=(const ModInt& a){
        x = (x + a.x) % mod;
        return *this;
    }
    ModInt& operator-=(const ModInt& a){
        x = (x + mod - a.x) % mod;
        return *this;
    }
    ModInt& operator*=(const ModInt& a){
        x = (x * a.x) % mod;
        return *this;
    }
    ModInt operator+(const ModInt& a) const{
        ModInt res(*this);
        res += a;
        return res;
    }
    ModInt operator-(const ModInt& a) const{
        ModInt res(*this);
        res -= a;
        return res;
    }
    ModInt operator*(const ModInt& a) const{
        ModInt res(*this);
        res *= a;
        return res;
    }
    ModInt power(long long a) const{
        if(a == 0) return 1;
        auto b = power(a >> 1);
        b *= b;
        if(a & 1) b *= *this;
        return b;
    }
    ModInt inverse() const{
        return power(mod - 2);
    }
    ModInt& operator/=(const ModInt& a){
        (*this) *= a.inverse();
        return *this;
    }
    ModInt operator/(const ModInt& a)const{
        ModInt res(*this);
        res /= a;
        return res;
    }
    friend ostream& operator<<(ostream& os, const ModInt& a){
        os << a.x;
        return os;
    }

    static ModInt add(long long a, long long b){
        ModInt res(a);
        res += b;
        return res;
    }

    static long long get_mod(){ return mod;}

private:
    static const long long mod = 1000000007;
    long long x;
};

class FastCombination{
public:
    FastCombination(int n){
        auto mod = ModInt::get_mod();
        m_fac  = vector<ModInt>(n);
        m_finv = vector<ModInt>(n);
        m_inv  = vector<ModInt>(n);

        m_fac[0] = 1;
        m_fac[1] = 1;
        m_finv[0] = 1;
        m_finv[1] = 1;
        m_inv[1] = 1;
        for(int i=2; i<n; i++){
            m_fac [i] = m_fac[i-1] * i;
            m_inv [i] =-m_inv[mod%i] * (mod / i);
            m_finv[i] = m_finv[i-1] * m_inv[i];
        }
    }

    ModInt calc(int n, int k){
        if(n<k) return 0;
        if(n<0 || k<0) return 0;
        return m_fac[n] * m_finv[k] * m_finv[n-k];
    }

private:
    vector<ModInt> m_fac;
    vector<ModInt> m_finv;
    vector<ModInt> m_inv;
};

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    FastCombination fc(N);
    ModInt sum_min(0);
    ModInt sum_max(0);
    for(int i=0; i<N-K+1; i++){
        sum_min += ModInt(A[i]    ) * fc.calc(N-1-i, K-1);
        sum_max += ModInt(A[N-1-i]) * fc.calc(N-1-i, K-1);
    }
    cout << (sum_max - sum_min) << endl;

    return 0;
}


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

using namespace std;

char m[22][22];
int d[22][22];
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int h,w;

int main() {

    auto check = [] (int x, int y) {
        return x >= 0 and y >= 0 and x < h and y < w and m[x][y] == '.' and d[x][y] == -1;
    };
    auto bfs = [check](int x, int y) {

        queue<pair<int,int> > q;

        for (int i = 0; i < h; ++i)
            for (int j = 0; j < w; ++j)
                d[i][j] = -1;

        q.push({x,y});
        d[x][y] = 0;
        int mx = 0;
        while(!q.empty()) {
            x = q.front().first;
            y = q.front().second;
            q.pop();

            for (int i = 0; i < 4; ++i) {
                int u = dx[i] + x;
                int v = dy[i] + y;
                if(check(u, v)) {
                    d[u][v] = d[x][y] + 1;
                    mx = max(mx, d[u][v]);
                    q.push({u,v});
                }
            }
        }

       
        return mx;
    };
    cin >> h >> w;
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            cin >> m[i][j];

    int ans = 0;
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j) {
            if(m[i][j] == '.') {
                ans = max(ans, bfs(i,j));
            }
        }

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


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

int main()
{
	int a , b , c;
	cin>>a>>b>>c;
	int tmp = a + b;
	
	if(c<= tmp)
	{
		cout<<"Yes"<<endl;
	}
	else
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
 
    cout << x2 + y1 - y2 << " "
         << y2 + x2 - x1 << " "
         << x1 + y1 - y2 << " "
         << y1 + x2 - x1 << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define wi while
#define vl vector<ll>
#define vi vector<int>
#define map map<char,ll>
#define endl "\n"
const int mxN = 200001;
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    
    int n;
    cin>>n;
    vector<double> dp(n+1,0);
    dp[0] = 1;
    for(int coin=0;coin<n;++coin)
    {
        double p_heads;
        cin>>p_heads;
        for(int i=coin+1;i>=0;--i)
        {
            
            if(i==0)
            {
                dp[i] = dp[i] * (1-p_heads);
            }
            else
            {
                dp[i] = (dp[i-1] * p_heads )+
                    (dp[i]*(1 - p_heads));
            }
        }
    }
    double ans = 0;
    for(int i=0;i<=n;++i)
    {
        int tails = n - i;
        if(i >= tails)
        {
            ans += dp[i];
        }
    }
    cout<<fixed<<setprecision(10)<<ans;

    return 0;

}


Measured memory_bytes: 3844
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>

using namespace std;


string u[257];
string t[257];

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

	for(int i = 0;i < n;i++)
	{
		cin >> u[i];
	}

	int m;

	cin >> m;

	for(int i = 0;i < m;i++)
	{
		cin >> t[i];
	}

	int p = 1;

	for(int i = 0;i < m;i++)
	{
		bool flag = false;
		for(int j = 0;j < n;j++)
		{
			if(u[j] == t[i])flag = true;
		}

		if(flag)
		{
			if(p)
			{
				cout << "Opened by ";
			}else
			{
				cout << "Closed by ";
			}
			p = 1 - p;
		}else
		{
			cout << "Unknown ";
		}

		cout << t[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 1228
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  int a[100];
  for(int i=0;i<m;i++){
    scanf("%d",a+i);
  }
  int c=0,x=-1,y=-1;
  for(int i=0;i<m;i++){
    if(a[i]%2==1){
      if(c==0){
	x=i;
      }
      else if(c==1){
	y=i;
      }
      c++;
    }
  }
  if(c>2){
    puts("Impossible");
    return 0;
  }
  if(x!=-1){
    swap(a[0],a[x]);
  }
  if(y!=-1){
    swap(a[y],a[m-1]);
  }
  for(int i=0;i<m;i++){
    printf("%d%c",a[i],i==m-1?'\n':' ');
  }
  printf("%d\n",(m==1?2:m)-(a[0]==1?1:0));
  if(m==1){
    if(a[0]>1){
      printf("%d ",a[0]-1);
    }
    printf("%d\n",1);
  }
  else{
    if(a[0]>1){
      printf("%d ",a[0]-1);
    }
    for(int i=1;i<m-1;i++){
      printf("%d ",a[i]);
    }
    printf("%d\n",a[m-1]+1);
  }
  return 0;
}


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

int main() {
    int N, M; cin >> N >> M;
    priority_queue<int, vector<int>, less<int> > Q;
    rep(i, N){
        int A; cin >> A;
        Q.push(A);
    }
    rep(i, M){
        int a = Q.top(); Q.pop();
        a /= 2;
        Q.push(a);
    }
    ll ans = 0;
    rep(i, N){
        ans += Q.top();
        Q.pop();
    }

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

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

int main() {
  int a,b;
  char op;
  while(1){
    cin >> a >> op >> b;
    if(op=='?'){
      break;
    }
    if(op=='+'){
      cout << a+b << endl;
    }
    else if(op=='-'){
      cout << a-b << endl;
    }
    else if(op=='*'){
      cout << a*b << endl;
    }
    else{
      cout << a/b << endl;
    }
  }
}



Measured memory_bytes: 3100
//N=jumlah huruf->3
//K=huruf keberapa yg mau dikecilin->1
//S=kata pake huruf besar semua->aBC(output)

#include <stdio.h>

int main ()
{
	int N;
	int K;
	char S[55];
	
	scanf("%d %d", &N, &K);
	scanf("%s", S);
	
	S[K-1]+=32;
	
	printf("%s",S);
	
	return 0;
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
#define M 1000000007
#define W 10005
#define N 205
using namespace std;
int n,w,a[N],A[N],dp[W],ans;

int main(){
  cin>>n>>w;
  for(int i=1;i<=n;i++)cin>>a[i];
  sort(a+1,a+n+1);
  for(int i=1;i<=n;i++)A[i]=A[i-1]+a[i];
  dp[0]=1;
  if(A[n]<=w)ans++;
  for(int i=n;i>=1;i--){
    if(A[i-1]<=w){
      int k=w-A[i-1],l=max(0,k-a[i]+1);
      for(int j=k;j>=l;j--)ans=(ans+dp[j])%M;
    }
    for(int j=w-a[i];j>=0;j--)
      dp[j+a[i]]=(dp[j+a[i]]+dp[j])%M;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int i,a=0;
  string s;
  cin >> s;
  for (i=0;i<s.size();i++) if (s.at(i)-'0'==i%2) a++;
  if (a*2<s.size()) cout << a << endl;
  else cout << s.size()-a << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#define endl "\n"
using namespace std;
int main(int argc, char const *argv[])
{
	int n,a,b;
	cin>>n>>a>>b;
	if(abs(a-b)&1)
		cout<<"Borys"<<endl;
	else
		cout<<"Alice"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T &a, T b) {if (a < b) {a = b;return 1;}return 0;}
template<class T> inline bool chmin(T &a, T b) {if (a > b) {a = b;return 1;}return 0;}

int main(){
  int n; cin >> n;
  std::vector<int> v(n);
  std::vector<int> c(n);
  rep(i,n) cin >> v.at(i);
  rep(i,n) cin >> c.at(i);

  int ans = 0;
  rep(i,n) {
    if (v.at(i) > c.at(i)) {
      ans += v.at(i) - c.at(i);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
/* Stay hungry, stay foolish. */
/* Copyright by HenryLi */
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<sstream>
#include<stack>
#include<ctime>
#include<cmath>
#include<cctype>
#include<climits>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<bitset>
#include<complex>
using namespace std;
template <class _T> inline void read(_T &_x) {
	int _t; bool _flag=false;
	while((_t=getchar())!='-'&&(_t<'0'||_t>'9')) ;
	if(_t=='-') _flag=true,_t=getchar(); _x=_t-'0';
	while((_t=getchar())>='0'&&_t<='9') _x=_x*10+_t-'0';
	if(_flag) _x=-_x;
}
typedef long long LL;
const int maxn = 100010;
int n, x[maxn], y[maxn], t[maxn];
int main() {
	//freopen("C.in","r",stdin);
	//freopen("C.out","w",stdout);
	read(n);
	for (int i = 1; i <= n; ++i) {
		read(t[i]), read(x[i]), read(y[i]);
		int a = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]), b = t[i] - t[i - 1];
		if (a > b || (b - a) & 1) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

ll modpow(ll a, ll b, ll m = mod) {
  ll r = 1;
  while (b > 0) {
    if (b & 1) r = (r * a) % m;
    a = (a * a) % m;
    b >>= 1;
  }
  return r;
}

ll modinv(ll x, ll m = mod) {
  ll b = m;
  ll u = 1;
  ll v = 0;
  ll tmp;
  while (b) {
    ll t = x / b;
    x -= t * b;
    tmp = x;
    x = b;
    b = tmp;
    u -= t * v;
    tmp = u;
    u = v;
    v = tmp;
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

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

  ll n, a, b;
  cin >> n >> a >> b;

  ll comb = modpow(2, n) - 1;

  if (comb < 0) comb += mod;

  vector<ll> factorial(400000);
  factorial[0] = 1;
  for (int i = 1; i < 400000; i++) {
    factorial[i] = (factorial[i-1] * i) % mod;
  }

  vector<ll> ncr(400000);
  ncr[0] = 1;
  for (int i = 1; i < 400000; i++) {
    ncr[i] = (((((ncr[i-1] * (n - i + 1)) % mod) * factorial[i-1]) % mod) * modinv(factorial[i])) % mod;
  }

  comb -= ncr[a];
  if (comb < 0) comb += mod;
  comb -= ncr[b];
  if (comb < 0) comb += mod;

  cout << comb << endl;

  return 0;
}


Measured memory_bytes: 6528
my $k = Int(get);
my $ans = 0;
my @loop = 1..$k;
for @loop -> $a {
    for @loop -> $b {
        my $tmp = $a gcd $b;
        for @loop -> $c {
            $ans += $tmp gcd $c;
        }
    }
}
print "$ans\n";


Measured memory_bytes: 95332
h,w=map(int,input().split())
maze=[list(input()) for i in range(h)]
distance=[[-1]*w for i in range(h)]

cnt=0
for i in maze:
  cnt+=i.count('#')

Q=[[0,0]]
distance[0][0]=1

ans=-1

while Q:
  p=Q.pop(0)
  if p[0]==h-1 and p[1]==w-1:
    ans=h*w-cnt-distance[h-1][w-1]
    break

  dx=[1,-1,0,0]
  dy=[0,0,1,-1]

  for i in range(4):
    nx=p[0]+dx[i]
    ny=p[1]+dy[i]

    if 0<=nx<h and 0<=ny<w and distance[nx][ny]==-1 and maze[nx][ny]!='#':
      Q.append([nx,ny])
      distance[nx][ny]=distance[p[0]][p[1]]+1

print(ans)


Measured memory_bytes: 9116
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    bool all9=1;
    for(int i=1;i<SZ(s);i++) if(s[i]!='9') all9=0;
    if(all9) cout<<(s[0]-'0')+9*(SZ(s)-1)<<endl;
    else cout<<(s[0]-'1')+9*(SZ(s)-1)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,s,ans; 
int main(){
    cin>>n; 
    for(int i=sqrt(n);i;i--) 
        if(n%i==0){
            s=n/i;
            break;
        }
    while(s){ 
        ans++;
        s/=10;
    }
    cout<<ans<<endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool> vecbool;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<vecint> vec2int;
typedef vector<vecbool> vec2bool;
int dx[4]{-1, +1, 0, 0};
int dy[4]{0, 0, -1, +1};
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main() {
  init();
  ll n;
  cin >> n;
  int num = 0;
  set<ll> divnm, divn;
  for (ll i = 1; i * i <= n - 1; i++) {
    if ((n - 1) % i == 0) {
      if (divnm.find((n - 1) / i) == divnm.end()) {
        divnm.insert((n - 1) / i);
      }
      if (divnm.find(i) == divnm.end()) {
        divnm.insert(i);
      }
    }
  }
  num = divnm.size() - 1;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (divn.find(n / i) == divn.end()) {
        divn.insert(n / i);
      }
      if (divn.find(i) == divn.end()) {
        divn.insert(i);
      }
    }
  }

  // cout << num << endl;
  REPvec(itr, divn) {
    ll k = *itr;
    if (k == 1) continue;
    ll nc = n;
    // cout << k << " " << nc / k << endl;
    // cout << " " << endl;
    while (nc % k == 0) {
      nc = nc / k;
      // cout << nc << endl;
    }
    if (nc % k == 1) num++;
  }
  cout << num << endl;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
	int fib[40] = {};
	fib[1] = fib[2] = 1;
	for (int i = 3; i < 40; ++i) fib[i] = fib[i - 1] + fib[i - 2];
	int x, y; cin >> x >> y;
	int i = 0, l = 0, r = 0, u = 0, d = 0;
	while (!(l <= x && x <= r && d <= y && y <= u)) {
		if (i % 4 == 0) r += fib[i + 2];
		else if (i % 4 == 1) u += fib[i + 2];
		else if (i % 4 == 2) l -= fib[i + 2];
		else d -= fib[i + 1];
		i++;
	}
	cout << 1 + i % 3 << endl;

	return 0;
}


Measured memory_bytes: 3108
use proconio::{fastout,input};

fn main() {
	input!{
		n:usize,
		a:[i32; n]
	}
	let mut sum:i32=0;
	let mut ans:i64=0;
	const m:i32=1000000007;
	for i in 0..n{
		ans+=sum as i64*a[i] as i64;
		ans%=m as i64;
		sum+=a[i];
		sum%=m;
	}
	println!("{}",ans);
}

Measured memory_bytes: 4828
#include "bits/stdc++.h"
using namespace std;
int main(){
    vector<int>v(201);
    for(int i=1;i<201;i++)for(int j=i;j<201;j+=i)v[j]++;
    for(int i=1;i<201;i++)v[i]=v[i]==8&&(i&1);
    int n;
    cin>>n;
    cout<<accumulate(v.begin(),v.begin()+1+n,0);
}

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

int main() {
    while (true) {
        int H, W;
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }
        for (int y = 0; y < H; y++) {
            for (int x = 0; x < W; x++) {
                if ((x + y) % 2 == 0) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define INF 10000000000

ll a, b, c, n, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s;

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

    cin >> a >> b >> c >> x >> y;
    rep(i, 100001){
        mn = min(mn, i * 2 * c + a * max((ll)0, x - i) + b * max((ll)0, y - i));
    }
    cout << mn << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int main()
{
    int n;
    cin >> n;
    multiset<ll> ball;
    rep(i,n){
        ll ai;
        cin >> ai;
        ball.insert(ai);
    }
    ll ans = 0;
    while (!(ball.empty())){
        auto itr = ball.end();
        itr--;
        ll last = *itr;
        ball.erase(itr);
        repr(k,31,-1){
            if ((1ll<<k)<last)
                break;
            auto x = ball.find((1ll << k) - last);
            if (x!=ball.end()){
                ans++;
                ball.erase(x);
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9728
using System;

namespace Aizu
{
    public class OnlineJudge
    {
        static void Main()
        {
            for (string i; (i = Console.ReadLine()) != null;)
            {
                int a = 0;
                for (int t = 0, d = int.Parse(i); t < 600; a += t * ((t += d) - d) * d);
                System.Console.WriteLine(a);
            }
        }
    }
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int64 N;
  cin >> N;
  cout << (N+1)/2 << endl;
}


Measured memory_bytes: 256
import itertools
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))

l=list(itertools.chain.from_iterable([[i+1]*a[i] for i in range(n)]))
c=0
for i in range(h):
    if c%2==0:
      print(*l[i*w:(i+1)*w])
    else:
      print(*(l[(i+1)*w-1:i*w-1:-1]))
    c+=1


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

bool isPalindrome(const std::string &s) {
    std::string rev(s.rbegin(), s.rend());
    return rev == s;
}

int main(int argc, char **argv) {
    std::string S;
    std::cin >> S;

    auto N = S.length();


    bool p1 = isPalindrome(S);
    bool p2 = isPalindrome(S.substr(0, (N - 1) / 2));

    std::cout << ((p1 && p2) ? "Yes" : "No") << std::endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
k = int(input())

count = 0
change = False

for i in range(1, len(s)):
    if s[i-1] == s[i] and not change:
        count += 1
        change = True
    else:
        change = False

count2 = 0
change2 = False
for i in range(2, len(s)):
    if s[i-1] == s[i] and not change2:
        count2 += 1
        change2 = True
    else:
        change2 = False


if len(s) == 1:
    print(k//2)
elif s[0] == s[-1] and not change:
    if change2:
        print((count+count2+1)*(k//2)+count*(k%2))
    else:
        print(count+(count2+1)*(k-1))
else:
    print(count*k)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int a,n;
    long long x=1000000,y=-1000000,z=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(x>a){
            x=a;
        }
        if(y<a){
            y=a;
        }
       z=z+a;
    }
    cout<<x<<" "<<y<<" "<<z<<endl;

}


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

int main(int argc, char *argv[])
{
    int n;
    bool approved = true;

    std::cin >> n;


    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        if (a % 2 == 0) { //偶数
            if ((a % 5 == 0)||(a % 3 == 0)) {
                // approved
            } else {
                approved = false;
            }
        }
    }

    if (approved) {
        std::cout << "APPROVED" << std::endl;
    } else {
        std::cout << "DENIED" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,ans=0;
int main()
{
	cin>>n>>m;
	if(n%3==0)ans++;
	if(m%3==0)ans++;
	if((m+n)%3==0)ans++;
	if(ans>0)cout<<"Possible";
	else cout<<"Impossible";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vector<string> s(n);
  re(i, n) std::cin >> s[i];
  vll aru(n, 0), alok(n, 0);
  re(i, n) re(j, n) if(s[i][j]=='#') aru[j] = 1;
  re(j, n){
    bool flag = true;
    re(i, n) if(s[i][j]=='.') flag = false;
    if(flag) alok[j] = 1;
  }
  bool ed = true;
  re(i, n) re(j, n) if(s[i][j]=='#') ed = false;
  if(ed){
    std::cout << -1 << '\n';
    return 0;
  }

  ll ans = 10000000000;
  re(i, n){
    bool flag = true;
    ll ok_count=0, c=0;
    re(j, n){
      if(s[i][j]=='.'&&!aru[i]) flag = false;
      if(alok[j]) ok_count++;
      if(s[i][j]=='.') c++;
    }
    if(!flag) ans = min(ans, c+1+n-ok_count);
    else ans = min(ans, c+n-ok_count);
  }
  std::cout << ans << '\n';
  return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>


using namespace std;

/////////////////////////////////////////////////////
#define INF 1e12
ll N,A[4],l[10],v1[10],v2[10];
ll ans,mk[10];
ll i, j, k;

void bfs(ll n){
    if(n==N){
        ll pt = 0;
        fornum(i,0,3){
            if(v2[i]==0)
                return;
            pt += abs(A[i]-v1[i])+(v2[i] - 1) * 10;
        }
        if(pt<ans){
            ans = pt;
        }
        return;
    }
    bfs(n + 1);
    ll i;
    fornum(i,0,3){
        v1[i] += l[n];
        v2[i]++;
        bfs(n + 1);
        v1[i] -= l[n];
        v2[i]--;
    }
}

int main(){
    scanf("%lld", &N);
    fornum(i,0,3){
        scanf("%lld", &A[i]);
    }
    fornum(i,0,N){
        scanf("%lld", &l[i]);
    }
    ans = INF;
    bfs(0);
    printf("%lld", ans);

    return 0;
}

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

typedef long long ll;
const int MOD = 1000000007;
const int MAXN = 2010;

int C[MAXN][MAXN], sum[MAXN][MAXN], f[MAXN][MAXN];

int main()
{
	for(int i = 0; i < MAXN; ++i)
	{
		C[i][0] = sum[i][0] = f[i][0] = 1;
		for(int j = 1; j <= i; ++j)
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
		for(int j = 1; j < MAXN; ++j)
		{
			sum[i][j] = (sum[i][j - 1] + C[i][j]) % MOD;
			f[i][j] = (f[i][j - 1] + sum[i][j]) % MOD;
		}
	}
	int a, b, ans = 0;
	scanf("%d %d", &a, &b);
	if(!a || !b) return puts("1"), 0;
	for(int t = 1; t <= a + 1; ++t)
	{
		int res = 1;
		for(int i = 1; i <= min(b - 1, t - 1); ++i)
			res = (res + (ll)f[i - 1][t - i - 1] * C[b - 1][i] % MOD) % MOD;
		ans = (ans + res) % MOD;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 47744
IDENTIFICATION DIVISION.
       PROGRAM-ID. ATCODER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  indata PIC X(100).
       01  a1 PIC S9(08).
       01  a2 PIC S9(08).
       01  a3 PIC S9(08).
       01  r1 PIC S9(08).
       01  r2 PIC S9(08).
       01  r3 PIC S9(08).
       01  g1 pic S9(08).
       01  g2 pic S9(08).
       01 disp pic Z(20)9.
       PROCEDURE DIVISION.
        ACCEPT a1.
        ACCEPT a2.
        

        divide a1 by 500 giving g1 remainder r1
        if r1 <= a2 then
         display "Yes"
        else
         display "No"
        end-if

 
 
       STOP RUN.


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

 int main() {

 int N,A;
 cin>>N>>A;

 int L=A;
 int R=A+N-1;

 int eat;
 if(R<=0)eat=R;
 else if(L>=0)eat=L;
 else eat=0;

 int answer=(R+L)*(R-L+1)/2-eat;

 cout<<answer<<endl;

 return 0;

 }

Measured memory_bytes: 256
import math
A,B = map(int,input().split())
Xa = math.ceil(A/0.08)
xa = int((A+1)/0.08)
Xb = math.ceil(B/0.1)
xb = int((B+1)/0.1)
ans = -1
for i in range(Xa,xa):
    if Xb <= i < xb:
        ans = i
        break
print(ans)


Measured memory_bytes: 3060
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

S = read().decode().rstrip()

print("ABC") if S == 'ARC' else print("ARC")


Measured memory_bytes: 9016
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    for i in range(h):
        if i % 2 == 0:
            str_li = []
            for j in range(w):
                if j % 2 == 0:
                    str_li.append('#')
                else:
                    str_li.append('.')
            print(''.join(str_li))
        else:
            str_li = []
            for j in range(w):
                if j % 2 == 0:
                    str_li.append('.')
                else:
                    str_li.append('#')
            print(''.join(str_li))
    print()



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

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

#define INF 1000000000

int array_min_max(int* p, int n,bool f)  //f: true→min false→max
{
	int tmp;

	if (f)
		tmp = INF;
	else
		tmp = 0;

	for (int i = 0; i < n; i++)
	{
		if (f)
		{
			if (p[i] < tmp)
				tmp = p[i];
		}
		else
		{
			if (p[i] > tmp)
				tmp = p[i];
		}
	}
	return tmp;
}

void swap(int *a, int *b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void bubble_sort(int *p, int n)
{
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n - i - 1; j++)
		{
			if (p[j] > p[j + 1])
				swap(&p[j], &p[j + 1]);
		}
	}
}

int main()
{
	int N;
	int A, B;
	char S[101];
	char T[101];
	//char A[202];

	scanf("%d", &N);
	scanf("%s%s", S,T);

	for (int i = 0; T[i] != NULL; i++)
	{
		printf("%c%c", S[i], T[i]);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	int len = s.size();
	for(int i = 0; i < len; i++){
		if(i%2 == 0){
			if(s[i] == 'L'){
				cout << "No" << endl;
				return 0;
			}
		} else {
			if(s[i] == 'R'){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

const ll INF = ll(1e18)+1;
const ll MOD = ll(1e9)+7;


int main() {
  int N;

  cin >> N;
  vector<long long> A(N);
  vector<long long> num(400002, 0);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    num.at(A.at(i)-1)++;
  }

  ll sum = 0;

  for (int i = 0; i < num.size(); i++) {
    if (num.at(i) >= 2) {
      sum += num.at(i)*(num.at(i)-1)/2; 
    }
  }
  

  ll ans = 0;
  
  for (int i = 0; i < N; i++) {

    ans = sum;    
    ll tmp = num.at(A.at(i)-1) - 1;

    if (tmp >= 0) {
      ans = sum - tmp;
    }
    
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 7296