akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
bool oddpalin(string s){
	int m = s.length();
	for(int i=0;i<(m-1)/2;i++){
		if(s[i]!=s[m-i-1]){
			return false;	
		}
	}
	return true;
}
bool evenpalin(string s){
	int m = s.length();
	for(int i=0;i<m/2;i++){
		if(s[i]!=s[m-i-1]){
			return false;	
		}
	}
	return true;
}
int main() {
	string s;
	cin >> s;
	int n;
	n = s.length();
	if(oddpalin(s)){
		string t= "";
		for(int i=0;i<(n-1)/2;i++){
			t+=s[i];	
		}
		if(evenpalin(t)){
			cout << "Yes" <<'\n';
			return 0;
		}
	}
	cout << "No" <<'\n';
}

Measured memory_bytes: 256
<?php
$x = 0;
fscanf(STDIN, "%d %d", $N, $M);
while($N--) {
    fscanf(STDIN, "%d %d", $A, $B);
    $a[$A][] = $B;
}

$h = new SplMaxHeap;
for ($i = 1; $i <= $M; $i++) {
    if (isset($a[$i]) === true) {
        foreach ($a[$i] as $v) {
            $h->insert($v);
        }
    }
    if ($h->isEmpty() === false) {
        $x += $h->extract();
    }
}
echo $x;

Measured memory_bytes: 47604
#include <iostream> 
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <string>
using namespace std;
#define MAX_N 50
#define MAX_M 50

int main() {
	int n,m;
	cin >> n >> m;
	int out[MAX_N] = {0};
	// int road[MAX_M][2];
	for (int i(0); i < m ; i++) {
		int a,b;
		cin >> a >> b;
		out[a - 1] += 1;
		out[b - 1] += 1;
		// cin >> road[i][0] >> road[i][1];
		// out[road[i][0] - 1] += 1;
		// out[road[i][1] - 1] += 1;
	}
	for (int i(0);i < n; i++){
		cout << out[i] << endl;
	}

	// for (int i(0); i < m ; i++) {
		// cout << road[i][0] << road[i][1];
	// }
	// string a,b,c;
	// cin >> a >> b >> c;
	// if (a[a.length() - 1] == b[0]) {
		// if (b[b.length() - 1] == c[0]) {
			// cout << "YES";
			// return 0;
		// }
	// }
	// cout << "NO";
    return 0;
 }

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

char s[1005];

