akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;++x)
#define Red(x,y,z) for(int x=y;x>=z;--x)
using namespace std;
const int MAXN=1e3+5,MAXM=1e6+5;
char buf[1<<12],*p1=buf,*p2=buf,nc;int ny;
//inline char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
inline char gc(){return getchar();}
inline ll read(){
	ll x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;if(nc<0)return nc;
	x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48);return x*ny;
}
struct Edge{int to,next,w;ll c;}edges[MAXM];
int cnt,head[MAXN],cur[MAXN],vis[MAXN],S,T,mf;ll dis[MAXN],mc;
inline void add(int x,int y,int w,ll c){
	edges[++cnt]=(Edge){y,head[x],w,c},head[x]=cnt;
	edges[++cnt]=(Edge){x,head[y],0,-c},head[y]=cnt;
}inline bool bfs(){
	queue<int>q;q.push(S),memset(dis,-0x3f,sizeof(dis)),memcpy(cur,head,sizeof(head)),memset(vis,0,sizeof(vis)),dis[S]=0;
	for(int x;!q.empty();q.pop()){
		x=q.front(),vis[x]=0;
		for(int i=head[x],y;i;i=edges[i].next)
			if(edges[i].w&&dis[y=edges[i].to]<dis[x]+edges[i].c)dis[y]=dis[x]+edges[i].c,!vis[y]?q.push(y),0:0;
	}return dis[T]>0;
}int dfs(int x,int dist){
	if(x==T||!dist)return dist;int z=0;vis[x]=1;
	for(int&i=cur[x],y,k;i;i=edges[i].next)if(edges[i].w&&dis[y=edges[i].to]==dis[x]+edges[i].c&&!vis[y]){
		k=dfs(y,min(dist,edges[i].w)),z+=k,dist-=k,edges[i].w-=k,edges[i^1].w+=k;
		if(!dist)break;
	}return z;
}inline void MCMF(){mc=mf=0;for(int t=0;bfs();)t=dfs(S,1e9),mc+=dis[T]*t,mf+=t;}
int x[MAXN],y[MAXN],a[MAXN],b[MAXN],lx[MAXN],rx[MAXN],ly[MAXN],ry[MAXN],n,m;char ty[MAXN];ll v[MAXN],ans;
inline void Solve(int k){
	memset(head,0,sizeof(head)),cnt=1;
	Rep(i,1,n)add(x[i],i+200,1,v[i]),add(i+200,y[i]+100,1,0);
	Rep(i,1,k)lx[i]=ly[i]=1,rx[i]=ry[i]=100;
	Rep(i,1,m){
		if(ty[i]=='L')lx[b[i]+1]=max(lx[b[i]+1],a[i]+1);
		if(ty[i]=='R'&&b[i]<k)rx[k-b[i]]=min(rx[k-b[i]],a[i]-1);
		if(ty[i]=='D')ly[b[i]+1]=max(ly[b[i]+1],a[i]+1);
		if(ty[i]=='U'&&b[i]<k)ry[k-b[i]]=min(ry[k-b[i]],a[i]-1);
	}Rep(i,1,k)lx[i]=max(lx[i],lx[i-1]),ly[i]=max(ly[i],ly[i-1]);
	Red(i,k-1,1)rx[i]=min(rx[i],rx[i+1]),ry[i]=min(ry[i],ry[i+1]);
	S=MAXN-2,T=MAXN-1;
	Rep(i,1,k){
		if(lx[i]>rx[i]||ly[i]>ry[i])return;
		add(S,i+n+200,1,0),add(i+n+k+200,T,1,0);
		Rep(j,lx[i],rx[i])add(i+n+200,j,1,0);Rep(j,ly[i],ry[i])add(j+100,i+n+k+200,1,0);
	}MCMF();if(mf!=k)return;ans=max(ans,mc);
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read();Rep(i,1,n)x[i]=read(),y[i]=read(),v[i]=read();
	m=read();Rep(i,1,m)cin>>ty[i],a[i]=read(),b[i]=read();
	Rep(i,1,n)Solve(i);cout<<ans<<"\n";
	return 0;
}



