akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const long long int Inf = 10000000000LL;

int main() {
    int v, e;
    cin >> v >> e;
    long long int g[v][v];

    for (int i = 0; i < v; ++i) {
        for (int j = 0; j < v; ++j) {
            g[i][j] = Inf;
        }
        g[i][i] = 0;
    }
    for (int i = 0; i < e; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        g[s][t] = d;
    } 
    for (int k = 0; k < v; ++k) {
        for (int i = 0; i < v; ++i) {
            for (int j = 0; j < v; ++j) {
                if (g[i][k] != Inf && g[k][j] != Inf) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
    for (int i = 0; i < v; ++i) {
        if (g[i][i] < 0) {
                cout << "NEGATIVE CYCLE" << endl;
                return 0;
        }
    }

    for (int i = 0; i < v; ++i) {
        for (int j = 0; j < v; ++j) {
            if (g[i][j] == Inf) {
                cout << "INF";
            } else {
                cout << g[i][j];
            }
            if (j == v - 1) {
                cout << endl;
            } else {
                cout << " ";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3216
#coding:utf-8
n,k = map(int,input().split())
d = dict()
d['s'],d['p'],d['r'] = map(int,input().split())
T = list(input())
ans = 0
for i in range(len(T)):
    if (i-k >= 0 and T[i-k]==T[i]):
        T[i] = "*"
    else:
        ans += d[T[i]]

print (ans)



Measured memory_bytes: 4084
n, m, q = map(int, input().split())
plist = []
for _ in range(q):
    plist.append(list(map(int, input().split())))

alist = []


def bfs(depth: int, l: list):
    global n, m, alist
    if depth == n:
        alist.append(l[1:])
        return
    c = l[depth]
    cl = l.copy()
    cl.append(c)
    bfs(depth+1, cl)
    while c < m:
        c += 1
        cl = l.copy()
        cl.append(c)
        bfs(depth + 1, cl)


bfs(0, [1])
pmax = 0
for a in alist:
    point = 0
    for p in plist:
        if (a[p[1]-1] - a[p[0]-1] == p[2]):
            point += p[3]
    pmax = max(pmax, point)

print(pmax)


Measured memory_bytes: 88988
//ac(2:54 + 15:34 + 21:30 = 38:00)
/*

dp[l][r] = Min. possible cost in joining slimes a[l, l+1, ..., r] and making it into 1 slime.

dp[l][r] = min(dp[l][i]+dp[i+1][r]+pre[r]-pre[l]+a[l], l<=i<r)

dp[i][i+1] = a[i]+a[i+1]
dp[i][i] = 0
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ull INF = 1e17;
const ll MDO = 1e9+7;

int main(){
	int n;
	vector<ull> a, pre;
	vector<vector<ull> > dp;
	cin>>n;
	a.assign(n+1, 0);
	pre.assign(n+1, 0);
	dp.assign(n+1, vector<ull>(n+1, 0));
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	pre[0] = a[0];
	for(int i=1;i<n;i++){
		pre[i] = pre[i-1]+a[i];
	}
	for(int l=n-1;l>=0;l--){
		for(int r=0;r<n;r++){
			if(l==r)
				continue;
			ull mini = INF;
			for(int i=l;i<r;i++){
				mini = min(mini, dp[l][i]+dp[i+1][r]+pre[r]-pre[l]+a[l]);				
			}
			dp[l][r] = mini;
		}
	}
	cout<<dp[0][n-1]<<"\n";
	return 0;
}

Measured memory_bytes: 1536
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val s = sc.next
    var dp = new Array[Int](13)
    var dpn = new Array[Int](13)

    // 初期化(最初は余りは「0」)
    dp(0) = 1

    for (c <- s.toCharArray) {
      dpn = new Array[Int](13)
      // 桁上げ処理
      for (i <- 0 to 12) {
        dpn((i*10)%13) = dp(i)
      }
      dp = dpn
      dpn = new Array[Int](13)

      // 固定値なら値に応じてシフト
      if (c != '?') {
        val v = c.asDigit
        for (i <- 0 to 12) {
          dpn((i+v)%13) += dp(i)
        }
      }
      // ?なら値を0-9とみなしてそれぞれシフト
      else {
        for (v <- 0 to 9) {
          for (i <- 0 to 12) {
            dpn((i+v)%13) += dp(i)
            dpn((i+v)%13) %= 1000000007
          }
        }
      }
      dp = dpn
    }
    println(dp(5))
    //println(dp.deep)
  }
}


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

namespace ConsoleApp11
{
    class Class80
    {
        static void Main()
        {
            string A = Console.ReadLine();
            string B = Console.ReadLine();
            if(A.Length>B.Length)
            {
                Console.WriteLine("GREATER");
                return;
            }
            else if (A.Length < B.Length)
            {
                Console.WriteLine("LESS");
                return;
            }
            else
            {
                if (int.Parse(A[0].ToString()) > int.Parse(B[0].ToString()))
                {
                    Console.WriteLine("GREATER");
                    return;
                }
                else if (int.Parse(A[0].ToString()) < int.Parse(B[0].ToString()))
                {
                    Console.WriteLine("LESS");
                    return;
                }
                else
                {
                    Console.WriteLine("EQUAL");
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n;
  cin >> n;
  vector<ll> a(n), b(n+1);
  for(ll i = 0; i < n+1; i++) cin >> b[i];
  for(ll i = 0; i < n; i++) cin >> a[i];
  
  ll ans = 0;
  for(ll i = 0; i < n; i++){
    if(b[i] <= a[i]){
      ans += b[i];
      a[i] -= b[i];
      if(b[i+1] <= a[i]){
        ans += b[i+1];
        b[i+1] = 0;
      }else{
        ans += a[i];
        b[i+1] -= a[i];
      }
    }else{
      ans += a[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ls (o << 1)
#define rs (o << 1 | 1)
#define mid ((L + R) >> 1)
using namespace std;
typedef long long LL;
const int N = 200500;
const int mod = 998244353;
unordered_map<int, int> dp, fp;
int main() {
#ifdef TEST
	freopen("input.txt", "r", stdin);
#endif
	int n, m;
	scanf("%d%d", &n, &m);
	dp[0] = 0;
	while (n--) {
		int u, v;
		scanf("%d%d", &u, &v);
		fp.clear();
		for (auto &i : dp) {
			fp[i.first] = max(fp[i.first], i.second);
			if (i.first + u <= m) {
				fp[i.first + u] = max(fp[i.first + u], i.second + v);
			}
		}
		swap(dp, fp);
	}
	int ans = 0;
	for (auto &i : dp) ans = max(ans, i.second);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>

using namespace std;

int N, M;

int main() {
	int ans = 0;
	cin >> N >> M;
	vector<int> num(N, -1);//[0][1][2]
	for (int i = 0; i < M; i++) {
		int s, c;
		cin >> s >> c;
		s--;
		if (num[s] != -1 && num[s] != c) {
			ans = -1;
		}
		else if (num[s] == -1) {
			num[s] = c;
			if (N != 1 && s == 0 && c == 0) { ans = -1; }
		}
	}
	if (ans == -1) {
		cout << ans << endl;
	}
	else if (N == 1 && M == 0) {
		cout << 0 << endl;
	}
	else {
		for (int i = 0; i < N; i++) {
			if (num[i] == -1) {
				if (i == 0) { num[i] = 1; }
				else { num[i] = 0; }
			}
		}
		int now = 1;
		for (int i = N - 1; i >= 0; i--) {
			ans += now * num[i];
			now *= 10;
		}
		//ans = num[0] * 100 + num[1] * 10 + num[2];
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define pb push_back
#define ll long long
using namespace std;
const int nmax=101234;

int n,x,y;
ll dp[2][nmax];
vector<vector<int> > v2(nmax);

void dfs(int s,int f){
    for(int i=0;i<v2[s].size();++i){
        if(v2[s][i]!=f){
            dfs(v2[s][i],s);
        }
    }
    for(int i=0;i<v2[s].size();++i){
        if(v2[s][i]!=f){
            dp[1][s]=dp[1][s]*dp[0][v2[s][i]]%MOD;
            dp[0][s]=(dp[0][v2[s][i]]+dp[1][v2[s][i]])*dp[0][s]%MOD;
        }
    }
}

int main()
{
    scanf("%d",&n);
    for(int i=1; i<n; ++i){
        scanf("%d %d",&x,&y);
        v2[x].pb(y);
        v2[y].pb(x);
        dp[1][i]=dp[0][i]=1;
    }
    dp[1][n]=dp[0][n]=1;
    dfs(1,0);
    printf("%lld",(dp[1][1]+dp[0][1])%MOD);
    return 0;
}


Measured memory_bytes: 11520
#include <stdio.h>
int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！

    
   int a,b,c;

    scanf("%d %d %d",&a,&b,&c);
   if(a+b>=c){
       puts("Yes");
   }else{
       puts("No");
   }

   
    
    return 0;
}

Measured memory_bytes: 1628
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n, m;
    cin >> n >> m;
    int a[n];
    int sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }

    int cnt = 0;
    rep(i,n){
        if(a[i] * 4 * m >= sum)cnt++;
    }

    if(cnt >= m)yn;
    
    return 0;
}
 
 


Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
ave = (a + b) / 2

if c >= ave:
    ans = a * x + b * y
else:
    temp1 = c * max(x, y) * 2
    temp2 = c * min(x, y) * 2 + a * (x - min(x, y)) + b * (y - min(x, y))
    ans = min(temp1, temp2)
    
print(ans)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

ll dp[100005];

void Main() {
    int N, M;
    cin >> N >> M;
    vector<bool> B(N + 1, false);
    rep(i, M) {
        int a;
        cin >> a;
        B[a] = true;
    }
    dp[0] = 1;
    rep(i, N) {
        if (!B[i + 1]) {
            dp[i + 1] += dp[i];
            dp[i + 1] %= MOD;
        }
        if (i + 2 <= N && !B[i + 2]) {
            dp[i + 2] += dp[i];
            dp[i + 2] %= MOD;
        }
    }
    cout << dp[N] << endl;


}

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


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

using namespace std; 

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

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

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

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

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

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


void Main()
{
    double r;cin>>r;

    cout<<(2*r)*M_PI<<endl;
    
	return;
}

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

Measured memory_bytes: 3804
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n;
  cin>>n;
  
  vector<int> p(n);
  vector<int> q(n);
  vector<int> r(n); 
  
  cin>>p[0]>>q[0]>>r[0];
  
  if((p[0]+q[0]+r[0])%2!=0 || p[0]<(q[0]+r[0])) {
    cout << "No" << endl; 
    return 0;
  }
  
  repo(i,n){
    cin>>p[i]>>q[i]>>r[i];
    if((p[i]-p[i-1]+q[i]-q[i-1]+r[i]-r[i-1])%2!=0 ||
       (p[i]-p[i-1])<(q[i]-q[i-1]+r[i]-r[i-1])||
       (p[i]-p[i-1])<(q[i-1]-q[i]+r[i-1]-r[i])) {
      cout << "No" << endl; 
      return 0;
    }  
  }
  
  cout << "Yes" << endl;
  
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;


int main(){
    int H, W; cin >> H >> W;
    vector<string> S(H);
    for(int i = 0; i < H; i++) cin >> S[i];
    int ans = 0;
    vector<vector<int>> U(H, vector<int>(W)), D(H, vector<int>(W)), L(H, vector<int>(W)), R(H, vector<int>(W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(j == 0){
                if(S[i][j] == '.') L[i][j] = 1;
                else L[i][j] = 0;
            }
            else{
                if(S[i][j] == '.') L[i][j] = L[i][j-1]+1;
                else S[i][j] = 0;
            }

            if(i == 0){
                if(S[i][j] == '.') U[i][j] = 1;
                else U[i][j] = 0;
            }
            else{
                if(S[i][j] == '.') U[i][j] = U[i-1][j]+1;
                else U[i][j] = 0;
            }
        }
    }

    for(int i = H-1; i >= 0; i--){
        for(int j = W-1; j >= 0; j--){
            if(j == W-1){
                if(S[i][j] == '.') R[i][j] = 1;
                else R[i][j] = 0;
            }
            else{
                if(S[i][j] == '.') R[i][j] = R[i][j+1]+1;
                else R[i][j] = 0;
            }

            if(i == H-1){
                if(S[i][j] == '.') D[i][j] = 1;
                else D[i][j] = 0;
            }
            else{
                if(S[i][j] == '.') D[i][j] = D[i+1][j]+1;
                else D[i][j] = 0;
            }
        }
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            int u=U[i][j], d = D[i][j], l = L[i][j], r=R[i][j];
            if(u>0) u--;
            if(d>0) d--;
            if(l>0) l--;
            if(r>0) r--;
            ans = max(ans, u+d+r+l+1);
            //cout << i << " " << j << " " << U[i][j]+D[i][j]+R[i][j]+L[i][j]-4 << endl;
        }
    }
    cout << ans << endl;
}

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

#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);


int main(void) {

	char    S[4], s[4] = "abc";
	int     i, j;

	s_cin(S);
	for (i = 0; i < 3; i++) {
		for (j = 0; j < 3; j++) {
			if (S[i] == s[j]) {
				s[j] = 0x00; break;
			}
		}
		if (j==3) { No_RTN; }
	}
	Yes_RTN;
}
	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	rept(i, 0, n) {
		i_cin(*(a + i));
	}

	return 0;
}



Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <tuple>
#include <vector>
using namespace std;

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }

struct node_t {
	shared_ptr<node_t> left_child, right_child;

	inline bool is_leaf() const {
		return left_child == nullptr;
	}

	node_t(const shared_ptr<node_t> &l = nullptr, const shared_ptr<node_t> &r = nullptr):
		left_child(l), right_child(r) {}
};

constexpr int MAX_S = 6;

typedef array<vector<shared_ptr<node_t>>, MAX_S + 1> T_array;
typedef tuple<int, double, double> result;
enum { WEIGHT, LEFT, RIGHT };

T_array init_trees() {
	T_array trees;

	trees[1].emplace_back(new node_t());

	for(int s = 2; s <= 6; ++s) {
		for(int l = 1; l < s; ++l) {
			const int r = s - l;

			for(const auto &p1 : trees[l]) {
				for(const auto &p2 : trees[r]) {
					trees[s].emplace_back(new node_t(p1, p2));
				}
			}
		}
	}

	return trees;
}

result dfs(const shared_ptr<node_t> &node, vector<int>::const_iterator &it) {
	if(node->is_leaf()) {
		const result res(*it, 0.0, 0.0);
		++it;
		return res;
	}

	const auto l_result = dfs(node->left_child, it);
	const auto r_result = dfs(node->right_child, it);

	const int weight = get<WEIGHT>(l_result) + get<WEIGHT>(r_result);

	const double left_pos = -static_cast<double>(get<WEIGHT>(r_result)) / weight;
	const double right_pos = static_cast<double>(get<WEIGHT>(l_result)) / weight;

	const double left = min(get<LEFT>(l_result) + left_pos, get<LEFT>(r_result) + right_pos);
	const double right = max(get<RIGHT>(l_result) + left_pos, get<RIGHT>(r_result) + right_pos);

	return result(weight, left, right);
}

void solve(const T_array &trees) {
	double r;
	int s;
	cin >> r >> s;

	vector<int> w(s);
	for(auto &e : w) cin >> e;

	sort(w.begin(), w.end());

	double ans = -1;
	do {
		for(const auto &root : trees[s]) {
			auto it = w.cbegin();
			const auto tmp = dfs(root, it);
			const double width = get<RIGHT>(tmp) - get<LEFT>(tmp);
			if(width < r) chmax(ans, width);
		}

	} while(next_permutation(w.begin(), w.end()));


	if(ans < 0) {
		cout << "-1" << endl;
	}
	else {
		cout << ans << endl;
	}
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);

	const auto trees = init_trees();

	int T;
	cin >> T;

	while(T--) solve(trees);

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1312
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int maxn = 300005;

int a[maxn];

int main() {
 // freopen("in.cpp","r",stdin);
  int n;
  cin>>n;
  n*=3;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  ll ret=0;
  int m=n/3;
  for(int i=n-1;m;i-=2){
    ret+=a[i-1];
    m--;
  }
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool compare(pair<long long int,long int> a,pair<long long int,long int> b)
{
    return a.second<b.second;
}
int main()
{
    long long int a,b,c,d;
    cin>>a>>b>>c>>d;
    long long int ans=0;
    long long int kk=(c*d)/(__gcd(c,d));
    ans=(b/c)-((a-1)/c)+(b/d)-((a-1)/d)-(b/(kk))+((a-1)/(kk));
    ans=(b-a+1)-ans;
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s;
  R s;
  ll x=0;
  rep(i,s.size()) {
    if(s[i]=='+') x++;
    else x--;
  }
  pr(x);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
   /* #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    
    

    
    ll n;
    cin>>n;
    vi v;
    while(n>0)
    {
        if(n%10==1)
            {
                //cout<<9;
                v.pb(9);
                n/=10;
            }
        else
           { 
            //cout<<1;
            v.pb(1);
            n/=10;
        }

     //n/=10;
    }
    for(int i=v.size()-1;i>=0;i--)
    {
        cout<<v[i];
    }

}
return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7

n,k = map(int,input().split())
graph = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

def dfs(now,pre):
    available_color = 0  # 子ノードに使用可能な色の数
    if pre == -1:
        available_color = k-1
    else:
        available_color = k-2
    if k < len(graph[now]):
        return 0
    res = 1
    for son in graph[now]:
        if son == pre:continue
        res *= available_color
        available_color -= 1
        res %= MOD
    for son in graph[now]:
        if son == pre:continue
        res *= dfs(son,now)
        res %= MOD

    return res

ans = (k*dfs(0,-1)) % MOD
print(ans)

Measured memory_bytes: 152240
#include<stdio.h>
int n,t,A[101][101],d[101],f[101],C[101];
   
void DFS(int u)
{
  int i;
  C[u]=1;
  d[u]=++t;
  for(i=0;i<n;i++){
    if(A[u][i]==1){
      if(C[i]==0)DFS(i);
    }
  }
  C[u]=2;
  f[u]=++t;
}
  
int main()
{
  int i,j,k,v,w;
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    C[i]=0;
    for(j=0;j<n;j++){
      A[i][j]=0;
    }
  }
  t=0;
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&k);
    for(j=0;j<k;j++){
      scanf("%d",&w);
      A[v-1][w-1]=1;
    }
  }
  for(i=0;i<n;i++){
    if(C[i]==0)DFS(i);
  }
  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  return 0;
}

Measured memory_bytes: 636
import java.util.*;

class Main{

    Main(){
        Scanner SC = new Scanner(System.in);

        int X = Integer.parseInt(SC.next());
        int Y = Integer.parseInt(SC.next());
        int A = Integer.parseInt(SC.next());
        int B = Integer.parseInt(SC.next());
        int C = Integer.parseInt(SC.next());

        TreeMap<Integer, Integer> P, Q, R;
        P = new TreeMap<>();
        Q = new TreeMap<>();
        R = new TreeMap<>();

        for (int i = 0; i < A; i++) {
            int IN = Integer.parseInt(SC.next());
            P.put(IN, P.getOrDefault(IN ,0)+1);
        }
        for (int i = 0; i < B; i++) {
            int IN = Integer.parseInt(SC.next());
            Q.put(IN, Q.getOrDefault(IN ,0)+1);
        }
        for (int i = 0; i < C; i++) {
            int IN = Integer.parseInt(SC.next());
            R.put(IN, R.getOrDefault(IN ,0)+1);
        }

        long Ans = 0L;
        int limitN = X+Y;
        int pMax, qMax, rMax;
        while (limitN > 0){
            if (X != 0){
                pMax = P.lastKey();
            } else {
                pMax = 0;
            }
            if (Y != 0){
                qMax = Q.lastKey();
            } else {
                qMax = 0;
            }
            if (!R.isEmpty()){
                rMax = R.lastKey();
            } else {
                rMax = 0;
            }

            if (rMax >= pMax && rMax >= qMax){
                Ans += rMax;

                if (R.get(rMax) != 1){
                    R.put(rMax, R.get(rMax)-1);
                } else {
                    R.remove(rMax);
                }
            } else if (pMax > qMax){
                Ans += pMax;
                X -= 1;

                if (P.get(pMax) != 1){
                    P.put(pMax, P.get(pMax)-1);
                } else {
                    P.remove(pMax);
                }
            } else {
                Ans += qMax;
                Y -= 1;

                if (Q.get(qMax) != 1){
                    Q.put(qMax, Q.get(qMax)-1);
                } else {
                    Q.remove(qMax);
                }
            }

            limitN -= 1;
        }

        System.out.println(Ans);
    }

    public static void main(String[] args){
        new Main();
    }
}


Measured memory_bytes: 78504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int a, b; cin >> a >> b;
    if(a % 3 && b % 3 && (a+b) % 3) cout << "Impossible" << endl;
    else cout << "Possible" << endl;
}

Measured memory_bytes: 256
[a,b,k]=[int(i) for i in input().split()]

c=int(k/2)

f=0
if k%2!=0:
    f=1

for i in range(c):
    if a%2!=0:
        a=a-1
    tempa=int(a/2)
    a=tempa
    b+=tempa

    if b%2!=0:
        b=b-1
    tempb=int(b/2)
    b=tempb
    a+=tempb

if f:
        if a%2!=0:
            a=a-1
        tempa=int(a/2)
        a=tempa
        b+=tempa

print(a, b)


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int H=stdIn.nextInt();
		int W=stdIn.nextInt();
		int N=stdIn.nextInt();
		int min=100000;
		for(int i=0;i<=H;i++){
			for(int j=0;j<=W;j++){
				int a=i*W;
				a+=(H-i)*j;
				if(a>=N&&i+j<min)
					min=i+j;
			}
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 21460
import java.util.Scanner


object Main {

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val x = sc.next()
    val isGood = x(0) != x(1) && x(1) != x(2) && x(2) != x(3)

    println(if(isGood) "Good" else "Bad")
  }
}

Measured memory_bytes: 27316
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
	t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])


Measured memory_bytes: 7748
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val ans = if (readStringList().distinct().size == 3) "Three" else "Four"
    out.println(ans)
}


fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 36464
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static int[][] rotate(int[][] a) {
		int n = a.length;
		int[][] res = new int[n][n];
		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++) {
				res[i][j] = a[j][n-1-i];
			}
		}
		return res;
	}

	static boolean solve() {
		int n = in.nextInt();
		int m = in.nextInt();
		if (n + m == 0) return false;

		int[][] w = new int[n][n];
		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++) {
				w[i][j] = in.nextInt();
			}
		}

		int[][] p = new int[m][m];
		for (int i=0; i<m; i++) {
			for (int j=0; j<m; j++) {
				p[i][j] = in.nextInt();
			}
		}

		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++) {
				for (int t=0; t<4; t++) {
					boolean f = true;

					for (int k=0; k<m; k++) {
						for (int l=0; l<m; l++) {
							if (i+k >= n || j+l >= n) {
								f = false;
								break;
							}
							if (p[k][l] == -1) continue;
							if (w[i+k][j+l] != p[k][l]) {
								f = false;
								break;
							}
						}
					}

					if (f) {
						for (int ai=0; ai<m; ai++) {
							for (int aj=0; aj<m; aj++) {
								if (p[ai][aj] != -1) {
									out.println((aj+j+1)+" "+(ai+i+1));
									return true;
								}
							}
						}
					}

					p = rotate(p);
				}
			}
		}

		out.println("NA");

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 292212
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<vint> v(n + 1, vint(n + 1, 0));

		rep(y, n) rep(x, n)
			cin >> v[y][x];


		int sum = 0;
		rep(y, n) 
		{
			rep(x, n)
			{
				v[y][n] += v[y][x];
				v[n][x] += v[y][x];
			}
		
			sum += v[y][n];
		}

		v[n][n] = sum;


		rep(y, n+1)	rep(x, n+1)
			printf("%5d%s", v[y][x], (n == x ? "\n" : ""));		
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <cstdlib>

using namespace std;

int func(int y, int m, int d);

int main()
{
	int n, m, p;
	while(1){
		cin >> n >> m >> p;
		if(n == 0 && m == 0 && p == 0) break;
		int a[100], sum = 0;
		for(int i = 0; i < n; i++){
			cin >> a[i];
			sum += a[i];
		}
		int b, c;
		b = sum * (100 - p);
		if (a[m-1] == 0) c = 0;
		else c = b / a[m-1];
		cout << c << endl;
	}
	return 0;
}

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

int main(void){
  int N,D,delta,temp,count;
  cin >> N >> D;
  vector<vector<int>> v(N,vector<int>(D));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> v.at(i).at(j);
    }
  }
  
  count=0;
  for (int i=0; i<N; i++){
  	for (int j=i+1; j<N; j++){
      delta = 0;
  	  for (int k=0; k<D; k++){
        temp=(v.at(i).at(k)-v.at(j).at(k));
        delta += temp*temp;
      }
  	  for (int k=0; k<200; k++){
        if(delta==k*k){
          count+=1;
          break;
        }
      }
  	}    
  }
  
  cout << count << endl;

}

Measured memory_bytes: 256
while True:
    H,W = map(int,input().split())
    if H==W==0:
        break
    for i in range(H):
        if i%2 == 0:
            for x in range(W):
                if x%2 == 0:
                    print("#", end="")
                else:
                    print(".",end="")
        else:
            for y in range(W):
                if y%2 == 0:
                    print(".",end="")
                else:
                    print("#",end="")
        print()
    print()



Measured memory_bytes: 7000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<a[k-1];
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
using namespace std;

int main() {
int a[3];
cin>>a[0]>>a[1]>>a[2];
sort(a,a+3);
if(a[0]==5&&a[1]==5&&a[2]==7){
	cout<<"YES"<<endl;
}else{
	cout<<"NO"<<endl;
}

}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B;
    for (int i = 0; i < N; i++) cin >> A[i];
    B = A;
    sort(B.begin(), B.end());
    int ans = 0;
    for (int i = 0; i < N; i += 2) {
        auto it = lower_bound(B.begin(), B.end(), A[i]);
        int t = distance(B.begin(), it);
        if (t%2 == 1) ans++;
    }
    cout << ans << endl;
}

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

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[][] arr = new int[n][2];

			for (int i = 0; i < n; i++) {
				arr[i][0] = sc.nextInt();
				arr[i][1] = sc.nextInt();
			}
			Arrays.sort(arr, (a, b) -> Integer.compare(a[1], b[1]));

			int timer = 0;
			for (int i = 0; i < n; i++) {
				timer += arr[i][0];
				if (arr[i][1] < timer) {
					System.out.println("No");
					return;
				}
			}
			System.out.println("Yes");
		}
	}
}


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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int T = sc.nextInt();
		int[] a = new int[T];

		for (int i = 0; i < T; i++) {
			a[i] = sc.nextInt();
		}

		Arrays.sort(a);

		for (int i = 0; i < T - 1; i++){
			a[T - 1] = a[T - 1] - a[T - 2];
			a[T - 2] = 0;
			Arrays.sort(a);
		}

		int ans = a[T-1] -1;

		if (ans <0)ans =0;

		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 10504
n=int(input())
a=list(map(int, input().split()))

a=[0]+a+[0]

cost=[abs(a[i]-a[i+1]) for i in range(len(a)-1)]
total=sum(cost)

ans=0
for i in range(n):
    ans = total - cost[i] - cost[i+1] + abs(a[i]-a[i+2])
    print(ans)


Measured memory_bytes: 14176
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
 #define PI 3.141592653
using namespace std;


void solve(){
	ll n; cin>>n;
	cout<<(n*(n-1))/2;


}


int main()
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed<<setprecision(12);
	int t =1; //cin>>t;
	for(int i=1; i<=t; i++){
		solve();
		cout<<"\n";
	}
	return 0;

}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    ll n;
    cin >> n;

    map<ll, ll> fact;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            fact[i]++;
            n /= i;
        }
    }
    if (n != 1) fact[n]++;

    ll ans = 0;
    for (auto [x, c] : fact) {
        int cur = 1;
        int total = 0;
        while (total + cur <= c) {
            total += cur;
            cur++;
        }
        ans += cur - 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3656
/**
 * Road to ROI
**/ 
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define forn for(int i=0;i<n;i++)
#define form for(int j=0;j<m;j++)
#define pb push_back
#define mp make_pair
#define sc second
#define f first
#define kek cout<<"\n"
#define all(v)        ((v).begin()), ((v).end())
#define pob pop_back()
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  string s;
  cin>>s;
  int n=s.size();
  string a,b;
  a=s;
  reverse(all(s));
  int ans=0;
  for(int i=0;i<n;i++)
  {
            if(a[i]!=s[i]) ans++;
  }
  cout<<ans/2;
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool k = 0;
    for(int i = 0; i < n-1; i++){
        if(s[i] == 'A' && s[i+1] == 'C'){
            k = 1;
        }
    }
    if(k == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a>=1&&b>=1&&c>=1&&d>=1&&a<=10&&b<=10&&c<=10&&d<=10)
	{if(a+b>c+d) printf("Left");
	if(a+b==c+d) printf("Balanced");
	if(a+b<c+d) printf("Right");
	}
	
	return 0;
	
 } 

Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 100005
#define ll long long
ll ans;
int n, m, S, T, A[N], siz[N];
int stk[N], top;
int tar[N << 1], nex[N << 1], fir[N], cnt;
bool odd;
void Add(int x, int y)
{
	++cnt;
	tar[cnt] = y;
	nex[cnt] = fir[x];
	fir[x] = cnt;
}
void Dfs1(int x, int fa)
{
	for (int i = fir[x]; i; i = nex[i])
	{
		int v = tar[i];
		if (v == fa)
			continue;
		if (siz[v])
		{
			if (siz[x] == siz[v])
				odd = 1;
			S = x, T = v;
		}
		else
		{
			siz[v] = -siz[x];
			Dfs1(v, x);
		}
	}
}
void Dfs2(int x, int fa)
{
	for (int i = fir[x]; i; i = nex[i])
	{
		int v = tar[i];
		if (v == fa || (x == S && v == T) || (x == T && v == S))
			continue;
		Dfs2(v, x);
		siz[x] += siz[v];
		A[x] += A[v];
	}
}
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		Add(x, y), Add(y, x);
	}
	siz[1] = 1, Dfs1(1, 0);
	int sum = 0;
	for (int i = 1; i <= n; i++)
		sum += siz[i];
	if (m == n - 1)
	{
		if (sum)
		{
			puts("-1");
			return 0;
		}
	}
	else
	{
		if (odd)
		{
			if (sum & 1)
			{
				puts("-1");
				return 0;
			}
			ans += abs(sum>>1);
			siz[S] -= sum >> 1;
			siz[T] -= sum >> 1;
		}
		else
		{
			if (sum)
			{
				puts("-1");
				return 0;
			}
			else
				A[S] = 1, A[T] = -1;
		}
	}
	Dfs2(1, 0);
	for (int i = 1; i <= n; i++)
	{
		if (A[i])
			stk[++top] = A[i] * siz[i];
		else
			ans += abs(siz[i]);
	}
	stk[++top] = 0;
	sort(stk + 1, stk + top + 1);
	int mid = stk[(top + 1) >> 1];
	for (int i = 1; i <= top; i++)
		ans += abs(stk[i] - mid);
	printf("%lld\n", ans);
}


Measured memory_bytes: 14572
#include <iostream>
using namespace std;
int main () {
//the variables below are the a,i,o,e.u decimal values from asci table.
//Declaration
char  z=97,x=101,c=105,v=111,b=117;
char n ;
//input
cin>>n;

//process
if (n==z){
  cout<<"vowel";
}else if (n==x){
  cout<<"vowel";
 }else if (n==c){
 cout<<"vowel";
 }else if (n==v){
     cout<<"vowel";
}else if(n==b){
    cout<<"vowel";
}else{
  cout<<"consonant";
}

return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int A, B, n[5], num, j = 0, count = 0;
	scanf("%d%d", &A, &B);
	for (int i = A; i <= B; i++) {
		num = i;
		j = 0;
		while (num > 0) {
			n[j] = num % 10;
			num /= 10;
			j++;
		}
		if (n[0] == n[4] && n[1] == n[3]) {
			count++;
		}
	}
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=4010,mod=924844033;
int n,K,f[N][N][2],g[N],Fac[N];bool vis[N][2],d[N];
int main(){
  scanf("%d%d",&n,&K);
  int tot=0;
  for(int i=1;i<=n;i++){
	  for(int j=0;j<2;j++){
		  if(vis[i][j])continue;
		  int t=0;
		  for(int x=i,y=j;x<=n;x+=K,y^=1)vis[x][y]=1,t++;
		  d[tot+=t]=1;
	  }
  }
  f[0][0][1]=1;
  for(int i=0;i<tot;i++){
	  for(int j=0;j<=i;j++){
		  f[i+1][j][0]=(1ll*f[i+1][j][0]+f[i][j][0]+f[i][j][1])%mod;
		  if(!d[i])f[i+1][j+1][1]=(f[i+1][j+1][1]+f[i][j][0])%mod;
	  }
  }
  for(int i=1;i<=n;i++)
	  g[i]=(f[tot][i][0]+f[tot][i][1])%mod;
  Fac[0]=1;
  for(int i=1;i<=n;i++)Fac[i]=1ll*Fac[i-1]*i%mod;
  int ans=Fac[n];
  for(int i=1;i<=n;i++)ans=(ans+1ll*(i&1?-1:1)*g[i]*Fac[n-i])%mod;
  if(ans<0)ans+=mod;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 123904
#include <iostream>
using namespace std;
#define fo(i, a, b) for (int i=a; i<(b); i++)

int main() {


	// int t; cin >> t; while (t--)

	long double a, b; cin >> a >> b;

	int64_t ans = a * b;

	cout << ans;

	return 0;
}

Measured memory_bytes: 3200
//??????????????§
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Queue[LEN];
int head,tail,n;

void enqueue(P x)
{
  Queue[tail] = x;
  tail = (tail + 1)%LEN;
}

P dequeue()
{
  P x= Queue[head];
  head = (head + 1)%LEN;
  return x;
}

int minimum(int x,int y){
  return x<y ? x: y;
}
int main()
{
  int laps =0;
  int c,i,q;
  P u;
  scanf("%d %d",&n,&q);

  for(i=1;i<=n;i++){
    scanf("%s",Queue[i].name);
    scanf("%d",&Queue[i].t);
  }
  head =1;
  tail = n +1;
  while(head != tail)
    {
      u=dequeue();
      c=minimum(q,u.t);
      u.t-=c;
      laps+=c;
      if(u.t >0)enqueue(u);
      else{
	printf("%s %d\n",u.name,laps);
      }
    }
  return 0;
}

  
 
  

Measured memory_bytes: 10756
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a + b >= 10) System.out.println("error");
		else System.out.println(a+b);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

struct Card{
    int value;
    char suit;
};

void BubbleSort(struct Card A[], int N){
    for(int i=0;i<N-1;i++){
        for(int j=N-1;j>i;j--){
            if(A[j].value<A[j-1].value) swap(A[j],A[j-1]);
        }
    }
}

void SelectionSort(struct Card A[], int N){
    for(int i=0;i<N;i++){
        int mi = i;
        for(int j=i+1;j<N;j++){
            if(A[j].value < A[mi].value) mi = j;
        }
        swap(A[i],A[mi]);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;cin>>N;
    Card a[100],b[100];
    int cnt=0;
    REP(i,N){
        cin>>a[i].suit>>a[i].value;
        b[i] = a[i];
    }
    BubbleSort(a,N);
    SelectionSort(b,N);
    REP(i,N) cout<<a[i].suit<<a[i].value<<(i<N-1?" ":"");
    cout<<endl;
    cout<<"Stable"<<endl;
    bool flg=true;
    REP(i,N){
        cout<<b[i].suit<<b[i].value<<(i<N-1?" ":"");
        if(a[i].suit!=b[i].suit) flg=false;
    }
    cout<<endl;
    if(flg) cout<<"Stable"<<endl;
    else cout<<"Not stable"<<endl;
}


Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
#define MAX 1001

int dp[MAX][MAX],t,w,m;
int Val[MAX],Wei[MAX];

void judge(){
    
    for(int i = 1 ; i <= m ; i++){
        for(int j = 1 ; j <= w ; j++){
            int k = j - Wei[i];
            if(k < 0){
                dp[i][j] = dp[i-1][j];
            }
            else{
                dp[i][j] = max(dp[i-1][j],dp[i-1][k]+Val[i]);
            }
        }
    }
    int ans_W=0,ans_C;
    for(int i = 1 ; i <= w ; i++){
        ans_W = max(ans_W,dp[m][i]);
    }
    for(int i = w ; i >= 1 ; i--){
        if(ans_W==dp[m][i]) ans_C = i;
    }
    
    cout << ans_W << endl;
    cout << ans_C << endl;
}

void print(){
    cout << "Case " << t++ << ":" << endl;
}

int main(){
    char c;
    
    t = 1;
    while(cin >> w,w){
        cin >> m;
        
        fill(dp[0],dp[MAX-1],0);
        Wei[0] = Val[0] = 0;
        
        print();
        for(int j = 1 ; j <= m ; j++) cin >> Val[j] >> c >> Wei[j];
        
        judge();
    }
    
    return 0;
}

Measured memory_bytes: 5080
#!/Users/takahiro.kida/git/atcorder/venv/bin/python

import numpy as np
import scipy

from collections import defaultdict
from pprint import pprint

N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    if A[i] == B[i] and B[i] == C[i]:
        pass
    elif A[i] == B[i] or B[i] == C[i] or C[i] == A[i]:
        ans += 1
    else:
        ans += 2
print(ans)


Measured memory_bytes: 21520