akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
p b.inject(:+) + (1...n).to_a.map{|i| a[i]==a[i-1]+1 ? c[a[i-1]-1] : 0}.inject(:+)

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

#define N 1000
#define W 1000
#define INF 10001

#define max(a,b) (a>b?a:b)

int main() {
	static int dp[N+1][W+1];
	int tw[N+1], tv[N+1];
	int w, n, mv, mw, c=0; char dummy;

	while(1) {
		cin >> w;
		if(!w) break;
		c++; mw = INF; mv = 0;
		for(int i=0; i<N+1; ++i) {
			for(int j=0; j<N+1; ++j) {
				dp[i][j] = 0;
			}
		}
		cin >> n;
		for(int i=1; i<=n; ++i) cin >> tv[i] >> dummy >> tw[i];
		for(int i=1; i<=n; ++i) {
			for(int j=0; j<=w; ++j) {
				if(j-tw[i]>=0) dp[i][j] = max(dp[i-1][j], dp[i-1][j-tw[i]]+tv[i]);
				else dp[i][j] = dp[i-1][j];
			}
		}
		for(int i=0; i<=w; ++i) {
			if(mv<dp[n][i]) {
				mw = i; mv = dp[n][i];
			}
		}
		cout << "Case " << c << ":" << endl;
		cout << mv << "\n" << mw << endl;
	}
	return 0;
}

Measured memory_bytes: 5080
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 998244353 
#define pb push_back
#define mb make_pair
int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n; cin >> n;
    cout << (n-2)*180 << endl;


    return 0;

}



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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
using ll = long long;
using P = pair<int,int>;

// code starts
#define max_n 200010
vector<int> par(max_n);
vector<int> ranks(max_n);
vector<int> sizes(max_n);

void init(int n)
{
  int i;
  rep(i,n)
  {
    par[i] = i;
    ranks[i] = 0;
    sizes[i] = 1;
  }
}

int find(int x)
{
  if(par[x] == x) return x;
  else return par[x] = find(par[x]); 
}