int main(){
	int n, f1, f2, f3, f4;
	scanf("%s", s + 1);
	n = strlen(s + 1);
	f1 = f2 = f3 = f4 = 0;
	for (int i = 1; i <= n; i++){
		if (s[i] == 'N') f1 = 1;
		else if (s[i] == 'S') f2 = 1;
		else if (s[i] == 'E') f3 = 1;
		else f4 = 1;
	}
	if (f1 == f2 && f3 == f4) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int a,b;cin>>a>>b;
	cout<<(b-a)*(b-a-1)/2-a<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
using namespace std;

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

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define ii pair<int, int>
#define fi first
#define se second





 
int32_t main(){
	
	string s;
	cin >> s;
	if(s == "AAA" || s == "BBB"){
		cout << "No\n";
	}else{
		cout << "Yes\n";
	}
	 return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define INF 0x3f3f3f3f
#define maxn 100005
int n,m,q,s[maxn],d[maxn],x[maxn],maxd[maxn],c[maxn],que[maxn],fr,bk;
struct node { int v; node *nxt; } edge[maxn*2],*head[maxn],*ncnt;
void addedge(int u,int v)
{
	ncnt++;
	ncnt->v=v,ncnt->nxt=head[u];
	head[u]=ncnt;
}
void dfs(int u,int d,int x)
{
	if(maxd[u]>=d) return;
	if(!c[u]) c[u]=x;
	if(!d) return;
	maxd[u]=d;
	for(node *p=head[u];p;p=p->nxt) dfs(p->v,d-1,x);
}
int main()
{
	scanf("%d%d",&n,&m);
	ncnt=&edge[0];
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		addedge(u,v); addedge(v,u);
	}
	memset(maxd,-1,sizeof(maxd));
	scanf("%d",&q);
	for(int i=1;i<=q;i++) scanf("%d%d%d",&s[i],&d[i],&x[i]);
	for(int i=q;i;i--) dfs(s[i],d[i],x[i]); 
	for(int i=1;i<=n;i++) printf("%d\n",c[i]);
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}

int main(){
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	ll p[a], q[b], r[c];
	FOR0(i, a) cin >> p[i];
	FOR0(i, b) cin >> q[i];
	FOR0(i, c) cin >> r[i];
	sort(p, p + a, greater<ll>());
	sort(q, q + b, greater<ll>());
	sort(r, r + c, greater<ll>());
	pi ans[x+y];
	FOR0(i, x) ans[i] = {p[i], 1};
	FOR0(i, y) ans[i+x] = {q[i], 2};
	sort(ans, ans+x+y, greater<pi>());
	priority_queue<pi> pq;
	pq.push(ans[0]);
	pq.push({r[0], 3});
	int cnt = 0;
	ll res = 0;
	int i = 1, j = 1;
	while(cnt < x + y){
		auto tp = pq.top();
		pq.pop();
		cnt++;
		res += tp.ff;
		if (j < c && tp.ss == 3) {
			pq.push({r[j], 3});
			j++;
		}
		else if (i < x + y) {
			pq.push(ans[i]);
			i++;
		}
	}
	cout << res;
}

Measured memory_bytes: 5376
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int N;cin>>N;
  int ans = 0;
  FOR(i,0,N) {
    ll in;cin>>in;
    if(in==2) {
      ans++;
      continue;
    }
    bool ok = true;
    FOR(i,2,sqrt(in)+1) {
      if(in%i==0) {
        ok = false;
        break;
      }
    }
    if(ok) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3100
#include<iostream>
using namespace std;
int main(){
    int n,m,tmp,ans=0;
int q[51];
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        cin>>tmp;
        q[i]=tmp;
    }
    for(int i=0;i<n;i++)
    {
        int a=0;
        for(int j=i+1;j<n;j++)
        {
            if(q[j]>q[i])
            {
                a=q[i];
            q[i]=q[j];
            q[j]=a;
            }
        }
    }
    for(int i=0;i<m;++i){
        ans+=q[i]; //加前m个元素
    }
    cout<<ans<<endl; //输出
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	var m, ans int64
	for i := 0; i < n; i++ {
		a := getNextInt64(scanner)
		b := getNextInt64(scanner)
		if m < a {
			ans = a + b
			m = a
		}
	}
	fmt.Fprintln(writer, ans)
}


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

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ll long long
#define li long int
#define ld long double
#define lld long long double

#define pb push_back
#define mk make_pair
#define F first
#define S second

#define all(v) (v).begin(),(v).end()
#define fill(a) memset(a, 0, sizeof(a))

const int MX = 1e6;
const int MI = -1e6;
const int MOD = 1e9 + 7;
const string ALPHA = "abcdefghijklmnopqrstuvwxyz";
const double PI = 3.1415926535;

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

const int mod=1e9+7;
inline int add(int x,int y)
{
  x+=y;
  if (x>=mod)
    return x-mod;
  return x;
}
inline int sub(int x,int y)
{
  x-=y;
  if (x<0)
    return x+mod;
  return x;
}
inline int mul(int x,int y)
{
  return (x*1ll*y)%mod;
}
inline int power(int x,int y)
{
  int ans=1;
  while(y)
    {
      if (y&1) ans=mul(ans,x);
      x=mul(x,x);
      y>>=1;
    }
  return ans;
}
inline int inv(int x)
{
  return power(x,mod-2);
}
inline int gcd(int x, int y)
{
  return(y!=0)?gcd(y, x%y):x;
}
inline ll nPr(int n, int r)
{
  ll i,result=1;
  rep(i,r)
    {
      result*=(ll)(n-i);
    }
  return result;
}
inline ll nCr(int n,int r)
{
  ll i,result=1;
  rep(i,min(r,n-r))
    {
      result*=(ll)(n-i);
      result/=(ll)(i+1);
    }
  return result;
}
bool prime(int n)
{
  for (int i=2; i<n/2; i++)
    {
      if(n%i==0)
	return false;
    }
  return true;
}

/*------------CODE->BEGINS------------*/



int main()
{
  IOS;
  //bool ans=false;
  int n;
  cin >> n;
  int arr[n][2];
  //int cnt=0;
  for (int i=0; i<n; i++)
    {
      for (int j=0; j<2; j++)
	{
	  cin >> arr[i][j];
	}
    }
  for (int i=0; i<n-2; i++)
    {
      if (arr[i][0]==arr[i][1] && arr[i+1][0]==arr[i+1][1] && arr[i+2][0]==arr[i+2][1])
	{
	  cout << "Yes" << endl;
	  return 0;
	}
    }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define int64 long long
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 (b<a) { a=b; return 1; } return 0; }
using namespace std;

int main() {
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	vector<int64> p(A, 0);
	vector<int64> q(B, 0);
	vector<int64> r(C, 0);
	for (int64 i = 0; i < A; i++) {
		cin >> p[i];
	}
	for (int64 i = 0; i < B; i++) {
		cin >> q[i];
	}
	for (int64 i = 0; i < C; i++) {
		cin >> r[i];
	}
	sort(all(p),greater<int64>());
	sort(all(q),greater<int64>());
	int64 result=0;

	for (int64 i = 0; i < X; ++i) {
		r.push_back(p[i]);
	}
	for (int64 i = 0; i < Y; ++i) {
		r.push_back(q[i]);
	}
	sort(all(r),greater<int64>());
	for (int64 i = 0; i < X+Y; ++i) {
		result+=r[i];
	}
	cout << result << endl;

	return 0;
}


Measured memory_bytes: 6384
#include<bits/stdc++.h>
#define pll pair<long long, long long> 
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    long long x;
    vector<pair<long long, pll> > value;
    cin>>x;
    for(long long i=-1000; i<1000; i++){
        for(long long j=-1000; j<1000; j++){
            long long ans = i*i*i*i*i-j*j*j*j*j;
            value.push_back({ans, {i,j}});
        }
    }
    for(auto i : value){
        if(x==i.first){
            cout<<(i.second).first<<" "<<(i.second).second;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 101724
#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    int a, b;
    cin >> a >> b;
    
    cout << (a + b + 1) / 2 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define INF 10000000

void MatrixChainOrder(int );
int min(int, int);

int p[N];
int m[N][N];


main(){

  int n,i,j,k,r,c;

  scanf("%d",&n);


  for(i=0; i<n; i++){   

    scanf("%d %d",&r,&c);
    p[i]=r;
    p[i+1]=c;
  }
  
  MatricChainOrder(n);
  
  
  printf("%d\n",m[1][n]);

  return 0;
}

void MatricChainOrder(int n) {

  int i,j,l,k,q;

  for(i=1; i<=n; i++)
    m[i][i]=0;

  for(l=2; l<=n; l++){

    for(i=1; i<=n-l+1; i++){
      j=i+l-1;
      m[i][j]=INF;

      for(k=i; k<=j-1; k++){

	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];

	m[i][j]=min(m[i][j],q);
      }
    }
  }
}



int min(int m,int q){
  if(m<q)
    return m;
  else 
    return q;
}

Measured memory_bytes: 636
// itne me hi thakk gaye?
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
#define ll long long 
#define ull unsigned long long
using ld = long double;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll rk = 256;
const ld PI = 3.141592653589793;
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define print(a) for(auto j:a) {cout<<j<<",";} cout << "\n";
#define endl '\n'
#define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
// // Printing pair
ostream & operator << (ostream & os, pair <ll, ll> const& x) {
    os << x.first << "," << x.second;
    return os;
}
 
// printing vector
template <class T>
ostream & operator << (ostream & os, vector <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
// printing set
template <class T>
ostream & operator << (ostream & os, set <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
const int mxn = 1e5+5;
vc <string> g;
vc <vc <ll> > dp;
bool isSafe(int i, int j, int row, int col) {
    return (i > 0 && i<row && j>0 && j<col && g[i][j] != '#');
}
int32_t main(){
    FastIO;
    int n, m;
    cin >> n >> m;
    dp.assign(n, vc <ll> (m, 0));
    g.resize(n);
    for(int i=0; i<n; i++) {
        cin >> g[i];
    }
    if (g[0][0] == '.') dp[0][0] = 1;
    for(int i=1; i<n; i++) {
        if (g[i][0] == '.') dp[i][0] = dp[i-1][0];
    }
    for(int i=1; i<m; i++) {
        if (g[0][i] == '.') dp[0][i] = dp[0][i-1];
    }
    for(int i=1; i<n; i++) {
        for(int j=1; j<m; j++) {
            if (g[i][j] == '.') dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod; 
        }
    }
    cout << dp[n-1][m-1] << endl;
    return 0;
}


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

#define ll long long

const int mxN = 3e3, M = 998244353;
int n, s, a[mxN];
ll dp[mxN + 1][mxN + 1], ans;
//dp[i][sum] = Σf(L, R), 1 ≤ L ≤ R ≤ i
//f(L, R)在這裡定義為 符合 [L <= x1 < x2 < ... < xk <= R 且 Ax1 + Ax2 + ... + Axk = sum] 的 sequence(X1, X2, ..., Xk)數量

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

	cin >> n >> s;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		memcpy(dp[i + 1], dp[i], sizeof(dp[0]));
		//start a new sequence
		//void *memcpy(void*dest, const void *src, size_t n);
		//由src指向地址為起始地址的連續n個位元組的資料複製到以destin指向地址為起始地址的空間內
		//sizeof(dp[0]) = 24008 因為mxN + 1 = 3001，long long佔8個位元組
		dp[i + 1][a[i]] = (dp[i + 1][a[i]] + i + 1) % M;
		//R = i, L從0到i，共有i + 1種 pair(L, R)
		for (int j = 0; j + a[i] <= s; ++j) {	//超過 s 的不用記
			dp[i + 1][j + a[i]] = (dp[i + 1][j + a[i]] + dp[i][j]) % M;
		}
		//cout << "dp[" << i + 1 << "][" << s << "] = "<< dp[i + 1][s] << endl;
		ans = (dp[i + 1][s] + ans) % M;
	}
	cout << ans << endl;
}

Measured memory_bytes: 70656
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map>
using namespace std;
int n,L[105];
long long ans;
map<pair<pair<int,int>,int>,int> MP;

bool chk(int a,int b,int c)
{
	if(a+b>c&&a+c>b&&b+c>a) 	return 1;
	else	return 0;
}

pair<pair<int,int>,int> SORT(int a,int b,int c)
{
	int F[3]={a,b,c};
	sort(F,F+3);
	return make_pair(make_pair(F[0],F[1]),F[2]);
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)	scanf("%d",&L[i]);
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
		{
			for(int k=1;k<=n;++k)
			{
				if(i==j||i==k||j==k)	continue;
				if(L[i]==L[j]||L[i]==L[k]||L[j]==L[k])	continue;
				if (MP[SORT(i,j,k)]==0)
				{
					if(chk(L[i],L[j],L[k]))
					{
						ans++;
//						printf("%d %d %d | %d %d %d | %d\n",i,j,k,L[i],L[j],L[k],chk(L[i],L[j],L[k]));
					}
					MP[SORT(i,j,k)]=1;
				}
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 13328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

ll dp[123456][4]; // dp[i][j] := i文字目までに"ABC"がj文字分完成している数

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    rep(i, S.size())
    {
        rep(j, 4)
        {
            if (S[i] != '?') {
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
            } else {
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * 3) % MOD;
            }
        }
        if (S[i] == 'A' || S[i] == '?')
            dp[i + 1][1] = (dp[i + 1][1] + dp[i][0]) % MOD;
        if (S[i] == 'B' || S[i] == '?')
            dp[i + 1][2] = (dp[i + 1][2] + dp[i][1]) % MOD;
        if (S[i] == 'C' || S[i] == '?')
            dp[i + 1][3] = (dp[i + 1][3] + dp[i][2]) % MOD;
    }
    cout << dp[S.size()][3] << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Library
//

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int D; cin >> D;
    if(D == 25){
        cout << "Christmas" << endl;
    }
    else if(D == 24){
        cout << "Christmas Eve" << endl;
    }
    else if(D == 23){
        cout << "Christmas Eve Eve" << endl;
    }
    else if(D == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
using namespace std;

int main()
{
    faster

    int a,b;
    cin>>a>>b;

    int m=a*b;
    int ad=a+b;
    int s=a-b;

    int ans=max(m,max(ad,s));
    cout<<ans<<endl;




    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    s = S()
    lens = len(s)+1
    ans = 0
    for i in range(lens // 2):
        if s[i] == s[-i - 1]:
            continue
        ans += 1
    print(ans)

    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38512
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>

using namespace std;

#define cn cout << '\n'
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

int main() {
    cio;
    int N; cin >> N;
    string S; cin >> S;
    string t = S.substr(0, N/2);
    if (S == t + t) cout << "Yes\n";
    else cout << "No\n";
    cn;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  string S;
  cin >> S;

  if (S == "ABC") {
    cout << "ARC" << '\n';
  } else {
    cout << "ABC" << '\n';
  }

  return 0;
}

Measured memory_bytes: 3652
def gcd(l, r):
  while r > 0:
    l, r = r, l % r
  return l

def main():
  N, K, *A = map(int, open(0).read().split())
  g = A[0]
  for a in A:
    g = gcd(g, a)
  if K % g == 0 and K <= max(A):
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

if __name__ == '__main__':
  main()


Measured memory_bytes: 14052
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
ll n, h;
vector<ll> w, v;
ll memo[1010][10100 * 2];
ll dp(ll i, ll j){
    if(j <= 0) return 0;
    if(i == -1) return INF;
    if(memo[i][j] != -1) return memo[i][j];

    ll res = INF;
    res = min(res, dp(i - 1, j));
    res = min(res, dp(i, j - v[i]) + w[i]);

    //cout << i << "," << j << " " << res << endl;

    return memo[i][j] = res;
}


int main(void){
    cin >> h >> n;
    w.resize(n);
    v.resize(n);

    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= h * 2; j++){
            memo[i][j] = -1;
        }
    }
    for(int i = 0; i < n; i++){
        cin >> v[i] >> w[i];
    }

    ll ans = INF;
    for(ll i = h; i <= h * 2; i++){
        ans = min(ans, dp(n - 1, i));
    }

    cout << ans << endl;
}

Measured memory_bytes: 158592
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli inf = 1e18;

int main(){
	lli h,w;
	cin >> h >> w;
	if(h%3==0 || w%3==0){
		cout << 0 << endl;
	}else{
		lli ans=inf;
		for(int i=0; i<2; i++){
			for(int j=0; j<2; j++){
				vector<lli> a(3);
				lli sh = (j==0)? h/3: (h+2)/3;
				lli rh = h -sh;
				a[0] = sh *w;
				if(w%2==0 || rh%2==0){
					a[1] = a[2] = rh*w/2;
				}else{
					a[1] = min(rh,w)*(max(rh,w)/2);
					a[2] = a[1] +min(rh,w);
				}
				sort(a.begin(), a.end());
				ans = min(a[2]-a[0], ans);
			}
			swap(h,w);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S) + 1
Ans = [0]
a = 0
for c in S:
    if c=="<":
        a += 1
        Ans.append(a)
    else:
        a = 0
        Ans.append(a)

a = 0
for c, i in zip(S[::-1], range(N-2, -1, -1)):
    if c==">":
        a += 1
    else:
        a = 0
    Ans[i] = max(Ans[i], a)

#print(Ans)
print(sum(Ans))



Measured memory_bytes: 67632
#include<iostream>
#include<algorithm>
#include<vector>
typedef long long int ll;
using namespace std;

int main(){
	string s; cin >>s;
	bool ok=false;
	if(s[0]==s[1]&&s[2]==s[3]&&s[2]!=s[1])ok=true;
	if(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1])ok=true;
	if(s[0]==s[3]&&s[2]==s[1]&&s[0]!=s[1])ok=true;
	cout << (ok?"Yes":"No") << endl;
}

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {

    string s;
    cin >> s;

    int cont0 = 0, cont1 = 0;
    for ( auto l : s ) {
        if ( l == '1' ) cont1++;
        else cont0++;
    }

    cout << 2 * min(cont0, cont1) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N;
    cin>>N;
    cout<<(N-N%3)/3<<endl;
    return 0;
}

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


        signed main() {
        int n,m,t;
        cin>>n>>m;
        string a[n],b[m];
        for(int i=0;i<n;i++)cin>>a[i];
        for(int i=0;i<m;i++)cin>>b[i];
        for(int i=0;i<=n-m;i++){
           for(int j=0;j<=n-m;j++){
               t=1;
                for(int k=0;k<m;k++){
                    if(a[i+k].substr(j,m)!=b[k])t=0;
                }
                if(t){
                    cout<<"Yes";
                    return 0;
                }
           }
        }
        cout<<"No";
         return 0;

        }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    int H, W; cin >> H >> W;
    vector<string> grid(H);
    for (int h = 0; h < H; h++) {
        cin >> grid[h];
    }
    int L[H][W], R[H][W], U[H][W], D[H][W];
    int ans = 0;
    int h_l, w_l, h_r, w_r, h_u, w_u, h_d, w_d;
    for (int i = 0; i < H * W; i++) {
        h_l = i / W; w_l = i % W;
        h_r = i / W; w_r = W-1 - i % W;
        h_u = i % H; w_u = i / H;
        h_d = H-1 - i % H; w_d = i / H;
        if (grid[h_l][w_l] == '#') L[h_l][w_l] = 0;
        else if (w_l == 0) L[h_l][w_l] = 1;
        else L[h_l][w_l] = L[h_l][w_l-1] + 1;

        if (grid[h_r][w_r] == '#') R[h_r][w_r] = 0;
        else if (w_r == W-1) R[h_r][w_r] = 1;
        else R[h_r][w_r] = R[h_r][w_r+1] + 1;

        if (grid[h_u][w_u] == '#') U[h_u][w_u] = 0;
        else if (h_u == 0) U[h_u][w_u] = 1;
        else U[h_u][w_u] = U[h_u-1][w_u] + 1;

        if (grid[h_d][w_d] == '#') D[h_d][w_d] = 0;
        else if (h_d == H-1) D[h_d][w_d] = 1;
        else D[h_d][w_d] = D[h_d+1][w_d] + 1;
    }
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            ans = max(ans, L[h][w] + R[h][w] + U[h][w] + D[h][w] - 3);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {

	int n; cin >> n;
	vector<string> c(n);
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	const int p = 26;
	vector<vector<int>> num(n, vector<int>(p, 0));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < c[i].size(); j++) {
			num[i][c[i][j] - 'a']++;
		}
	}
	vector<bool> use(p, true);
	for (int j = 0; j < p; j++) {
		for (int i = 0; i < n; i++) {
			if (num[i][j] == 0) {
				use[j] = false;
			}
		}
	}
	vector<int> extraction(p, 10000);
	for (int j = 0; j < p; j++) {
		if (!use[j]) continue;
		for (int i = 0; i < n; i++) {
			extraction[j] = min(extraction[j], num[i][j]);
		}
	}
	string ans = "";
	for (int j = 0; j < p; j++) {
		int cnt = extraction[j];
		if (cnt == 10000) continue;
		while (cnt--) {
			ans += (char)('a' + j);
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
int x[100000],y[100000];
signed main(){
	int n,m;
	cin>>n>>m;
	f(i,m) cin>>x[i];
	sort(x,x+m);
	for(int i=1;i<m;i++){
		y[i-1]=x[i]-x[i-1];
	}
	sort(y,y+m-1);
	int sum=0;
	for(int i=m-2;i>=max((int)(0),m-n);i--){
		sum+=y[i];
	}
	cout<<x[m-1]-x[0]-sum<<endl;
	return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
import collections
import math


def C(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N = int(input().split()[0])
a_list = list(map(int, input().split()))
cumsum_list = [0]
for i, a in enumerate(a_list):
    idx = i + 1
    c = cumsum_list[idx - 1] + a
    cumsum_list.append(c)

counter = collections.Counter(cumsum_list)
total = 0
for k, v in counter.items():
    if v > 1:
        total += C(v, 2)

ans = total
print(ans)


Measured memory_bytes: 41700
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> v(n);
  fore(i, 0, n) cin >> v[i];
  int res = 0;
  fore(i, 0, n) res = (res ^ v[i]);
  fore(i, 0, n) cout << (res ^ v[i]) << (char)(i + 1 == n ? 10 : 32);

  return 0;
}

Measured memory_bytes: 3988
#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<ll, ll>;

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

	ll b[n] = {};
	rep( i, (n - 1) ) {
		ll a;
		cin >> a;

		b[a - 1]++;
	}

	rep( i, n ) {
		cout << b[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 5188
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, n);
  vector<int> a(n);
  for (auto& e : a) cin >> e;

  int now = 1;
  int ans = 0;
  for (auto e : a) {
    if (e != now)
      ans++;
    else
      now++;
  }
  cout << (ans == sz(a) ? -1 : ans) << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

int main(void) {

  int n, q;
  cin >> n >> q;
  int s, t, x;
  vector< pair<int, pair<int, int> > > event;
  rep(i, n) {
    cin >> s >> t >> x;
    event.push_back(make_pair(s - x, make_pair(-2, x)));
    event.push_back(make_pair(t - x - 1, make_pair(0, x)));
  }
  int D;
  rep(i, q) {
    cin >> D;
    event.push_back(make_pair(D, make_pair(-1, i)));
  }

  sort(event.begin(), event.end());
  /*rep(i, event.size()) {
    cout << event[i].first << " " << event[i].second.first << " " << event[i].second.second << endl;
  }*/

  int i = 0;
  set<int> c;
  vector<int> ans(q);
  while (i < event.size()) {
    int d = event[i].second.first;
    int y = event[i].second.second;
    int z = event[i].first;
    if (d == -2) c.insert(y);
    else if (d == 0) c.erase(y);
    else {
      if (c.empty()) ans[y] = -1;
      else ans[y] = *(c.begin());
    }
    i++;
  }
  rep(i, q) cout << ans[i] << endl;
}


Measured memory_bytes: 19432
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    int mini_1 = min(a, b);
    int mini_2 = min(c,d);
    
    cout << mini_1 + mini_2 << endl;
}

Measured memory_bytes: 256
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
#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)
typedef long long ll;

vector<int> g[10000+5];
ll cs[10000+5];
int ds[10000+5];
ll vs[10000+5];
struct K {
  int i;
  int d;
};
bool operator>(const K& k1, const K& k2) {
  return k1.d > k2.d;
}

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n-1) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
    ds[a]++;
    ds[b]++;
  }
  REP(i, n) {
    scanf("%lld", &cs[i]);
  }
  sort(cs, cs+n);
  ll sum = 0;
  REP(i, n) {
    sum += cs[i];
  }

  priority_queue<K, vector<K>, greater<K> > q;
  REP(i, n) {
    q.push((K){i, ds[i]});
  }
  memset(vs, -1, sizeof vs);
  int ci = 0;
  while(!q.empty()) {
    K cur = q.top(); q.pop();
    if(vs[cur.i] >= 0) {
      continue;
    }
    vs[cur.i] = cs[ci++];
    for(int next : g[cur.i]) {
      q.push((K){next, --ds[next]});
    }
  }
  printf("%lld\n", sum - cs[n-1]);
  REP(i, n) {
    printf("%lld%c", vs[i], i == n-1 ? '\n' : ' ');
  }
  
  return 0;
}


Measured memory_bytes: 1408
n, m = [int(x) for x in input().split()]
food_list = [0 for x in range(m)]
 
for i in range(n):
  s = [int(x) for x in input().split()]
  k = s[0]
  e = s[1:]
  for j in range(k):
    food_list[e[j]-1] += 1

ans = 0

for i in range(m):
  if food_list[i] == n:
    ans += 1
print(ans)

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

int main()
{
    int h,w;
    cin >> h >> w;
    char s[h][w];
    for(int i=0; i<h; i++){
        cin >> s[i];
        //cout << s[i] << endl;
    }
    
    int l[h][w],r[h][w],u[h][w],d[h][w];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(s[i][j] == '#'){
                l[i][j] = 0;
                u[i][j] = 0;
            }else{
                if(j == 0){
                    l[i][j] = 1;
                }else{
                    l[i][j] = l[i][j-1] + 1;
                }
                if(i == 0){
                    u[i][j] = 1;
                }else{
                    u[i][j] = u[i-1][j] + 1;
                }
            }
        }
    }
    for(int i=h-1; i>=0; i--){
        for(int j=w-1; j>=0; j--){
            if(s[i][j] == '#'){
                r[i][j] = 0;
                d[i][j] = 0;
            }else{
                if(j == w-1){
                    r[i][j] = 1;
                }else{
                    r[i][j] = r[i][j+1] + 1;
                }
                if(i == h-1){
                    d[i][j] = 1;
                }else{
                    d[i][j] = d[i+1][j] + 1;
                }
            }
        }
    } 
    
    int ans = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(s[i][j] == '#') continue;
            int tmp = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3;
            //cout << i << "," << j << ":" << tmp << endl;
            ans = std::max(ans, tmp);
        }
    }
    
    cout << ans << endl; 
    return 0;
}

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

