akhauriyash/Code-Regression huggingface dataset:
/********************************************//**
 ****** Handle: techno_phyle    *****************
 ***********************************************/

#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long ll;
#define mod 1000000007
#define N 100010
#define M 200010
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto it:a) cout << it << " "; cout << endl
#define adbp(a) for(auto it:a) cout << it.first << " " << it.second << endl
#define pb push_back
#define mp make_pair
#define endline "\n"
#define in(x) scanf("%d",&x);
const ll INF = 1e18L + 5;
const int inf = 1e9 + 5;
typedef pair<double, long> key;
struct comp {
	bool operator()(pair<int, int> p1, pair<int, int> p2) {
		if (p1.first < p2.first) return false;
		if (p2.first < p1.first) return true;
		return p1.second < p2.second;
	};
};
//greater<pair<int,int> , greater<int>>
//ll a[M];

ll power(ll x, ll y , ll m)
{
	ll temp;
	if ( y == 0)
		return 1;
	temp = power(x, y / 2 , m);
	if (y % 2 == 0)
		return (temp * temp) % m;
	else
		return (x * (temp * temp) % m) % m;
}
bool prime[1000015];
bool primesquare[1000015]; int a[1000015];
void SieveOfEratosthenes(int n) {
	for (int i = 2; i <= n; i++)
		prime[i] = true;
	for (int i = 0; i <= (n + 1); i++)
		primesquare[i] = false;
	prime[1] = false;

	for (int p = 2; p * p <= n; p++) {
		if (prime[p] == true) {
			for (int i = p * 2; i <= n; i += p)
				prime[i] = false;
		}
	}

	int j = 0;
	for (int p = 2; p <= n; p++) {
		if (prime[p]) {
			a[j] = p;
			j++;
		}
	}
	for (int p = 2; p <= sqrt(n); p++) {
		if (prime[p]) {
			primesquare[p * p] = true;
		}
	}
}
int countDivisors(int n) {
	if (n == 1)
		return 1;
	int ans = 1;
	for (int i = 0;; i++) {
		if (a[i] * a[i] * a[i] > n)
			break;
		int cnt = 1;
		while (n % a[i] == 0)
		{
			n = n / a[i];
			cnt = cnt + 1;
		}
		ans = ans * cnt;
	}

	// First case
	if (prime[n])
		ans = ans * 2;

	// Second case
	else if (primesquare[n])
		ans = ans * 3;

	// Third case
	else if (n != 1)
		ans = ans * 4;
	return ans; // Total divisors
}

