akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <vector>
//const int maxn = 1e5+5;
#define ll long long
#define MAX INT_MAX
#define FOR(i,a,b) for( int i = a;i <= b;++i)

using namespace std;

int main()
{
        int a,b,c;
        cin>>a>>b>>c;
        if(a+b==c||a+c==b||b+c==a)
        {
            cout<<"Yes";
            return 0;
        }
        cout<<"No";

}


Measured memory_bytes: 256
// B.

#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, char *argv[]) {
	int h, w;
	cin >> h >> w;
	cout << string(w + 2, '#') << endl;
	for (int i = 0; i < h; ++i) {
		string s;
		cin >> s;
		cout << "#" << s << "#" << endl;
	}
	cout << string(w + 2, '#') << endl;
	return 0;
}


Measured memory_bytes: 256
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
ll mod=1000000007;
int main()
{
fast;
    ll n;
    cin>>n;
    ll a[n][n];
    f(i,n)
      f(j,n)
        cin>>a[i][j];
    ll dp[1<<n];
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    f(mask,(1<<n)-1)
    {
        ll num=__builtin_popcountll(mask);
        f(i,n)
        {
            if(a[num][i]==1 && (mask & 1<<i)==0)
            {
                dp[mask | 1<<i]=(dp[mask | 1<<i]+dp[mask])%mod;
            }
        }
    }
    cout<<dp[(1<<n)-1];
    endd;
    return 0;
}

Measured memory_bytes: 20052
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

s = input().split("/")

if int(s[0]) <= 2018:
    print("Heisei")
elif int(s[0]) >= 2020:
    print("TBD")
elif int(s[1]) <= 3:
    print("Heisei")
elif int(s[1]) >= 5:
    print("TBD")
elif int(s[2]) <= 30:
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 3064
input_list = input().split(' ')
A = int(input_list[0])
B = int(input_list[1])
C = int(input_list[2])

if A + B >= C: # 解毒剤入り >= 毒入りの場合、美味しい全て食べられる
    print(B + C)
else: # 解毒剤入り < 毒入り場合、最初の1個 + 解毒剤分 + 解毒剤の美味しい
    print(1 + A + B + B)


Measured memory_bytes: 2940
#include<iostream>

using namespace std;

int a, b, c;
int main(){
    cin >> a >> b;
    while(1){
        c=1;
        for(int i=a;i<=b;i++) {
            if(i%4==0&&(i%100>0||i%400==0)) {
                cout<<i<<endl;c=0;
            }
             
        }
        if(c)
			cout << "NA" << endl;
        cin >> a >> b;
        if(a == 0 && b == 0)
			break;
        else 
			cout<<endl;
    }
    return 0;
}


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

