akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
 
#define FI(z,n) for(int j=z; j<=n; j++)
#define FL(z,n) for(l j=z; j<=n; j++)
 
#define inf 10000000000
#define mod 1000000007
 
void In_Out(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("error.txt", "w", stderr);
    #endif
}

struct Act{
    ll A, B, C;
};
 
 
int main(){
 
    // In_Out();

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

    Act arr[n];

    for(ll i=0; i<n; i++){
        cin >> arr[i].A >> arr[i].B >> arr[i].C;
    }

    ll dp[n][3];
    dp[0][0] = arr[0].A;
    dp[0][1] = arr[0].B;
    dp[0][2] = arr[0].C;

    for(ll i=1; i<n; i++){

        for(ll j=0; j<3; j++){

            if(j==0){
                dp[i][j] = arr[i].A + max(dp[i-1][1], dp[i-1][2]);
            }
            else if(j==1){
                dp[i][j] = arr[i].B + max(dp[i-1][0], dp[i-1][2]);
            }
            else if(j==2){
                dp[i][j] = arr[i].C + max(dp[i-1][1], dp[i-1][0]);
            }
        }
    }

    ll ans = INT_MIN;
   for(ll i=0; i<3; i++){
    ans = max(ans, dp[n-1][i]);
   }

   cout << ans;
}

Measured memory_bytes: 8332
def resolve():
    import sys
    
    read = sys.stdin.read
    readline = sys.stdin.readline

    N, M = map(int, readline().split())
    a = set(int(x) for x in read().split())
    
    dp = [0] * (N + 2)
    dp[0] = 1

    for i in range(N):
        now = dp[i]
        if i + 1 not in a:
            dp[i + 1] += now
        if i + 2 not in a:
            dp[i + 2] += now

    print(dp[N] % 1_000_000_007)


resolve()


Measured memory_bytes: 467496
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll A,B,C,D;
  cin>>A>>B>>C>>D;
  if(B<=C||D<=A) {
    cout<<0<<endl;
    return 0;

  }
 vector<ll> vec(4);
 vec[0]=A;
 vec[1]=B;
 vec[2]=C;
 vec[3]=D;
 sort(all(vec));
 cout<<vec[2]-vec[1]<<endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<sstream>
#include<iomanip>
#include<bitset>
#include<map>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
using namespace std;
int main(){
  int n,sum=0;
  cin>>n;
  vector<lli> p(n);
  rep(i,0,n)
    cin>>p.at(i);
  rep(i,1,n-1){
    if((p.at(i-1)<p.at(i)&&p.at(i)<p.at(i+1))||(p.at(i-1)>p.at(i)&&p.at(i)>p.at(i+1)))
      ++sum;
      //ou(i);
  }
  ou(sum);
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N = keyboard.nextInt();
		
		int ame = 0;
		
		for(int i = 1; i <= N ; i++ ) {
			ame += i;
		}
			System.out.println(ame);	
			
		keyboard.close();	
	}
}

Measured memory_bytes: 23252
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
  char S[11];
  int pos;
  int cnt=0, flg, len, i, j=0;

  scanf("%s", S);
  len = strlen(S);
  pos = (int)(strstr(S, "C") - S) + 1;
  if(pos==len || pos<3){ puts("WA"); return 0;}
  if(S[0]=='A')
  {
    for(i=0; i<len; i++)
    {
        if(S[i]=='C'){cnt++;}
        if(islower(S[i])){j++;}
    }
  }
  if(j != (len-2)){ puts("WA"); return 0;}
  puts("AC");
  return 0;
}

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

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

    if ((n - k) % (k - 1) == 0){
        cout << (n - k) / (k - 1) + 1 <<endl;
    } else {
        cout << (n - k) / (k - 1) + 2 <<endl;
    }
    return 0;

}

Measured memory_bytes: 1024
// ABC-065-A Expired

#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  double X,A,B;
  cin >> X >> A >> B;

  double e = B - A;
  if (e <= 0) cout << "delicious" << endl;
  else if (e <= X) cout << "safe" << endl;
  else cout << "dangerous" << endl;
}



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

