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

int main(){
  int N;
  cin >> N;
  int L[N];
  for(int i=0;i<N;i++){
    cin >> L[i];
  }
  std::sort(L,L+N);
  int part_sum = 0;
  for(int i=0;i<N-1;i++){
    part_sum += L[i];
  }
  if(part_sum > L[N-1]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

int main() {
  int a,b,c;
   cin >> a >> b >> c;
  int x=0;
   for(int i=a;i<=b;i++){
     if(c%i==0){
      x++;
   }
 }
  cout<< x  <<endl;
  
  return 0;
  
  
  
}


Measured memory_bytes: 3120
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N;
vector<int> ans(N);
vector<string> s(N);
for (int i = 0; i < N; ++i) cin >> s[i];
cin >> M;
vector<string> t(M);
for (int i = 0; i < M; ++i) cin >> t[i];
for (int i = 0; i < N; ++i) {
        ans.push_back(count(s.begin(), s.end(), s[i])
                         - count(t.begin(), t.end(), s[i]));
}
cout << *max_element(ans.begin(), ans.end()) << endl;
}

Measured memory_bytes: 888
using System;
using System.Collections.Generic;

public class AtCoderB
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        for (int i = 1; i <= 9; i++)
        {
            for (int j = i; j <= 9; j++)
            {
                if (i * j == n)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
        }

        Console.WriteLine("No");
    }
}

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

const int maxn = 100050;
const int INF = 0x3f3f3f3f;
int a[100050];
int dp[maxn];

int main()
{
	int n,k;
	cin>>n>>k;
	for(int i = 1;i<=n;++i)
	    cin>>a[i];
	
	dp[0] = 0,dp[1] = 0;
	for(int i = 2;i<=n;++i){
	    dp[i] = INF;
	    for(int j = i-1;j>=max(1,i-k);--j)
	        dp[i] = min(dp[i],dp[j]+abs(a[i]-a[j]));		
	}
	
	cout<<dp[n]<<endl;
	return 0;
} 

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

const int mxN = 1e5 + 5;
int n;
vector<int> adj[mxN];
int dp[mxN];

int solve(int v) {
	if (dp[v] != -1) {
		return dp[v];
	}
	int ans = 0;
	for (auto it : adj[v]) {
		ans = max(ans, 1 + solve(it));
	}
	return dp[v] = ans;
}

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

	int m;
	cin >> n >> m;
	int x, y;
	for (int i = 0; i < m; i++) {
		cin >> x >> y;
		x--;
		y--;
		adj[x].push_back(y);
	}
	int answer = 0;
	memset(dp, -1, sizeof(dp));
	for (int i = 0; i < n; i++) {
		answer = max(answer, solve(i));
	}
	cout << answer;

	return 0;
}

Measured memory_bytes: 8192
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

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

#define INF 200000000000

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

struct UnionFind
{
	vector<int> parent;
	vector<int> rank;

	UnionFind(int n) :parent(n, 0), rank(n, 0)
	{
		for (int i = 0; i < n; i++)
		{
			parent[i] = i;
		}
	}

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

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

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (x == y)
		{
			return;
		}

		if (rank[x] < rank[y])
		{
			parent[x] = y;
		}
		else
		{
			parent[y] = x;
			if (rank[x] == rank[y])
			{
				rank[x]++;
			}
		}
	}
};

struct OwnEdge
{
	int from, to, cost;
	OwnEdge(int from,int to,int cost):from(from),to(to),cost(cost){}
	OwnEdge():from(-1),to(-1),cost(-1){}

	bool operator<(const OwnEdge& o)const
	{
		return cost < o.cost;
	}
	bool operator>(const OwnEdge& o)const
	{
		return cost > o.cost;
	}
};

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

	int V, E;
	scanf("%d %d", &V, &E);

	priority_queue<OwnEdge, vector<OwnEdge>, greater<OwnEdge>> pq;
	UnionFind uf(V);

	for (int i = 0; i < E; i++)
	{
		int s, t, d;
		scanf("%d %d %d", &s, &t, &d);

		pq.push(OwnEdge(s, t, d));
	}

	int sum = 0;
	while (!pq.empty())
	{
		OwnEdge t = pq.top();
		pq.pop();

		if (!uf.same(t.from, t.to))
		{
			uf.unite(t.from, t.to);
			sum += t.cost;
		}
	}

	printf("%d\n", sum);

	return 0;
}


