akhauriyash/Code-Regression huggingface dataset:
/*
    AUTHOR : TANMAY SINHA
    INORMATION TECHNOLOGY
    BIT MESRA ,RANCHI
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define rep(j,L,R) for(j=L;j<R;j++)
#define per(i,L,R) for(i=L;i>= R;i--)
#define all(con) (con).begin(),(con).end()
#define fi first
#define se second
#define foreach(iter,con) for(auto iter=(con).begin(); iter!=(con).end(); iter++)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
const ll INF = 1e18l+10,N = 1e5+10,MAX = 1e6+5;

int main()
{
   SPEED
   ll i,j,n;
   string t;
   cin>>n>>t;
   if(n%2==1)
   {
       cout<<"No\n";
       return 0;
   }
   ll f =1;
   for(i=0,j=n/2;i<n/2;i++,j++)
   {
       if(t[i]!=t[j])
       {
           f = 0;
           break;
       }
   }
   if(!f)
    cout<<"No\n";
   else
    cout<<"Yes\n";
}



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

int max(int x, int y);
int min(int x, int y);
int gcd(int x, int y);	/*最大公約数*/
int lcm(int x, int y);	/*最小公倍数*/
void swap(int* x, int* y);	/*値の交換*/
void downsort(int* a, int n);	/*降順ソート*/
void upsort(int* a, int n);	/*昇順ソート*/

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*/

/*ここからmain関数*/

int main()
{
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;

	if (e - a <= k)
		cout << "Yay!";
	else
		cout << ":(";

	return 0;
}

/*2数の大きい方を返す*/
int max(int x, int y)
{
	int max;

	if (x < y)
		max = y;
	else
		max = x;

	return max;
}

/*2数の小さい方を返す*/
int min(int x, int y)
{
	int min;

	if (x < y)
		min = x;
	else
		min = y;

	return min;
}

/*2数の最大公約数を返す*/
int gcd(int x, int y)
{
	int m;
	int gcd = 1;

	m = min(x, y);

	for (int i = 1;i <= m; i++)
	{
		if (x%i == 0 && y%i == 0)
			gcd = i;
	}

	return gcd;
}

/*2数の最小公倍数を返す*/
int lcm(int x, int y)
{
	int m;

	for (int i = 1;i <= y;i++)
	{
		if ((x*i) % y == 0) {
			m = x * i;
			break;
		}
	}

	return m;
}

/*2数の値を交換する*/
void swap(int* px, int* py)
{
	int temp;

	temp = *px;
	*px = *py;
	*py = temp;
}

/*クイックソートによる降順並べ替え*/
void downsort(int* a, int n)
{
	//初期設定
	int l = 0, r = n - 1;

	// ピボットの決定
	int piv = *a;

	//ピボットより大を左に、ピボット以下を右に
	while (l < r)
	{
		if (*(a + l) > piv)
			l++;
		else if (*(a + r) <= piv)
			r--;
		else
			swap(a + l, a + r);
	}

	//再帰処理
	if (n == 2)
		return;
	else if (l == 1 || l == 0)
		downsort(a + 1, n - 1);
	else if (r == n - 1)
		downsort(a, n - 1);
	else
	{
		downsort(a, l);
		downsort(a + l, n - l);
	}
}

