akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

#define N 3

using namespace std;

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int a[ N ];
  int i;

  for ( i = 0; i < N; ++i )
  {
    cin >> a[ i ];
  }
  sort ( a, a + N );
  for ( i = 0; i < N; ++i )
  {
    if ( i ) cout << " ";
    cout << a[ i ];
  }
  cout << endl;

  return ( 0 );
}

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

typedef long long ll;

int prime_check(ll& number) {
    for (int i = 2; i <= sqrt(number); i++) {
        if (number % i == 0) {
            return 0;
        }
    }
    return 1;
}

int main () {
    int n; cin >> n;
    int prime_cnt =  0;
    for (int i = 0; i < n; i++) {
        ll number; cin >> number;
        prime_cnt += prime_check(number);
    }
    printf("%d\n", prime_cnt);
}


Measured memory_bytes: 3132
from sys import stdin

nbLig,nbCol=map(int,stdin.readline().split())
grille=[]
possible=[[-1]*nbCol for i in range(nbLig)]
possible[0][0]=0
for i in range(nbLig):
    ligne=stdin.readline()
    grille.append(ligne)
compteur=0
cases=0
for lig in range(nbLig):
    for col in range(nbCol):
        if grille[lig][col]=="#" and (lig!=0 or col!=0):
            cases+=1
            maximum=-1
            if lig>0:
                maximum=max(maximum,possible[lig-1][col])
            if col>0:
                maximum=max(maximum,possible[lig][col-1])
            possible[lig][col]=maximum+1

if cases==possible[nbLig-1][nbCol-1]:
    print("Possible")
else:
    print("Impossible")

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll Q,H,S,D,N;
    cin >> Q >> H >> S >> D;
    cin >> N;
    ll min2L = min(min(Q*8,H*4),min(S*2,D));
    ll min1L = min(min(Q*4,H*2),S);
    ll cnt2L = N / 2;
    ll cnt1L = N % 2;
    ll ans = min2L*cnt2L + min1L*cnt1L;
    cout << ans << endl;
}

Measured memory_bytes: 3656
#include <stdio.h>
 
#define LIMIT	(10000)
 
int main(void)
{
	int n;
	int mem[2][10000];
	int ct;
	int under_line;
	int dl;
	int i, j;
	int index;
 
	while (scanf("%d", &n), n){
		for (i = 0; i < n; i++){
			scanf("%d", &mem[0][i]);
		}
 
		under_line = n;
		for (ct = 0; ct < LIMIT; ct++){
			for (i = 0; i < under_line && mem[ct & 1][i] == i + 1; i++);
			if (i == under_line) break;
 
			dl = index = 0;
			for (i = 0; i < under_line; i++){
				dl -= !(--mem[ct & 1][i]);
				if (mem[ct & 1][i]) mem[!(ct & 1)][index++] = mem[ct & 1][i];
			}
			mem[!(ct & 1)][index] = under_line;
			under_line = under_line + 1 + dl;
		}
		printf("%d\n", ct != LIMIT ? ct : -1);
	}
 
	return (0);
}