int main()
{
     int n;
    cin>>n;
  
    bool j = true;

    for(int i=0;i<n;i++)
    {
       int a;
       cin>>a;
    
       if(a%2==0)
       {
          if(a%3!=0&&a%5!=0) 
          {
             j=false;
          }
         
       }
  
    
    }


   if(j) 
       {cout<<"APPROVED"<<endl;}
   else  
       {cout<<"DENIED"<<endl;}


return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,m,q,x[100002],y[100002];
    string s,t;
    cin>>s>>t;
    n=s.length();
    m=t.length();
    x[0]=y[0]=0;
    for(int i=0;i<n;i++){
        x[i+1]=x[i]+1;
        if(s[i]=='B')x[i+1]++;
    }
    for(int i=0;i<m;i++){
        y[i+1]=y[i]+1;
        if(t[i]=='B')y[i+1]++;
    }
    cin>>q;
    for(int i=0;i<q;i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int z=(x[b]-x[a-1]-y[d]+y[c-1]+3000000)%3;
        if(z==0){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
}


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

long long n;
string s;

void solve();

int main() {
  cin >> n >> s;
  solve();
  return 0;
}

void solve() {
  long long d[2] = {0};
  string ans;
  for(int i = 0; i < n; ++i) {
    if(s[i] >= 'A' && s[i] <= 'M')
      ++d[0];
    else if(s[i] >= 'N' && s[i] <= 'Z')
      --d[0];
    else if(s[i] >= 'a' && s[i] <= 'm')
      ++d[1];
    else
      --d[1];
  }
  for(int i = 0; i < d[0]; ++i) ans += 'A';
  for(int i = d[0]; i < 0; ++i) ans += 'N';
  for(int i = 0; i < d[1]; ++i) ans += 'a';
  for(int i = d[1]; i < 0; ++i) ans += 'n';
  cout << ans.size() << endl << ans << endl;
}


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

int main() {
  ll n;
  int k, ans=0;

  cin >> n >> k;
  vector<int> h(n);

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

  sort(h.begin(),h.end(), greater<int>());
  for(int i=0; i<n; i++) {
    if(h[i]>=k) ans++;
    else break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	int x;
	int a;
	int b;
	int xa, xb;

    cin >> x >> a >> b ;
    xa = x-a > 0? x-a : a-x;
    xb = x-b > 0? x-b : b-x;
	cout<< ((xa > xb) ? "B" :"A") << endl;
}

Measured memory_bytes: 256
from itertools import product
s = input()
n = len(s)
if n == 1:
    print(int(s))
    exit()

plus_list = list(product([0, 1], repeat=n-1))
ans = 0
for plus in plus_list:
    next = 0
    for i in range(n-1):
        if plus[i] == 1:
            temp = s[next:i+1]
            #print(temp)
            ans += int(temp)
            next = i+1
        if i == n-2:
            temp = int(s[next:])
            #print(temp)
            ans += temp
print(ans)





Measured memory_bytes: 67644
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        call(n);
    }
    public static void call(int n){
        int i = 1;
        while(i<=n){
            int x = i;
             surplus(x,i);
            i++;
        }
        System.out.println();
    }
    public static void surplus(int i,int j){
        if(i%3==0 ) {
        	System.out.print(" "+j);
        }else {
        	while(i>=1) {
        	if(i%10 == 3) {
        		System.out.print(" "+j);
        		break;
        	}else i/=10;
        	}
        }
    }
}


Measured memory_bytes: 30640
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

ll power(ll a, ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans*=a;
        a*=a;
        n>>=1;
    }
    return ans;
}

int main()
{
    IOS;
    ll a,b;
    cin>>a>>b;
    ll d=__gcd(a,b);
    ll ans=1;
    for(ll i=2;i*i<=d;i++)
    {
        if(d%i==0)
        {
            ans++;
            while(d%i==0) d/=i;
        }
    }
    if(d>1) ans++;
    cout<<ans<<endl;
    return 0;  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        HashMap<String, Integer> hashmap = new HashMap<>();
        hashmap.put("S", 0);
        hashmap.put("H", 1);
        hashmap.put("C", 2);
        hashmap.put("D", 3);
        boolean[][] cards = new boolean[4][13];
        for (int i = 0; i < n; i++) {
            String design = sc.next();
            int num = Integer.parseInt(sc.next());
            cards[hashmap.get(design)][num - 1] = true;
        }
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 13; j++) {
                if (!cards[i][j]) {
                    String x = "";
                    switch(i) {
                        case 0: x = "S"; break;
                        case 1: x = "H"; break;
                        case 2: x = "C"; break;
                        case 3: x = "D"; break;
                    }
                    System.out.println(x + " " + (j + 1));   
                }
            }
        }
    }
}



Measured memory_bytes: 26340
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var a     = int.Parse(spl[0]);
        var b     = int.Parse(spl[1]);

        return 500 * a >= b ? Yes : No;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define eps 1e-9
#define oo 1e7+5

using namespace std;

typedef unsigned long long ull;
typedef vector<pair<int,pair<int,int>>> dirgraph;
typedef vector<vector<int>> graph;

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	
	int n,m;
	cin>>n>>m;
	vector<int> v(n+1);
	vector<bool> ac(n+1);
	int c_ans=0;
	int p_ans=0;

	for(int i=0;i<m;i++){
		int x;string r;
		cin>>x>>r;
		if(r=="AC"){
			if(!ac[x]){
				p_ans+=v[x];
				c_ans++;
				ac[x]=1;
				v[x]=0;
			}
		}
		else{
			v[x]++;
		}
	}

	cout<<c_ans<<" "<<p_ans<<endl;

	return 0;
}