/*クイックソートによる昇順ソート*/
void upsort(int* a, int n)
{
	downsort(a, n);

	for (int i = 0;i < n / 2;i++)
		swap(a[i], a[n - 1 - i]);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
using namespace std;


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

	int ans = 1;
	int pos = 0;
	int l;
	for(int i=0;i<n;i++){
		cin >> l;
		pos += l;
		if(pos <= x)
			ans++;
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  string s;cin>>s;
  
  
  if(s[0]==s[1]){
    cout<<"Bad";
    return 0;
  }
  if(s[1]==s[2]){
    cout<<"Bad";
    return 0;
  }
  if(s[2]==s[3]){
    cout<<"Bad";
    return 0;
  }
  cout << "Good";
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const ll INF = 10e16;
const int maxN = 500010;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1000000007;

int a[maxN]; 
int main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	int n = 1e5;
	int ans = -1;
	for(int i=n;i>=1;i--)
	{
		double p = i * 1.0;
		if((int)(p*0.08) == x && (int)(p*0.1) == y)
		{
			ans = i;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,k;
  cin>>n>>k;
  int h[n],dp[n];
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  for(int i=0; i<n; i++){ dp[i]=INT_MAX; }
  dp[0]=0;
  for(int i=0; i<n; i++){
    for(int j=1; j<k+1 && i+j<n; j++){
      dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
    }
  }
  cout<<dp[n-1];
}


Measured memory_bytes: 1024
a, b = map(int, input().split())
s = input()
for i in range(a):
    if s[i] == '-':
        print('No')
        exit()
if s[a] != '-':
    print('No')
    exit()
for i in range(a+1, a+b+1):
    if s[i] == '-':
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#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--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c ;
  cin >> a >> b >> c ;
  if(max({a,b,c})==a+b+c-max({a,b,c})-min({a,b,c}) || min({a,b,c})==a+b+c-max({a,b,c})-min({a,b,c})){
    if(max({a,b,c})!=min({a,b,c})){
      yes() ;
    }
    else{
      no() ;
    }
  }
  else{
    no() ;
  }
  
  
  
  return 0 ;
}




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

int FreeDay(int N){
    int M; cin >> M;
    int A[M]={};
    int HWday=0;
    for(int i=0;i<M;i++){
        cin >> A[i];
        HWday+=A[i];
    }
    if(N-HWday<0){
        return -1;
    }
    else{
        return N-HWday;
    }
}

int main(){
    int N; cin >> N;
    cout << FreeDay(N) << endl;
    return 0;
}

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

int visited[100005];

void DFSUtil(vector<int> v[], int i){
    visited[i] = 1;

    for (int j = 0; j < v[i].size(); j++)
    {
        if (visited[v[i][j]] == 0){
            DFSUtil(v, v[i][j]);
        }
    }


    
}

int main(){
    
    int n, m, ans = 0;

    cin >> n >> m;

    vector<int> v[n];

    for (int i = 0; i < m; i++){
        int l, r;

        cin >> l >> r;

        v[l-1].push_back(r-1);
        v[r-1].push_back(l-1);
    }


    for (int i = 0; i < n; i++) 
    { 
        if (visited[i] == 0) 
        { 
            DFSUtil(v, i); 
  
            ans++; 
        } 
    } 

    cout << ans - 1 << endl;

    return 0;
}


Measured memory_bytes: 10404
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a[256];
	a['A']='A';
	a['B']='B';
	a['C']='C';
	char A,B,C;
	while(cin>>A>>B>>C)
		swap(a[A],a[C]);
	for(int i=0;i<256;i++)
		if(a[i]=='A')
			cout<<(char)i<<endl;
}

Measured memory_bytes: 1132
#include <cassert>
#include "limits.h"
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;



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

  ll n;
  std::cin>>n;

  std::vector<std::vector<ll>> graph(n);

  rep(i,0,n-1){
    ll a,b;
    std::cin>>a>>b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  ll root=-1;
  rep(i,0,n){
    if(graph[i].size()>2){
      root=i;
      break;
    }
  }

  if(root==-1){
    std::cout<<1<<"\n";
    return 0;
  }

  std::vector<std::vector<ll>> dp(n,std::vector<ll>(2,0));

  std::function<void(ll,ll)> f=[&](ll now,ll par){
    ll cnt=0;
    for(ll next:graph[now]){
      if(next!=par){
        f(next,now);
        cnt++;
      }
    }

    if(cnt==0){
      dp[now][0]=0;
      dp[now][1]=1;
    }else if(cnt==1){
      for(ll next:graph[now]){
        if(next!=par){
          dp[now][0]=dp[next][0];
          dp[now][1]=std::max(dp[next][0],1ll);
        }
      }
    }else{
      ll max=0;
      ll sum=0;
      for(ll next:graph[now]){
        if(next!=par){
          chmax(max,dp[next][1]-dp[next][0]);
          sum+=dp[next][1];
        }
      }
      dp[now][1]=sum-max;
      dp[now][0]=sum-max;
    }
  };

  f(root,-1);

  std::cout<<dp[root][1]<<"\n";

  return 0;
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> even;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 0) even.push_back(a[i]);
  }

  int size = even.size();
  if (size == 0) {
    cout << 0 << endl;
    return 0;
  }

  for (int i = 0; i < even.size(); i++) {
    while (even[i] % 2 == 0) {
      even[i] /= 2;
      cnt++;
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 512
import math

a, b, x = map(int, input().split())

s = x / a

if s == a * b:
    print(0)
else:
    if s > b * a / 2:
        bu = 2 * s / a - b
        s -= a * bu
        b -= bu
        a2 = 2 * s / b
    else:
        a2 = 2 * s / b

    rad = math.atan(b/a2)
    print(rad*(180/math.pi))

Measured memory_bytes: 38384
#include <stdio.h>
#include <stdlib.h>

static int cards[200000];
static struct change_tag{
  int b;
  int c;
} changes[100000];

static int compar(const void* a, const void* b)
{
  const int* aa = a;
  const int* bb = b;
  return *bb - *aa;
}

static int compar_chg(const void* a, const void* b)
{
  const struct change_tag* aa = a;
  const struct change_tag* bb = b;
  return bb->c - aa->c;
}

int main(int argc, char** argv)
{
  int n,m,count;
  unsigned long long sum = 0;
  scanf("%d %d", &n, &m);
  for(int i=0;i<n;++i){
    scanf("%d", cards+i);
  }
  for(int i=0;i<m;++i){
    scanf("%d %d", &changes[i].b, &changes[i].c);
  }
  qsort(changes,m,sizeof(*changes),compar_chg);
  
  count=0;
  for(int i=0;i<m;++i){
    for(int j=0;j<changes[i].b;++j){
      if(count < n){
	    cards[n+(count++)]=changes[i].c;
      } else {
        break;
      }
    }
  }
  qsort(cards,n+count,sizeof(*cards),compar);
  for(int i=0;i<n;++i){
    sum+=cards[i];
  }
  printf("%llu\n", sum);
  return 0;
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll N;
vector<ll> A, B;

int main(int argc, char **argv)
{
	cin >> N;
	A.resize(N);
	REP(i, N) cin >> A[i];
	B = A;
	sort(ALL(B));

	map<ll, ll> m;
	REP(i, N)
		m[B[i]] = i;

	ll res{0};
	REP(i, N)
	{
		if (i % 2 != m[A[i]] % 2) 
			++res;
	}

	std::cout << res/2 << std::endl;
}


Measured memory_bytes: 8064
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<pair<int, int> > VPII;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL N, M;
	cin >> N;
	VL D, T;
	FOR(i, 0, N) {
		D.push_back(IN<LL>());
	}
	cin >> M;
	FOR(i, 0, M) {
		T.push_back(IN<LL>());
	}
	sort(D.begin(), D.end());
	sort(T.begin(), T.end());
	auto Ditr = D.begin();
	auto Titr = T.begin();

	while (Ditr != D.end() && Titr != T.end()) {
		if (*Titr == *Ditr) {
			Titr++;
			Ditr++;
		}
		else {
			Ditr++;
		}
	}

	if (Titr == T.end()) {
		O("YES");
	}
	else {
		O("NO");
	}

	return 0;
}


Measured memory_bytes: 4848
n,a,b,*v=map(int,open(0).read().split())
v=[0]+v
dp=[[[0,1]]+[[0,0]for j in range(b)]for i in range(n+1)]
for i in range(1,n+1):
  for j in range(1,b+1):
    if dp[i-1][j-1][0]+v[i]>dp[i-1][j][0]:
      dp[i][j]=[dp[i-1][j-1][0]+v[i],dp[i-1][j-1][1]]
    elif dp[i-1][j-1][0]+v[i]==dp[i-1][j][0]:
      dp[i][j]=[dp[i-1][j][0],dp[i-1][j][1]+dp[i-1][j-1][1]]
    else:
      dp[i][j]=[dp[i-1][j][0],dp[i-1][j][1]]
m=0
for i in range(a,b+1):
  m=max(m,dp[-1][i][0]/i)
print(m,sum(dp[-1][i][1]*(dp[-1][i][0]/i==m)for i in range(a,b+1)),sep='\n')

Measured memory_bytes: 40176
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int N = Integer.parseInt( br.readLine() );
        String[] strH = br.readLine().split(" ");
        int[] H = Stream.of(strH).mapToInt(Integer::parseInt).toArray();
        
        boolean isOK = true;
        for(int i = N - 1; i > 0; i--){
            if(H[i-1] - 1 > H[i]){
                isOK = false;
                break;
            } else if ( H[i-1] - 1 == H[i] ){
                H[i-1]--;
            }
        }
        
        System.out.println( isOK ? "Yes" : "No" );
    }
}


