akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1e9+7
#define pf2 pop_front
#define pb2 pop_back
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define sz size
#define eps 1e-7
#define fod find_by_order
#define fastio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ofk order_of_key
#define val(x) cout << "Value dari "<< #x << " adalah " << x  << "\n"
#define tr tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;

int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};

void readf(string x){
	freopen((x+".in").c_str(),"r",stdin);
	freopen((x+".out").c_str(),"w",stdout);
}

void pr(string x){
	freopen((x+".in").c_str(),"w",stdout);
}


int read()
{
	bool min = 0;
	int  result = 0;
	char ch;
	ch = getchar();
	while(1)
	{
		if(ch == '-') break;
		if(ch >='0' && ch <= '9') break;
		ch = getchar();
	}
	if(ch == '-') min = 1;else result = ch-'0';
	while(1)
	{
		ch =getchar();
		if(ch< '0' || ch>'9') break;
		result = result * 10 + (ch-'0');
	}
	if(min) return -result;
	return result;
}
//Reynaldo's Template

int main(){
	ll N;
	ll sum = 0;
	ll ans = 1;
	cin >> N;
	while(sum < N){
		sum += ans;
		ans++;
	}
	cout << ans-1 << "\n";
}



Measured memory_bytes: 256
S = input()
T = input()
ans = []

for left in range(len(S)):
    subS = S[left: left + len(T)]
    if len(subS) < len(T):
        break
    for s, t in zip(subS, T):
        if s == '?':
            continue
        if s != t:
            break
    else:
        U = S[:left] + T + S[left + len(T):]
        ans.append(U.replace('?', 'a'))

if len(ans) == 0:
    print('UNRESTORABLE')
