akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

string prepare(string a){
  string res;
  for(int i=0;i<a.size();i++){
    if('a'<=a[i] && a[i]<='z')res += a[i]-32;
    if('A'<=a[i] && a[i]<='Z')res += a[i];
  }
  return res;
}

bool pal(string a){
  int l = a.size();
  for(int i=0;i<l/2;i++){
    if(a[i] != a[l-1-i])return false;
  }
  return true;
}

string x,tmp;

int main(){
  while(getline(cin,x)){
    x = prepare(x);
    vector<string> v;
    for(int i=0;i<x.size();i++){
      for(int j=3;j+i<=x.size();j++){
	tmp = x.substr(i,j);
	if(pal(tmp))v.push_back(tmp);
      }
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());

    for(int i=0;i<v.size();i++){
      for(int j=0;j<v.size();j++){
	if(i!=j){
	  if(v[i].size() <= v[j].size()+1)continue;
	  int a = v[i].size(); a -= v[j].size();
	  if(a&1)continue; a >>= 1;
	  if(v[j] == v[i].substr(a,v[j].size())){
	    v.erase(v.begin()+j);
	    if(j<i)i--;
	    j--;
	  }
	}
      }
    }

    for(int i=0;i<v.size();i++){
      cout << v[i] << ((i+1==v.size())?"\n":" ");
    }
    if(v.empty())cout << endl;
  }
}

Measured memory_bytes: 1216
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;


public class Main {
	
	public static final int WIDTH = 20;
	public static final int HEIGHT = 20;
	public static final int MAX_BIT = (1 << 10) - 1;
	
	public static final int[][] move_dir = new int[][]{{1, 0}, {-1, 0},{0, 1}, {0, -1}};
	public static boolean is_ok(int x, int y, int w, int h){
		return 0 <= x && x < w && 0 <= y && y < h;
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		boolean[][] is_wall = new boolean[HEIGHT][WIDTH];
		int[][] is_dirty = new int[HEIGHT][WIDTH];
		boolean[][][] visited = new boolean[HEIGHT][WIDTH][MAX_BIT];
		
		while(true){
			final int w = sc.nextInt();
			final int h = sc.nextInt();
					
			if(w == 0 && h == 0){
				break;
			}
		
			int start_x = -1;
			int start_y = -1;
			int dirty_id = 0;
			
			for(int i = 0; i < h; i++){
				char[] input = sc.next().toCharArray();
				
				//System.out.println(Arrays.toString(input));
				
				for(int j = 0; j < w; j++){
					final char in = input[j];
					
					for(int k = 0; k < MAX_BIT; k++){
						visited[i][j][k] = false;
					}
					
					if(in == '.'){
						is_wall[i][j] = false;
						is_dirty[i][j] = -1;
					}else if(in == '*'){
						is_wall[i][j] = false;
						is_dirty[i][j] = dirty_id;
						dirty_id++;
					}else if(in == 'x'){
						is_wall[i][j] = true;
						is_dirty[i][j] = -1;
					}else if(in == 'o'){
						is_wall[i][j] = false;
						is_dirty[i][j] = -1;
						start_x = j;
						start_y = i;
					}
				}
			}
			
			final int all_dirty = (1 << dirty_id) - 1;
			
			LinkedList<Integer> x_queue = new LinkedList<Integer>();
			LinkedList<Integer> y_queue = new LinkedList<Integer>();
			LinkedList<Integer> time_queue = new LinkedList<Integer>();
			LinkedList<Integer> dirty_queue = new LinkedList<Integer>();
			x_queue.add(start_x);
			y_queue.add(start_y);
			time_queue.add(0);
			dirty_queue.add(0);
			visited[start_y][start_x][0] = true;
			
			boolean flag = false;
			while(!time_queue.isEmpty()){
				final int x = x_queue.poll();
				final int y = y_queue.poll();
				final int time = time_queue.poll();
				final int dirty_bit = dirty_queue.poll();
				
				if(dirty_bit == all_dirty){
					flag = true;
					System.out.println(time);
					break;
				}
				
				for(int[] move : move_dir){
					final int nx = x + move[0];
					final int ny = y + move[1];
					final int ntime = time + 1;
					
					if(!is_ok(nx, ny, w, h)){
						continue;
					}else if(is_wall[ny][nx]){
						continue;
					}
					//System.out.println(nx + " " + ny);
					int next_dirty = dirty_bit;
					if(is_dirty[ny][nx] >= 0){
						next_dirty |= 1 << is_dirty[ny][nx];
					}
					
					if(visited[ny][nx][next_dirty]){
						continue;
					}
					visited[ny][nx][next_dirty] = true;
					
					x_queue.add(nx);
					y_queue.add(ny);
					time_queue.add(ntime);
					dirty_queue.add(next_dirty);
				}
			}
			
			if(!flag){
				System.out.println("-1");
			}
		}
	}
	
}

Measured memory_bytes: 171580
#include<stdio.h>




int main()
{
    int N,i,count=0;
    scanf("%d",&N);
    char S[N+1];
    scanf("%s",S);
    for (i=0;S[i]!='\0';i++)
    {
        if (S[i]=='A' && S[i+1]=='B' && S[i+2]=='C')
        {
            count++;
            i+=2;
        }
    }
    printf("%d",count);


}


Measured memory_bytes: 1704
#include<iostream>
#include<cstdio>
#include<cstring>
#define x first
#define y second