Measured memory_bytes: 47700
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const int MAX = 10000010;
bool IsPrime[MAX];
int MinFactor[MAX];
vector<int> preprocess(int n = MAX) {
    vector<int> res;
    for (int i = 0; i < n; ++i) IsPrime[i] = true, MinFactor[i] = -1;
    IsPrime[0] = false; IsPrime[1] = false; 
    MinFactor[0] = 0; MinFactor[1] = 1;
    for (int i = 2; i < n; ++i) {
        if (IsPrime[i]) {
            MinFactor[i] = i;
            res.push_back(i);
            for (int j = i*2; j < n; j += i) {
                IsPrime[j] = false;
                if (MinFactor[j] == -1) MinFactor[j] = i;
            }
        }
    }
    return res;
}

vector<pair<int,int> > prime_factor(int n) {
    vector<pair<int,int> > res;
    while (n != 1) {
        int prime = MinFactor[n];
        int exp = 0;
        while (MinFactor[n] == prime) {
            ++exp;
            n /= prime;
        }
        res.push_back(make_pair(prime, exp));
    }
    return res;
}
int main(){ 
  int n;
  cin >> n;
  ll res = 0;
  preprocess();
  for (int x = 1; x <= n; x++) {
    auto pf = prime_factor(x);
    ll tmp = 1;
    for (auto p : pf) {
      tmp *= (p.second + 1);
    }
    res += tmp * x;
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 56276
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    struct Player : IComparable
    {
        internal int id, stok;

        public int CompareTo(object obj)
        {
            Player other = (Player)obj;

            if (stok == other.stok)
            {
                return other.id - id;
            }
            return stok - other.stok;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string[] input = Console.ReadLine().Split(' ');
            int q = int.Parse(input[1]);

            PriorityQueue<Player> pq = new PriorityQueue<Player>();
            int[] memo = new int[1000001];

            for (int i = 0; i < q; i++)
            {
                input = Console.ReadLine().Split(' ');
                int a = int.Parse(input[0]);
                int v = int.Parse(input[1]);

                memo[a] += v;

                Player temp;
                temp.id = a;
                temp.stok = memo[a];

                pq.Enqueue(temp);

                while (true)
                {
                    temp = pq.Peek();

                    if (memo[temp.id] != temp.stok)
                    {
                        pq.Dequeue();
                    }
                    else
                    {
                        sb.AppendLine(temp.id + " " + temp.stok);
                        break;
                    }
                }
            }
            Console.Write(sb);
        }
    }

    class PriorityQueue<T> where T : IComparable
    {
        List<T> heap;
        int size;

        public PriorityQueue()
        {
            heap = new List<T>();
        }

        public void Enqueue(T x)
        {
            heap.Add(x);
            int i = size++;

            while (i > 0)
            {
                int p = (i - 1) / 2;

                if (Compare(heap[p], x) <= 0) break;

                heap[i] = heap[p];
                i = p;
            }
            heap[i] = x;
        }

        public T Dequeue()
        {
            T ret = heap[0];
            T x = heap[--size];

            int i = 0;
            while (i * 2 + 1 < size)
            {
                int a = i * 2 + 1;
                int b = i * 2 + 2;

                if (b < size && Compare(heap[b], heap[a]) < 0)
                    a = b;
                if (Compare(heap[a], x) >= 0)
                    break;

                heap[i] = heap[a];
                i = a;
            }
            heap[i] = x;
            heap.RemoveAt(size);
            return ret;
        }

        public T Peek()
        {
            return heap[0];
        }

        public int Count()
        {
            return size;
        }

        private int Compare(T x, T y)
        {
            return y.CompareTo(x);
        }
    }
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;


int main(){
  int n; cin >> n;
  vector<int> a(n); rep(i,n) cin >> a[i];
  vector<int> dp(n, 0);
  dp[0] = 3;

  ll ans = 1;
  rep(i,n){
    ans = ans*dp[a[i]] % MOD;
    dp[a[i]+1]++;
    dp[a[i]]--;
  }

  cout << ans << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<set<int>> graph(N+1);
    for (int i = 0; i < N-1; ++i) {
        int a, b;
        cin >> a >> b;
        graph[a].insert(b);
        graph[b].insert(a);
    }
    vector<int>c(N);
    for (int i = 0; i < N; ++i) {
        cin >> c[i];
    }

    sort(c.begin(), c.end());
    queue<int> que;
    for (int i = 1; i <= N; ++i) {
        if(graph[i].size() == 1) que.push(i);
    }

    ll M = 0;
    int count = 0;
    vector<int>ans(N+1, -1);
    while (! que.empty()){
        int top = que.front();
        que.pop();
        ans[top] = c[count];
        count++;
        M += ans[top];
        int target = *graph[top].begin();
        graph[target].erase(top);
        if(graph[target].size() == 1){
            que.push(target);
        }
    }

    M -= c[N-1];
    cout << M << "\n";
    for (int i = 1; i <= N; ++i) {
        cout << ans[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 1792
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec_char() -> Vec<char> {
    read::<String>().chars().collect()
}

fn main() {
    let mut s = read_vec_char();
    let mut t = read_vec_char();
    s.sort();
    t.sort_by(|a,b| b.cmp(a));
    println!("{}",if s < t { "Yes" } else { "No" });
}


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

using namespace std;

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

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

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

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

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

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

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

int main() {

    int n;
    cin >> n;
    vector<ll> c(n, 0);
    vector<ll> d(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        --a;
        c[a]++;
        d[c[a]]++;
    }
    
    vector<ll> s(n + 1, 0);
    for (int i = 1; i < n + 1; ++i) s[i] = s[i - 1] + d[i];

    for (ll k = 1; k <= n; ++k) {
        ll floor = 0, ceil = n + 1;
        while (ceil - floor > 1) {
            ll x = (floor + ceil) / 2;
            if (s[x] >= k * x) floor = x;
            else ceil = x;
        }
        cout << floor << endl;
    }
}

Measured memory_bytes: 10324
#include <bits/stdc++.h>
using namespace std;
constexpr int CONTEST_NUM=26;

int score_function(const vector<int> &t,const vector<vector<int>> &s,const vector<int> &c,const int &d){
    vector<int> last(27);
    int manzoku=0;
    for(int i=1;i<=d;i++){
        manzoku+=s[i][t[i]];
        last[t[i]]=i;
        int sum=0;
        for(int j=1;j<=CONTEST_NUM;j++){
            sum+=c[j]*(i-last[j]);
        }
        manzoku-=sum;
    }
    return manzoku;
}

void set_ans(const vector<int> &t,vector<int> &ans,const int &d){
    for(int i=1;i<=d;i++){
        ans[i]=t[i];
    }
}

int main() {
    int d;cin>>d;
    vector<int> c(27);
    for(int i=1;i<=CONTEST_NUM;i++){
        cin>>c[i];
    }
    vector<vector<int>> s(d+1,vector<int>(27));
    for(int i=1;i<=d;i++){
        for(int j=1;j<=CONTEST_NUM;j++){
            cin>>s[i][j];
        }
    }
    vector<int> t(d+1);
    vector<int> ans(d+1);
    int old_ans=-1000000000;
    std::random_device rnd;
    std::mt19937 mt(rnd());
    std::uniform_int_distribution<> rand26(1,26);
    std::uniform_int_distribution<> randd(1,d);

    for(int i=1;i<=d;i++){
        int max_contest=-1;
        for(int j=1;j<=CONTEST_NUM;j++){
            if(max_contest<s[i][j]){
                max_contest=s[i][j];
                t[i]=j;
            }
        }
    }
    int k=0;
    while(k<105000){
        int che1=randd(mt);
        int che2=randd(mt);
        int che3=randd(mt);
        int old_f=t[che1];
        int old_g=t[che2];
        int old_h=t[che3];
        t[che1]=rand26(mt);
        t[che2]=rand26(mt);
        t[che3]=rand26(mt);
        int tmp=score_function(t,s,c,d);
        if(tmp>old_ans){
            old_ans=tmp;
        }
        else{
            t[che1]=old_f;
            t[che2]=old_g;
            t[che3]=old_h;
        }
        k++;
    }
    //cout<<old_ans<<endl;
    for(int i=1;i<=d;i++){
        cout<<t[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3700
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap as IM
main=print.solve.unfoldr(B.readInt.B.dropWhile isSpace)=<<B.getContents
solve(n:as)=fst$foldl f(1,IM.singleton(-1)3)as
f(k,m)a=(k*max(g(a-1)m-g a m)0`mod`(10^9+7),IM.insertWith(+)a 1 m)
g=IM.findWithDefault 0

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



int main(){
    int n;
    cin >> n;
    vector<int> p,q;
    rep(i,n){
        int a;
        cin >> a;
        p.push_back(a);
    }
    rep(i,n){
        int a;
        cin >> a;
        q.push_back(a);
    }
    vector<int> v;
    rep(i,n) v.push_back(i+1);

    int count = 0;
    int num_p=0;
    int num_q=0;
    
    do{
        int flag_p = 0;
        int flag_q = 0;
        rep(i,n){
            if(v[i]==p[i]) flag_p++;
            if(v[i]==q[i]) flag_q++;
            //cout << v[i] << " ";
        }
        //cout << endl;
        if(flag_p==n) num_p = count;
        if(flag_q==n) num_q = count;
        count++;
    }
    while(next_permutation(v.begin(),v.end()));
    cout << abs(num_p-num_q) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn = 200010;
const int mod = 1e9+7;
typedef long long ll;

int n, c[maxn];

int qpow(int x, int y) {
	int ret = 1;
	while (y) {
		if (y & 1)
			ret = 1ll*ret*x%mod;
		x = 1ll*x*x%mod;
		y >>= 1;
	}
	return ret;
}

int dp[maxn], sum[maxn];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &c[i]);
		if (i > 1 && c[i] == c[i-1]) {
			-- i;
			-- n;
		}
	}
	sum[c[1]] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i] = sum[c[i]];
		sum[c[i+1]] = (sum[c[i+1]]+dp[i])%mod;
	}
	printf("%d\n", dp[n]);
	return 0;
}

Measured memory_bytes: 2560
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,t = list(map(int, input().split()))
ab = [None]*n
for i in range(n):
    ab[i] = tuple(map(int, input().split()))
ab.sort()
dp = [[0]*(t) for _ in range(n)]
for i in range(1, n):
    a,b = ab[i-1]
    for j in range(t-1, 0, -1):
        dp[i][j] = dp[i-1][j]
        if j>=a and dp[i][j]<dp[i-1][j-a]+b:
            dp[i][j] = dp[i-1][j-a]+b
ans = max((dp[i][t-1] + ab[i][1]) for i in range(n))
print(ans)

Measured memory_bytes: 139064
//
//  main.cpp
//  test130
//
//  Created by  on 2019/06/16.
//  Copyright © 2 All rights reserved.
//
//
//  main.cpp
//  new
//
//  Created on 2019/06/09.
//  Copyright  All rights reserved.
//

// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#define int long long
using namespace std;

int n,ans,m;

signed main(){
    cin>>n;
    int p=sqrt(n);
    for(int i=p+1;i>=1;i--)if(n%i==0){m=i;break;}
    ans=m-1+(n/m)-1;
    
    cout<<ans<<endl;
    
}






Measured memory_bytes: 256
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
		
const double eps = 1e-9;																							   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

double tab[100005];


///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    double n, x;
    cin >> n >> x;
	for(int i = 0; i < n; i++){
		cin >> tab[i];
	}
    
    list<int> res;
    for(int i = 0; i < n; i++){
		res.pb(abs(tab[i] - x));
	}
	
	int ans = *res.begin();
	//cout << "starting ans: " << ans << endl;
	res.pop_front();
	for(auto it : res){
		ans = __gcd(ans, it);
	}
    
    cout << ans << endl;
    
    
    
    
    
    
    
    
 
	return 0;
}


Measured memory_bytes: 4224
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
const long double PI = acos(-1);
const long long INF = 1e15;
const ll DEP = (1LL << 50);
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
template<class T> bool chmax(T& a,T b){ if(a < b) {a = b; return true;} return false;}
template<class T> bool chmin(T& a,T b){ if(a > b) {a = b; return true;} return false;}
template<typename T>
T GCD(T x,T y){
    return y ? GCD(y,x%y) : x;
}
template<typename T>
string toString( const T &a ){
    ostringstream oss;
    oss << a;
    return oss.str();
};


/* 
*/
int main(){
    int N,L; cin >> N >> L;
    int sum = 0;
    for(int i = 1; i <= N; i++){
        sum += L+i-1;
    }
    int check = sum;
    int mn = MM;
    int ans = 0;
    for(int i = 1; i <= N; i++){
        int tmp = L+i-1;
        check -= tmp;
        if(abs(check-sum) < mn){
            mn = abs(check-sum);
            ans = check;
        }
        check += tmp;
    }
    cout << ans << endl;
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//Write From this Line

int main()
{
	int n;
	cin >> n;
	map<string,int> money ;
	rep(i,n){
		string s ;
		cin >> s ;
		money[s] ++;
	}
	int m ;
	cin >> m ;
	rep(i,m){
		string s ;
		cin >> s ;
		money[s] --;
	}
	int ans =  0 ;
	for(auto x : money){
		chmax(ans,x.second);
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int D = sc.nextInt();
    int X = sc.nextInt();
    int cnt =0;
    for(int i=0; i<N; i++){
      int A = sc.nextInt();
      for(int j=0; j<100; j++){
        if (j * A + 1 <= D){
          cnt++;
        }else{
          break;
        }
      }
    }
    System.out.println(cnt+X);
  }
}
    
    

Measured memory_bytes: 35924
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
	long long int N, K, x;

	cin >> N >> K;

	x = N % K;

	if (x == 0) {
		cout << 0;
	}
	else if (K - x >= x) {
		cout << x;
	}
	else {
		cout << K - x;
	}
	return 0;
}


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

const int MAXN = 1e5 + 5;
vector<int> adj[MAXN];
bool mark[MAXN];
int dp[MAXN];
int n, m, ans;

void input();
void dfs(int);
void solve();

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	input();
	solve();
	return 0;
}

void input() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
	}
}