int main() {
	fastIO;

	SieveOfEratosthenes(1000000);
	//cout << countDivisors(100) << endl;
	int test = 1;
	//cin >> test;
	while (test--) {
		int n;
		cin >> n;
		int ans = 0;
		for (int i = 1 ; i < n ; i++) {
			int rest =  n - i;
			int factors = countDivisors(rest);
			ans += factors;

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





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

using namespace std;

int n, a, b, c;
int l[8];
int inf = pow(10, 9);

// DFS: deps-first search 深さ優先探索を使う
int dfs(int now,int la,int lb,int lc) {
  if (now==n) {
    if (min({la,lb,lc})>0) return abs(la-a)+abs(lb-b)+abs(lc-c)-30;
    else return inf;
  }
  int m0=dfs(now+1,la,lb,lc);
  int ma=dfs(now+1,la+l[now],lb,lc)+10;
  int mb=dfs(now+1,la,lb+l[now],lc)+10;
  int mc=dfs(now+1,la,lb,lc+l[now])+10;
  return min({m0,ma,mb,mc});
}

int main() {
  cin >> n >> a >> b >> c;
  for (int i=0;i<n;i++) {
    cin >> l[i];
  }
  cout << dfs(0,0,0,0) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,x,y,z;
    scanf("%d",&a);
    x=a/100;
    y=(a%100)/10;
    z=(a%100)%10;
    if(x==7 || y==7 || z==7)
    {
        printf("Yes\n");
    }
    else
        printf("No\n");
    return 0;

}


Measured memory_bytes: 1620
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  cin >>N;
  vector<double> vec(N);
  vector<string> vect(N);
  rep(i,N) {
   cin >>vec.at(i)>>vect.at(i);
  }
  int J=0;
  double B=0;
  double c=380000.0;
  rep(i,N) {
if(vect.at(i)=="JPY") {
  J +=vec.at(i);
}
    if(vect.at(i)=="BTC") {
 B +=vec.at(i)*c;
    }
  }
  cout <<J+B<< endl;
}
  
 

Measured memory_bytes: 256
s = input()

ans = 101
for i in range(26):
    a = chr(i+97)
    txt = s
    count = 0
    if txt.count(a) == len(txt):
        ans = 0
        break
    for j in range(len(s)-1):
        newtext = ""
        count += 1
        for k in range(len(txt)-1):
            if txt[k] == a or txt[k+1] == a:
                newtext += a
            else:
                newtext += txt[k]
        if newtext.count(a) == len(newtext):
            anstemp = count
            ans = min(anstemp, ans)
            break
        else:
            txt = newtext
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P  = pair<int, int>;
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()
{
    string s;
    cin >> s;
    char x = *s.rbegin();
    int y = *s.rbegin() - '0';
    int a[] {2, 4, 5, 7, 9};
    int b[] {0, 1, 6, 8};
    if(y == 3)
    {
        cout << "bon" << endl;
    }
    if(find(a, a+5, y) != a+5)
    {
        cout << "hon" << endl;
    }
    if(find(b, b+4, y) != b+4){
        cout << "pon" << endl;
    }
    return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    int n,q;cin>>n>>q;

    VVI e(n);
    REP(i,n-1){
        int a,b;cin>>a>>b;
        a--;b--;
        e[a].PB(b);
        e[b].PB(a);
    }

    VI result(n);

    REP(i,q){
        int p,x;cin>>p>>x;
        p--;

        result[p] += x;
    }

    queue<int> que;
    que.push(0);

    vector<bool> f(n);

    while(!que.empty()){
        int now = que.front();
        que.pop();
        f[now]=true;
        //dump(now)
        //dump(result[now])
        for(auto next : e[now]){
            if(f[next]){
                continue;
            }
            //dump(next)
            //dump(result[next])
            result[next] += result[now];
            que.push(next);
            //dump(result[next])
        }
    }

    REP(i,n){
        if(i!=0){
            cout<<" ";
        }
        cout<<result[i];
    }
    cout<<endl;
    



	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 15604
#include<stdio.h>
int main(){
	int h,w,i,j;
	char a[60][60];
	scanf("%d%d",&h,&w);
	for(i=0;i<h;i++){
		scanf("%s",a[i]);
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(a[i][j]=='.'){
				a[i][j]='0';
				if(i!=0   && a[i-1][j]=='#')a[i][j]+=1;
				if(i!=h-1 && a[i+1][j]=='#')a[i][j]+=1;
				if(j!=0   && a[i][j-1]=='#')a[i][j]+=1;
				if(j!=w-1 && a[i][j+1]=='#')a[i][j]+=1;
				if(i!=0   && j!=0   && a[i-1][j-1]=='#')a[i][j]+=1;
				if(i!=0   && j!=w-1 && a[i-1][j+1]=='#')a[i][j]+=1;
				if(i!=h-1 && j!=0   && a[i+1][j-1]=='#')a[i][j]+=1;
				if(i!=h-1 && j!=w-1 && a[i+1][j+1]=='#')a[i][j]+=1;
			}
		}
	}
	for(i=0;i<h;i++){
		printf("%s\n",a[i]);
	}
	return 0;
}


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

int N, T, ans, dp[3001][6000];

int main() {
    cin >> N >> T;
    pair<int, int> p[N];
    rep(i, N) cin >> p[i].first >> p[i].second;
    
    sort(p, p + N);
    rep(i, N) {
        rep(j, T) {
            chmax(dp[i+1][j], dp[i][j]);
            chmax(dp[i+1][j + p[i].first], dp[i][j] + p[i].second);
        }
        chmax(ans, dp[i][T-1] + p[i].second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 70528
#include<bits/stdc++.h>
using namespace std;
int main(void){
    char c[1010];
    scanf("%s",c);
    int l=strlen(c);
    for(int i=0;i<l;i++)if(c[i]==67){
        for(int j=i+1;j<l;j++)if(c[j]==70){
            printf("Yes");return 0;
        }printf("No");return 0;
    }printf("No");return 0;
}

Measured memory_bytes: 256
n, k, q = list(map(int, input().split(' ')))
# 全員から1引くのではなくあらかじめ全部引いておいて正解者にだけ1点あげる(1*1e5)
points = [k-q] * n
for i in range(q):
    t = int(input())
    points[t-1] += 1
print('\n'.join(['Yes' if p > 0 else 'No' for p in points]))

Measured memory_bytes: 54232
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

//to calculate p1^x  *  p2^x2  *p3^x3 ----------
//i.e. prime factorization and store pi and xi in vector 
vector<pair<ll, ll>> pFactor;

void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        pFactor.pb({2,count}); 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            pFactor.pb({i,count});
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        pFactor.pb({n,1}); 
} 



int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    int n;
    cin>>n;
    double pi = 3.141592653589793;
    double ans = 2*pi*n;
    cout<<fixed<<setprecision(8)<<ans<<endl;
}

Measured memory_bytes: 3740
#include <iostream>

using namespace std;

int main(void)
{
    long long N, i, A[201], judge=0, ans=0;

    cin >> N;

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

    while(1){
        for(i=1; i<=N; i++){
            if(A[i] % 2 == 0){
                A[i] /= 2;
            }
            else{
                judge = 1;
            }
        }

        if(judge == 1){
            break;
        }

        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5;
const int modu = 1e9 + 7;
int H, W, A, B;
ll inv[maxn+5], c1[maxn+5], c2[maxn+5];

int main() {
	inv[1] = 1;
	for (int i = 2; i <= maxn; ++i)
		inv[i] = inv[modu % i] * (modu - modu/i) % modu;
	cin >> H >> W >> A >> B;
	ll ans = 0;
	c1[0] = 1;
	for (int i = 1; i <= H-A+B-1; ++i)
		c1[i] = c1[i-1] * (H-A+B-i) % modu * inv[i] % modu;
	c2[0] = 1;
	for (int i = 1; i <= W-B+A-1; ++i)
		c2[i] = c2[i-1] * (W-B+A-i) % modu * inv[i] % modu;
	for (int i = H-A-1, j = W-B-1; i >= 0 && j >= 0; --i, --j)
		ans = (ans + c1[H-A+B-1-i] * c2[W-B+A-1-j] % modu) % modu;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4480
import java.util.Scanner;

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

		if(a <= b * 2) {
			System.out.println(0);
		}else {
			System.out.println(a - b * 2);
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;
typedef pair<int,int> p;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x);
    ll t=exp(x,y/2);
    return (t*t);
}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll big=998244353;

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(0);
    /*--------------------------------*/
    
    int n;cin >> n;
    vector<int> a;
    rep(i,n){
        int k;cin >> k;
        if(i!=0&&k==a[(int)a.size()-1])continue;
        else a.push_back(k);
    }
    n=(int)a.size();
    if(n==1){cout << 1 << endl;return 0;}
    
    int cnt=1;
    bool pl=(a[0]<a[1]);
    //i-1とiで観測する
    rep2(i,1,n){
        if((a[i-1]<a[i]&&pl)||(a[i-1]>a[i]&&(!pl)))continue;
        cnt++;
        if(i==n-1)break;
        if(a[i]>a[i+1])pl=false;
        else pl=true;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3892
class Node
  attr_accessor :parent
  def initialize(n)
    @parent = n
  end
end

class UnionFindTree
  attr_accessor :nodes, :parents
  def initialize(n)
    @nodes = (1..n).to_a.map{|i| Node.new(i)}
  end
  def find(x)
    #ループ版
    #while @nodes[x-1].parent != x
    #  x = @nodes[x-1].parent
    #end
    #return @nodes[x-1].parent = x

    #再帰版
    return x if x == @nodes[x-1].parent
    @nodes[x-1].parent = find(@nodes[x-1].parent)
    return @nodes[x-1].parent
  end

  def union(a,b)
    return if find(a) == find(b)
    $ans -= 1
    return @nodes[find(b)-1].parent = find(a)
  end

  def parents
    @nodes.map(&:parent)
  end
end

n,m = gets.split.map(&:to_i)
tree = UnionFindTree.new(n)

$ans = n
m.times do |i|
  x,y,z = gets.split.map(&:to_i)
  tree.union(x,y)
end

p $ans


Measured memory_bytes: 10108
#!/usr/bin/env python

from sys import stdin, stderr

def main():
   A, B = map(int, stdin.readline().split())
   if 1 <= A <= 9 and 1 <= B <= 9:
      print(A*B)
   else:
      print(-1)

   return 0

if __name__ == '__main__': main()


Measured memory_bytes: 2568
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b;
    cin >> a >> b;
    if(a <= b){
        cout << a;
    }
    else
        cout << a-1;
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

constexpr double pi = acos(-1);
struct C {
  double x, y;
  C() : x(0), y(0) {}
  C(double x, double y) : x(x), y(y) {}
  C(double th) : x(cos(th)), y(sin(th)) {}
  C operator~() const { return {x, -y}; }
  C operator*(const C& r) const { return {x * r.x - y * r.y, x * r.y + y * r.x}; }
  C operator+(const C& r) const { return {x + r.x, y + r.y}; }
  C operator-(const C& r) const { return {x - r.x, y - r.y}; }
};
void fft(V<C>& a, bool inv = false) {
  int n = a.size();
  assert(__builtin_popcount(n) == 1);
  int j = 0;
  for (int i = 1; i < n; ++i) {
    int w = n >> 1;
    while (j >= w) j -= w, w >>= 1;
    j += w;
    if (i < j) swap(a[i], a[j]);
  }
  static VV<C> xi;
  for (int k = 0; 1 << k < n; ++k) if (k >= (int)xi.size()) {
    xi.emplace_back(1 << k);
    for (int i = 0; i < 1 << k; ++i) {
      xi[k][i] = C(i * pi / (1 << k));
    }
  }
  for (int k = 0; 1 << k < n; ++k) {
    const int w = 1 << k;
    for (int s = 0; s < n; s += 2 * w) {
      for (int i = s; i < s + w; ++i) {
        C p = a[i], q = a[i + w] * (inv ? ~xi[k][i - s] : xi[k][i - s]);
        a[i] = p + q, a[i + w] = p - q;
      }
    }
  }
}

int main() {
  int m, n, k, l; cin >> m >> n >> k >> l;
  int N = 1 << __lg(2 * n - 1);
  VV<C> a(N, V<C>(N));
  VV<C> b(N, V<C>(N));
  for (int i = 0; i < m; ++i) for (int j = 0; j < m; ++j) {
    char c; cin >> c;
    b[i][j].x = c == 'X';
  }
  {
    string s; cin >> s;
    int x = 0, y = 0;
    for (char c : s) {
      if (c == 'U') --x;
      if (c == 'D') ++x;
      if (c == 'L') --y;
      if (c == 'R') ++y;
      ++a[x][y].x;
    }
  }
  auto fn = [&](VV<C>& a, bool inv = false) {
    for (auto&& v : a) fft(v, inv);
    for (int j = 1; j < N; ++j) for (int i = 0; i < j; ++i) {
      swap(a[i][j], a[j][i]);
    }
    for (auto&& v : a) fft(v, inv);
    for (int j = 1; j < N; ++j) for (int i = 0; i < j; ++i) {
      swap(a[i][j], a[j][i]);
    }
    if (inv) {
      for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) {
        a[i][j].x /= N * N;
        a[i][j].y /= N * N;
      }
    }
  };

  fn(a), fn(b);
  for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) {
    a[i][j] = a[i][j] * b[i][j];
  }
  fn(a, true);
  int res = 0;
  for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) {
    res += a[i][j].x + 0.5 >= k;
  }
  cout << res << endl;
}


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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
using namespace std;

int main() {
	string s;
	cin >> s;
	if (s.size() % 2 == 0) {
		s = s.substr(0, s.size() - 2);
	}
	else {
		s = s.substr(0, s.size() - 1);
	}
	while(true) {
		if (s.substr(0, s.size() / 2) == s.substr(s.size() / 2, s.size() / 2)) {
			cout << s.size() << endl;
			return 0;
		}
		s = s.substr(0, s.size() - 2);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef vector <ll> vi;                 // Vector of long long
typedef vector <vi> vvi;                // Vector of vi
typedef vector <pair<ll,ll>> ii;        // Vector of pairs
#define ff first                        // For pairs
#define ss second                       // For pairs
#define sz(a) int((a).size())           // Function to determine size of any container
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define MAX 3005
string s, t;
ll dp[MAX][MAX];
ll parent[MAX][MAX];

ll solve(ll i, ll j)
{
    if (i < 0 || j < 0)
        return 0;
    
    if (dp[i][j] == -1)
    {
        ll ans = 0;
        if (s[i] == t[j])
            ans = max(ans, solve(i - 1, j - 1) + 1);
        
        ans = max(ans, solve(i - 1, j));
        ans = max(ans, solve(i, j - 1));

        if (s[i] == t[j] && ans == solve(i - 1, j - 1) + 1)
            parent[i][j] = -2;
        else if (ans == solve(i - 1, j))
            parent[i][j] = 1;
        else
            parent[i][j] = -1;

        dp[i][j] = ans;
    }
    return dp[i][j];
}

string ans;

void print(ll i, ll j)
{
    if (i < 0 || j < 0)
        return;
    
    if (parent[i][j] == -2)
        ans.pb(s[i]), print(i - 1, j - 1);
    else if (parent[i][j] == 1)
        print(i - 1, j);
    else
        print(i, j - 1);
}

int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    memset(dp, -1, sizeof(dp));
    cin >> s >> t;
    solve(s.size() - 1, t.size() - 1);

    print(s.size() - 1, t.size() - 1);

    for (auto it = ans.rbegin(); it != ans.rend(); it++)
        cout << *it;
    cout << "\n";
}


Measured memory_bytes: 141696
from collections import Counter

n = int(input())
def kC2(k):
  return k * (k - 1) // 2
A = list(map(int, input().split()))
AC = Counter(A)
total = sum(kC2(v) for v in AC.values())
print(*[total - kC2(AC[a]) + kC2(AC[a] - 1) for a in A], sep='\n')

Measured memory_bytes: 34052
#include <iostream>

using namespace std;

const int max_p = 1300000;
bool prime[max_p + 1];

void initial_prime()
{
    for (int i = 0; i < max_p; i++)
        prime[i] = true;
    prime[0] = prime[1] = false;

    for (int i = 2; i * i < max_p; i++)
        if (prime[i])
            for (int j = 2 * i; j <= max_p; j += i)
                prime[j] = false;
}

int main()
{
    int k;
    
    initial_prime();

    while (cin >> k, k) {
        int l, r;
        int ans = 0;

        l = r = k;
        while (!prime[l--])
            ans++;
        while (!prime[r++])
            ans++;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 2428
S = input()
S_str = str(S)
S_list = []
for i in range(len(S_str)):
    S_list.append(int(S_str[i]))
ans = ''

for i in range(2**3):
    tmp = S_list[0]
    for j in range(1,4):
        if i & (1 << 3-j):
            tmp -= S_list[j]
        else:
            tmp += S_list[j]
    if tmp == 7:
        break
for n in range(3):
    ans += S_str[n]
    if i & (1 << 2-n):
        ans += '-'
    else:
        ans += '+'
ans += S_str[-1] + '=7'
print(ans)

Measured memory_bytes: 3064
using System;

class Program
{
    static void Main(string[] args)
    {
       // 整数の入力
            int N = int.Parse(Console.ReadLine());
            if ((N + 1) / 13.5 - ((int)((N+1)/13.5))<0.04)
            {
                Console.WriteLine(":(");
                return;
            }

            int X = N - (int)(N / 13.5);
            Console.WriteLine(X);
        
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	ll n;
	cin >> n;
	string s;
	cin >> s;
	ll ans = 0;
	rep(i, n - 2) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
const ll inf = 1e18;

int n;
ll k;
vector<ll> a;

ll divceil(ll x, ll y) {
  if (x<0) return x/y;
  return (x+y-1)/y;
}

ll divfloor(ll x, ll y) {
  if (x<0) {
    return (x-y+1)/y;
  }
  return x/y;
}

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

  cin>>n>>k;
  a.resize(n);
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  sort(a.begin(), a.end());
  
  ll lo = -inf - 1; ll hi = inf;

  while (hi - lo > 1) {
    ll target = (lo+hi)/2;
    ll cnt = 0;
    
    for (int i=0; i<n; i++) {
      if (a[i] < 0) {
	if (target <= 0) continue;
	ll cur = (a.begin()+i) - std::lower_bound(a.begin(), a.begin()+i, target / a[i]);
	cnt += cur;
      } else if (a[i] == 0) {
	if (target >= 0) cnt += i;
      } else {
	ll cur = std::upper_bound(a.begin(), a.begin()+i, divfloor(target, a[i])) - a.begin();
	cnt += cur;
      }
    }

    if (cnt >= k) {
      hi = target;
    } else {
      lo = target;
    }
  }

  cout<<hi<<endl;  
  return 0;
}
// don't forget to read in the input :^)


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

long n, m;
string s, t;
map<int, char> good_string;

long gcd(long a, long b)
{
  if (b < a) {
    return gcd(b, a);
  } else if (a == 0) {
    return b;
  } else {
    return gcd(b % a, a);
  }
}

long lcm(long a, long b)
{
  return a * b / gcd(a, b);
}

void print_with_space(const string st, long index)
{
  for (int i = 0; i < index*st.size(); i++) {
    if (i % index == 0) {
      cout << st[i/index];
    } else {
      cout << ' ';
    }
  }
  cout << '\n';
}

int main()
{
  cin >> n >> m;
  cin >> s;
  cin >> t;

  long sindex = lcm(n, m) / n;
  long tindex = lcm(n, m) / m;
  for (int i = 0; i < n; i++) {
    good_string[sindex*i] = s[i];
  }
  for (int i = 0; i < m; i++) {
    auto iter = good_string.find(tindex*i);
    if (iter != good_string.end()) {
      if (iter->second != t[i]) {
        //cout << iter->first << '\n';
        //cout << iter->second << '\n';
        //cout << t[i] << '\n';
        //cout << i << '\n';
        //print_with_space(s, sindex);
        //print_with_space(t, tindex);
        cout << "-1\n";
        return 0;
      }
    }
  }
  cout << lcm(n, m) << '\n';

  return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int func(int x)
{
    if (x < 10)
    {
        return x;
    }
    return x % 10 + func(x / 10);
}
int main()
{
    int n;
  	cin>>n;
    if(n%func(n)==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	int h,w;
	cin >> h >> w;
	int n;
	cin >> n;
	int a[n];
	FOR(i,n) cin >> a[i];
	int sum[n];
	sum[0]=a[0];
	for(int i=1;i < n;i++) sum[i]=a[i]+sum[i-1];
	int k=0;
	int count=0;
	int ans[h][w];
	FOR(i,h){
		FOR(j,w){
			if(i%2==0){
				
				if(count < sum[k]) {
					ans[i][j]=k+1;
					count++;
				}
				else{
					k++;
					ans[i][j]=k+1;
					count++;
				}
			}
			else {
				if(count < sum[k]){
					ans[i][w-j-1]=k+1;
					count++;
				}
				else {
					k++;
					ans[i][w-j-1]=k+1;
					count++;
				}
			}
		}
	}
	FOR(i,h)
		FOR(j,w)
			cout << ans[i][j] <<" \n"[j==w-1];

	return 0;
}

Measured memory_bytes: 3716
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        for(int i = 0; i < String.valueOf(s).length();i++){
            if(String.valueOf(s).charAt(i) == '9'){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 22100
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {
	long long N;
	cin >> N;
	long long ans=0;
	for(int i=1; i*i<=N; i++){
		ans=i*i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <deque>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdio>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define mp make_pair
#define fname ""
#define fi first
#define se second
#define sz(a) (int)a.size()
#define pb push_back
#define fo(i,k,n) for(int i=k; (int)i<n; ++i)
#define rep(i,n,k) for(int i=n; (int)i>=k; --i)
#define all(v) v.begin(), v.end()
#define it ::iterator
#define forit(it,v) for(__typeof(v.begin()) it = v.begin(); it != v.end(); ++it)


int n;
vector<pair<pii, int>> cor1, cor2;
vector<pair<int, pii>> g;
bool u[100100];
vector<int> p(100100);

int dsu_get(int v){
    if (v== p[v])
        return v;
    return p[v] = dsu_get(p[v]);
    
}

void dsu_unit(int a, int b){
    a = dsu_get(a);
    b = dsu_get(b);
    if (rand() & 1){
        swap(a,b);
    }
    if(a!=b){
        p[a] = b;
    }
}

int main(){
    
    //freopen(fname"in", "r", stdin);
    //freopen(fname"out", "w", stdout);
    
    scanf("%d", &n);
    
    fo(i,0,n){
        int a,b;
        scanf("%d%d", &a,&b);
        a--, b--;
        cor1.pb(mp(mp(a,b), i));
        cor2.pb(mp(mp(b,a), i));
    }
    
    sort(all(cor1));
    sort(all(cor2));
    
    fo(i,0,n-1){
        g.pb(mp(cor1[i+1].fi.fi - cor1[i].fi.fi,mp(cor1[i].se, cor1[i+1].se)));
        g.pb(mp(cor2[i+1].fi.fi - cor2[i].fi.fi,mp(cor2[i].se, cor2[i+1].se)));
    }
    
    int cost = 0;
    vector<pii> res;
    
    sort(all(g));
    
    p.resize(n);
    fo(i,0,n){
        p[i] = i;
    }
    
    fo(i,0,2*(n-1)){
        int a = g[i].se.fi,  b = g[i].se.se,  l = g[i].fi;
        if (dsu_get(a) != dsu_get(b)) {
            cost += l;
            res.pb(g[i].se);
            dsu_unit(a, b);
        }
    }
    
    cout<<cost;
    
    
    return 0;
}









Measured memory_bytes: 7720
import fractions
n, m = map(int, input().split())
a = [i//2 for i in list(map(int, input().split()))]
tmp = a[0]
count = 0
while tmp % 2 == 0:
    tmp /= 2
    count += 1
for i in range(n):
    tmp = a[i]
    div = 0
    while tmp % 2 == 0:
        tmp /= 2
        div += 1
    if div != count:
        print(0)
        exit()
ans = 0
k = a[0]
for i in range(n):
    k = (k * a[i]) // (fractions.gcd(k, a[i]))
ans = m // k
ans = (ans + 1) // 2
print(ans)

Measured memory_bytes: 90080
H,W = map(int,input().split())
mat = [input() for _ in range(H)]
#print(mat)

#[mat.remove(row) for row in mat[::] if ("#" not in row)]
#print(mat)

for row in mat[::]:
  if "#" not in row:
    mat.remove(row)
#print(mat)

showCol = [i for i in range(W) if "#" in [row[i] for row in mat]]
#print(showCol)

showCol = []
#for i in range(W):
#  if "#" in [row[i] for row in mat]:
#    showCol.append(i)
for i in range(W):
  for row in mat:
    if "#" in row[i]:
      showCol.append(i)
setCol = set(showCol)
#print(setCol)

print("\n".join(["".join([row[c] for c in setCol]) for row in mat]))


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;



int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    string s;
    cin >> s;
    int n = s.size() - 1;
    ll sum = 0;
    rep (bit, 1 << n) {
        ll tmp = 0;
        rep (i, s.size()) {
            tmp *= 10;
            tmp += s[i] - '0';
            if (bit & (1 << i)) {
                sum += tmp;
                tmp = 0;
            }
        }
        sum += tmp;
    }
    cout << sum << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

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

int main() {
	int N;cin >> N;
	vector<int>dp(N + 1, INF);
	int m[] = { 1,6,9 };
	dp[0] = 0;
	rep(i, N + 1) {
		rep(j, 3) {
			int a = m[j];
			if (i < m[j])continue;
			if (j > 0) {
				while (i >= a) {
					chmin(dp[i], dp[i - a] + 1);
					a *= m[j];
				}
			}
			else chmin(dp[i], dp[i - a] + 1);
		}
	}
	cout << dp[N] << "\n";

	return 0;
}

Measured memory_bytes: 640
use std::cmp::min;

fn main() {
    let (n, m) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut it = buf.trim_end().split_whitespace();
        let n: u32 = it.next().unwrap().parse().unwrap();
        let m: usize = it.next().unwrap().parse().unwrap();
        (n, m)
    };
    let mut a: Vec<i32> = Vec::new();
    let mut b: Vec<i32> = Vec::new();
    let mut c: Vec<Vec<i32>> = Vec::new();
    for _ in 0..m {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut it = buf.trim_end().split_whitespace();
        let _a: i32 = it.next().unwrap().parse().unwrap();
        let _b: i32 = it.next().unwrap().parse().unwrap();
        a.push(_a);
        b.push(_b);

        let mut buf2 = String::new();
        std::io::stdin().read_line(&mut buf2).unwrap();
        let mut it2 = buf2.trim_end().split_whitespace();
        let _c = (0.._b)
            .map(|_| it2.next().unwrap().parse().unwrap())
            .collect::<Vec<i32>>();
        c.push(_c);
    }

    let mx = 10i32.pow(9);
    let mut dp = vec![vec![mx; 1 << n]; m + 1];
    dp[0][0] = 0;

    for i in 1..m + 1 {
        let key = c.get(i - 1).unwrap();
        let cost = a.get(i - 1).unwrap();
        let mut k = 0;
        for j in key {
            k |= 1 << (j - 1)
        }
        for j in 0..(1 << n) {
            dp[i][j | k] = min(dp[i][j | k], dp[i - 1][j] + cost);
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
        }
    }
    if dp[m][(1 << n) - 1] == mx {
        println!("{}", -1);
    } else {
        println!("{}", dp[m][(1 << n) - 1]);
    }
}

Measured memory_bytes: 18312
import sys
input = sys.stdin.readline

n = int(input())

def factorization(n):
    arr = []
    wari = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if wari%i==0:
            cnt=0
            while wari%i==0:
                cnt+=1
                wari //= i
            arr.append([i, cnt])

    if wari!= 1:
        arr.append([wari, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

m = 0

if n == 1:
    print(0)
else:
    for i in factorization(n):
        sankaku = (int((1+8*i[1])**0.5)-1) // 2
        m += sankaku   
    print(m)

Measured memory_bytes: 9428
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}



signed main(){
	ll a,b;
	cin >> a >> b;
	
	if(a < b){
		rep(i,0,b){
			cout << a;
		}
		cout << endl;
	}
	else{
		rep(i,0,a){
			cout << b;
		}
		cout << endl;
	}
	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define ll long long
#define mod 1000000007

vector<int> v[1001];

int main() {
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int n, d, an = 0; cin >> n>> d;
        for (int i = 0; i < n; i++) {
                for (int j = 0; j < d; j++) { int a; cin >> a; v[i].push_back(a); }
        }
        for (int i = 0; i < n - 1; i++) {
                for (int j = i + 1; j < n; j++) {
                        int res = 0;
                        for (int k = 0; k < d; k++) {
                                int po = v[i][k] - v[j][k];
                                po = po * po;
                                res += po;
                        }
                        int sq = sqrt(res);
                        if (sq * sq == res) an++;
                }
        }
        cout << an;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
 
int main() {
	int N,M,X,Y;
cin>>N>>M>>X>>Y;
vector<int> a;
vector<int> b;
fx(N){
	int A;
	cin>>A;
	a.push_back(A);
}
fx(M){
	int A;
	cin>>A;
	b.push_back(A);
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
if(a.at(a.size()-1)>=b.at(0)){
	ce("War")
}else{
	
	if(X<=a.at(a.size()-1)&&a.at(a.size()-1)<Y
	  &&X<b.at(0)&&b.at(0)<=Y){
	  	ce("No War")
	  }else{
	  	ce("War")
	  	
	  }
	
}
	
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n, w;
double cnt[100];

int main() {
	while (cin >> n >> w&&n + w) {
		rep(i, 100)cnt[i] = 0;
		double vmax = 0;
		rep(i, n) {
			int v;
			cin >> v;
			vmax = max(vmax, (double)v);
			cnt[v / w]++;
		}
		double cntmax = 0;
		vmax /= w;
		vmax = (int)(vmax);
		rep(i, 100 / w + 1) {
			cntmax = max(cntmax, double(cnt[i]));
		}
		double ans = 0;
		rep(i, 100 / w + 1) {
			ans += (vmax - i)*(cnt[i]) / (vmax*cntmax);
		}
		cout << ans + 0.01 << endl;
	}
}

Measured memory_bytes: 3280
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    if(n == 1)
        cout << "Hello World" << endl;
    else
        cout << (a + b) << endl;

    return 0;
}


Measured memory_bytes: 256
let memoize n f =
  let dp = Hashtbl.create n in
  let rec get x =
    try Hashtbl.find dp x with
    | Not_found ->
        let result = f get x in
        Hashtbl.add dp x result;
        result in
  get

let rec take n = function
  | [] -> []
  | x :: xs ->
      if n = 0 then []
      else x :: take (n - 1) xs

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init (1 lsl n) @@ fun _ ->
    Scanf.scanf "%d " @@ fun a -> a in
  let dp = Array.init (1 lsl n) (fun i -> [i]) in
  for i = 0 to (1 lsl n) - 1 do
    for j = 0 to n - 1 do
      if 0 < i land (1 lsl j) then
        dp.(i) <-
          take 2 @@
          List.sort (fun i j -> compare as_.(j) as_.(i)) @@
          List.sort_uniq compare @@
          dp.(i) @ dp.(i land (lnot (1 lsl j)))
    done
  done;
  let a = Array.map (fun is ->
    List.fold_left ( + ) 0 @@
    List.map (Array.get as_) is) dp in
  for i = 1 to (1 lsl n) - 1 do
    a.(i) <- max a.(i) a.(i - 1);
    Printf.printf "%d\n" a.(i)
  done


Measured memory_bytes: 31360
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<llint>&ar,llint in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<llint>&ar,llint in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint n,i,k;cin>>n>>k;
	string str;cin>>str;
	deque<char>s;
	for(auto it:str){s.pub(it);}
	if(n%2){if(s[0]=='A'){k--;}s.pof();}
	while(s.size()>0&&k>6){
		if(n%2==1){
				 if(s[0]=='A'&&s[1]=='A'){s.pof();s.pof();k-=3;}
			else if(s[0]=='A'&&s[1]=='B'){s.pof();s.pof();k-=2;}
			else if(s[0]=='B'&&s[1]=='A'){s.pof();s.pof();k-=4;}
			else if(s[0]=='B'&&s[1]=='B'){s.pof();s.pof();k-=3;}
		}else{
				 if(s[0]=='A'&&s[1]=='A'){s.pof();s.pof();k-=3;}
			else if(s[0]=='A'&&s[1]=='B'){s.pof();s.pof();k-=4;}
			else if(s[0]=='B'&&s[1]=='A'){s.pof();s.pof();k-=2;}
			else if(s[0]=='B'&&s[1]=='B'){s.pof();s.pof();k-=3;}
		}
	}
	if(s.size()==0){
		if(n%2==1&&k%2==0){cout<<'B';}
		if(n%2==1&&k%2==1){cout<<'A';}
		for(i=1;i<n;i+=2){cout<<"BA";}
		cout<<endl;return 0;
	}
	if(n%2==1){s.puf('B');}
	while(s.size()<n){s.pub('B');s.pub('A');}
	while(k--){
		int mae=1,bas=0;
		while(0<=bas&&bas<n){
			if(s[bas]=='A'){
				mae=-mae;
				s[bas]='B';
				bas+=mae;
			}else{
				s[bas]='A';
				bas+=mae;
			}
		}
		
	}
	for(auto it:s){cout<<it;}cout<<endl;
	//ない ある
	//AA 3 3
	//BA 2 4
	//BB 3 3
	//AB 4 2
	return 0;
}

Measured memory_bytes: 900
n = int(input())
a = list(map(int,input().split()))
q = int(input())
m = list(map(int,input().split()))

def solve(i,m):
    if m == 0:
        return True
    if i >= n:
        return False
    res = solve(i+1,m) or solve(i+1,m-a[i])
    return res

for m_tmp in m:
    if sum(a) < m_tmp:
        print('no')
    elif solve(0,m_tmp):
        print('yes')
    else:
        print('no')

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

namespace Atc_0028
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            int A = int.Parse(str.Split(' ')[0]);

            int P = int.Parse(str.Split(' ')[1]);

            Console.WriteLine((A * 3 + P) / 2);
        }
    }
}


Measured memory_bytes: 27412
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        int[] sortX = new int[N];
        for(int i = 0; i < N; i++){
            X[i] = sc.nextInt();
            sortX[i] = X[i];
        }
        Arrays.sort(sortX);
        int a = sortX[N/2 -1];
        int b = sortX[N/2];
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < N; i++){
            if(X[i] <= a) sb.append(b + "\n");
            else sb.append(a + "\n");
        }
        System.out.print(sb.toString());
        sc.close();

    }

}


Measured memory_bytes: 95720
#include <bits/stdc++.h>
#define R cin>>
#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 INF 1e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long unsigned int ll;
int main(){
    int n;
    scanf("%d", &n);
    vector<int>a(n+2);
    a[0] = 0;
    a[n+1] = 0;
    FOR(i, 1, n+1) scanf("%d", &a[i]);
    int S=0, ans;
    rep(i, n+1) {
        S += abs(a[i]-a[i+1]);
    }
    rep(i, n) {
        ans = S + abs(a[i]-a[i+2]) - abs(a[i+1]-a[i+2]) - abs(a[i+1]-a[i]);
        printf("%d\n", ans);
    }
    
    return 0;
}


Measured memory_bytes: 1664