namespace hh
{
	typedef long long ll;
	typedef std::pair<ll,ll> pii;
	const int N=105;

	int begin[N],next[N*2],to[N*2];

	int n,e;

	void add(int x,int y,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		if(k)add(y,x,0);
	}
	void initialize()
	{
		scanf("%d",&n);
		for(int i=1,u,v;i<n;i++)
			scanf("%d%d",&u,&v),add(u,v);
	}

	int fa[N];

	pii dfs(int p,int h=0)
	{
		fa[p]=h;

		pii ret(0,p);

		for(int i=begin[p],q;i;i=next[i])
			if((q=to[i])!=h)
			{
				pii tmp=dfs(q,p);
				tmp.x++;
				ret=std::max(tmp,ret);
			}
		return ret;
	}

	int maxd[N],tot;

	void DFS(int p,int h=0,int dis=0)
	{
		tot=std::max(tot,dis);

		int deg=0;
		for(int i=begin[p],q;i;i=next[i])
			if((q=to[i])!=h)DFS(q,p,dis+1),deg++;
		maxd[dis]=std::max(maxd[dis],deg);
	}

	pii calc_point(int p)
	{
		memset(maxd,0,sizeof(maxd)),tot=0;
		DFS(p);
		ll pi=1;
		for(int i=0;i<tot;i++)pi*=maxd[i];
		return pii(tot+1,pi);
	}
	pii calc_edge(int u,int v)
	{
		memset(maxd,0,sizeof(maxd)),tot=0;
		DFS(u,v),DFS(v,u);
		ll pi=2;
		for(int i=0;i<tot;i++)pi*=maxd[i];
		return pii(tot+1,pi);
	}

	void solve()
	{
		initialize();

		pii ans(23333,23333);

		for(int p=1;p<=n;p++)
			ans=std::min(ans,calc_point(p));
		for(int p=1;p<=n;p++)
			for(int i=begin[p],q;i;i=next[i])
				if((q=to[i])<p)ans=std::min(ans,calc_edge(p,q));

		printf("%lld %lld\n",ans.x,ans.y);
	}
}


int main()
{
	hh::solve();
	return 0;
}


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

int main(){

	std::array<int, 4> A;
	while(std::cin >> A[0] >> A[1] >> A[2] >> A[3]){
		std::array<int, 4> B;
		std::cin >> B[0] >> B[1] >> B[2] >> B[3];
		
		int hit = 0;
		int blow = 0;
		for(int i=0; i<4; ++i){
			if( A[i] == B[i] )
				++hit;
			else
				for(int j=0; j<4; ++j)
					if( A[i] == B[j] )
						++blow;
		}
		std::cout << hit << " " << blow << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

const ll MOD=(ll)1e9+7;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n,m;cin>>n>>m;
    bool state[n+1];mset(state);
    ll d;
    for(int i=0;i<m;i++){
        cin>>d;state[d]=true;
    }
    ll dp[n+1];mset(dp);
    dp[0]=1;
    dp[1]=(state[1]?0:1);
    for(int i=2;i<=n;i++){
        if(state[i]){dp[i]=0;continue;}
        dp[i]=dp[i-2]+dp[i-1];
        dp[i]%=MOD;
    }
    //print(dp);
    cout<<dp[n]<<"\n";
}


Measured memory_bytes: 4528
#include <iostream>
#include <algorithm>
#include <map>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;

int a[30];
int L;

int nextNum(string pre, int L)
{
	map<char, int> cnt;
	if (pre.length() < L) {
		cnt['0'] = L - pre.length();
	}
	REP(i,pre.length()) cnt[pre[i]]++;

	string small = "", large = "";
	for (char c='0'; c<='9'; c++) {
		REP(i,cnt[c]) {
			small = small + c;
			large = c + large;
		}
	}

	//cout << "large = " << large << endl;
	//cout << "small = " << small << endl;

	return stoi(large) - stoi(small);
}
 
signed main()
{
	while (true) {
		cin >> a[0] >> L;
		if (a[0] == 0 && L == 0) break;
		FOR(i,1,30) {
			a[i] = nextNum(to_string(a[i-1]), L);
			//cout << a[i] << endl;
		}

		int ans_i, ans_j;
		for (int i=29; i>0; i--) {
			for (int j=0; j<i; j++) {
				if (a[i] == a[j]) {
					ans_i = i;
					ans_j = j;
				}
			}
		}

		cout << ans_j << " " << a[ans_i] << " " << ans_i - ans_j << endl;
	}
}

Measured memory_bytes: 3276
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m;
    cin >> n >> m;
    vector<int> vec(m);
    rep(i,n)
    {
        int k;
        cin >> k;
        rep(j,k)
        {
            int a;
            cin >> a;
            a--;
            vec[a] += 1;
         }
    }
    
    int cnt=0;
    rep(i,m)
    {
        if(vec[i]==n)
        {
            ++cnt;
        }
    }
    
    cout << cnt << endl;
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

long long int check(int);
long long int solve();

long long int n,van_num;
long long int cab[100000];

int main(){
  long long int i;
  long long int tmp;

  scanf("%d %d",&n,&van_num);
  for(i=0;i<n;i++){
    scanf("%d",&cab[i]);
  }
  tmp=solve();
  printf("%d\n",tmp);
  
  return 0;
}

long long int check(int max_burd){
  long long int i=0,j;
  long long int van_burd;
  for(j=0;j<van_num;j++){
    van_burd=0;
    while(van_burd+cab[i]<=max_burd){
      van_burd+=cab[i];
      i++;
      if(i==n) return n;
    }
  }
  return i;
}

long long int solve(){
  long long int left=0;
  long long int right=100000*10000;
  long long int mid;
  long long int num_pie;

  while(right-left>1){
    mid=(left+right)/2;
    num_pie=check(mid);
    if(num_pie>=n){
      right=mid;
    }else{
      left=mid;
    }
  }

  return right;
}



Measured memory_bytes: 2604
#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 ll long long
#define INF 999999999
using namespace std;
int main() {
  int S,W;
  std::cin >> S >> W;
  if (W >= S) {
    std::cout << "unsafe" << endl;
  }
  else{
    std::cout << "safe" << '\n';
  }
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <utility>

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,a,b) for(ll i=(a); i < (b); i++)
#define RFOR(i,a,b) for(ll i=(b)-1; i >= (a); i--)
#define rep(i,n) FOR(i,0,(n))
#define rrep(i,n) RFOR(i,0,(n))

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	bool f = true;
	rep(i,N) {
		cin >> a[i];
		if(a[i] > 0) f = false;
	}
	ll mx = -1e10;
	vector<int> o;
	if(f) {
		int indx = 0;
		for(int i = 0; i < N; i++) {
			if(a[indx] < a[i]) {
				indx = i;
			}
		}
		mx = a[indx];
		int cnt = N;
		for(int i = 0; i < indx; i++, cnt--)
			o.push_back(1);
		for(int i = indx+1; i < N; i++, cnt--)
			o.push_back(cnt);
	}
	else {
		ll t0 = 0, t1 = 0;
		vector<int> v0, v1;
		for(int i = 0; i < N; i += 2) {
			if(a[i] > 0) {
				t0 += a[i];
				v0.push_back(i);
			}
			if(i+1 < N && a[i+1] > 0) {
				t1 += a[i+1];
				v1.push_back(i+1);
			}
		}
		vector<int> v;
		if(t0 > t1) {
			mx = t0;
			v = v0;
		} else {
			mx = t1;
			v = v1;
		}
		int cnt = N;
		for(int i = 0; i < v[0]; i++, cnt--)
			o.push_back(1);
		for(int i = 1; i < v.size(); i++) {
			for(int j = 1; j < (v[i]-v[i-1]) / 2; j++) {
				o.push_back(3);
				cnt -= 2;
			}
			o.push_back(2);
			cnt -= 2;
		}
		while(cnt > 1)
			o.push_back(cnt--);
	}

	cout << mx << endl;
	cout << o.size() << endl;
	for(int i = 0; i < o.size(); i++)
		cout << o[i] << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String str1 = line.replaceAll("apple", "テンプ");
		String str2 = str1.replaceAll("peach", "apple");
		String str3 = str2.replaceAll("テンプ", "peach");
        System.out.println(str3);
	}
}

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