Measured memory_bytes: 4104
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] arr = new int[n];
		int right = 0;
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		    right = Math.max(right, arr[i]);
		}
		int left = 0;
		while (right - left > 1) {
		    int m = (left + right) / 2;
		    if (check(m, k, arr)) {
		        right = m;
		    } else {
		        left = m;
		    }
		}
		System.out.println(right);
	}
	
	static boolean check(int num, int count, int[] arr) {
	    for (int x : arr) {
	        count -= (x + num - 1) / num - 1;
	        if (count < 0) {
	            return false;
	        }
	    }
	    return true;
	}
}


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

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

    set<ll> s;

    ll a;
    rep(i,n) {
        cin >> a;
        if (s.find(a) != s.end()) {
            cout << "NO" << endl;
            return 0;
        }
        s.insert(a);
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 12920
import math

if __name__ == "__main__":

    param = input().split(" ")
    x1 = float(param[0])
    y1 = float(param[1])
    x2 = float(param[2])
    y2 = float(param[3])

    dist = math.sqrt( (x1 - x2)**2 + (y1 - y2)**2 )

    print(dist)



Measured memory_bytes: 5656
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#define rep(a,b,c) for(ll a=b;a<=c;a++)
#define per(a,b,c) for(ll a=b;a>=c;a--)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
const int inf = 0x3f3f3f3f;
const int N = 4e5+5;
int n, m;

int main(){
    cin >> n>> m;
    int ans = n + m;
    ans = max(ans, n - m);
    ans = max(ans, n * m);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define rep(i, n) for(int i = 0; i < n; i++)
#define in_arr(type, a, n) for(int i = 0; i < n; i++) scanf(type, &((a)[i]));

int main(){
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d\n", a * b / 2);
    return 0;
}



Measured memory_bytes: 128
gets
h=Hash[gets.split.map(&:to_i).group_by{|e|e}]
s,e=h.keys.minmax
 
puts (e+1)/2 == s && h[s].size==e%2+1 && (s+1..e).all?{|e|h[e]&&h[e].size>=2} ? "Possible" : "Impossible"

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<sstream>
using namespace std;

typedef pair<int,int> P;

int stoi(string s){
  stringstream ss(s);
  int res; ss>>res;
  return res;
}

int main(){
  int n,ans,mul;
  vector<int> list;
  string m;

  while(cin >> n >> m,n||(m!="0")){
    int l = m.size()-1;
    ans = -1; mul = 0;
    for(int i=0;i<(1<<l);i++){
      vector<P> v; int prv = 0;
      for(int j=0;j<l;j++){
	if((i>>j)&1){
	  v.push_back(P(prv,j)); prv = j+1;
	}
      }
      v.push_back(P(prv,l));
      
      int sum = 0;
      for(int j=0;j<v.size();j++)
	sum += stoi(m.substr(v[j].first,v[j].second-v[j].first+1));
      
      if(sum>n)continue;
      if(sum == ans)mul++;
      else if(sum > ans){
	ans = sum; mul = 0;
	list.clear();
	for(int j=0;j<v.size();j++)
	  list.push_back(stoi(m.substr(v[j].first,v[j].second-v[j].first+1)));
      }
    }
    if(ans<0)cout << "error\n";
    else if(mul)cout << "rejected\n";
    else{
      cout << ans;
      for(int i=0;i<list.size();i++)cout << " " << list[i];
      cout << endl;
    }
  }
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << "," << el.second << "] "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<ll> H;

void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path path_to_file = __FILE__;
        fs::path input,output;
        input = output = path_to_file.parent_path();
        input += string("/input/") + string(path_to_file.stem()) + string(".txt");
        output += string("/output/") + string(path_to_file.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N;
    H = fetch_vec<ll>(N);
}

int solve(){
    bool isok=true;
    for (int i = 0; i < N-1; i++)
    {
        if(H[i]<H[i+1]) {H[i+1]--;continue;}
        if(H[i]==H[i+1]) continue;
        isok = false;        
    }
    string ans = isok ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
ans = [i for i in range(0, N+1)]

for i in range(0, N+1, 3):
    ans[i] = 0

for i in range(0, N+1, 5):
    ans[i] = 0

for i in range(0, N+1, 15):
    ans[i] = 0

print(sum(ans))


Measured memory_bytes: 48544
# UnionFind: https://note.nkmk.me/python-union-find/
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1] * (n + 1)
        
    def find(self, x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.root[x] > self.root[y]:
            x, y = y, x
        self.root[x] += self.root[y]
        self.root[y] = x
        
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    
    def size(self, x):
        return -self.root[self.find(x)]
    
n, m, k = map(int, input().split())
friends = UnionFind(n)
f_or_b = [1] * (n + 1)
for i in range(m):
    a, b = map(int, input().split())
    friends.unite(a, b)
    f_or_b[a] += 1
    f_or_b[b] += 1
for i in range(k):
    c, d = map(int, input().split())
    if friends.is_same(c, d):
        f_or_b[c] += 1
        f_or_b[d] += 1
print(*[friends.size(i) - f_or_b[i] for i in range(1, n + 1)])

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

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#include <boost/multiprecision/cpp_int.hpp>

ll d = 1e9 + 7;

int main(void){
    ll n; cin >> n;
    ll k; cin >> k;
    vector <boost::multiprecision::cpp_int> combs_b = {0, 1};
    for (int i=2; i<k+1; i++){
        boost::multiprecision::cpp_int prev = combs_b[i-1];
        //dump(prev)
        combs_b.push_back(prev*(k-i+1)/(i-1));
    }
    vector <boost::multiprecision::cpp_int> combs_r = {0, 1};
    for (int i=2; i<k+2; i++){
        boost::multiprecision::cpp_int prev = combs_r[i-1];
        //dump(prev)
        combs_r.push_back(prev*(n-k-i+1)/(i-1));
    }
    for(int i=1; i<=k; i++){
        //dump(combs_b[i])
        cout << combs_b[i]*(combs_r[i-1]+2*combs_r[i]+combs_r[i+1]) % d << endl;
    }
    return 0;
}

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

int main()
{
	string s; cin >> s;

	int changeCnt = 0;
	for (int i = 0; i < s.size() - 1; i++) {
		if (s[i] != s[i + 1]) changeCnt++;
	}

	cout << changeCnt << endl;
	return 0;
}

Measured memory_bytes: 512
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
alice = 0
bob = 0
for i in range(n):
    if i % 2 == 0:
        alice += a[i]
    else:
        bob += a[i]

ans = alice - bob
print(ans)
    

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try {
	    String st, sp;
	    while((st=sc.readLine())!=null){
		st = Integer.toBinaryString(Integer.valueOf(st));
		int m=1;
		for(int i=st.length()-1; i>=1; i--){
		    if(st.charAt(i)=='1'){
			System.out.printf(m+" ");
			m*=2;
		    }
		    else
			m*=2;
		}
		System.out.println(m);
	    }
	}
	catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 12000
K=int(input())
ans=[]
def saiki(A):
    genzai_saigo=int(A[-1])
    ketasu=len(A)
    if ketasu>0:
        B="".join(A)
        ans.append(eval(B))
    if ketasu==10:
        return
    for i in [genzai_saigo-1,genzai_saigo,genzai_saigo+1]:
        if i < 0 or i>9:
            continue
        A.append(str(i))
        saiki(A)
        A.pop()
for i in range(1,10):
    saiki([str(i)])
ans.sort()
print(ans[K-1])

Measured memory_bytes: 17328
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, m;
	cin >> n >> m;

	int p, y;
	map<int, int> id_to_year;
	vector<vector<int> > prefecture(n + 1, vector<int> ());
	vector<int> order_in_prefecture(n + 1, 1);
	for (int i = 0; i < m; ++i) {
		cin >> p >> y;
		prefecture[p].push_back(y);
		id_to_year[i + 1] = y;
		++order_in_prefecture[p];
	}

	map<int, string> all_labels;
	for (int i = 1; i <= n; ++i) {
		sort(prefecture[i].begin(), prefecture[i].end());
		string is = to_string(i);
		string p_label = string(6 - is.size(), '0') + is;
		for (int j = 0; j < (int) prefecture[i].size(); ++j) {
			string js = to_string(j + 1);
			string city_label = p_label + string(6 - js.size(), '0') + js;
			all_labels[prefecture[i][j]] = city_label;
		}
	}

	for (int i = 1; i <= m; ++i) {
		cout << all_labels[id_to_year[i]] << "\n";
	}	

	return 0;

}

Measured memory_bytes: 24576
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int a,b;

int main() {
    cin >> a >> b;
    int res = (a-1)*(b-1);
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <map>
#include <memory>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
//#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef pair<int, int> pdi;
typedef pair<ll, int> pli;

int const maxn = 1e5 + 10;
inline int lc(int x)  {return x << 1;}
inline int rc(int x)  {return x << 1 | 1;}

void solve() {
    int n;
    cin >> n;
    vector<double> v;
    for (int i = 0; i < n; i++) {
        double x;
        cin >> x;
        v.push_back(x);
    }
    sort(all(v));
    double ans = (v[0] + v[1]) / 2;
    for (int i = 2; i < n; i++) {
        ans = (ans + v[i]) / 2;
    }
    cout << ans << endl;
}

int main(void) {
    FAST_IO;
    
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
long long a[5];
long long b[5];
long long cnt[5010];
long long ans[5000*5000+10];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<3;i++)cin>>a[i];
	for(int i=0;i<3;i++)cin>>b[i];
	for(int i=0;i<3;i++){
		for(long long j=a[i];j<=n;j++){
			cnt[j]=max(cnt[j],cnt[j-a[i]]+b[i]-a[i]);
		}
	}
	long long m=cnt[n]+n;
	for(int i=0;i<3;i++){
		for(long long j=b[i];j<=m;j++){
			ans[j]=max(ans[j],ans[j-b[i]]+a[i]-b[i]);
		}
	}
	cout<<ans[m]+m<<endl;
	return 0;
}

Measured memory_bytes: 195584
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
  static void Main(string[] args)
  {
    int n = int.Parse(Console.ReadLine());
    List<int> list=new List<int>();
    for(int i=0;i<n;i++){
      list.Add(int.Parse(Console.ReadLine()));
    }
    
    var array = list.OrderByDescending(x=>x).ToArray();
    int sum=0;
    for(int i=0;i<n;i++){
      if(i==0){
      	sum = array[i]/2;
      } else {
        sum += array[i];
      }
    }    
    Console.WriteLine(sum);
  }
}

Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();

            foreach (var item in N)
            {
                if (item == '9')
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int n, k; cin >> n >> k;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];
	long long ans = 0;
	for (int i = 0; i <= min(n, k); ++i) {
		for (int j = 0; i + j <= min(n, k); ++j) {
			long long tmp = 0;
			vector<int> value;
			for (int t = 0; t < i; ++t) {
				tmp += v[t];
				value.push_back(v[t]);
			}
			for (int t = 0; t < j; ++t) {
				tmp += v[n - t - 1];
				value.push_back(v[n - t - 1]);
			}
			sort(value.begin(), value.end());
			for (int t = 0; t < min((int)value.size(), k - i - j); ++t) {
				if (value[t] < 0) tmp -= value[t];
			}
			ans = max(ans, tmp);
		}
	}
	cout << ans << endl;

	return 0;
}

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

// #define int long long
struct Fast {Fast() {cin.tie(0); ios::sync_with_stdio(false);}} fast;

template <typename T> inline size_t maxElement(T beginIt, T endIt) { return max_element(beginIt, endIt); }
template <typename T> inline size_t minElement(T beginIt, T endIt) { return min_element(beginIt, endIt); }
template <typename T> inline size_t maxIndex(T beginIt, T endIt) { return distance(beginIt, *max_element(beginIt, endIt)); }
template <typename T> inline size_t minIndex(T beginIt, T endIt) { return distance(beginIt, *min_element(beginIt, endIt)); }
template <typename T> inline int sum(T beginIt, T endIt) { return accumulate(beginIt, endIt, 0); }
template <typename T> inline int mean(T beginIt, T endIt) { return sum(beginIt, endIt) / distance(beginIt, endIt); }
template <typename T> inline void debug(T x) { cerr << x << " " << "(L:" << __LINE__ << ")" << endl; }

int gcd(int n, int m) {
  if (m == 0) return n;
  else return gcd(m, m % n);
}
int lcm(int n, int m) {
  return n * m / gcd(n, m);
}

signed main(void) {
  /* */
  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  int N, M;
  array<int, 10000> A;
  string S, T;
  /* */

  // cin >> N;

  cin >> S;

  bool flag = true;
  int cCount = 0;

  for (int i = 0; i < S.length(); ++i) {
    if (i == 0) {
      flag = S[0] == 'A' && flag;
    } else if (1 < i && i <= S.length() - 2) {
      if (S[i] == 'C') cCount++;
    } else 
      if (S[i] != 'A' && S[i] != 'C') {
        flag = flag & ('a' <= S[i] && S[i] <= 'z');
    }
  }

  flag = (cCount == 1) && flag;
      
  if (flag) cout << "AC" << endl;
  else cout << "WA" << endl;
  
  
  // cout << num << endl;
  return 0;
}


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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << "\n";
    return 0;
}



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

