akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<int,int> P;
const long long MOD=1000000007;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)
vector <ll> dp;

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long K, long long Q, std::vector<long long> A){
  vector <ll> score(N, 0);
  for (ll i = 0; i < Q; i++)
  {
    score[A[i]-1]++;
  }
  for (ll i = 0; i < N; i++)
  {
    if ((Q-score[i])<K)
    {
      std::cout << YES << std::endl;
    } else{
      std::cout << NO << std::endl;
    }
  }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> A(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, Q, std::move(A));
    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;
int x, y, h, w;

int main(){
	while (cin >> n&&n){
		int ans = 0;
		REP(i, n){
			cin >> x >> y >> h >> w;
			int size = x + y + h;
			if (size <= 60 && w <= 2) ans += 600;
			else if (size <= 80 && w <= 5) ans += 800;
			else if (size <= 100 && w <= 10) ans += 1000;
			else if (size <= 120 && w <= 15) ans += 1200;
			else if (size <= 140 && w <= 20) ans += 1400;
			else if (size <= 160 && w <= 25)ans += 1600;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
N,M=map(int,input().split())#ID,ゲート


LR=[]
for i in range(M):
        LR.append(input().split())


numbers=[]
for i in range(N+1):
    numbers.append(i)




Lmax=1
Rmax=100000
for j in LR:

    L=int(j[0])
    R=int(j[1])

    if Lmax<L:
        Lmax=L
    if Rmax>R:
        Rmax=R
result=0

for i in numbers:

    if i>=Lmax:

        if i<=Rmax:
            result+=1



print(result)


Measured memory_bytes: 36216
#include <bits/stdc++.h>
using namespace std;
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */

int main() {
    /*int n, k;
    cin >> n >> k;
    long double rui[200100];
    rui[0] = 0;
    bool ok = true;
    ll a[200100];
    rep1(i, n) {
        cin >> a[i];
        rui[i] += rui[i-1] + a[i];
        if(i>1)if(a[i] != a[i - 1]) ok = false;
    }
    if(ok) {
        cout << (rui[1]+1)/2 * k << endl;
        return 0;
    }
    long double ma = -1;
    for(int i = k; i <= n; i++) ma = max(ma, rui[i] - rui[i - k]);
    cout << fixed << setprecision(10) << (ma + k) / 2 << endl;*/
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = (b/c - (a-1)/c) + (b/d - (a-1)/d) - (b/lcm(c,d) - (a-1)/lcm(c,d));
    cout << b - a + 1 - ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = 0;
    rep(i, n - 2) {
        if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
            ans++;
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
 
long long int i, count, H, N, A[100000], sum=0;
  
  scanf("%d %d", &H, &N);

  for(i=0;i<N;i++){
    scanf("%lld", &count);
  sum+=count;
  }
  if(H<=sum){
    printf("Yes\n");
  }else{
  printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iostream>
#include <string.h>
#include <vector>
#include <queue>
#include <cstdio>
#include <math.h>
#include <map>
#include <algorithm>
#include <deque>
#include <stack>
#include<set>
//#include <bits/stdc++.h>
#define lson l,mid,rt<<1

#define rson mid+1,r,rt<<1|1

const int N=1e5+100;
using namespace std;

typedef long long ll;
const int inf=0x3f3f3f3f;

ll dp[N],a[200];
int main()
{
    int n,W;scanf("%d%d",&n,&W);
    ll w,v;
    for(int i=1;i<=n;i++){
            scanf("%lld%lld",&w,&v);
        for(int j=W;j>=w;j--)
         dp[j]=max(dp[j],dp[j-w]+v);
    }
    printf("%lld\n",dp[W]);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main() {
  int n,h,height=0;
  string result = "Yes";
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> h;
    if (h < height) {
      result = "No";
      break;
    }
    
    if (h > height) {
      height = h - 1;
    }
  }

  cout << result << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int res = 0;
    for (int i = 1; i < n - 1; ++i) {
        int a[26] = {0}, b[26] = {0};
        for (int j = 0; j < i; ++j) {
            a[s[j] - 'a']++;
        }
        for (int j = i; j < n; ++j) {
            b[s[j] - 'a']++;
        }
        int _res = 0;
        for (int j = 0; j < 26; ++j) {
            if (a[j] > 0 && b[j] > 0) {
                _res++;
            }
        }
        if (res < _res) {
            res = _res;
        }
    }
    cout << res << endl;
    return 0;
}


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

const int N=305;

int n,m,L;

int dis1[N][N];
int dis2[N][N];


int main() {
	scanf("%d%d%d",&n,&m,&L);
	memset(dis1,0x3f,sizeof dis1);
	memset(dis2,0x3f,sizeof dis2);
	for(int i=1; i<=m; i++) {
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		dis1[a][b]=c;
		dis1[b][a]=c;
	}
	for(int k=1; k<=n; k++)
		for(int i=1; i<=n; i++)
			for(int j=1; j<=n; j++){
				dis1[i][j]=min(dis1[i][j],dis1[i][k]+dis1[k][j]);
				if(dis1[i][j]<=L) dis2[i][j]=1;
			}
	for(int k=1; k<=n; k++)
		for(int i=1; i<=n; i++)
			for(int j=1; j<=n; j++){
				dis2[i][j]=min(dis2[i][j],dis2[i][k]+dis2[k][j]);
			}
	int q;
	cin>>q;
	while(q--){
		int s,t;
		scanf("%d%d",&s,&t);
		if(dis2[s][t]>=0x3f000000) {
			puts("-1");
		}
		else cout<<dis2[s][t]-1<<endl;
	}
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int c[10][1005];
int ans=INF;

int main(){
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h){
    cin >>s[i];
  }
  rep(bit, (1<<h-1)){
    int g=0;
    vector<int> id(h);
    rep(i, h){
      id[i]=g;
      if(bit>>i & 1){
        g++;
      }
    }
    g++;
    rep(i, g)rep(j, w){
      c[i][j]=0;
    }
    rep(i, h)rep(j, w){
      c[id[i]][j]+=s[i][j]-'0';
    }
    int num=g-1;
    vector<int> now(g);
    auto add = [&](int j){
      rep(i, g)now[i]+=c[i][j];
      rep(i, g)if(now[i]>k) return false;
      return true;
    };
    rep(j, w){
      if(!add(j)){
        num++;
        now =vector<int>(g);
        if(!add(j)){
          num=INF;
          break;
        }
      }
    }
    ans=min(ans, num);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
static const int N = 100001;


int main() {
    int n, k, q; cin >> n >> k >> q;
    int a;
    int p[N] = {};

    for (int i = 0; i < q; i++) {
        cin >> a;
        p[a - 1]++;
    }

    for (int i = 0; i < n; i++)
        cout << (q - p[i] < k ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

int main()
{
  int a;
  int b;

  cin >> a >> b;
  cout << a * b << " " << a * 2 + b * 2 << endl;

  return 0;
}



Measured memory_bytes: 3112
#include<iostream>
#include<stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  //整数の時はint
  int a,b,m;
  //文字の時はstring
  //string a;
  int aa[100000],bb[100000],c,x,y;
  int min;

  cin>>a>>b>>m;
  int mina=100000,minb=100000;
  for(int i=0;i<a;i++){
    cin>>aa[i];
    if(aa[i]<mina)mina=aa[i];
  }
  for(int i=0;i<b;i++){
    cin>>bb[i];
    if(bb[i]<minb)minb=bb[i];
  }
  min=mina+minb;

  
  for(int i=0;i<m;i++){
    cin>>x>>y>>c;
    int sum=aa[x-1]+bb[y-1]-c;
    if(sum<min)
      min=sum;
   }
  cout<<min<<endl;

 
  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int n;
 cin >> n;
  vector<long long> a(n);
  for(int i = 0;i<n;i++){
    cin >> a[i];
  }
  long long c = 0;
  vector<long long> b(n);//a保存用配列
  b = a;
  vector<long long> SUM(n);
  long long sum = 0;
  //sum(2N)>0のとき
  
  for(int i = 0;i<n;i++){
    sum += a[i];
    SUM[i] = sum;
    if(i%2 == 0){
      if(a[0] <= 0){
        a[i] = 1;
        SUM[i] = 1;
        sum = 1;
        c += abs(a[i]-b[i]);
      }
      else if(SUM[i]<=0 && i>=1){
        a[i] = 1-SUM[i-1];
        SUM[i] = 1;
        sum = 1;
        c += abs(a[i]-b[i]);
      }
     
    }
      else if(i%2 !=0){
      if(SUM[i] >=0){
        a[i] = -1-SUM[i-1];
        SUM[i] = -1;
        sum = -1;
        c += abs(a[i]-b[i]);
      }
    }
  }

  a = b;
  //sum(2N)<0,sum(2N+1)>0のとき
  vector<long long> SUM2(n);
  long long sum2 = 0;
  long long d = 0;
    for(int i = 0;i<n;i++){
    sum2 += a[i];
    SUM2[i] = sum2;
    if(i%2 == 0){
      if(a[0] >= 0){
        a[i] = -1;
        SUM2[i] = -1;
        sum2 = -1;
        d += abs(a[i]-b[i]);
      }
      else if(SUM2[i]>=0 && i>=1){
        a[i] = -1-SUM2[i-1];
        SUM2[i] = -1;
        sum2 = -1;
        d += abs(a[i]-b[i]);
      }
     
    }
      else if(i%2 !=0){
      if(SUM2[i] <=0){
        a[i] = 1-SUM2[i-1];
        SUM2[i] = 1;
        sum2 = 1;
        d += abs(a[i]-b[i]);
      }
    }
  }
 

     cout << min(c,d) << endl;   
      
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
 int a,b;
 cin>>a>>b;
 
 if(a>b){
  cout<<a+(a-1)<<endl;
 }
 else if(b>a){
  cout<<b+(b-1)<<endl;
 }
 else{
  cout<<a+b<<endl;
 }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;

int main() {
    string s;
    multiset<string> v;

    int max_num = 0;
    int max_len = 0;

    while(cin >> s) {
        v.insert(s);
        max_num = max((int)v.count(s), max_num);
        max_len = max((int)s.length(), max_len);
    }

    for(auto x : v) {
        if(v.count(x) == max_num) {cout << x << " "; break;}
    }
    for(auto x : v) {
        if(x.length() == max_len) {cout << x << endl; break;}
    }
    return 0;
}

Measured memory_bytes: 3236
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

void A(){
    ll N,K; cin >> N >> K;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    vector<ll> x(200001);
    set<ll> s;
    for(int i = 0; i < N;i++){
        x[A[i]]++;
        s.insert(A[i]);
    }
    sort(x.begin(),x.end());
    ll ans = 0;
    for(int i = 0; i <= 200000;i++){
        if(s.size() <= K) break;
        if(x[i] == 0) continue;
        ans += x[i];
        s.erase(*s.begin());
    }
    cout << ans << endl;
}

void B(){
    ll N; cin >> N;
    vector<ll> a(N); for(auto& in:a) cin >> in;
    map<ll,ll> mp;
    for(int i = 0; i < N;i++) mp[a[i]]++;
    ll ans = 0;
    for(auto p:mp){
        if(p.first < p.second) ans += (p.second-p.first);
        if(p.second < p.first) ans += p.second;
    }
    cout << ans << endl;
}

void C(){
    ll X,Y; cin >> X >> Y;
    ll ans = 0;
    while(X <= Y){
        ans++;
        X*=2;
    }
    cout << ans << endl;
}
void D(){
    ll N; cin >> N;
    vector<ll> C(N),S(N),F(N);
    for(int i = 0; i < N-1;i++) cin >> C[i] >> S[i] >> F[i];
    for(int i = 0; i < N;i++){
        ll ans = S[i] + C[i];
        for(int j = i+1; j < N-1;j++){
            if(ans <= S[j]){
                ans = S[j]+C[j];
            }else{
                ans = (ans - S[j]+F[j]-1)/F[j]*F[j] + S[j]+C[j];
            }
        }
        cout << ans << endl;
    }
}

void E(){
    ll N,Y; cin >> N >> Y;
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N;j++){
            if(i + j > N) break;
            if(10000*i + 5000*j + 1000*(N-i-j) == Y){
                cout << i << " " << j << " " << (N-i-j) << endl;
                return ;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    //A();
    //B();
    //C();
    //D();
    E();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
const int sz = 1e8;
const long long ub = 1e12;
typedef long long ll;
ll a, b;
ll ans = 1;
ll gcd(ll a, ll b)
{
    if (a < b)
        swap(a, b);
    while (b)
    {
        ll c = a % b;
        a = b;
        b = c;
    }
    return a;
}

void integerFactorize(long long n,vector<pair<long long,int> >&v)
{
    v.clear();
    long long a=2;
    while(a*a<=n)
    {
        int b=0;
        while(n%a==0)
        {
            ++b;
            n/=a;
        }
        if(b>0)v.emplace_back(make_pair(a,b));
        ++a;
    }
    if(n>1)v.emplace_back(make_pair(n,1));
}
void solve()
{
    vector<pair<long long,int> >v;
    integerFactorize(gcd(a,b),v);

    ans += v.size();
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> a >> b;
    solve();
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
int main(){
	long long n;
	cin>>n;
	if(n%2==1||n==0){
		cout<<0<<endl;
	}else{
		long long ans=0;
		ans+=n/10;
		n/=10;
		while(n){
			ans+=n/5;
			n/=5;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int main() {
  int n, m, a;
  while (scanf("%d%d%d", &n, &m, &a), n|m|a) {
    vector<map<int, int>> bar(1000);
    for (int i = 0; i < m; ++i) {
      int h, p, q; scanf("%d%d%d", &h, &p, &q);
      bar[h-1][p] = q;
      bar[h-1][q] = p;
    }
    for (int i = 999; i >= 0; --i) {
      if (bar[i].count(a)) { a = bar[i][a]; }
    }
    printf("%d\n", a);
  }
}

Measured memory_bytes: 1176
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
}
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    cards[s][int(r) - 1] = 1
 
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print(s, r + 1)

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    ll m;
    cin >> n >> m;
    map<int,bool> flag;
    rep(i,m){
      int x;
      cin >> x;
      flag[x] = true;
    }

    FOR(i,n,100000){
      ll tmp = i;
      bool ansFlag = true;
      while(tmp != 0){
        if(flag[tmp%10]){
          ansFlag = false;
          break;
        }
        tmp/= 10;
      }
      if(ansFlag){
        cout << i << endl;
        return 0;
      }
    }

    return 0;
}


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

int main(){
  int n,m,X,Y;
  cin>>n>>m>>X>>Y;
  vector<int> x(n),y(m);
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  sort(x.begin(),x.end());
  for(int i=0;i<m;i++){
    cin>>y[i];
  }
  sort(y.begin(),y.end());
  int z=Y;
  while(X<z && z<=Y){
    if(x[n-1]<z && z<=y[0]){
      cout<<"No War"<<endl;
      return 0;
    }else z--;
  }
  cout<<"War"<<endl;
}

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

/*
vector.push_back()
vector<int> hoge(3,-1); {-1,-1,-1}
vector<vector<int>> hogehoge(2,vector<int>(2,-1)); {{-1,-1},{-1,-1}} 
cin >>temp;
scanf("%d %d %d",&A,&B,&Q);
sort(a.begin(),a.end());
a.push_back(4000000000000);
a.insert(a.begin(),-1000000000000);
upper_bound(a.begin(),a.end(),x); // list[i] > x のイテレータ取得. *itrで数値化 
*/
template <typename T> void debug(T arr);
template <typename T> void debug (T arr, int dim);



int main(void){
    std::cout<<std::fixed<<std::setprecision(10);
    int h,w;
    cin >> h >> w;
    vector<string> ans;
    string head;
    for (int i = 0; i < w+2; ++i){
        head += "#";
    }
    ans.push_back(head);
    for (int i = 0; i < h; ++i){
        string buf = "#";
        string pic;
        cin >> pic;
        buf += pic;
        buf += "#";
        ans.push_back(buf);
    }
    ans.push_back(head);
    for (int i = 0; i < h+2; ++i){
        cout << ans[i] << endl;
    }


};


template <typename T> void debug(T arr){
    for (auto col:arr){
        cout << col << " ";
    }
    cout <<endl;
};

template <typename T> void debug (T arr, int dim){
    for (auto raw:arr){
        for(auto col:raw){
            cout << col << " ";
        }
        cout << endl;
    }
};

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N, K, Q; cin>>N>>K>>Q;
  vector<int> A(N,0);
  REP(i,Q) {
    int	a; cin>>a; a--;
    A[a] ++;
  }
  REP(i,N) {
    int	rem = K	- (Q - A[i]);
    //    cout << i << " " << rem << endl;                                                       
    YesNo(rem > 0);
  }
  return 0;
}


Measured memory_bytes: 1024
// Author:: MUKUL KUMAR RAI
// Institution:: Jalpaiguri Government Engineering College
//If you are not doing well now just stick to it and learn new things one day you will be...
//Compete with yourself 
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
///*template{{{
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
#define trav(a,x) for(auto &a:x)
#define fr(i,a,b)  for(ll i=a;i<=b;i++)
#define fr1(i,a)   for(ll i=0;i<a;i++)
#define frr(i,a,b) for(ll i=b;i>=a;i--)
#define frr1(i,a)   for(ll i=a-1;i>=0;i--)
#define sorta(a,n) sort(a,a+n)
#define sortd(a,n) sort(a,a+n,greater<ll>())
#define sortva(a) sort(a.begin(),a.end())
#define sortvd(a) sort(a.begin(),a.end(),greater<ll>())
#define tc(t) while(t--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
using vi= vector<ll>;
using vvi= vector<vi>;
using vb =vector<bool>;
using vc =vector<char>;
using vs =vector<string>;
using vld =vector<ld>;
using pii =pair<ll,ll>;
using psi =pair<string,ll>;
using pci =pair<char,ll>;
using vpii =vector<pii>;
//}}}template*/
ll mod=1e9+7;
ll const maxn=1e6+5;
ll const inf=1e18;
bool ss(const pair<ll,ll> &a, const pair<ll,ll> &b) { 
    return a.first*b.second+a.second<b.first*a.second+b.second;
}
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
ll modinverse(ll a, ll m){
    return powm(a,m-2,m);
}
bool prime(ll x){
    if(x<=1)return false;
    for(int i=2;i<=sqrt(x);i++)if(x%i==0)return false;
    return true;
}
ll divisor(ll x){
    ll cnt=0;
    for(int i=1;i<=sqrt(x);i++){
        if(x%i==0){
            if(i!=x/i)cnt+=2;
            else cnt+=1;
        }
    }
    return cnt;
}
vector<ll> sieve(ll n) {     
    bool prim[n+1]; 
    memset(prim, true, sizeof(prim)); 
  
    for (ll p=2; p*p<=n; p++) {
        if (prim[p] == true) { 
            for (int i=p*p; i<=n; i += p) 
                prim[i] = false; 
        } 
    }
    vector<ll>v;
    for(int i=2;i<=n;i++)if(prim[i])v.push_back(i);
    return v; 
}
bool check(string s){
    ll l=0,r=sz(s)-1;
    while(l<=r){
        if(s[l]!=s[r])return false;
        l++;
        r--;
    }
    return true;
}
int main(){
 
    fio;
    ll n,w;
    cin>>n>>w;
    vi weight(n+1,0);
    vi value(n+1,0);
    ll dp[n+1][w+1];
    fr(i,1,n)cin>>weight[i]>>value[i];
    fr(i,0,n){
        fr(j,0,w){
            if(i==0 or j==0)dp[i][j]=0;
            else if(weight[i]<=j){
                dp[i][j]=max(value[i]+dp[i-1][j-weight[i]],dp[i-1][j]);
            }
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w];
    return 0;
}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
const ll mod = 998244353ll;
int k, n;
vector<string> a;
bool cc;
bool check(string& s) {
	int c;
	for(auto &i : a) {
		c = 0;
		for(int j = 0; j < n; j++)
			c += s[j] != i[j];
		if(c&&c!=2)
			return false;
//		if(cc==false&&c==0)
//			return false;
	}
	return true;
}

int main() {
	ios::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	int n;
	cin >> n;
	long double t = (n+1)/2;
	cout << fixed << setprecision(15) << t/n;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc103/tasks/abc103_d
import sys

def solve():
    pairs.sort(key=lambda pair: pair[1])
    cnt = 0
    base = 0
    for (a, b) in pairs:
        if a >= base:
            cnt += 1
            base = b
    return cnt

n, m = map(int, input().split())
pairs = [tuple(int(c) for c in input().split()) for _ in range(m)]
print(n, pairs, file=sys.stderr)
print(solve())

Measured memory_bytes: 21344
<?php

fscanf(STDIN, "%s", $s);

$n = strlen($s);
$first = substr($s, 0, ($n - 1) / 2);
$last = substr($s, ($n + 3) / 2 - 1);

if ($s === strrev($s) && $first === strrev($first) && $last === strrev($last)) {
    echo 'Yes';
} else {
    echo 'No';
}



Measured memory_bytes: 4732
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;

int main (){
    int x,a,b,t,ans;
    ans = 1;
    scanf("%d",&x);
    for(a = 2;a<=sqrt(x);a++){
      for(b = 2;pow(a,b)<=x;b++){
        t = pow(a,b);
        if(t > ans)ans =t;
      }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int A,B,M;
   cin >> A >> B>> M;
   int a[A];
   int b[B];
   int ma=INT_MAX;
   int mb=INT_MAX;
   for(int i =0;i<A;i++){ 
      cin >> a[i];
      ma=min(ma, a[i]);
   }
   for(int i = 0;i<B; i++){
      cin >>b[i];
      mb=min(mb, b[i]);
   }
   int ans = ma+mb;
   for(int i = 0 ; i <M; i++ ){
      int x,y,c;
      cin >> x >> y >> c;
      ans = min(ans, a[x-1]+b[y-1]-c);

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  int N;
  cin >> N;
  ll A[N];
  vector<ll> S(N+1,0);
  for(int i = 0;i<N;++i){
    cin >> A[i];
    S.at(i+1) = S.at(i) + A[i];
  }
  
  sort(S.begin(),S.end());
  
  ll flag = 0;
  ll ans = 0;
  for(ll i = 0;i<N+1;++i){
    if(i == N){
      ans += (i+1-flag)*(i-flag)/2;
    }else if(S.at(i+1) != S.at(i)){
      ans += (i+1-flag)*(i-flag)/2;
      flag = i+1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int N, Q, C[500000], L[5000000], R[500000];
int bit[500001];

int sum(int i) {
    int s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(int i, int x) {
    while (i <= N) {
        bit[i] += x;
        i += i & -i;
    }
}

int main() {
    cin >> N >> Q;
    REP(i, N) cin >> C[i];

    map<int, int> index;
    vector<pii> range;
    RREP(i, N) {
        if (index.count(C[i])) {
            range.push_back({i, index[C[i]]});
        }
        index[C[i]] = i;
    }
    vector<pii> qrange;
    REP(i, Q) {
        cin >> L[i] >> R[i]; L[i]--; R[i]--;
        qrange.push_back({L[i], R[i]});
    }
    sort(ALL(qrange), greater<pii>());

    map<pii, int> ans;
    int ri = 0, qri = 0;
    while (ri < range.size() || qri < qrange.size()) {
        if (ri < range.size() && range[ri].first >= qrange[qri].first) {
            add(range[ri++].second, 1);
        } else {
            pii qr = qrange[qri++];
            int duplicate_count = sum(qr.second);
            ans[qr] = qr.second - qr.first + 1 - duplicate_count;
        }
    }
    REP(i, Q) cout << ans[{L[i], R[i]}] << endl;
    return 0;
}

Measured memory_bytes: 68272
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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

ll gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
vector<int> lat[100010];
vector<int> pet[100010];
bool rel[100010];
bool lal[100010];
void rec(int pe) {

	rel[pe] = true;
	for (int c : pet[pe])
	{
		if (lal[c]) continue;
		lal[c] = true;
		for (int ne : lat[c])
		{
			if (rel[ne]) continue;
			rec(ne);
		}
	}
}
ll a[2010];

int n;
ll memo[2][2010];
ll rec(int t,int num,ll z, ll w) {

	if (num == n) {
		return abs(z - w);
	}
	if (memo[t][num] != -1) return memo[t][num];
	ll res = -1;
	int nex = (t + 1) % 2;
	for (int i = num; i < n; i++)
	{
		if (res == -1) {
			if (t == 0) {
				res = rec(nex, i + 1, a[i], w);
			}
			else {
				res = rec(nex, i + 1, z, a[i]);
			}
		}
		if (t == 0) {
			res = max(res, rec(nex, i + 1, a[i], w));
		}
		else {
			res = min(res, rec(nex, i + 1, z, a[i]));
		}
	}
	return memo[t][num] = res;

}

void Solve() {
	
	ll z, w;
	cin >> n >> z >>w;
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (size_t i = 0; i < 2; i++)
	{
		for (size_t j = 0; j < 2000; j++)
		{
			memo[i][j] = -1;
		}
	}
	cout << rec(0, 0, z, w) << endl;
}


int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 1; i < n; i++)
#define REPP(i, n) for(int i = n-1; i >= 0; i--)

using namespace std;

const int MOD = 1000000007;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    vector<int> w(n, 0);
    vector<int> e(n, 0);
    if(s[0]=='W') w[0]=1;
    REP(i,n) {
        w[i] = (s[i]=='W' ? w[i-1]+1 : w[i-1]);
    }
    if(s[n-1]=='E') e[n-1]=1;
    REPP(i,n-1) {
        e[i] = (s[i]=='E' ? e[i+1]+1 : e[i+1]);
    }
    int ans = MOD;
    for(int i = 0; i < n; i++) {
        if(i==0) ans = min(ans, e[1]);
        else if(i==n-1) ans = min(ans, w[n-2]);
        else ans = min(ans, w[i-1]+e[i+1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdlib>

using namespace std;
typedef long double ll;

#define PI 3.14159265358979
int main(){
    ll n = 0;
    cin >> n;
    cout << 2*PI*n << endl;
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <cmath>

int main()
{
    double x1,y1,x2,y2;

    std::cin >> x1 >> y1 >> x2 >> y2;

    std::printf("%lf", sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));

    return 0;


}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
#define int long long
using namespace std;

/*Starry Sky Tree*/
/*Range Add Min(Max) Query*/
/*区間加算、区間Min,区間Max*/

class RSUQ{
public: 
  
  //遅延用の型  
  struct T{
    int type; //0 - empty   , 1 - update
    int value;
    T():type(0),value(0){}
    T(int type,int value):type(type),value(value){}
  };

  //マージ可能な主データ型
  struct D{
    int value;
    D():value(0){} /*適切な値にする!!!!!!*/
    D(int value):value(value){}
    bool operator < (D a)const {return value < a.value;} //merge用
  };
  
  int n;
  vector<D> dat;
  vector<T> td;
  D returnD = D(0); // 範囲外の時に返す値。
  
  RSUQ(){n=-1;}
  RSUQ(int n_){
    n=1;
    while(n<n_)n*=2;
    td.resize(2*n-1,T());
    dat.resize(2*n-1,D());
  }
  
  D merge(D a,D b){return a.value + b.value;}
  
  void delay(int k,int len){
    if(td[k].type==0) return;
    int v = td[k].value;
    td[k].type = 0;
    td[k].value = 0;
    
    len /= 2;
    int l = k*2+1,r = k*2+2;
    dat[l].value = v * len; td[l].type = 1; td[l].value = v;
    dat[r].value = v * len; td[r].type = 1; td[r].value = v;
  }

  D update(int k,int x, int len){
    dat[k].value = x * len;
    td[k].type = 1;
    td[k].value = x;
    return dat[k];
  }
  
  //[a,b)の値をx変更　add(a,b,x)
  D query(int a,int b,int x,bool flg=true,int k=0,int l=0,int r=-1){
    if(r==-1) r=n, assert(a <= n && b <= n);
    if(r<=a||b<=l) return flg? dat[k]:returnD;
    if(a<=l&&r<=b) return flg? update(k, x, r - l):dat[k];
    
    delay(k, r - l);
    D vl = query(a,b,x,flg,k*2+1,l,(l+r)/2);
    D vr = query(a,b,x,flg,k*2+2,(l+r)/2,r);
    if(flg) dat[k] = merge(vl,vr);
    return merge(vl,vr);
  }
  
  //[a,b)の合計値を得る　find(a,b);
  int find(int a,int b){
    D res = query(a,b,0,false);
    return res.value;
  }
};


signed main(){
  int n,q;
  cin>>n>>q;
  
  RSUQ rsuq(n);
  while(q--){
    int cmd;
    cin>>cmd;
    if(cmd == 0){
      int s,t,x;
      cin>>s>>t>>x;
      rsuq.query(s,t+1,x);
    }
    if(cmd == 1){
      int s,t;
      cin>>s>>t;
      cout<<rsuq.find(s,t+1)<<endl;
    }
  }
  
  return 0;
}



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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
void debug(vector<T> &vec) {
    for (auto x : vec) {
        cout << x << " ";
    }
    cout << endl;
    return;
}

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

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

vector<string> makeInt(vector<int> vec) {
    vector<string> res;
    sort(ALL(vec));
    do {
        string s = "";
        for (auto x : vec) {
            s += to_string(x);
        }
        res.push_back(s);
    } while (next_permutation(ALL(vec)));

    return res;
}

int solve(int n, int k) {
    vector<int> a(n);
    REP(i, n) { cin >> a[i]; }
    set<string> st;
    REP(S, 1 << n) {
        if (k != __builtin_popcount(S)) continue;
        vector<int> vec;
        REP(i, n) {
            if ((S >> i) & 1) {
                vec.push_back(a[i]);
            }
        }
        vector<string> strs = makeInt(vec);
        for (auto x : strs) {
            st.insert(x);
        }
    }
    cout << st.size() << endl;
}

int main() {
    int n, k;
    while(cin >> n >> k && n) {
        solve(n, k);
    }
    return 0;
}


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

int cango(int t1, int t2, int x1, int x2, int y1, int y2){
    if((int)(abs(x2-x1)+abs(y2-y1))%2==0){
        if(t2-t1>=(int)(abs(x2-x1)+abs(y2-y1))&&(t2-t1)%2==0) return 1;
        else return 0;
    } else {
        if(t2-t1>=(int)(abs(x2-x1)+abs(y2-y1))&&(t2-t1)%2==1) return 1;
        else return 0;
    }
}

int main()
{
    int N;
    scanf("%d", &N);
    int t[N+1], x[N+1], y[N+1];
    int i;
    for(i=1;i<=N;i++) scanf("%d %d %d", &t[i], &x[i], &y[i]);
    
    int judge = 1;
    judge *= cango(0, t[1], 0, x[1], 0, y[1]);
    for(i=1;i<N;i++){
        judge *= cango(t[i], t[i+1], x[i], x[i+1], y[i], y[i+1]);
    }
    
    if(judge==1) printf("Yes");
    else printf("No");

    return 0;
}

Measured memory_bytes: 1280
#include <cstdio>
#include <algorithm>
#include <cmath>
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout);
using namespace std;
#include <queue>
typedef long long ll;
const int MAXN = 3 * 100005;
const ll INF = 1e18;
int n;
int s[MAXN];
ll f[MAXN], g[MAXN];

priority_queue<ll, vector<ll>, greater<ll> > a;
priority_queue<ll> b;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= 3 * n; i++)
        scanf("%d", s + i);
    for (int i = 1; i <= n; i++)
        a.push(s[i]), f[n] += s[i];
    for (int i = n + 1; i <= 3 * n; i++)
        if (s[i] > a.top()) {
            f[i] = f[i - 1] + s[i] - a.top();
            a.pop(), a.push(s[i]);
        } else
            f[i] = f[i - 1];
    for (int i = 3 * n; i > n << 1; i--)
        b.push(s[i]), g[n << 1 | 1] += s[i];
    for (int i = n << 1; i; i--)
        if (s[i] < b.top()) {
            g[i] = g[i + 1] + s[i] - b.top();
            b.pop(), b.push(s[i]);
        } else
            g[i] = g[i + 1];
    ll ans = -INF;
    for (int i = n; i <= n << 1; i++)
        ans = max(ans, f[i] - g[i + 1]);
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 7284
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    let mut edges: Vec<Vec<Edge>> = vec![Vec::new(); n];
    for i in 0..m {
        let v = read_vec::<usize>();
        let (a, b) = (v[0] - 1, v[1] - 1);
        edges[a].push(Edge { to: b, cost: 1 });
        edges[b].push(Edge { to: a, cost: 1 });
    }
    let from = solve(&edges, 0);
    println!("Yes");
    for i in 1..n {
        println!("{}", from[i] + 1);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
use std::cmp::Ordering;
use std::collections::BinaryHeap;
const INF: i64 = 100000_00000_00000;

#[derive(PartialEq, Debug)]
struct MinInt {
    value: i64,
}

impl Eq for MinInt {}

impl PartialOrd for MinInt {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        other.value.partial_cmp(&self.value)
    }
}

impl Ord for MinInt {
    fn cmp(&self, other: &MinInt) -> Ordering {
        other.value.cmp(&self.value)
    }
}

fn make_pair(x: i64, y: usize) -> (MinInt, usize) {
    (MinInt { value: x }, y)
}

#[derive(Debug, Clone)]
struct Edge {
    to: usize,
    cost: i64,
}

fn solve(edges: &Vec<Vec<Edge>>, start_idx: usize) -> Vec<usize> {
    let num_apexes = edges.len();
    let mut d = vec![INF; num_apexes];
    let mut from = vec![std::usize::MAX; num_apexes];
    d[start_idx] = 0;
    let mut que = BinaryHeap::new();
    que.push(make_pair(0, start_idx));

    while let Some((u, v)) = que.pop() {
        if d[v] < u.value {
            continue;
        }
        for e in &edges[v] {
            if d[v] != INF && d[e.to] > d[v] + e.cost {
                d[e.to] = d[v] + e.cost;
                from[e.to] = v;
                que.push(make_pair(d[e.to], e.to));
            }
        }
    }
    from
}


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

namespace AtCoder190810_C
{
    class Program
    {
        static void Main()
        {
            string input0 = Console.ReadLine();
            int n = int.Parse(input0);
            var sTable = new Dictionary<string, int>();
            long res = 0;
            for (int i = 0; i < n; i++)
            {
                string inputI = Console.ReadLine();
                string key = string.Concat(inputI.OrderBy((c) => c));
                
                if (sTable.ContainsKey(key))
                {
                    res += sTable[key];
                    sTable[key] += 1;
                }
                else
                {
                    sTable[key] = 1;
                }
            }

            Console.WriteLine($"{res}");
        }
    }

}


Measured memory_bytes: 31252
#include<iostream>
#include<algorithm>
#define REP(i,n) for(int i = 0;i < n ; i++)

typedef long long ll;

using namespace std;

bool pri1[2000000];
int pri2[2000000];
ll n ,ans;

void seg(int n)
{
	int p = 0;
	for(int i = 0;i <= n;i++)pri1[i] = true;
	pri1[0] = pri1[1] = false;
	for(int i = 2;i <= n;i++)
	{
		if(pri1[i])
		{
			pri1[p++] = i;
			for(int j = 2 * i;j <= n;j += i)pri1[j] = false;
			
		}
	}
}
			
			

int main()
{
	for(;;)
	{
		n = 0;
		ans = 0;
		cin >> n;
		if(n == 0)break;
		seg(2*n+1);
		for(int i = n+1;i<=2*n;i++)if(pri1[i])
		{
			ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

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

typedef long long int llint;

int main(){
	string A,B;
	cin >> A;
	cin >> B;
	if(A.length()<B.length()){
		cout << "LESS" << endl;
	}else if(A.length()>B.length()){
		cout << "GREATER" << endl;
	}else{
		for(int i=0;i<A.length();i++){
			if(A[i]<B[i]){
				cout << "LESS" << endl;
				return 0;
			}else if(A[i]>B[i]){
				cout << "GREATER" << endl;
				return 0;
			}
		}
		cout << "EQUAL" << endl;
	}
	return 0;
}


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

#define LLINF (1LL<<60)
typedef long long ll;
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


//C++14 (GCC 5.4.1)
int main() {
    ll N,n;
    cin >>N;
    int ans=1;
    for(int i=2;i*i<=1000;i++){
        int bp=i*i;
        for(int k=1;k<10;k++){
            if(bp<=N)chmax(ans,bp);
            if(N<bp)break;
            bp*=i;
        }
    }

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

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

using namespace std;
using ll = long long;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}


void init()
{
}

void solve()
{
	int K, A, B;
	cin >> K >> A >> B;
	if (K <= A || A+1 >= B) {
		cout << 1+K << endl;
		return;
	}
	ll res = 0;
	res += B;
	K -= A+1;
	ll cnt = K / 2;
	res += cnt * (B - A);
	K -= cnt * 2;
	res += K;
	cout << res << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>

// NO ERROR handling implemented!! full, empty

int stack[1000]={0},top=0;

void push(int x)
{
	stack[++top] = x;   // ++top, top-- etc.. incre/decre top permanently, stack[top+1] does not change the top outside the stack[...].
}

int pop()
{
	//top--;
	return stack[top--];
}

int main()
{
    int x,y;
	char op[100];
	

	while( scanf("%s",op) != EOF ){
		if(op[0] == '+'){
			x = pop();
			y = pop();
			push(x + y);
		}else if(op[0] == '-'){
			x = pop();
			y = pop();
			push(y - x);
		}else if(op[0] == '*'){
			x = pop();
			y = pop();
			push(x * y);
		}else{
			push(atoi(op));  // read terminal inputs(空白で区切られた壱文字ずつ読み込む), operatorはpushされない！！
		}
	}

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

	return 0;
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
int main(){
 int A,B;
 cin>>A>>B;
 int a=A+B;
 if(A%3==0){
     cout<<"Possible"<<endl;
 }
 
 else if(B%3==0){
     cout<<"Possible"<<endl;
 }
 
 else if(a%3==0){
     cout<<"Possible"<<endl;
 }
 
 else{
     cout<<"Impossible"<<endl;
 }
 
}

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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    rep(i, n - 1) {
        if(a[i + 1] == a[i]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 1024
object Main extends App {


  val arr: Array[Int] = readLine().split(" ").map(_.toInt)
  val n = arr(0)
  val a = arr(1)
  val b = arr(2)

  def solution(n: Int, a: Int, b:Int) = {
    Math.min(n*a, b)
  }
  println(solution(n,a,b))



}

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

int main()
{
        long long h,w;
        cin >> h>> w;
        long long ans;
 
  if (h == 1 || w== 1)
  {
    ans = 1;
  }
        else if((h*w) %2 != 0)
        {       
                ans = (h*w /2) +1;
        }
        else if((h*w)% 2== 0)
        {
                ans = h*w /2;
        }
        cout << ans << endl;

}



Measured memory_bytes: 256