int main() {
  int A,B,sum;
  cin >> A >> B;
  
  for(int i=A; i<=B; i++){
  	if((i/10000==i%10)&&(i/1000%10==i/10%10))
      sum++;
  }
    
    cout << sum << endl;
  
}

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

int main()
{
    string temp = "";
    cin >> temp;

    for (int i = 0; i < temp.size() - 1;i++)
    {
        if(temp[i]=='A'&&temp[i+1]=='C')
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            IO io = new IO();

            //ここから
            int d = io.ReadLineToInt();
            string s = "Christmas";
            for(int i = 0; i < 25 - d; i++)
            {
                s += " Eve";
            }
            //ここまで
            Console.Write(s);
            Console.ReadKey();
        }
    }

    //関数
    public class Func
    {
        public void Swap<T>(ref T a,ref T b)
        {
            T temp;
            temp = a;
            a = b;
            b = temp;
        }
    }

    //IOを担う関数群
    public class IO
    {
        //stringの入力
        public string ReadLineToString()
        {
            return Console.ReadLine();
        }

        //intの入力
        public int ReadLineToInt()
        {
            return int.Parse(Console.ReadLine());
        }

        //空白区切りの複数の文字列の入力をstring[]にして返す
        public string[] ReadLineToStringArray()
        {
            return Console.ReadLine().Split(' ').ToArray();
        }


        //空白区切りの複数の整数の入力をint[]にして返す
        public int[] ReadLineToIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        //空白区切りの複数の文字列の入力をList<string>で受け取る
        public List<string> ReadLineToStringList()
        {
            return Console.ReadLine().Split(' ').ToList();
        }

        //空白区切りの複数の整数の入力をList<int>で受け取る
        public List<int> ReadLineToIntList()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }

}


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