void unite(int x, int y)
{
  x = find(x);
  y = find(y);
  if(x == y)return;
  if(ranks[x] < ranks[y])
  {
    par[x] = y;
    sizes[y] += sizes[x];
  }
  else
  {
    par[y] = x;
    sizes[x] += sizes[y];
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

int sizing(int x)
{
  return sizes[find(x)];
}

bool same(int x,int y)
{
  return find(x) == find(y);
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	vector<int> b(m);
	init(n);
	int i;
	rep(i,m)
	{
		cin >> a[i] >> b[i];
		unite(a[i]-1, b[i]-1);
	}
	int ans = 0;
	rep(i,n)
	{
		ans = max(ans,sizes[i]);
		//cout << sizes[i] << endl;
	}
	cout << ans << endl;
}


Measured memory_bytes: 7212
H,W = map(int, input().split())
c = []
for i in range(10):
  c.append(list(map(int, input().split())))

A = []
for _ in range(H):
  A.append(list(map(int, input().split())))

for k in range(10):
  for i in range(10):
    for j in range(10):
      c[i][j] = min(c[i][j], c[i][k]+c[k][j])

res = 0
for a in A:
  for e in a:
    if e != -1 and e != 1:
      res += c[e][1]

print(res)

Measured memory_bytes: 40668
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n;
  scan(n);
  vi a(n+1);
  vi b(n);
  scan(a);
  scan(b);
  ll ans = 0;
  rep (i, n) {
    if (a[i] >= b[i]) {
      ans += b[i];
      continue;
    } else {
      ans += a[i];
      b[i] -= a[i];
      int ms = min(a[i+1], b[i]);
      ans += ms;
      a[i+1] -= ms;
    }
  }
  print(ans);

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 5000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
struct edge { int to, cost; };
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i*i <= x; i++) {
		while (x%i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
/*--------Library Zone!--------*/

int a[10];
signed main() {
	rep(i, 7)cin >> a[i];
	int ans1 = 0, ans2 = 0;
	ans1 += a[1]; ans2 += a[1];
	if (a[0] && a[3] && a[4]) {
		ans1 += 3;
		ans1 += (a[0] - 1) / 2 * 2 + (a[3] - 1) / 2 * 2 + (a[4] - 1) / 2 * 2;
	}
	ans2 += a[0] / 2 * 2 + a[3] / 2 * 2 + a[4] / 2 * 2;
	cout << max(ans1, ans2) << endl;
	endre;
}


Measured memory_bytes: 256
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, X = map(int, input().split())
A = list(map(int, input().split()))

D = 0
cnt = 0
while D <= X and cnt <= N:
    if cnt != N:
        D += A[cnt]
    cnt += 1

print(cnt)

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

int main() {
	// your code goes here
	int a[] = {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 b;
	cin >> b;
	cout << a[b-1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int n;
vector<pii_> lft,rgt;
ll cal(vector<pii_> a)
{
    int n = a.size();
    ll res = 0;
    set<int> pos;
    rep(i,1,n) pos.insert(i);
    for(auto x:a){
        auto it = pos.upper_bound(x.se);
        if(it!=pos.begin()){
            it--;
            res += x.fi;
            pos.erase(it);
        }
    }
    return res;
}
int main()
{
    fastio();
    int _;
    for(cin>>_;_;_--){
        cin>>n; ll ans = 0;
        lft.clear(),rgt.clear();
        rep(i,1,n){
            int k,l,r; cin>>k>>l>>r;
            if(l>r) lft.pb({l-r,k}),ans+=r;
            else rgt.pb({r-l,n-k}),ans+=l;
        }
        sort(lft.begin(),lft.end());sort(rgt.begin(),rgt.end());
        reverse(lft.begin(),lft.end());reverse(rgt.begin(),rgt.end());
        ans = ans + cal(lft) + cal(rgt);
        cout<<ans<<endl;
    }
    return 0;
}


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

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

int memo[60][60][60][60] = {};

int mas[60][60];

typedef struct{
    int cost;
    int tx;
    int ty;
    int kx;
    int ky;
} Data;

Data make_data(int c, int x, int y, int xx, int yy){
    Data d;
    d.cost = c;
    d.ty = y;
    d.tx = x;
    d.ky = yy;
    d.kx = xx;
    return d;
}

int w, h;

bool isMove(int x, int y){
    return 0 <= x && x < w && 0 <= y && y < h && mas[y][x] == 0;
}

int main(){

    while(cin >> w >> h, w != 0 && h != 0){
        int tx, ty;
        int kx, ky;
        cin >> tx >> ty;
        cin >> kx >> ky;

        tx--;
        ty--;
        kx--;
        ky--;

        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                cin >> mas[i][j];
            }
        }

        memset(memo, -1, sizeof(memo));

        queue<Data> que;
        que.push(make_data(0, tx, ty, kx, ky));
        while(!que.empty()){
            int cost = que.front().cost;
            tx = que.front().tx;
            ty = que.front().ty;
            kx = que.front().kx;
            ky = que.front().ky;

            que.pop();

            if(cost >= 100){
                continue;
            }

            if(memo[tx][ty][kx][ky] != -1){
                continue;
            }

            memo[tx][ty][kx][ky] = cost;

            cost++;
            for(int i = 0;i < 4;i++){
                int nx = tx + dx[i];
                int ny = ty + dy[i];

                if(!isMove(nx, ny)){
                    nx -= dx[i];
                    ny -= dy[i];
                }

                int mx = kx - dx[i];
                int my = ky - dy[i];

                if(!isMove(mx, my)){
                    mx += dx[i];
                    my += dy[i];
                }

                que.push(make_data(cost, nx, ny, mx, my));
            }

        }

        int ans = INT_MAX;;
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                if(memo[j][i][j][i] != -1){
                    ans = min(ans, memo[j][i][j][i]);
                }
            }
        }

        if(ans == INT_MAX){
            cout << "NA" << endl;
        }else{
            cout << ans << endl;
        }
    }
}



Measured memory_bytes: 58016
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c = 1 ;
        char[] cs = sc.next().toCharArray();

        char back = cs[0];
        for(int i = 1; i < n; i++) {
        	if(cs[i] != back) {
        		c++;
        		back = cs[i];
        	}
        }


        System.out.println(c);

    }


}

Measured memory_bytes: 26196
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
 
const int N=1005;
const int MOD=1e9+7;
 
 
// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
 
 
int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/
 int a,b,c;
 cin>>a>>b>>c;
 int d=c-a-b;

 if(d>0 && d*d>(4*a*b))
 {
  cout<<"Yes";
 }
 else
 {
  cout<<"No";
 }
 
  
  
}


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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; read(n);
	vector<ll> v(n);
	rep(i, 0, n) read(v[i]);
	ll rem = 0;
	rep(i, 2, n) rem ^= v[i];
	ll a0 = v[0], a = v[0], b = v[1];
	if ((a ^ b ^ rem) & 1 == 0)
		die(-1);
	for (int i = 0; i < 50; i++) {
		ll sig = 1ll << i;
		if (a > sig / 2 && ((a & sig) ^ (b & sig)) != (rem & sig))
			a -= sig / 2, b += sig / 2;
		for (int j = i - 1; j >= 0; j--) {
			ll sig = 1ll << j;
			if (a + sig < a0 && ((a + sig) ^ (b - sig) ^ rem) == 0)
				a += sig, b -= sig;
		}
	}
	if ((a ^ b ^ rem) == 0)
		write(a0 - a);
	else
		write(-1);
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll ceil1(ll n,ll m){
    if(n%m==0){return n/m;}
    return n/m +1;}


