akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=10050;
//↑templete
signed main(){

    ll A, B, M;
    cin>>A>>B>>M;
    vll C, D;
    for(int i=0;i<A;i++){
        int c;
        cin>>c;
        C.pb(c);
    }
    for(int i=0;i<B;i++){
        int d;
        cin>>d;
        D.pb(d);
    }
    ll ans=INFLL;
    for(int i=0;i<M;i++){
        ll x, y, c;
        cin>>x>>y>>c;
        x--, y--;
        ans=min(ans, C[x]+D[y]-c);
    }
    sort(C.begin(), C.end());
    sort(D.begin(), D.end());
    
    cout<<min(ans, C[0]+D[0])<<endl;
	
    return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
    #define ll  long long int
    #define pb push_back
    #define mp make_pair
    #define ff first
    #define ss second
    #define vi vector<int>
    #define br cout <<"\n";
    #define all(x)  (x).begin(),(x).end()
    #define tr(c,i) for(auto i : c)
    #define pii pair< int,int >
    #define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
    #define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
    #define er(x) cout << x << " "
    #define err(x,y) cout << x << " "<<y
    const int M = 200005;
    using namespace std;
    clock_t time_p=clock();
    void dem()
    {
        time_p=clock()-time_p;
        cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
    }
    using namespace std ;
    const int N =  100 ;
    const int dx[] = { 1, -1 , 0 , 0  };
    const int dy [] = { 0 ,0 , 1 , -1  };
    const int MOD = 1000 * 1000 * 1000 + 9 ;
    int main (){
   int n , k  ;
cin >> n >> k ;
vector<int> v ( n ) ;
for ( auto &x : v  ) cin >> x ;
sort( all( v)  ) ;
int lb = lower_bound(all( v ) , k ) - v.begin() ;
int res = n - lb ;


cout << res  ;

    return 0 ;
    }


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
#include <unordered_set>
#define rep(i, n) for(int i = 0; i < n; i++)
//#include <Windows.h>
//#include "Library.h"
//#include "Math.h"
using namespace std;
typedef long long int ll; typedef pair <int, int> P; typedef vector <int> vecint;
const int INF = 100000000000;
const double EPS = 10e-9;
int main()
{
	int a; cin >> a;
	int tmp = a;
	int b = tmp / 1000;
	tmp %= 1000;
	int c = tmp / 100;
	tmp %= 100;
	int d = tmp / 10;
	tmp %= 10;
	if ((b == c && c ==  d )|| (c == d && d== tmp))  { cout << "Yes" << endl; return 0; }
	cout << "No" << endl;
	return 0;
}

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

int main()
{

	int i, N;
	char S;
	
	cin >> N;

	for (i = 0; i < N; ++i){
		cin >> S;
		if (S == 'Y'){
			cout << "Four" << endl;
			return 0;
		}

	}

	cout << "Three" << endl;

	return 0;

}


Measured memory_bytes: 256
# ABC126D - Even Relation
def dfs(r: int) -> None:
    stack = [r]
    while stack:
        v = stack.pop()
        for u, w in T[v]:
            if D[u] == -1:
                D[u] = (D[v] + w) % 2
                stack += [u]


def main():
    global T, D
    N, *A = map(int, open(0).read().split())
    T = [[] for _ in range(N + 1)]
    for i in range(0, (N - 1) * 3, 3):
        v, u, w = A[i : i + 3]
        T[v] += [(u, w)]
        T[u] += [(v, w)]
    D = [-1] * (N + 1)  # D[i] := parity of distance from vertex 1 (root)
    D[1] = 0
    dfs(1)
    print(*D[1:], sep="\n")


if __name__ == "__main__":
    main()

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

namespace ConsoleApplication1
{
    class Program
    {
        static readonly double INF = 1e8;

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] temp = input.Split(' ');

                int W = int.Parse(temp[0]);

                List<double> r = new List<double>();

                for (int i = 1; i < temp.Length; i++)
                {
                    r.Add(double.Parse(temp[i]));
                }

                int n = r.Count;

                double[,] dp = new double[1 << n, n];

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

                for (int i = 0; i < n; i++)
                {
                    dp[(1 << n) - (1 << i) - 1, i] = r[i];
                }

                for (int i = (1 << n) - 1; i >= 0; i--)
                {
                    for (int j = 0; j < n; j++)
                    {
                        if ((i & (1 << j)) != 0) continue;

                        for (int k = 0; k < n; k++)
                        {
                            double dist = Math.Sqrt((r[j] + r[k]) * (r[j] + r[k]) - (r[j] - r[k]) * (r[j] - r[k]));

                            dp[i, j] = Math.Min(dp[i, j], dp[i | (1 << j), k] + dist);
                        }
                    }
                }

                double min = INF;

                for (int i = 0; i < n; i++)
                {
                    min = Math.Min(min, dp[0, i] + r[i]);
                }
                sb.AppendLine(min > W ? "NA" : "OK");
            }
            Console.Write(sb);
        }
    }
}

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


signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 int n;
 cin>>n;
 int a[n+1];
 int dp[n+1][n+1];
 memset(dp,0,sizeof(dp));
 for(int i=1;i<=n;i++)
 {
      cin>>a[i];
 }
 int x=1;    //x=0 if the taro chance else x=1 for jiro
 if(n&1)
 {
      x=0;
 }
 for(int i=1;i<=n;i++)
 {
      dp[i][i]=a[i];
      if(x==1)
      dp[i][i]*=-1;
 }
 for(int len=1;len<n;len++)
 {
     x^=1;
     for(int i=1;i+len<=n;i++)
     {
          //cout<<i<<" "<<i+len<<" "<<x<<endl;
          if(x==0)
          dp[i][i+len]=max(dp[i][i+len-1]+a[i+len],dp[i+1][i+len]+a[i]);
          else
          dp[i][i+len]=min(dp[i][i+len-1]-a[i+len],dp[i+1][i+len]-a[i]);
     }
 }
 cout<<dp[1][n]<<endl;
 
//  for(int i=1;i<=n;i++)
//  {
//       for(int j=1;j<=n;j++)
//       cout<<dp[i][j]<<" ";
//       cout<<endl;
//  }
}

Measured memory_bytes: 70656
from math import *
a,b,c,d = map(int,input().split())
f =(c*d)//gcd(c,d)
r = f
rock = 2
compteur= (b//f)-(a//f)
if a%f==0:
  compteur +=1
div1 = ((b//c)-(a//c))
div2 = ((b//d)-(a//d))
if  a%c == 0:
  div1+=1
if a%d ==0:
  div2 +=1
roger =(div1+div2)-compteur
mm = (b-a)+1
print(mm-roger)


Measured memory_bytes: 9000
#include <iostream>
#include <stack>

using namespace std;

int main()
{
    int n;
    stack<int> s;
    while (cin >> n) {
        if (n == 0) {
            cout << s.top() << endl;
            s.pop();
        } else {
            s.push(n);
        }
    }

    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "random"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))

const int N=333;

int m,n,k,it=1,mi;
int a[N][N],ans[N][N],vis[N][N];
vector<int> pos[N];


main(){
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    m=in,n=in,k=in;
    int tot=0;
    forinc(i,1,m) forinc(j,1,n){
        char ch=getchar(); while(ch!='.' && ch!='#') ch=getchar();
        a[i][j]=ch=='#';
        if(a[i][j]) pos[i].pb(j);
    }
    forinc(i,1,m){
        if(pos[i].size()) mi=i; pos[i].pb(n+1);
        int j=1;
        forinc(t,1,pos[i].size()-1){
            while(j<pos[i][t]){
                ans[i][j]=it;
                j++;
            }
            it++;
        }
    }
    forinc(i,mi+1,m){
        forinc(j,1,n) if(!ans[i][j]) ans[i][j]=ans[i-1][j];
    }
    fordec(i,mi-1,1){
        forinc(j,1,n) if(!ans[i][j]) ans[i][j]=ans[i+1][j];
    }
    forinc(i,1,m){
        forinc(j,1,n) cout<<ans[i][j]<<" ";
        cout<<"\n";
    }
}


Measured memory_bytes: 3584
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
flg = 1
if a > b:
    flg = -1

a = a+v*t*flg
b = b+w*t*flg

if flg == 1:
    if a >= b:
        print('YES')
    else:
        print('NO')
else:
    if a <= b:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 9200
#include <iostream>
#include <queue>
#define P pair<int,int>
using namespace std;
int main()
{
  P jump[] = { P(-1,-2), P(0,-2), P(1,-2), P(-2,-1), P(2,-1), P(-2,0),
	       P(2,0), P(-2,1), P(2,1), P(-1,2), P(0,2), P(1,2) };
  P area[] = { P(-1,-1), P(0,-1), P(1,-1), P(-1,0), P(0,0),
	       P(1,0), P(-1,1), P(0,1), P(1,1) };
  int j = sizeof(jump) / sizeof(jump[0]);
  int a = sizeof(area) / sizeof(area[0]);
  int x,y;
  while(cin >> x >> y,x || y){
    queue< pair<int, P > > q;
    q.push( pair<int,P >(0, P(x,y)) );
    int n;
    cin >> n;
    vector< P > v(n);
    for(int i=0; i<n; i++){
      cin >> x >> y;
      v[i] = P(x,y);
    }
    bool f = true;
    while(!q.empty()){
      pair<int, P > r = q.front(); q.pop();
      P pyon = r.second;
      P show = v[r.first];
      for(int x=0; x<j && f; x++){
	for(int y=0; y<a && f;y++){
	  if(pyon.first + jump[x].first == show.first + area[y].first &&
	     pyon.second + jump[x].second == show.second + area[y].second){
	    if(r.first+1 >= n) f = false; 
	    q.push( pair<int,P>(r.first+1,
		    P(pyon.first+jump[x].first,pyon.second+jump[x].second)));
	  }
	}
      }
    }
    if(f) cout << "NA" << endl;
    else cout << "OK" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
N = int(input())
list = list(map(int,input().split()))
diff = [list[i]-(i+1) for i in range(N)]
diff.sort()

m = diff[len(diff)//2]
ans = 0

for i,l in enumerate(list):
    ans += abs(list[i]-(i+1+m))

print(ans)

Measured memory_bytes: 25196
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	final int LEN = 100000;

	void doIt() {
		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int left = 0, mid = a[0] / 2, right = a[0];
		while(true) {
			List<Integer> li = new ArrayList<>();
			int[] _a = a.clone();
			_a[0] -= mid;
			_a[n - 1] -= mid;
			li.add(mid);
			for(int j = 0; j < n - 1; j++) {
				int num = _a[j];
				_a[j] -= num;
				_a[j + 1] -= num;
				li.add(num);
			}
			//System.out.println(Arrays.toString(_a));
			if(_a[n - 1] == 0) {
				for(int i : li) {
					System.out.print(i * 2 + " ");
				}
				System.out.println();
				return;
			}
			else if(_a[n - 1] < 0) {
				right = mid - 1;
				mid = (right + left) / 2;
			}
			else {
				left = mid + 1;
				mid = (right + left) / 2;
			}
		}
		
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 92408
#include <stdio.h>
int main()
{
    int n,sum=0,s[100005];
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&s[i]);
        while(s[i]%2==0)
        {
            s[i]=s[i]/2;
            sum++;
        }
    }
    printf("%d\n",sum);
    return 0;
}



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

def fctr1(n): 
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f

import math

if n == 1:
    print(0)
else:
    l = fctr1(n)
    ans = 0
    for i in l:
        ans += math.floor((-1+math.sqrt(1+8*i[1]))/2)
    print(ans)

Measured memory_bytes: 63540
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MAX_N = 1e5;
const int MOD = 1e9 + 7;

main() {
  bool error;
  int N, A[MAX_N], ans;
  cin >> N;
  rep(i, N) cin >> A[i];
  sort(A, A + N);
  error = false;
  for (int i = (A[0] == 0 ? 1 : 0); i < N; i += 2) {
    if (A[i] != A[i + 1]) error = true;
  }
  if (error) {
    ans = 0;
  } else {
    ans = 1;
    rep(i, N / 2) {
      ans = (ans * 2) % MOD;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

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

  cout << fixed << setprecision(10) 
  << (double)((n+1)/2)/n << endl;
}


Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
	int N, X;
	cin >> N >> X;
	vector<int> L(N);
	for (int i = 0; i < N; i++) cin >> L[i];
	int D = 0, count = 1;
	for (int i = 0; i < N; i++) {
		D += L[i];
		if (D <= X) count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

struct MyStruct
{
	int list[13];
};



signed main() {
	int i, j, k, n, m, sum = 0, cnt = 0;
	string s, s1, s2;
	bool flag = false;
	vector<vector<int>>list(1005, vector<int>(1005, 0));
	vector<int>list2;
	vector<int>list3(10005, 0);
	int a, b;
	

	cin >> n >> m;


	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			cin >> list[i][j];
		}
	}





	for (i = 0; i < n; i++) {
		int sum = 0;

		for (j = 0; j < m; j++) {
			sum += list[i][j];
		}
		list[i][m] = sum;
	}



	for (i = 0; i < m; i++) {
		int sum = 0;

		for (j = 0; j < n; j++) {
			sum += list[j][i];
		}
		list[n][i] = sum;
	}



	for (i = 0; i <= n; i++) {
		for (j = 0; j <= m; j++) {

			if (!(i == n && j == m)) {
				cout << list[i][j];
			}

			if (i == n && j == m) {
				int sum = 0;
				for (k = 0; k < m; k++) {
					sum += list[i][k];
				}
				cout << sum ;

			}
			else if (j != m) {
				cout << " ";
			}
		}
		cout << endl;
	}





	getchar();
	getchar();
	return 0;
}


Measured memory_bytes: 6620
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner yomi = new Scanner(System.in);
        int n = yomi.nextInt();
        int n2=0;
        for (int i=1;i<=n;i++){
            n2=n2+i;
        }
        System.out.println(n2);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    double s = max(min((h-y)*w, h*w-(h-y)*w), min((w-x)*h, h*w-(w-x)*h));
    int e=0;
    if(2*x==w && 2*y==h) e++;
    printf("%.10f %d\n",w*h/2.0,e);
    return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    int A,B,C,X,Y;  cin>>A>>B>>C>>X>>Y;
    int maisu=X+Y;
    int ans=0;
    if(2*C<A+B){
        ans=2*C*min(X,Y);
    }
    else{
        ans=(A+B)*min(X,Y);
    }
    if(X-Y>0){//Xのが大きい
        ans+=min(A,2*C)*(X-Y);
    }
    else {
        ans+=min(B,2*C)*(Y-X);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    
    int x,y;
    
    while (1)
    {
        scanf("%d%d",&x,&y);
        if (x==0&&y==0)
            break;
        if (x>y)
        {
            printf("%d %d\n",y,x);
        }
        else
        {
            printf("%d %d\n",x,y);
        }
    }
    
    return 0;
}

Measured memory_bytes: 600
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    N = int(input())

    cnt = 0
    ans = "No"
    for i in range(N):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        
        if cnt >= 3:
            ans = "Yes"  
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 77528
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

int N;
vector<int> Graph[100030];
int dist[100030];
int dist2[100030];

void BFS() {
  queue<P> que;
  bool used[100030];
  for (int i = 0; i < 100030; i++) {
    used[i] = false;
  }
  que.push(make_pair(0,0));
  used[0] = true;
  dist[0] = 0;
  while (!que.empty()) {
    P p = que.front();
    que.pop();
    for (int i = 0; i < (int)Graph[p.S].size(); i++) {
      if (!used[Graph[p.S][i]]) {
        dist[Graph[p.S][i]] = p.F + 1; 
        used[Graph[p.S][i]] = true;
        que.push(make_pair(p.F+1,Graph[p.S][i]));
      }
    } 
  }

  queue<P> que2;
  bool used2[100030];
  for (int i = 0; i < 100030; i++) {
    used2[i] = false;
  }
  que2.push(make_pair(0,N-1));
  used2[N-1] = true;
  dist2[N-1] = 0;
  while (!que2.empty()) {
    P p = que2.front();
    que2.pop();
    for (int i = 0; i < (int)Graph[p.S].size(); i++) {
      if (!used2[Graph[p.S][i]]) {
        dist2[Graph[p.S][i]] = p.F + 1; 
        used2[Graph[p.S][i]] = true;
        que2.push(make_pair(p.F+1,Graph[p.S][i]));
      }
    } 
  }
}

int main() {
  cin >> N;
  for (int i = 0; i < N-1; i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    Graph[a].push_back(b);
    Graph[b].push_back(a);
  }

  BFS();
  
  int fe = 0;
  int sn = 0;
  int samecnt = 0;

  for (int i = 0; i < N; i++) {
    if (dist[i] <= dist2[i]) {
      fe++;
    } else if (dist[i] > dist2[i]) {
      sn++;
    }
  }

  if (fe > sn) {
    cout << "Fennec" << endl;
  } else {
    cout << "Snuke" << endl;
  }
  return 0;
}


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

int main(void) {
	int a;
	int num=0;
	string s;
	cin >> a;
	cin >> s;

	string alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

	if (a == 0) {
		cout << s << endl;
		exit(0);
	}

	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < alp.size(); j++) {
			if (s[i] == alp[j]) {
				num = j;
				break;
			}
		}
		if (num + a < 26) {
			cout << alp[num + a];
		}
		else {
			cout << alp[num + a - 26];
		}
	}
	cout << endl;

}

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

int main(int argc, char *argv[]){

  char words[101];

  scanf("%s",words);

  int num = 0;
  int length = strlen(words);

  for(int i=0; i<length; i++)
    if(words[i] != words[length-1-i])
      num++;

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

  return 0;
}

  


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

int main() {
    int c[3][3];
    rep(i, 3) rep(j, 3) cin >> c[i][j];

    rep(a1, 101) rep(a2, 101) rep(a3, 101) {
        bool ok = true;
        rep(j, 3) if (!(c[0][j] - a1 == c[1][j] - a2 &&
                        c[1][j] - a2 == c[2][j] - a3)) ok = false;
        if (ok) {
            cout << "Yes" << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define N 10000

int main(){
  int n,num[N],i,j,count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++)scanf("%d",&num[i]);

  for(i=0;i<n;i++){
    if(num[i]==2)continue;
    if(num[i]%2==0){
      count+=1;
      continue;
    }
    for(j=3;j<=sqrt(num[i]);j+=2){
      if(num[i]%j==0){
	count++;
	break;
      }
    }
  }
  printf("%d\n",n-count);
  
  return 0;
}

Measured memory_bytes: 632
n = int(input())
b = list(map(int, input().split()))
ln = []
ln2 =  []
for i in b:
    if i % 4 == 0:
        ln.append(i)
    if i % 2 == 0 and i % 4 != 0:
        ln2.append(i)
if n % 2 == 0:
    if len(ln) >= n//2:
        print('Yes')
    else:
            if n - len(ln) * 2 == len(ln2):
                print('Yes')
 
            else:
                    print('No')
if n % 2 == 1:
    if len(ln) >= (n - 1)//2:
        print('Yes')
    else:
        if n - len(ln) * 2 == len(ln2):
            print('Yes')
        else:
            if n == 3 and len(ln) == 1:
                print('Yes')
            else:
                print('No')

Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;

int main() {
    int n;
    double x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> n;
    while(n--) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        cout << (abs((x2-x1)*(y4-y3) - (x4-x3)*(y2-y1)) < eps ? "YES" : "NO") << endl;
    }
    return 0;
}


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

int main(){
    int N;
    string S;
    cin >> N >> S;
    if(N%2) cout << "No" << endl;
    else{
        string t1 = S.substr(0,N/2),t2 = S.substr(N/2,N/2);
        cout << (t1==t2? "Yes":"No") << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int A[1000000 + 10], inv[1000000 + 10];
ll mod = 1e9 + 7;
ll qpow(ll a, ll b){
	ll res = 1;
	while(b){
		if(b & 1){
			res = res * a % mod;
		}
		b >>= 1;
		a = a * a % mod;
	}
	return res;
}
ll c(int a, int b){
	if(a < b) return 0;
	return (ll)A[a] * inv[b] % mod * inv[a - b] % mod;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n, m;
	cin >> n >> m;
	A[0] = 1;
	inv[0] = 1;
	rep(i, 1, 1000000 + 1){
		A[i] = (ll)A[i - 1] * i % mod;
		inv[i] = (ll)inv[i - 1] * qpow(i, mod - 2) % mod;
	}
	ll ans = c(m, n) * c(m, n) % mod * A[n] % mod * A[n] % mod;
//	cout << ans << endl;
	rep(i, 1, n + 1){
		if(i % 2 == 1) ans = (ans - c(n, i) * c(m, i) % mod * A[i] % mod * A[n - i] % mod* A[n - i] % mod * c(m - i, n - i) % mod * c(m - i, n - i) % mod + mod) % mod;
		else ans = (ans + c(n, i) * c(m, i) % mod * A[i] % mod * A[n - i] % mod* A[n - i] % mod * c(m - i, n - i) % mod * c(m - i, n - i) % mod) % mod; 
		//cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

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

ll n;
vector<string> s;
vector<ll> v(3);
bool ans = false;
vector<char> route;

void dfs(ll d = 0) {
    if (*min_element(all(v)) < 0) return;
    if (ans) return;
    if (d == n) {
        ans = true;
        return;
    }
    {
        v[s[d][0] - 'A']++;
        v[s[d][1] - 'A']--;
        route.push_back(s[d][0]);
        dfs(d + 1);
        if (!ans) route.pop_back();
        v[s[d][0] - 'A']--;
        v[s[d][1] - 'A']++;
    }
    if (!ans) {
        v[s[d][0] - 'A']--;
        v[s[d][1] - 'A']++;
        route.push_back(s[d][1]);
        dfs(d + 1);
        if (!ans) route.pop_back();
        v[s[d][0] - 'A']++;
        v[s[d][1] - 'A']--;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin >> n;
    rep(i, 3) cin >> v[i];
    s.resize(n);
    rep(i, n) cin >> s[i];
    dfs();
    if (ans) {
        cout << "Yes" << endl;
        rep(i, sz(route)) cout << route[i] << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 9704
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	if (n > k * 2) {

	}
	return fac[n] / (fac[k] * fac[n - k]);
}

ll dp[201010][2];
ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char c[10][10];
bool flag[10][10];
bool flag2[10][10];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	ll ans = 0;
	rep(i, n) {
		cin >> a[i];
		if (i % 2 == 0 && a[i] % 2 == 1)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define maxn 200005
#define pii pair<int,int>
#define mk make_pair
using namespace std;

int n;

struct node {int x,y,id;}poi[maxn];

bool cmp1(node i,node j)
{
	return i.x<j.x;
}

int ans[maxn],siz[maxn];

set< pii >	sets;
set< pii >::iterator it;

int fa[maxn];

int find(int x)
{
	return fa[x]==x ? x:fa[x]=find(fa[x]);
}

signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>poi[i].x>>poi[i].y,poi[i].id=fa[i]=i,siz[i]=1;
	sort(poi+1,poi+n+1,cmp1);
	sets.insert(mk(9999999,9999999));
	for(int i=1;i<=n;i++)
	{
		it=sets.begin();
		if((*it).first<poi[i].y)
		{
			while((*it).first<poi[i].y)
			{
				int fx=find(poi[i].id),fy=find((*it).second);
				if(fx!=fy)
				{
					fa[fx]=fy;
					siz[fy]+=siz[fx];
				}
				it++;
			}
		}
		else sets.insert(mk(poi[i].y,poi[i].id));
	}
	for(int i=1;i<=n;i++)
		cout<<siz[find(i)]<<endl;
	
		
} 

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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n, m;
  cin >> n >> m;
  int l = 1, r = n;
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    if (l < x) l = x;
    if (y < r) r = y;
  }

  if (r - l < 0)
    cout << 0 << endl;
  else
    cout << r - l + 1 << endl;
  return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len, stones;
    cin >> len >> stones;
    vector<bool> dp(stones + 1, false);
    vector<int> arr(len);
    for(int i = 0; i < len; i++) {
        cin >> arr[i];
    }
    for(int i = 0; i <= stones; i++) {
        bool c;
        if(dp[i] == false) c = true;
        else continue;
        for(int j = 0; j < len; j++)
            if(i + arr[j] <= stones && !dp[i + arr[j]])
                dp[i + arr[j]] = c;
        //cout << dp << endl;
    }
    if(dp[stones]) cout << "First";
    else cout << "Second";
}



Measured memory_bytes: 3620
N,L = map(int,input().split())
if L > 0:
    k = N*(L-1) + (N * (N+1))//2 - L
    print(k)
elif L == 0:
    print( (N-1) * N //2)
else: 
    if L+N-1 >=0:
        k = N*(L-1) + (N * (N+1))//2
        print(k)
    else:
        k = N*(L-1) + (N * (N+1))//2 - (L+N-1)
        print(k)

Measured memory_bytes: 3064
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	map<int, int> mp;
	for (int i = 0; i < N; i++) {
		int d;
		cin >> d;
		mp[d]++;
	}

	if (any_of(mp.begin(), mp.end(), [&](auto &m) { return m.second > 2; })) cout << 0 << "\n";
	else {

		vector<int> D{ 0 }, one;
		for (const auto &e : mp) {
			if (e.second == 2) {
				D.emplace_back(e.first);
				D.emplace_back(24 - e.first);
			}
			else one.emplace_back(e.first);
		}

		int ans = 0;
		int bmax = (int)one.size();
		for (int bit = 0; bit < (1 << bmax); bit++) {

			vector<int> tmp = D;
			for (int i = 0; i < bmax; i++) {
				if ((1 << i) & bit) tmp.emplace_back(one[i]);
				else tmp.emplace_back(24 - one[i]);
			}

			int s = INF;
			DMP(tmp);
			for (int i = 0; i <= N; i++) {
				for (int j = i + 1; j <= N; j++) {
					chmin(s, min(abs(tmp[i] - tmp[j]), abs(24 - abs(tmp[i] - tmp[j]))));
				}
			}
			chmax(ans, s);
		}

		cout << ans << "\n";
	}



	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            a.add(ni()-(i+1));
        }
        Collections.sort(a);
        int bestb = a.get((N-1)/2);
        
        long ans = 0;
        for (int i = 0; i < N; i++) {
            ans += Math.abs(a.get(i) - bestb);
        }
        out.println(ans);
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);
    int upperBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new UpperBoundComparator<Long>());
        return ~i;
    }
    class UpperBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) > 0) ? 1 : -1;
        }
    }
    int lowerBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new LowerBoundComparator<Long>());
        return ~i;
    }
    class LowerBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) >= 0) ? 1 : -1;
        }
    }
    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