Measured memory_bytes: 4576
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 100000 + 10;
int n, x[N];
int L, Q, a[N], b[N];
int nex[N][22];
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i ++) {
        scanf("%d", &x[i]);
    }
    scanf("%d", &L);
    x[n+1] = 2e9+7;
    for (int i = 1; i <= n; i ++) {
        int pos = upper_bound(x+1, x+2+n, x[i]+L) - x - 1;
        nex[i][0] = pos;
    }
    for (int i = 1; i < 20; i ++) {
        for (int j = 1; j <= n; j ++) {
            nex[j][i] = nex[nex[j][i-1]][i-1];
        }
    }
    scanf("%d", &Q);
    for (int q = 1; q <= Q; q ++) {
        scanf("%d %d", &a[q], &b[q]);
        if (a[q] > b[q]) swap(a[q], b[q]);
        int ans = 0;
        for (int i = 19; i >= 0; i --) {
            if (nex[a[q]][i] < b[q]) {
                ans += (1<<i);
                a[q] = nex[a[q]][i];
            }
        }
        for (int i = 0; i <= 19; i ++) {
            if (nex[a[q]][i] >= b[q]) {
                ans += (1<<i);
                break;
            }
        }
        printf("%d\n", ans);
    }
}






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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

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

  int N; cin >> N;
  map<PII,int> xs;
  REP(i,N){
	PII p;
	int w; cin >> p >> w;
	xs[p] = w;
  }

  LL ans = 0;
  for(auto p: xs){
	for(int i=0;i<8;i+=2){
	  LL sum = p.SS;
	  REP(j,3){
		PII n(p.FF.FF+dx[(i+j)%8], p.FF.SS+dy[(i+j)%8]);
		if(xs.count(n))
		  sum += xs[n];
	  }
	  ans = max(ans, sum);
	}
  }

  cout << ans << " / " << 1 << endl;
  
  return 0;
}

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

int main(void) {
  int n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << 0 << endl;
    return 0;
  }
  int y = n - (k-1);
  int x = 1;
  cout << y -x << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.nextLine().toCharArray();

        boolean isFound = false;
        int aLocation = 0;
        int zLocation = 0;
        for(int i=0; i<s.length; i++) {
            if(s[i] == 'A' && !isFound) {
                isFound = true;
                aLocation = i;
            } else if(s[i] == 'Z') {
                zLocation = i;
            }
        }
        System.out.println(zLocation - aLocation + 1);
        sc.close();
    }
}


Measured memory_bytes: 26328
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch RightTriangle | diff RightTriangle.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address RightTriangle.cpp && ./a.out

/*
 
 2/19/2019
 
 19:25-
 
 */

int a,b,c;

void solve() {
  cout<<(a*b)/2<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>a>>b>>c;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private long[] elems;
	private long result;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		String[] tokens = in.nextLine().split(" ");
		Main main = new Main(tokens);
		System.out.println(main.result);
		in.close();
	}

	public Main(String[] tokens) {
		this.elems = new long[tokens.length];
		for (int i = 0; i < tokens.length; ++i) {
			elems[i] = Long.parseLong(tokens[i]);
		}

		for (int i = 0; i < elems.length; ++i) {
			result += divCount(elems[i]);
		}
	}

	private int divCount(long num) {
		int result = 0;
		while (true) {
			if (num % 2 != 0) {
				break;
			}
			result++;
			num = num / 2;
		}
		return result;

	}

}


Measured memory_bytes: 26504
import java.util.Scanner;