Measured memory_bytes: 35924
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  int N; cin >> N;
  int tmax = 0;
  int t[N+2]; FOR(i,0,N) cin >> t[i+1], tmax += t[i+1];
  int v[N+2]; FOR(i,0,N) cin >> v[i+1];
  v[0] = v[N+1] = 0;
  t[0] = t[N+1] = 0;
  double l[2*tmax+1], r[2*tmax+1];
  l[0] = 0;
  r[2*tmax] = 0;
  CLR(l);CLR(r);
  int i = 1;
  int T = 0;
  FOR(k,0,N+1) {
    T += t[k];
    while(i <= (T + t[k+1]) * 2) {
      l[i] = min(l[i-1] + 0.5, (double)v[k+1]);
      i++;
    }
  }
  T = 0;
  i = 1;
  for(int k = N + 1; k > 0; k--) {
    T += t[k];
    while(i <= (T + t[k-1]) * 2) {
      r[2 * tmax - i] = min(r[2 * tmax - i + 1] + 0.5, (double)v[k-1]);
      i++;
    }
  }
  // FOR(i,0,tmax+1) cout << l[i] << " " << r[i] << endl;
  double ans = 0;
  FOR(i,0,2*tmax) {
    ans += (min(l[i], r[i]) + min(l[i], r[i])) * 0.25;
  }
  printf("%.10lf\n", ans);
  return 0;
}