void dfs(int u) {
	mark[u] = true;
	for (auto v: adj[u]) {
		if (!mark[v])
			dfs(v);
		dp[u] = max(dp[u], dp[v] + 1);
	}
	ans = max(ans, dp[u]);
}

void solve() {
	for (int i = 0; i < n; i++)
		if (!mark[i])
			dfs(i);
	cout << ans;
}


Measured memory_bytes: 8320
program sample
implicit none

integer(8) :: N, K, i, sum, m, j
integer(8), allocatable:: p(:)

read(*,*) N, K
allocate(p(N))
read(*,*) p

do j = 1, N-1
do i = 1, N-1
if(p(i) > p(i+1))then
m=p(i)
p(i)=p(i+1)
p(i+1)=m
end if
end do
end do


sum = 0
do i = 1, K
sum = sum + p(i)
end do

write(*,*) sum


deallocate(p)
stop

end program sample

Measured memory_bytes: 2884
n = gets.to_i
as = gets.split.map(&:to_i)

ans = as.inject(:+)
counts = as.each_with_object(Hash.new(0)) { |a, h| h[a] += 1 }

q = gets.to_i
q.times do
  b, c = gets.split.map(&:to_i)
  ans = ans - b * counts[b] + c * counts[b]
  counts[c] += counts[b]
  counts[b] = 0

  puts ans