int main(void) {
  string s;
  cin >> s;
  int counter;
  if (s[0] == 'o') {
    ++counter;
  }
  if (s[1] == 'o') {
    ++counter;
  }
  if (s[2] == 'o') {
    ++counter;
  }

  cout << 700+100*counter << endl;
}

Measured memory_bytes: 256
from collections import deque
from math import ceil

n,d,a = map(int,input().split())
xh = sorted([list(map(int,input().split())) for _ in range(n)])

q = deque()
ans = 0
count = 0
total = 0
for x,h in xh:
    while q:
        if q[0][0] < x:
            total -= q.popleft()[1]
        else:
            break
    
    if total < ceil(h/a):
        count = ceil(h/a)-total
        ans += count
        total += count
        q.append((x+2*d,count))

print(ans)

Measured memory_bytes: 66392
N,T = map(int, input().split())
List = []
for i in range(N):
    List.append([int(a) for a in input().split()])

ok_list = []
for j in range(N):
    if List[j][1] <= T:
        ok_list.append(List[j][0])
if ok_list == []:
    print("TLE")
else:
    ok_list.sort()
    print(ok_list[0])

Measured memory_bytes: 3060
N, M = map(int, input().split())
adj = [[] for _ in range(N)]
E = []
for _ in range(M):
	a, b = map(int, input().split())
	adj[a - 1].append(b - 1)
	adj[b - 1].append(a - 1)
	E.append([a - 1, b - 1])
	
ans = 0

for i in range(M):
	# bfs
	Q = [0]
	visited = [False for _ in range(N)]
	while Q:
		if all(visited): break
		cur_v = Q.pop(0)
		visited[cur_v] = True
		for adj_v in adj[cur_v]:
			if visited[adj_v] == False:
				# print(cur_v, adj_v, E[i])
				if (cur_v != E[i][0] or adj_v != E[i][1]) and (cur_v != E[i][1] or adj_v != E[i][0]):
					visited[adj_v] = True
					Q.append(adj_v)
	# print(visited)
	if all(visited):
		ans += 1
		
print(M - ans)

Measured memory_bytes: 41708
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll> a(n);
	rep(i, n)cin >> a[i];
	map<ll, ll> ma;
	ma[0]++;
	ll now = 0;
	rep(i, n) {
		now = (now + a[i]) % m;
		ma[now]++;
	}
	ll cnt = 0;
	for (auto itr : ma) {
		cnt += (itr.second*(itr.second - 1)) / 2;
	}
	cout << cnt;


	return 0;
}

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

