akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#include <set>
#include <string>
#include <stdbool.h>
#include<ctime>

#include <cstring>

#define pb push_back


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.12lf ",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define MOD  ( int)(1e9 + 7)
#define MAXN (ll) ((1e5+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;







typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int, int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph;
ll res = 0;
ll n, m,d;
vector <string> g;
string s;
bool vis[2005][2005];

signed main(){
	cin >> n >> m >> d;
	n = abs(n);
	if (m  > n/d){
		m -= n / d;
		
		if (m & 1){
			
			res = d - n % d;
		}
		else{
			res = n%d;
		}
	}
	
	else{
		res = n - m * d;
	}

	cout << res; 

	getchar(); getchar(); getchar(); getchar();



	return 0;



}







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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = acos(-1.0);
const ll LINF = (ll)1e18 + 5;
const int INF = (int)1e9 + 5;

template<class T>
T sqr(T x) { return x * x; }

template<class T>
T abs(T x) { return x < 0 ? -x : x; }

template<class T>
ll round(T x) { return x < 0 ? x - 0.5 : x + 0.5; }

template<class T>
bool chmin(T & x, const T & y) {
	if (y < x) {
		x = y;
		return true;
	}
	return false;
}

template<class T>
bool chmax(T & x, const T & y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}


template<class P, class Q>
ostream & operator <<(ostream & os, const pair<P, Q> & p) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template<class T>
ostream & operator <<(ostream & os, const vector<T> & v) {
	bool was = false;
	os << "{";
	for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); it++) {
		if (was) {
			os << ", ";
		}
		else {
			was = true;
		}
		os << *it;
	}
	os << "}";
	return os;
}

template<class T>
ostream & operator <<(ostream & os, const set<T> & v) {
	bool was = false;
	os << "{";
	for (typename set<T>::const_iterator it = v.begin(); it != v.end(); it++) {
		if (was) {
			os << ", ";
		}
		else {
			was = true;
		}
		os << *it;
	}
	os << "}";
	return os;
}

template<class T>
ostream & operator <<(ostream & os, const multiset<T> & v) {
	bool was = false;
	os << "{";
	for (typename multiset<T>::const_iterator it = v.begin(); it != v.end(); it++) {
		if (was) {
			os << ", ";
		}
		else {
			was = true;
		}
		os << *it;
	}
	os << "}";
	return os;
}

template<class P, class Q>
ostream & operator <<(ostream & os, const map<P, Q> & v) {
	bool was = false;
	os << "{";
	for (typename map<P, Q>::const_iterator it = v.begin(); it != v.end(); it++) {
		if (was) {
			os << ", ";
		}
		else {
			was = true;
		}
		os << *it;
	}
	os << "}";
	return os;
}

#define all(x) (x).begin(), (x).end()

string nextToken() {
	static char str[(int)1e6 + 5];
	scanf("%s", str);
	return str;
}

template<class T>
T nextInt() {
	ll x = 0;
	bool p = false;
	char c;
	do {
		c = getchar();
	} while (c <= 32);
	if (c == '-') {
		p = true;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - '0';
		c = getchar();
	}
	return (p ? -x : x);
}