end


Measured memory_bytes: 25844
n = int(input())
l = list(map(int, input().split()))
mod = 10**9+7
if n % 2 == 0 and len(set(l)) == n//2:
  print(2**(n//2)%mod)
elif not n % 2 == 0 and l.count(0) == 1:
  print(2**((n-1)//2)%mod)
else:
  print(0)

Measured memory_bytes: 14008
# coding: utf-8
import numpy as np
n,d = map(int, input().split())
X = [list(map(int,list(input().split()))) for i in range(n)]
X = np.array(X)
#print(n,d)
#print(X)
count = 0

for i in range(n-1):
    for j in range(i+1,n):
        ans = np.sqrt(np.sum(np.square(X[i]-X[j])))
        #print(X[i]-X[j])
        #print(np.square(X[i]-X[j]))
        #print(ans,ans.is_integer())
        if ans.is_integer():
            count += 1
print(count)
        


Measured memory_bytes: 12484
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	LL n; cin >> n;
	vector<LL> a(n);

	LL mx = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		mx = max(mx, a[i]);
	}

	LL t = 1;
	LL cnt = 0;
	while (mx > t) {
		cnt++;
		t *= 2;
	}
	
	vector<LL> tb(cnt);

	for (LL i = 0; i < n; i++) {
		for (LL j = 0; j < cnt; j++) {
			if (a[i] & (1LL << j)) {
				tb[j]++;
			}
		}

	}

	LL ans = 0;
	for (LL i = 0; i < n - 1; i++) {
		for (LL j = 0; j < cnt; j++) {
			if (a[i] & (1LL << j)) {
				tb[j]--;
			}
		}

		for (LL j = 0; j < cnt; j++) {
			if (a[i] & (1LL << j)) {
				LL x = n - (i + 1) - tb[j];
				
				x *= (1LL << j)%MOD;
				ans += x;
				ans %= MOD;
			}
			else {
				LL x = tb[j];
				
				x *= (1LL << j) % MOD;
				ans += x;
				ans %= MOD;
			}
		}

	}

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


Measured memory_bytes: 2560
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();
	int c = scan.nextInt();

	int flag = -1;
	for(int i = 1; i <= 100; i++){
	    if(a*i%b==c){
		flag = 1;
		break;
	    }
	}

	/* 出力 */
	if(flag == 1){
	    System.out.println("YES");
	}else{
	    System.out.println("NO");
	}
    }
}


Measured memory_bytes: 23508
#include<iostream>
using namespace std;
int a[3001];
long long dp[3001][3001];
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int len=1;len<=n;len++)
		for(int i=1;i<=n;i++)
		{
			int j=i+len-1;
			if(j>n)continue;
			if(len==1)dp[i][j]=a[i];
			else dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
		}
	cout<<dp[1][n];
	return 0;
}