int main() {
  string sa, sb, sc;
  cin >> sa >> sb >> sc;
  char turn = 'a';
  string ans;
  while (true) {
    if (turn == 'a') {
      if (sa.empty()) {
        ans = "A";
        break;
      }
      turn = sa.at(0);
      sa.erase(0, 1);
    } else if (turn == 'b') {
      if (sb.empty()) {
        ans = "B";
        break;
      }
      turn = sb.at(0);
      sb.erase(0, 1);
    } else if (turn == 'c') {
      if (sc.empty()) {
        ans = "C";
        break;
      }
      turn = sc.at(0);
      sc.erase(0, 1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define endl "\n"
#define loop(i,s,e) for(int i=s;i<e;i++)
#define int long long
#define mp make_pair
#define pii pair<int,int>
#define mset(a,f)  memset(a , f , sizeof(a))
#define pb push_back
const int N = 2e5 + 6;
const int M = 1e9 + 7;
int n;

void solve()
{
	int a,b;
	cin >> a >> b;	

	int ans = (a*b);

	if(a == 1 || b == 1)
	{
		cout << 1;
	}
	else if(ans%2)
	{
		ans /= 2;
		cout << ans+1;
	}
	else cout << ans/2;
}
 
int32_t main()
{
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
    

 	
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"

using namespace std;
using ll = long long;

int main(void){
    Cin(int, a);
    Cin(int, b);
    Cin(string, s);
    auto t = s;
    Sort(t);
    Cout((s[a] == '-' && t[1] != '-') ? "Yes" : "No");
}





Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
*/
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
using ll=long long int; using dd=double;
using pii=pair<int,int>; using pll=pair<ll,ll>;
typedef vector<int> vi;
const ll INFLL=(ll)2e18, MOD=1'000'000'007;
const int INF=0x3f3fffff ;
/////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is: "<<x<<'\n';
#define DD(x,y) cerr<<"("<<#x<<","<<#y<<") are: "<<x<<" "<<y<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vector<vector<pll>> adj; vector<int> vis;
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m){ll res=1;while(n){if(n&1)res=(res*x)%m;n>>=1;x=((x%m)*(x%m))%m;}return res;}
bool ispow2(ll x){ return x && (!(x&(x-1)));}
ll gcd(ll x, ll y){ pll p{x,y}; while(p.ss) p={p.ss,p.ff%p.ss}; return p.ff;}

/////////////////// MAIN STARTS //////////////////////////////////
int main(){
  ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
  cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
  random_device rd; mt19937 genr(rd());

#ifdef DEBUG
  auto tStart = chrono::system_clock::now();
  //freopen("op.txt","w",stdout);
#endif

int ans=INF;
vi v(3);
for (int i=0;i<3;i++){cin>>v[i];}
sort(all(v));
do{
  int temp=abs(v[1]-v[0])+abs(v[2]-v[1]);
  ans=min(ans,temp);
}while(next_permutation(all(v)));
cout<<ans<<"\n";

#ifdef DEBUG
  auto diff=chrono::system_clock::now()-tStart;
	cerr<<"\nExecution time: "<<chrono::duration<dd,milli>(diff).count()<<" ms.\n";
#endif
return 0;
}


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

int main() {
  int N;
  cin >> N;
  if (N%1000 == 0) cout << 0 << endl;
  else cout << 1000-N%1000 << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void)
{
int h, w, i, j;
int a = 0;

while(a == 0){

 scanf("%d", &h);
 scanf("%d", &w);

if(h == 0)
break;

for(i = 0; i < h; i++){
 for(j = 0; j < w; j++){

if(i == 0 || i == h-1 || j == 0 || j == w-1)
 printf("#");
else
 printf(".");
}
 printf("\n");

}
 printf("\n");
}


return 0;

}




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

#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;

  int C[VMAX + 1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short) * n + 1);
  B = malloc(sizeof(short) * n + 1);

  for( i = 0 ; i <= VMAX ; i++) C[i] = 0;

  for(i = 0 ; i < n ; i++){
    scanf ("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for(i = 1 ; i <= VMAX ; i++) C[i] = C[i] + C[i - 1];

  for(j = 1 ; j <= n ; j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }


  for(i = 1 ; i <= n ; i++){
    if(i > 1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 8464
def main():
    n = int(input())
    xd = [map(int, input().split()) for _ in range(n)]
    mod = 998244353
    INF = 10 ** 10

    xx = [(x, x + d, i) for i, (x, d) in enumerate(xd, 1)]
    xx.sort()
    adj = [[] for _ in range(n + 1)]
    stack = [(INF, 0)]
    for l, r, i in xx:
        while stack[-1][0] <= l:
            stack.pop()

        ip = stack[-1][1]
        adj[ip].append(i)
        stack.append((r, i))

    stack2 = [0]
    d = [-1] * (n + 1)
    d[0] = 0
    c = [[] for _ in range(n + 1)]
    order = []
    while stack2:
        u = stack2.pop()
        order.append(u)
        for v in adj[u]:
            if d[v] == -1:
                d[v] = d[u] + 1
                c[u].append(v)
                stack2.append(v)

    dp = [1] * (n + 1)
    for u in order[::-1]:
        for v in c[u]:
            dp[u] *= dp[v]
            dp[u] %= mod

        dp[u] += 1
        dp[u] %= mod

    ans = dp[0] - 1
    ans %= mod
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 146940
using System;

namespace AtCoder {
    class Program {
        static void Main() {
            string abcd = Console.ReadLine();
            for(int b = 0; b < 1 << 3; b++) {
                int sum = abcd[0] - '0';
                string form = abcd[0].ToString();
                for(int i = 0; i < 3; i++) {
                    if((b & 1 << i) == 0) {
                        sum += abcd[i + 1] - '0';
                        form += "+" + abcd[i + 1];
                    } else {
                        sum -= abcd[i + 1] - '0';
                        form += "-" + abcd[i + 1];
                    }
                }
                if(sum == 7) {
                    Console.WriteLine($"{form}=7");
                    return;
                }
            }
        }
    }
}

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

int main() {
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	cin>>a[i];
	int i=1;
	int cnt=0;
	while(i!=2&&cnt<=n)
	{
		i=a[i];
		cnt++;
	}
	if(i==2)
	cout<<cnt<<endl;
	else
	cout<<-1<<endl;
	return 0;
}

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

using namespace std;


int main(){
    
    int N;
    cin >> N;
    int p[N];
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    
    bool ans = false;
    
    int aa = 0;
    for (int k = 0; k < N-1; k++) {
        if (p[k] <= p[k+1]) {
            aa += 1;
            
        }else{
            break;
        }
    }
    
    if (aa == N-1) {
        ans = true;
    }else{
        
        for (int i = 0; i < N; i++) {
            for (int j = i+1; j < N; j++) {
                swap(p[i], p[j]);
                
                aa = 0;
                for (int k = 0; k < N-1; k++) {
                    if (p[k] <= p[k+1]) {
                        aa += 1;
                        
                    }else{
                        swap(p[i], p[j]);
                        break;
                    }
                }
                
                if (aa == N-1) {
                    ans = true;
                    i = N;
                    break;
                    
                }
                
                
            }
            
            
        }
        
    }
    
    if (ans) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    
    
    
}


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> vec(N);
  for (int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  int64_t sum = 0;
  int64_t SUM = 0;
  for (int i = 0; i < N; i++){
    sum += (vec.at(i) % 1000000007);
    sum %= 1000000007;
  }
  for (int i = 0; i < N; i++){
    SUM += ((vec.at(i) % 1000000007) * (vec.at(i) % 1000000007)) % 1000000007;
    SUM %= 1000000007;
  }
  int64_t ans;
  if((sum * sum - SUM) % 2 == 1){
    ans = ((1000000007 + sum * sum - SUM) / 2) % 1000000007;
  }
  else if(sum * sum - SUM < 0){
    ans = ((2000000014 + sum * sum - SUM) / 2) % 1000000007;
  }
  else{
  	ans = ((sum * sum - SUM) / 2) % 1000000007 ;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int k,s;cin>>k>>s;
    int ans=0;
    rep(x,k+1)rep(z,k+1){
        int y=s-x-z;
        if(y>=0&&y<=k)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




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

int n;
cin >> n;

double sum = 0;

rep(i,n){
    double a;
    cin >> a;

    sum += 1 / a;
} 
double ans = 1 / sum;
cout << fixed << setprecision(7) << ans << endl;

return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <cassert>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define rep(i, l, r) for (ll i = (l); i <= (r); i++)
#define irep(i, r, l) for (ll i = (r); i >= (l); i--)
#define vec(t) vector<int>

using namespace std;
using ll = long long;
using veci = vec(int);
using vecll = vec(ll);

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

    veci N(5);
    rep(i, 0, 4) cin >> N[i];
    vector<pair<int, int>> B;

    veci idx(5);
    rep(i, 0, 4) idx[i] = i;
    int ans = 1e8;
    do {
        int t = 0;
        rep(i, 0, 4) {
            t = t + N[idx[i]];
            if (i != 4 && t % 10 != 0) t = t + (10 - (t % 10));
        }
        ans = min(ans, t);

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

    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
lst = sorted(list(map(int, input().split())), reverse=True)
if n == 2:
  print(lst[0])
elif n % 2 == 0:
  print(sum(lst[:n // 2]) * 2 - lst[0])
else:
  print(sum(lst[:(n - 1) // 2]) * 2 - lst[0] + lst[(n - 1) // 2])

Measured memory_bytes: 31428
n = int(input())##7
d = list(int(input()) for _ in range(n))##list([50,30,50,100,50,80,30][_] for _ in range(n))
for i in range(n-1):
    for j in range(i+1,n):
        if d[i]>d[j]:
            ##昇順
            buf = d[i]
            d[i] = d[j]
            d[j] = buf
cnt = 1
##print(d)
for i in range(1,n):
    if d[i] != d[i-1]:
        cnt += 1
print(cnt)
    
    


Measured memory_bytes: 3060
n = int(input())

s = list(input())

l = 0
r = n-1

ans = 0

while l < r:
    if s[l] == 'W' and s[r] == 'R':
        s[l] = 'R'
        s[r] = 'W'
        ans += 1
        l += 1
        r -= 1
    else:
        if s[l] == 'R':
            l += 1
        if s[r] == 'W':
            r -= 1

print(ans)


Measured memory_bytes: 10664
using System;

namespace AOJ0067
{
    class Program
    {
        sbyte[,] map;
        const int WIDTH = 12;
        int count;

        public void Proc()
        {
            while (true)
            {
                // initialize
                this.map = new sbyte[WIDTH + 2, WIDTH + 2];
                this.count = 0;
                //setMap
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;

                for (int i = 1; i <= WIDTH; i++)
                {
                    for (int j = 0; j < WIDTH; j++)
                    {
                        this.map[i, j + 1] = sbyte.Parse(input.Substring(j, 1));
                    }
                    if (i != WIDTH) input = Console.ReadLine();
                }

                count += checkMap();

                Console.WriteLine(count);
                if (string.IsNullOrEmpty(input = Console.ReadLine())) continue;
            }
        }

        static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }

        public int checkMap()
        {
            int res = 0;
            
            for (int x = 1; x <= WIDTH; x++)
            {
                for (int y = 1; y <= WIDTH; y++)
                {
                    if (this.map[y, x] == 1)
                    {
                        countIsland(y, x);
                        res++;
                    }
                }
            }
            return res;
        }

        public void countIsland(int y, int x)
        {
            this.map[y, x] = -1;
            checkAround(y, x);
            this.count++;
        }

        public void checkAround(int y, int x)
        {
            checkRight(y, x);
            checkLeft(y, x);
            checkDown(y, x);
            checkUp(y, x);
        }
        public void checkRight(int y, int x)
        {
            if (this.map[y, x + 1] == -1) return;
            if (this.map[y, x + 1] == 1)
            {
                this.map[y, x + 1] = -1;
                checkAround(y, x + 1);
            }
        }

        public void checkLeft(int y, int x)
        {
            if (this.map[y, x - 1] == -1) return;
            if (this.map[y, x - 1] == 1)
            {
                this.map[y, x - 1] = -1;
                checkAround(y, x - 1);
            }
        }

        public void checkDown(int y, int x)
        {
            if (this.map[y + 1, x] == -1) return;
            if (this.map[y + 1, x] == 1)
            {
                this.map[y + 1, x] = -1;
                checkAround(y + 1, x);
            }
        }

        public void checkUp(int y, int x)
        {
            if (this.map[y - 1, x] == -1) return;
            if (this.map[y - 1, x] == 1)
            {
                this.map[y - 1, x] = -1;
                checkAround(y - 1, x);
            }
        }


    }
}

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

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    ll N;
    cin>>N;
ll a= modpow(8, N, 1000000007) ;
 ll b=modpow(9, N, 1000000007) ;
 b*=2;
 ll c=modpow(10, N, 1000000007);
  ll d=a+c-b;
  d%=1000000007;
  d+=1000000007;
  d%=1000000007;
  cout<<d<<endl;
}


Measured memory_bytes: 3576
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define L 100000
  
int main(void) {
  
  int n, q, Time = 0;
  
  int head=0;
  int tail=1;
  
  char name[L][11];
  int time[L];
  
  
  scanf("%d%d", &n, &q);
  
   for( tail=0; tail<n; tail++) {
    scanf("%s%d", name[tail], &time[tail]);
  }
  
  while(head != tail) {
  	if(time[head] <=q) {
  		Time+=time[head];
  		printf("%s %d\n",name[head],Time);
  	} else {
  		Time +=q;
  		strcpy(name[tail],name[head]);
  		time[tail] = time[head] - q;
  		
  		if(tail + 1 >= L) {
  			tail = 0;
  		}else {
  			tail++;
  		}
  	}
  		if(head + 1 >= L) {
  			head = 0;
  		} else {
  			head++;
  	}
  }
  	return 0;
}

  
  	
  	


Measured memory_bytes: 3160
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m = map(int,input().split())
SC = [list(map(int,input().split())) for i in range(m)]
N = [-1]*n
for i in range(m):
  s,c = SC[i]
  s -=1
  if (N[s] != -1 and N[s] != c):
    print(-1);exit()
  else:
    N[s] = c
if n != 1 and N[0] == 0:
  print(-1);exit()
if N[0] == -1:
  if n == 1:N[0] = 0
  else: N[0] = 1
for i in range(1,len(N)):
  if N [i] == -1:
    N[i] = 0
print(*N,sep="")

  

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

int main() {
  int N;
  cin >> N;
  vector<uint64_t> data(N + 1);
  data.at(0) = 2;
  data.at(1) = 1;
  for(int i = 2; i <= N; i++) {
    data[i] = data[i - 1] + data[i - 2];
  }
  printf("%ld\n", data.at(N) );
}

Measured memory_bytes: 3688
str1 = input()
s = list(str1)
str2 = input()
p = list(str2)

for i in range(len(s)):
    count = 0
    for j in range(len(p)):
        #print(i,j)
        if s[(i+j)%len(s)] != p[j]:
            break
        else:
            count = count + 1
    if count == len(p):
        print('Yes')
        #print(count)
        break

if count != len(p):
    print('No')



Measured memory_bytes: 5560
a, b, c = map(int, input().split())
d = [a, b, c]
c5=0
c7=0
for i in range(3):
  if d[i]==5:
    c5 +=1
  elif d[i]==7:
    c7+=1
if c5==2 and c7==1:
  print("YES")
else:
  print("NO")

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

int n;
double d, x, ans, t;

int main () {
	scanf("%d%lf%lf", &n, &d, &x);
	while (n) {
		ans += (2.0 * n - 1) / 2.0 * x + d;
		t = 1.0 / n;
		d += d * t + (t * 0.5 - 1) * x;
		x += x * t * 2;
		d += x;
		--n;
	}
	printf("%.15f\n", (double)ans);
	return 0;
}
/*
2 1 1
*/

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest
import numpy as np

def resolve():
    n, m, k = map(int, input().split())
    A = [0] + list(map(int, input().split()))
    B = [0] + list(map(int, input().split()))

    cum_A = np.cumsum(A)
    cum_B = np.cumsum(B)

    # print(cum_A)
    # print(cum_B)

    ans = [0 for _ in range(n + 1)]

    for i in range(len(cum_A)):
        if k < cum_A[i]:
            pass
        elif k == cum_A[i]:
            ans[i] = i
        else:
            tmp_k = k - cum_A[i]

            left = 0
            right = len(cum_B) - 1

            if tmp_k >= cum_B[-1]:
                ans[i] = i + len(cum_B) - 1
            else:
                while 1:
                    mid = (left + right) // 2 # 真ん中より左
                    # print(left, right, mid)
                    if mid == left or mid == right:
                        break
                    else:
                        if tmp_k >= cum_B[mid]:
                            left = mid
                        else:
                            right = mid

                if tmp_k > cum_B[right]:
                    ans[i] = i + right
                else:
                    ans[i] = i + left

    # print(ans)
    print(max(ans))



class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 4 240
60 90 120
80 150 80 150"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 4 730
60 90 120
80 150 80 150"""
        output = """7"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5 4 1
1000000000 1000000000 1000000000 1000000000 1000000000
1000000000 1000000000 1000000000 1000000000"""
        output = """0"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 63720
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

/*---------------------------------------------------*/

int sieve(int n){
  int prime[1000000];
  bool is_prime[1000000];
  int p=0;
  for(int i=0;i<=n;i++)is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<=n;i++){
    if(is_prime[i]){
      prime[p++]=true;
      for(int j=2*i;j<=n;j+=i)is_prime[j]=false;
    }
  }
  return p;
}

int main(){
  int n;
  while(cin>>n){
    cout<<sieve(n)<<endl;
  }
  return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	int ans = 0, curr = 0;
	for(int i = 0; i < s.length(); i++) {
	    if(s[i] == 'R') curr++;
	    else curr = 0;
	    ans = max(ans, curr);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3632
import java.io.*;
 
class Main {
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    while(true){
      String str[] = br.readLine().split(" ");
      int a = Integer.parseInt(str[0]);
      int b = Integer.parseInt(str[1]);
      if(a == 0 && b == 0)
          break;
 
      for(int i = 0; i < a; i++){
          for(int j = 0; j < b; j++){
              if(i == 0 || i == a-1 || j == 0 || j == b-1)
                  sb.append("#");
              else
                  sb.append(".");
          }
          sb.append("\n");
      }
      sb.append("\n");
    }
    System.out.print(sb);
  }
}

Measured memory_bytes: 25424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
#define PI 3.14159265359
#define MOD 998244353
const int MAX = 510000;

int main() {
  int N;cin>>N;
  int F[N][10];
  rep(i,N){
   	rep(j,10){
    	cin>>F[i][j];
    }
   }
  ll P[N][11];
  rep(i,N){
   	rep(j,11){
    	cin>>P[i][j];
    }
   }
  ll mgain=-1000000000;
   for (int tmp = 1; tmp < (1 << 10); tmp++) {
    bitset<10> s(tmp);
    int count[N]; 
    rep(i,N){count[i]=0;} 
    rep(i,N){
    	rep(j,10){
        	if(s.test(j)&&F[i][j]==1){count[i]++;}
        }
    }
    ll gain=0;
    rep(i,N){
    	gain+=P[i][count[i]];
    }
    mgain=max(mgain,gain); 
  }
  cout<<mgain; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

lint gcd(lint p, lint q){
    if(p < q) swap(p, q);
    while(q){
        lint r = p % q;
        p = q;
        q = r;
    }
    return p;
}

int main(){
    lint p, q;
    scanf("%lld%lld", &p, &q);
    lint g = gcd(p, q);
    p /= g; q /= g;
    lint ans = 1;
    for(lint i=2; i*i<=q; ++i){
        if(q%i == 0){
            ans *= i;
            while(q%i == 0) q /= i;
        }
    }
    if(q > 1) ans *= q;
    printf("%lld\n", ans);
}


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

int main() {
  int a,b,c;cin>>a>>b>>c;
  cout << (a+b>=c ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N,K;cin>>N>>K;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  std::vector<int> w[234567];
  for(int i=0;i<N;i++)w[v[i]].push_back(i);
  int now=0;
  int cnt=0;
  while(now<N){
    int num=v[now];
    int l=0;int r=w[num].size();
    while(r-l>1){
      int m=(l+r)/2;
      if(w[num][m]>now)r=m;
      else l=m;
    }
    if(l==w[num].size()-1){
      cnt++;
      now=w[num][0]+1;
    }
    else{
      now=w[num][l+1]+1;
    }
  }
  cnt++;
  now=0;
  //cout<<"cnt"<<" "<<cnt<<endl;
  K%=cnt;
  if(K<5){
    set<int> s;
    stack<int> que;
    for(int i=now;i<K*N;i++){
      int j=i%N;//cout<<j<<endl;
      if(s.count(v[j])){
        //cout<<"delete"<<v[j]<<endl;
        while(que.size()){
          int o=que.top();que.pop();
          s.erase(o);
          if(o==v[j])break;
        }
      }
      else {
        //cout<<"insert"<<v[j]<<endl;
        que.push(v[j]);
        s.insert(v[j]);
      }
    }
    //return 0;
    std::vector<int> ans;
    while(que.size()){
      int o=que.top();que.pop();
      ans.push_back(o);
    }
    reverse(ans.begin(),ans.end());
    bool f=false;
    for(int p:ans){
      if(f)cout<<" ";cout<<p;
      f=true;
    }
    cout<<endl;
    return 0;
  }
  cnt=0;
  while(cnt<K-2){
    int num=v[now];
    int l=0;int r=w[num].size();
    while(r-l>1){
      int m=(l+r)/2;
      if(w[num][m]>now)r=m;
      else l=m;
    }
    if(l==w[num].size()-1){
      cnt++;
      now=(w[num][0]+1)%N;
    }
    else{
      now=w[num][l+1]+1;
    }
  }
  //cout<<"now "<<now<<" "<<"K "<<K<<endl;
  set<int> s;
  stack<int> que;
  for(int i=now;i<2*N;i++){
    int j=i%N;//cout<<j<<endl;
    if(s.count(v[j])){
      //cout<<"delete"<<v[j]<<endl;
      while(que.size()){
        int o=que.top();que.pop();
        s.erase(o);
        if(o==v[j])break;
      }
    }
    else {
      //cout<<"insert"<<v[j]<<endl;
      que.push(v[j]);
      s.insert(v[j]);
    }
  }
  //return 0;
  std::vector<int> ans;
  while(que.size()){
    int o=que.top();que.pop();
    ans.push_back(o);
  }
  reverse(ans.begin(),ans.end());
  bool f=false;
  for(int p:ans){
    if(f)cout<<" ";cout<<p;
    f=true;
  }
  cout<<endl;
}


Measured memory_bytes: 27504
#include <iostream>
#include <set>

using namespace std;

typedef long long ll;

const int MAX_N = 1e5 + 5;
const ll INF = 1e18;

ll x [MAX_N];
ll dp [MAX_N];

int main () {
  ios::sync_with_stdio(false);

  int n, E, T;
  cin >> n >> E >> T;

  for (int i = 1; i <= n; i++) {
    cin >> x[i];
  }
  
  ll ans = 0;
  ans += E - x[n];
  ans += x[1];

  if (2 * (x[n] - x[1]) < T) {
    ans += T;
    ans += x[n] - x[1];
    cout << ans << endl;
    return 0;
  }

  ans += 3 * (x[n] - x[1]);
  
  set<pair<ll, int>, greater<pair<ll, int>>> zrange;
  set<pair<ll, int>, greater<pair<ll, int>>> lrange;

  x[n + 1] = x[n];
  lrange.insert(make_pair(dp[0] - 2 * x[1], 0));
  int lastl = 0;
  for (int i = 1; i <= n; i++) {
    while (lastl < i) {
      if (T - 2 * (x[i] - x[lastl + 1]) <= 0) {
        lrange.erase(make_pair(dp[lastl] - 2 * x[lastl + 1], lastl));
        zrange.insert(make_pair(dp[lastl], lastl));
        lastl++;
      } else {
        break;
      }
    }

    dp[i] = -INF;
    if (!lrange.empty()) {
      dp[i] = 2 * (x[i + 1] - x[i]) - T + 2 * x[i] + lrange.begin()->first;
    }
    if (!zrange.empty()) {
      dp[i] = max(dp[i], 2 * (x[i + 1] - x[i]) + zrange.begin()->first);
    }
    lrange.insert(make_pair(dp[i] - 2 * x[i + 1], i));
  }

  cout << ans - dp[n] << endl;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
#define ld long double
#define mid (l+r)/2
typedef pair<int,int> pii;
const int maxn=100005;
int a[maxn],b[maxn],n;
int tr[2*maxn];
inline int lowbit(int x){return x&(-x);}
void add(int x,int y)
{
    for(int i=x;i<=2*n+1;i+=lowbit(i)) tr[i]+=y;
}
int sum(int x)
{
    int ret=0;
    for(int i=x;i>=1;i-=lowbit(i)) ret+=tr[i];
    return ret;
}
ll calc(int x)
{
    memset(tr,0,sizeof tr);
    ll ret=0;
    add(n+1,1);
    for(int i=1;i<=n;i++)
    {
        if(a[i]<=x) b[i]=1;
        else b[i]=-1;
        b[i]+=b[i-1];
        ret+=sum(b[i]+n);
        add(b[i]+1+n,1);
    }
    return ret;
}
int main()
{
    #ifdef local
    freopen("in.txt","r",stdin);
    #endif
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    ll tot=1LL*(n+1)*n/2;
    int l=1,r=1e9,ans;
    while(l<=r)
    {
        if(calc(mid)>=tot/2+1)
        {
            ans=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    cout<<ans<<endl;
}


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

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

    ll output = 0;
    ll div = 10;
    if (N % 2 == 0) {
        while (div <= N) {
            output += N / div;
            div *= 5;
        }
        cout << output << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 3644