bool isPrime(int x) {
	if (x == 2) return true;
	if (x == 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

void solve() {
	int n;
	scanf("%d", &n);
	vector<ll> a(n), b(n);
	for (int i = 0; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		a[i] = x;
		b[i] = y;
	}
	ll added = 0;
	ll res = 0;
	for (int i = n - 1; i >= 0; i--) {
		a[i] += added;
		ll need;
		if (false) {
			need = b[i] - a[i];
		} else {
			need = b[i] - (a[i] % b[i]);
			need %= b[i];
		}
		a[i] += need;
		added += need;
		res += need;
	}
	cout << res << endl;
}

int main(int argc, char * argv[]) {
	srand(time(0));

#ifdef LOCAL
	//gen();
	freopen("input.txt", "r", stdin);
#else
	
#endif

	int t = 1;
	//cin >> t;
	for (int tc = 1; tc <= t; tc++) {
		solve();
	}

}

Measured memory_bytes: 1792
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    s,t = LS()
    ans = ""
    for x,y in zip(list(s),list(t)):
        ans += x+y
    print(ans)
main()            


Measured memory_bytes: 74452
#include <stdio.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];
int color[MAX], d[MAX], f[MAX], time = 0;
/*再帰、for 文に注意。3 から 2 に戻るときに color[2] に BLACK が代入される前に、まだ終っていない for 文に注目すると、v が 4 のときに 17行目が成り立つから、再び再帰。*/
void dfs_visit(int u){
  int v;
  
  color[u] = GRAY;
  d[u] = ++time;
  for(v = 0; v < n; v++){  
    if(M[u][v] == 0) continue;
    if(color[v] == WHITE){
      dfs_visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++time;
}
void dfs(){
  int u;

  for(u = 0; u < n; u++) color[u] = WHITE;
  for(u = 0; u < n; u++){
    if(color[u] == WHITE) dfs_visit(u);
  }
  for(u = 0; u < n; u++) printf("%d %d %d\n", u + 1, d[u], f[u]);
}


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

  scanf("%d", &n);

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

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



Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static String s;
	public static void main(final String[] args) {
		s = sc.next();
		int N = s.length();
		if (s.charAt(0)==s.charAt(N-1)) {
			if (N%2==0) System.out.println("First");
			else System.out.println("Second");
		} else {
			if (N%2==0) System.out.println("Second");
			else System.out.println("First");
		}
		sc.close();
	}
}


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

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
const int N=2005*2;
int n,a[N],dp[N][N],tot[N][N],p[N];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n*2;i++){
		char s[2];
		int v;
		scanf("%s%d",s,&v);
		if (s[0]=='W')
			a[i]=v;
		else
			a[i]=n+v;
		p[a[i]]=i;
	}
	for (int i=n*2;i>=1;i--){
		for (int j=1;j<=n*2+1;j++)
			tot[i][j]=tot[i+1][j];
		if (a[i]<=n)
			for (int j=a[i];j<=n;j++)
				tot[i][j]++;
		else
			for (int j=a[i];j<=n*2;j++)
				tot[i][j+1]++;
	}
	memset(dp,63,sizeof dp);
	dp[0][0]=0;
	for (int i=1;i<=n*2;i++)
		for (int j=0;j<=i;j++){
			int w=j,b=i-j+n;
			if (w>n||b>n+n)
				continue;
			if (w>0)
				dp[i][j]=min(dp[i][j],dp[i-1][j-1]+p[w]-i+tot[p[w]][w-1]+tot[p[w]][b+1]);
			if (b>n)
				dp[i][j]=min(dp[i][j],dp[i-1][j]+p[b]-i+tot[p[b]][b-1+1]+tot[p[b]][w]);
		}
/*	for (int i=0;i<=n*2;i++,puts(""))
		for (int j=0;j<=i;j++)
			printf("%10d ",dp[i][j]);*/
	printf("%d",dp[n*2][n]);
	return 0;
}

Measured memory_bytes: 125952
def isPrime(n)
  if n < 2 then
    return false
  elsif n == 2 then
    return true
  end

  if n % 2 == 0 then
    return false
  end

  3.step(n, 2){|i|
    if i > n/i then
      return true
    elsif (n % i) == 0 then
      return false
    end
  }

end

### main ###
length = STDIN.gets.to_s.to_i

count = 0
for i in 1..length do
  if isPrime(STDIN.gets.to_s.to_i) then
    count = count + 1
  end
end

p count

Measured memory_bytes: 8752
#include <iostream>


using namespace std;


int main()
{
	string s;
	cin >> s;
	int count = 0;
	bool found = false;
	for (auto c: s) {
		if(c == 'R' && !found) {
			found = true;
			count = 1;
		} else if(c == 'R' && found) {
			count++;
		} else if (c == 'S') {
			found = false;
		}
	} 	
	cout << count;
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.1415926535897932384626;
long long int mod = 998244353;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum,ans;
ll a,b,c,d,e,f,g,h,w,v;
ll x[800005],y[800005],z[900005];
ll dp[800005];
ll xa,ya,xb,yb;
ll xl,xs,yl,ys;


int main(){	
	cin>>xa>>ya>>xb>>yb;
	d = 1;
	if(xb-xa<0)d *= -1;
	if(yb-ya<0)d *= -1;
	
	xl = max(xa,xb);
	xs = min(xa,xb);
	yl = max(ya,yb);
	ys = min(ya,yb);
	double de = min(xl-xs,yl-ys);
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a >> b;
		if(xs <= a && a <= xl && ys <= b && b <= yl){
			x[num] = a;
			y[num] = b;
			if(d<0){
				y[num] = 100000000 - b;
			}
			num ++;
		}
	}
	n = num;
	//p(n);
	for(i=0;i<n;i++){
		z[i] = 1000000000 * x[i] + y[i];
	}	
	sort(z,z+n);
	sort(y,y+n);
	
	//xの順に並び替える
	//並び替えてから最小増加列問題をyについて解く
	for(i=0;i<2*n;i++){
		dp[i] = INF;
	}
	for(i=0;i<n;i++){
		a = z[i] / 1000000000;
		b = z[i] % 1000000000;
		num = lb(y,y+n,b) - lb(y,y+n,-10);
		c = lb(dp,dp+2*n,num) - lb(dp,dp+2*n,-10);
		dp[c] = num;
	}
	
	num = lb(dp,dp+n,INF) - lb(dp,dp+n,-10);
	
	double cc = (double)num;
	//p(cc);
	double aa,bb;
	aa = (double)(xl-xs)*100.000000000000;
	bb = (double)(yl-ys)*100.000000000000;
	if(n>=1 && num>=de+1){
		aa += 5.00000000 * Pi;
	}
	//ps(aa+bb);
	ps(aa+bb-cc*(20.00000000 - 5.00000000 * Pi));


	
	return 0;
}

Measured memory_bytes: 20480
#include<iostream>
#include<stdio.h>
#include<queue>
#include<algorithm>
using namespace std;
int main() {
	long long  n, a, b;
	cin >> n >> a >> b;



	long long ans = (n / (a + b)) * a + min(n % (a + b),a);

	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  long long int a, b, c[200000], i, sum = 0;
  scanf("%lld %lld", &a, &b);

  for ( i = 0; i < b; i++) {
    scanf("%lld", &c[i]);
    sum = sum + c[i];
  }

  if(a - sum <= 0) {
    printf("Yes");
  }
  else {
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 896
#110_C
S=input()
T=input()
R={}
L={}
flg=True
for i in range(len(S)):
    if S[i] in R:
        if R[S[i]]!=T[i]: flg=False
    else:
        R[S[i]]=T[i]
    if T[i] in L:
        if L[T[i]]!=S[i]: flg=False
    else:
        L[T[i]]=S[i]
print('Yes' if flg else 'No')

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	ll n, t;
	cin >> n >> t;
	vector<ll> a;
	for(int i=0; i<n; i++){
		ll tmp;
		cin >> tmp;
		a.pb(tmp);
	}
	
	ll ans = 0;
	for(int i=0; i<n-1; i++){
		if(a[i] + t < a[i+1]){
			ans += t;
		}else{
			ans += (a[i+1] - a[i]);
		}
	}

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


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int a,b;
  cin>>a>>b;
  int outlet =1,ans = 0;
  while(outlet < b) {
    outlet--;
    outlet += a;
    ans++;
  }
  cout<<ans<<"\n";
  return 0;
}
    


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

#define CheckNumber(number, limitLow, limitHigh) (	\
		(number) >= limitLow		&&				\
		(number) <= limitHigh						\
)

typedef struct {
	int** matrix;
	int rowSize;
	int columnSize;
} Matrix;

void InputNumber1(int* number, int limitLow, int limitHigh);
void InputNumber2(int* number1, int* number2, int limitLow, int limitHigh);

void GetMatrix(Matrix* matrix, const int rowSize, const int columnSize);
void MulMatrix(Matrix* newMatrix, Matrix* a, Matrix* b);

void FreeMatrix(Matrix* matrix);

int main(void) {
	int rowSize;
	int columnSize;

	Matrix a;
	Matrix b;
	Matrix res;

	int idr;
	int idc;

	InputNumber2(&rowSize, &columnSize, 1, 100);
	GetMatrix(&a, rowSize, columnSize);
	for (idr = 0; idr < a.rowSize; idr++) {
		for (idc = 0; idc < a.columnSize; idc++) {
			InputNumber1((*(a.matrix + idr) + idc), 0, 1000);
		}
	}

	GetMatrix(&b, columnSize, 1);
	for (idr = 0; idr < b.rowSize; idr++) {
		for (idc = 0; idc < b.columnSize; idc++) {
			InputNumber1((*(b.matrix + idr) + idc), 0, 1000);
		}
	}

	MulMatrix(&res, &a, &b);

	for (idr = 0; idr < res.rowSize; idr++) {
		for (idc = 0; idc < res.columnSize - 1; idc++) {
			printf("%d ", *(*(res.matrix + idr) + idc));
		}
		printf("%d\n", *(*(res.matrix + idr)+ idc));
	}

	FreeMatrix(&a);
	FreeMatrix(&b);
	FreeMatrix(&res);

	return 0;
}

void InputNumber1(int* number, int limitLow, int limitHigh) {
	int tmp1;
	do {
		scanf("%d", &tmp1);
	} while(!CheckNumber(tmp1, limitLow, limitHigh));
	*number = tmp1;
}

void InputNumber2(int* number1, int* number2, int limitLow, int limitHigh) {
	int tmp1;
	int tmp2;
	do {
		scanf("%d %d", &tmp1, &tmp2);
	} while(
			!CheckNumber(tmp1, limitLow, limitHigh) ||
			!CheckNumber(tmp2, limitLow, limitHigh)
			);
	*number1 = tmp1;
	*number2 = tmp2;
}

void GetMatrix(Matrix* matrix, const int rowSize, const int columnSize) {
	int idx;
	int** arr = (int**)malloc(sizeof(int*) * rowSize);
	for (idx = 0; idx < rowSize; idx++) {
		*(arr + idx) = (int*)malloc(sizeof(int) * columnSize);
	}
	matrix->matrix = arr;
	matrix->rowSize = rowSize;
	matrix->columnSize = columnSize;
}

void MulMatrix(Matrix* newMatrix, Matrix* a, Matrix* b) {
	const int newRowSize = a->rowSize;
	const int newColumnSize = b->columnSize;

	const int repeat = (a->columnSize == b->rowSize) * a->columnSize;

	int idr;
	int idc;
	int idrp;

	GetMatrix(newMatrix, newRowSize, newColumnSize);
	for (idr = 0; idr < newRowSize; idr++) {
		for (idc = 0; idc < newColumnSize; idc++) {
			int sum = 0;

			for (idrp = 0; idrp < repeat; idrp++) {
				int aVal = *(*(a->matrix + idr) + idrp);
				int bVal = *(*(b->matrix + idrp) + idc);
				sum += aVal * bVal;
			}
			*(*(newMatrix->matrix + idr) + idc) = sum;
		}
	}
}

void FreeMatrix(Matrix* matrix) {
	int rowSize = matrix->rowSize;

	int idr;

	for (idr = 0; idr < rowSize; idr++) {
		free(*(matrix->matrix + idr));
	}
	free(matrix->matrix);
}


Measured memory_bytes: 2112
use std::str::FromStr;
use std::io::stdin;
use std::collections::HashMap;
use std::cmp::max;

fn main() {
    let n = read::<usize>();
    let mut map: HashMap<String, u64> = HashMap::new();
    let mut mx = 0u64;
    for _ in 0..n {
        let string = read::<String>();
        let val = *map.get_mut(string.as_str()).unwrap_or(&mut 0) + 1;
        mx = max(mx, val);
        map.insert(string, val);
    }
    let mut filtered: Vec<&String> = map.iter().filter(|x| *x.1 == mx).map(|x| x.0).collect();
    filtered.sort();
    for i in filtered {
        println!("{}", i);
    }
}

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

Measured memory_bytes: 20408
import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N, X, T = MI()
    if N % X == 0:
        print((N//X)*T)
    else:
        print(((N//X)+1)*T)
if __name__ == "__main__":
    main()

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


using namespace std;


void security()
{
  string s;
  cin >> s;

  for (int i = 1; i < s.size(); ++i)
  {
    if (s[i - 1] == s[i])
    {
      cout << "Bad\n";
      return;
    }
  }
  cout << "Good\n";
}


void fifty_fify()
{
  string s;
  cin >> s;

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

  if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes\n";
  else cout << "No\n";
}


void dodecagon()
{
  int r;
  cin >> r;

  cout << 3 * r * r << "\n";
}


void harmony()
{
  int a, b;
  cin >> a >> b;

  if (a % 2 == b % 2) cout << (a + b) / 2 << "\n";
  else cout << "IMPOSSIBLE\n";
}


void transfer()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << max(0, c - (a - b)) << "\n";
}


void A_137()
{
  int a, b;
  cin >> a >> b;

  cout << max(a + b, max(a - b, a * b)) << "\n";
}



int main()
{
  //security();
  //fifty_fify();
  //dodecagon();
  //harmony();
  //transfer();
  A_137();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int A[2*n+5];
    for(int i = 0; i < 2*n; i++) cin >> A[i];
    sort(A,A+2*n);
    int ans = 0;
    for(int i = 2*n-1; i >= 0; i-= 2){
        ans += min(A[i],A[i-1]);
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N;
    cin >> N;
    cout << "ABC" << (N < 100 ? "0" : "") << (N < 10 ? "0" : "") << N << endl;
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  int N;
  cin >> S >> T;
  
  N = 0;
  
  for (int i=0; i < S.size(); i++) {
    if (S.at(i) == T.at(i)) {
    }
    else {
      N = N+1;  
    }
  }
    
  cout << N << endl;
   
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define int long long
#define pi acos(-1)
#define P pair<int,int>
#define fi first
#define se second
#define si signed
#define sc(x) scanf("%lld",&(x));
int N,D,C;
P A[200005];
int p[200005];
const int INF=1e9;
signed main()
{
    sc(N)sc(D)sc(C)
    for(int i=1; i<=N; i++)
    {
        sc(A[i].fi)sc(A[i].se)
    }
    sort(A+1,A+N+1);

    int ans  = 0;
    for(int i=1; i<=N; i++)
    {
        p[i]+=p[i-1];
        if(A[i].se-p[i]<=0)continue;
        int x=A[i].se-p[i];
        int t=x/C+((x%C)!=0);
        //cout<<t<<'\n';
        ans+=t;
        int r = upper_bound(A+1,A+1+N,P{A[i].fi+2*D,INF})-A-1;
        p[i]+=t*C;
        p[r+1]-=t*C;
    }
    cout<<ans<<'\n';

}


Measured memory_bytes: 4992
import java.util.*;

public class Main {

    /* チェックリスト
     * 結果はintの範囲を超えていませんか？(必要な時以外はlongを使いましょう)
     * TLEしそうな処理はありませんか？
     */
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String[] in = sc.nextLine().split(" ");
        int n = Integer.parseInt(in[0]);
        Long k = Long.parseLong(in[1]);
        int q = Integer.parseInt(in[2]);
        List<Long> players = new ArrayList<Long>();
        for(int i = 0;i < n;i++){
            players.add(k - q);
        }
        for(int i = 0;i < q;i++){
            int player = Integer.parseInt(sc.next()) - 1;
            long ok = players.get(player) + 1;
            players.set(player,ok);
        }
        for(int i = 0;i < players.size();i++){
            System.out.println(players.get(i) <= 0 ? "No" : "Yes");
        }
    }
}

Measured memory_bytes: 50080
n, k = map(int, input().split())
an = list(map(int, input().split()))

left, right = 0, 0
for i in range(len(an)):
    ref = an[i]
    left += len([a for a in an[0:i] if a < ref])
    right += len([a for a in an[i+1:] if a < ref])


k2 = k**2
ans = ((k2 + k) * right + (k2 - k) * left) // 2
print(ans % (10**9 + 7))


Measured memory_bytes: 3188
#include<stdio.h>
int main(){

  int i,j,k,n,A[101],min,count;

  count = 0;

  scanf("%d", &n );

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

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

    min = A[i];
    k = i;
    
    for ( j = i ; j < n ; j++ ){
      if ( A[j] < min ) {
	min = A[j];
	k = j;
      }
    }

    if ( i != k ) {
      count += 1;
    }
    
    A[k] = A[i];
    A[i] = min;

  }

  for ( i = 0 ; i < n ; i++ ){
    if ( i < n - 1 ){
      printf("%d ", A[i] );
    } else {
      printf("%d\n", A[i] );
    }
  }

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

  return 0;

}

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

int main(){
    int N;
    scanf("%d", &N);
    vector<int> A(1<<N);
    for (int i = 0; i < (1<<N); i++) scanf("%d", &A[i]);
    vector<vector<pair<int, int>>> dp(1<<N, vector<pair<int, int>>(N+1, {0,0}));
    for (int i = 0; i < (1<<N); i++) dp[i][0] = {A[i], 0};
    
    for (int i = 0; i < (1<<N); i++) {
        for (int j = 1; j <= N; j++) {
            if (i & (1 << (j-1))) {
                int k = i - (1<<(j-1));
                dp[i][j] = dp[i][j-1];
                int t = dp[k][j-1].first, u = dp[k][j-1].second;
                if (t > dp[i][j].first) {
                    dp[i][j] = {t, dp[i][j].first};
                }else if (t > dp[i][j].second) {
                    dp[i][j] = {dp[i][j].first, t};
                }
                if (u > dp[i][j].second) dp[i][j] = {dp[i][j].first, u};
            }
            else {
                dp[i][j] = dp[i][j-1];
            }
        }
    }
    int ans = 0;
    for (int i = 1; i < (1<<N); i++) {
        ans = max(ans, dp[i][N].first+dp[i][N].second);
        printf("%d\n", ans);
    }
}

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

int main() {
    int n;
    long long k;
    int perm[5010];
    long long nums[5010];
    long long ans = -1e18;
    cin >> n >> k;
    for(int i = 0;i < n;i++) cin >> perm[i];
    for(int i = 0;i < n;i++) cin >> nums[i];

    for (int i = 0;i < n;i++) {
        long long s = nums[i];
        vector<long long> dp;
        dp.push_back(s);
        for(int idx_p = perm[i]-1;idx_p != i; idx_p = perm[idx_p]-1) {
            s += nums[idx_p];
            dp.push_back(s);
        }
        int len = dp.size();
        for(int j = 0;j < len;j++) {
            long long rest = k - j - 1;
			if(rest < 0) break;
			ans = max(ans, dp[j] + (rest / len) * max(s, 0LL));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel

signed main()
{
	fasterthanlight;
	int n;
	cin >> n;
	string s;
	//cin >> s;
	int a = 0, b = 0, c = 0, d = 0;
	while (n--)
	{
		cin >> s;
		if (s == "AC")
			a++;
		else if (s == "WA")
			b++;
		else if (s == "TLE")
			c++;
		else
			d++;
	}
	cout << "AC x " << a << endl;
	cout << "WA x " << b << endl;
	cout << "TLE x " << c << endl;
	cout << "RE x " << d << endl;
	//cout << "\n\n" << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

Measured memory_bytes: 3660
#75 C - 怪文書
import collections
n = int(input())
S = [input() for _ in range(n)]

cnt = collections.Counter(S[0])
for s in S[1:]:#O (50)
    for a in cnt.keys():# O(26)
        if a in s:# O(50)
            cnt[a] = min(cnt[a],s.count(a))# O(50)
        else:
            cnt[a] = 0
            
ans = [key*value for key,value in cnt.items() if value > 0]
ans = sorted(ans,reverse = False)
print(''.join(ans))

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

int main(){
    string s;
    cin>>s>>s;
    if(s.length()%2==0
    && s.substr(0,s.length()/2) == s.substr(s.length()/2, s.length()/2)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A=0,Z=0,c=0,m=0,n=0;
    string a;
    getline(cin,a);
        int b=a.length();
        for(int x=0;x<b;x++)
        {
            if(a[x]=='A')
            {
                 A=x+1;
                 m=1;
                break;
            }
            if(m)
                break;
        }
        for(int x=b-1;x>0;x--)
        {
            if(a[x]=='Z')
            {
            Z=x+1;
            n=1;
            break;
            }
            if(n)
                break;
        }
        c=Z-A+1;

    cout<<c;
}


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

struct data {
  long long a, b;
};
bool operator<(const data &l, const data &r) {
  if(l.a != r.a) return l.a < r.a;
  return l.b > r.b;
}

long long n, t;
vector<data> v;
vector<vector<long long>> dp;

long long solve();

int main() {
  cin >> n >> t;
  v.resize(n);
  for(int i = 0; i < n; ++i) cin >> v[i].a >> v[i].b;
  sort(v.begin(), v.end());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  dp.assign(n + 1, vector<long long>(t + 1, 0));
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < t; ++j) {
      dp[i + 1][j] = dp[i][j];
      ans = max(ans, dp[i][j] + v[i].b);
      if(j + v[i].a < t)
        dp[i + 1][j] =
            max(dp[i + 1][j], dp[i][j + v[i].a] + v[i].b);
      ans = max(ans, dp[i + 1][j]);
    }
  }
  return ans;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int N, M, A[9][9];
//---------------------------------------------------------------------------------------------------
int check(int y) {
    int win = 0, lose = 0;
    rep(x, 0, N) {
        if (A[y][x] == 1) win++;
        else if (A[y][x] < 0 and y != x) lose++;
    }
    return win <= (N - 1) / 2 and (N - 1) / 2 <= win + lose;
}
//---------------------------------------------------------------------------------------------------
int answer = 0;
void dfs(int cu) {
    int x = cu % N;
    int y = cu / N;

    if (cu == N * N) {
        answer++;
        return;
    }

    if (x == y or 0 <= A[y][x]) {
        if (check(y)) dfs(cu + 1);
        return;
    }
    
    A[y][x] = 1; A[x][y] = 0;
    if(check(y)) dfs(cu + 1);

    A[y][x] = 0; A[x][y] = 1;
    if (check(y)) dfs(cu + 1);

    A[y][x] = A[x][y] = -1;
}

//---------------------------------------------------------------------------------------------------

void _main() {
    while (cin >> N) {
        if (N == 0) return;
        cin >> M;
        rep(i, 0, N) rep(j, 0, N) A[i][j] = -1;
        rep(i, 0, M) {
            int a, b; cin >> a >> b;
            a--; b--;
            A[a][b] = 1;
            A[b][a] = 0;
        }

        answer = 0;
        dfs(0);
        printf("%d\n", answer);
    }
}




Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define inf 2e9
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
using namespace std;

int main() {
    int a,b;
    cin>>a>>b;
    if (a+b<=16 && a<=8 && b<=8)
        cout<<"Yay!\n";
    else cout<<":(\n";
    return 0;
}


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

using namespace std;

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#endif


#define ll                             long long int
#define endl                           '\n'
#define pb                             push_back
#define vectl                          vector<ll>
#define vecti                          vector<int>
#define debugh                         cout<<"here"<<endl;
#define loopi(i,n)                     for(ll i=0;i<n;i++)
#define loopj(j,n)                     for(ll j=0;j<n;j++)
#define loop2(i,a,b)                   for(int i=a;i<b;i++)
#define mp                             make_pair
#define ip(a,n)                        for(ll i=0;i<n;i++)cin>>a[i]
#define op(a,n)                        for(ll i=0;i<n;i++)cout<<a[i]<<" "
#define gcd(a,b)                       __gcd((a),(b))`
#define lcm(a,b)                       (((a)*(b))/gcd((a),(b)))
#define mem(x,n)                       memset(x,n,sizeof(x))
#define cn                             cout<<"\n";
#define fast                           ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define testcase                       ll t; cin>>t; while(t--)



const ll INF=1e18;
const ll N=100005;
const ll MOD=1e9+7;

int main()
{
    fast
    //testcase
    // {
        ll n; cin>>n;
        int a[n][3];       

        loopi(i,n)
        {
            for (ll j=0;j<3;j++)
            {
               // debugh
                cin>>a[i][j];
            }
        }

        ll dp[n][3];
        dp[0][0]=a[0][0];
        dp[0][1]=a[0][1];
        dp[0][2]=a[0][2];

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

        ll ans = max(dp[n-1][0],dp[n-1][1]);
        ans = max(ans,dp[n-1][2]);

        cout<<ans<<endl;



              
   // }

    return 0;

}





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

using namespace std;

int main(void){
	int n;
	int l;
	cin >> n;
	cin >> l;
	
	int i,j;

	int a[n];
	int loss[n];
	for(i = 0; i < n; ++i){
		a[i] = l+(i+1)-1;
	}
	
	int sum_r = 0;
	for(i = 0; i < n; ++i){
		sum_r += a[i];
	}
	
	int sum_p[n] = {0};
	for(j = 0; j < n; ++j){
		for(i = 0; i < n; ++i){
			if(i != j) sum_p[j] += a[i];
		}
		loss[j] = abs(sum_r - sum_p[j]);
	}
	
	int min = 0;
	for(i = 1; i < n; ++i){
		if(loss[min] > loss[i]){
			min = i;
		}
	}
	printf("%d\n", sum_p[min]);
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    int ans = 1e9;
    for (int p = 0; p <= 100; p++) {
        int score = 0;
        for (int i = 0; i < n; i++){
            score += (x[i] - p) * (x[i] - p);
        }
        ans = min(ans, score);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=1000005;
#define M 1000000007
#define double long double
#define BINF 10000000000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
const int LG = 22;


#undef int 
int main() { 
#define int long long int 
 
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0); 


	int n,k;
	cin >> n >> k;

	int x = ((n - 1) * (n - 2)) / 2;
	if(k > x){
		cout << -1;
		return 0;
	}

	int left = x - k;
	int f = 0;

	//cout << x << ' ' << k << ' ' << left << endl;

	vector<pair<int,int>>v;

	for(int i = 2; i <= n; i++)
		v.pb(mp(1,i));

	for(int i = 2; i <= n; i++){
		for(int j = i + 1; j <= n; j++){
			if(left == 0){
				f = 1;
				break;
			}
			v.pb(mp(i,j));
			left--;
		}
		if(f) break;
	}

	cout << v.size() << endl;
	for(auto i : v){
		cout << i.F << ' ' << i.S << endl;
	}




return 0;
}

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

using namespace std;

struct kick
{
    string piao;
    int n;
}a[250000];

bool sp(kick a,kick b)
{
    return a.piao<b.piao;
}

bool sq(kick a,kick b)
{
    if(a.n==b.n)
        return a.piao<b.piao;
    else
        return a.n>b.n;
}

int main()
{
    int n;
    while(cin>>n)
    {
        int i;
        for(i=0;i<n;i++)
        {
            cin>>a[i].piao;
            a[i].n=0;
        }
        sort(a,a+n,sp);
        int num=1;
        for(i=0;i<n;i++)
        {
            if(a[i].piao!=a[i+1].piao)
            {
                a[i].n=num;
                num=1;
            }
            else
                num++;
        }
        sort(a,a+n,sq);
        int x=a[0].n;
        for(i=0;a[i].n==x;i++)
            cout<<a[i].piao<<endl;
    }
    return 0;
}

Measured memory_bytes: 17024
s = list(map(int,list(input())))
k = int(input())
n=len(s)
for i in range(n):
  if s[i]>1:
    tmp=s[i]
    break

if n>=k:
  if sum(s[0:k])==k:
    print(s[k-1])
  else:
    print(tmp)
else:
  print(tmp)

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

#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'

const int N = 1e5+1;
int in[N][3] , dp[N][3];
int main()
{
	 #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	int n , x; cin >> n ; 
	for(int i = 1 ; i <= n ; ++i)
		for(int j = 0 ; j < 3 ; ++j)
			cin >> in[i][j];
	for(int i = 1 ; i <= n ; ++i)
	{
		dp[i][0] = max(dp[i-1][1] , dp[i-1][2]) + in[i][0];
		dp[i][1] = max(dp[i-1][0] , dp[i-1][2]) + in[i][1];
		dp[i][2] = max(dp[i-1][0] , dp[i-1][1]) + in[i][2];
	}
	cout << max(max(dp[n][0] , dp[n][1]) , dp[n][2]);
	return 0;
}

Measured memory_bytes: 2560
n=int(input())
a=[[0,0,0] for _ in range(n)]
for j in range(n):
  a[j][0],a[j][1],a[j][2]=map(int,input().split())
dp=[[0,0,0] for _ in range(n)]
dp[0][0]=a[0][0]
dp[0][1]=a[0][1]
dp[0][2]=a[0][2]
for i in range(1,n):
    dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2])
    dp[i][1] = a[i][1] + max(dp[i - 1][0], dp[i - 1][2])
    dp[i][2] = a[i][2] + max(dp[i - 1][1], dp[i - 1][0])
print(max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])))

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

int main()
{
int iCnt;
long long X;
long long Y;

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

	cin >> X;
	cin >> Y;

	iCnt = 0;
	while( X <= Y )
	{
		X *= 2;
		iCnt++;
	}

	cout << iCnt << endl;

	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n;
  cin>>n;
  cout<<48-n<<endl;

  return 0;
}







Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    while(true){
        int h;
        cin >> h;
        if(h == 0){
            break;
        }
        int cells[h][5];
        for(int i = 0; i < h; i++){
            cin >> cells[i][0] >> cells[i][1] >> cells[i][2] >> cells[i][3] >> cells[i][4];
        }
        int score = 0;
        bool isErased = false;
        do{
            isErased = false;
            for(int i = 0; i < h; i++){
                int currentRecording = cells[i][0];
                int currentCount = 1;
                for(int j = 1; j < 5; j++){
                    if(cells[i][j] == currentRecording && currentRecording != -1){
                        currentCount++;
                    }else {
                        if(currentCount >= 3){
                            isErased = true;
                            score += currentRecording * currentCount;
                            for(int k = j - 1; k >= 0; k--){
                                if(cells[i][k] == currentRecording){
                                    cells[i][k] = -1;
                                }else{
                                    break;
                                }
                            }
                        }
                        currentCount = 1;
                        currentRecording = cells[i][j];
                    }
                }
                if(currentCount >= 3){
                    isErased = true;
                    score += currentRecording * currentCount;
                    for(int k = 4; k >= 0; k--){
                        if(cells[i][k] == currentRecording){
                            cells[i][k] = -1;
                        }else{
                            break;
                         }
                    }
                }
            }
            if(isErased){
            for(int i = h; i > 0; i--){
                for(int j = 0; j < 5; j++){
                    if(cells[i][j] == -1){
                        for(int k = i; k >= 0; k--){
                            if(cells[k][j] != -1){
                                cells[i][j] = cells[k][j];
                                cells[k][j] = -1;
                                break;
                            }
                        }
                    }
                }
            }
            }
        }while(isErased);
        cout << score << endl;
    }
    return 0;
}



Measured memory_bytes: 3100
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cctype>
#include <map>
#include <queue>
#include <stack>
#include <string>

using namespace std;

#define inpfile(f) freopen(f,"r",stdin)
#define outfile(f) freopen(f,"w",stdout)
#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define FORD(i,a,b) for(int i=a;i>=b;--i)
#define fill(a,val) memset(a,val,sizeof(a))
#define ll long long
#define ull unsigned long long
#define INF 500000000
#define bit(i) ((i)&(-i))
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define pb push_back
#define nL(note) note+note
#define nR(note) note+note+1
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<int,ii> viii;

#define OJ
#define MOD 10000007
#define maxN 100

typedef vi::iterator iter;
int n;
vi a,ans;
iter k;

void input() {
  scanf("%d",&n);
  a.assign(n,0);
  REP(i,n) scanf("%d",&a[i]);
}

void Lis() {
  REP(i,n) {
      k=lower_bound(all(ans),a[i]);
      if(k!=ans.end()) ans[k-ans.begin()]=a[i];
       else ans.pb(a[i]);
  }
  printf("%d\n",ans.size());
}
int main() {
    #ifndef OJ
        inpfile("test.inp"); //outfile("test.out");
    #endif
    input();
    Lis();
    return 0;
}

Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2e5+7;
struct node
{
	int h,id;
	ll val;
};
bool cmp(node a,node b)
{
	return a.h<b.h;
}
int a[N],n;
ll b[N],st[N*4];
void build(int node,int l,int r)
{
	if(l==r)
	{
		st[node]=0;
		return;
	}
	int mid=(l+r)>>1;
	build(node<<1,l,mid);
	build(node<<1|1,mid+1,r);
	st[node]=max(st[node<<1],st[node<<1|1]);
}
void update(int node,int l,int r,int pos,ll val)
{
	if(l==r)
	{
		st[node]=val;
		return;
	}
	int mid=(l+r)>>1;
	if(pos<=mid) update(node<<1,l,mid,pos,val);
	else update(node<<1|1,mid+1,r,pos,val);
	st[node]=max(st[node<<1],st[node<<1|1]);
}
ll get(int node,int l,int r,int bg,int ed)
{
	if(l>ed||r<bg) return 0;
	if(bg<=l&&r<=ed) return st[node];
	int mid=(l+r)>>1;
	ll a1=get(node<<1,l,mid,bg,ed);
	ll a2=get(node<<1|1,mid+1,r,bg,ed);
	return max(a1,a2);
}
node USS[N];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
		USS[i].h=a[i],USS[i].val=b[i],USS[i].id=i;
	}
	build(1,0,n-1);
	sort(USS,USS+n,cmp);
	for(int i=0;i<n;i++)
	{
		ll ans=get(1,0,n-1,0,USS[i].id-1);
		update(1,0,n-1,USS[i].id,ans+USS[i].val);
	}
	cout<<get(1,0,n-1,0,n-1);
}

Measured memory_bytes: 13212
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  bool ans = false;
  for(int i=0;i<=N/4;i++){
    for(int m=0;m<=N/7;m++){
      if(i*4+m*7==N) ans = true;
    }
  }
  if(ans==true) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
# Code for B - Multiplication 2
# Use input() to fetch data from STDIN
import sys

n = input()
a = list(map( int, input().split() ))

for x in a:
    if x == 0:
        print(0)
        sys.exit(0)

total = 1
for x in a:
    if x > 10 ** 18:
        print(-1)
        sys.exit(0)

    total = total * x;

    if total > 10 ** 18:
        print(-1)
        sys.exit(0)

print(total)


Measured memory_bytes: 21636
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int n,k;
	cin>>n>>k;
	vector<int> h(n);
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	int dp[n];
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++){
		dp[i]=INT_MAX;
		for(int j=1;j<=k&&j<=i;j++){
			dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
	}
	cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 3660
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    
    long long int h[N], dp[N];
    for(int i=0; i<N; i++) {
        cin >> h[i];
        if(i==0) {
            dp[i]=0;
        } else if(i==1) {
            dp[i]=abs(h[i]-h[i-1]);
        } else {
            dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]), dp[i-1]+abs(h[i-1]-h[i]));
        }
    }
    
    cout << dp[N-1] << endl;

    return 0;
    
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n;
  cin >> n;
  vector<ll> h(n);
  ll mmin = 1000, mmax = -1;
  rep(i,n) {
    cin >> h[i];
    mmin = min(h[i],mmin);
    mmax = max(h[i],mmax);
  }

  ll ans = mmin;
  vector<ll> temp(n,mmin);
  
  for (int i = mmin; i <= mmax; ++i) {
    bool flag = false;
    for (int j = 0; j < n; ++j) {
      if (temp[j] < h[j]) {
        if (!flag) {
          flag = true;
        }
        temp[j] += 1;
      } else {
        if (flag) {
          ans += 1;
          flag = false;
        }
      }
    }
    if (flag) {
      ans += 1;
    }
  }

  cout << ans << endl;
}