else:
    ans.sort()
    print(ans[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n = 1) : n(n), f(n + 1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; ++i) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i * i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    bool isPrime(int x) {
        return f[x] == x;
    }
    vector<int> factorList(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<pair<int, int>> factor(int x) {
        vector<int> fl = factorList(x);
        if (fl.size() == 0) return {};
        vector<pair<int, int>> res(1, pair<int, int>(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};

int main() {
    int N;
    cin >> N;
    
    Sieve sieve(55555);
    vec<int> ans;

    for(auto e:sieve.primes){
        if(e%5 == 1) ans.push_back(e);
        if(ans.size() == N) break;
    }
    
    for(auto e:ans){
        cout << e << " ";
    }
    cout << endl;
}


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


using namespace std;

int main(){
  int N,W;
  cin >> N >> W;
  int w[N];
  int v[N];
  for(int i = 0 ; i < N; i++) cin >> w[i] >> v[i];
  long long dp[W+1];
  for(int i = 0 ; i < W+1; i++) dp[i] = 0;
  for(int i = 0 ; i < N; i++){
     for(int j = W-w[i]; j >=0; j-- ){
        dp[j+w[i]] = max(dp[j+w[i]], dp[j] + v[i]);
     }
  }
  long long ans = 0;
  for(int i = 0 ; i <=W; i++) ans = max(ans, dp[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
# 2019/10/29
import math

a,b,x=map(int,input().split())
r=(pow(a,2)*b-(2*x))/(a*b)
pi=math.pi

if r>=0:
    ans=math.atan2(b,a-r)
else:
    t=2*(b-(x/pow(a,2)))
    ans=math.atan2(t,a)

print(math.degrees(ans))

Measured memory_bytes: 3060
#!/usr/bin/python

import os
import sys
import math

def solve(f):
    n = f.read_int()
    if n == 0: raise StopIteration
    ary = [f.read_float_list() for _ in xrange(n)]

    x_min = -100.0
    x_max = 100.0

    for _ in xrange(60):
        c1 = (x_min*2 + x_max) / 3
        c2 = (x_min + x_max*2) / 3
        if search_y(ary, c1) > search_y(ary, c2):
            x_max = c2
        else:
            x_min = c1

    return math.sqrt(search_y(ary, x_max))

def search_y(ary, x):
    y_min = -100.0
    y_max = 100.0

    for _ in xrange(60):
        c1 = (y_min*2 + y_max) / 3
        c2 = (y_min + y_max*2) / 3
        if calc(ary, x, c1) > calc(ary, x, c2):
            y_max = c2
        else:
            y_min = c1

    return calc(ary, x, y_max)

def calc(ary, x, y):
    return min([item[2]**2 - (item[0]-x)**2 - (item[1]-y)**2 for item in ary])


class Reader(object):
    def __init__(self, filename=None):
        self.test_mode = filename is not None
        self.cases = 1
        self.buffer = []
        if self.test_mode:
            with open(filename) as f:
                blank_flg = False
                for line in f:
                    line = line.strip()
                    if line:
                        self.buffer.append(line)
                        blank_flg = False
                    else:
                        if not blank_flg: self.cases += 1
                        blank_flg = True

    def __readline(self):
        return self.buffer.pop(0) if self.test_mode else raw_input()

    def read_int(self):
        return int(self.__readline())
    def read_float(self):
        return float(self.__readline())
    def read_long(self):
        return long(self.__readline())
    def read_str(self):
        return self.__readline()

    def read_int_list(self):
        return [int(item) for item in self.__readline().split()]
    def read_float_list(self):
        return [float(item) for item in self.__readline().split()]
    def read_long_list(self):
        return [long(item) for item in self.__readline().split()]
    def read_str_list(self):
        return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv)>1 else None
    f = Reader(filename)
    while True:
        try:
            print solve(f)
        except StopIteration:
            break

Measured memory_bytes: 6524
# -*- coding: utf-8 -*-
S = list(input())
Q = int(input())

lim = 10**5 *2
buf = [None for _ in range(lim)] + S + [None for _ in range(lim)]
forward_i, back_i = lim-1, lim + len(S) + 1
is_reversed = False
for _ in range(Q):
    token = input().split(' ')
    if len(token) == 1:
        is_reversed = ~is_reversed

    else:
        _, f, c = token
        f = int(f)
        if (f == 1 and is_reversed) or (f == 2 and not is_reversed):
            buf[back_i] = c
            back_i += 1
            # S.append(c)

        else:
        # elif (f == 1 and not is_reversed) or (f == 2 and is_reversed):
            buf[forward_i] = c
            forward_i -= 1
            # S.insert(0, c)

S = ''.join([b for b in buf if b is not None])
if is_reversed:
    print(''.join(reversed(list(S))))
    # S.reverse()
    # print(''.join(S))

else:
    print(S)
    # print(''.join(S))



Measured memory_bytes: 125848
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n,k;
    scanf("%d %d", &n, &k);
    vector<int> va(n);
    for(int i = 0; i < n; i++){
        scanf("%d", &va[i]);
    }
    sort(va.begin(), va.end());
  
    int nAns = 0;
    for(int i = 0; i < k; i++){
        nAns += va[i];
    }
    
    printf("%d", nAns);
    return 0;
}


Measured memory_bytes: 3224
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;

int main(){
    int a,b,c;cin>>a>>b>>c;
    int x=abs(a-b),y=abs(b-c),z=abs(c-a);
    cout<<x+y+z-max(x,max(y,z))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<sstream>
using namespace std;
int main(){
    int n,i,a[10000],b[10000],c[10000],ans1=0,ans2=0;
    while(cin>>n){
        if(n==0)break;
        for(i=0;i<n;i++){
            cin>>a[i]>>b[i]>>c[i];
            ans1=(a[i]+b[i]+c[i])/3;
            ans2=(a[i]+b[i])/2;
            if(a[i]==100||b[i]==100||c[i]==100||ans1>=80||ans2>=90){
                cout<<"A"<<endl;
            }
            else if(ans1>=70||ans1>=50&&a[i]>=80||ans1>=50&&b[i]>=80){
                cout<<"B"<<endl;
            }
            else{
                cout<<"C"<<endl;
            }
        }
        
    }
     return 0;
}

Measured memory_bytes: 2972
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;

ll rec(auto &dp, int l, int r){
  if(dp[l][r]!=0) return dp[l][r];
  ll ans=((ll)1<<59);
  ll cst=dp[l][l+1];
  for(int i=l+1;i<r;i++){
    ans=min(ans,rec(dp,l,i)+rec(dp,i,r));
    cst+=dp[i][i+1];
  }
  //cout << l << " " << r << ":" << ans+cst << endl;
  return dp[l][r]=ans+cst;  
}

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

  ll s=0;
  vector<vector<ll>> dp(N+1,vector<ll>(N+1));
  for (int i = 0; i < N; i++){
    cin >> dp[i][i+1];
    s+=dp[i][i+1];
  }

  cout << rec(dp,0,N)-s << endl;

  return 0;
}


Measured memory_bytes: 1536
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    A.sort();
    long i = 0;
    long ans = 0;
    while (i < N)
    {
        long a = A[i];
        long j = i;
        while (j < N && A[j] - a < 3)
            j++;
        ans = ans.max(j - i);
        while (i < N && A[i] == a)
            i++;
    }
    writeln(ans);
}


Measured memory_bytes: 4400
N, M = map(int, input().split())
A = list(map(int, input().split()))
sum = sum(A)
flag = 0
A = sorted(A, reverse=True)
# print(sum, A)

for i in range(0, M):
  if M == 0:
    break
  if A[i]<(sum/(4*M)):
    print('No')
    flag = 1
    break

if flag == 0:
  print("Yes")

Measured memory_bytes: 3064
n,k=map(int,input().split())
s=input()
s='x'+s
l=[0]*n
for i in range(n):
  if s[i:i+2]=='AC':
    l[i]=l[i-1]+1
  else:
    l[i]=l[i-1]
for i in range(k):
  a,b=map(int,input().split())
  print(l[b-1]-l[a-1])

Measured memory_bytes: 6060
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn run() {
    input! {
        n: u64,
        k: u64,
    }
    let mut l = 1;
    let mut r = k + 1;
    while r - l > 1 {
        let m = (l + r) / 2;
        let mut x = m;
        let mut sum = 0;
        let mut c = n;
        while x > 0 && c > 0 {
            sum += x;
            x = x / 2;
            c -= 1;
        }
        if sum <= k {
            l = m;
        } else {
            r = m;
        }
    }
    println!("{}", l);
}

fn main() {
    run();
}



Measured memory_bytes: 5036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    rep(i, n) {
        ll tmp_a;
        cin >> tmp_a;
        while(1) {
            if ( tmp_a % 2 != 0 ) break;
            tmp_a /= 2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import sys

def main():
    lines = sys.stdin.readlines()

    # The number of rooms
    rooms = [0] * 10
    floors = [rooms] * 3
    buildings = [floors] * 4

    data_num = 0

    for index, line in enumerate(lines):
        #print(line)
        # rm '\n' from string of a line
        line = line.strip('\n')
        elems = line.split(" ")
        if index == 0:
            data_num = int(elems[0])
        else:
            b = int(elems[0]) - 1   # as index
            f = int(elems[1]) - 1   # as index
            r = int(elems[2]) - 1   # as index
            v = int(elems[3])       # as data
            # print v
            # print buildings[b][f][r]
            ans = []
            for b_i in range(0, 4):
                b_list = []
                for f_i in range(0, 3):
                    f_list = []
                    for r_i in range(0, 10):
                        if b == b_i and f == f_i and r == r_i:
                            f_list.append(buildings[b_i][f_i][r_i] + v)
                        else:
                            f_list.append(buildings[b_i][f_i][r_i])
                    b_list.append(f_list)
                ans.append(b_list)
            # print ans
            buildings = ans

    for b_i in range(0, 4):
        for f_i in range(0, 3):
            for r_i in range(0, 10):
                sys.stdout.write(' %d' % buildings[b_i][f_i][r_i])
            sys.stdout.write('\n')
        if b_i != 3:
            print "####################"



if __name__ == "__main__":
    main()

Measured memory_bytes: 6512
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

#define rep(i,n) for(int i=0;i< (n);++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define for_lowercase(c) for(int c='a';c<='z';++c)
#define for_uppercase(c) for(int c='A';c<='Z';++c)
#define ALL(a) (a).begin(),(a).end()
using LLI = long long int;
LLI GCD(LLI a,LLI b){ if(a<b) return GCD(b,a); else if(a%b==0) return b; else return GCD(b,a%b); }
LLI LCM(LLI a,LLI b){ return (a/GCD(a,b))*b; }
using VI  = std::vector<LLI>;
using PI  = std::pair<LLI,LLI>;
using VVI = std::vector<VI>;
using VPI = std::vector<PI>;
template<class T> bool is_odd (T x){ return   x%2 ; }
template<class T> bool is_even(T x){ return !(x%2); }

int main() {
    std::ios::sync_with_stdio(false);
    LLI A[305][305];
    LLI N;
    std::cin >> N;
    rep(i,N)
        rep(j,N)
            std::cin >> A[i][j];

    rep(i,N)
        rep(j,N)
            rep(k,N)
                if(A[i][j] > A[i][k]+A[k][j]){
                    // being able to update -> contra.
                    std::cout << -1 << std::endl;
                    return 0;
                }
    // ok
    LLI ans=0;
    rep(i,N)
    {
        rep(j,N)
        {
            bool needed = true;
            rep(k,N)
            {
                if(i!=j&&j!=k&&k!=i&&A[i][j] == A[i][k]+A[k][j])
                {
                    needed = false;
                }
            }
            if(needed)
                ans += A[i][j];
        }
    }
    std::cout << ans/2 << std::endl;
    return 0;
}

Measured memory_bytes: 1024
import sys;input = lambda : sys.stdin.readline()
import collections
N = int(input())
d = collections.Counter()
if N == 1:
    print(1)
else:
    for n in range(2, N + 1):
        while n % 2 == 0:
            d[2] += 1
            n //= 2
        i = 3
        while i * i <= n:
            if n % i == 0:
                while n % i == 0:
                    d[i] += 1
                    n //= i
            i += 2
        if n > 1:
            d[n] += 1
    ans = 1
    for k, v in d.items():
        ans = (ans * (v + 1)) % 1000000007
    print(ans)

Measured memory_bytes: 9384
#include <cstring> 
#include <iostream> 
using namespace std; 
  
int main() 
{ int i;
    string str;
 str.length()==19;
  cin>>str;
 
    for (int i = 0; i < 19; ++i) { 
  
        if (str[i] == ',') { 
  
            str[i] = ' '; 
        } 
    } 

   for (int i = 0; i < 19; ++i)
   {cout<<str[i];}
  
    return 0; 
} 


Measured memory_bytes: 3612
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}
std::uint32_t euclidean_gcd(std::uint32_t a, std::uint32_t b){return b != 0 ? euclidean_gcd(b, a % b) : a;}


void solve(long long H, long long A){
    if(H%A!=0&&A!=1)cout<<H/A+1<<endl;
    else cout<<H/A<<endl;

}

int main(){
    long long H;
    scanf("%lld",&H);
    long long A;
    scanf("%lld",&A);
    solve(H, A);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {

  static class Point {
    int x, y;
    Point(int a, int b) {
      this.x = a;
      this.y = b;
    }
  }

  static int W, H;
  static int map[][];
  static ArrayDeque<Point> stack;
  static int x8[] = {0, 1, 1, 1, 0, -1, -1, -1};
  static int y8[] = {1, 1, 0, -1, -1, -1, 0, 1};

  static void bfs() {
    while (!stack.isEmpty()) {
      Point p = stack.removeFirst();
      for (int i = 0; i < 8; i++) {
        int nx = p.x + x8[i];
        int ny = p.y + y8[i];
        if (nx < W && ny < H && nx >= 0 && ny >= 0) {
          if (map[ny][nx] == 1) {
            stack.addLast(new Point(nx, ny));
            map[ny][nx]++;
          }
        }
      }
    }
  }

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    while (true) {
      W = sc.nextInt();
      H = sc.nextInt();
      if (W == 0 && H == 0) return;
      map = new int[H][W];
      stack = new ArrayDeque<>();
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          map[i][j] = sc.nextInt();
        }
      }
      int count = 0;

      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (map[i][j] == 1) {
            count++;
            stack.addFirst(new Point(j, i));
            map[i][j]++;
            bfs();
          }
        }
      }
      /*
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          System.out.print(map[i][j] + " ");
        }
        System.out.println();
      }
      */

      System.out.println(count);
    }
  }
}



Measured memory_bytes: 45404
#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 <utility>
#define INF 0x3f3f3f3f
#define MOD 1000000007
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	long long N,M;
	long long S,C;
	cin>>N>>M;
	if(M>=N*2){
		S=N;
		C=M-2*N;
		C/=4;
	}
	else if(M<N*2){
		S=M/2;
		C=0;
	}
	cout<<S+C<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

struct combination {
    ll mod;
    vector<ll> fac, finv, inv;

    combination(int n, ll m) : fac(n), finv(n), inv(n) {
        mod = m;
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < n; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }

    ll c(int n, int k) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }

    ll p(int n, int k) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * inv[k] % mod;
    }
};

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

    ll n, mod = 1e9 + 7;
    cin >> n;
    vector<ll> x(n);
    rep(i, 0, n) cin >> x[i];
    vector<ll> d(n - 1);
    rep(i, 0, n - 1) d[i] = x[i + 1] - x[i];
    combination z(300000, mod);
    vector<ll> fc(n + 1);
    rep(i, 0, n - 1) {
        fc[i] = z.p(n - 1, i + 1);
        if (i) fc[i] = (fc[i] + fc[i - 1]) % mod;
    }
    ll ans = 0;
    rep(i, 0, n) {
        ans += d[i] * fc[i];
        ans %= mod;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9600
import java.util.Scanner;
    public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);

            double r = sc.nextDouble();
            double pi = Math.PI;
            double area = r * r * pi;
            double length = 2 * pi * r;
            
            System.out.printf("%f %f",area,length);
            sc.close();

        }

    }


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