Measured memory_bytes: 624
#include<iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 110;
int pos[N];
int n;
int main(){
    cin >> n;
    int res = 0x3f3f3f;
    for(int i = 1; i <= n; i ++){
        cin >> pos[i];
    }
    for(int j = 1; j <= 100; j ++){
        int curr = 0;
        for(int i = 1; i <= n; i ++){
            curr += (pos[i] - j) * (pos[i] - j);
        }
        res = min(res, curr);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 888
N = int(input())
a = list(map(int, input().split()))
A = []
B = []
while True:
  A.append(max(a))
  a.remove(max(a))
  if len(a) == 0:
    break
  B.append(max(a))
  a.remove(max(a))
  if len(a) == 0:
    break
print(sum(A)-sum(B))

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

int main(void){
 
    string a,b,c;
    cin >> a >> b >> c;
    
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
        cout << "YES" <<endl;
    }
    else{
        cout << "NO" <<endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,int>pii;
//struct _IO { _IO() { ios::sync_with_stdio(0); cin.tie(0); } }_io;
const ll mod=1e9+7;
const int maxn=2e5+10;
int fa[maxn],sz[maxn];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++) fa[i]=i,sz[i]=1;
	int mx=1;
	for(int i=1;i<=m;i++){
		int x,y;
		cin>>x>>y;
		int fx=find(x);
		int fy=find(y);
		if(fx!=fy){
			fa[fx]=fy;
			sz[fy]+=sz[fx];
			mx=max(mx,sz[fy]);
		}
	}
	cout<<mx<<'\n';


}

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

int main(){
    string s;cin>>s;
    if(s[s.size()-1]=='s'){
        s+="es";
    }else{
        s+="s";
    }
    cout<<s<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <climits>
#include <map>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if((a*b) % 2 == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
q = int(input())
num_list = [0 for i in range(100001)]
for i in a:
    num_list[i] += 1
ans = sum(a)

for _ in range(q):
    b, c = map(int, input().split())
    num_b = num_list[b]
    num_list[c] += num_b
    ans += num_b * (c - b)
    num_list[b] = 0
    print(ans)

Measured memory_bytes: 21052
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

int main(){
  int n, ws; cin >> n >> ws;
  int v[n+1], w[n+1];
  for(int i=1; i<=n; i++) cin >> v[i] >> w[i];

  int dp[n+1][ws+1];
  for(int i=0; i<=n; i++){
    for(int j=0; j<=ws; j++) dp[i][j]=0;
  }

  for(int i=1; i<=n; i++){
    for(int j=0; j<=ws; j++){
       if(j<w[i]) dp[i][j] = dp[i-1][j];
       else dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
    }
  }

  cout << dp[n][ws] << endl;

  return 0;
}



Measured memory_bytes: 7044
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.D
{
    internal static class CR
    {
        public static string GetText() { return Console.ReadLine(); }
        public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long GetLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
    }

    public class Program
    {
        public static long N { get; private set; }
        public static string S { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            N = CR.GetLong();
            S = CR.GetText();

            var r = 0;
            var g = 0;
            var b = 0;
            for (int i = 0; i < N; i++)
            {
                switch (S[i])
                {
                    case 'R': r++; break;
                    case 'G': g++; break;
                    case 'B': b++; break;
                    default: throw new Exception();
                }
            }

            var x = 0;
            for (int i = 0; i < N; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    var k = j * 2 - i;
                    if (k < N && k > j)
                    {
                        if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i])
                        {
                            Debug.WriteLine($"{i} {j} {k}");
                            x++;
                        }
                    }
                }
            }

            return (long)r * (long)g * (long)b - (long)x;
        }
    }
}


Measured memory_bytes: 27544
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; cout.tie(NULL);
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007


int32_t main(){
IOS;
int k,n;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}


sort(a , a+n);
int sum = 0;
for(int i=0;i<max((int)0 , n-k) ; i++)
sum += a[i];
cout<<sum<<endl; 
return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  priority_queue<pair<ll, ll>> q;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  ll min_life = A[0], min_ind = 0;
  set<ll> dead;
  while (dead.size() < N - 1) {
    for (int i = 0; i < N; i++) {
      if (i == min_ind || A[i] <= 0) continue;
      A[i] -= min_life * (A[i] / min_life);
      if (A[i] <= 0)
        dead.insert(i);
      else if (A[i] < min_life) {
        min_life = A[i];
        min_ind = i;
      }
    }
  }
  cout << min_life << endl;
  return 0;
}

Measured memory_bytes: 8708
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <cstring>
#include <cstdlib>
#include <cmath>
#define endl '\n'
#define ll long long

using namespace std;

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

        int A, B; cin >> A >> B;
        if(A % 3 == 0)
                cout << "Possible";
        else if(B % 3 == 0)
                cout << "Possible";
        else if((A+B) % 3 == 0)
                cout << "Possible";
        else
                cout << "Impossible";


        return 0;
}


Measured memory_bytes: 256
S = input()

o = S[::2]
p = S[1::2]

o1 = len([i for i in o if i == "1"])
o0 = len(o) - o1

p1 = len([i for i in p if i == "1"])
p0 = len(p) - p1

print(min(o1 + p0, o0 + p1))


Measured memory_bytes: 3700
#include <stdio.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 100000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem2168 : Luigi's Tavern **/
const int MAX_V = 1000;

class MaxFlow {
public:
	struct edge { int to, cap, rev, cost;};
	vector<edge> G[MAX_V];
	bool used[MAX_V];
	int V;
	
	MaxFlow() {V=MAX_V;}
	MaxFlow(int v) {
		V = v;
	}
	
	void add_edge(int from, int to, int cap) {
		G[from].push_back((edge){to, cap, (int)G[to].size(), 0});
		G[to].push_back((edge){from, 0, (int)G[from].size()-1, 0});
	}
	