Measured memory_bytes: 3968
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void){
    int N;
    scanf("%d", &N);

    int *L;
    
    int max = 0;
    int sum = 0;
    int i;
    L = (int*)malloc(N * sizeof(int));
    for(i=0; i<N; i++) {
        scanf("%d", &L[i]);
        sum += L[i];
        if(L[i] > max) {
            max = L[i];
        }
    }

    if(max < sum - max) {
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    free(L);

    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node{
	int key;
	Node *parent, *left, *right;
};

Node *root, *NIL;

Node* find(Node *u, int k){
	while(u != NIL && k != u->key)
	{
		if(k > u->key)
			u = u->right;
		else
			u = u->left;
	}
	return u;
}

void Insert(int k)
{
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node*)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	
	while(x!=NIL) //不是空树 
	{
		y = x;
		if(z->key < x->key)
			x = x->left;
		else if(z->key > x->key)
			x = x->right;
	}
	z->parent = y;
	if(y == NIL)
	{
		root = z;
	}
	else
	{
		if (z->key < y->key)
		{
			y->left = z;
		}
		else
			y->right = z;
	}
	
}

void PreOrderTraverse(Node *u)
{
	if(u == NIL)
		return;
	printf(" %d", u->key);
	PreOrderTraverse(u->left);
	PreOrderTraverse(u->right);
}

void InOrderTraverse(Node *u)
{
	if(u == NIL)
		return;
	InOrderTraverse(u->left);
	printf(" %d", u->key);
	InOrderTraverse(u->right);
}


int main()
{
	int n, x;
	char s[10];
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%s", s);
		if(s[0] == 'i')
		{
			scanf("%d", &x);
			Insert(x);
		}
		else if(s[0] == 'f')
		{
			scanf("%d", &x);
			Node *t = find(root, x);
			if(t != NIL)
				printf("yes\n");
			else
				printf("no\n");
		}
		else if(s[0] == 'p')
		{
			InOrderTraverse(root);
			printf("\n");
			PreOrderTraverse(root);
			printf("\n");
		}
			
	}
}



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

int main()
{
  int val,hold[4],i,roop;
  int money[4]={10,50,100,500};

  for(roop=0;;roop++){
    cin>>val;
    if(!val) break;
    int sum=-val; int ans[4]={0};
    for(i=0;i<4;i++){
      cin>>hold[i];
      sum+=money[i]*hold[i];
    }
    if(roop) cout<<endl;
    for(i=3;i>=0;i--){
      ans[i]+=sum/money[i];
      sum-=sum/money[i]*money[i];
    }
    for(i=0;i<4;i++)
      if(hold[i]>ans[i]) cout<<money[i]<<" "<<hold[i]-ans[i]<<endl;
  }
} 


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

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	int N; cin >> N;
	int x = 1, y = 1;
	rep(_, N) {
		int t, a; cin >> t >> a;
		int l = 0, r = min(LLONG_MAX / t, LLONG_MAX / a);
		while (l + 1 < r) {
			int mid = (l + r) / 2;
			if (x <= t * mid && y <= a * mid) r = mid;
			else l = mid;
		}
		x = t * r;
		y = a * r;
	}
	cout << x + y << endl;
	system("pause");
}

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