int N;
int A[210];

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];
    
    int res = 0;
  
    while (true) {
      bool exist_odd = false;
      for (int i = 0; i < N; ++i) {
        if(A[i] % 2 != 0) exist_odd = true;
      }        
      
      if (exist_odd) break;
      
      for (int i = 0; i < N; ++i) {
          A[i] /= 2;
      }
      ++res;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
NK = gets.chomp.split(' ')
N = NK[0].to_i
K = NK[1].to_i

RSP = gets.chomp.split(' ')
R = RSP[0].to_i
S = RSP[1].to_i
P = RSP[2].to_i

T = gets.chomp

i = 0
hands = ''
score = 0
T.each_char do |c|
  if c == 'r'
    if i - K >= 0 && hands[i - K] == 'p'
      if T[i + K] == 'r'
        hands += 'r'
      elsif T[i + K] == 's'
        hands += 's'
      elsif T[i + K] == 'p'
        hands += 'r'
      else
        hands += 'r'
      end
    else
      hands += 'p'
      score += P
    end
  elsif c == 's'
    if i - K >= 0 && hands[i - K] == 'r'
      if T[i + K] == 'r'
        hands += 's'
      elsif T[i + K] == 's'
        hands += 's'
      elsif T[i + K] == 'p'
        hands += 'p'
      else
        hands += 's'
      end
    else
      hands += 'r'
      score += R
    end
  elsif c == 'p'
    if i - K >= 0 && hands[i - K] == 's'
      if T[i + K] == 'r'
        hands += 'r'
      elsif T[i + K] == 's'
        hands += 'p'
      elsif T[i + K] == 'p'
        hands += 'p'
      else
        hands += 'p'
      end
    else
      hands += 's'
      score += S
    end
  end

  i += 1
end

puts score


Measured memory_bytes: 83796
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
int main()
{
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++)
    cin>>a[i];
    ll res=0,val=0;
    for(int i=0;i<n;i++)
    {
        val=(val+a[i])%mod;
    }
    ll cur=0;
    for(int i=0;i<n;i++)
    {
        cur=(cur+a[i])%mod;
        res=(res+(a[i]*(val-cur))%mod+mod)%mod;
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 4832
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}

	int N;
	std::string S;
	std::cin >> N >> S;

	for (char ch : S) {
		ch += N;
		if (ch > 'Z')
			ch -= 26;
		std::cout << ch;
	}
	std::cout << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
#define ll long long
int main(){
	int H,W;
	cin >>H>>W;
	int area[H+1][W+1];
	int i,j;
	for(i=1;i<=H;i++){
		for(j=1;j<=W;j++){
			cin >> area[i][j];
		}
	}
	int tmp[H*W+1][4];
	int cnt=0;
	for(i=1;i<H;i++){
		for(j=1;j<=W;j++){
			if(area[i][j]%2==1){
				area[i][j]-=1;
				area[i+1][j]+=1;
				tmp[cnt][0]=i;
				tmp[cnt][1]=j;
				tmp[cnt][2]=i+1;
				tmp[cnt][3]=j;
				cnt++;
			}
		}
	}
	for(j=1;j<W;j++){
		if(area[H][j]%2==1){
				area[i][j]-=1;
				area[i][j+1]+=1;
				tmp[cnt][0]=H;
				tmp[cnt][1]=j;
				tmp[cnt][2]=H;
				tmp[cnt][3]=j+1;
				cnt++;
			}
		}
	cout << cnt <<endl;
	for(i=0;i<cnt;i++){
  	cout << tmp[i][0] << " " <<tmp[i][1]<< " " << tmp[i][2]<< " " <<tmp[i][3] <<endl;
}
	  return 0;
}


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

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
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;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	set<ll> s;
	rep(i,n){ll t;cin>>t;s.insert(t);}
	YN(s.size()==n);
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	const int MOD = 1000000007;

	int h, w, k;
	cin >> h >> w >> k;

	vector<vector<int>> dp(h + 1, vector<int>(w));
	dp[0][0] = 1;

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			for (int mask = 0; mask < 1 << (w - 1); mask++) {
				bool isConnect = false;
				for (int k = 0; k < w - 2; k++) {
					if (mask & (1 << k) && mask & (1 << (k + 1))) {
						isConnect = true;
						break;
					}
				}

				if (isConnect) {
					continue;
				}

				if (j >= 1 && mask & (1 << (j - 1))) {
					dp[i + 1][j - 1] += dp[i][j];
					dp[i + 1][j - 1] %= MOD;
				} else if ((j + 1) < w && mask & (1 << j)) {
					dp[i + 1][j + 1] += dp[i][j];
					dp[i + 1][j + 1] %= MOD;
				} else {
					dp[i + 1][j] += dp[i][j];
					dp[i + 1][j] %= MOD;
				}
			}
		}
	}

	cout << dp[h][k - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
q = int(input())
ans = sum(a)
count = [0] * 100005
for i in a:
    count[i] += 1
for i in range(q):
    b, c = map(int, input().split())
    ans += (c-b) * count[b]
    print(ans)
    count[c] += count[b]
    count[b] = 0
    

Measured memory_bytes: 20924
n=int(input())
if n<10:
  print(n)
elif n<10**2:
  print(9)
elif n<10**3:
  print(n-(10**2-1)+9)
elif n<10**4:
  print(900+9)
elif n<10**5:
  print(n-(10**4-1)+900+9)
else:
  print(9*10**4+9*10**2+9)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100000
using namespace std;
struct node
{
	int to;
	node *nxt;
}edges[MAXN*2+5];
node *ncnt=&edges[0],*Adj[MAXN+5];
int N;
void AddEdge(int u,int v)
{
	node *p=++ncnt;
	p->to=v;
	p->nxt=Adj[u];
	Adj[u]=p;
	
	node *q=++ncnt;
	q->to=u;
	q->nxt=Adj[v];
	Adj[v]=q;
}
int DFS(int u,int fa)
{
	int ret=0;
	for(node *p=Adj[u];p!=NULL;p=p->nxt)
	{
		int v=p->to;
		if(v==fa)
			continue;
		ret^=(DFS(v,u)+1);
	}
	return ret;
}
int main()
{
	scanf("%d",&N);
	int u,v;
	for(int i=1;i<N;i++)
	{
		scanf("%d %d",&u,&v);
		AddEdge(u,v);
	}
	if(DFS(1,-1)==0)
		printf("Bob\n");
	else
		printf("Alice\n");
	return 0;
}

Measured memory_bytes: 8704
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		System.out.print(s.charAt(0));
		System.out.print(s.length() - 2);
		System.out.println(s.charAt(s.length() - 1));
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=400005,mod=998244353;
int fac[N],rev[N],f[N],pre[N],t[N],p2[N],ip2[N],n,m,ans,emp=1;
char A[N],B[N],C[N],D[N];

int power(int x,int p){
	int res=1;
	for(;p;p>>=1,x=(ll)x*x%mod)
		if(p&1)res=(ll)res*x%mod;
	return res;
}
void init(int n){
	fac[0]=1;
	rep(i,1,n) fac[i]=(ll)fac[i-1]*i%mod;
	rev[n]=power(fac[n],mod-2);
	per(i,n,1) rev[i-1]=(ll)rev[i]*i%mod;
	p2[0]=1,ip2[0]=1;
	rep(i,1,n) p2[i]=2*p2[i-1]%mod;
	rep(i,1,n) ip2[i]=(ll)(mod/2+1)*ip2[i-1]%mod;
}
int Co(int n,int m){
	return m<0||m>n?0:(ll)fac[n]*rev[m]%mod*rev[n-m]%mod;
}

void solve(int n,int m){
	int ca=0,cb=0;
	rep(i,1,n) ca+=A[i]-'0',cb+=B[i]-'0';
	rep(i,1,m) t[i]=t[i-1]+(C[i]=='1'&&D[i]=='1');
	int cnt=0;
	rep(i,1,m){
		cnt+=(C[i-1]=='1')+(D[i-1]=='1');
		pre[i]=pre[i-1];
		if(C[i]=='1'||D[i]=='1'){
			f[i]=(ca==0?cnt==0:Co(ca+cnt-1,ca-1))*(1+t[i]-t[i-1])%mod;
			pre[i]=(pre[i]+(ll)f[i]*ip2[t[i]])%mod;
		}
	}
	cnt=0;
	per(i,m,1){
		cnt+=(C[i+1]=='1')+(D[i+1]=='1');
		if(C[i]=='1'||D[i]=='1'){
			int owo=(cb==0?cnt==0:Co(cb+cnt-1,cb-1)); 
			ans=(ans+(ll)owo*f[i])%mod;
			ans=(ans+(ll)owo*pre[i-1]%mod*p2[t[i]])%mod;
		}
	}
}

int main(){
	init(400000);
	read(n),read(m);
	scanf("%s%s",A+1,B+1);
	scanf("%s%s",C+1,D+1);
	rep(i,1,n) emp&=(A[i]=='0'&&B[i]=='0');
	rep(i,1,m) emp&=(C[i]=='0'&&D[i]=='0');
	if(emp) return puts("1"),0;
	solve(n,m);
	swap(A,C),swap(B,D);
	solve(m,n);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12800
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input())-1])