	// 最大流
	int dfs(int v, int t, int f) {
		if (v==t) return f;
		used[v] = true;
		for (int i=0; i<G[v].size(); i++) {
			edge &e = G[v][i];
			if (!used[e.to] && e.cap>0) {
				int d = dfs(e.to, t, min(f, e.cap));
				if (d>0) {
					e.cap-=d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	
	int max_flow(int s, int t) {
		int flow = 0;
		for (;;) {
			memset(used, 0, sizeof(used));
			int f = dfs(s, t, INF);
			if (f==0) return flow;
			flow += f;
		}
	}
};

int main()
{
	int H, W, C, M, Nw, Nc, Nm;
	while (cin>>H>>W>>C>>M>>Nw>>Nc>>Nm) {
		if (H<0&&W<0&&C<0&&M<0&&Nw<0&&Nc<0&&Nm<0) break;
		
		int s=H+2*W+2*C+2*M, t=s+1, nw=t+1, nc=nw+2, nm=nc+2;
		
		MaxFlow F(H+2*W+2*C+2*M+8);
		
		rep(i, H) {
			// s->H
			F.add_edge(s, i, 1);

			// H -> Nw
			F.add_edge(i, nw, 1);
			
		}
		
		rep(i, W) {
			int a; cin>>a;
			rep(j, a) {
				int b; cin>>b; b--;
				// 親しいH, W
				F.add_edge(b, H+i, 1);
			}
			// W同士
			F.add_edge(H+i, H+W+i, 1);
			// W->Nc
			F.add_edge(H+W+i, nc, 1);

		}
		rep(i, C) {
			int a; cin>>a;
			rep(j, a) {
				int b; cin>>b; b--;
				// 親しいW, C
				F.add_edge(H+W+b, H+2*W+i, 1);
			}
			
			// C同士
			F.add_edge(H+2*W+i, H+2*W+C+i, 1);
			
			// Nw+1 -> C
			F.add_edge(nw+1, H+2*W+i, 1);
			// C -> Nm
			F.add_edge(H+2*W+C+i, nm, 1);
		}
		
		rep(i, M) {
			int a; cin>>a;
			rep(j, a) {
				int b; cin>>b; b--;
				// 親しいC, M
				F.add_edge(H+2*W+C+b, H+2*W+2*C+i, 1);
			}
			// M同士
			F.add_edge(H+2*W+2*C+i, H+2*W+2*C+M+i, 1);
			// Nc+1->M
			F.add_edge(nc+1, H+2*W+2*C+i, 1);
		}
				
		rep(i, M) {
			F.add_edge(H+2*W+2*C+M+i, t, 1);
		}
		
		F.add_edge(nw, nw+1, Nw);
		F.add_edge(nc, nc+1, Nc);
		F.add_edge(nm, nm+1, Nm);
		F.add_edge(nm+1, t, Nm);
		
		cout << F.max_flow(s, t) << endl;
	}
}

Measured memory_bytes: 1584
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    LL x,k,d;
    cin>>x>>k>>d;
    x = abs(x);
    LL m = x/d, ans;
    if(m >= k) ans = x - (k*d);
    else
    {
        LL k1 = k - m;
        ans = x - (m*d);
        if(k1 % 2)
        {
            ans = abs(ans - d);
        }
    }

    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a < c&&c < b)cout << "Yes" << endl;
	else if (a > c&&c > b)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <ctime>
#define LL long long
#define inf 0x3f3f3f3f
#define PII pair<int,int>
#define lson rt<<1
#define rson rt<<1|1
#define test freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
using namespace std;
const int maxn=3e5+5;
int main()
{
    int n;
    scanf("%d",&n);
    int t=n/2;
    if(n&1) ++t;
    printf("%.8f",1.0*t/n);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String str = scan.nextLine();
	int q = Integer.valueOf(scan.nextLine());
	for (int i = 0; i < q; i++) {
	    String commands = scan.nextLine();
	    String[] command = commands.split(" ");
	    if (command[0].equals("print")) {
		int a = Integer.valueOf(command[1]);
		int b = Integer.valueOf(command[2]);
		print(a, b, str);
	    } else if (command[0].equals("reverse")) {
		int a = Integer.valueOf(command[1]);
		int b = Integer.valueOf(command[2]);
		str = reverse(a, b, str);
	    } else if (command[0].equals("replace")) {
		int a = Integer.valueOf(command[1]);
		int b = Integer.valueOf(command[2]);
		String p = command[3];
		str = replace(a, b, p, str);
	    }
	}
    }
    public static void print(int a, int b, String str) {
	System.out.println(str.substring(a, b + 1));
    }
    public static String reverse(int a, int b, String str) {
	int diff = b - a + 1;
	int cnt = diff / 2;
	char[] strtmp = str.toCharArray();
	for (int j = 0; j < cnt; j++) {
	    char tmp = strtmp[a+j];
	    strtmp[a+j] = strtmp[b-j];
	    strtmp[b-j] = tmp;
	}
	return String.valueOf(strtmp);
    }
    public static String replace(int a, int b, String p, String str) {
	StringBuilder sb = new StringBuilder(str);
	sb.replace(a, b+1, p);
	return sb.toString();
    }
}

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

int main() {
  long long K;
  long long A;
  long long B;


  cin >>K ;
  cin >>A>>B;

  for(int i=A;i<=B;i++){
       if(i%K==0){
         cout << "OK" << endl; return 0;
       }
  }

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

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
const long long INF=1LL << 60;



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> dan(35,0);
    vector<int> dp(35,0);
    int N;
    for(int i=0;i<35;i++){
        int tmp;
        cin>>tmp;
        if(tmp==0){
            N=i;
            break;
        }
        dan[i]=tmp;        
    }
    dp[0]=1;
    for(int i=1;i<31;i++){
        dp[i]+=dp[i-1];
        if(i>1)dp[i]+=dp[i-2];
        if(i>2)dp[i]+=dp[i-3];
    }
    for(int i=0;i<N;i++){
        int tmp=dp[dan[i]]/3650;
        if(dp[dan[i]]%3650!=0) tmp++;
        cout << tmp <<endl;
    }

    return 0;
}


Measured memory_bytes: 3216
#include <algorithm>
#include <iostream>
#define INF (1e9)
using namespace std;

int main(){
  int d[10]={0,0,1,2,0,-1,2,0,1,2},cnt,ans,c;
  string s;
  while(1){
    cin>>s;
    if(s=="#") break;
    ans=INF;
    for(int i=0;i<2;i++){
      c=i;
      cnt=0;
      for(int j=1;j<s.size();j++){
	int k=s[j-1]-'0',t=s[j]-'0';
	if((!c&&d[k]>d[t])||(c&&d[k]<d[t])) cnt++;
	else c=!c;
      }
      ans=min(ans,cnt);
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
    return (a.second < b.second);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    int a, b;
    int r = INT_MAX;
    int ans = 0;
    
    vector<pair<int, int>> vp;
    
    rep(i, m) {
        cin >> a >> b;
        vp.push_back(pair<int, int>(a, b));
    }
    
    sort(all(vp), cmp);
    
    rep(i, m) {
        //printf("(%d, %d)\n", vp[i].first, vp[i].second);
        if ((r < (vp[i].first + 1)) || (r > vp[i].second)) {
            r = vp[i].second;
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
def lis(N, A):
    from bisect import bisect_left

    # dp[i] := 長さがi以下の部分列で作られる最長部分増加列の最後の要素の最小値
    dp = [-1]  # A[i] >= 0 なのでそれ以下の値を設定し、数列の単調性を保つ
    for a in A:
        if dp[-1] < a:
            dp.append(a)
        else:
            # LISテーブルが単調増加であるため、aに更新される場所は1箇所しかあり得ず、二分探索で決定できる
            idx = bisect_left(dp, a)
            dp[idx] = a
    print(len(dp) - 1)

N = int(input())
A = [int(input()) for _ in range(N)]
lis(N, A)


Measured memory_bytes: 10360
# ABC068C - Cat Snuke and a Voyage (ARC079C)
def main():
    N, M = tuple(map(int, input().split()))
    A = tuple(tuple(map(int, input().split())) for _ in range(M))
    S, D = set(), set()  # start, destination
    for a, b in A:
        if a == 1:
            S |= {b}
        if b == N:
            D |= {a}
    flg = S & D  # if the same X in both S & D -> possible
    print("POSSIBLE" if flg else "IMPOSSIBLE")


if __name__ == "__main__":
    main()

Measured memory_bytes: 37216
#define TEST_MODE true

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= b; --i)
#define range(i, a, b, c) for (int i = a;             \
                               c > 0 ? i < b : i > b; \
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long

#ifdef LOCAL_ENV

#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << endl
#else
const bool test = false;
#define dump(x) 
#endif

#else
const bool test = false;
#define dump(x) 
#endif

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while (getline(ss, buffer, sep))
    {
        v.push_back(buffer);
    }
    return v;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
    return accumulate(begin, end, 0ll);
}

void solve();

signed main()
{
    cout << fixed << setprecision(20);
    solve();
    while (true)
    {
        char s[MAX];
        if (scanf("%s", s) == EOF)
            break;
        int n = strlen(s);
        for (int i = n - 1; i > -1; i--)
        {
            ungetc(s[i], stdin);
        }
        solve();
    }
    return 0;
}

string A, B;

int cmp() {
	if (A.size() > B.size()) return 1;
	if (A.size() < B.size()) return -1;
	rep(i, A.size()) {
		if (A[i] > B[i]) return 1;
		if (A[i] < B[i]) return -1;
	}
	return 0;
}

void solve() {
	cin >> A >> B;
	string res;
	if (cmp() == 1) res = "GREATER";
	if (cmp() == -1) res = "LESS";
	if (cmp() == 0) res = "EQUAL";
	cout << res << endl;
}


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

int main() {
	string s;
	cin >> s;
	string ans = "Yes";
	if(s.size()%2==1) {
		cout << "No" << endl;
		return 0;
	}
	for(int i = 0; i < s.size()-1; i+=2) {
		if(s[i] != 'h' || s[i+1] != 'i') {
			cout << "No" << endl;
		return 0;
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)

using namespace std;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    string s;
    cin >> s;
    
    set<char> st;
    for(auto c : s) st.insert(c);

    if(s.size() < 26){
        rep(i, 26){
            if(st.count('a'+i) == 0){
                cout << s + (char)('a'+i) << endl;
                return 0;
            }
        }
    }

    for(int i = s.size()-1; 0 <= i; i--){
        for(char x = s[i]+1; x <= 'z'; x++){
            if(st.count(x) == 0){
                cout << s.substr(0, i) + x << endl;
                return 0;
            }
        }
        st.erase(s[i]);
    }
   
    cout << -1 << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ull i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl "\n"


int main() {
    #ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
    #endif
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    ll n; cin >> n;
    ll ans = 0;
    for__(i, 1, n+1) {
        ll k = n/i;
        ans += i * (k * (k + 1)) / 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
using namespace std;

int main(int argc, char const *argv[])
{
    double x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
    int x3,y3,x4,y4;
    double x12 = x2-x1;
    double y12 = y2-y1;
    double x14 = cos(M_PI_2)*x12-sin(M_PI_2)*y12;
    double y14 = sin(M_PI_2)*x12+cos(M_PI_2)*y12;
    x4 = x1 + round(x14);
    y4 = y1 + round(y14);
    x3 = x2 + round(x14);
    y3 = y2 + round(y14);

    cout << x3<<" "<< y3<<" "<< x4<<" "<< y4<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys

def key2rep_iter(key, key2rep, temp_list):
    if key2rep[key] == key:
        for i in temp_list:
            key2rep[i] = key2rep[key]
        return key
    temp_list.append(key)
    return key2rep_iter(key2rep[key], key2rep, temp_list)

def add_x2y(x, y, key2rep):
    rep = key2rep_iter(y, key2rep, [])
    big_rep = key2rep_iter(x, key2rep, [])
    if rep == big_rep:
        return
    key2rep[big_rep] = rep

N, M = map(int,input().split(' '))
p_list = [int(i) for i in input().split(' ')]
key2rep = {i+1:i+1 for i in range(N)}

for line in sys.stdin:
    x,y = map(int, line.strip().split(' '))
    add_x2y(max(x,y), min(x,y), key2rep)

print(len([1 for i in range(N) if key2rep_iter(p_list[i], key2rep, []) == key2rep_iter(i+1, key2rep, [])]))



Measured memory_bytes: 23392
#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

int main() {
    ll N, K, C;
    cin >> N >> K >> C;
    string S;
    getline(cin, S);
    getline(cin, S);
    vector<ll> work(N, 0);
    for (ll i = 0; i < N; i++) {
        if (S.at(i) == 'o') {
            work[i] = 1;
        }
    }

    vector<ll> rightmax(N, 0);
    for (ll i = N - 1; i >= 0; i--) {
        if (i + C < N - 1) {
            rightmax[i] = max(rightmax[i + 1], work[i] + rightmax[i + C + 1]);
        } else if (i < N - 1) {
            rightmax[i] = max(rightmax[i + 1], work[i]);
        } else {
            rightmax[i] = work[i];
        }
    }

    vector<ll> leftmax(N, 0);
    for (ll i = 0; i < N; i++) {
        if (i - C > 0) {
            leftmax[i] = max(leftmax[i - 1], work[i] + leftmax[i - C - 1]);
        } else if (i > 0) {
            leftmax[i] = max(leftmax[i - 1], work[i]);
        } else {
            leftmax[i] = work[i];
        }
    }

    for (ll i = 0; i < N; i++) {
        ll total = 0;
        total += (i > 0) ? leftmax[i - 1] : 0;
        total += (i < N - 1) ? rightmax[i + 1] : 0;
        if (total < K) {
            print(i + 1);
        }
    }
}


Measured memory_bytes: 8384
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
using namespace std;

struct start { start() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(10);
}; }start;

typedef long long ll;


int main(){
    int x;
    rep(i,1,10010){
        cin >> x;
        if(!x) break;
        else cout << "Case " << i << ": " << x << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
n=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
ans=sum(a1)+a2[n-1]
sum_a=ans

for i in range(n-1):
  sum_a=sum_a-a1[n-1-i]+a2[n-2-i]
  ans=max(ans,sum_a)
print(ans)




Measured memory_bytes: 61868
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0)
#define ll long long
#define ld long double
#define lcm(a, b) (a * b) / __gcd(a, b)
#define flu(i, a, b) for (ll i = a; i < b; i++)
#define blu(i, a, b) for (ll i = a; i >= b; i--)
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define Unique(X) (X).erase(unique(all(X)), (X).end())
#define all(v) v.begin(), v.end()
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
char e = '\n';
ll MOD = 1e9 + 7;
ll i, j, le;
vl G[1000000];
vl L(1000000, 0);
vl vis(1000000, 0);
void dfs(ll y, ll c)
{
  vis[y] = c;

  for (auto h : G[y])
  {
    if (vis[h] == 0)
      dfs(h, c);
  }
}

int main()
{
	IOS;
	int t;
	//cin >> t;
	t=1;
	while (t--)
	{ ll n,m,c,a,b;
		cin>>n>>m;
flu(i,1,m+1)
cin>>a>>b,G[a].pb(b),G[b].pb(a);
c=0;

flu(i,1,n+1)
if(vis[i]==0)
dfs(i,++c);
cout<<c-1<<endl;
	}
}


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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=105, mod=1e9+7;
inline void add(int &x,int y) {x=(x+y>=mod) ? (x+y-mod) : (x+y);}

int n,a[N];
int f[N/2][N][N];

int main() {
	n=rd();
	for(int i=1;i<=2*n-1;i++) a[i]=rd();
	sort(a+1,a+2*n);
	
	f[n][1][0]=1;
	for(int i=n-1;i>=1;i--) {
		int al=(a[i]!=a[i+1]), ar=(a[2*n-i]!=a[2*n-i-1]);
		for(int l=0;l<=2*n-1;++l)
			for(int r=0;r+l<=2*n-1;++r) if(f[i+1][l][r]) {
				int &t=f[i+1][l][r];	
				for(int dl=1;dl<=l+al;++dl) add(f[i][l+al-dl+1][r+ar+(dl>1)],t);
				for(int dr=1;dr<=r+ar;++dr) add(f[i][l+al+1][r+ar-dr],t);
			}
	}
	
	int ans=0;
	for(int l=0;l<=2*n-1;++l)
		for(int r=0;r+l<=2*n-1;++r)
			add(ans,f[1][l][r]);
	cout<<ans<<'\n';
}

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

a = []

f = [0 for i in range(n)]

ans = 0

for i in range(n):
    m = int(input())
    if m > 1:
        f[i] = 1
    ans += m//2
    a.append(m%2)

for i in range(n):
    if a[i] == 1 and i != n-1:
        if a[i+1] == 1:
            ans += 1
            a[i+1] = 0
        elif f[i+1] == 1:
            a[i+1] = 1
            
print(ans)

Measured memory_bytes: 4768
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int S,W;
  cin>>S>>W;
  if(S<=W) cout<<"unsafe"<<endl;
  else cout<<"safe"<<endl;

  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl

using namespace std;
using lli = long long int;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli x[101], y[101], h[101];

int main(void) {

	lli N,memo = 0;
	cin >> N;

	for (lli i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] != 0)
			memo = i;
	}

	cout.precision(18);

	for (lli cx = 0; cx <= 100; cx++) {
		for (lli cy = 0; cy <= 100; cy++) {
			lli H = h[memo] + abs(x[memo] - cx) + abs(y[memo] - cy);

			bool f = true;
			for (lli i = 0; i < N; i++) {
				if (h[i] == 0) {
					if(H - (abs(x[i] - cx) + abs(y[i] - cy)) > 0)
						f = false;
				}
				else if (H != h[i] + abs(x[i] - cx) + abs(y[i] - cy))
					f = false;
			}
			if (f) {
				cout << cx << " " << cy << " " << H << endl;
				return 0;
			}
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007

const int maxn = 3004;
double dp[maxn][maxn];

// i = number of coins
// x = number of required heads
double fun(vector<double>& arr, int i, int x)
{
	if (x == 0)  // if we need zero head from i coins
		return 1;
	if (i == 0) // if the coins have been exhausted
		return 0;
	if (dp[i][x] > -0.9)
		return dp[i][x];

	// if it comes head them we call for (coins-1,heads-1) else if it is tail
	// then we call for (coins-1,heads)
	return dp[i][x] = arr[i] * fun(arr, i - 1, x - 1) + (1 - arr[i]) * fun(arr, i - 1, x);

}
void solve()
{
	int n;
	cin >> n;
	memset(dp, -1, sizeof(dp));
	vector<double> arr(n + 1);
	for (int i = 1; i <= n; i++)
		cin >> arr[i];

	cout << fixed << setprecision(10) << fun(arr, n, (n + 1) / 2);

}

int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 71040
#include<iostream>
#include<queue>


using namespace std;

#define MAX_W 50
#define MAX_H 50

int main(){

  int w,h;
  char tile[MAX_H][MAX_W];

  cin>>w>>h;
  while(w!=0 && h!=0){
    pair<int,int> s;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>>tile[i][j];
	if(tile[i][j] == '@'){
	  s = make_pair(i,j);
	}
      }
    }

    int ans = 0;
    queue<pair<int,int> > que;
    que.push(s);
    int next[4][2] = {{0,1},{0,-1},{1,0},{-1,0}};

    while(!que.empty()){
      pair<int,int> now = que.front();
      que.pop();

      if(tile[now.first][now.second] != '#'){
	ans++;
	tile[now.first][now.second] = '#';

	for(int i=0;i<4;i++){
	  int ny = now.first + next[i][0];
	  int nx = now.second + next[i][1];
	  if(ny>=0 && ny<h && nx>=0 && nx<w && tile[ny][nx]!='#'){
	    que.push(make_pair(ny,nx));
	  }
	}
      }
    }

    cout<<ans<<endl;
    cin>>w>>h;
  }

  return 0;
}

Measured memory_bytes: 1216
/*for better*/
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define M 998244353
#define inf 1e9+10
using namespace std;

ll dp[105][100005];

int main()
{
    fast; 
    ll n,mx,i,j,m=100005,ans=0,x;
    cin>>n>>mx;
    ll w[n+1],v[n+1];
    f(i,1,n+1)
    	cin>>w[i]>>v[i];
    
    f(i,0,n+1)
    	dp[i][0]=0;
    f(j,1,m)
    	dp[0][j]=inf;

    f(i,1,n+1)
    {
    	f(j,1,m)
    	{
    		if(j>=v[i])
    		{
    			x=w[i]+dp[i-1][j-v[i]];
    			if(dp[i-1][j]>x)
    			{
    				dp[i][j]=x;
    				if(x<=mx)
    					ans=max(ans,j);
    			}
    			else dp[i][j]=dp[i-1][j];
    		}
    		else dp[i][j]=dp[i-1][j];
    	}
    }
    cout<<ans;
}


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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;cin>>n;
    ll ans = 0;
    rep(i,n){
        ll a;cin>>a;
        while(a%2==0){
            a/=2;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#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 dame {cout<< "No" <<"\n"; return;}
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 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---------------------------------
ll dp[100010][11]; // node,kyorid = 最後に塗られた番目
//--MAIN-----------------------------------
void Main() {
    ll N,M,Q; cin>>N>>M;
    vector<ll> G[N];
    vector<ll> A(M);
    vector<ll> B(M);
    rep(i,M){
        cin>>A[i]>>B[i]; --A[i],--B[i];
        G[A[i]].emplace_back(B[i]);
        G[B[i]].emplace_back(A[i]);
    }
    cin>>Q;
    ll btoc[Q+1]={}; //i番目は何色 1-ind
    rep(i,Q){
        ll v,d,c; cin>>v>>d>>c; --v;
        btoc[i+1]=c;
        dp[v][d]=i+1;
    }
    repr(i,10,1){
        rep(j,N){
            for(auto x:G[j]){
                maxi(dp[x][i-1],dp[j][i]);
            }
            maxi(dp[j][i-1],dp[j][i]);
        }
    }
    rep(i,N){
        cout<< btoc[dp[i][0]]<<"\n";
    }

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


Measured memory_bytes: 17780
#include<iostream>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
	ll n;
	cin >> n;
	ll a[n], odd[100010] = {}, even[100010] = {}, oddc[100010] = {}, evenc[100010] = {};
	for (int i = 1;i <= n;i++) {
		cin >> a[i];
		if (i % 2 == 0)even[a[i]]++;
		else odd[a[i]]++;
		if (i % 2 == 0)evenc[a[i]]++;
		else oddc[a[i]]++;
	}
	sort(evenc, evenc + 100010);
	sort(oddc, oddc + 100010);
	ll me1 = 0, me2 = 0, mo1 = 0, mo2 = 0;
	for (int i = 0;i <= 100000;i++) {
		if (odd[i] == oddc[100009] && mo1 == 0)mo1 = i;
		else if (odd[i] == oddc[100008])mo2 = i;
		if (even[i] == evenc[100009] && me1 == 0)me1 = i;
		else if (even[i] == evenc[100008])me2 = i;
	}
	if (mo1 != me1) {
		cout << n - oddc[100009] - evenc[100009] << endl;
	}
	else if (oddc[100008] > evenc[100008]) {
		cout << n - oddc[100008] - evenc[100009] << endl;
	}
	else cout << n - oddc[100009] - evenc[100008] << endl;
}


Measured memory_bytes: 4096
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
x.sort()
y.sort()
ans=False
for i in range(X+1,Y+1):
    if(x[-1]<i and y[0]>=i):
        ans=True
        break
if(ans):
    print('No War')
else:
    print('War')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

class UnionFind {
public:
    vl parent;  //親ノード
    vl Siz;  //集合の大きさ

    // コンストラクタ
    UnionFind(ll n): parent(n), Siz(n, 1LL) {
        rep(i, n) {
            parent[i] = i;
        }
    }

    // n要素で初期化
    void init(ll n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    ll root(ll x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(ll x, ll y) {

        x = root(x);
        y = root(y);

        if(x == y) {
            return;
        }

        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }

        Siz[x] += Siz[y];
        parent[y] = x;
    }
    
    // xとyが同じ集合に属するかどうか
    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    ll size(ll x) {
        return Siz[root(x)];
    }
};

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

    UnionFind Uni(n);
    Uni.init(n);

    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;  b--;
        Uni.unite(a, b);
    }

    set<ll> st;
    rep(v, n) {
        st.insert(Uni.root(v));
    }

    ll renketuseibun = st.size();  // 連結成分の個数

    out(renketuseibun);
    re0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<cstdio> 
#include<stdlib.h>
#include<string.h>
#include<algorithm>
#include<math.h>

#define MAXN 0x7fffffff

using namespace std;

int m,n,i,j,k,p,q,l,flag=0;

int main(){
	char a,b,c,d,e,f,enter;
	scanf("%c",&a);
	scanf("%c",&b);
	scanf("%c",&c);
	scanf("%c",&enter);
	scanf("%c",&d);
	scanf("%c",&e);
	scanf("%c",&f);
	if(a!=f){
		flag=1;
	}
	if(b!=e){
		flag=1;
	}
	if(c!=d){
		flag=1;
	}
	if(flag==0) printf("YES");
	else printf("NO");
	return 0;
} 

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i=0,j,k,N,M,x,y;
  ll priority[9]={1,7,4,5,3,2,9,6,8},cost[10]={0,2,5,5,4,5,6,3,7,6};
  cin>>N>>M;
  vector<ll> list(10,0),v;
  rep(j,M){
    cin>>x;
    list[x]++;
  }
  while(list[priority[i]]==0){
    i++;
  }
  x=N/cost[priority[i]];
  y=N-x*cost[priority[i]];
  if(y==0){
    rep(j,x){
      cout<<priority[i];
    }
    cout<<endl;
    return 0;
  }
  rep(j,i){
    if(list[priority[j]]&&cost[priority[j]]<=y){
      break;
    }
  }
  if(j!=i){
    if(cost[priority[j]]==y){
      if(priority[i]>priority[j]){
        rep(k,x){
          cout<<priority[i];
        }
        cout<<priority[j]<<endl;
      }else{
        cout<<priority[j];
        rep(k,x){
          cout<<priority[i];
        }
        cout<<endl;
      }
      return 0;
    }
    x+=1;
  }

  priority_queue<ll> que;
  while(x>6){
    que.push(priority[i]);
    N-=cost[priority[i]];
    x--;
  }
  rep(j,10){
    if(list[j])v.push_back(j);
  }
while(x){
  M=pow(v.size(),x);
  brep(i,M){
    j=i;
    vec tr(v.size(),0);
    rep(k,x){
      tr[j%v.size()]++;
      j/=v.size();
    }
    ll cnt=0;
    rep(k,(ll)v.size()){
      cnt+=tr[k]*cost[v[k]];
    }
    j=i;
    if(cnt==N){
      while(x--){
        que.push(v[j%v.size()]);
        j/=v.size();
      }
      x=0;
      break;
    }
  }
  if(x)x--;
}
  while(!que.empty()){
    cout<<que.top();que.pop();
  }
  cout<<endl;
  return 0;
}

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

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

    vector<bool> isAc = vector<bool>(n,false);
    vector<int> wa = vector<int>(n,0);

    int wac = 0;
    for(int i=0;i<m;i++){
        int prob;
        string res;
        cin>>prob>>res;
        if(!isAc[prob-1]){//非AC問題のみ計算
            if(res=="AC"){
                isAc[prob-1]=true;
            }else{
                wa[prob-1]++;
            }
        }
    }

    int resac =0;
    int reswa =0;
    for(int i=0;i<n;i++){
        if(isAc[i]){
            resac++;
            reswa += wa[i];
        }
    }
    cout<<resac<<' '<<reswa<<endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  double a,b; cin>>a>>b;
	double a_min = a/0.08, a_max = (a+1.0)/0.08;
	double b_min = b/0.10, b_max = (b+1.0)/0.10;
	for(int i=int(a_min);i<a_max;i++){
		if((double)i<a_min) continue;
		if(i>=b_min&&i<b_max) return cout<<i<<endl,0;
	}
	cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
A,B=map(int,input().split())

if B>A:
    A,B=B,A

X=A-B

Y=B-X

if Y%3!=0:
    print(0)
    exit()

Z=(Y*2)//3

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
print(cmb(Z+X,Z//2,mod))

Measured memory_bytes: 127560