int main(){
    int H, W;
    std::cin >> H >> W;
    std::vector<std::vector<char>> pix(H, std::vector<char>(W, 0));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++) std::cin >> pix[i][j];
    }

    
    for(int i = 0; i < W + 2; i++) std::cout << '#';
    std::cout << std::endl;
    for(int i = 0; i < H; i++){
        std::cout << '#';
        for(int j = 0; j < W; j++) std::cout << pix[i][j];
        std::cout << '#' << std::endl;
    }
    for(int i = 0; i < W + 2; i++) std::cout << '#';

    return 0;
}


Measured memory_bytes: 256
import sys 
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
a = [int(input()) - 1 for _ in range(m)]
a.append(n)

dp = [-1] * max(3, n + 1)
dp[0] = 1
dp[1] = 1
dp[2] = 2
def stepsum(n):
    if dp[n] != -1:
        return dp[n]
    dp[n] = stepsum(n-1) + stepsum(n-2)
    return dp[n]
prev = 0
ans = 1
for ai in a:
    if prev != 0 and ai - prev < 0:
        ans = 0
        break
    ans *= stepsum(ai - prev)
    prev = ai + 2

print(ans % ( 10 ** 9 + 7 ))


Measured memory_bytes: 537852
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int n;
	cin >> n;
	vector<vector<int> > a(2, vector<int>(n));
	REP(i, 2) REP(j, n) cin >> a[i][j];

	int ans = 0;
	REP(i, n)
	{
		int sum0;
		if (i < n - 1)
			sum0 = accumulate(a[0].begin(), a[0].begin() + i + 1, 0);
		else
			sum0 = accumulate(a[0].begin(), a[0].end(), 0);
		int sum1 = accumulate(a[1].begin() + i, a[1].end(), 0);
		if (ans < sum0 + sum1)
			ans = sum0 + sum1;
	}

	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


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

