akhauriyash/Code-Regression huggingface dataset:
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let A = read![[i64]];

    let set = A.into_iter().collect::<BTreeSet<_>>();

    println!("{}", if set.len() == N { "YES" } else { "NO" })
}


Measured memory_bytes: 8444
#include <iostream>

using namespace std;

#ifndef ONLINE_JUDGE
  #include <fstream>
  #define cin fin
  #define cout fout
  ifstream fin ("test.in");
  ofstream fout ("test.out");
#endif

int p[10];
int n, m, q;
int a[60], b[60], c[60], d[60];

int f (int i, int fn) {
  if (i == n) {
    int ans = 0;
    for (int j = 0; j < q; j++) {
      if (p[b[j]] - p[a[j]] == c[j])
        ans += d[j];
    }
    return ans;
  }
  int ans = 0;
  for (int j = fn; j <= m; j++) {
    p[i] = j;
    ans = max (ans, f(i + 1, j));
  }
  return ans;
}

int main() {
  cin >> n >> m >> q;
  for (int i = 0; i < q; i++)
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  for (int i = 0; i < q; i++) {
    a[i]--; b[i]--;
  }
  cout << f (0, 1) << endl;
  return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <list>
#include <stack>
#include <queue>
#include <utility>

using namespace std;

#define ll long long
#define MOD 1000000007
#define rep(i, n) for(int i = 0;i < n;i++)

int main()
{
    int n,q;
    ll k;
    cin >> n >> k >> q;
    vector<int> a(q);
    vector<int> not_sub(n+1,0);
    rep(i,q)
    {
        cin >> a[i];
        not_sub[a[i]] += 1;
    }
    for (int i = 1; i < n+1; i++)
    {
        if((k-q+not_sub[i])>0)cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
    int n, sum = 0, flag = 0;
    double m, vote;
    cin >> n >> m;
    vector<int> a(n);

    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    vote = sum / (4*m);

    sort(a.begin(), a.end(), greater<int>());
    for(int i = 0; i < m; i++) {
        if(a[i] < vote) flag = 1;
    }

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

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
a={}
b={}
count=0
for i in range(n):
	t=l[i]-(i+1)
	if t in a:
		a[t]+=1
	else:
		a[t]=1
	t=-l[i]-(i+1)
	if t in b:
		b[t]+=1
	else:
		b[t]=1
		# b[t].add(i+1)
for i in a:
	if i in b:
		count+=a[i]*b[i]
print(count)

Measured memory_bytes: 145848
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false
	

int main() {
	string S;
	cin >> S;

	int l = -1, r = -1;
	for (int i = 0; i < S.size(); i++) {
		if (l == -1 && S[i] == 'A') l = i;
		if (S[i] == 'Z') r = i;
	}
	cout << r - l + 1 << endl;

	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <utility>
#include <cctype>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	int h {in}, r {in}, d {h + r};
	outl(d ? d > 0 ? 1 : -1 : 0);
}


Measured memory_bytes: 2516
import java.io.*;
 
public class Main{
    public static void main(String[]args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
        int n = Integer.parseInt(br.readLine());
        String[] str2 = br.readLine().split(" ");
        long sum=0;
        int max=-1000000, min=1000000, tmp=0;
        for(int i=0;i<n;i++){
            tmp=Integer.parseInt(str2[i]);
            if(tmp>max)max=tmp;
            if(tmp<min)min=tmp;
            sum=sum+tmp;
        }
        System.out.println(min+" "+max+" "+sum);
    }
}

Measured memory_bytes: 28260
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int main() {
  int n;
  cin >> n;
  double ans = ((n + 1) / 2) / double(n);
  cout << ans << endl;
}


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


 int main(){

 long long n,x;
  cin>>n;
 vector<int>v;
  long long sum = 0;

 while(n--){

    cin>>x;
    v.push_back(x);
    sum += x;
 }

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

 if(sum%10 != 0)
  cout<<sum<<endl;
  else {
     int cnt=0;
    while(sum && cnt<v.size()){
         if(v[cnt]%10 != 0)
        sum -= v[cnt];

        if(cnt == n-1) break;

        if(sum %10 != 0)
            break;

         cnt++;
    }

    if(sum %10 != 0)
    cout<<sum<<endl;
    else
        cout<<"0"<<endl;
  }


 return 0;
 }


Measured memory_bytes: 256
//                _                                      
//  ___ _ __ ___ (_) __ ___      ___   _ _ __ ___  _ __  
// / __| '_ ` _ \| |/ _` \ \ /\ / / | | | '_ ` _ \| '_ \ 
// \__ \ | | | | | | (_| |\ V  V /| |_| | | | | | | |_) |
// |___/_| |_| |_|_|\__, | \_/\_/  \__,_|_| |_| |_| .__/ 
//                  |___/                         |_|  
//code by smigwump
//https://codeforces.com/blog/entry/62393 hashing hack protection
//https://codeforces.com/blog/entry/61587 rand() alternatives
//https://codeforces.com/blog/entry/61675 randomized hack protection
#include <bits/stdc++.h>
typedef long long ll;
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define REP(i,a,b) for(ll i = a; i <= b; i++)
#define PER(i,a,b) for(ll i = a; i >= b; i--)

using namespace std;
long double dist(ll a, ll b) {
	return sqrt(a*a + b*b);
}
int main() {
	// #ifndef ONLINE_JUDGE
	//     freopen("input.txt", "r", stdin);
	//     freopen("output.txt", "w", stdout);
	// #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,d;
    cin>>n>>d;
    vector<ll> x(n,0),y(n,0);
    REP(i,0,n-1) {
    	cin>>x[i]>>y[i];
    }
    ll ans = 0;
    REP(i,0,n-1) {
    	if(dist(x[i],y[i])<=d) {
    		//cout<<dist(x[i],y[i])<<"\n";
            ans++;
    	}
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 6376
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<vector<pii>> v(n);
    REP(i,n) {
        int a; cin >> a;
        REP(j,a) {
            int x, y;
            cin >> x >> y;  
            x--;
            v[i].push_back(make_pair(x,y));
        }
    }

    int ans = 0;
    for(int i = (1 << n) - 1; i >= 0; i--) {
        bool b = true;
        bitset<16> bs(i);
        REP(j,n) {
            for(auto p:v[j]) {
                if (bs[j]) {
                    if (bs[p.first] != p.second) {
                        b = false;
                        break;
                    }
                }
            }
        }
        if (b) ans = max(ans,(int)bs.count());
    } 

    cout << ans << endl;


    return 0;
}

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

int main() {
  int n;
  long x,pa=0;
  cin>>n>>x;
  long long ans=0;
  rep(i,n){
    long a;
    cin>>a;
    if(pa+a>x){
      ans+=pa+a-x;
      a=x-pa;
    }
    pa=a;
  }
  cout<<ans<<endl;
}


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

int main(){
    int n,s=0;
    cin>>n;
    string str=to_string(n);
    for(int i=0;i<str.size();++i){
        s+=str[i]-'0';
    }
    if(n%s==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define double long double
#define pb push_back
#define ff first
#define ss second
#define PI acos(-1)
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define sp fixed<<setprecision
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int MOD = (1e9)+7;
const int N = 1000005;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n,x;
        cin>>n;
        int a[n+1]={};
        for(int i=1;i<n;i++)cin>>x,a[x]++;
        for(int i=1;i<=n;i++)cout<<a[i]<<endl;
    }
    return 0;
}
/*
Test Case
*/


Measured memory_bytes: 5180
H,W = map(int,input().split())
s=[list(input()) for i in range(H)]
def ts(s):
  ss=[]
  for i in range(len(s)):
    if s[i] != ["."]*len(s[i]):
      ss.append(s[i])
  return ss
sH = ts(s)
sH = list(map(list,zip(*sH)))
sW = ts(sH)
sW = list(map(list,zip(*sW)))
for i in range(len(sW)):
  print("".join(sW[i]))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;
template <typename T>
T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T>
T lcm(T a, T b) { T g = gcd(a, b); return a * b / g; }

void solve()
{
    int n; cin >> n;
    string s; cin >> s;
    string colors = "RGB";
    map<char,int> clrs;
    rep(i, 3)clrs[colors[i]] = i+1;
    vector<vector<int>> sum(3, vector<int>(n + 1, 0));
    rep(i, 3)rep(j, n)
    {
        if(s[j] == colors[i])sum[i][j+1] = sum[i][j] + 1;
        else sum[i][j+1] = sum[i][j];
    }
    ll ans = 0;
    rep(i, n - 2)mrep(j, i + 1 ,n - 1)
    {
        if(s[i] == s[j])continue;
        int k = 6/clrs[s[i]]/clrs[s[j]];
        k--;
        ans += sum[k][n] - sum[k][j + 1];
        if(2*j-i < n && s[2*j-i] == colors[k])ans--;
    }
    cout << ans << endl;
    return;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b){
  if(b==0) return a;
  if(a%b==0) return b;
  else return gcd(b, a%b);
}
int main(){
  int n, ans=0;
  cin >> n;
  int a[n], l[n+1], r[n+1];
  l[0]=0;
  r[n]=0;
  for(int i=0; i<n; i++)
    cin >> a[i];
  for(int i=0; i<n; i++){
    l[i+1]=gcd(l[i], a[i]);
    r[n-1-i]=gcd(r[n-i], a[n-1-i]);
  }
  for(int i=0; i<n; i++){
    int m=gcd(l[i], r[i+1]);
    if(m>ans) ans = m;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int INF = 10000000;

int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

    rep(i, n) {
        cin >> a[i];
        if(a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans = 1;
    rep(i, n){
        if(a[i] <= 1000000000000000000 / ans) {
            ans *= a[i];
        }else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4028
calcArea :: Int -> Int -> Int
calcArea a b = a * b

calcPerimeter :: Int -> Int -> Int
calcPerimeter a b = (a + b) * 2

main = do
  line <- getLine
  let 
    [a,b] = map read $ words line :: [Int]
    area = calcArea a b
    perimeter = calcPerimeter a b
  putStrLn $ show area ++ " " ++ show perimeter


Measured memory_bytes: 3656
n = int(input())
x = [input().split() for i in range(n)]

mm = 0
flag = 1

if int(x[0][0]) < int(x[0][1]) + int(x[0][2]):
    flag = 0
else:
    if int(x[0][0])%2 != (int(x[0][1]) + int(x[0][2]))%2:
        flag = 0
    else:
        for i in range(n-1):
            if int(x[i+1][0])-int(x[i][0]) < int(x[i+1][1]) +int(x[i+1][2])-int(x[i][1])-int(x[i][2]):
                flag = 0
                break
            else:
                if (int(x[i+1][0])-int(x[i][0]))%2 != (int(x[i+1][1]) +int(x[i+1][2])-int(x[i][1])-int(x[i][2]))%2:
                    flag = 0
                    break            

if flag == 1:
    print("Yes")
else:
    print("No")
    



Measured memory_bytes: 32144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>

using namespace std;

typedef long long    ll;
typedef long double  ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

template <typename T> bool chmax(T &a, T& b) {if (a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, T& b) {if (a > b) {a = b; return true;} return false;}
#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define mset(x, val) memset(x, (val), sizeof(x))
#define cons(a, b) make_pair((a), (b))
#define car first
#define cdr second

#define endl '\n'
#define INF  0x7f7f7f7f7f7f7f7f
#define INFi 0x7f7f7f7f


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll solve(vector<char> a) {
  return count(all(a), '1');
}

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

  vector<char> a(3);
  cin >> a[0] >> a[1] >> a[2];

  auto ans = solve(a);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <algorithm>
#include<vector>

using namespace std;

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

bool used[1010101];
vector<int>primes;
void era() {
	for (int i = 2; i < 1e6; i++) {
		if (!used[i]) {
			primes.push_back(i);
			for (int j = i; j < 1e6; j += i)used[j] = true;
		}
	}
}
signed main() {
	int N; cin >> N;
	vector<int>A(N);
	era();
	REP(i, N) {
		cin >> A[i];
		if (A[i] == 1)continue;
		primes.push_back(A[i]);
	}
	int M = primes.size();
	long long ans = 0;
	REP(i, M) {
		int tmp = 0;
		REP(j, N) {
			if (A[j] % primes[i] == 0)tmp += A[j];
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}


Measured memory_bytes: 4892
//Longest Increasing Subsequence
#include <iostream>

using namespace std;

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

    int dp[n+1];
    int length = 0;
    dp[length] = A[0];

    for(int i=1; i<n; i++) {
        if(A[i] > dp[length]) dp[++length] = A[i];
        else *lower_bound(dp, dp+length, A[i]) = A[i];
    }

    cout << length+1 << endl;

    return 0;
}


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

int main(){
  int n;cin>>n;
  string s;cin>>s;
  rep(i,s.size()){
    s[i] = 'A' + (s[i]-'A'+n)%26;
  }
  cout<<s<<endl;
}

Measured memory_bytes: 3664
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define TRUE 1
#define FALSE 0

#define MOD 1000000007

typedef struct _words {
	int size;
	char *s;
} words;

int main(void) {
	long int answer = 1;
	int alphabets[26];
	for (int i = 0; i < 26; i++) {
		alphabets[i] = 1;
	}
	words w;
	scanf("%d", &(w.size));
	w.s = (char *)malloc(sizeof(char) * w.size);
	scanf("%s", w.s);
	for (int i = 0; i < w.size; i++) {
		alphabets[(int)(w.s[i]) - 97]++;
	}
	for (int i = 0; i < 26; i++) {
		answer = (answer * alphabets[i]) % MOD;
	}
	answer -= 1;
	if (answer == -1) {
		answer += MOD;
	}
	printf("%ld\n", answer);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
//		System.out.println(a/b + " " + a % b + " " + String.format("%.5f", (float)a/b));
//		System.out.printf("%d %d %.10f%n", a/b, a%b, (double)a/(double)b);
		System.out.printf("%d %d %f%n", a/b, a%b, (double)a/b);
// 		System.out.printf("%d %d %d%n", a/b, a%b, BigDecimal.valueOf(double)a/b.toPlainString());
		
	}

}


Measured memory_bytes: 26496
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//Private Teacher
public class Main{

	long augumentPath(int v, int t, long f, long[][] cap, boolean[] used){
		if(v==t)return f;
		used[v] = true;
		for(int i=0;i<cap[v].length;i++){
			if(cap[v][i]>0 && !used[i]){
				long d = augumentPath(i, t, Math.min(f, cap[v][i]), cap, used);
				if(d>0){
					cap[v][i] -= d;
					cap[i][v] += d;
					return d;
				}
			}
		}
		return 0;
	}
	
	long maxFlow(int s, int t, long[][] cap){
		long flow = 0;
		int n = cap.length;
		boolean[] used = new boolean[n];
		while(true){
			Arrays.fill(used, false);
			long f = augumentPath(s, t, Integer.MAX_VALUE, cap, used);
			if(f==0)return flow;
			flow += f;
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		String[] day = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
		Map<String, Integer> ref = new HashMap<String, Integer>();
		for(int i=0;i<7;i++)ref.put(day[i], i);
		for(;;){
			int n = sc.nextInt();
			long W = sc.nextLong();
			if((n|W)==0)break;
			long[][] cap = new long[n+9][n+9];
			for(int i=1;i<=7;i++)cap[0][i]=W;
			long s = 0;
			for(int i=0;i<n;i++){
				long t = sc.nextLong();
				s += t;
				cap[i+8][n+8] = t;
				int c = sc.nextInt();
				while(c--!=0)cap[ref.get(sc.next())+1][i+8] = W;
			}
			System.out.println(maxFlow(0, n+8, cap)==s?"Yes":"No");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main(){
  int n;
  double t, a;
  cin >> n >> t >> a;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h[i];
  double min = 1e9, ans = 0;
  int min_index = 0;
  for(int i = 0; i < n; i++){
    ans = abs((t - h[i] * 0.006) - a);
    if(ans < min){
      min = ans;
      min_index = i + 1;
    }
  }
  cout << min_index << endl;
  return 0;
}

Measured memory_bytes: 3764
s = input()
l = list(s)
l = [int(x) for x in l]
dp = [[0, 0] for i in range(len(s))]
dp[0][0] = l[0]
dp[0][1] = 11 - l[0]
for i in range(1, len(s)):
  dp[i][0] = min(dp[i - 1][0], dp[i - 1][1]) + l[i]
  dp[i][1] = min(dp[i - 1][0] + 11 - l[i], dp[i - 1][1] + 9 - l[i])
print(min(dp[-1][0], dp[-1][1]))

Measured memory_bytes: 155076
/*
	 
	                              Jai Shree Krishna !!
	                                 Radhe Radhe !!
	                                 
	             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
	             
	*/
	   
	   
	#include <bits/stdc++.h>
	using namespace std;
	 
	#define int long long
	typedef long long ll;
	#define loop(i,n)  for(int i=0;i<n;i++)
	#define read(a) int a; cin >>a;
	#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
	#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];
	#define pb push_back
	#define ff first
	#define ss second
	#define vi vector<int>
	#define pi pair<int,int>
	#define vvi vector<vector<int>>
	#define sti set<int>
	#define vpi vector<pair<int,int>>
	#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
	#define printmat(a,n,m) for(int i=0;i<n;i++) {for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
	#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
	#define endl "\n"
	#define mp make_pair
	#define ins insert
	#define rep(i,s,e)   for(int i=s;i<=e;i++)
	#define repd(i,s,e)  for(int i=e;i>=s;i--)
	#define vb vector<bool>
	#define read2(n,m) int n,m; cin >> n >> m;
	#define range(v) v.begin(),v.end()
	#define sortd(v) sort(v.begin(),v.end(),greater<int>())
	#define sorti(v) sort(v.begin(),v.end())
	 
	const ll inf = 1e18;
	const ll mod = 1e9 + 7;



	signed main()
	{
	 
	    fast;
		read(n);
		
	    int c = n/1000;
	    int r = n%1000;
	    if(r==0) cout<<0<<endl;
	    else{
	    	cout<<(1000-r)<<endl;
	    	
	    }
	    
	    return 0;
	}
	 
	/* Pooja Yadav */

Measured memory_bytes: 3612
N,W=map(int,input().split())
w=[]
v=[]
for i in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)
val_max=sum(v)
dp=[1000000001]*(val_max+1)
#value 0~maxのリスト。それぞれの値はそのvalueを生み出す最小weight
#リストが完成したら後ろから順に見て行き、初めてW以下になったvalueのindex番号がans
dp[0]=0
for i in range(N):
    for j in range(val_max,-1,-1):
        if dp[j]!=1000000001:
            if dp[j]+w[i]<=W:
                dp[j+v[i]]=min(dp[j+v[i]],dp[j]+w[i])

for i in range(val_max,-1,-1):
    if dp[i]!=1000000001:
        print(i)
        break

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

int main() {
int A,B;
cin >> A >> B ;
int C = A + B;
if(A % 3 == 0 || B % 3 == 0 || C % 3 == 0){
cout << "Possible" << endl;
}
else {
    cout << "Impossible" << endl;
}
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{

  int n, i, j, k, a, b;

  scanf("%d",&n);
  int M[n][n];
  int N[n];

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

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

  for(i=1;i<n;i++){
    for(j=0;j<n-i;j++){
      for(k=j;k<i+j;k++){
	a = M[j][k] + M[k+1][i+j] + N[j]*N[k+1]*N[i+j+1];
	if(j==k || a<b){
	  b = a;
	}
	M[j][j+i] = b;
      }
    }
  }

  printf("%d\n",M[0][n-1]);

  return 0;

}

  



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < (n); ++i)

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> net(n);
    vector<pair<int, int>> edges;
    REP(i, m){
        int si, ti;
        cin >> si >> ti;
        si--; ti--;
        net.at(si).push_back(ti);
        edges.emplace_back(si, ti);
    }

    double ans = n + 1;
    for(int ng = -1; ng < n - 1; ++ng){
        if(ng != -1 && net.at(ng).size() == 1){
            continue;
        }
        vector<double> exp(n, 0);
        for(int x = n - 2; x >= 0; x--){

            double tmp = 0;
            double count = 0;
            double maxval = 0;
            for(int nxt : net.at(x)){
                tmp += exp.at(nxt) + 1.0;
                maxval = max(maxval, exp.at(nxt) + 1.0);
                count++;
            }
            if(ng != x){
                exp.at(x) = tmp / count;
            }else{
                exp.at(x) = (tmp - maxval) / (count - 1);
            }
        }
        ans = min(ans, exp.at(0));
    }
    printf("%.8f\n", ans);
    return 0;
}


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

#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define bk back
#define ed endl
#define en cout << endl
#define wl while
#define mod (ll)(1e9 + 7)
#define f(i, a, b) for(ll i = a; i < b; i++)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

int main()
{
    FAST;
    ll n; cin >> n;
    vector<ll> dp(3);
    for(ll day = 0; day < n; day++)
    {
      vector<ll> new_dp(3);
      vector<ll> c(3);
      for(int i = 0; i < 3; i++) cin >> c[i];
      for(int i = 0; i < 3; i++)
            for(int j = 0; j < 3; j++)
                if(i!=j)
                    new_dp[j] = max(new_dp[j], dp[i]+c[j]);

        dp = new_dp;//cout << dp[0] << " " << dp[1] << " " << dp[2] << "\n";
    }


    cout << max({dp[0],dp[1],dp[2]});

    return 0;
}


Measured memory_bytes: 256
n =int(input())
a,b = map(int,input().split())
p= list(map(int,input().split()))

ans = [0,0,0]
for i in range(n):
    if p[i] <= a:
        ans[0]+= 1
    elif p[i]<=b:
        ans[1]+=1
    else:
        ans[2] += 1
print(min(ans))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>

using namespace std;

struct Item {
  int weight;
  int value;
};

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

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

int dp[105][10005];

int main()
{
  vector<Item> item_array;
  int n, W;
  cin >> n >> W;

  item_array.resize(n);
  for (int i = 0; i < n; i++) {
    int weight, value;
    cin >> item_array[i].value >> item_array[i].weight;
  }

  for (int i = 0; i < 10005; i++) {
    dp[0][i] = 0;
  }

  for (int i = 1; i <= n; i++) {
    for (int w = 0; w <= W; w++) {
      if (w - item_array[i - 1].weight >= 0) {
        chmax(dp[i][w], dp[i - 1][w - item_array[i - 1].weight] + item_array[i - 1].value);
      }
      chmax(dp[i][w], dp[i - 1][w]);
    }
  }

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

  return 0;
}



Measured memory_bytes: 7044
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def solve():
    record = list(map(int,input().split()))
    while record[-1] != 0:
        record += list(map(int,input().split()))
    number_of_room = sum(1 if r > 0 else 0 for r in record) + 1
    G = [[] for _ in range(number_of_room)]
    deg = [0] * number_of_room
    parents = [-1] * number_of_room
    dist = [1000] * number_of_room
    dist[1] = 0

    now = 1
    cnt = 0
    for r in record[:-1]:
        if r > 0:
            cnt += 1
            if cnt > 1:
                G[cnt].append(now)
                G[now].append(cnt)
                deg[now] -= 1
                dist[cnt] = dist[now] + 1
                parents[cnt] = now
                deg[cnt] = r - 1
            else:
                deg[cnt] = r
            now = cnt
            while deg[now] <= 0 and now >= 0:
                now = parents[now]
        else:
            i = parents[now]
            while True:
                if dist[i] - dist[now] == r:
                    G[now].append(i)
                    G[i].append(now)
                    deg[i] -= 1
                    deg[now] -= 1
                    while deg[now] <= 0 and now >= 0:
                        now = parents[now]
                    break
                i = parents[i]
    
    for i in range(1,number_of_room):
        G[i].sort()
        print(i,*G[i])      

def main():
    N = int(input())
    for _ in range(N):
        solve()
    
if __name__ == '__main__':
    main()


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int a, b; cin >> a >> b;
    cout << 6 - (a + b) << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
if b < c:
    if a == 1:
        print(0)
        exit()
    if a == 2:
        print(1)
        exit()
    else:
        print(abs((a - 2) * b - (a - 2) * c) + 1)
elif b > c:
    print(0)
    exit()
else:
    print(1)
    exit()


Measured memory_bytes: 3060
#include <cmath>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const int maxn=101000;
const ll maxx=1e9+10;
ll h,w;
int n;
struct node{
    ll ai,bi;
};
ll ans[10];
node sum[maxn];
map<ll,ll>mp;
map<ll,ll>mp1;

bool cmp(node n1,node n2){
    if(n1.ai==n2.ai) return n1.bi<n2.bi;
    else return n1.ai<n2.ai;
}

void solve(ll x1,ll y11,int x2,int y2){
     ll xx=x1-x2+1,yy=y11-y2+1;
     if(xx+2>h||yy+2>w||xx<1||yy<1) return;
     if(mp[xx*maxx+yy]) return;
     int cnt=0;
     for(int i=1;i<=3;i++){
         for(int j=1;j<=3;j++){
             ll f1=xx+i-1;
             ll f2=yy+j-1;
             if(mp1[f1*maxx+f2]==1) cnt++;
         }
     }
     mp[xx*maxx+yy]=1;
     ans[cnt]++;
}


int main(){
    scanf("%lld%lld%d",&h,&w,&n);
    for(int i=1;i<=n;i++) scanf("%lld%lld",&sum[i].ai,&sum[i].bi);
    for(int i=1;i<=n;i++) mp1[sum[i].ai*maxx+sum[i].bi]=1;
    sort(sum+1,sum+n+1,cmp);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=3;j++){
            for(int k=1;k<=3;k++){
                solve(sum[i].ai,sum[i].bi,j,k);
            }
        }
    }
    ll tmp=0;
    for(int i=1;i<=9;i++) tmp+=ans[i];
    ans[0]=(h-2)*(w-2)-tmp;
    for(int i=0;i<=9;i++) printf("%lld\n",ans[i]);
    return 0;
}

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

int gcd(int x, int y){
  if(x<y){
    swap(x,y);
  }
  while(y>0){
    int r = x%y;
    x = y;
    y = r;
  }
  return x;
}

int main(){
  int x, y;
  cin >> x >> y;
  int a = gcd(x,y);
  int x1 = x/a+1;
  int y1 = y/a+1;

  if(x1==y1)
    cout << x+1 << endl;
  else
    cout << (x1+y1-3)*a+1 << endl;

  return 0;
}



Measured memory_bytes: 3100
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>

using namespace std;

int main()
{
    int n;
    int t1 = 0, t2 = 0;
    cin>>n;
    for(int i = 1; i <= n; i++)
    {
        int a;
        cin>>a; 
        if(a % 4 == 0)
            t1++;
        else if(a % 2 == 0)
            t2++;
       
    }
    if(t1 + t2 / 2 < n / 2)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
constexpr int mod = 1000000007;
constexpr int inf = 1e9;
int k, a, b;
int main(){
	cin>>k>>a>>b;
	for(int i = a; i <= b; ++i)if(i % k == 0){cout<<"OK"<<endl;return 0;}
	cout<<"NG"<<endl;
	

	 
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int front = 0, back = 0, ans;
  string s;

  cin >> s;

  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'A'){
      front = i;
      break;
    }
  }

  for(int i = s.size()-1; 0 < i; i--){
    if(s[i] == 'Z'){
      back = i;
      break;
    }
  }

  ans = back - front + 1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
N = int(input())
h = list(map(int, input().split()))
a = list(map(int, input().split()))

num = 2**((N+1).bit_length())

seg = [0]*(2*num-1)

#update(i,x):Aiをxに更新する
def update(i,x):
    k = i + num - 1
    while k >= 0:
        seg[k] = max(x,seg[k])
        k = (k-1)//2

#query(a,b,0,0,num):[a,b)の最大値
def query(a,b,k,l,r):
    if r <= a or b <= l:
        return -1
    elif a <= l and r <= b:
        return seg[k]
    else:
        return max(query(a,b,2*k+1,l,(l+r)//2),query(a,b,2*k+2,(l+r)//2,r))


for i in range(N):
    update(h[i], query(0,h[i],0,0,num) + a[i])

print(max(seg))

Measured memory_bytes: 124880
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const int INF = 1001001001;

int main() {
  int X;
  cin >> X;
  vector<bool> expo(X + 1);

  expo[1] = true;
  repe(b, 2, X) {
    int v = b * b;
    while (v <= X) {
      expo[v] = true;
      v *= b;
    }
  }

  for (int i = X; i >= 1; i--) {
    if (!expo[i]) continue;
    cout << i << endl;
    return 0;
  }
}


Measured memory_bytes: 3572
// atc.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <string>
#include    <algorithm>
using namespace std;

int main()
{
    int n,l;
    vector<string> A;
    bool flg = false;
    cin >> n>>l;

    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        A.push_back(s);
    }

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

    for (int i = 0; i < n; i++) {
        cout << A[i];
    }

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;


int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   pair<ld,ld> arr[n];
   set<ld> st;
   st.insert(-inf);
   rep(n)
   {
       ll x,l;
       cin>>x>>l;
       arr[i] = mp(x-l+(ld)0.1,x+l-(ld)0.1);
       st.insert(x-l+(ld)0.1);
       st.insert(x+l-(ld)0.1);
       st.insert(x-l+(ld)0.1+0.1);
       st.insert(x-l+(ld)0.1-0.1);
       st.insert(x+l-(ld)0.1+0.1);
       st.insert(x+l-(ld)0.1-0.1);
   }
   
   vector<ld> hold;
   autoit(st,it)
        hold.pb(*it);
   
   map<ld,ll> ma;
   rep(hold.size())
        ma[hold[i]] = i;
   
   ll l = hold.size();
   ll dp[l+1];
   memset(dp,0,sizeof(dp));
   vector<pair<ld,ld>> inte[l];
   sort(arr,arr+n);
   for(ll i=0;i<n;i++)
        inte[ma[arr[i].ff]].pb(arr[i]);
   //cout<<"l = "<<l<<"\n";
   ll ans = 0;
   for(ll i=1;i<l;i++)
   {
       ll cnt = 0;
       autoit(inte[i],it)
       {
           if(cnt)
                break;
           auto curr = *it;
           ll temp = dp[ma[curr.ff-0.1]];
           ans = max(ans, temp+1);
           dp[ma[curr.ss]] = max(dp[ma[curr.ss]], temp + 1);
           cnt++;
       }
       
       dp[i] = max(dp[i], dp[i-1]);
   }
   
   cout<<ans;
        
   
   return 0;        
}  
   

Measured memory_bytes: 121704
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()
	a := readInt()
	b := readInt()
	if (n * a) <= b {
		fmt.Println(n * a)
	} else {
		fmt.Println(b)
	}
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, e := strconv.Atoi(read())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
L = int(input())
r = 0
while 1:
    r += 1
    if 2**r > L or r == 20:
        N = r
        break

path = []
for i in range(1,N):
    path.append([i, i+1, 0])
    path.append([i, i+1, 2**(i-1)])

for t in range(N-1,0,-1):
    if L - 2**(t-1) > 2**(N-1)-1:
        path.append([t, N, L - 2**(t-1) ])
        L -= 2**(t-1)


M = len(path)
print("{} {}".format(N, M))
for i in range(M):
    print(" ".join(map(str,path[i])))

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for ( int i = 0; i < n; ++ i) {
    cin >> a[i];
  }
  vector<int> b = a;
  sort(b.begin(), b.end());
  map<int, int> pt;
  for ( int i = 0; i < n; ++ i) {
    pt[b[i]] = i & 1;
  }
  int ans = 0;
  for ( int i = 0; i < n; ++ i) {
    if( (i&1)^pt[a[i]]) {
      ++ ans;
    }
  }
  cout << (ans >> 1) << "\n";
  return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    string S; cin >> S;
    map<char, int> M;
    rep(i, 0, S.size()){
        if(M[S[i]] > 0){
            cout << "no" << endl;
            return 0;
        }
        M[S[i]]++;
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

K, A, B = map(int, input().split())

if K == 1:
    print(2)
elif B - A < 3:
    # 2回かけるので3以上増えないと意味ない
    print(1+K)
else:
    # b < Aまでは+1で増やす (A-1回)
    # b >= Aなら2回で-A+B増やす

    # -A+Bを行える回数を調べる
    d = K - A + 1
    if d % 2 == 0:
        res = A + (d//2)*(B-A)
    else:
        res = A+1 + (d//2)*(B-A)

    print(res)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
	int n,k;
	cin >> n >> k;
	int a;
	map<int, int> mp;
	REP(i,n){
		cin >> a;
		mp[a]++;
	}
	vector<int> vec;
	for(auto i : mp){
		vec.push_back(i.second);
	}
	if(vec.size() <= k){
		cout << 0 << endl;
		return 0;
	}
	sort(ALL(vec));
	int ans = 0;
	REP(i,vec.size() - k){
		ans += vec[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 10748
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
	char x,y;
	cin >> x >> y;
	if(x>y)cout << ">" << endl;
	else if(x==y)cout << "=" << endl;
	else cout << "<" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		String a = "Yes";
		for(int i=0; i<S.length(); i+=2) {
			if(S.charAt(i)=='L'){
				a = "No";
			}
		}
		for(int i=1; i<S.length(); i+=2) {
			if(S.charAt(i)=='R'){
				a = "No";
			}
		}
		System.out.println(a);

	}

}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 2);
    a[0] = a[n + 1] = 0; 
    rep(i, 0, n) cin >> a[i + 1];
    int total = 0;
    rep(i, 0, n + 1) total += abs(a[i + 1] - a[i]);

    rep(i, 0, n)
    {
        int cost = total;
        cost -= abs(a[i + 1] - a[i]);
        cost -= abs(a[i + 2] - a[i + 1]);
        cost += abs(a[i + 2] - a[i]);
        cout << cost << endl;
    }
    return 0;
}

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

int main(){
  long int N, X, M;
  cin >> N >> X >> M;
  vector<long int> B(M+1);
  vector<long int> C(M);
  long int ans = 0;
  int f = 0;
  for (int i = 1; i <= N; i++){
  	B[i] = B[i-1] + X;
    if (C[X] != 0){
      ans += ((N-C[X]+1) / (i-C[X])) * (B[i-1] - B[C[X]-1]);
      ans += B[C[X] + (N-C[X]+1) % (i-C[X]) - 1];
      f = 1;
      break;
    }
    else{
    	C[X] = i;
    }
    X = X * X % M;
  }
  if (f == 1)
    cout << ans << endl;
  else
    cout << B[N] << endl;
  return 0;
}

Measured memory_bytes: 4704
#include "iostream"

using namespace std;

int main()
{
	int n[3];
	cin >> n[0] >> n[1] >> n[2];
	if (n[0] > n[1]) {
		int m = n[0];
		n[0] = n[1];
		n[1] = m;
	}
	if (n[1] > n[2]) {
		int m = n[1];
		n[1] = n[2];
		n[2] = m;
	}
	if (n[0] > n[1]) {
		int m = n[0];
		n[0] = n[1];
		n[1] = m;
	}
	cout << n[0] << " " << n[1] << " " << n[2] << endl;

    return 0;
}

Measured memory_bytes: 1164
/*
 Author:Alokit Kumar
   */
  #include<bits/stdc++.h>
  using namespace std;
  #define int long long 
  int32_t main()
  {
    int n,m,i,j,k,l,q,s=0;
    cin>>n>>k>>q;
    map<int,int> m1;
    for(i=1;i<=q;i++)
    {
      cin>>l;
      m1[l]++;
    }
   for(i=1;i<=n;i++)
   {
     j=m1[i];
     j=q-j;
     if((k-j)<=0)
      cout<<"No\n";
     else
      cout<<"Yes\n";
   }
  }

Measured memory_bytes: 6912