typedef long long ll;
using namespace std;

int pot (ll q, ll w){
	ll qw = q;
	q = 1;
	for (int i = 0; i<w; i++)
		q*= qw;
	return q;
}

ll n,a[102],rj,brp;

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

cin >> n;

for (int i = 0; i<n; i++){
	cin >> a[i];
	if (a[i] % 2 == 0){
		brp++;
		if (a[i] % 3 == 0 || a[i] % 5 == 0)
			rj++;
	}
}

if (rj != brp)
	cout << "DENIED";
else 
	cout << "APPROVED";


return 0;
}



Measured memory_bytes: 256
def pay(n, a, b, c, d):
    ops = ((2, a), (3, b), (5, c))
    dp = {0:0, 1:d, 2:d + min(a, d)}
    
    def helper(n):
        if n in dp:
            return dp[n]
        
        m = min(op[1] + min(helper(n//op[0]) + (n-n//op[0]*op[0])*d, 
                helper(-(-n//op[0])) + ((-(-n//op[0]))*op[0]-n)*d) for op in ops)
        m = min(n*d, m)
        dp[n] = m
        return m
        
    return helper(n)

      
t = int(input())
for i in range(t):
    n, a, b, c, d = map(int, input().split())
    print(pay(n, a, b, c, d))
        

Measured memory_bytes: 89788
#include<iostream>
using namespace std;
bool check(string main,string test,int start){
    string result="";
    if(start+test.size()>main.size())
    return false;
    for(int i=start;i<start+test.size();i++){
        result+=main[i];
    }
    if(result==test)
    return true;
    return false;
}
int main(){
    string s;
    cin>>s;
    int start=0;
    bool no=0;
    while(start!=s.size()){
        if(check(s,"dreamer",start)){
            start+=7;
            if(start!=s.size()&&s[start]=='a'){
                start-=2;
            }
            continue;
        }
        else
        if(check(s,"dream",start)){
            start+=5;
            continue;
        }
        else
        if(check(s,"eraser",start)){
            start+=6;
            continue;
        }
        else
        if(check(s,"erase",start)){
            start+=5;
            continue;
        }
        else{
            no=1;
            break;
        }
    }
    if(!no){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
}

Measured memory_bytes: 3764
#include <cstdio>           // printf(), scanf()
#include <algorithm>        // lower_bound()

using namespace std;
static const int MAX_N = 100000;

int A[MAX_N + 1];
int L[MAX_N];
int n;

int
lis()
{
	L[0] = A[0];
	int length = 1;
	for (int i = 1; i < n; ++i)
	{
		if (L[length - 1] < A[i])
			L[length++] = A[i];
		else
			*lower_bound(L, L + length, A[i]) = A[i];
	}

	return length;
}

int
main(int argc, char** argv)
{
	int i;

	scanf("%d", &n);
	for (i = 0; i < n; ++i)
		scanf("%d", &A[i]);

	printf("%d\n", lis());
	return 0;
}

Measured memory_bytes: 3448
#include <cstdio>  
#include <algorithm>  
using namespace std;  
#define mmax 200000+10  
int a[mmax],b[mmax],x[30][mmax],y[mmax];  
int fun(int k,int n,int v){//二分  
    int l=1,r=n;  
    int h=(l+r)/2;  
    while(l<=r){  
        if(v<=x[k][h]&&x[k][h-1]<v)  
            return h;  
        else if(v<=x[k][h])  
            r=h-1;  
        else if(v>x[k][h])  
            l=h+1;  
        h=(l+r)/2;  
    }  
    return n+1;  
}  
int main() {  
    int n;  
    scanf("%d",&n);  
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);  
    for(int i=1;i<=n;i++) scanf("%d",&b[i]);  
    for(int k=0;k<28;k++){  
        if(k==0)  
            for(int i=1;i<=n;i++) x[k][i]=a[i]&1;//2ˆ0次幂,a[i]最后一位的拆分  
        else  
            for(int i=1;i<=n;i++) x[k][i]=x[k-1][i]^((1<<k)&a[i]);// 取出其a[i]后k位  
    }  
    long long ans=0;  
    for(int k=0;k<28;k++) sort(x[k]+1, x[k]+1+n);  
    for(int k=1;k<=28;k++){  
        for(int i=1;i<=n;i++){  
            y[i]^=(1<<(k-1))&b[i];//取出a[i]后k位  
            int t=fun(k-1,n,(1<<k)-y[i]);//二分查找会产生进位项的位子,下的low_bound也对  
            //int t=int(lower_bound(x[k-1]+1, x[k-1]+1+n, (1<<k)-y[i])-x[k-1]);  
            ans^=(((n-t+1)%2)<<k);//产生进位的异或和  
        }  
    }  
    int q,w,e,r;  
    for(int k=0;k<28;k++){  
        q=w=e=r=0;  
        for(int i=1;i<=n;i++){//算a[i]里的第k位的奇偶数量 0,1  
            if((1<<k)&a[i]) q++;  
            else w++;  
        }  
        for(int i=1;i<=n;i++){//算b[i]里的第k位的奇偶数量 0,1  
            if((1<<k)&b[i]) e++;  
            else r++;  
        }  
        ans^=(((((long long)1)*q*r%2+((long long)1)*w*e%2)%2)<<k);///产生不进位的异或和  
    }  
    printf("%lld\n",ans);  
    return 0;  
}  

Measured memory_bytes: 25984
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
const int MAX = 1000005;
const ll MOD = 1000000007;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main(){
  int n,m; 
  cin >> n >> m;
  int k[n];
  int a[n][40];
  rep(i,n){
    cin >> k[i];
    rep(j,k[i]) cin >> a[i][j];
  }
  int ans = 0;
  for(int p=0;p<=30;p++){
    int res = 0;
    rep(i,n){
      bool ok = false;
      rep(j,k[i]){
        if(a[i][j] == p) ok = true;
      }
      if(ok) res++;
    }
    if(res == n) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int i = 1;
	int x;
	while (1) {
		scanf("%d", &x);
		if (x == 0) {
			break;
		}
		else {
			printf("Case %d: %d\n", i, x);
			++i;
		}
	}
	return 0;
}

Measured memory_bytes: 2556
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strArray = Console.ReadLine().Split(' ');
            int maxInd = 0;
            int maxVal = 0;
            for(int i = 0; i < strArray.Length; i++)
            {
                if (int.Parse(strArray[i]) > maxVal)
                {
                    maxVal = int.Parse(strArray[i]);
                    maxInd = i;
                }
            }
            int printVal = 0;
            for (int i = 0; i< strArray.Length; i++)
            {
                if (i == maxInd)
                {
                    printVal += maxVal * 10;
                }
                else
                {
                    printVal += int.Parse(strArray[i]);
                }
            }
            Console.WriteLine(printVal);
        }
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  for(ll h=1;h<=3500;h++){
    for(ll n=1;n<=3500;n++){
      ll num, den;
      num = N * h * n;
      den = 4 * h * n - N * n - N * h;
      if(den > 0 && num % den == 0){
        cout << h << " " << n << " " << num / den << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (){
 int a,b,c,d,e,k;
 cin >> a;
 cin >> b;
 cin >> c;
 cin >> d;
 cin >> e;
 cin >> k;
 if (e - a <= k)
   cout << "Yay!" << endl;
  else 
    cout << ":(" << endl;

 
  return 0;
  
}

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

def devide(array, count):
	dividable = True
	for i in array:
		if ((i % 2) != 0):
			dividable = False
	if (dividable):
		for index, value in enumerate(array):
			array[index] = value / 2
		count += 1
		return devide(array, count)
	else:
		return array, count

devided, count = devide(A, 0)
print(count)

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

int main() {
	// your code goes here
	int n, m, sum=0;
	cin >> n >> m;
	vector<int> v(n);
	for(int i=0; i<n; i++){
		cin >> v[i];
		sum+=v[i];
	}
	sort(v.begin(), v.end());
	sum=(int)ceil((double)sum/(4*m));
	int cnt=m;
	for(int i=n-1; i>=0 && cnt>0 && v[i]>=sum; i--, cnt--);
	if(cnt==0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};
use std::cmp::max;

fn cup(nums: &mut Vec<i32>, idx: usize) {
    if idx == nums.len() {
        nums.push(1);
    } else if nums[idx] == 9 || (idx < nums.len() - 1 && nums[idx] - nums[idx + 1] == 1) {
        cup(nums, idx + 1);
        nums[idx] = max(nums[idx + 1] - 1, 0);
    } else {
        nums[idx] += 1;
    }
}

#[fastout]
fn main() {
    input! {in_k: usize};

    if in_k <= 10 {
        println!("{}", in_k);
        return;
    }

    let mut nums = vec![0, 1];

    for _ in 10..in_k {
        if nums[0] == 9 || nums[0] - nums[1] == 1 {
            cup(&mut nums, 0);
        } else {
            nums[0] += 1;
        }
    }

    let ret: Vec<_> = nums.iter().rev().map(|x| x.to_string()).collect();
    println!("{}", ret.join(""));
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

bool Solve() {
  int w, h, n;
  cin >> w >> h >> n;

  auto is_on_border_fn = [&](int x, int y) -> bool {
    return x == 0 || x == w || y == 0 || y == h;
  };

  auto encode_fn = [&](int x, int y) -> int {
    if (x == 0) return y;
    else if (y == h) return h + x;
    else if (x == w) return h + w + (h - y);
    else if (y == 0) return h + w + h + (w - x);
    exit(1);
  };
  
  vector<pair<int, int>> ps;
  for (int i = 0; i < n; i++) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if (is_on_border_fn(x1, y1) && is_on_border_fn(x2, y2)) {
      ps.push_back(make_pair(encode_fn(x1, y1), i));
      ps.push_back(make_pair(encode_fn(x2, y2), i));
    }
  }
  if (ps.empty()) return true;

  sort(ps.begin(), ps.end());
  vector<int> cs(n);

  stack<int> s;
  for (const auto& p : ps) {
    if (DEBUG) cout << p.first << " " << p.second << endl;
    int id = p.second;
    if (cs[id] == 0) {
      s.push(id);
      cs[id]++;
    } else {
      if (s.empty()) return false;
      if (s.top() != id) return false;
      s.pop();
      cs[id]++;
    }
  }
  return true;
}

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

  bool ans = Solve();
  cout << (ans ? "YES" : "NO") << endl;
}

Measured memory_bytes: 2420