int main() {
    int n, l;
    cin >> n >> l;
    int ans = 0;
    rep (i, n) ans += l + i;
    if (l > 0) cout << ans - l << endl;
    else if (l + n - 1 < 0) cout << ans - (l + n - 1) << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        int[][] results = new int[11][331];
        solve(new int[10], 0, 0, results);

        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line = null;
        while ((line = reader.readLine()) != null) {
            if (line.isEmpty()) {
                continue;
            }
            String[] values = line.split(" ");
            int n = Integer.parseInt(values[0]);
            int s = Integer.parseInt(values[1]);
            if (n > 10 || s > 330) {
                out.println(0);
                continue;
            }
            out.println(results[n][s]);
        }
    }

    private static void solve(int[] indexes, int k, int s, int[][] results) {
        if (k == 10) {
            return;
        }
        for (int i = 0; i < 10; i++) {
            boolean used = false;
            for (int j = 0; j < k; j++) {
                if (indexes[j] == i) {
                    used = true;
                    break;
                }
            }
            if (used) {
                continue;
            }
            indexes[k] = i;
            int t = s + i * (k + 1);
            results[k + 1][t]++;
            solve(indexes, k + 1, t, results);
        }
    }
}

Measured memory_bytes: 9740
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S, T):
    return T + S