void solve()
{
	ll n,flag=0;
	cin>>n;
	while(n--)
	{
		ll a;
		cin>>a;
		if(a%2==0)
		{
			if(a%3==0 || a%5==0)
				flag=0;
			else
			{
				flag=1;
				break;
			}
		}
	}
	if(flag==1)
		cout<<"DENIED";
	else
		cout<<"APPROVED";
		
}

int main()
{
	fast;
	ll q=1;
	// cin>>q;
	while(q--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat May 25 20:54:15 2019

@author: Yamazaki Kenichi
"""

r,D,x = map(int,input().split())

def a(x,D):
    return r * x - D

for i in range(10):
    x = a(x,D)
    print(x)

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

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

using namespace std;

int n,m;
int start,end;
vector<int> v,p;
vector<bool> flag,used;
bool ans;

void init(int now)
{
	rep(i,end+1)
	{
		int next = i + v[i];
		if(now == next || (now == end && now < next))
		{
			REP(j,1,m+1)
			{
				if(0 <= i-j && !flag[i-j])
				{
					flag[i-j] = true;
					init(i-j);
				}
			}
		}
	}

	return;
}

void dfs(int now)
{
	if(!flag[now]) 
	{
		ans = false;
	}

	REP(j,1,m+1)
	{
		if(now + j <= end)
		{
			int next = now + j + v[now + j];
			if(next < 0) next = 0;
			if(next > end) next = end;

			if(used[next]) continue;
			used[next] = true;
			dfs(next);
		}
	}

	return;
}

int main()
{
	while(cin >> m && m)
	{
		p.clear();
		p.resize(m);
		rep(i,m) p[i] = i+1;

		cin >> n;

		v.clear();
		v.resize(n+2);
		
		v[0] = 0;
		start = 0;

		REP(i,1,n+1) cin >> v[i];

		v[n+1] = 0;
		end = n+1;
	
		ans = true;

		used.clear();
		used.resize(n+2);
		rep(i,n+2) used[i] = false;
		used[0] = true;

		flag.clear();
		flag.resize(n+2);
		rep(i,n+2) flag[i] = false;

		flag[end] = true;
		init(end);
		dfs(0);

		if(ans) cout << "OK" << endl;
		else cout << "NG" << endl;
	}

	return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

// コンビネーションを計算する関数
ll modpow(ll a, ll n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}
int main()
{
    cout << fixed << setprecision(15);
    ll N, K;
    cin >> N >> K;

    vector<ll> F(K+1, 0);

    for(ll i=K; i>=1; i--){
        F[i] = modpow(floor(K/i), N);
        ll now = i;
        ll counter = 2;
        while(now*counter <= K){
            F[i] -= F[now*counter];
            F[i] = (F[i]+MOD) % MOD;
            counter++;
        }
    }
    
    ll ans = 0;
    for(ll i=1; i<=K; i++){
        ans += F[i] * i;
        ans = ans % MOD;
    }
    cout << ans << endl;
    return 0;
}

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

long long a, b, c, ans;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> a >> b >> c;
    if(a==b&&a==c&&a%2==0&&b%2==0&&c%2==0) {
        cout << -1;
        return 0;
    }

    while(a%2==0&&b%2==0&&c%2==0) {
        long long tempa=a, tempb=b, tempc=c;
        a=0; b=0; c=0;
        a+=tempb/2;
        a+=tempc/2;
        b+=tempa/2;
        b+=tempc/2;
        c+=tempa/2;
        c+=tempb/2;
        ans++;
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    mod = 1000000007

    N, W = map(int, input().split())
    w = [0]*N
    v = [0]*N
    for i in range(N):
        w[i], v[i] = map(int, input().split())

    V = 10**5+1
    inf = float('inf')
    dp = [inf]*V
    dp[0] = 0

    for i in range(N):
        for j in range(V-1, v[i]-1, -1):
            if dp[j-v[i]]+w[i]<=W:
                dp[j] = min(dp[j], dp[j-v[i]]+w[i])
    
    res = 0
    for i, x in enumerate(dp):
        if x <= W:
            res = i
    print(res)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 47052
#include "stdio.h"
#include "limits"
#include "algorithm"
#include "iostream"
#include "cmath"
#include "string"
#include "map"
#include "iomanip"
#include "stack"
using namespace std;

int main(){
  char S[110];
  bool FLAG;
  stack<char> temp;
  while(1){
    FLAG=true;
    gets(S);
    if(S[0]=='.')break;
    for(int i=0;S[i]!='.';++i){
      if(S[i]=='(' || S[i]=='[')temp.push(S[i]);
      if(S[i]==')'){
        if(temp.empty()){
          FLAG=false;
          break;
        }
        char a=temp.top();
        temp.pop();
        if(a!='('){
          FLAG=false;
          break;
        }

      }
      if(S[i]==']'){
        if(temp.empty()){
          FLAG=false;
          break;
        }
        char a=temp.top();
        temp.pop();
        if(a!='['){
          FLAG=false;
          break;
        }
      }
    }
    if(FLAG&&temp.empty())cout<<"yes"<<endl;
    else cout<<"no"<<endl;
    while(!temp.empty())temp.pop();
  }
}

Measured memory_bytes: 1156
require 'prime'

n = gets.strip.to_i
h = Hash.new(0)

(2..n).each do |i|
  Prime.prime_division(i).each do |k, v|
    h[k] += v
  end
end



answer = 1
MOD = 10 ** 9 + 7
 
h.each_value do  |v|
  answer = answer * (v + 1) % MOD
end
puts answer

Measured memory_bytes: 2300
#include <iostream>
#include <map>
#include <set>

int main()
{
	std::map<int, int> counter;
	int number;
	while (std::cin >> number) {
		counter[number]++;
	}

	int max_count = 0;
	std::set<int> max_numbers;
	for (std::map<int, int>::iterator i = counter.begin(); i != counter.end(); ++i) {
		if (i->second >= max_count) {
			if (i->second > max_count) {
				max_count = i->second;
				max_numbers.clear();
			}
			max_numbers.insert(i->first);
		}
	}

	for (std::set<int>::iterator i = max_numbers.begin(); i != max_numbers.end(); ++i) {
		std::cout << *i << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1196
from collections import Counter

n=int(input())
a=list(map(int,input().split()))

ans=0
c=Counter(a)
for v in c.values():
  if v>=2:
    ans+=v*(v-1)//2

for i in range(n):
  x=a[i]
  if c[x]<=1:
    print(ans)
  else:
    print(ans-(c[x]-1))

Measured memory_bytes: 26780
package main

import(
	"fmt"
)

var N, Y int

func main() {
	x := -1
	y := -1
	z := -1
	fmt.Scan(&N, &Y)
	
	for i:=0; i<=N; i++ {
		for j:=0; j<=N-i; j++ {
			k := N-(i+j)
			if 10000*i+5000*j+1000*k == Y{
				x = i
				y = j
				z = k
			}
		}
	}

	fmt.Println(x, y, z)
}

Measured memory_bytes: 512
INF = 10 ** 9 + 7

n = gets.to_i
a = gets.chomp.split.map(&:to_i)
cnt = Array.new(n, 0)

x = Array.new(n)
n.times do |i|
  cnt[a[i]] += 1
end

res = 1
n.times do |i|
  if res == 0
    break
  end

  req = 2
  if n % 2 != 0 && i == 0
    req = 1
  elsif i % 2 == n % 2
    req = 0
  end
    
  if cnt[i] != req
    res *= 0
  elsif i % 2 != n % 2
    res = (res * req) % INF
  end
end
puts res

Measured memory_bytes: 22664
//AtCoder 
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
#if LOCAL&0
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    vector<ll> tbl(5);
    for(auto&& t:tbl){
        cin>>t;
    }
    ll minr_id=-1;
    ll minr=10;
    REP(i,tbl.size()){
        auto r=tbl[i]%10;
        if(r!=0&&minr>r){
            minr=r;
            minr_id=i;
        } 
    }
    ll ans=0;
    REP(i,tbl.size()){
        if(i==minr_id){
            ans += tbl[i];
        } else {
            ans += ((tbl[i]+9) / 10)*10;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  string  s;
  int t=0;
  cin >>s;

for (int i=0 ; i<s.size() ; i++)  
{ t+= s[i]-'0' ;}
if (t%9==0) {cout << "Yes" <<endl;
}
else {cout << "No" << endl;}
return 0 ;}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	string s, t;
	cin >> s >> t;
	
	int ans = 0;
	for(int i = 0; i < (int)s.size(); ++i) {
		if( s[i] != t[i] ) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3916
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0

for i in range(a + 1):
    for k in range(b + 1):
        for m in range(c + 1):
            if (500 * i + 100 * k +  50 * m) == x:
                cnt += 1

print(cnt)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Text;

class TEST{
	static void Main(){
		
		var n=int.Parse(Console.ReadLine());
		for(int i=0;i<n;i++){
			int score=0;
			int outcnt=0;
			int BaseRunner=0;
			while(true){
				var s=Console.ReadLine();
				if(s=="OUT")outcnt++;
				if(outcnt==3)break;
				
				if(s=="HIT"){
					BaseRunner=(BaseRunner<<1)|0x1;
					if((BaseRunner&0x8)!=0){
						BaseRunner=BaseRunner&0x7;
						score++;
					}
				}
				if(s=="HOMERUN"){
					score++;
					if((BaseRunner&0x1)!=0)score++;
					if((BaseRunner&0x2)!=0)score++;
					if((BaseRunner&0x4)!=0)score++;
					BaseRunner=0;
				}
			}
			Console.WriteLine(score);
		}
	}
}

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

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

    a = N / 10;
    b = N % 10;

    if(a == 9 || b == 9){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main() {
  int a;
  cin >> a;
  vector <int> s(a);
  int c = 0;
  for (int i = 0; i < a; i++) {
    cin >> s.at(i);
  }
  for (int i = 0; i < a; i++) {
    if ((i+1)%2 == 1 && s.at(i)%2 == 1) {
      c++;
    }
  }
  cout << c <<endl;
}


Measured memory_bytes: 3552
// Beginner159.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <climits>
#include <vector>

using namespace  std;

typedef  long long ll;

bool is_strong_pa(const string& s, int from, int to)
{
	bool is_pal = true;

	for (int i = from; i <= (to-from)/2; ++i)
	{
		if (s[i] != s[to-i])
		{
			is_pal = false;
			break;
		}
	}
	
	return is_pal;
}

int main()
{
	/*int n, m;
	cin >> n >> m;

	int sum = 0;
	sum += n * (n - 1) / 2;
	sum += m * (m - 1) / 2;
	cout << sum;*/

	/*string s;
	cin >> s;

	const int n = s.length();

	bool is_pal = is_strong_pa(s, 0, n - 1) &&
		is_strong_pa(s, 0, (n - 1) / 2 - 1) &&
		is_strong_pa(s, (n + 3) / 2 - 1, n - 1);

	cout << (is_pal ? "Yes" : "No");*/

	/*int l;
	cin >> l;

	double side = 1.0*l / 3;
	double res = side * side * side;

	cout.precision(10);

	cout << res;*/

	ll n, ai;
	cin >> n;
	vector<ll> a(n);
	map<ll, ll> numbers;
	
	for (int i = 0; i < n; ++i)
	{
		cin >> ai;
		a[i] = ai;
		numbers[ai]++;
	}

	ll sum = 0;
	for (const auto& item: numbers)
	{
		ll count = item.second;
		sum += count * (count - 1) / 2;
	}

	for (int i = 0; i < n; ++i)
	{
		ll count = numbers[a[i]];
		cout << (sum - (count-1)) << "\n";
	}

	//for (int i = 0; i < n; ++i)
	//{
	//	ll sum = 0;
	//	/*for (int j = 0; j < n; ++j)
	//	{
	//		int count = numbers[a[i]];
	//		if (i == j) count--;
	//		sum += count * (count - 1) / 2;
	//	}*/

	//	for (const auto& item:numbers)
	//	{
	//		ll count = item.second;
	//		if (item.first == a[i]) count--;
	//		sum += count * (count - 1) / 2;
	//	}
	//	
	//	//if (other_number == 0) cout << 0 << "\n";
	//	cout << sum << "\n";
	//}
}



Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
const int MXX = 1e5;
typedef long long int ll;

int main ()
{
    ll n, k;
    cin>>n>>k;
    ll ans = k;
    for(int i = 1; i<n; i++)
    {
        ans*=(k-1);
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define INF 1000000000000
#define MOD 1000000007
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                                 \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << endl
#define debug_4(x1, x2, x3, x4)                                             \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                         \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;

template <class T>
void printVector(const vector<T>& v) {
    for (auto value : v) {
        cout << value << " ";
    }
    cout << endl;
}
int main() {
    ll h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    ll ans = 0;
    rep(is, 1 << h) rep(js, 1 << w) {
        ll cnt = 0;
        rep(i, h) rep(j, w) {
            if (is >> i & 1) continue;
            if (js >> j & 1) continue;
            if (s[i][j] == '#') cnt++;
        }
        if (cnt == k) ans++;
    }

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

Measured memory_bytes: 3152
#include<stdio.h>
int main()
{	
  int X,a,b,c,d;
  scanf("%d",&X);
 b = X / 500;
 c = X % 500;
 d = c / 5;
 a = b * 1000 + d * 5;
 printf("%d",a);
      return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n, rn;
vector< int > str, sum;
int cal(int from, int to){
    int res = 0;
    if(from/rn == to/rn){
        for(int i = from; i <= to; i++) res |= str[i];
    }else{
        res |= cal(from, from/rn*rn+rn-1);
        res |= cal(to/rn*rn, to);
        for(int i = from/rn+1; i < to/rn; i++) res |= sum[i];
    }
    return res;
}
void cal(int x){
    sum[x] = cal(x*rn, x*rn+rn-1);
}
int main(void){
    string s;
    cin >> n >> s;
    for(rn = 1; rn*rn < n; rn++);
    str.assign(rn*rn, 0);
    sum.assign(rn, 0);
    for(int i=0;i<n;i++) str[i] = (1<<(s[i]-'a'));
    for(int i=0;i<rn;i++) cal(i);
    int q;
    cin >> q;
    while(q--){
        int t;
        cin >> t;
        if(t == 1){
            int i;
            char c;
            cin >> i >> c;
            str[--i] = (1<<(c-'a'));
            cal(i/rn);
        }else{
            int l, r, bit, ans = 0;
            cin >> l >> r;
            bit = cal(--l, --r);
            for(int i=0;i<26;i++) ans += ((bit>>i)&1);
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 2820
n = int(input())
a = list(map(int, input().split()))
if a[0] >= 1 or n == 0:
    print(1 if a[0] == 1 and n == 0 else -1)
    exit()
b = [0] * (n + 1)
for i in range(1, n + 1):
    b[i] = a[i] + b[i - 1]
v = 1
ans = 1
for i in range(n):
    v = min(b[n] - b[i], 2 * (v - a[i]))
    if v < a[i + 1]:
        print(-1)
        exit()
    ans += v
print(ans)

Measured memory_bytes: 20040
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static class Point {
		long x, y;
		
		public Point(long x, long y) {
			this.x = x;
			this.y = y;
		}
	}
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			Point[] points = new Point[N];
			for(int i = 0; i < N; i++) {
				points[i] = new Point(sc.nextLong(), sc.nextLong());
			}
			
			Arrays.sort(points, new Comparator<Point>() {
				@Override
				public int compare(Point o1, Point o2) {
					return Long.compare(o1.x + o1.y, o2.x + o2.y);
				}
			});
			
			long answer = Math.abs(points[0].x - points[N - 1].x) + Math.abs(points[0].y - points[N - 1].y);
			
			Arrays.sort(points, new Comparator<Point>() {
				@Override
				public int compare(Point o1, Point o2) {
					return Long.compare(o1.x - o1.y, o2.x - o2.y);
				}
			});
			
			answer = Math.max(answer, Math.abs(points[0].x - points[N - 1].x) + Math.abs(points[0].y - points[N - 1].y));
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


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

ll n;

int main() {
	cin>>n;
	ll digit, jml[12];
	for (int i=1; i<12; i++) {
		jml[i]=pow(26, i);
		if (i!=1) jml[i]+=jml[i-1];
	}
	jml[0]=0;
	for (int i=1; i<12; i++) {
		if (jml[i]>=n) {
			digit=i;
			break;
		}
	}
	//cout<<"digit: "<<digit<<endl;
	char ans[digit];
	ll cnt=0, temp=n;
	for (int i=digit; i>0; i--) {
		if (i==1) {
			ans[digit-i]=96+temp;
		}
		else {
			//cout<<"temp1: "<<temp<<endl;
			temp-=jml[i-1];
			//cout<<"temp2: "<<temp<<endl;
			double isi=temp/pow(26, i-1);
			ll bulet=isi;
			if (isi==bulet) ans[digit-i]=96+isi;
			//cout<<"isi: "<<isi<<endl;
			else ans[digit-i]=97+isi;
			ll con=pow(26, i-1);
			temp=temp%con;
			if (temp==0) temp=con;
			temp+=jml[i-2];
			//cout<<"tempakhir: "<<temp<<endl;
		}
	}
	for (int i=0; i<digit; i++) {
		cout<<ans[i];
	}
	cout<<endl;
}



Measured memory_bytes: 4064
#include <iostream>
#include <limits>
#include <numeric>
#include <vector>

template <typename T>
T gcd(T the_one, T the_other)
{
    if (the_one < the_other)
    {
        std::swap(the_one, the_other);
    }

    while (0 < the_other)
    {
        T r = the_one % the_other;
        the_one = the_other;
        the_other = r;
    }

    return the_one;
}

int main()
{
    int N;
    std::cin >> N;

    int min_mod;
    std::cin >> min_mod;
    for (int i = 1; (i < N) && (1 < min_mod); ++i)
    {
        int a;
        std::cin >> a;
        min_mod = gcd<int>(min_mod, a);
    }

    std::cout << min_mod << std::endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def func(k, n):
    if n <= k:
        return n + 1
    elif n <= 2 * k:
        return 2 * k - n + 1
    else:
        return 0

K,S = map(int,input().split())
ans = 0
for a in range(K+1):
    if S-a >= 0:
        ans += func(K, S-a)
print(ans)


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

public class Main{
    public static void main(String[] args) {
        int n ;
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        //System.out.println(n);
        int[] arr = new int[n];
        for(int i = 0; i<n; i++){
            arr[i] = in.nextInt();
        }


        Arrays.sort(arr);
        int m = 0;
        m = in.nextInt();
        //System.out.println(m);
        int[] brr = new int[m];
        for(int i = 0; i<m; i++){
            brr[i] = in.nextInt();
        }
        int res = 0;
        //System.out.println("n"+n+" "+arr[0]);
        //System.out.println(res);
        for(int i = 0; i<m; i++){
            if(search(arr,brr[i],0,n-1)==1) res++;
            //System.out.println(search(arr,brr[i],0,n-1));
        }
        System.out.println(res);
    }

    private static int search(int[] arr, int i,int left, int right) {
        //System.out.println("i:"+i);
        if(right<left) return -1;
        int mid = (left+right)/2;
        //System.out.println(arr[mid]+" "+mid);
        if(arr[mid] == i) return 1;
        if(arr[mid]>i){
            return search(arr,i,left,mid-1);
        }else {
            return search(arr,i,mid+1,right);
        }

    }
}



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

int main(){
  string s;
  cin >> s;
  int ans = 0;
  if(s.at(1)=='R'){
    if(s.at(0)=='R' and s.at(2)=='R'){
      ans = 3;
    }else if((s.at(0)=='R' and s.at(2)=='S')or(s.at(0)=='S' and s.at(2)=='R')){
      ans = 2;
    }else{
      ans = 1;
    }
  }else if(s.at(0)=='R' or s.at(2)=='R'){
    ans = 1;
  }else{
    ans = 0;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3620
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-16 23:49:56
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  vector<int> a(3); cin >> a;
  sort(all(a));

  if ((a[0] == a[1] && a[1] != a[2]) || (a[1] == a[2] && a[0] != a[1])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

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


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define N 1000
using namespace std;

void selectionSort(int n, int A[]) {
	int count = 0;
	for (int i = 0; i < n; i++) {
		int minj = i;
		for (int j = i + 1; j < n; j++) {
			if (A[minj] > A[j]) {
				minj = j;
			}
		}
		int t = A[i];
		A[i] = A[minj];
		A[minj] = t;
		if(i != minj ) count++;
	}
	for (int i = 0; i < n; i++) {
		if(i != 0) cout << " " << A[i];
		else cout << A[i];
	}
	cout << endl << count << endl;
}

int main() {
	int n;
	int A[N];

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

	selectionSort(n, A);

	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

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

    int ans = 0;
    for(int i = 1; i <= 99998; i++) {
        int t = c[i-1] + c[i] + c[i+1];
        ans = max(ans, t);
    }
    
    cout << ans;

    cout << endl;
    return 0;
}

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

#define DEBUG true
using namespace std;

#define $(x) {if (DEBUG) {cout << __LINE__ << ": "; cout << x << endl;}}
#define _(x) {cout << #x << " = " << x << " ";}

int main() {
    int R, C;
    int at_i, at_j;
    int des_i, des_j;
    cin >> R >> C;
    cin >> at_i >> at_j;
    cin >> des_i >> des_j;
    at_i--; at_j--;
    des_i--; des_j--;


    vector<vector<char>> board(R, vector<char> (C, ' '));
    for (int i=0;i<R;i++){
        for(int j=0;j<C;j++) {
            cin >> board[i][j];
        }
    }

    vector<vector<int>> visited(R, vector<int> (C, -1));
    vector<vector<int>> next{ {0,1},{0,-1},{1,0},{-1,0}};

    int magic{0};
    queue<pair<int,int>> q;
    q.push({at_i,at_j});
    visited[at_i][at_j] = 0;
    
    while (!q.empty()) {
        vector<pair<int,int>> reuse;
        queue<pair<int,int>> n_q;

        while (!q.empty()) {
            auto at = q.front();
            q.pop();
            int i = at.first;
            int j = at.second;

            visited[i][j] = magic;
            reuse.push_back({i,j});

            for (auto n : next) {
                if (i+n[0] >= R || i+n[0] < 0 || j+n[1] >= C || j+n[1] < 0 ) 
                    continue;
                else if (visited[i+n[0]][j+n[1]] != -1 || board[i+n[0]][j+n[1]] == '#'  ) 
                    continue;
                visited[i+n[0]][j+n[1]] = magic;
                q.push({i+n[0], j+n[1]});
            }
        }

        magic++;
        for (auto m : reuse) {
            int i = m.first;
            int j = m.second;
            for(int _i=-2;_i<=2;_i++) {
                for(int _j=-2;_j<=2;_j++) {
                    if (i+_i >= R || i+_i < 0 || j+_j >= C || j+_j < 0 ) 
                        continue;
                    else if (visited[i+_i][j+_j] != -1 || board[i+_i][j+_j] == '#'  ) 
                        continue;
                    visited[i+_i][j+_j] = magic;
                    n_q.push({i+_i, j+_j});
                }
            }
        }
        q = n_q;
    }
    cout << visited[des_i][des_j];
    return 0;
}


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

int main()

{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	double c=n;
	int x=n/2+n%2;
	double y=x;
	y/=c;
	printf("%.7f\n", y);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  long long L,R,i,j;
  int min=2020;
  scanf("%lld %lld",&L,&R);
  if(R-L>=2019){
    printf("0\n");
    return 0;
  }
  for(i=L;i<=R;i++){
    for(j=i+1;j<=R;j++){
      if(min>(i*j)%2019) min=(i*j)%2019;
    }
  }
  printf("%d\n",min);
  return 0;
}

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

bool parindroma(string st) {
	int len = (int)st.length();
	for (int i = 0; i < (len / 2); i++) {
		if (st[i] != st[len - i - 1]) {
			return false;
		}
	}

	len = (len - 1) / 2;
	for (int i = 0; i < (len / 2); i++) {
		if (st[i] != st[len - i - 1]) {
			return false;
		}
	}

	return true;
}

int main() {
	string st;

	cin >> st;

	if(parindroma(st)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Beginning
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

int cs[10];

/* subroutines */

/* main */

int main() {
  for (int i = 0; i < 4; i++) {
    int ni;
    scanf("%d", &ni);
    cs[ni]++;
  }

  if (cs[1] && cs[9] && cs[7] && cs[4]) puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>

using namespace std;

int main()
{
  int n; cin >> n;
  int min = INT_MAX;
  int max = 1;

  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    if (max < a) max = a;
    if (min > a) min = a;
  }

  cout << max - min << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mod 1000000007
#define ar array
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

void init() {
  string s;
  cin >> s;
  int n = s.size();
  int cnt = 0;
  for (int i = 1; i < n; i++) {
    if (s[i] == s[i - 1]) {
      cnt++;
      char cur = s[i];
      s[i] = (cur == '1') ? '0' : '1';
    }
  }
  cout << cnt << endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


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

int main(){
    int N;
    cin>>N;
    int a=0,b=0,c=0,d=0;
    rep(i,N){
        string s;
        cin>>s;
        if(s=="AC")a++;
        else if(s=="WA")b++;
        else if(s=="TLE")c++;
        else if(s=="RE")d++;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;
    return 0;
}

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

int main()
{   
    int n;
    cin>>n;
    int t[n];
    for(int i=0;i<n;i++) cin>>t[i];
    int m;
    cin>>m;
    int p[m],x[m];
    for(int i=0;i<m;i++){
        cin>>p[i]>>x[i];
    } 
    
    for(int i=0;i<m;i++){
        int ans=0;
        for(int j=0;j<n;j++){
            if(j==p[i]-1){
                ans+=x[i];
            }
            else ans+=t[j];
        }
        cout<<ans<<endl;
        
    }
    
}

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

int main(){
	int d,g;
	cin >> d >> g;
	vector<int> p(d),c(d);
	for(int i=0; i<d; i++){
		cin >> p[i] >> c[i];
	}
	vector<int> ord(d);
	for(int i=0; i<d; i++){
		ord[i] = i;
	}
	int ans = 1e9;
	do{
		int sub = 0;
		int rem = g;
		for(int i=0; i<d; i++){
			if((ord[i]+1)*100 *p[ord[i]] >= rem){
				while(rem > 0){
					rem -= (ord[i]+1)*100;
					sub++;
				}
				break;
			}
			rem -= (ord[i]+1)*100 *p[ord[i]];
			sub += p[ord[i]];
			if(c[ord[i]] >= rem){
				break;
			}
			rem -= c[ord[i]];
		}
		ans = min(ans, sub);
	}while(next_permutation(ord.begin(), ord.end()));
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256