akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int n,k; cin >> n >> k;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  int res = 0;
  rep(i,n+1) {
    rep(j,n+1) {
      if(i + j > n) continue;
      int x = k - (i + j);
      if(x < 0) continue;
      vector<int> vec;
      int sum = 0;
      rep(l,i) {
	vec.push_back(v[l]);
	sum += v[l];
      }
      rep(l,j) {
	vec.push_back(v[n - 1 - l]);
	sum += v[n - 1 - l];
      }
      if(vec.size() == 0) continue;
      sort(vec.begin(), vec.end());
      int idx = 0;
      while(vec[idx] < 0 && 0 < x - idx) {
	sum -= vec[idx];
	idx++;
	if(idx == vec.size()) break;
      }
      chmax(res, sum);
    }
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

const int INF = 1001001001;

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

    int n, m;
    cin >> n >> m;
    
    vector<vector<int>> cost(n, vector<int>(n, INF));
    for(int i = 0; i < n; ++i) cost[i][i] = 0;
    vector<int> a(m), b(m), c(m);
    for(int i = 0; i < m; ++i){
        cin >> a[i] >> b[i] >> c[i];
        --a[i];
        --b[i];

        cost[a[i]][b[i]] = c[i];
        cost[b[i]][a[i]] = c[i];
    }

    vector<vector<int>> dist = cost;
    for(int k = 0; k < n; ++k){
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int res = 0;
    for(int e = 0; e < m; ++e){
        bool flg = true;
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                if(dist[i][j] == dist[i][a[e]] + c[e] + dist[b[e]][j]) flg = false;
                if(dist[i][j] == dist[i][b[e]] + c[e] + dist[a[e]][j]) flg = false;
            }
        }
        
        if(flg) ++res;

    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3692
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
#define N 2507
#define M 5007
#define int long long
using namespace std;
inline int read() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') { x=(x<<3)+(x<<1)+(ch^48); ch=getchar(); }
    return x * f;
}
const int INF = 1e18;   //longlong的INF不是0x3f3f3f 
int n,m,p;
int f[N];
struct Edge {
    int u,v,d;
}E[M];
signed main()
{
    n = read() ,m = read() ,p = read();
    for(int i=1,u,v,d;i<=m;++i) {
        u = read() ,v = read() ,d = read();
        E[i] = (Edge){u,v,d-p};
    }
    for(int i=1;i<=n;++i) f[i] = -INF;
    f[1] = 0;
    for(int i=1;i<=n*2;++i) {
        for(int j=1;j<=m;++j) {
            int u = E[j].u ,v = E[j].v ,d = E[j].d;
            if(f[u]==-INF) continue;
            if(f[u]+d > f[v]) {
                f[v] = i<=n ? f[u]+d : INF;
            }
        }
    }
    if(f[n]==INF) puts("-1");
    else if(f[n]<0) puts("0");
    else printf("%lld\n",f[n]);
    return 0;
}//特斯太

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  ll ans = 0;
  if (N%2==0){
    ans += N/10;
    N /= 10;
    while (N>0){
      ans += N / 5;
      N /= 5;
    }
  }
  
  cout << ans << "\n";
  return 0;
}

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