def main():
    S, T = read_str_n()
    print(slv(S, T))


if __name__ == '__main__':
    main()


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  string s;cin>>s;

  if(n%2==1){
    cout<<"No"<<endl;
  }else{
    if (s.substr(0,n/2)==s.substr(n/2)){
      cout<<"Yes"<<endl;
    }else{
    cout<<"No"<<endl;
    }
  }

  return 0;
}


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

distSum = [0 for _ in range(N + 3)]

for i in range(1, N + 2):
    distSum[i] = distSum[i - 1] + abs(A[i - 1] - A[i])

for j in range(1, N + 1):
    ans = distSum[j - 1] + abs(A[j - 1] - A[j + 1]) + (distSum[-2] - distSum[j + 1])
    print(ans)

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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

bool X[N][N];

void initialize(){
	for(int i=0;i<N;i++) {row[i] = FREE, col[i] = FREE;}
	for(int i=0;i<2 * N - 1;i++){ dpos[i] = FREE; dneg[i] = FREE;}
}

void printBoard(){
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(X[i][j]){
				if(row[i] != j) return;
			}
		}
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			cout << ( ( row[i] == j) ? "Q" : ".");
		}
		cout << endl;
	}
}

void recursive(int i){
	if(i == N){
		printBoard(); return;
	}
	
	for(int j=0;j<N;j++){
		if(NOT_FREE == col[j] ||
		   NOT_FREE == dpos[i+j] || 
		   NOT_FREE == dneg[i - j + N - 1]) continue;
		row[i] = j; col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
		recursive(i+1);
		row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
	}
}