Measured memory_bytes: 896
#include<stdio.h>

void trace(int A[], int N) {
  int i;
  for (i = 0; i < N; i++) {
    if (i > 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void insertionSort(int A[], int N) {
  int j, i, v;
  for (i = 1; i < N; i++) {
    v = A[i];
    j = i -1;
    while(j >= 0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    trace(A, N);
  }
}

int main() {
  int N, i, j;
  int A[100];

  scanf("%d", &N);
  for(i = 0; i < N; i++) scanf("%d", &A[i]);

  trace(A, N);
  insertionSort(A, N);

  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
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 long long INF = 1LL << 60;

int main(){
  ll a, b;
  cin >> a >> b;
  if((a+b)%2!=0){
    cout << "IMPOSSIBLE" << endl;
  }
  else{
    cout << (a + b) / 2 << endl;
  }
}

Measured memory_bytes: 256
function*stdinIter(){const t=require("fs").readFileSync("/dev/stdin","utf-8").trim().split(/\n|\s/);yield*t}function readMany(t,e){const i=e||this.iter||(this.iter=stdinIter()),n=[];for(let e=0;e<t;e+=1)n.push(i.next().value);return n};

(() => {
    const [ n ] = readMany(1).map(it => parseInt(it))
    const a = readMany(n).map(it => parseInt(it))
    const [ q ] = readMany(1).map(it => parseInt(it))
    const queries = []
    for (let i = 0; i < q; i += 1) {
        queries.push(readMany(2).map(it => parseInt(it)))
    }

    const map = {}
    let sum = 0
    for (let i = 0; i < n; i += 1) {
        if (a[i] in map) {
            map[a[i]] += 1
        } else {
            map[a[i]] = 1
        }
        sum += a[i]
    }

    for (let i = 0; i < q; i += 1) {
        const [ b, c ] = queries[i]

        sum += (c - b) * (map[b] || 0)

        if (c in map) {
            map[c] += map[b] || 0
        } else {
            map[c] = map[b] || 0
        }
        map[b] = 0

        console.log(sum)
    }

})()


Measured memory_bytes: 106136
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b;
	cin>>a>>b;
	cout<<(a+b)%24<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include<vector>

using namespace std;

int main(){
	int n;
	cin >> n;
	long long sum = 0;
	for (int i = 1; i <= n; i++) {
		int a;
		if (i % 5 == 0 || i % 3 == 0) {
			a = 0;
		}
		else {
			a = i;
		}
		sum += a;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<algorithm>
#define ll long long
using namespace std;
ll  b[200100];
int main()
{
    ll h,a;
    scanf("%lld%lld",&h,&a);
    for(ll i=0; i<h; i++)
    {
        scanf("%lld",&b[i]);
    }
    sort(b,b+h);
    if(h<=a)
    {
        printf("0\n");
    }
    else
    {
       ll sum=0;
        for(int i=0; i<h-a; i++)
        {
            sum+=b[i];
        }
        printf("%lld\n",sum);
    }

    return 0;
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	X, Y := nextInt(), nextInt()
	x_mult2 := 4*X - Y
	y_mult2 := Y - 2*X
	if x_mult2 < 0 || y_mult2 < 0 || x_mult2%2 == 1 || y_mult2%2 == 1 {
		fmt.Fprintln(out, "No")
	} else {
		fmt.Fprintln(out, "Yes")
	}
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
  int X;
  cin >> X;
  int f = false;
  if(X >= 2000) {
    f = true;
  } else {
    int c = X / 100;
    X %= 100;
    f = X <= c * 5;
  }
  cout << f << endl;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, k;
  std::cin >> n >> k;

  std::vector<double> p(n);

  for (int64_t i = 0; i < n; i++) {
    double pi;
    std::cin >> pi;
    p[i] = (pi + 1) / 2;
  }

  double current = summation(p.cbegin(), std::next(p.cbegin(), k));
  double ans = current;

  for (int64_t i = k; i < n; i++) {
    current += p[i] - p[i - k];
    ans = std::max(ans, current);
  }

  std::cout << std::fixed << std::setprecision(10) << ans << std::endl;

  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>

#define INF 100100100
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main(){
    string s; cin >> s;
    string t = s;
    
    reverse(t.begin(), t.end());
    
    int n = s.size();
    int ans = 0;
   
    for(int i=0; i<=n/2-1; i++){
            if(s[i] != t[i]) ans++;
       
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256