int main() {
  int s;
  int s1,s2,s3;
  cin >> s ;
  s1=s/100;
  s2=s/10-s1*10;
  s3=s-s1*100-s2*10;
  cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


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

Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define pragp(a,b) for(ll p = a;p >= b;p--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;
//Using a top down approach this time
ll memo[1000][1000];
ll CountWays(ll h,ll w,string grid[],ll i,ll j)
{
  if((i == h-1) and (j == w-1)) return 1ll;
  else if(grid[i][j] == '#') return 0ll;
  else if(memo[i][j] != -1) return memo[i][j]%mod;
  else
  {
     if((i< h-1) and (j < w-1)) memo[i][j] = (CountWays(h,w,grid,i,j+1)%mod + CountWays(h,w,grid,i+1,j)%mod)%mod;
     else if(i < h-1) memo[i][j] = CountWays(h,w,grid,i+1,j)%mod;
     else if(j < w-1) memo[i][j] = CountWays(h,w,grid,i,j+1)%mod;
      return memo[i][j];
  }
  
}
void Compute(ll h,ll w)
{
    KAKA
    string grid[h];
    //ll memo[h][w];
    pragi(0,h)
    {
        
            cin>>grid[i];
        
    }
   pragi(0,1000)
   {
       pragj(0,1000)
       {
           memo[i][j] = -1;
       }
   }
    cout<<CountWays(h,w,grid,0,0)<<"\n";
   
}
int main()
{
    KAKA
    ll h,w;
    cin>>h>>w;
    Compute(h,w);
}

Measured memory_bytes: 9344
s=input().strip()
n=len(s)
ans="No"

if s==s[::-1]:
  if s[:(n-1)//2]==s[(n-1)//2-1::-1] and s[(n+3)//2-1:]==s[:(n+3)//2-2:-1]:
    ans="Yes"
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 200'009;

int a[N];
int b[N];
int f[N];
long long suff[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    b[i] = -1;
    for (int j = 0; j <= 29; ++j) {
      if (a[i] >> j & 1) {
        b[i] = j;
      }
    }
    a[i] <<= 29 - b[i];
  }
  f[n] = 0;
  suff[n] = 0;
  for (int i = n - 1; i >= 0; --i) {
    f[i] = b[i];
    suff[i] = suff[i + 1];
    for (int j = i + 1; j < n; ++j) {
      if (f[j] > f[j - 1] || (f[j] == f[j - 1] && a[j] >= a[j - 1])) {
        break;
      }
      int v = (f[j - 1] - f[j] + 1) / 2 * 2;
      if (f[j] + v == f[j - 1] && a[j] < a[j - 1]) {
        v += 2;
      }
      if (f[j] < 29) {
        f[j] += v;
        suff[i] += v;
      } else {
        suff[i] += (long long)v * (n - j);
        break;
      }
    }
  }
  long long ans = suff[0];
  long long pref = 0;
  for (int i = 0; i < n; ++i) {
    f[i] = b[i] + 1;
    pref += 1;
    for (int j = i - 1; j >= 0; --j) {
      if (f[j] > f[j + 1] || (f[j] == f[j + 1] && a[j] >= a[j + 1])) {
        break;
      }
      int v = (f[j + 1] - f[j] + 1) / 2 * 2;
      if (f[j] + v == f[j + 1] && a[j] < a[j + 1]) {
        v += 2;
      }
      if (f[j] < 29) {
        f[j] += v;
        pref += v;
      } else {
        pref += (long long)v * (j + 1);
        break;
      }
    }
    ans = min(ans, pref + suff[i + 1]);
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 4096
/*
	Failure is not the reason for you to stop trying 
	   it is actually a remainder that you should 
			KEEP GOING 
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define E endl
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin>>n;
		string s;
		cin>>s;
		int ans =0 ;
		for(int i =2;i<n;i++){
			if(s[i-2]=='A' && s[i-1]=='B' && s[i]=='C'){
				ans++;
			}
		}
	
		cout <<ans<<E;
	}
	
	cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    vector<vector<int>> board(3, vector<int>(3));
    rep(i, 0, 3) {
        rep(j, 0, 3) {
             cin >> board[i][j];
        }
    }

    rep(i, 0, 3) {
        int minElem = min(min(board[i][0], board[i][1]), board[i][2]);
        if (minElem == 0) continue;
        rep(j, 0, 3) board[i][j] -= minElem;
    }

    rep(i, 0, 3) {
        int minElem = min(min(board[0][i], board[1][i]), board[2][i]);
        if (minElem == 0) continue;
        rep(j, 0, 3) board[j][i] -= minElem;
    }

    int count0 = 0;
    rep(i, 0, 3) {
        count0 += count(board[i].begin(), board[i].end(), 0);
    }
    
    string res = "No";
    if (count0 == 9) res = "Yes";

    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 1000000007
using namespace std;
typedef long long int ll;
vector<int>prime;
void sieve()
{
    vector<bool>visit(1000001,true);
    for(int i=2;i*i<=1000000;i++)
    {
        if(visit[i])
        {
            for(int j=i*i;j<=1000000;j+=i)
            {
                visit[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++)
    {
        if(visit[i])
        {
            prime.push_back(i);
        }
    }
}
int present[1000001]={0};
int main()
{
    int n;
    cin>>n;
    int arr[n];

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

        }

        bool coprime=true;
    for(int i=0;coprime&&i<n;i++)
    {
        int val = arr[i];



            for(int j=1;j*j<=val;j++)
            {
                if(val%j==0)
                {
                    int q = val/j;
                   if(present[j]!=0||present[q]!=0)
                    {
                        coprime=false;
                        break;
                    }
                    else
                    {
                        if(j==1)
                        {
                            if(q!=1)
                            present[q]=1;
                        }
                        else
                            present[j]=present[q]=1;
                    }
                }
            }



    }
    if(coprime)
    {
        cout<<"pairwise coprime\n";
    }
    else
    {
        int gcd=0;
        for(int i=0;i<n;i++)
        {
            gcd = __gcd(gcd,arr[i]);
        }
        if(gcd==1)
        {
            cout<<"setwise coprime\n";
        }
        else
        {
            cout<<"not coprime\n";
        }
    }
}


Measured memory_bytes: 7624
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String X  = sc.next();
    String[] words = X.split("[^ATCG]+");
    int max = 0;
    for(String word : words){
      if(word.length() > max){
        max = word.length();
      }
    }
    System.out.print(max);
  }
}


Measured memory_bytes: 23508
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
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 SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

//const LL mod = 1e9 + 7;


double noudo(int mizu, int sato) {
	return 100.0*(double)sato / (double)(mizu + sato);
}

int main() {
	int N;
	cin >> N;
	vector<LL> A(N),B;

	REP(i, N) {
		cin >> A[i];
	}
	int n = N - 1;
	for (; n > 0; n -= 2) {
		if (n < 0) { break; }
		cout << A[n] <<" ";
	}
	//n = 1;
	//debug(n);

	if (n == 0) { cout << A[n] << " "; }
	n++;
	for (; n < N; n += 2) {
		cout << A[n] << " ";
	}
	cout << endl;

}

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

int main()
{
  int N,M ;
  cin>>N>>M ;
  vector<int>A(N) ;
  int SUM=0 ;
  for(int i=0;i<N;i++){
    cin>>A.at(i) ;
    SUM+=A.at(i) ;
  }
  sort(A.begin(),A.end()) ;
 
  if(SUM%(4*M)==0) SUM/=4*M ;
  else SUM=SUM/(4*M)+1 ;
  if(A.at(N-M)<SUM) cout<<"No"<<endl ;
  else cout<<"Yes"<<endl ;
  
  return 0 ;
}


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

int main()
{
    int K, X;
    cin >> K >> X;
    if (500 * K < X)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] H = new int[N];
		for (int i=0;i<N;i++) {
			H[i] = Integer.parseInt(sc.next());
		}

		int flag = 0;
		int height = H[0];
		for (int i=1;i<N;i++) {
			if (height<H[i]) {
				height = H[i]-1;
			} else if (height>H[i]) {
				flag=1;
				break;
			}
		}
		if (flag==0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 47292
import scala.io.StdIn._

object Main  {
  def main(args: Array[String]): Unit = {
    val K = readToInts()(1)
    val dice = readToVectorInts()
    println(Dice.getTotal(K, dice))
  }

  def readToInts(): Array[Int] = readLine.split(" ").map(_.toInt)
  def readToListInts(): List[Int] = readLine.split(" ").map(_.toInt).toList
  def readToVectorInts(): Vector[Int] = readLine.split(" ").map(_.toInt).toVector

}

case class Dice(index: Int, total: Double) {

  def getNewDice(vec: Vector[Double], K: Int): Dice = {
    if (index + K >= vec.length) {
      Dice(index + 1, 0.0)
    } else {
      Dice(index + 1, total + vec(index + K) - vec(index))
    }
  }

  override def toString: String = s"$index - $total"
}

object Dice {
  private def avg(v: Int): Double = (v + 1.0) / 2.0

  private def createInitial(K: Int, vec: Vector[Double]): Dice = {
    val total = Iterator.iterate(0)(n => n + 1)
      .takeWhile(n => n < K)
      .map(n => vec(n))
      .sum

    new Dice(0, total)
  }

  def getTotal(K: Int, vec: Vector[Int]): Double = {
    val average = vec.map(Dice.avg)
    Iterator.iterate(createInitial(K, average))(d => d.getNewDice(average, K))
      .takeWhile(d => d.index <= vec.length - K)
      .maxBy(dice => dice.total)
      .total
  }
}

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

int main() {
  int K;
  string S;
  cin >> K >> S;
  if (S.size() <= K) cout << S << endl;
  else {
    rep(i,K) {
      cout << S.at(i);
    }
    cout << "..." << endl;
  }      
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A, B;
    cin >> A >> B;

    if(A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0)
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll MOD = 1e9 + 7;
vector<vector<ll>> dp(110, vector<ll>(1e5 + 10));
int main(){
    ll N, W;
    cin >> N >> W;
    for(ll i = 0; i < N; i++){
        ll w, v;
        cin >> w >> v;
        for(ll pre = 0; pre <= W; pre++){
            dp[i + 1][pre] = max(dp[i + 1][pre], dp[i][pre]);
            if(pre >= w) dp[i + 1][pre] = max(dp[i + 1][pre], dp[i][pre - w] + v);
        }
    }
    cout << *max_element(dp[N].begin(), dp[N].end()) << endl;
    return 0;
}


Measured memory_bytes: 87296
a=list(map(int, input().split()))
xy=[map(int, input().split()) for l in range(a[0])]
x, y=[list(i) for i in zip(*xy)]
set=[[0 for j in range(2)] for i in range(a[0])]
num=0
for ele in x:
    set[num][0]=x[num]
    set[num][1]=y[num]
    num+=1
set.sort()
num=0
while a[1]>0:
    a[1]=a[1]-set[num][1]
    num+=1
print(set[num-1][0])

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

int main(void) {
    long long k, n;
    long long *a;
    long long max = 0;
    long long before, after;
    long long start;
    
    scanf("%lld %lld", &k, &n);
    
    a = (long long*)malloc(sizeof(long long));

    before = 0;
  
    for(int i=0;i<n;i++){
        scanf("%lld ",&after);
        if(i==0){
            start = after;
        }
        if(max < (after - before)){
            max = after - before;
        }
        before = after;
    }
    
    if(max < start + k - after){
        max = start + k - after;
    }
    
    printf("%lld", k - max);
    

    return 0;
  
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 200005
#define ll long long
#define ld double
#define mod 998244353
using namespace std;
int gcd(int a, int b)
{
	if(!b) return a;
	return gcd(b, a % b);
}
int x[maxn];
int n;
int main()
{
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", &x[i]);
	sort(x, x + n);
	ll ans = 1;
	for(int i = 0; i < n; i++)
		ans = ans * gcd(x[i], i) % mod;
	printf("%lld\n", ans);
	return 0;
 } 

Measured memory_bytes: 640
import math
import numpy

def is_prime(n):
    if (n==1):
        return 0
    if (n==2):
        return 1
    for i in range(3,int(math.sqrt(n))+1,2):
        if (n % i == 0):
            return 0
    return 1

prime = [0]*(10**5+1)
for i in range(1,10**5+1,2):
    prime[i] = is_prime(i)
prime[2] = 1

q = int(input())
li = [0]*(10**5+1)
for i in range(1,10**5+1):
    if (i%2 == 1):
        if (prime[i] and prime[int((i+1)/2)]):
            li[i] = 1

com = numpy.cumsum(li)
for _ in range(q):
    l,r = [int(x) for x in input().split()]
    print(com[r]-com[l-1])

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin >> n;
    vector<int> a(n);
    map<int,int> cnt;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    ll ans = 0;
    for (auto p: cnt) {
        ans += 1LL*p.second*(p.second-1)/2;
    }
    for (int i = 0; i < n; i++) {
        ans -= 1LL*cnt[a[i]]*(cnt[a[i]]-1)/2;
        cnt[a[i]]--;
        ans += 1LL*cnt[a[i]]*(cnt[a[i]]-1)/2;
        cout << ans << '\n';
        ans -= 1LL*cnt[a[i]]*(cnt[a[i]]-1)/2;
        cnt[a[i]]++;
        ans += 1LL*cnt[a[i]]*(cnt[a[i]]-1)/2;
    }
}



Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N, M;
  cin >> N >> M;

  vector<long long> A(N);
  long long sum = 0;
  rep(i, N)
  {
    cin >> A[i];
    sum += A[i];
  }
  long long not_count = 0;
  rep(i, N)
  {
    if (A[i] * 4 * M < sum)
      not_count++;
  }
  long long count = N - not_count;
  bool is_ok = count >= M;
  printYesNo(is_ok);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <vector>
#include <iomanip>

using namespace std;

int main(void) {
  string S;
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    cout << "x";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
/* ***********************************************
Author        :axp
Created Time  :2017/2/4 20:35:09
TASK		  :B.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

typedef unsigned long long ll;
const int inf = 1<<30;
const int md = 1e9+7;
const int N = 1e6+10;
int n;
int T;
int ar[N];
ll c[N];

bool solve()
{
	ll sum=0;
	for(int i=0;i<n;i++)sum+=ar[i];
	if(sum%(1ll*n*(n+1)/2))return 0;

	for(int i=0;i<n;i++)
	{
		ll t=sum/(1ll*n*(n+1)/2)+ar[i]-ar[(i+1)%n];
		//cout<<t<<endl;
		if(t%n)return 0;
		c[i]=t/n;
		if(c[i]>md)return 0;
		if(1ll*n*c[i]>md)return 0;
	}
	ll now=0;
	ll s=0;
	for(int i=0;i<n;i++)now+=(i+1ll)*c[n-i-1],s+=c[i];
	for(int i=0;i<n;i++)
	{
		//cout<<ar[i]<<' '<<now<<endl;
		if(ar[i]!=now)return 0;
		now+=s-1ll*n*c[i];
	}
	return 1;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&ar[i]);
	bool ans=solve();
	puts(ans?"YES":"NO");
    return 0;
}


Measured memory_bytes: 1408
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    int X;
    cin >> X;
    if (X == 3 || X == 5 || X == 7)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

ans = S.count('R')*S.count('G')*S.count('B')

for i in range(N):
    for j in range(N):
        if i+2*j < N:
            if len(set([S[i],S[i+j],S[i+2*j]]))==3:
                ans -=1
print(ans)


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


bool prime(int x){
    if(x==2){
        return true;
    }
    
    int n=2;
    while(x>=n*n){
        if(prime(n)){
            if(x%n==0){
                return false;
            }
        }
        n++;
    }
    return true;
}

int main(){
    int x;
    cin >> x;
    while(true){
        if(prime(x)) break;
        x++;
    }

    cout << x << endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<int>> mat;

int main(){
    int N;cin>>N;
    vec a(200010);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    int k=0,x=1;
    while(k<N){
        if(a[k]==x){
            x++;
        }
        k++;
    }
    if(x==1){
        cout<<-1<<endl;
    }
    else{
        cout<<N-x+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define LL       long long
#define DS       pair<LL, LL>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int n;
    scanf("%d", &n);
    printf("%d\n", n / 2 + (n % 2));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

template<typename T>
void say(vector<T> s, string t) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << t << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T & a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T & a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T> & v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

int main() {
	makei(n);
	vi ans = { n / 60 / 60,n / 60 % 60,n % 60 };
	say(ans, ":");
}


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

using namespace std;

int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double t;
    if (x > a * a * b / 2){
        double y = (2 * x - a * a * b) / (a * a);
        t = 90 - abs(atan(a / (b - y)) * 180 / M_PI);
    } else {
        double y = 2 * x / (a * b);
        t = 90 - atan(y / b) * 180 / M_PI;
    }
    
    cout << setprecision(20);
    cout << t << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
void degree(int);
int depth(int);
 
typedef struct{
  int parent;
  int left;
  int right;
}Node;
 
Node nodes[100001];
int counter = 0;
 
int main(void) {
 
  int i, j, n, m, new_node, child, left, right;
 
  scanf("%d", &n);
 
  for(i = 0; i < n; i++) {
    nodes[i].parent = -1;
    nodes[i].left = -1;
    nodes[i].right = -1;
  }
 
  for(i = 0; i < n; i++) {
    scanf("%d%d", &new_node, &m);
 
    for(j = 0; j < m; j++) {
      scanf("%d", &child);
      nodes[child].parent = new_node;
      if(j != 0)   nodes[left].right = child;
      else         nodes[new_node].left = child;
      left = child;
 
    }
  }
 
  for(i = 0; i < n; i++) {
    counter = 0;
    printf("node %d: parent = %d, depth = %d, ", i, nodes[i].parent, depth(i));
 
    if(nodes[i].parent == -1)       printf("root, [");
    else if (nodes[i].left == -1)   printf("leaf, [");
    else                            printf("internal node, [");
    
    counter = 0;
    degree(nodes[i].left);
    printf("]\n");
  }
  return 0;
}
 
int depth(int node_num) {
 
  if(nodes[node_num].parent == -1) {
    return counter;
  } else {
    counter++;
    return depth(nodes[node_num].parent);
  }
 
}
 
void degree(int node_num) {
 
  if(node_num != -1) {
 
    if(counter != 0)      printf(", ");
    printf("%d", node_num);
    counter++;
    degree(nodes[node_num].right);
     
  }
}


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

int main(void) {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;
}


Measured memory_bytes: 256
INF = 1e9
n,k = map(int, input().split())
h = list(map(int, input().split()))
ans = [INF]*n
ans[0]= 0
ans[1] = abs(h[1]-h[0])
for i in range(2,n):
    x = max(0, i-k)
    for j in range(x,i):
        ans[i]=min(ans[i], abs(h[i]-h[j])+ans[j])
print(ans[-1])

Measured memory_bytes: 55392
--[[------------------------------------------------------------------------]]--
local function floor_sum(elm_num, div_num, mul_num, add_num)
	local ans = 0
	if mul_num >= div_num then
		ans = ans + (elm_num - 1) * elm_num * (mul_num // div_num) // 2
		mul_num = mul_num % div_num
	end
	if add_num >= div_num then
		ans = ans + elm_num * (add_num // div_num)
		add_num = add_num % div_num
	end

	local y_max = (mul_num * elm_num + add_num) // div_num
	local x_max = (y_max * div_num - add_num)
	if y_max == 0 then
		return ans
	else
		ans = ans + (elm_num - (x_max + mul_num - 1) // mul_num) * y_max
		ans = ans + floor_sum(
			y_max, mul_num, div_num,
			(mul_num - x_max % mul_num) % mul_num, ans
		)
		return ans
	end
end
--[[------------------------------------------------------------------------]]--

local read = io.read
local t = read("n")

local out_t = {}
for i = 1, t do
	out_t[i] = floor_sum(read("n", "n", "n", "n"))
end
print(table.concat(out_t, "\n"))


Measured memory_bytes: 11916
def main():
    a, b, c = map(int, input().split())
    mod = []
    mul_a = a
    while True:
        if mul_a % b == 0:
            break
        else:
            mod.append(mul_a % b)
            mul_a += a

    if c in mod:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()    

Measured memory_bytes: 9180
N = int(input())
abc = [list(map(int, input().split())) for _ in range(N)]

dp = [[0, 0, 0] for _ in range(N + 1)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k])

print(max(dp[N]))


Measured memory_bytes: 76300
require 'pp'

n, m, x = gets.chomp!.split(" ").map(&:to_i)
a_m = gets.chomp!.split(" ").map(&:to_i)
masu = Array.new(n + 1, 0)
a_m.each do |a|
    masu[a] = 1
end

costs = []
# left
sum = 0
x.downto(0) do |i|
    sum += masu[i]
end
costs << sum

# right
sum = 0
x.upto(n) do |i|
    sum += masu[i]
end
costs << sum

puts costs.min


Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>

using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;

typedef vector<lint> vl;
typedef pair<lint,lint> pll;

#define mpr make_pair



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

    int n; cin>>n;

    vector<vi> sons(n+1);
    for (int i =2;i<=n; ++i){
        int fa; cin>>fa;
        sons[fa].push_back(i);
    }

    for (int i=1; i<=n; ++i) cout<<sons[i].size()<<"\n";

}


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

using namespace std;
const int MAXN = 1e5 + 5;

int A[MAXN];
int DP[MAXN];


int main(int argc, char* argv[]){
	int N, K;
	scanf("%d%d", &N, &K);
	
	for (int i=0; i < N; i++) {
		scanf("%d", A + i);
		if (i != 0)
			DP[i] = 1e9 + 5;

		for (int j=max(0, i - K); j < i; j++) 
			DP[i] = min(DP[i], DP[j] + abs(A[i] - A[j]));
	}

	printf("%d\n", DP[N - 1]);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int calc(int a,int b){
  if(b == 0) return 1;
  if(b%2 == 0){
    int d = calc(a,b/2);
    return (d*d)%MOD;
  }
  return (a*calc(a,b-1))%MOD;
}

int comb(int n,int r){
  int tmp = 1,ttmp = 1;
  for(int i = n;i >= n-r+1;i--) tmp = (tmp*i)%MOD;
  for(int i = 1;i <= r;i++) ttmp = (ttmp*i)%MOD;
  return (tmp*calc(ttmp,MOD-2))%MOD;
}

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

  cout << ((comb(c+1+d+1, d+1)+comb(a+b, b)-comb(c+1+b, b)-comb(a+d+1, d+1))%MOD+MOD)%MOD << "\n";

  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
using std::min;
using std::max;

const int MAXN=1e5+5;

char s[MAXN];int n;

int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	int ans=0;
	int l=1,r=n,lcnt,rcnt;
	while(l<r)
	{
		lcnt=rcnt=0;
		while(s[l]=='x') l++,lcnt++;
		while(s[r]=='x') r--,rcnt++;
		if(s[l]==s[r]) ans+=max(lcnt,rcnt)-min(lcnt,rcnt);
		else {ans=-1;break;}
		l++,r--;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {

int N, M, C; cin >> N >> M >> C;
vector <int> B(M);
for (int i = 0; i < M; ++i) {
cin >> B[i];
}
vector <vector <int>> A(N, vector <int >(M));
for (int i = 0; i < N; ++i) {
for (int j = 0; j < M; ++j) {
cin >> A[i][j];
}
}
int ans = 0;
for (int i = 0; i < N; ++i) {

int sum = 0;
for (int j = 0; j < M; ++j) {
sum += A[i][j] * B[j];
}
if (sum + C > 0) {

ans++;
}
}

cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL <<60;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
ll dp[100100];
ll h [100100];

int main(){
  int n,k;
  cin>>n>>k;
  
  for(int i = 0; i < n; i++){
    cin>>h[i];
  }
  for(int i = 0; i < 100100; i++) dp[i] = INF;
  dp[0] = 0;
  for(int i = 0; i < n; i++){
    for(int j = 1; j <= k; j++){
      chmin(dp[i+j],dp[i] + abs(h[i+j]-h[i]));
    }
  }
  cout<<dp[n-1]<<endl;

  return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
unsigned prime[15] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47}, over[5], divisor[5] = {3,5,15,25,75};

int main(){
    unsigned N;
    scanf("%u", &N);
    unsigned power, _N;
    for (size_t i = 0; i < 15; i++){
        power = 1, _N = N;
        while(_N /= prime[i]) power += _N;
        for (size_t j = 0; j < 5; j++){
            if(power >= divisor[j]) over[j]++;
        }
    }
    printf("%u\n", over[4] + over[3]*(over[0] - 1) + over[2]*(over[1] - 1) + (over[1]*(over[1] - 1)>>1)*(over[0] - 2));
	return 0;
}

Measured memory_bytes: 1736
#include<stdio.h>
#include<iostream>
using namespace std;

int main(void)
{
int h,w;
while(cin>>h>>w)
{
;
if(h==0&&w==0)
break;
else 
for(int i=1;i<=h;i++)
{
for(int j=1;j<=w;j++)
{

if(i>1&&i!=h&&j>1&&j!=w)
	{
cout<<".";
}
else{
cout<<"#";
}

}cout<<endl;
}
	cout<<endl;
}
}

Measured memory_bytes: 3072
#include<stdio.h>

int main(){
  int x,y,r,tmp;
  
  scanf("%d %d", &x,&y);

  if(x < y){
    tmp = x;
    x = y;
    y = tmp;
  }

  r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }

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

  return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N; cin >> N;
    long long SUM=0;
    vector<long long> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i]; SUM+=a[i];
    }
    long long ans=INFLL;
    for(int i=0;i<N-1;i++){
        SUM-=2*a[i];
        ans = min(ans, abs(SUM));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
	double x, h;

	while ( cin >> x >> h && !( !x && !h ) ){
		cout << setprecision( 6 ) << setiosflags( ios::fixed );
		cout << x * x + 2 * x * sqrt( x * x / 4 + h * h ) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 118
	// https://atcoder.jp/contests/abc118/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		
		if (n == 25) {
			System.out.println("Christmas");
		} else if (n == 24) {
			System.out.println("Christmas Eve");
		} else if (n == 23) {
			System.out.println("Christmas Eve Eve");
		} else {
			System.out.println("Christmas Eve Eve Eve");
		}
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


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

#define ll long long

int main(){
    int N;
    string S;
    cin >> N >> S;

    ll r=0, g=0, b=0;
    for(int i=0; i<N; i++){
        if(S[i] == 'R') r++;
        if(S[i] == 'G') g++;
        if(S[i] == 'B') b++;
    }
    ll ans = r * g * b;

    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            int k = j + (j-i);
            if(k >= N) break;
            if(S[i]!=S[j] && S[j]!=S[k] && S[k]!=S[i]) ans--;
        }
    }

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

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
using P = pair< int,int>;
using node = tuple<int,int,int>;
const int MAX_N = (1 << 21) - 1;
const int inf = numeric_limits<int>::max();

int main(void){
  int a,p;
  cin >> a >> p;
  int tot = a * 3 + p;
  cout << tot / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <algorithm> 
using namespace std; 
  
int main(){
	int aux,sum,j,k,i;
	int ar[5];
	int* max;

	scanf("%d%d%d%d",&ar[0],&ar[1],&ar[2],&k);

	max=max_element(ar,ar+3);

	sum=*max<<k;

	j=max-ar;

	for(i=0;i<3;i++)
		if(i!=j)
			sum+=ar[i];

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

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

int main(){
    int N, M;
    int sum = 0, popSum = 0;
    cin >> N >> M;
    int A[N];
    FOR(i,0,N) {
        cin >> A[i]; 
        sum += A[i];
    }
    FOR(i,0,N) {
        if(A[i] * 4 * M < sum ) continue; 
        popSum++;
    }
    if(popSum>=M) cout << "Yes" << endl; 
    else cout << "No" << endl; 
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    p = []
    for i in range(N):
        r, c = (int(i) for i in input().split())
        p.append(r)
        if i == N - 1:
            p.append(c)
    memo = [[float('inf') for j in range(N + 1)] for i in range(N + 1)]

    def matrix_chain_order():
        for i in range(1,N+1):
            memo[i][i] = 0

        for l in range(2,N+1):
            for i in range(1, N - l + 1 + 1):
                j = i + l - 1
                for k in range(i, j):
                    q = memo[i][k] + memo[k + 1][j] + p[i-1]*p[k]*p[j]
                    if q < memo[i][j]:
                        memo[i][j] = q

    matrix_chain_order()
    print(memo[1][N])

if __name__ == '__main__':
    main()


Measured memory_bytes: 5932
n,s=map(int,input().split())
dp=[0]*(s+1)
dp[0]=1
ne=[0]*(s+1)
mod=998244353
for i in list(map(int,input().split())):

    for k in range(0,s+1):
        if k+i<=s:
            ne[k+i]=(ne[k+i]+dp[k])%mod
        ne[k]=(ne[k]+2*dp[k])%mod
        dp[k]=0
    dp,ne=ne,dp
print(dp[-1])

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

bool CheckPalindrome(const std::string& str)
{
    int n = str.size();
    bool ans = true;
    for(int i = 0; i < (n-1)/2.0; ++i)
    {
        if(str[i] not_eq str[n - i - 1])
        {
            ans = false;
        }
    }
    return ans;
}

int main()
{
    std::string S;
    std::cin >> S;
    int N = S.size();

    if(CheckPalindrome(S) 
        and CheckPalindrome(S.substr(0, (N-1)/2))
        and CheckPalindrome(S.substr((N+1)/2, N)))
    {
        std::cout << "Yes" << std::endl;
        return 0;
    }
    std::cout << "No" << std::endl;
    return 0;
}

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>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e15+9
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

double a, b, h;

int main(){
	cin >> a >> b >> h;
	cout << (a + b)*h / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c >=22) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast       ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define fs          first
#define sc          second
#define pb         push_back
#define nl          '\n'
#define all(a) a.begin(),a.end()
#define REP(i,start,end) for (int i = start; i <=end; i++)
#define RREP(i,end,start) for (int i=end; i>=start ;i--)
typedef long long LL;
class seq{
    public:
    int low, high, bal, id;
    seq(int a,int b, int c,int d)
    {
        low=a;
        high=b;
        bal=c;
        id=d;
    }
};
bool custom(seq a , seq b)
{
    if(a.low==b.low)
        return a.bal>b.bal;
    return a.low<b.low;
}
bool custom2(seq a , seq b)
{
    if(a.high==b.high)
        return a.bal<b.bal;
    return a.high<b.high;
}
void solve()
{
    int n;
    cin>>n;
    vector<seq> vect1,vect2;
    REP(i,1,n)
    {
        string s;
        cin>>s;
        int low=0;
        int high=0;
        int bal=0;
        REP(j,0,s.size()-1)
        {
            bal+=(s[j]=='(');
            bal-=(s[j]==')');
            low=min(low,bal);
        }
        bal=0;
        RREP(j,s.size()-1,0)
        {
            bal-=(s[j]=='(');
            bal+=(s[j]==')');
            high=min(high,bal);
        }
        seq sq(-low,-high,-bal,i);
        if(bal<0)
            vect1.pb(sq);
        else
            vect2.pb(sq);
    }
    sort(all(vect1), custom);
    sort(all(vect2), custom2);
    int bal=0;
    if(vect1.size()>=1)
    {
        REP(i,0,vect1.size()-1)
        {
            if(vect1[i].low>bal)
            {
                cout<<"No"<<nl;
                return;
            }
            bal+=vect1[i].bal;
            
        }
    }
    int bal2=0;
    if(vect2.size()>=1)
    {
        REP(i,0,vect2.size()-1)
        {
            if(vect2[i].high>bal2)
            {
               
                cout<<"No"<<nl;
                return;
            }
            bal2-=vect2[i].bal;
        }
    }
    if(bal==bal2)
    {
        cout<<"Yes"<<nl;
    } 
    else
        cout<<"No"<<nl;
}
int main()
{
    fast;
        solve();
}

Measured memory_bytes: 19032