int main(){
	initialize();
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++) X[i][j] = false;

	int k; cin >> k;
	for(int i=0;i<k;i++){
		int r,c; cin >> r >> c;
		X[r][c] = true;
	}

	recursive(0);

	return 0;
}

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

using namespace std;
using ll = long long;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n, ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		ans += (i % 2 == 0 && x % 2);
	}
	cout << ans;
}


Measured memory_bytes: 3576
using System;
public class Hello{
    public static void Main(){
        string[] s = Console.ReadLine().Split(' ');
        int N = int.Parse(s[0]);
        int M = int.Parse(s[1]);
        int X = int.Parse(s[2]);
        int[] A = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
        int r = 0;
        int l = 0;
        for(int i = X;i <= N;i++){
            for(int j = 0;j < M;j++){
                if(i == A[j]){
                    r++;
                }
            }
        }
        for(int a = X;a >= 0;a--){
            for(int b = 0;b < M;b++){
                if(a == A[b]){
                    l++;
                }
            }
        }
        Console.WriteLine(Math.Min(r,l));
    }
}


Measured memory_bytes: 11092
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
        for j in range(W):
            if i==0:
                print('#',end='')
            elif i==H-1:
                print('#',end='')
            elif j==0:
                print('#',end='')
            elif j==W-1:
                print('#',end='')
            else:
                print('.',end='')
        print()
    print()


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

using namespace std;

int main() {

  vector<int> a,b;

  int s,t;

  int temp;


  for(int i=0;i<4;i++) {

    cin >> temp;

    a.push_back(temp);

  }

  for(int i=0;i<4;i++) {

    cin >> temp;

    b.push_back(temp);

  }

  s=t=0;

  for(int i=0;i<4;i++) {

    s+=a[i];
    t+=b[i];

  }

  if(s>t) cout << s << endl;

  else cout << t << endl;

  return 0;

}

Measured memory_bytes: 0
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        s: Chars,
    }

    let mut set: HashSet<char> = HashSet::new();
    
    for c in s.iter() {
        set.insert(*c);
    }

    let ns_flag: bool;
    let ew_flag: bool;

    if set.contains(&'N') && set.contains(&'S') {
        ns_flag = true
    } else if set.contains(&'N') || set.contains(&'S') {
        ns_flag = false
    } else {
        ns_flag = true
    }

    if set.contains(&'E') && set.contains(&'W') {
        ew_flag = true
    } else if set.contains(&'E') || set.contains(&'W') {
        ew_flag = false
    } else {
        ew_flag = true
    }

    if ns_flag && ew_flag {
        println!("Yes");
    } else {
        println!("No");
    }
    
    println!("", );
}


Measured memory_bytes: 2180
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  for(int i=1;i<=n;i++){
    int temp = i * 1.080000;
    if(temp==n){
      cout << i;
      return 0;
    }
  }
  cout << ":(";
  return 0;
}