public class Main {
    static Node nil = new Node(-1, null, null, null);
    static Node root = nil;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            String order = sc.next();
            if (order.startsWith("i")) {
                    insert(root, new Node(sc.nextInt(), nil, nil, nil));
            } else {
                printInorder(root);
                System.out.println();
                printPreorder(root);
                System.out.println();
            }
        }
    }
    static void insert(Node nd, Node z) {
        Node y = nil; // parent of x
        Node x = nd;
        while (!x.equals(nil)) {
            y = x; // 親を設定
            if (z.val < x.val)
                x = x.left;
            else
                x = x.right;
        }
        z.parent = y;
        
        //  Tが空の場合
        if (y.equals(nil))
            root = z;
        else if (z.val < y.val)
            y.left = z;
        else
            y.right = z;
    }
    
    static void printInorder(Node arg) {
        Node nd = arg;
        if(!nd.equals(nil)) {
            printInorder(nd.left);
            System.out.print(" " + nd.val);
            printInorder(nd.right);
        }
    }
    
    static void printPreorder(Node arg) {
        Node nd = arg;
        if(!nd.equals(nil)) {
            System.out.print(" " + nd.val);
            printPreorder(nd.left);
            printPreorder(nd.right);
        }
    }
    
    static class Node {
        int val;
        Node parent;
        Node left;
        Node right;
        
        Node (int val, Node parent, Node left, Node right) {
            this.val = val;
            this.parent = parent;
            this.left = left;
            this.right = right;
        }
        Node (int val) {
            this.val = val;
            this.parent = nil;
            this.left = nil;
            this.right = nil;
        }
    }
}


Measured memory_bytes: 219156
#include<bits/stdc++.h>
using namespace std;
long MOD=1e9+7,n,k,ans=1,l,r,flg=1,a[1<<18],x,y;
int main(){
  cin>>n>>k;
  r=n-1;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  if(k%2)ans=a[r],r--,k--,flg=(ans<0?-1:1);
  while(k){
    x=a[l]*a[l+1],y=a[r]*a[r-1];
    if(x*flg>y*flg)ans*=x%MOD,ans%=MOD,l+=2;
    else ans*=y%MOD,ans%=MOD,r-=2;
    k-=2;
  }
  cout<<(ans+MOD)%MOD<<endl;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n;

signed main() {
    cin >> n;
    cout << (double)(n%2 + n/2)/(double)n << endl;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

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

	long long ans = 0;

	for (int i = 0; i < n - k; i++)
		ans += h[i];

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

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

using namespace std;

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

 int a[100];
 for(int i=0;i<n;i++) cin>>a[i];
 for(int i=0;i < n-1-i;i++) swap(a[i], a[n-1-i]);

 for(int i=0;i<n;i++){
  if(i) cout<<" ";
  cout<<a[i];
 }
  cout<<endl;

}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const ll INF = LLONG_MAX / 10;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int n, t, src, dst, V;
map<string, int> id;

vector<vi> stations;
vector<vi> cost;
vector<vector<pii>> change;
typedef pair<ll, int> Weight;


int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	string ss, sd;
	cin >> n >> t >> ss >> sd;
	id[ss] = 0; id[sd] = 1;
	src = 0, dst = 1;
	V = 2;
	stations.resize(n);
	cost.resize(n);
	change.resize(2);
	REP(i, n)
	{
		int a; cin >> a;
		REP(j, a)
		{
			string s; cin >> s;
			if (!id.count(s))
			{
				id[s] = V;
				V++;
				change.resize(V);
			}
			stations[i].push_back(id[s]);
			change[id[s]].emplace_back(i, j);
		}
		REP(j, a - 1)
		{
			int t; cin >> t;
			cost[i].push_back(t);
		}
	}

	
	//vector<Weight> d(V, Weight(INF, 1e9));
	vector<vector<Weight>> d(n);
	REP(i, n)
	{
		d[i].resize(stations[i].size(), Weight(INF, 1e9));
	}
	vector<bool> used(V);
	priority_queue<pair<Weight, pii>, vector<pair<Weight, pii>>, greater<pair<Weight, pii>>> que;
	for(auto i: change[0])
	{
		d[i.first][i.second] = Weight(0, 0);
		que.emplace(make_pair(Weight(0, 0), i));
	}
	while (!que.empty())
	{
		Weight w = que.top().first;
		int rosen = que.top().second.first;
		int pos = que.top().second.second;
		que.pop();
		int tmp = stations[rosen][pos];
		if (d[rosen][pos] < w) continue;
		if (pos != 0)
		{
			int ct = cost[rosen][pos-1];
			if (d[rosen][pos-1] > Weight(w.first + ct, w.second))
			{
				d[rosen][pos-1] = Weight(w.first + ct, w.second);
				que.emplace(make_pair(d[rosen][pos - 1], pii(rosen, pos - 1)));
			}
		}
		if (pos != stations[rosen].size() - 1)
		{
			int ct = cost[rosen][pos];
			if (d[rosen][pos + 1] > Weight(w.first + ct, w.second))
			{
				d[rosen][pos + 1] = Weight(w.first + ct, w.second);
				que.emplace(make_pair(d[rosen][pos + 1], pii(rosen, pos + 1)));
			}
		}
		if (!used[tmp])
		{
			used[tmp] = true;
			for (auto i : change[tmp])
			{
				if (d[i.first][i.second] > Weight(w.first + t, w.second + 1))
				{
					d[i.first][i.second] = Weight(w.first + t, w.second + 1);
					que.emplace(make_pair(d[i.first][i.second], pii(i.first, i.second)));
				}
			}
		}
	}
	Weight ans(INF, 1e9);
	for (auto i : change[dst]) chmin(ans, d[i.first][i.second]);
	if (ans.first >= INF) cout << -1 << endl;
	else cout << ans.first << " " << ans.second << endl;
	return 0;
}