Measured memory_bytes: 9172
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
#include <numeric>
#include <cmath>

using namespace std;

int main(){
    vector<int> arr(3);
    copy_n(istream_iterator<int>(cin), 3, arr.begin());
    int max_ = accumulate(arr.begin(), arr.end(), 0, 
            [](int a, int b){ return (a < b ? b : a); });

    
    int times;
    cin >> times;
    cout << accumulate(arr.begin(), arr.end(), max_ * (int)pow(2, times)- max_) << endl;
    return 0;
}


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

using namespace std;


void solve() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for (int _ = 0; _ < m; _++) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        g[x].emplace_back(y);
    }
    vector<array<double,2>> e(n);
    e[n-1][0] = 0;
    for (int i = n-2; i >= 0; i--) {
        double sum = 0, mx = 0;
        for (int v: g[i]) {
            sum += e[v][0];
            mx = max(mx, e[v][0]);
        }
        e[i][0] = sum / g[i].size() + 1;
        if (g[i].size() > 1) e[i][1] = (sum-mx)/(g[i].size()-1) + 1;
        else e[i][1] = 1e12;
    }
    double res = min(e[0][0], e[0][1]);
    for (int i = 0; i < n-1; i++) {
        auto f = e;
        for (int j = i-1; j >= 0; j--) {
            double sum = 0;
            for (int v: g[j]) {
                sum += v==i? f[v][1] : f[v][0];
            }
            f[j][0] = sum / g[j].size() + 1;
        }
        res = min(res, f[0][0]);
    }
    cout << fixed << setprecision(10);
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

using namespace std;

typedef unsigned long long ull;

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

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

    int k = 0;
    ull sum=0;
    for(int i=0;i<N-1;++i){
        sum += A[i];
        if(sum*2 < A[i+1]){
            k = i+1;
        }
    }
    cout << N - k << endl;
}


Measured memory_bytes: 640
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cassert>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define BASE 77747
#define PI acos(-1.0)
#define MAXLEN 29

typedef std::pair <int, int> pii;
typedef long long ll;
typedef std::vector <ll> vll;

using namespace std;

int n;
int arr[100000];
int k;