Measured memory_bytes: 256
N = int(input())
List = []
for i in range(N):
  if(i == 0):
    W1 = input()
    List.append(W1)
  else:
    W2 = input()
    if(W1[-1] != W2[0] or W2 in List):
      print("No")
      exit()
    else:
      W1 = W2
      List.append(W2)
print("Yes")

Measured memory_bytes: 3060
using System;

namespace T1PC2017
{
    class C
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            for (int h = 1; h <= 3500; h++)
            {
                for (int n = 1; n <= 3500; n++)
                {
                    if (4 * h * n - N * n - N * h > 0)
                    {
                        if ((N * h * n) % (4 * h * n - N * n - N * h) == 0)
                        {
                            Console.WriteLine("{0} {1} {2}", h, n, (N * h * n) / (4 * h * n - N * n - N * h));
                            return;
                        }
                    }
                }
            }
        }
    }
}


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

int main()
{
int n;
cin>>n;
int arr[n],sum=0;
for(int i=0;i<n;i++)
{
    cin>>arr[i];
    sum+=arr[i]-1;
}
cout<<sum<<endl;
return 0;
}

Measured memory_bytes: 256
/*                        _
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                   ____/`---'\____
                  /  \\|     |//  \
                 / \\||| /:\ |||// \
                / _||||| -:- |||||- \
               |   | \\\ \-/ /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
            ____'. .'  /--.--\  `. .'_____
          /"" '<  `.___\_<|>_/___.' >' "" \
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
          `-.____`.___ \_____/___.-`___.-'
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.    IIT PATNA    ADITI GOEL IS LOVE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// while(scanf("%d",&n)!=EOF)

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <bits/stdc++.h>
#define ii int64_t
#define lli long long int
#define li long int
#define vi vector<int64_t>
#define mii unordered_map<int64_t,int64_t>
#define nl cout<<"\n"
#define deb(x) cout<<"\nhi"<<x<<"\n"
#define mod 1000000007
ii n,t,i,j,k,l,x,y,z,cnt=0,sum=0,mx=-1,mn=INT_MAX;
bool f,f1,f2;
using namespace std;


int main()
{fio;
    
    cin>>n>>x>>y;
    vi v[n+2];
    v[1].push_back(2);
    for(i=2;i<n;i++)
    {
        v[i].push_back(i+1);
        v[i].push_back(i-1);
    }
    v[n].push_back(n-1);
    v[x].push_back(y);
    v[y].push_back(x);
    
    ii cnt[n+2];
    memset(cnt, 0, sizeof(cnt));
    
        for(i=1;i<=n;i++)
        {
            vi level(n+1,10000);
            vector<bool> f(n+1,false);
            queue<ii> q;
            level[i]=0;
            q.push(i);
            f[i]=true;

            while(!q.empty())
            {
                x=q.front();
                q.pop();
                z=level[x]+1;
                //if(z>k)break;
                for(j=0;j<v[x].size();j++)
                {
                    if(f[v[x][j]])continue;
                    q.push(v[x][j]);
                    f[v[x][j]]=true;
                    level[v[x][j]]=z;
                    cnt[z]++;
                    //if(z==k)cnt++;
                    //cout<<v[x][j]<<" "<<level[v[x][j]];nl;
                }
                
            }
        }
    for(i=1;i<n;i++)
    {
        cout<<cnt[i]/2;nl;
    }
    

    
    
    
    
}



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

int main(){
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  if(a == 0)
    cout << 1 << endl;
  else if(b == 0)
    cout << 2 << endl;
  else if(c == 0)
    cout << 3 << endl;
  else if(d == 0)
    cout << 4 << endl;
  else
    cout << 5 << endl;
}

Measured memory_bytes: 3632
alf = ["a","b","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
s = list(str(input()))
flag = 0
for i in alf:
    if i not in s:
        print(i)
        flag = 1
        break
if flag == 0:
    print("None")

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

using namespace std;
using nagai = long long;
#define sz(x) int((x).size())

const int N=200200;
vector<int>g[N];
int n;
vector<int>calc(int u){
	 vector<int>d(n,-1);
	 vector<int>q={u};
	 d[u]=0;
	 for(int i=0;i<q.size();++i){
		  int x=q[i];
		  for(int y:g[x])
			  if(d[y]==-1)
				  d[y]=d[x]+1,q.push_back(y);
	 }
	 return d;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n-1;++i){
		int a,b;
		cin>>a>>b;
		--a,--b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	auto kek=calc(0);
	int rofl=max_element(kek.begin(),kek.end())-kek.begin();
	kek=calc(rofl);
	rofl=*max_element(kek.begin(),kek.end());
	if(rofl%3==1)
		cout<<"Second\n";
	else
		cout<<"First\n";
	return 0;
}



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

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

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

    std::vector<int> sorted = a;
    std::sort(sorted.begin(), sorted.end(), std::greater<int>());

    int max = sorted[0], second_max = sorted[1];

    for (auto c : a) {
        std::cout << (c == max ? second_max : max) << std::endl;
    }
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  vll dp(n,LINF);
  rep(i,n){
    *lower_bound(all(dp),a[i])=a[i];
  }
  ll ans=0;
  rep(i,n) if(dp[i]!=LINF) ans++;
  cout<<ans<<endl;
}



Measured memory_bytes: 4348
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n;
  cin >> n;
  vector<int> t(n);
  rep(i,n) cin >> t[i];
  
  int m;
  cin >> m;
  vector<int> p(m);
  vector<int> x(m);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;
    p[i] = a;
    x[i] = b;
  }
  
  int total = 0;
  rep(i,n) total += t[i];
  
  rep(i,m){
    cout << total - t[p[i]] + x[i] << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace _1277
{
	class Program
	{
		static void Main(string[] args)
		{
			while (true)
			{
				int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
				if (x.Max() == 0) break;
				double[,] dp = new double[x[1] + 1, x[0] + 1];//trun mass
				int[] lose = new int[x[2]];
				for (int i = 0; i < x[2]; i++) lose[i] = int.Parse(Console.ReadLine());
				int[] back = new int[x[3]];
				for (int i = 0; i < x[3]; i++) back[i] = int.Parse(Console.ReadLine());
				dp[0, 0] = 1;
				for (int turn = 0; turn < x[1]; turn++)
				{
					for (int mass = 0; mass < x[0]; mass++)
					{
						double probability = dp[turn, mass] / 6;
						dp[turn, mass] = 0;
						for (int dice = 1; dice <= 6; dice++)
						{
							int moved = mass + dice <= x[0] ? mass + dice : x[0] * 2 - (mass + dice);
							if (lose.Contains(moved))
							{
								if (turn + 2 < x[1])
									dp[turn + 2, moved] += probability;
							}
							else if (back.Contains(moved))
							{
								dp[turn + 1, 0] += probability;
							}
							else
							{
								dp[turn + 1, moved] += probability;
							}
						}
					}
				}
				double ret = 0;
				for (int i = 0; i <= x[1]; i++) ret += dp[i, x[0]];
				Console.WriteLine(ret.ToString("F6"));
			}
		}
	}
}


Measured memory_bytes: 22548
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct edge{ll to, cost;};
int main()
{
  ll N,M;
  cin >> N >> M;
  vector<vector<ll>> A(M,vector<ll>(3));
  vector<vector<edge>> G(N);
  REP(i, M){
    REP(j, 3){
      cin >> A.at(i).at(j);
    }
    A[i][0]--;
    A[i][1]--;
    G[A[i][0]].push_back(edge{A[i][1],A[i][2]});
    G[A[i][1]].push_back(edge{A[i][0],-A[i][2]});
  }
  
  vector<ll> dist(N,-INF);
  ll now=0;
  int flag = 0;
  REP(i,N){
    if(dist[i]!=-INF) continue;
    queue<ll> que;
    que.push(i);
    dist[i]=0;
    while(!que.empty()){
      ll v=que.front();
      que.pop();
      for(auto x:G[v]){
        if(dist[x.to]!=-INF&&dist[x.to]-dist[v]!=x.cost){
          flag=1;
        }
        if(dist[x.to]==-INF){
          dist[x.to]=dist[v]+x.cost;
          que.push(x.to);
        }
      }
    }
  }

  if(flag==1){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl; 
  }
}


Measured memory_bytes: 27908
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
 
	public static void main(String[] args) throws Exception {
 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
		String line[] = br.readLine().split(" ");
		int a = Integer.parseInt(line[0]);
		int b = Integer.parseInt(line[1]);
		String x = "Impossible";
 
		if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
			x = "Possible";
		}
		System.out.println(x);
	}
}

Measured memory_bytes: 23124