Measured memory_bytes: 21736
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n; cin >> n;
	int a = 9;
	while (a > 0 and n % a != 0) a--;

	if (a == 0) cout << "No";
	else {
		if (((n / a) <= 9) and ((n / a) >= 1)) cout << "Yes";
		else cout << "No";
	}

	return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define all(x) x.begin(),x.end()
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

//
int main(void) {
    int N,K;
    string s;
    cin >> N >> s >> K;
    rep(i,s.size()){
        if(s[i]!=s[K-1]){
            s[i] = '*';
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    int a,b,c=0,d=0,k=0,n,h,w,m,ans=0;
    string s,s2;
    cin >> n; 
    for(int i=1; i<=n;i++){
        s = to_string(i);
        if(s.size()%2==1){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define fi first
#define se second

const int N = 111100;
const int MAGIC = 1000;
const long long mod = 998244353;

using namespace std;

int n;
int a[N];
int res[N];
vector < int > v[N];

void dfs(int x, int p = -1)
{
        res[x] = a[n--];
        for(int y: v[x]){
                if(y == p){
                        continue;
                }
                dfs(y, x);
        }
}

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> n;
        for(int i = 1; i < n; i++){
                int x, y;
                cin >> x >> y;
                v[x].push_back(y);
                v[y].push_back(x);
        }
        for(int i = 1; i <= n; i++){
                cin >> a[i];
        }
        sort(a + 1, a + n + 1);
        int s = 0;
        for(int i = 1; i < n; i++){
                s += a[i];
        }
        dfs(1);
        cout << s << "\n";
        for(int i = 1; res[i]; i++){
                cout << res[i] << " ";
        }
}


Measured memory_bytes: 3840
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;


namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Read();
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;

            var A=0;
            if (N % 2 == 0)
            {
                A = N;
            }
            else
            {
                A = N * 2;
            }

            Console.WriteLine(A);
            Console.Read();

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        ///
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
#define enld endl
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int X,N; cin >> X >> N;
    int p[105];
    for(int i=0;i<N;i++){
        cin >> p[i];
    }
    sort(p,p+N);
    int ans = X;
    int i = 0;
    while(true){
        if(!(binary_search(p,p+N,X-i))){
            cout << X-i << endl;
            return 0;
        }
        if(!(binary_search(p,p+N,X+i))){
            cout << X+i << endl;
            return 0;
        }
        i++;
    }
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

int main(void){
    ll n,m;
    cin>>n>>m;
    vector<ll>x(n),y(m);
    for(ll i=0;i<n;i++)cin>>x[i];
    for(ll i=0;i<m;i++)cin>>y[i];
    ll sumx=0,sumy=0;
    for(ll i=0;i<n;i++){
        sumx=(sumx+i*x[i]%N-(n-1-i)*x[i]%N)%N;
    }
    for(ll i=0;i<m;i++){
        sumy=(sumy+i*y[i]%N-(m-1-i)*y[i]%N)%N;
    }
    cout<<((sumx+N)%N*(sumy+N)%N)%N<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct mint {
    const int mod = 1e9 + 7;
    long long x;
    
    mint (long long x = 0) : x((x % mod + mod) % mod) {
        
    }
    
    mint& operator=(const long long a) {
        x = a % mod;
        return *this;
    }
    
    mint& operator=(const mint a) {
        x = a.x % mod;
        return *this;
    }
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    
    mint& operator-=(const mint a) {
        if ((x += (mod - a.x)) >= mod) x -= mod;
        return *this;
    }
    
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    
    mint inv() const {
        return pow(mod - 2);
    }
    
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    vector<ll> s(n);
    rep(i, n) cin >> s[i];
    vector<ll> t(m);
    rep(i, m) cin >> t[i];
    vector<vector<mint>> dp(n + 1, vector<mint>(m + 1, 0));
    dp[0][0] = 1;
    rep(i, n + 1) {
        rep(j, m + 1) {
            if (i > 0) dp[i][j] += dp[i - 1][j];
            if (j > 0) dp[i][j] += dp[i][j - 1];
            if ((i > 0) && (j > 0)) {
                dp[i][j] -= dp[i - 1][j - 1];
                if (s[i - 1] == t[j - 1]) dp[i][j] += dp[i - 1][j - 1];
            }
        }
    }
    cout << dp[n][m].x << endl;
    return 0;
}


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

#define ll long long
#define ld long double
#define fi first
//#define endl "\n"
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define initialize(array,size,value) for(ll i=0;i<size;i++) array[i]=value
#define couta(array,size) for(ll i=0;i<size;i++) cout<<array[i]<<" "
#define debug(x) cout<<"x: "<<x<<endl
#define dbug(x,y) cout<<"x: "<<x<<"    "<<"y: "<<y<<endl
#define inf (long long int) 1e18
#define eps 0.000001
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
#define mod 1000000007
#define MAXN 100001
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
ll spf[MAXN]; 
ll gcd(ll a,ll b);
ll palindrome(string s);
ll modexp(ll a,ll b,ll m);
void sieve();
ll ceil(ll a, ll b);
vl getFactorization(ll x);
void getZarr(string str, ll Z[]);
vector<ll> prefix_function(string s);

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
        
    ll r, g, b, n, ans=0;
    cin>>r>>g>>b>>n;
    loop(i,0,5000){
        loop(j,0,5000){
            ll x=n-i*r-j*g;
            if(x>=0 && x%b==0) ans++;
        }
    }
    cout<<ans<<endl;

}

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

ll palindrome(string s){
    ll l = 0;
    ll h = s.length() - 1;
    while (h > l){
        if (s[l++] != s[h--]){
            return 0;
        }
    }
    return 1;
}

ll modexp(ll a, ll b, ll m){
    if (b==0)
        return 1;
    ll temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

void sieve() { 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int L, R, d;

    scanf("%d%d%d", &L, &R, &d);

    int num = 0;
    for (int i = L; i <= R; i++)
    {
        if (i % d == 0)
        {
            num++;
        }
    }

    printf("%d\n", num);

    return 0;
}

Measured memory_bytes: 1716
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

void add_self(int &a, int b, int m){
    a%=m;
    b%=m;
    a+=b;
    if(a>=m)a-=m;
}

signed main() {
   tezz
   
   int n;
   cin >> n;
   string s;
   cin >> s;
   if(n%2==1){
       cout << "No";
       return 0;
   }
   for(int i=0; i<n/2; i++){
       if(s[i]!=s[i+n/2]){
           cout << "No" << endl;
           return 0;
       }
   }
   cout << "Yes" << endl;
   
  
   return 0;
}



Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;//, core.stdc.stdio;

int sum2d(int[][] A, int r1, int c1, int r2, int c2) {
    return A[r2+1][c2+1] - A[r2+1][c1] - A[r1][c2+1] + A[r1][c1];
}

void main() {
    auto s = readln.split.map!(to!int);
    auto H = s[0];
    auto W = s[1];
    auto Q = s[2];
    auto B = H.iota.map!(_ => readln.chomp).array;

    auto blue = new int[][](H+1, W+1);
    foreach (i; 0..H) foreach (j; 0..W) blue[i+1][j+1] = B[i][j] == '1' ? 1 : 0;
    foreach (i; 0..H) foreach (j; 0..W) blue[i+1][j+1] += blue[i+1][j];
    foreach (j; 0..W) foreach (i; 0..H) blue[i+1][j+1] += blue[i][j+1];

    auto tate = new int[][](H+1, 2*W);
    foreach (i; 0..H) foreach (j; 0..W-1) tate[i+1][2*j+2] = (B[i][j] == '1' && B[i][j+1] == '1') ? 1 : 0;
    foreach (i; 0..H) foreach (j; 0..2*W-1) tate[i+1][j+1] += tate[i+1][j];
    foreach (j; 0..2*W-1) foreach (i; 0..H) tate[i+1][j+1] += tate[i][j+1];
    
    auto yoko = new int[][](2*H, W+1);
    foreach (i; 0..H-1) foreach (j; 0..W) yoko[2*i+2][j+1] = (B[i][j] == '1' && B[i+1][j] == '1') ? 1 : 0;
    foreach (i; 0..2*H-1) foreach (j; 0..W) yoko[i+1][j+1] += yoko[i+1][j];
    foreach (j; 0..W) foreach (i; 0..2*H-1) yoko[i+1][j+1] += yoko[i][j+1];


    while (Q--) {
        s = readln.split.map!(to!int);
        int r1 = s[0] - 1, c1 = s[1] - 1, r2 = s[2] - 1, c2 = s[3] - 1;
        int a = sum2d(blue, r1, c1, r2, c2);
        int b = sum2d(tate, r1, c1*2, r2, c2*2);
        int c = sum2d(yoko, r1*2, c1, r2*2, c2);
        writeln(a - b - c);
    }

}


Measured memory_bytes: 92284
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll k, x;std::cin >>  k >> x;
  std::cout << (k*500>=x?"Yes":"No") << '\n';
  return 0;
}


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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;


int tens[8];


int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	tens[0] = 1;

	for (int i = 1; i <= 7; ++i) {
		tens[i] = tens[i - 1] * 10;
	}

	int N;

	cin >> N;

	ll ans = 0, ansSame = 0;

	for (int A = 1; A <= N; ++A) {
		int tmp = A;
		vi digits;
		while (tmp)
			digits.pb(tmp % 10), tmp /= 10;
		if (digits[0] == 0)
			continue;

		if (sz(digits) == 1) {
			ansSame++;
			continue;
		}

//		db(A, digits);

		int mid = 0;

		for (int i = sz(digits) - 2; i >= 1; --i) {
			mid *= 10;
			mid += digits[i];
		}

		db(A, mid);

		if (digits[0] == digits.back()) {
			if (sz(digits) == 2) {
				ansSame += 1;
				ans++;
				continue;
			}

			++ans;	// if B has 1 digit
			for (int d = 2; d <= sz(digits) - 1; ++d) {
				ans += tens[d - 2];
			}
			ans += mid;
			++ansSame;	// A = B
		} else if (digits[0] < digits.back()) {
			for (int d = 2; d <= sz(digits); ++d) {
				ans += tens[d - 2];
			}
		} else {
			for (int d = 2; d <= sz(digits) - 1; ++d) {
				ans += tens[d - 2];
			}
		}
	}

	cout << ansSame + ans * 2 << '\n';

	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
    return 0;
}


Measured memory_bytes: 256
import javax.management.Query;
import javax.print.attribute.SupportedValuesAttribute;
import java.io.*;
import java.security.interfaces.DSAKeyPairGenerator;
import java.sql.Array;
import java.util.*;
import java.util.function.Predicate;


public class Main {

    static class TaskB {

        static int oo = Integer.MAX_VALUE - 1;

        static int MOD = 1000000007;


        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();

            int[] a = new int[n];
            int[] b = new int[n];
            int[] c = new int[n];

            for(int i = 0; i < n; i++)
            {
                a[i] = in.nextInt();
                b[i] = in.nextInt();
                c[i] = in.nextInt();
            }

            int[][] dp = new int[n][3];
            dp[0][0] = a[0];
            dp[0][1] = b[0];
            dp[0][2] = c[0];

            for(int i = 1; i < n; i++)
            {
                dp[i][0] = Math.max(dp[i-1][1], dp[i-1][2]) + a[i];
                dp[i][1] = Math.max(dp[i-1][2], dp[i-1][0]) + b[i];
                dp[i][2] = Math.max(dp[i-1][0], dp[i-1][1]) + c[i];
            }
            out.print(Math.max(Math.max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]));
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(in, out);
        out.close();
    }



    static void sort(int[] a)
    {
        ArrayList<Integer> list = new ArrayList<>();
        for(Integer i: a)list.add(i);
        Collections.sort(list);
        for(int i = 0; i < a.length; i++)a[i]=list.get(i);
    }


    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer = new StringTokenizer("");

        public InputReader(InputStream inputStream) {
            this.reader = new BufferedReader(
                    new InputStreamReader(inputStream));
        }

        public String next() {
            while (!tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

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

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

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }
    }
}

Measured memory_bytes: 57016
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  ll H[N];
  for(int i=0;i<N;i++){
    cin >> H[i];
  }
  bool t = true;
  for(int j=N-1;j>0;j--){
    if(H[j]<H[j-1]){
      --H[j-1];
      if(H[j]!=H[j-1]){
	t = false;
	break;
      }
    }
  }
  if(t) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3884
(defun read-revlist (&optional (N (read)))
  (do ((i N (1- i))
       (l nil (cons (read) l)))
      ((= i 0) l)))


(defun solve (l)
  (- (reduce #'+ l)
     (/ (reduce #'max l) 2) ))

(princ (solve (read-revlist)))

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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LONG_LONG_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;

bool my_compare(pair<int, string> a, pair<int, string> b) {
    if(a.first != b.first){
        return a.first > b.first; // 降順
    }
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

int main() {
    int n;
    cin >> n;
    vector<pair<int, string>> str(n);
    vector<string> s(n);
    rep(i, n) {
        cin >> s.at(i);
    }
    sort(s.begin(), s.end());
    int count = 1;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            str.at(i).second = s.at(i);
            str.at(i).first = count;
            continue;
        }
        if (s.at(i) == s.at(i - 1)) {
            ++count;
            str.at(i).second = s.at(i);
            str.at(i).first = count;
        } else {
            str.at(i).second = s.at(i);
            str.at(i).first = 1;
            count = 1;
        }

    }
    sort(str.begin(), str.end(), my_compare);
    for(int i = 0; i < n; i++) {
       if (i == 0) {
            cout << str.at(i).second << endl;
            continue;
        }
        if (str.at(i).first == str.at(i - 1).first) {
            cout <<  str.at(i).second << endl;
        } else {
            return 0;
        }


    }
}



Measured memory_bytes: 17408
N, Q = map(int, input().split())
S = input()
lr = [0] * Q
for i in range(Q):
  lr[i] = list(map(lambda x: int(x) - 1, input().split()))

t = [0]*N
for i in range(1, N):
  t[i] = t[i-1] + (1 if S[i-1:i+1] == 'AC' else 0)
  
for i in range(Q):
  print(t[lr[i][1]] - t[lr[i][0]])

Measured memory_bytes: 32200
ABCD=list(map(int,list(input())))

n=8
bit=0
while(bit<n):
    tmp=ABCD[0]
    for i in range(0,3):
        if(bit & 1<<i):
            tmp+=ABCD[i+1]
        else:
            tmp-=ABCD[i+1]
    if(tmp==7):
        break
    else:
        bit+=1

print(ABCD[0],end="")
for i in range(0,3):
    if(bit & 1<<i):
        print("+{}".format(ABCD[i+1]),end="")
    else:
        print("-{}".format(ABCD[i+1]),end="")        
print("=7")

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>

using namespace std;
using ll = long long;

void solve();
int main() {
	solve();
#ifdef DBG
	while (true);
#endif
}

void solve() {
	int n, a[100000];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);
	sort(a, a + n);

	if (n <= 2) {
		printf("%d %d\n", a[1], a[0]);
		return;
	}
	int low = 0, upp = n - 1, cen = (low + upp) / 2;
	while (2 <= upp - low) {
		if (a[cen] <= a[n - 1] / 2)
			low = cen;
		else
			upp = cen;
		cen = (low + upp) / 2;
	}
	printf("%d %d\n", a[n - 1], abs(a[n - 1] / 2 - a[low]) < abs(a[n - 1] / 2 - a[upp]) ? a[low] : a[upp]);
}

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

void scaan(int *,int);
int solve(int,int *,int,int);

int main(){
  int *A[2],i,n[2];
  
  for(i = 0;i < 2;i++){
    scanf("%d",&n[i]);
    A[i] = (int *)malloc(n[i] * sizeof(int));
    scaan(A[i],n[i]);
  }
  
  for(i = 0;i < n[1];i++){
    if(0 != solve(0,A[0],A[1][i],n[0])) printf("yes\n");
    else printf("no\n");
    
  }

  
  
  free(A[0]);
  free(A[1]);
  return 0;
}

void scaan(int *a,int b){
  int i;
  // a = (int *)malloc(b * sizeof(int));
  for(i = 0;i < b;i++){
    scanf("%d",&a[i]);
  }
}

int solve(int i,int *A,int m,int n){
  int res;
  if(m == 0) return 1;
  if(i >= n) return 0;
  res = solve(i + 1,A,m,n) || solve(i + 1,A,m - A[i],n);
  return res;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e15 + 5;
int main(){
    long long n, W, sum_val = 0;
    cin >> n >> W;
    vector<long long>val(n), weight(n);
    for(int i = 0; i < n; i++){
        cin >> weight[i] >> val[i];
        sum_val += val[i];
    }
    vector<long long>dp(sum_val + 5, INF);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int v = sum_val - val[i]; v >= 0; v--){
            dp[v + val[i]] = min(dp[v + val[i]], dp[v] + weight[i]);
        }
    }
    for(int i = sum_val; i >= 0; i--){
        if(dp[i] <= W){
            cout << i;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int a[5005];
bool pre[5005][5005];
bool suf[5005][5005];
int cur[5005][5005];
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i = 1; i <= n; i++){
        scanf("%d",a+i);
    }
    pre[0][0] = true;
    for(int i = 1; i <= n; i++){
        for(int j = k-a[i]; j >= 0; j--){
            if(pre[i-1][j]) pre[i][j+a[i]] = true;
        }
        for(int j = 0; j <= k; j++){
            if(pre[i-1][j]) pre[i][j] = true;
        }
    }
    suf[n+1][0] = true;
    for(int i = n; i > 0; i--){
        for(int j = k-a[i]; j >= 0; j--){
            if(suf[i+1][j]) suf[i][j+a[i]] = true;
        }
        for(int j = 0; j <= k; j++){
            if(suf[i+1][j]) suf[i][j] = true;
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        cur[i][0] = suf[i+1][0] ? 1 : 0;
        for(int j = 1; j <= k; j++){
            cur[i][j] = cur[i][j-1] + (suf[i+1][j] ? 1 : 0);
        }
        for(int j = 0; j < k; j++){
            if(pre[i-1][j]){
                int cnt = cur[i][k-j-1];
                if(k-a[i]-1-j >= 0) cnt -= cur[i][k-a[i]-1-j];
                if(cnt > 0){
                    ans++;
                    break;
                }
            }
        }
    }
    printf("%d\n",n - ans);
}

Measured memory_bytes: 147072
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n;
	cin>>n;
	vl h(n);
	rep(i,n)cin>>h[i];
	cout<<accumulate(all(h),-(*max_element(all(h)))/2)<<endl;
	return 0;
}


Measured memory_bytes: 256