Measured memory_bytes: 49732
n = int(input())
s =[input() for _ in range(n)]
ac = s.count('AC')
wa = s.count('WA')
tle = s.count('TLE')
re = s.count('RE')

print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))

Measured memory_bytes: 16164
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[int(input()) for i in range(n)]
    biggest = max(l)
    lsort=sorted(l)
    niban=lsort[-2]
    for j in range(n):
        if l[j]!=biggest:
            print(biggest)
        else:
            print(niban)
resolve()

Measured memory_bytes: 61024
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


const long long MOD = 1000000007;

int N;
string s[2];

long long dp[210];

int main() {
	while (cin >> N >> s[0] >> s[1]) {
		memset(dp, 0, sizeof(dp));
		dp[0] = 1;
		if (s[0][0] == s[1][0]) dp[1] = 3;
		else dp[1] = 6;

		for (int i = 1; i < N; ++i) {
			if (s[0][i - 1] == s[1][i - 1]) {
				if (s[0][i] == s[1][i]) {
					dp[i + 1] += dp[i] * 2;
					dp[i + 1] %= MOD;
				}
				else {
					dp[i + 1] += dp[i] * 2;
					dp[i + 1] %= MOD;
				}
			}
			else {
				if (s[0][i] == s[1][i]) {
					dp[i + 1] += dp[i];
					dp[i + 1] %= MOD;
				}
				else {
					if (s[0][i - 1] == s[0][i]) {
						dp[i + 1] += dp[i];
						dp[i + 1] %= MOD;
					}
					else {
						dp[i + 1] += dp[i] * 3;
						dp[i + 1] %= MOD;
					}
				}
			}
		}
		cout << dp[N] << endl;
	}
}







Measured memory_bytes: 256
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int[] a = new int[N];
    int min = 1_000_000;
    for (int i = 0; i < N; i++) {
      a[i] = scanner.nextInt();
      min = Math.min(min, a[i]);
    }

    boolean[] dp = new boolean[K + 1];
    for (int i = min; i <= K; i++) for (int j = 0; j < N; j++) if (i >= a[j]) dp[i] |= !dp[i - a[j]];
    System.out.println(dp[K] ? "First" : "Second");
  }
}


Measured memory_bytes: 24148