int a,b,c;
int main(void){
    cin >> a >> b >> c;
    if(a==1 && b==0 && c==0)cout << "Close" << endl;
    if(a==0 && b==1 && c==0)cout << "Close" << endl;
    if(a==1 && b==1 && c==0)cout << "Open" << endl;
    if(a==0 && b==0 && c==1)cout << "Open" << endl;
    if(a==0 && b==0 && c==0)cout << "Close" << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;
const ll mod = 2019;

void solve()
{
    string s;
    cin >> s;

    ll n = sz(s);

    map <ll, ll> cnt;
    cnt[0]++;

    ll cur = 0;
    ll ten = 1;

    ll ans = 0;

    for(ll i = n-1; i >= 0; i--)
    {
        cur += ((s[i] - 48)%mod) * ten;
        cur %= mod;

        ans += cnt[cur];

        ten *= 10;
        ten %= mod;

        cnt[cur]++;
    }

    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N,M,C,count = 0;
  cin >> N >> M >> C;
  vector<int> b(M);
  vector<int> a(N * M);
  for (int iteM=0;iteM<M;iteM++){
    cin >> b[iteM];
  }
  for (int iteN=0; iteN<N;iteN++){
    int tempSum = C;
    for (int iteM=0; iteM<M; iteM++){
      cin >> a[iteN * M + iteM];
      tempSum += a[iteN * M + iteM] * b[iteM];
    }
    if(tempSum > 0)count++;
  }
  cout << count << endl;
  return 0;
}

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

int main(void){
  int a[4],b[4],Hit,Blow;


  while( scanf("%d%d%d%d%d%d%d%d" ,&a[0],&a[1],&a[2],&a[3] ,&b[0] ,&b[1] ,&b[2] ,&b[3]) != EOF ){
    Hit = Blow = 0;
  for( int i = 0 ; i < 4 ; i++ ){
    for( int j = 0 ; j < 4 ; j++ ){

      if( a[i] == b[j] && i == j ) Hit++;
      else if( a[i] == b[j] && i != j ) Blow++;

    }
  }

  cout << Hit <<" "<< Blow << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
from collections import Counter

def prime_factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n //=2
    f=3
    while f**2<=n:
        if n%f==0:
            a.append(f)
            n //=f
        else:f +=2
    if n!=1:a.append(n)
    return a

n,p=map(int,input().split())
A=Counter(prime_factorize(p)).items()
cnt=1
for i,j in A:
    cnt *=pow(i,j//n)
print(cnt)

Measured memory_bytes: 3444
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    double x, sum = 0;
    string u;
    for (int i = 0; i < n; i++) {
        cin >> x >> u;
        if (u == "JPY") {
            sum += x;
        }else{
            sum += x * 380000;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    string s; cin >> s;
    if(s == "AAA" || s == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
}







Measured memory_bytes: 256
def func(x):
    if(x % 2 != 0):
        return 0
    else:
        return func(x / 2) + 1

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))

    ans = 0
    for i in range(n):
        ans += func(a[i])
    print(ans)

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

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

    switch (N%10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
             cout << "pon" << endl;
            break;
        default:
            cout << "bon" << endl;

    }
    return 0;

}

Measured memory_bytes: 3080
n = int(input())
a = input()
b = input()
c = input()

count = 0
for i in range(n):
    if a[i] == b[i] and b[i] == c[i] and c[i] == a[i]:
        continue
    else:
        if a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
            count += 1
        else:
            count += 2
print(count)

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

int gcd(int x, int y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

vector<int> divisor(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> p = divisor(gcd(a, b));
    sort(p.rbegin(), p.rend());
    cout << p[k - 1] << endl;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var n = Number(lines[0]);
 var dx = lines[1].split(' ');
 var d = Number(dx[0]);
 var x = Number(dx[1]);
 var sum = 0;

 for(i=2; i<n+2; i++){
   var j = 0;
   while(true){
     var ai = Number(lines[i]);
     var day = (j*ai) + 1;
     if(day <= d){
       sum++;
       j++;
     }else{
       break;
     }
   }
 }

 console.log(sum + x);
 
});

Measured memory_bytes: 7884
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;

int main() {
  string strs[9] = {{".,!? "}, {"abc"},  {"def"}, {"ghi"}, {"jkl"},
                    {"mno"},   {"pqrs"}, {"tuv"}, {"wxyz"}};
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string ans = "", sw;
    cin >> sw;
    int a = 0, b = 0;
    for (int j = 0; j < sw.size(); j++) {
      if (sw[j] == '0' && b >= 1) {
        ans += strs[a - 1][(b + strs[a - 1].size() - 1) % strs[a - 1].size()];
        a = 0, b = 0;
      }
      if (sw[j] == '0')
        continue;
      else {
        a = sw[j] - '0';
        b++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.12f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 1010101;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// mod.m での a の逆元 a^ { -1 } を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x /gcd(x, y) * y );
}

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

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

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


ll dx[8] = { 1,-1,0,0,1,1,-1,-1 };
ll dy[8] = { 0,0,1,-1,1,-1,1,-1 };
char c[2010][2010];
ll sum[2010][2010];
vector<vector<ll>>to, cost;
ll dist[101010];
bool flag[101010];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, m;
	cin >> n >> m;
	init(n);
	rep(i, m) {
		ll x, y, z;
		cin >> x >> y >> z;
		x--, y--;
		unite(x, y);
	}
	map<ll, ll>mp;
	rep(i, n) {
		ll x = find(i);
		mp[x]++;
	}
	ll ans = 0;
	for (auto p : mp) {
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11352
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n, m, k, ans, fact[MAXN], inv[MAXN], inverse[MAXN];

ll C(ll r, ll n) {
    if (r < 0 || r > n || n < 0) return 0;
    return fact[n] * inv[r] % MOD * inv[n - r] % MOD;
}

int main() {
    fast_io;

    fact[0] = 1;
    inv[0] = 1;
    inverse[1] = 1;
    for (ll i = 2; i < MAXN; i++) inverse[i] = (-(MOD / i) + MOD) * inverse[MOD % i] % MOD;
    for (ll i = 1; i < MAXN; i++) fact[i] = fact[i - 1] * i % MOD, inv[i] = inv[i - 1] * inverse[i] % MOD;

    cin >> n >> m >> k;
    for (ll i = 0; i < n; i++) {
        ans += m * m % MOD * i * (i + 1) / 2 % MOD % MOD * C(k - 2, n * m - 2);
        ans %= MOD;
    }
    for (ll i = 0; i < m; i++) {
        ans += n * n % MOD * i * (i + 1) / 2 % MOD * C(k - 2, n * m - 2);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}
/*

*/


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

int main() {
  int H, W; cin >> H >> W;
  cout << string(W+2, '#') << endl;
  for (int i=0; i<H; i++) {
    string s;
    cin >> s;
    cout << '#'+s+'#' << endl;
  }
  cout << string(W+2, '#') << endl;
}

Measured memory_bytes: 256
a = int(input())
aa = list(map(int, input().split()))

ans = 1
for i in range(len(aa)):
    if aa[i] == 0:
        ans = 0
        break

for i in range(len(aa)):
    ans *= aa[i]
    if ans > 10**18:
        ans = -1
        break

print(ans)


Measured memory_bytes: 21788
#include <iostream>
#define N_MAX 100000
using namespace std;

int main() {
	int H, N, ans;
	cin >> H >> N;
	int A[N_MAX];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		H = H - A[i];
	}

	if (H > 0)
		cout << "No";
	else
		cout << "Yes";

	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define ull unsigned long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FOR(i,start,stop)  for(int i=(start); i < (stop); i++)
#define FORD(i,start,stop) for(int i=(start); i >= (stop); i--)
#define RIP(i,stop) FOR(i,0,stop)
#define PI 3.141592653589793
#define PRECISION(c,f) fixed << setprecision(c) << f
using namespace std;

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

  if(S[0] != S[1] || S[1] != S[2] || S[0] != S[2]) yes;
  else no;


  return 0;
}


Measured memory_bytes: 3632
#coding:utf-8
n,m=list(map(int,input().split()))

A,b=[],[]
for i in range(n):
    A.append(list(map(int,input().split())))

for j in range(m):
    b.append(int(input()))

ans=[0 for i in range(n)]
for i in range(n):
    for j in range(m):
        ans[i]+=A[i][j]*b[j]

for i in ans:
    print(i)

Measured memory_bytes: 8072
def myAnswer(A: list, B: list, N: int) -> str:
    clomn = [0, 0, 0]
    bingoCard = [[0, 0, 0] for i in range(3)]
    row = [0, 0, 0]
    # マスが空くがどうかの判定
    for b in B:
        for i, a in enumerate(A):
            if(b in a):
                bingoCard[i][a.index(b)] = 1
                clomn[i] += 1
                row[a.index(b)] += 1
                break
   #  for n, b in enumerate(bingoCard):
   #      if(sum(b) == 3):
   #          return "Yes"  # 横の判定

    # 縦の判定(列ごとの合計が3である列があったかどうか)
    if(3 in row or 3 in clomn):
        return "Yes"

    # 斜めの判定
    if(bingoCard[1][1]):
        if((bingoCard[0][0] and bingoCard[2][2]) or (bingoCard[0][2] and bingoCard[2][0])):
            return "Yes"

    # 縦、横、斜めに当てはまらなければ,No
    return "No"


def modelAnswer():
    tmp = 1


def main():
    A = []
    B = []
    for _ in range(3):
        A.append(list(map(int, input().split())))
    N = int(input())
    for _ in range(N):
        B.append(int(input()))
    print(myAnswer(A[:], B[:], N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string N; cin >> N;
    rep(i, 2) {
        if (N[i] == N[i + 1] && N[i + 1] == N[i + 2]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
 

int main() 
{    
    string S,res;
    
    cin >> S;

    //' o, x

    int cnt;

    int maruCnt = 0;
    for(auto c: S)
    {
        if(c == 'o')maruCnt++;
    }

    res ="NO";
    //oがはち以上
    if(15 - S.size() + maruCnt >= 8)res = "YES";

    cout << res << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

vector<int> findNextIndex(const vector<int>& A) {
  int N = A.size();
  vector<int> res(N, -1);
  map<int, int> mem;
  for (int i = N - 1; i >= 0; i--) {
    if (mem.count(A[i])) {
      res[i] = mem[A[i]];
    }
    mem[A[i]] = i;
  }
  return res;
}

pair<ll, ll> findLoop(const vector<int>& A, const vector<int>& nextIndex) {
  int N = A.size();
  vector<ll> mem(N, -1);
  int x = 0;
  ll len = 0;
  while (mem[x] == -1) {
    mem[x] = len;
    int y = nextIndex[x];
    len += y - x + 1;
    x = (y + 1) % N;
  }
  return make_pair(mem[x], len - mem[x]);
}

vector<int> solveNaive(const vector<int>& A, ll bg, ll ed) {
  int N = A.size();
  vector<int> res;
  set<int> S;
  for (ll x = bg; x < ed; x++) {
    int v = A[x % N];
    if (!S.count(v)) {
      res.push_back(v);
      S.insert(v);
      continue;
    }
    while (res.back() != v) {
      S.erase(res.back());
      res.pop_back();
    }
    S.erase(v);
    res.pop_back();
  }
  return res;
}

vector<int> solve(const vector<int>& A, const vector<int>& nextIndex, ll bg, ll ed) {
  int N = A.size();
  for (ll x = bg; x < ed; ) {
    int add = nextIndex[x % N] - x % N + 1;
    if (x + add <= ed) {
      x += add;
      continue;
    }
    return solveNaive(A, x, ed);
  }
  return {};
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  ll K;
  while (cin >> N >> K) {
    vector<int> A(N);
    for (auto& x : A) cin >> x;
    vector<int> B(2 * N);
    for (int i = 0; i < N; i++) B[i] = B[N + i] = A[i];
    auto nextIndex = findNextIndex(B);
    auto loop = findLoop(A, nextIndex);
    assert(loop.snd > 0);
    ll rem = max(0ll, N * K - loop.fst) % loop.snd;
    vector<int> res;
    if (rem > 0) {
      res = solve(A, nextIndex, N * K - rem, N * K);
    }
    for (int x : res) cout << x << " ";
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 15572
#include<stdio.h>
int main(){
	int a, flag;
	scanf("%d", &a);
	char b[a+1];
	scanf("%s", b);
	if(a%2==1){
		printf("No");
	}
	else{
		int flag=1;
	for(int i=0; i<a/2; i++){
		if((b[i]!= b[i+a/2])){
			flag=0;
		}
	}
	if(flag){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
}
	
	return 0;
}

Measured memory_bytes: 1700
#include <string>
#include <stack>
#include <iostream>

using namespace std;

int main() {
    string word;
    stack<int> S;
    while(cin >> word){
        if (word == "+"){
            // ??°??????????¶???????????????\??????
            int n = S.top();
            S.pop();
            n = n + S.top();
            S.pop();
            S.push(n);
        }
        else if (word == "-"){
            // ??°??????????¶???????????????\??????
            int n = S.top();
            S.pop();
            n = S.top() - n;
            S.pop();
            S.push(n);
        }
        else if (word == "*"){
            // ??°??????????¶???????????????\??????
            int n = S.top();
            S.pop();
            n = n * S.top();
            S.pop();
            S.push(n);
        }
        else {
            // word?????°???????????\??????
            S.push(stoi(word));
        }
 }
    // S??????????????¨???
    cout << S.top() << endl;
}

Measured memory_bytes: 3164
/*  In the name of ALLAH */

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define int long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define w(x) int x;cin>>x;while(t--)
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int POSITIVE_INFINITY = 9223372036854775807;
const int NEGATIVE_INFINITY = -9223372036854775807;
const int MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif
int d[10];

bool checkvalid(int n){
    while(n){
        int dit = n%10;
        if(!d[dit])return false;
        n/=10;
    }
    return true;
}

int32_t main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
  
    int n,k;
    cin>>n>>k;
    rep(i,0,10)d[i]=1;
    for(int i = 0 ; i < k;i++){
        int digit;cin>>digit;
        d[digit]=0;
    }
    while(true){
        if(checkvalid(n)){
            cout<<n<<endl;
            return 0;
        }
        n++;
    }

    
 
    return 0;
}


Measured memory_bytes: 256
while True:
    H,W=map(int,input().split())
    if H==0 & W==0:
        break
    shape_dot='#.'*W
    dot_shape='.#'*W
    for i in range(H):
        if i %2 ==0:
            print(shape_dot[:W])

        else:
            print(dot_shape[:W])

    print('')


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=100100100100;
const int Inf=1001001001;
const int mod=1000000007;
const double pi=3.141592653589793;
bool used[100000];
vvi g(100000);
void dfs (ll i,vi &k){
    k.pb(i);used[i]=true;
    for(ll x: g[i]){
        if(!used[x])dfs(x,k);
    }
}
int main(){
    ll n,m,ans=0;cin>>n>>m;
  rep(i,n)used[i]=false;
    vi v(n);
    rep(i,n){
        cin>>v[i];
        v[i]--;
    }
    rep(i,m){
        int a,b;cin>>a>>b;a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    rep(i,n){
        if(used[i])continue;
        vi k;
        dfs(i,k);
        vi t;
        for(int x:k)t.pb(v[x]);
        sort(all(t));
        for(int x:k)if(binary_search(all(t),x))ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 11892