Measured memory_bytes: 256
a = (1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,476,484,512,529,576,625,676,729,784,841,900,961,1000)
k = int(input())
for i in range(len(a)):
  if k == 1:
    print(1)
    break
  elif k == 1000:
    print(1000)
    break
  
  elif a[i] > k:
    print(a[i-1])
    break

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define pai 3.1415926535

int main(void) {
	char S[11];
	scanf("%s", S);
	int min = 753 - 111;
	int sum = 0;
	int moji = 0;
	char t[4];
	for (int i = 0; i < strlen(S)-2; i++) {
		strncpy(t, &S[i], 3);
		t[3] = '\0';
		sum = atoi(t); 
		if (abs(sum - 753) < min) {
			min = abs(sum - 753);
		}

	}
	printf("%d", min);


	return 0;
}




Measured memory_bytes: 128
import collections
n=int(input())
v = list(map(int,input().split()))
od=[]
ev=[]
k=int(n/2)
cev=0
cod=0

for i in range(0,n,2):
  ev.append(v[i])
  od.append(v[i+1])

ev.sort()
od.sort()

c=collections.Counter(ev)
d=collections.Counter(od)

e=c.most_common()[0][1]
f=d.most_common()[0][1]

if len(set(v))==1:
  e=k
  f=0
else:
  if(c.most_common()[0][0]==d.most_common()[0][0])and(c.most_common()[0][1]==d.most_common()[0][1]):
    e=max(c.most_common()[1][1],d.most_common()[1][1])