int main()
{
    string s,t;
    ll cnt=0,i;
    cin>>s>>t;

    ll l=s.size();

    for(i=0;i<l;i++)
    {
        if(s[i]!=t[i])
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3896
N = int(input())
A = []
A.append([int(n) for n in input().split()])
A.append([int(n) for n in input().split()])

res = 0
for i in range(N):
    res = max(res, sum(A[0][:i+1]) + sum(A[1][i:]))

print(res)



Measured memory_bytes: 3060
#include <cstdio>

int main(){
  int n, y;
  scanf("%d %d", &n, &y);
  int a, b, c;
  a = b = c = -1;
  for(int i=0; i<=n; i++){
    for(int j=0; j<=n-i; j++){
      if(10000*i + 5000*j + 1000*(n-i-j) == y){
        a = i;
        b = j;
        c = n - i - j;
      }
    }
  }
  printf("%d %d %d\n", a, b, c);
}

Measured memory_bytes: 128
import java.util.*;

class Main{
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int[] iline = new int[4];
		int isum = 0;
		char op1 = '-';
		char op2 = '-';
		char op3 = '-';
		
		for(int i=0;i<4;i++){
			iline[i] = line.charAt(i);
			iline[i] -= 48;
		}
		for(int j=0;j<2;j++){
			op1 = hantenchar(op1);
			for(int k=0;k<2;k++){
				op2 = hantenchar(op2);
				for(int l=0;l<2;l++){
					op3 = hantenchar(op3);
					isum = iline[0];
					if(op1 == '+'){
						isum += iline[1];
					}
					else{
						isum -= iline[1];
					}
					if(op2 == '+'){
						isum += iline[2];
					}
					else{
						isum -= iline[2];
					}
					if(op3 == '+'){
						isum += iline[3];
					}
					else{
						isum -= iline[3];
					}
					if(isum==7){
						j=2;
						k=2;
						l=2;
					}
				}
			}
		}
		System.out.println(iline[0]+""+op1+""+iline[1]+""+op2+""+iline[2]+""+op3+""+iline[3]+"=7");
    }
    public static char hantenchar(char x){
    	if(x == '+'){
    		x = '-';
    	}
    	else{
    		x = '+';
    	}
    	return x;
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    ll n, k;
    cin >> n >> k;
    VI a(n);
    REP(i,n) a[i] = in() - 1;
    VI p, q(n, -1);
    int x = 0;
    REP(i,n){
        p.push_back(x);
        q[x] = i;
        x = a[x];
        if (q[x] != -1) break;
    }
    if (k >= p.size()){
        int e = q[x], f = p.size();
        k = ((k - f) % (f - e)) + e;
    }
    cout << p[k] + 1 << endl;

    return 0;
}


Measured memory_bytes: 5924
M=10**9+7
r=[[(j-k)*9%13for j in range(10)]for k in range(13)]
d=[1]+[0]*12
for c in input():
  d = [sum(d[j]for j in k)%M for k in r] if c>'9' else [d[(int(c)-k)*9%13]for k in range(13)]
print(d[5])

Measured memory_bytes: 3188
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

S = [A,B,C,D,E]

s = []

for i in S:
    if i%10 != 0:
        s.append(i%10)

s.sort()

ans = 0

for i in S:
    if i%10 == 0:
        ans += i
    else:
        ans += i + 10 - i%10
if len(s) != 0:
    print(ans - 10 + s[0])
else:
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    map<int, int> mp;
    for(int i = 0; i < n; i++)
    {
        int x; cin >> x;
        mp[x]++;
    }
    int cnt = 0;
    for(auto x : mp)
    {
        if(x.second % 2 == 0) cnt++;
    }
    if(cnt % 2 == 0) cout << mp.size() << endl;
    else cout << mp.size() - 1 << endl;
    return 0;
}



Measured memory_bytes: 4992
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 2e5 + 10;
const int MOD = 1e9 + 7;
ll fac[N];
ll qpow(ll x, ll k) {
    ll r = 1;
    while(k) {
        if(k & 1) r = r * x % MOD;
        k >>= 1;
        x = x * x % MOD;
    }
    return r;
}
ll divd(ll x, ll y) {
    return x * qpow(y, MOD - 2) % MOD;
}
ll C(ll x, ll y) {
    return divd(fac[x], fac[y] * fac[x-y] % MOD);
}
int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    fac[0] =1;
    for(int i = 1; i < N; i++) {
        fac[i] = fac[i - 1] * i % MOD;
    }
    ll ans = C(h+w-2, h-1);
    for(int i = h - a; i <= h - 1; i++) {
        int x = i, y = b - 1;
        ll res = C(x+y, x) * C(h+w-3-x-y, h-1-x) % MOD;
        ans -= res;
        if(ans < 0) ans += MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MOD 1000000007

int main(){
  string S,T;
  cin>>S>>T;
  int ans=0;
  int N=S.size();
  for(int i=0;i<N;i++){
    if(S.at(i)!=T.at(i)){
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3912
from collections import deque

h, w = map(int, input().split())
s = [list(str(input())) for _ in range(h)]


def bfs(h, w, s, s_h, s_w):
    if s[s_h][s_w] == '#':
        return 0
    d_max = 0
    pas = [[-1 for _ in range(w)] for _ in range(h)]
    dist = [[-1 for _ in range(w)] for _ in range(h)]
    dist[s_h][s_w], pas[s_h][s_w] = 0, 's'
    que = deque()
    que.append((s_h, s_w))
    while len(que) > 0:
        q = que.popleft()
        near = [(q[0]+1, q[1]), (q[0], q[1]+1), (q[0]-1, q[1]), (q[0], q[1]-1)]
        for i in near:
            if (i[0] < 0) | (i[0] >= h) | (i[1] < 0) | (i[1] >= w):
                continue
            if (dist[i[0]][i[1]] == -1) & (s[i[0]][i[1]] == '.'):
                dist[i[0]][i[1]] = dist[q[0]][q[1]] + 1
                pas[i[0]][i[1]] = q
                que.append(i)
                d_max = max(dist[q[0]][q[1]] + 1, d_max)
    return d_max


dmax = 0
for i in range(h):
    for j in range(w):
        dist = bfs(h, w, s, i, j)
        dmax = max(dmax, dist)
print(dmax)


Measured memory_bytes: 3316
/*/ Author:Amar1503/*/
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define fio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ull unsigned long long
#define ll long long
#define inf 1e9
#define mninf INT_MIN
#define Mod 1000000007
#define endl "\n"
#define cp(x) cout<<(x)<<" "
#define cl(x) cout<<(x)<<endl
#define ct(x,y) cout<<(x)<<" "<<(y)<<endl;
#define nl   cout<<endl
//const double PI=3.1415926535897932384626433832;
//looping
#define For(i,a,b) for(int i=a;i<b;i++)
#define test(t)  int (t); cin>>(t); while((t)--)
#define array(a,n) int (n); cin>>(n); int a[n]; for(int i=0;i<(n);i++) cin>>a[i];
#define trace(x) clog<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) clog<<#x<<": "<<x<<"     "<<#y<<" "<<y<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define printv(v)  for(int i=0;i<(v).size();i++) cout<<v[i]<<" "
//containers
#define F first
#define S second
#define pb emplace_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define itr(it, a) for(auto it = (a).begin(); it != (a).end(); it++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ers(v)   sort(all(v)); (v).erase(unique(all(v)),(v).end())
#define printmatrix(a,n,m) for(int i=0;i<n;i++){ for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
typedef pair <int, int> pii;
typedef vector < pair <int, int> > vpii;
// cout<<"\nTime Elapsed : " << 1.0*clock() /CLOCKS_PER_SEC << " s\n";
int dx[8]={1,-1,0,0,1,1,-1,-1};
int dy[8]={0,0,1,-1,1,-1,1,-1};
#define int long long
const ll INF=1e18L+5;
/*/----------------------------Code begins----------------------------------/*/
string a,b;
vector<vector<int> > dp(3001,vector<int> (3001,0));
int32_t main(){
fio;
cin>>a>>b;
int n=a.size(),m=b.size();
for(int i=1;i<=n;i++){
	for(int j=1;j<=m;j++){
		if(a[i-1]==b[j-1])
		dp[i][j]=dp[i-1][j-1]+1;
		else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
	}
}
//printmatrix(dp,n+1,m+1);
string s;
int i=n,j=m;
while(i>0&&j>0){
	if(dp[i][j]==dp[i-1][j])
		i--;
	else if(dp[i][j]==dp[i][j-1])
	j--;
	else {
	s+=a[i-1];
	i--;j--;
	}
}
reverse(s.begin(),s.end());
cout<<s;
}







Measured memory_bytes: 70784
#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>

using namespace std;

long long N,M,H,W;
long long A[200001];
long long B[200001] = {};
long long x[51][2] = {};
long long y[2][200] = {};
int ayasi[5] = {};
bool r[52] = {};
int check[102][102] = {};
long long result=0;
string S;
vector <long long>vl;
typedef pair<long long, long long> pl;
vector <pl> vpl;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (i == 0) {
			B[i] = A[i];
		}
		else {
			B[i] = B[i - 1] + A[i];
			
		}
		if (B[i] == 0) {
			M++;
		}

		vl.push_back(B[i]);

	}
	H = 1;
	sort(vl.begin(), vl.end());
	for (int i = 1; i < vl.size(); i++) {
		if (vl[i] != vl[i - 1]) {
			M += H*(H-1) / 2;
			H = 0;
		}
		H++;
	}
	M += H*(H - 1) / 2;

	cout << M<<endl;
	return 0;
}


Measured memory_bytes: 5104
#include <stdio.h>
#include <string.h>

int main(void)
{
	char blood[3];
	int number;
	char conma;
	int A = 0;
	int B = 0;
	int O = 0;
	int AB = 0;
	
	while (scanf("%d %c %s", &number, &conma, &blood) != EOF){
		if (strcmp("A", blood) == 0){
			A++;
		}
		else if (strcmp("B", blood) == 0){
			B++;
		}
		else if (strcmp("O", blood) == 0){
			O++;
		}
		else if (strcmp("AB", blood) == 0){
			AB++;
		}
	}
	
	printf("%d\n%d\n%d\n%d\n", A, B, AB, O);
	
	return 0;
}

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

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_S = 100000;
int q;
string S, T;
ll snuma[MAX_S], tnuma[MAX_S];

int main() {
  cin >> S >> T;
  cin >> q;

  if (S[0] == 'A') snuma[0] = 1;
  if (T[0] == 'A') tnuma[0] = 1;
  for (int i = 1; i < S.size(); ++i) {
    if (S[i] == 'A') snuma[i] = snuma[i-1]+1;
    else snuma[i] = snuma[i-1];
  }
  for (int i = 1; i < T.size(); ++i) {
    if (T[i] == 'A') tnuma[i] = tnuma[i-1]+1;
    else tnuma[i] = tnuma[i-1];
  }

  while (q--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    --a; --b; --c; --d;
    int difs = 2*(snuma[b]-(a == 0 ? 0 : snuma[a-1])) - (b-a+1);
    int dift = 2*(tnuma[d]-(c == 0 ? 0 : tnuma[c-1])) - (d-c+1);
    if (abs(difs-dift)%3 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#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> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> d(N);
    REP(i,N)cin >> d[i];
    sort(d.begin(),d.end());
    cout <<d[N/2] - d[N/2-1]<< "\n";
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
n,c=map(int,input().split())
prog=[]
stc=[]
for i in range(n):
    x=tuple(map(int,input().split()))
    stc.append(x)
stc=sorted(stc)
video=[[0]*(10**5+1) for i in range(30)]
for s,t,ci in stc:
    if video[ci-1][s]!=-1:
        video[ci-1][s-1]+=1
        video[ci-1][t]-=1
    else:
        video[ci-1][s]=0
        video[ci-1][t]-=1
newvideo=[]
for i in range(10**5+1):
    cnt=0
    for c in range(30):
        cnt+=video[c][i]
    newvideo.append(cnt)

from itertools import accumulate
videoacc=list(accumulate(newvideo))

print(max(videoacc))

Measured memory_bytes: 121660
s=input()
s_re = s[::-1]
list =  ["dream","dreamer","erase", "eraser"]
list_re = [ i[::-1] for i in list]

count=True
while count:
    value=0
    for i in list_re:
        if s_re[:len(i)] == i:
            s_re = s_re[len(i):]
            value=0
        else:
            value+=1
    if value>3:
        count=False

if s_re=="":
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9340
#include<iostream>
#include<iomanip>
using namespace std ;
using ll = long long ;
using ld = long double ;

int main(){
	ld n,k ; 
	cin >> n >> k ;
	ld ans = 1 ;
    ld mx = 1 ;
    while(k>mx){ mx *= 2 ; }
	for(int i=2;i<=n;i++){
		ld two = 1 ;
		while(k>two*i){
			two *= 2 ;
		}
		ans += mx/two ;
	}
	cout << fixed << setprecision(10) << ans/n/mx << endl ;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100000

void swap(int *,int *);
int partition(int *,int,int);


int main()
{
  int w[MAX],a,i,c;
  
  scanf("%d",&a);
  
  for(i=0;i<a;i++)scanf("%d",&w[i]);
  
  c = partition(w,0,a-1);
  
  for(i=0;i<a;i++){
    if(i==c){
      printf("[%d] ",w[i]);
      continue;
    }
    
    if(i!=a-1)printf("%d ",w[i]);
    else printf("%d\n",w[i]);
      }
  
  return 0;
}


void swap(int *s,int *t)
{
  int r = *s;
  
  *s=*t;
  *t=r;
}

int partition(int *x,int y,int z)
{
  int k=x[z],i=y-1,j;
  
  for(j=y;j<z;j++){
    if(x[j]<=k){
      i++;
      swap(&x[i],&x[j]);
    }
  }
  
  swap(&x[i+1],&x[z]);
  
  return i+1;
}




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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;

int N;
int x[55], y[55];

int square(int a) { return a * a; }

int f(int x, int y) { return x * x + y * y; }

long double sqrt2(int x) {
    long double mi = 0;
    long double ma = x + 100;
    while (ma - mi > 1e-10) {
        long double m = (mi + ma) / 2;
        if (m * m > x)ma = m;
        else mi = m;
    }
    return mi;
}

signed main() {
    cin >> N;
    rep(i, N) {
        cin >> x[i] >> y[i];
    }
    cout << fixed << setprecision(20);
    //半径が最小の時少なくとも3つの点が円周上にある。そうでなければ縮められる
    if (N == 2) {
        //二点の距離/2
        cout << sqrt(square(x[0] - x[1]) + square(y[0] - y[1])) / 2 << endl;
        return 0;
    }
    //const double eps = 1e-4;
    long double ans = 1e10;
    rep(i, N) {
        rep(j, N) {
            if (i == j)continue;
            rep(k, N) {
                if (i == k || j == k)continue;
                //点i,j,kが円周上
                int alpha = x[i] - x[j];
                int beta = y[i] - y[j];
                int gamma = x[j] - x[k];
                int delta = y[j] - y[k];
                int Z1 = f(x[i], y[i]) - f(x[j], y[j]);
                int Z2 = f(x[j], y[j]) - f(x[k], y[k]);
                //double a = 1. * (delta * Z1 - beta * Z2) / (2 * (alpha * delta - beta * gamma));
                //double b = 1. * (-gamma * Z1 + alpha * Z2) / (2 * (alpha * delta - beta * gamma));
                int bunbo = 2 * (alpha * delta - beta * gamma);
                int a2 = (delta * Z1 - beta * Z2);
                int b2 = (-gamma * Z1 + alpha * Z2);
                if (bunbo < 0) {
                    bunbo *= -1;
                    a2 *= -1;
                    b2 *= -1;
                }
                //double r2 = square(x[i] - a) + square(y[i] - b);
                int r22 = square(bunbo * x[i] - a2) + square(bunbo * y[i] - b2);
                bool can = true;
                rep(l, N) {
                    if (square(bunbo * x[l] - a2) + square(bunbo * y[l] - b2) > r22) {
                        can = false;
                        break;
                    }
                }
                if (can)ans = min(ans, sqrt((long double) r22 / bunbo / bunbo));
            }
        }
    }
    rep(i, N) {
        rep(j, N) {
            int a2 = (x[i] + x[j]);
            int b2 = (y[i] + y[j]);
            int r22 = square(2 * x[i] - a2) + square(2 * y[i] - b2);
            bool can = true;
            rep(k, N) {
                if (square(2 * x[k] - a2) + square(2 * y[k] - b2) > r22) {
                    can = false;
                    break;
                }
            }
            if (can)ans = min(ans, sqrt((long double) r22) / 2);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int a = 0;//タップ追加を数える変数
    int s = 1;//分岐した先端の数を数える変数
    int A,B;
    cin >> A >> B;
    while (s  < B) {
        s += A-1;
        a++;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int H,W;
  while (1) {
    cin >> H >> W;
    if (H == 0 && W == 0)break;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (i != 0 && i != H - 1 && j != 0 && j != W - 1) {
          cout << ".";
        }
        else cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3004
#include <stdio.h>

void DFS();
void ReVisit(int);
void print();

int Adj[100][100];
int d[100];
int f[100];
int n, i, j, count;

int main() {
  int u, v, k;

  scanf("%d",&n);

  for( i=0 ; i<n ; i++ ) {
    d[i] = 0;
    f[i] = 0;
    for( j=0 ; j<n ; j++ ) Adj[i][j] = 0;
  }
  
  for( i=0 ; i<n ; i++ ) {
    scanf("%d%d",&u,&k);
    for( j=0 ; j<k ; j++ ) {
      scanf("%d",&v);
      Adj[i][v-1] = 1;
    }
  }

  DFS();
  print();

  return 0;
}

void DFS() {
  count = 1;
 
  for( i=0 ; i<n ; i++ ) {
      if(d[i] == 0)
    ReVisit(i);
    }
}
 
void ReVisit(int u) {
  int l;
  d[u] = count++;
  for( l=0 ; l<n ; l++ ) {
    if(Adj[u][l] == 1 && d[l] == 0) ReVisit(l);
  }
  f[u] = count++;
}

void print() {
  for( i=0 ; i<n ;i++ )
    printf("%d %d %d\n",i+1,d[i],f[i]);
}

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;



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

	string S;
	cin >> S;

	ll ans0 = 0;
	ll ans1 = 0;

	for (ll i = 0; i < S.size(); ++i)
	{
		if (i % 2 == 0)
		{
			if (S[i] == '0')
			{
				ans0++;
			}
			else
			{
				ans1++;
			}
		}
		else
		{
			if (S[i] == '1')
			{
				ans0++;
			}
			else
			{
				ans1++;
			}
		}
	}

	ll ans = min(ans0, ans1);
	cout << ans << endl;

	//system("pause");
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int n; cin >> n;
    vector<int>  B(n-1);
    rep(i, n-1) cin >> B[i];

    int res = 0;
    res += B[0] + B[n-2];
    for(int i=1; i<n-1; i++){
        res += min(B[i], B[i-1]);
    }
    cout << res << ln;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);

  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }

  for (int i = a.size()-1; i >= 0; i-=2)
  {
    cout << a[i] << " ";
  }

  int m;
  if(n%2) m=1;
  else m=0;

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

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  int X,A;
  cin>>X>>A;
  cout<<((X<A)?0:10)<<endl;
  return 0;
}


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



int main()
{
	long long a[200005],n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	long long ind=1;
	long long cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==ind)
		{
			ind++;
			continue;
		}
		cnt++;
	}
	if(cnt==n) cout<<-1<<'\n';
	else cout<<cnt<<'\n';
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

const int INF=1e9;
int dp[100010]={};

int main(){
	int n;
	cin>>n;
	vi a(n);
	rep(i,0,n) cin>>a[i];
	fill(dp,dp+n,INF);
	rep(i,0,n){
		*lower_bound(dp,dp+n,a[i])=a[i];
	}
	o(lower_bound(dp,dp+n,INF)-dp);
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
#include <ctime>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// #include<boost/multiprecision/cpp_int.hpp>
// using boost ::multiprecision::cpp_int;
/*__builtin_clz();
__builtin_ctz();
__builtin_popcount();*/
ll n;
ll a[100002] ={0};
ll dp[100002];
ll fun(ll idx)
{
    if(idx >=n)
    return 0;
    if(idx==n-1)
    {
        dp[idx] =0;
        return 0;
    }
    if(dp[idx] != -1)
    {
        return dp[idx];
    }
    ll k1 =fun(idx +1);
    ll k2 = fun(idx+2);
    ll x1 =  abs(a[idx] - a[idx+1])+k1;
    ll x2= abs(a[idx] - a[idx+2])+k2;
    ll k;
    if(idx+2 < n)
    {
        k =min(x1,x2);
    }
    else 
    {
        k=x1;
    }
    // cout<<idx<<" "<<x1<<" "<<x2<<"\n";
    return dp[idx] = k;
    

}
int main()
{
    boost;
    cin>>n;
    for(ll i=0;i<n;i++)
    cin>>a[i];
    memset(dp,-1,sizeof dp);
    cout<<fun(0)<<"\n";

    cerr << "\nTime elapsed: " << 1000 * clock()/CLOCKS_PER_SEC << "ms\n";
}
/* AnsHuman_7 || Anshuman Gaur */

Measured memory_bytes: 9824
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  int box[n]={0};
  // int ans=1;
  box[0]=1;
  int bxcnt[n];
  rep(i,n) bxcnt[i]=1;
  rep(i,m){
    int x,y;
    cin>>x>>y;
    if(bxcnt[x-1]!=0){
      if(box[x-1]==1 && box[y-1]==0) box[y-1]=1;
      bxcnt[x-1]--;
      bxcnt[y-1]++;
      if(bxcnt[x-1]==0) box[x-1]=0;
    }
  }
  int ans=0;
  rep(i,n){
    ans+=box[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] n=sc.next().split("");

		for(int i=0;i<3;i++) {
			System.out.print(Integer.valueOf(n[i])==1?"9":"1");
		}
	}
}

Measured memory_bytes: 23636
#coding: UTF-8

from bisect import bisect_right

max_number = 1000000
prime_flag_list = [True] * max_number

prime_flag_list[0] = False
prime_flag_list[1] = False

prime_flag_list[4::2] = [False] * len(prime_flag_list[4::2])

for i in range(3, int(max_number**0.5) + 1, 2):
    prime_flag_list[i*i::i] = [False] * len(prime_flag_list[i*i::i])

prime_list = [i for i in range(2, max_number) if prime_flag_list[i]]

while True:
    try:
        input = int(raw_input())
    except EOFError:
        break
    print bisect_right(prime_list, input)

Measured memory_bytes: 44588
N,K=map(int,input().split())

class SegTree:
    """ segment tree with point modification and range product. """
    # # https://yukicoder.me/submissions/452850
    def __init__(self, N, data_f = min, data_unit=1<<30):
        self.N = N
        self.data_f = data_f
        self.data_unit = data_unit
        self.data = [self.data_unit] * (N + N)

    def build(self, raw_data):
        data = self.data
        f = self.data_f
        N = self.N
        data[N:] = raw_data[:]
        for i in range(N - 1, 0, -1):
            data[i] = f(data[i << 1], data[i << 1 | 1])

    def set_val(self, i, x):
        data = self.data
        f = self.data_f
        i += self.N
        data[i] = x
        while i > 1:
            data[i >> 1] = f(data[i], data[i ^ 1])
            i >>= 1

    def fold(self, L, R):
        """ compute for [L, R) """
        vL = vR = self.data_unit
        data = self.data
        f = self.data_f
        L += self.N
        R += self.N
        while L < R:
            if L & 1:
                vL = f(vL, data[L])
                L += 1
            if R & 1:
                R -= 1
                vR = f(data[R], vR)
            L >>= 1
            R >>= 1
        return f(vL, vR)

A=[int(input()) for _ in range(N)]
seg = SegTree(300005,max,0)
seg.build([0]*300005)
for i in range(N):
  a = A[i]
  tmp = seg.fold(max(0,a-K),min(300005,a+K+1))
  seg.set_val(a,tmp+1)

print(seg.fold(0,300005))

Measured memory_bytes: 109620
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=sorted([a[i]-b[i] for i in range(N)])
k=-sum(c)
# print(c,k)
cp=[ci for ci in c if ci>0]
cn=[ci for ci in c if ci<0]

# 必要な「1増やす回数」
p=sum(cp)+sum([cni%2 for cni in cn])
# 必要な「2減らす回数」
n=sum([(-cni+1)//2 for cni in cn])

f=k>=0 and p<=k and n<=k

print('Yes' if f else 'No')

Measured memory_bytes: 41072
#include <bits/stdc++.h>
using namespace std;
vector<int> to[100005];
const int INF = 1001001001;

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

  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  queue<int> q;
  vector<int> dist(n, INF);
  vector<int> pre(n, -1);
  dist[0] = 0;
  q.push(0);

  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int u : to[v]) {
      if (dist[u] != INF) continue;
      dist[u] = dist[v] + 1;
      pre[u] = v;
      q.push(u);
    }
  }

  cout << "Yes" << endl;
  for (int i = 0; i < n; i++) {
    if (i == 0) continue;
    int ans = pre[i];
    ans++;
    cout << ans << endl;
  }
}

Measured memory_bytes: 10748
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

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

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i,0,n){
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    sort(all(b));
    ll ans;
    debug(a);
    debug(b);
    if(n%2==1){
        debug(b[n/2],a[n/2]);
        ans = b[n/2] - a[n/2] + 1ll;
    }
    else{
        ans = b[n/2]+b[n/2-1] - a[n/2] - a[n/2-1] + 1ll;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6340
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  vector<int> con[N];
  set<int> s[N];
  map<pair<int,int>,int> m;
  int ans[N-1];
  REP(i,N-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    con[a].push_back(b);
    con[b].push_back(a);
    m[make_pair(a,b)]=i;
    m[make_pair(b,a)]=i;
  }
  int K=0;
  queue<int> q;
  q.push(0);
  s[0].insert(-1);
  while(!q.empty()){
    int p=q.front();
    q.pop();
    int x=0;
    for(auto e:con[p])if(s[e].empty()){
      while(s[p].find(x)!=s[p].end())x++;
      ans[m[make_pair(p,e)]]=x;
      K=max(K,x+1);
      s[e].insert(x);
      x++;
      q.push(e);
    }
  }
  cout<<K<<endl;
  REP(i,N-1)cout<<ans[i]+1<<endl;
  return 0;
}


Measured memory_bytes: 28288
#include<iostream>

using namespace std;

int main(){
  int in[6];
  for(int i=0;i<6;i++){
    cin>>in[i];
  }
  int s[6][6]={
    {in[0],in[1],in[2],in[4],in[3],in[1]},
    {in[1],in[5],in[2],in[0],in[3],in[5]},
    {in[2],in[1],in[5],in[4],in[0],in[1]},
    {in[3],in[1],in[0],in[4],in[5],in[1]},
    {in[4],in[0],in[2],in[5],in[3],in[0]},
    {in[5],in[1],in[3],in[4],in[2],in[1]}
  };
  int q;
  cin>>q;
  for(int g=0;g<q;g++){
    int u,f,r,v;
    cin>>u>>f;
    for(int p=0;p<6;p++){
      if(s[p][0]==u){
        for(v=1;v<5;v++){
          if(s[p][v]==f){
            r=s[p][v+1];
            break;
          }
        }
      }
    }
    cout<<r<<endl;
  }
}



Measured memory_bytes: 3088
#include <iostream>
#include <string>
 
using namespace std;
 
int main(int argc, char** argv)
{
  string str;
  int len;
  cin >> len;
  cin >> str;
  if(str.length() > len)
  {
    string outstr = str.substr(0, len);
    cout << outstr << "..." << endl;
  }
  else
  {
    cout << str << endl;
  }
  return 0;
}

Measured memory_bytes: 3624