int main() {
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
	int cnt = 0;
	for (int i = 0; i < n; i++) if (arr[i] == 0) cnt++;
	k -= cnt;
	if (k < 0) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = INF;
	vector <int> pp, nn;
	pp.push_back(0);
	for (int i = 0; i < n; i++) if (arr[i] < 0) nn.push_back(-arr[i]); else if (arr[i] > 0) pp.push_back(arr[i]);
	nn.push_back(0);
	reverse(nn.begin(), nn.end());
	for (int i = 0; i < pp.size(); i++) {
		if (i + nn.size() <= k) continue;
		if (k - i >= 0)
			ans = min(ans, 2LL * pp[i] + nn[k - i]);
		else ans = min(ans, pp[i] * 1LL);
	}
	for (int i = 0; i < nn.size(); i++) {
		if (i + pp.size() <= k) continue;
		if (k - i >= 0)
			ans = min(ans, 2LL * nn[i] + pp[k - i]);
		else ans = min(ans, nn[i] * 1LL);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1404
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    string str;
    while(cin>>str){
        int len=str.length();
        int col=0;
        int res=0;
        for(int i=0;i<len;i++){
            if(col<=0){
                if(str[i]=='p'){
                    res--;
                }
                col++;
            }
            else{
                if(str[i]=='g'){
                    res++;
                }
                col--;
            }
        }
        cout<<res<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int r, c, n; 

int check(int x, int y) {
    if(y == 0) {
        return x;
    }
    if(x == r) {
        return r + y;
    }
    if(y == c) {
        return r + c + (r - x);
    }
    if(x == 0) {
        return 2 * r + 2 * c - y;
    }
    return -1;
}

void solve() {
	cin >> r >> c >> n;
    deque<P> ps;
    rep(i, n) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if(check(x1, y1) != -1 && check(x2, y2) != -1) {
            ps.push_back(P{check(x1, y1), i});
            ps.push_back(P{check(x2, y2), i});
        }
    }
    if(ps.empty()) {
        cout << "YES" << endl;
        return;
    }
    sort(all(ps));
    int m = (int)ps.size();
    int cnt = 0;
    while(ps.size()) {
        if(ps.front().sc != ps.back().sc) {
            ++cnt;
            P x = ps.back();
            ps.pop_back();
            ps.push_front(x);
        } else {
            ps.pop_front();
            ps.pop_back();
            cnt = 0;
        }
        if(cnt > m) {
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3584
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

int n, m;

#define MAXN (1 << 17)
#define INF (1 << 30)

vector<int> a[MAXN];
vector<int> rev[MAXN];
int p[MAXN];
int v[MAXN]; 
int f[MAXN];

int curt;

void dfs(int cur) {
	v[cur] = 1;
	curt++;
	for (int i = 0; i < a[cur].size(); i++) {
		int nnext = a[cur][i];
		if (!v[nnext]) {
			dfs(nnext);
		}
	}
	curt++;
	f[cur] = curt;
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < n + m - 1; i++) {
		int t1, t2;
		cin >> t1 >> t2;
		a[t1].push_back(t2);
		rev[t2].push_back(t1);
		p[t2] = t1;
	}

	int s = 1;
	while (p[s]) {
		s = p[s];
	}
	dfs(s);
/*	for (int i = 1; i <= n; i++) {
		cerr << f[i] << " ";
	}	
	cerr << endl;
*/	for (int i = 1; i <= n; i++) {
		int best = INF;
		int bestind = 0;
		for (int j = 0; j < rev[i].size(); j++) {
			int nnext = rev[i][j];
			if (f[nnext] < best) {
				best = f[nnext];
				bestind = nnext;
			}
		}
		cout << bestind << endl;
	}

	return 0;
}


Measured memory_bytes: 21888
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;

int main(){
  ll N,K;
  cin >> N >> K;
  ll ans=0;
  if(K%2 == 0){
    ll m1 = N/K;
    ans += m1*m1*m1;
    ll m2 = (2*N)/K;
    ans += (m2-m1)*(m2-m1)*(m2-m1);
  }else{
    ll m1 = N/K;
    ans += m1*m1*m1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define PI 3.14159265358979
int main()
{
  int a, b;
  double x = 0, y = 0, r = 0;
  while(1)
  {
    scanf("%d,%d", &a, &b);
    if(!a && !b)
      break;
    x += sin(r) * a;
    y += cos(r) * a;
    r += b / 180.0 * PI;
  }
  printf("%d\n%d\n", (int)x, (int)y);
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;
    ll ans=0,pen=0;
    vector<ll> p(M);
    vector<string> S(M);
    vector<ll> AC(N+1,0);
    rep(i,M){
        cin>>p[i]>>S[i];
        if(S[i]=="AC") AC[p[i]]=1;
    }
    rep(i,M){
        if(!AC[p[i]]) continue;
        if(S[i]=="WA") ++pen;
        else{
            AC[p[i]]=0;
            ++ans;
        }
    }
    cout<< ans<<" "<<pen<<"\n";
}

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


Measured memory_bytes: 7296
a,b,c,d=map(int,input().split())
count1=0#高橋君が死ぬまでの回数
count2=0#青木君が死ぬまでの回数
while c>0:
    c-=b
    count2+=1
while a>0:
    a-=d
    count1+=1
if count1>=count2:
    print('Yes')
else:
    print('No')



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

int n, m;

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

	int h[n + 1];
	memset(h, 0, sizeof(h));

	for(int i = 1; i <= n; i++) cin >> h[i];

	int a, b;
	bool f[n + 1];

	memset(f, true, sizeof(f));

	for(int i = 1; i <= m; i++) {
		cin >> a >> b;

		if(h[a] <= h[b]) f[a] = false;
		if(h[a] >= h[b]) f[b] = false;
	}

	int t = 0;
	for(int i = 1; i <= n; i++) if(f[i]) t++;

	cout << t;

//	system("pause");
	return 0;
}

Measured memory_bytes: 4104
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define pb(a) push_back(a)
#define arr(a) new ll int[a]
#define INF 1000000000000000000
#define MOD 4222236787
//ll int composite[15125];
const int N = 1e5 + 2;
ll fact[N];
void factorial(){
    fact[0] = fact[1] = 1;
    for(ll i = 2; i < N; i++)
        fact[i] = (fact[i-1] * i) % MOD;
}
ll power(ll a, ll b, ll mod){
	ll x = 1, y = a;
	while (b > 0){
		if (b%2){
			x = (x*y)%mod;
		}
		y = (y*y)%mod;
		b /= 2;
	}
	return x%mod;
}
ll modular_inverse(ll n, ll mod){
	return power(n, mod-2, mod);
}
ll nCr(ll n, ll k, ll mod){
	return (fact[n]*((modular_inverse(fact[k],MOD)*modular_inverse(fact[n-k],MOD))%mod))%mod;
}
//ll int arr1[10001];
//ll int arr1[25];
ll int composite[1000001];
ll int res=0,n,t1,t2;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    composite[1]=1;
    cin>>n;
    for(ll int i=2;i<1000001;i++)
    {
        if(!composite[i])
        {composite[i]=i;
            for(ll int j=i*i;j<1000001;j+=i)
            {
                composite[j]=i;
            }
        }
    }
    res=1;
//    cout<<composite[4]<<endl;
    for(ll int i=2;i<n;i++)
    {
        t1=i;
        t2=1;
        map<ll int,ll int>mp;
        while(t1!=1)
        {
            mp[composite[t1]]++;
            t1/=composite[t1];
        }
        for(auto itr=mp.begin();itr!=mp.end();itr++)
        {
            t2*=(itr->second+1);
//            cout<<(itr->second+1)<<" "<<(itr->first)<<endl;
        }
//        cout<<t2<<endl;
        res+=t2;
    }
    cout<<res;
	return 0;
}


Measured memory_bytes: 11468
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[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		int q = Integer.parseInt(sa[2]);
		int[] c = new int[n];
		for (int i = 0; i < q; i++) {
			int a = Integer.parseInt(br.readLine()) - 1;
			c[a]++;
		}
		br.close();

		int ok = q - k;
		for (int i = 0; i < n; i++) {
			if (c[i] > ok) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}


Measured memory_bytes: 64420
package main

import "fmt"

var n, m int

type edge struct {
	a, b int
}

var graph [][]int
var seen []bool

func main() {
	fmt.Scan(&n, &m)
	edges := make([]edge, m)
	for i := 0; i < m; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		a--
		b--
		edges[i].a = a
		edges[i].b = b
	}
	ans := 0
	for i := 0; i < m; i++ {
		// 辺iを除いたグラフを作って、全ての頂点を辿れるかチェック
		graph = make([][]int, n)
		seen = make([]bool, n)
		for j := 0; j < m; j++ {
			if i != j {
				graph[edges[j].a] = append(graph[edges[j].a], edges[j].b)
				graph[edges[j].b] = append(graph[edges[j].b], edges[j].a)
			}
		}
		dfs(0)
		bridge := false
		for i := 0; i < len(seen); i++ {
			if !seen[i] {
				bridge = true
			}
		}
		if bridge {
			ans++
		}
	}
	fmt.Println(ans)
}

func dfs(v int) {
	seen[v] = true
	for i := 0; i < len(graph[v]); i++ {
		if seen[graph[v][i]] {
			continue
		}
		dfs(graph[v][i])
	}
}


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

int main() {

  ll n, a, b;
  cin >> n >> a >> b;
  

  ll c = a + b;
  ll tmp = n % c;
  ll tt = n / c;
  if(tmp > a) tmp = a;
  ll ans = (a * tt) + tmp;

  cout << ans << endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	inp(n)
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int k=1;k<=n;k++)
			{
				ans+=__gcd(__gcd(i,j),k);
			}
		}
	}
	cout<<ans<<'\n';
	printclock;
}

Measured memory_bytes: 3804
#include<iostream>
#include<cstdio>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<utility>
#include<cstring>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef pair<int,int> pll;
const int maxn= 2e5+10;
const int mod =1e9+7;
const double EPS = 1e-6;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin  >> n;
    if(n%2==0)
    {
        cout << n/2 << endl;
    }
    else
        cout << n/2+1 << endl;
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<set>
using namespace std;
int n,m,a[500010],x[500010],f[2000010],g[2000010],p;
set<int> w;
inline void add(int i,int j,int k,int p)
{
	f[i]++;
	if(j<k)
	  if(p<=(j+k>>1))
	    add(i<<1,j,j+k>>1,p);
	  else
	    add(i<<1|1,(j+k>>1)+1,k,p);
}
inline int sum(int i,int j,int k,int l,int r)
{
	if(l<=j && k<=r)
	  return f[i];
	else
	  {
	   int p=0;
	   if(l<=(j+k>>1))
	     p+=sum(i<<1,j,j+k>>1,l,r);
	   if(r>(j+k>>1))
	     p+=sum(i<<1|1,(j+k>>1)+1,k,l,r);
	   return p;
	  }
}
inline void down(int i)
{
	f[i<<1]-=g[i];
	g[i<<1]+=g[i];
	f[i<<1|1]-=g[i];
	g[i<<1|1]+=g[i];
	g[i]=0;
}
inline void upd(int i)
{
	f[i]=min(f[i<<1],f[i<<1|1]);
}
inline void del(int i,int j,int k,int l,int r)
{
	if(l<=j && k<=r)
	  if(f[i]>1)
	    {
	     f[i]--;
	     g[i]++;
	    }
	  else if(j<k)
	    {
	     down(i);
	     del(i<<1,j,j+k>>1,l,r);
	     del(i<<1|1,(j+k>>1)+1,k,l,r);
	     upd(i);
		}
	  else
	    {
		 f[i]=1e9;
		 w.insert(-(i-p+1));
		}
	else
	  {
	   down(i);
	   if(l<=(j+k>>1))
	     del(i<<1,j,j+k>>1,l,r);
	   if(r>(j+k>>1))
	     del(i<<1|1,(j+k>>1)+1,k,l,r);
	   upd(i);
	  }
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	scanf("%d%d",&n,&m);
	m--;
	for(i=1;i<=n;i++)
	  {
	   scanf("%d",&j);
	   a[j]=i;
	  }
	for(p=1;p<n;p<<=1);
	for(i=n;i>0;i--)
	  {
	   x[a[i]]=sum(1,1,p,max(a[i]-m,1),min(a[i]+m,n));
	   add(1,1,p,a[i]);
	  }
	for(i=1;i<=n;i++)
	  f[p+i-1]=x[i]+1;
	for(i=p-1;i>0;i--)
	  f[i]=min(f[i<<1],f[i<<1|1]);
	del(1,1,p,1,n);
	for(i=n;i>0;i--)
	  {
	   k=-*w.lower_bound(-1e9);
	   x[k]=i;
	   del(1,1,p,max(k-m,1),min(k+m,n));
	   w.erase(-k);
	  }
	for(i=1;i<=n;i++)
	  printf("%d\n",x[i]);
	return 0;
}


Measured memory_bytes: 42368
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(std::string S){
  pll min_val=pll(0,0);
  vector<ll> v(S.size()+1);
  for (ll i = 0; i < S.size(); i++)
  {
    char cur=S[i];
    ll l=i;
    while(i<S.size()&&S[i]==cur)++i;
    FOR(j,l,i+1){
      if(cur=='<'){
        v[j]=max(j-l,v[j]);
      }else{
        v[j]=max(v[j],i-j);
      }
    }
    --i;
  }
  dump(v);
  cout<<accumulate(v.begin(),v.end(),0LL)<<endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 5252
#!/usr/bin/env python3
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(x, k+1):
        z = s - x - y
        if x <= y <= z <= k:
            ans += [ None, 1, 3, 6 ][ len(set([ x, y, z ])) ]
print(ans)


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

int main(){

    char c;
    cin>>c;

    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
        cout<<"vowel"<<endl;
    }
    else{
        cout<<"consonant"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3624
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
const int MAXN = 11111;
int n;
char s[MAXN];
int main(){
    ____();
    cin >> n >> (s+1);
    int len = strlen(s+1);
    for(int i = 1; i <= len; i++){
        s[i] = 'A'+(s[i]-'A'+n)%26;
    }
    cout << s+1 << endl;
    return 0;
}

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


const int N=1e6,OO = 0x3f3f3f3f;
int d()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
long long lld()
{
    long long ret;
    scanf("%lld", &ret);
    return ret;
}
map<string,int>mp;
map<string,int>mp1;
int main(){
    int n=d();
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        mp[s]++;
    }
    int m=d();
    for(int i=0;i<m;i++){
        string s;
        cin>>s;
        mp1[s]++;
    }
    int mx=0;
    for(auto m:mp){
        if(m.second>mp1[m.first])mx=max(mx,m.second-mp1[m.first]);
    }
    cout<<mx<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a,b;
    scanf("%d", &a);
    scanf("%d", &b);
    if(a >= 13){
    printf("%d", b);
    }
    else if(a <= 12 && a >= 6){
    printf("%d", b / 2);
    }
    else{
    printf("0");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
using namespace std;
const int Max=123456*2;
int main(void){
    bool p[Max]={1};
    for(int i=0;i<Max;i++)p[i]=true;
    p[0]=0;p[1]=0;
    for(int i=2;i<Max;i++){
        if(p[i]==1){
            for(int s=i*2;s<Max;s+=i){
                p[s]=false;
            }
        }
    }
    while(1){
        int n,cnt=0;
        cin>>n;
        if(n==0)break;
        for(int i=n+1;i<=n*2;i++){
            if(p[i]==true)cnt++;
        }
        cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



int N, M;
vector<int> s;
vector<int> g;

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

  rep(i, M) {
    int a, b;
    cin >> a >> b;

    if (a == 1) {
      s.push_back(b);
    }
    if (b == N) {
      g.push_back(a);
    }
  }

  sort(All(s));
  sort(All(g));

  for (int i=2;i<N;++i) {
    if (binary_search(All(s), i) && binary_search(All(g), i)) {
      cout << "POSSIBLE\n";
      return 0;
    }
  }

  cout << "IMPOSSIBLE\n";
  return 0;
}

Measured memory_bytes: 1276
from bisect import bisect_left, bisect_right

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

A.sort()
C.sort()

cnt = 0
for b in B:
    cnt += bisect_left(A, b) * (N - bisect_right(C, b))
print(cnt)

Measured memory_bytes: 105172
#!/usr/bin/env python3
s = input()
x, y = map(int, input().split())

d = [len(s) for s in s.split('T')]
nx = [set([d[0]])]
ny = [set([0])]

for i, l in enumerate(d[2::2]):
    new_n = set()
    for n in nx[i]:
        new_n.add(n + l)
        new_n.add(n - l)
    nx.append(new_n)

for i, l in enumerate(d[1::2]):
    new_n = set()
    for n in ny[i]:
        new_n.add(n + l)
        new_n.add(n - l)
    ny.append(new_n)

print('Yes' if (x in nx[-1] and y in ny[-1]) else 'No')


Measured memory_bytes: 359944
r,g,b,n= map(int,input().split())


ret = 0
for i in range(n//r+1):
    for j in range(n//g+1):
#         print((r*i+g*i), n, (n-(r*i+g*i))%b)
        tmp = r*i+g*j
        if tmp > n:
            continue
        if (n-tmp)%b == 0:
#             print(i, j, (n-(r*i+g*j))/b)
            ret += 1
print(ret)

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

int main(){
	int h,w;cin>>h>>w;
	vector<string> a(h);
	for(auto&& w:a)cin>>w;
	map<char,int> cnt;
	string ans="Yes";
	for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){
		cnt[a[i][j]]++;
	}}
	int r1=0,r2=0;
	for(auto&& w:cnt){
	if(w.second%2==1){
		r1++;
	if(w.second%4==3)r2++;
	}
	else if(w.second%4==2)r2++;
	}
	int n0=0;
	if(h%2==1)n0+=w/2;
	if(w%2==1)n0+=h/2;
	if((h%2==1 && w%2==1 && r1>1)|| ((h%2==0 || w%2==0) && r1>0))ans="No";
	if(r2>n0)ans="No";
	cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100001],f[100001];
int main()
{
	int n,m,i,j,k;
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	f[1]=0;
	for(i=2;i<=n;i++)
	{
		f[i]=INT_MAX;
		for(j=1;j<=min(i-1,k);j++)
		{
			f[i]=min(f[i],f[i-j]+abs(a[i-j]-a[i]));
		}
	}
	printf("%d",f[n]);
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
  int a,b,k;
  cin >> a >> b >> k;
  for(int i=1; i<=k; ++i)
  {
    if (i&1) {
      b+=(a/2);
      a>>=1;
    } else
    {
      a+=(b/2);
      b>>=1;
    }
  }
  cout << a << " " << b;
  return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc074/tasks/arc083_a
# Cだけど水パフォ

import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))

# 水と砂糖の操作は独立にできる
# 知りたいのは砂糖の質量と水の質量
# 砂糖の質量の増加の仕方と水の質量の増加の仕方は全探索できる
# F<3000なので、1グラムずつ調べても10*7でpypyならギリok


from itertools import product
A, B, C, D, E, F = read_ints()

# 水の質量の増加の仕方
# Aの倍数とBの倍数はありえる #かつF[g]以下
candi_water = set()
for pa, pb in product(range(F // (A ** 100) + 2), range(F // (B ** 100) + 2)):
    candi = pa * A * 100 + pb * B * 100
    if candi > F:
        continue
    candi_water.add(candi)


# 砂糖の質量の増加の仕方
candi_suger = set()
for pa, pb in product(range(F // (C) + 2), range(F // (D) + 2)):
    candi = pa * C + pb * D
    if candi > F:
        continue
    candi_suger.add(candi)


# 全組み合わせを全探索
most = -1
ans = (-1, -1)
# print(candi_water, candi_suger)
for a, b in product(candi_water, candi_suger):
    if a == 0 or a + b > F or 100 * b > E * a:  # ビーカーに入らないか溶け残るか
        continue
    noudo = b / (a + b)
    if noudo > most:
        most = noudo
        ans = (a + b, b)
        # print(most, ans)
print(*ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    map<char, ll> mp;
    rep(i, n ) {
        string tmp_s;
        cin >> tmp_s;
        if ( tmp_s[0] == 'M' ) ++mp['M'];
        if ( tmp_s[0] == 'A' ) ++mp['A'];
        if ( tmp_s[0] == 'R' ) ++mp['R'];
        if ( tmp_s[0] == 'C' ) ++mp['C'];
        if ( tmp_s[0] == 'H' ) ++mp['H'];
    }
    ll ans = 0;
    rep(i, 10) {
        if ( i == 0 ) ans += mp['M'] * mp['A'] * mp['R']; 
        if ( i == 1 ) ans += mp['M'] * mp['A'] * mp['C']; 
        if ( i == 2 ) ans += mp['M'] * mp['A'] * mp['H']; 
        if ( i == 3 ) ans += mp['M'] * mp['R'] * mp['C']; 
        if ( i == 4 ) ans += mp['M'] * mp['R'] * mp['H']; 
        if ( i == 5 ) ans += mp['M'] * mp['C'] * mp['H']; 
        if ( i == 6 ) ans += mp['A'] * mp['R'] * mp['C']; 
        if ( i == 7 ) ans += mp['A'] * mp['R'] * mp['H']; 
        if ( i == 8 ) ans += mp['A'] * mp['C'] * mp['H']; 
        if ( i == 9 ) ans += mp['R'] * mp['C'] * mp['H']; 
    }
    cout << ans << endl; 
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <algorithm>
#include <map>
using namespace std;
#define ll long long
#define P pair<int,int>
#include <bits/stdc++.h>

ll a[100];

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



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int compare_pair(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int n, m, i, j;
int a[100000][2];
long long int ans;

int main(){
	scanf("%d%d", &n, &m);
	for(i=0; i<n; i++){
		scanf("%d%d", &a[i][0], &a[i][1]);
	}
	qsort(a, n, sizeof(int)*2, compare_pair);
	for(i=0; i<n; i++){
		if(m <= a[i][1]){
			ans += (long long int)a[i][0]*m;
			break;
		}else{
			ans += (long long int)a[i][0]*a[i][1];
			m -= a[i][1];
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 1788
/* ex 5_4
series2 */
#include <stdio.h>
#include <string.h>

int main(void){
    char str[11];
    char count=0;
    char max=0;
    scanf("%s",str);
    for(int i=0;i<strlen(str);i++){
        if(str[i]=='A'||str[i]=='C'||str[i]=='G'||str[i]=='T'){//調べている文字がACGTならカウントを増やし、そうでない時はmaxか判定してからカウントをリセット
            count++;
        }else{
            if(count>max){
                max=count;
            }
            count=0;
        }
    }
    //一番最後に調べているところについてmaxかどうか判定
    if(count>max){
        max=count;
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 1688
(let ((a '(1 3 5 7 8 10 12))
      (b '(4 6 9 11))
      (c '(2))
      (x (read))
      (y (read)))
  (cond ((and (find x a) (find y a)) (princ "Yes"))
        ((and (find x b) (find y b)) (princ "Yes"))
        ((and (find x c) (find y c)) (princ "Yes"))
        (t (princ "No"))))

Measured memory_bytes: 12132
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
const int MAXM = 4e2 + 5;
const int MAXN = 26 + 5;
const ll linf = 0x3f3f3f3f3f3f3f3f;

int n=26, m;
int c[MAXN];
int a[MAXM][MAXN];

int p[MAXM];
set<int> idx[MAXN];
ll ans;

ll solve(void)
{
	static int lst[MAXN];
	memset(lst,0,sizeof(lst));
	for(int i=1; i<=n; ++i)
	{
		idx[i].clear();
		idx[i].insert(0);
		idx[i].insert(m+1);
	}
	
	ll ans = 0;
	for(int k=1; k<=m; ++k)
	{
		int x = p[k];
		ans += a[k][x];
		for(int i=1; i<=n; ++i) if(i != x)
			ans -= c[i] * (k-lst[i]);
		lst[x] = k;
		
		idx[x].insert(k);
	}
	
	::ans = ans;
	return ans;
}

ll recalc(int pos, int x)
{
	int old = p[pos];
	if(old == x) return ans;
	
	ll res = ans;
	
	idx[old].erase(pos);
	
	set<int>::iterator it = idx[old].upper_bound(pos);
	int nxt = *it;
	int lst = *(--it);
	
	res -= (pos - lst) * c[old] * (nxt - pos);
	res -= a[pos][old];
	
	it = idx[x].upper_bound(pos);
	nxt = *it;
	lst = *(--it);
	
	res += (pos - lst) * c[x] * (nxt - pos);
	res += a[pos][x];
	
	idx[x].insert(pos);
	
	p[pos] = x;
	return res;
}

int main(void)
{
	scanf("%d",&m);
	for(int i=1; i<=n; ++i) scanf("%d",&c[i]);
	for(int i=1; i<=m; ++i)
		for(int j=1; j<=n; ++j)
			scanf("%d",&a[i][j]);
	for(int i=1; i<=m; ++i) scanf("%d",&p[i]);
	
	solve();
	
	int T;
	scanf("%d",&T);
	while(T--)
	{
		int pos, x;
		scanf("%d%d",&pos,&x);
		
		ans = recalc(pos, x);
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3388
N = int(input())
 
he = input().split()
 
for i in range(len(he)):
  he[i] = int(he[i])

flag = True
fff = -1
for i in he:
  if i < fff:
    flag = False
    break
  if i == fff:
    continue
  fff = i - 1
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 67312