print(n-e-f)

Measured memory_bytes: 23648
/* Arpit Pandey*/ 

#include <bits/stdc++.h>
#include <stdlib.h>
#include <stdint.h>
using namespace std;
 
#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define test(x) int x;cin>>x; while(x-->0)
#define memset(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;
 
void fast_io()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("error.txt", "w", stderr);
    freopen("output.txt", "w", stdout);
#endif
}
void sol()
{
  int n;cin>>n;
  if(n>=30)
    cout<<"Yes";
  else
    cout<<"No";
}

int32_t main()
{
    fast_io();
    //test(t)
    sol();
    
    //cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    //cerr << sizeof(dp)*(1e-6) << " megabytes\n";
    return 0;
}


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

using namespace std;

#define MOD 1000000007
#define N 10004
#define M 102
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

string s;
vector <int> num;
int n, d;
ll dp[N][M][2];

ll get(int pos, ll sum, bool flag){
    ll &ans = dp[pos][sum][flag];
    if(pos == n && sum%d == 0){
        return (ans = 1);
    }
    if(pos == n){
        return (ans = 0);
    }
    if(ans != -1){
        return ans;
    }
    ans = 0;
    int lim = flag ? 9 : num[pos];
    for(int i=0; i<=lim; i++){
        ans = (ans + get(pos+1, (sum+i)%d, flag | (i < num[pos]))) % MOD;
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>s>>d;
    for(auto it : s){
        num.pb(it-'0');
    }
    n = num.size();
    memset(dp, -1, sizeof dp);
    cout<<(get(0, 0, 0) - 1 + MOD)%MOD;
    return 0;
}

Measured memory_bytes: 17152