akhauriyash/Code-Regression huggingface dataset:
/*Program from Luvwgyx*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#define int long long
using namespace std;
const int maxn=1e5+10;
int n,m,K,a[maxn],X[maxn],nxt[maxn],ans[maxn],tmp[maxn];
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void print(int x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
void write(int x){print(x);puts(".0");}
signed main(){
    n=read();
    for(int i=1;i<=n;i++)tmp[i]=read(),X[i]=tmp[i]-tmp[i-1];
    m=read();K=read();
    for(int i=1;i<=m;i++)a[i]=read();
    for(int i=1;i<=n;i++)nxt[i]=i;
    for(int i=1;i<=m;i++)swap(nxt[a[i]],nxt[a[i]+1]);
    for(int i=1;i<=n;i++)ans[i]=i;
    while(K){
        if(K&1){
            for(int i=1;i<=n;i++)tmp[i]=ans[nxt[i]];
            for(int i=1;i<=n;i++)ans[i]=tmp[i];
        }
        for(int i=1;i<=n;i++)tmp[i]=nxt[nxt[i]];
        for(int i=1;i<=n;i++)nxt[i]=tmp[i];K>>=1;
    }
    for(int i=1;i<=n;i++)tmp[i]=X[ans[i]];
    for(int i=1;i<=n;i++)X[i]=tmp[i];int now=0;
    for(int i=1;i<=n;i++)now+=X[i],write(now);
    return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	lli a, b;
	cin >> a >> b;
	if(a <= 0 && b >= 0){
		cout << "Zero" << endl;
	}else if(a > 0 && b > 0) cout << "Positive" << endl;
	else if(a < 0 && b < 0){
		if((b-a+1)%2 == 0)cout << "Positive" << endl;
		else cout << "Negative" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
/*

  _|_|                              _|  _|    _|
_|    _|  _|  _|_|  _|_|_|_|        _|  _|  _|
_|    _|  _|_|          _|          _|  _|_|
_|    _|  _|          _|      _|    _|  _|  _|
  _|_|    _|        _|_|_|_|    _|_|    _|    _|

*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
//#define ls (rt<<1)
//#define rs (rt<<1|1)
#define vi vector<int>
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define fi first
#define se second
typedef long long ll;
const int maxn=2e5+1000;
const int inf=1e9+100;
using namespace std;
vi E[maxn],inset[maxn];
int s=2e5+1,t=2e5+2,cnt=1,head[maxn];
struct gg{
    int u,v,w,next;
}side[maxn*4];
void ins(int u,int v,int w) {
    side[++cnt]=(gg){u,v,w,head[u]};head[u]=cnt;
    side[++cnt]=(gg){v,u,0,head[v]};head[v]=cnt;
}
int rk[maxn],cur[maxn];
queue<int>q;
bool bfs() {
    memset(rk,0,sizeof(rk));rk[s]=1;
    while(!q.empty())q.pop();q.push(s);
    while(!q.empty()) {
        int u=q.front();q.pop();
        for(int i=head[u];i;i=side[i].next) {
            int v=side[i].v;if(rk[v]||!side[i].w)continue;
            rk[v]=rk[u]+1;
            q.push(v);
        }
    }
    if(!rk[t])return 0;
    return 1;
}
int dfs(int u,int flow) {
    if(u==t||!flow)return flow;
    int tot=0;
    for(int &i=cur[u];i;i=side[i].next) {
        int v=side[i].v;//cout<<v<<' '<<rk[v]<<endl;
        if(rk[v]!=rk[u]+1||!side[i].w)continue;
        int sent=dfs(v,min(flow,side[i].w));
        side[i].w-=sent;side[i^1].w+=sent;
        flow-=sent;tot+=sent;
    }
    return tot;
}
int dinic(){
    int maxflow=0;
    while(bfs()){
        memcpy(cur,head,sizeof(cur));
        maxflow+=dfs(s,inf);
    }
    return maxflow;
}
int match[maxn];//match[set_id]=match_point_id
bool inq[maxn];
pii ans[maxn];
int main(){
    //ios::sync_with_stdio(0);
    int n;scanf("%d",&n);//cin>>n;
    rep(i,1,n-1) {
        int c;scanf("%d",&c);//cin>>c;
        rep(j,1,c) {
            int u;scanf("%d",&u);//cin>>u;
            E[i].pb(u);inset[u].pb(i);
            ins(u,n+i,1);
        }
    }
    rep(i,2,n)ins(s,i,1);
    rep(i,1,n-1)ins(n+i,t,1);
    int flow=dinic();
    if(flow!=n-1) {
        printf("-1\n");//cout<<"-1";
        return 0;
    }
    rep(i,n+1,n+n-1) {
        for(int j=head[i];j;j=side[j].next) {
            int v=side[j].v;
            if(v<=n&&side[j].w) {
                match[i-n]=v;break;
            }
        }
    }
    while(!q.empty())q.pop();
    int tot=1;q.push(1);inq[1]=1;
    while(!q.empty()) {
        int u=q.front();q.pop();
        for(int i=0;i<inset[u].size();i++) {
            int setid=inset[u][i],set_match=match[setid];
            if(!inq[set_match]) {
                inq[set_match]=1;ans[setid]=mk(u,set_match);
                q.push(set_match);tot++;
            }
        }
    }
    if(tot!=n) {
        printf("-1\n");//cout<<"-1";
        return 0;
    }
    for(int i=1;i<n;i++) {
        printf("%d %d\n",ans[i].fi,ans[i].se);
        //cout<<ans[i].fi<<' '<<ans[i].se<<endl;
    }
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  int ans;
  if (n%2==0)ans=n/2;
  else ans=n/2+1;
  cout<<ans;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        new Main().run();
    }
    int[] p;

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        p = new int[n];
        for(int i = 0; i < n; i++){
            p[i] = scanner.nextInt();
        }
        int ans = 0;
        for(int i = 1; i < n-1; i++) {
            ans += check(i);
        }
        System.out.println(ans);
    }

    private int check(int i) {
        if((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i+1] < p[i] && p[i] < p[i-1])) {
            return 1;
        }
        return 0;
    }
}

Measured memory_bytes: 23764
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

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; }



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  string S; cin>>S;
  ll N=S.size();
  
  set<char> list; for(auto c:S) list.insert(c);
  ll ans=INF;
  for(auto c:list){
    vector<int> vec(N,0); rep(i,N) if(S[i]==c) vec[i]=1;
    int judge=1; 
    ll sans=0; 
    rep(i,N) if(!vec[i]) judge=0;
    while(!judge){
      ll sz=vec.size();
      vector<int> svec(sz-1,0);
      rep(i,sz-1) if(vec[i]||vec[i+1]) svec[i]=1;
      vec=svec;
      sans++;
      judge=1;
      rep(i,sz-1) if(!vec[i]) judge=0;
    }
    chmin(ans,sans);
  }
  
  cout<<ans<<'\n';
  
  return 0;
}

Measured memory_bytes: 3624
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        a: [i32;5],
    }
    // annotate for rust-analyzer
    let a: Vec<i32> = a;

    let mut i = 0;
    loop {
        if a[i] == 0 {
            break;
        }
        i += 1;
    }

    println!("{}", i + 1);
}


Measured memory_bytes: 2192
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 a, b, c;
  cin >> a >> b >> c;
  if ((a == b && b != c) || (b == c && a != c) || (a == c && a != b))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
/*  
    Talkin' to myself and feelin' old
    Sometimes I'd like to quit, nothin' ever seems to fit
    Hangin' around, nothin' to do but frown
    Rainy days and Mondays always get me down
    _________________________
    _________________________
    912 Hours of Solitude
    Quarantine_Day : 38
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;
typedef pair<ll, ll>		pll;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<int>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 90

ll n;
ll dp[MAX];

ll locus(ll l){
    if(l == 0) return 2;
    if(l == 1) return 1;
    if(dp[l] != -1) return dp[l];

    return dp[l] = locus(l - 1) + locus(l - 2);
}

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

    cin>>n;

    memset(dp, -1, sizeof(dp));
    cout<<locus(n)<<"\n";

    return 0;

}


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

int main() {
  string S;
  int N,a,b,sum=0,num=0;
  cin >> S;
  N = S.size();
  for(int i=0;i<N;i++){
    a = S[i] -'0';
  sum = sum + a; 
  num = num + a * pow(10,N-i-1);
  }
  
  if(num % sum == 0){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  cout << s1[0] << s2[1] << s3[2] << endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main() {
	ll n, c; cin >> n >> c;
	vector<ll> x(n), v(n),xsum(n+1,0),ysum(n+1,0);
	rep(i, 0, n)cin >> x[i] >> v[i];
	rep(i, 0, n) {
		xsum[i + 1] = xsum[i] + v[i];
		ysum[i + 1] = ysum[i] + v[n-1-i];
	}
	vector<ll> max1(n + 1, 0), max2(n + 1, 0);
	rep(i, 0, n) {
		max1[i + 1] = max(max1[i], xsum[i + 1] - x[i]);
		max2[i + 1] = max(max2[i], ysum[i + 1] - (c - x[n - 1 - i]));
	}
	ll ans = 0;
	rep(i, 0, n) {
		ans = max({ ans,xsum[i + 1] - x[i],ysum[i + 1] - (c - x[n - 1 - i]),xsum[i + 1] - 2LL * x[i] + max2[n - 1 - i],ysum[i + 1] - 2L * (c - x[n - 1 - i]) + max1[n - 1 - i] });
	}
	cout << max(ans,0LL) << endl;
	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    int x=0;

    int cn;
    cin >> cn;
    string s;
    cin >> s;
    int mx=0;
    for(int i=0; i<cn; i++){
        if(s[i] == 'I'){
            x++;
            mx = max(mx,x);
        }else if(s[i] == 'D'){
            x--;
        }
    }
    cout << mx << endl;
    return 0;
}

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

#第一項を正とするか負とするかで2パターン
#正
count1 = 0
if A[0] <= 0:
  sum1 = 1
  count1 = 1 - A[0]
else:
  sum1 = A[0]

for i in range(1, N):
  if i % 2 == 0:#和が正になるとき
    if sum1 + A[i] <= 0:
      count1 += 1 - (sum1 + A[i]) 
      sum1 = 1
    else:
      sum1 += A[i]
  if i % 2 == 1:
    if sum1 + A[i] >= 0:
      count1 += 1 + (sum1 + A[i]) 
      sum1 = -1
    else:
      sum1 += A[i]
  #print(count1,sum1)
#負
count2 = 0
if A[0] >= 0:
  sum2 = -1
  count2 = 1 + A[0]
else:
  sum2 = A[0]

for i in range(1, N):
  if i % 2 == 0:#和が負になるとき
    if sum2 + A[i] >= 0:
      count2 += 1 + (sum2 + A[i]) 
      sum2 = -1
    else:
      sum2 += A[i]
  if i % 2 == 1:
    if sum2 + A[i] <= 0:
      count2 += 1 - (sum2 + A[i]) 
      sum2 = 1
    else:
      sum2 += A[i]

print(min(count1, count2))
#print(count1, count2)

Measured memory_bytes: 63472
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
long long N;

int main() {
    long long i, h[100005], d[100005];
    cin >> N;
    h[0]=0;
    d[1]=0;
    d[0]=1000000000;
    for(i=1;i<=N;i++)
        cin>>h[i];
    for (i = 2; i <= N; i++) {
        d[i]=min(d[i-1]+abs(h[i]-h[i-1]),d[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<d[N];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
int N,a,b,c,dp[3][100000+10]={};

signed main(){
  cin >> N;
  cin >> a >> b >> c;
  dp[0][0]=a;
  dp[1][0]=b;
  dp[2][0]=c;
  for(int i=1;i<N;i++){
    cin >> a >> b >> c;
    dp[0][i]=max(dp[1][i-1]+a,dp[2][i-1]+a);//0:a,1:b,2:c
    dp[1][i]=max(dp[0][i-1]+b,dp[2][i-1]+b);
    dp[2][i]=max(dp[0][i-1]+c,dp[1][i-1]+c);
  }
  int ans=max(dp[0][N-1],dp[1][N-1]);
  cout << max(dp[2][N-1],ans) << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#define endl '\n'
using namespace std;
int main()
{
	int H,W,h,w,a,b,c,d;
	
	while(cin>>H>>W>>h>>w) {
	a=H*W;
	b=H*w;
	c=W*h;
	d=h*w;
	cout<<a-(b+c-d)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp;

fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
    }
    // a % b == c
    for i in 1..b {
        if a * i % b == c {
            println!("{}", "YES");
            return;
        }
    }
    println!("{}", "NO");
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(in) in.begin(), in.end()
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll arr[1005], mask[1005], dp[(1<<12) + 5];

int main(){
    FIO;
    ll n, m;    cin >> n >> m;
    for(ll i = 0 ; i < m ; i++){
        ll tmp;
        cin >> arr[i] >> tmp;
        while(tmp--){
            ll x;   cin >> x;   x--;
            mask[i] |= (1<<x);
        }
    }
    for(ll i = 1 ; i < (1<< n) ; i++){
        dp[i] = 1e18;
    }
    for(ll i = 0 ; i < (1<<n) ; i++){
        for(ll j = 0 ; j < m ; j++){
            ll nxt = mask[j] | i;
            dp[nxt] = min(dp[nxt], dp[i] + arr[j]);
        }
    }
    if(dp[(1<<n) - 1] == 1e18){
        dp[(1<<n) - 1] = -1;
    }
    cout << dp[(1<<n)-1] << endl;
    return 0;
}


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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		for(int i=1;i<=5;i++)
		{
			int x=in.nextInt();
			if(x==0)
			{
				System.out.println(i);
			}
		}
	}
}

Measured memory_bytes: 35764
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

const int MA_X = 1e-6;
const int MAxn = 1e5 + 5;

int main(){
    string s;
    cin >> s;
    cout << s[0];
    cout << s.size()-2 << s[s.size()-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <deque>

int main(){
  int N, K;
  scanf("%d", &N);
  scanf("%d", &K);
  std::vector<long long > x(N);
  for (int i=0; i<N; i++){
    scanf("%lld", &x[i]);
  }
  long long ans = 1e10+7;
  for (int i=0; i<N-K+1; i++){
    if(x[i]>0){
      ans = std::min(ans, x[i+K-1]);
    } else if (x[i+K-1]<0){
      ans = std::min(ans, -x[i]);
    } else {
      ans = std::min(ans, 2*abs(x[i])+abs(x[i+K-1]));
      ans = std::min(ans, 2*abs(x[i+K-1])+abs(x[i]));
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 1000000007;

int a[maxn],b[maxn];
int n;

bool check(ll lim, ll m){
  ll cnt = 0;
  for(int i=0;i<n;i++){
    if(a[i]*(ll)b[n-i-1]<=lim)continue;
    ll tt = lim/b[n-i-1];
    cnt+=a[i]-tt;
    if(cnt>m)return false;
  }
  return true;
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  ll m;
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];
  sort(a,a+n);
  sort(b,b+n);
  ll ret = 1000000L * 1000000L;
  ll l = 0, r = ret;
  while(l<=r){
    ll lim = (l+r)>>1L;
    if(check(lim, m)){
      ret = lim;
      r = lim -1;
    } else l = lim+1;
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 1792
import bisect
import sys
input = sys.stdin.readline


n = int(input())
A = [int(input()) for _ in range(n)]
A = A[::-1]
color = [10**10]

for a in A:
    idx = bisect.bisect_right(color, a)
    if idx < len(color):
        color[idx] = a
    else:
        color.append(a)

print(len(color))


Measured memory_bytes: 7840
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
const int D = 60;
ll to[D][200005];

signed main(){
	//cout << fixed << setprecision(10);
	int W,H,x,y,r; cin>>W>>H>>x>>y>>r;
	bool ok=1;
	if(y+r>H || y-r<0)ok=0;
	if(x+r>W || x-r<0)ok=0;
	cout<<(ok ? "Yes":"No")<<endl;

	return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  ll n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }

  vector<vector<int>> V(n);
  rep(j, n) V[j].push_back(j);
  vector<int> idx(n);
  rep(j, n) idx[j] = j;

  ll cnt =
    n * (n - 1) / 2;    // take care not to be overflow
  vector<ll> ans;
  ans.push_back(cnt);

  reverse(all(a));
  reverse(all(b));

  rep(i, m - 1) {
    int aj = idx[a[i]], bj = idx[b[i]];
    if(aj == bj) {
      ans.push_back(cnt);
      continue;
    }

    ll sza = (ll)V[aj].size(), szb = (ll)V[bj].size();
    cnt -= sza * szb;
    ans.push_back(cnt);

    if(sza < szb) swap(aj, bj);
    for(auto x : V[bj]) {
      V[aj].push_back(x);
      idx[x] = aj;
    }
    V[bj].clear();
  }

  reverse(all(ans));
  rep(i, m) printf("%lld\n", ans[i]);
  return 0;
}


Measured memory_bytes: 12916
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)


long max(long a, long b){
  if(a<b) return b;
  else return a;
}

int main(){
  int n,W;
  scanf("%d%d",&n,&W);
  int w[n];
  long v[n];
  F(i,0,n){
    scanf("%d%ld",w+i,v+i);
  }
  long dp[n+1][W+1];
	F(i,0,n+1){
		F(j,0,W+1){
			dp[i][j]=0;
		}
	}
  F(i,0,n){
    F(wi,0,W+1){
			if(wi-w[i] >= 0){
				dp[i+1][wi]=max(dp[i+1][wi],dp[i][wi-w[i]]+v[i]);
			}
			dp[i+1][wi]=max(dp[i+1][wi], dp[i][wi]);
    }
  }
  printf("%ld\n",dp[n][W]);
	return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less

#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cerr << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi  pair    <int,int>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define OO  (ll)1e18
#define EPS 1e-9
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
pii swapii( pii pr ){ return { pr.S , pr.F }; }
ll binEXP( ll x , ll pw , ll MOD = LLONG_MAX );
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 1e5 + 7;

ll x , y;
char arr[1002][1002];
ll   dp [1002][1002];

ll go( ll i , ll j ){

    if ( i == x-1 && j == y-1 ){
        return 1;
    }

    ll& ret = dp[i][j];
    if ( ~ret ) return ret;

    ll ans = 0;
    if ( i+1 < x && arr[i + 1][j] == '.' ){
        ans += go(i+1 , j); ans %= MOD;
    }
    if ( j+1 < y && arr[i][j + 1] == '.' ){
        ans += go(i , j+1); ans %= MOD;
    }
    return ret = ans;
}
int main()
{
    FASTIO //ONLINE__JUDGE();

    cin >> x >> y;
    for ( int i = 0; i < x; ++i ){
        for ( int j = 0; j < y; ++j ) cin >> arr[i][j] , dp[i][j] = -1;
    }

    cout << go(0 , 0);
    return 0;
}

void ONLINE__JUDGE()
{
    #ifndef ONLINE_JUDGE
    freopen( "inp.c"         , "r" , stdin  );
    //freopen( "OutPut.txt"   , "w" , stdout );
    #endif // ONLINE_JUDGE
}

ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  
  int n,k;
  cin >>n>>k;
  map<int,int> mp;
  rep(i,n){
    int a;
    cin >>a;
    mp[a] ++;
  }
  vector<P> imp;
  for(auto p : mp){
    P tmp = make_pair(p.second, p.first);
    imp.push_back(tmp);
  }
  sort(imp);
  int cnt = mp.size() - k;
  int ans = 0;
  rep(i,cnt) ans += imp[i].first;
  cout << ans << endl;
}

Measured memory_bytes: 11768
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	ll n;
	cin >> n;
	ll ans = 0;
	for (ll i = 1; i <= n; i++)
	{
		ll tmp = n / i;
		ans += (i + tmp * i) * tmp / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int selectionsort(int n,int a[])
{
    int count = 0;

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

        }

            int temp = a[minv];
            a[minv] = a[i];
            a[i] = temp;
        if(i != minv)
        {
           
            count++;
        }
        
        
    }
    return count;
}

static const int MAX = 100;

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

    count = selectionsort(n,a);

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

    cout << endl;

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3108
#include<stdio.h>
#include <stdlib.h>
int main()
{
    int n,m,k,p,q;
    scanf("%d",&n);
    scanf("%d",&m);
    k=(n+m)/2;
    p=abs(n-k);
    q=abs(m-k);
    if(p==q)
    {
        printf("%d\n",k);
    }
    else
    {
        printf("IMPOSSIBLE\n");
    }
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int bit = 0;
  cin >> s;
  for(int i = 0;i < s.size();i++){
    bit ^= 1 << s[i] - 'a';
  }
  if(bit)cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>

using namespace std;

char char_shift(char c){
	if (islower(c)){
		return toupper(c);
	}
	return tolower(c);
}

int main(int argc,char *argv[]){
	char buf[1200];
	cin.getline(buf, sizeof(buf));
	string str = buf; 
	transform(str.begin(), str.end(), str.begin(), char_shift);
	cout << str << endl;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

// 攻撃の回数をカウント.
// @param h: モンスター の HP.
// @return: 攻撃の回数.
LL recursive(LL h){
    if(h == 1) return 1;
    else       return 2 * recursive(h / 2) + 1;
}

int main(){
    
    // 1. 入力情報.
    LL H;
    scanf("%lld", &H);
    
    // 2. 攻撃の回数は？
    LL ans = recursive(H);
    
    // 3. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    int n;
    cin>>n;
    set<int> st;
    rep(i,n){
        int a;
        cin>>a;
        if(st.find(a)!=st.end()){
            YES(false);
            return 0;
        }
        st.insert(a);
    }

    YES(true);



}

Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<double> e;
	for (auto i = 0; i < N; ++i)
	{
		double p;
		cin >> p;
		e.push_back((p + 1) * p / (2 * p));
	}

	auto sum = 0.0;
	auto ans = 0.0;
	for (auto i = 0; i < N; ++i)
	{
		sum += e[i];
		if (i < K - 1)
		{
			continue;
		}
		if (i >= K)
		{
			sum -= e[i - K];
		}
		ans = max(ans, sum);
	}
	cout << fixed << setprecision(10) << ans << endl;

	return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <queue>
#include <climits>
using namespace std;


#define MOD 1000000007
using ll = long long;

bool operator<(const pair<int, int>& a, const pair<int, int>& b) {
	if (a.first == b.first) {
		return a.second < b.second;
	}
	return a.first < b.first;
}


const int sqrtN = 512;

struct SqrtDecomposition {
	int N, K;
	vector<int> data;
	vector<int> bucketAdd;
	SqrtDecomposition(int n) : N(n) {
		K = (N + sqrtN - 1) / sqrtN;
		data.assign(K*sqrtN, 0);
		bucketAdd.assign(K, 0);
	}

	// [s, t)
	void add(int s, int t, int x) {
		for (int k = 0; k < K; ++k) {
			int l = k * sqrtN, r = (k + 1) *sqrtN;
			if (r <= s || t <= l) continue;
			if (s <= l && r <= t) {
				bucketAdd[k] += x;
			}
			else {
				for (int i = max(s, l); i < min(t, r); ++i) {
					data[i] += x;
				}
			}
		}
	}

	//[x, y)
	int get(int i) {
		int k = i / sqrtN;
		return data[i] + bucketAdd[k];
	}
};
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, q; cin >> n >> q;
	SqrtDecomposition sd(n);

	for (int i = 0; i < q; ++i) {
		int com; cin >> com;
		if (com == 0) {
			int s, t, x; cin >> s >> t >> x;
			sd.add(s, t+1, x);
		}
		else {
			int t; cin >> t;
			cout << sd.get(t) << endl;
		}
	}
	int a; cin >> a;
	return 0;
}


Measured memory_bytes: 3344
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    string s;
    cin >> s;
    int n = s.size(), cnt['z'+1] = {};
    fore(i,0,n) cnt[s[i]]++;
    bool ok = true;
    fore(i,'a','z'+1) if (cnt[i]&1) ok = false;
    if (ok) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main() {
  int n;
  while(cin >> n && n) {
    set<int> st;
    int cnt[5000] = {};
    for(int i=0; i<n-1; i++) {
      st.insert( (i+1)*(i+1) % n );
    }
    
    int const size = st.size();
    
    vector<int> vec;
    set<int>::iterator it = st.begin();
    for(it; it!=st.end(); it++) vec.push_back(*it);
    
    for(int i=0; i<size-1; i++) {
      for(int j=i+1; j<size; j++) {
	int temp = vec[i] - vec[j];
	if(temp < 0) { temp += n; }
	if(temp > (n-1)/2) { temp = n - temp; }
	cnt[temp] ++;
      }
    }
    
    for(int i=1; i<=(n-1)/2; i++) {
      cout << cnt[i]*2 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1532
import java.util.*;

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

        int n = sc.nextInt();
        int N = n;

        int S = 0;
        do{
            S += ( N - ((N / 10) * 10));
            N /= 10;
        }while(N > 0);

        String ans = (n % S == 0)? "Yes" : "No";

        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
# B - AtCoDeerくんとボール色塗り
def main():
    n, k = map(int,input().split())

    for i in range(n):
        if i == 0:
            val = k
        else:
            val *= (k-1)
    else:
        print(val)


if __name__ ==  "__main__":
    main()

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

int main(void) {
  long long N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  long long mi = min({A, B, C, D, E});
  long long steps = ceil(1. * N / mi);

  cout << (5 + steps - 1) << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
S=sys.stdin.readline().strip()
N=len(S)
mod=10**9+7
S=S[::-1]

dp=[ [ 0 for j in range(13) ] for i in range(N) ]

for i,x in enumerate(S):  #i桁目
    if i==0:
        num=pow(10,i,13)
        if x!="?":
            x=int(x)
            dp[i][(x*num)%13]=1
        else:
            for x in range(10):
                dp[i][(x*num)%13]=1
    else:
        num=pow(10,i,13)
        if x!="?":
            x=int(x)
            for j in range(13):
                n=(x*num+j)%13
                dp[i][n]+=dp[i-1][j]
                dp[i][n]%=mod
        else:
            for j in range(13):
                for x in range(10):
                    n=(x*num+j)%13
                    dp[i][n]+=dp[i-1][j]
                    dp[i][n]%=mod
print dp[N-1][5]%mod


Measured memory_bytes: 50588
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 3000;
Int dp[max_n][max_n];

Int S[max_n];
Int T[max_n];

int main(void) {
    int N,M;
    cin>>N>>M;

    dp[0][0] = 1;
    for(int i = 1;i <= N;i++) {
        dp[i][0] = 1;
        cin>>S[i];
    }
    for(int i = 1;i <= M;i++) {
        dp[0][i] = 1;
        cin>>T[i];
    }

    for(int i = 1;i <= N;i++) {
        for(int j = 1;j <= M;j++) {
            if(S[i] == T[j]) {
                dp[i][j] = (dp[i-1][j]+dp[i][j-1])%MOD;
            } else {
                dp[i][j] = (MOD + dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])%MOD;
            }
        }
    }

    cout<<dp[N][M]<<endl;


    return 0;
}


Measured memory_bytes: 46976
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader bf =new BufferedReader(new InputStreamReader(System.in));
		int[] p = new int[5];
		int n;
		String t;
		String[] ps = new String[5];
		while((t=bf.readLine())!=null){
			ps=t.split(" ");
			for(int i=0;i<5;i++)p[i]=Integer.parseInt(ps[i]);
			for(int i=0;i<5;i++){
				for(int j=4;j>i;j--){
					if(p[j]>p[j-1]){n=p[j];p[j]=p[j-1];p[j-1]=n;}
				}
			}
			for(int i=0;i<5;i++)System.out.print((i>0?" ":"")+p[i]);
			System.out.print("\n");
		}

	}
}

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,K;
  cin>>N>>K;
  //ボーナス最優先かポイント最優先、のほかに、塩梅があるはず
  //N=Kなら全とり
  //K=1ならポイント
  //K=2なら、2番目にポイント高いやつか、もし種類の違うのがあればそれを考慮して2番目に高い奴か。
  //K=3なら、3番目にポイント高い奴か、種類が2なのか3になるのか。DP？
  //1種類、2種類、3種類、ごとの最高点を更新とか。むりそう。
  //別種類でポイントが高いものをとるか、種類関係なくポイントを取るか、の2択か。
  //複合の場合どうするか･･･。
  //10万種類あって、種類しばりしたとして、10万Ck通りは無理。
  //逆算的に考える
  //何種類合って、何個とれるのか。10種合って8個だったら8種類の64点ボーナスが最大。
  //7種にすると15点減点。8位と7位の差が15かどうか確認
  //そもそも8種とる時点でどれだけロストしてるかは未知数か
  //基準がいる？として、ポイント高い順にとってみる
  //いれかえするとき、種類被りの判定結構大変･･･。
  //少なくともポイントが一番高いやつ1個の獲得は確実。
  //次とるやつはポイントか、ボーナス＋3で比較、でOKか。
  //そうなると、ボーナス有利のやつがあとからきいてきて既存順位のいれかえまでおきうる。。
  //mapで特徴づけ？ポイントソートしたい、二次元配列か。種類はbool配列か
  //種類ごとに、個数と全得点を累積和で用意するか。
  //とる、とらない、の二択？
  //二次元配列で、ポイントと種類とでソート。
  
  //とりあえず最大ポイントでとる
  //種類かぶりの最小をはずして、別種類のものをほかからとる。最大値評価
  //全種類になるまで実施して終了
  
  //mapで種類と個数を管理？
  //二次元配列でポイントと種類を管理？
  //入力時に何種類あるかをboolで管理？
  //もう使ってる種類はpriorityqueueから省きたい
  
  //指定個数分、最大ポイントからとる。
  //そのとき、何の種類をとったかも把握。個数も。map管理がいいかも
  //同じ種類のあまりものはすべて除外
  //それ以外のうち、その種類の中で値が最大ポイントのものだけpriority_queueにいれる
  //指定個数までもしくは全種類になるまで入れ替え。順次最大値評価してクリア。
  
  vector<vector<ll>> Z(N,vector<ll>(2,0));
  for(int i=0; i<N; i++){
    ll t,d;
    cin>>t>>d;
    Z[i][0]=t;
    Z[i][1]=d;
  }
  sort(Z.begin(), Z.end(), [](auto& x, auto& y){return x[1] > y[1];});
  unordered_map<int,int> mp;
  ll type=0, pnt=0, ans=0;
  for(int i=0; i<K; i++){
    int tmp;
    pnt+=Z[i][1];
    mp[Z[i][0]]++;
    if(mp[Z[i][0]]==1)
      type++;
  }
  ans=pnt+type*type;
  priority_queue<int> pq;
  for(int i=0; i<N; i++){
    if(mp[Z[i][0]]>0)
      continue;
    pq.push(Z[i][1]);
    mp[Z[i][0]]=1;
  }
  for(int i=K-1; i>=0; i--){
    if(mp[Z[i][0]]<=1)
      continue;
    if(pq.empty())
      break;
    pnt-=Z[i][1];
    pnt+=pq.top();
    pq.pop();
    mp[Z[i][0]]--;
    type++;
    ans=max(ans, pnt+type*type);
  }
  cout<<ans<<endl;
}


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

int main(){
    int N;
    long long ans1=1,ans2=2,ans3=1;
    cin>>N;
    for(int i=0;i<N;i++){
        ans1 *= 10;
        ans1 %= int((pow(10,9.0)+7));
    }
    for(int i=0;i<N;i++){
        ans2 *= 9;
        ans2 %= int((pow(10,9.0)+7));
    }
    for(int i=0;i<N;i++){
        ans3 *= 8;
        ans3 %= int((pow(10,9.0)+7));
    }
    // ans2 = (2*ans2)%int((pow(10,9.0)+7));
    // cout<<ans1<<endl;
    // cout<<ans2<<endl;
    // cout<<ans3<<endl;
    // cout<<(ans1-ans2+ans3)<<endl;
    if((ans1-ans2+ans3)<0){
        ans2 = ans2-int((pow(10,9.0)+7));
    }
    cout<<(ans1-ans2+ans3)%int((pow(10,9.0)+7))<<endl;
    
}

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

using namespace std;

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

    map<char, int> m;
    for (char c : s) {
        m[c]++;
    }

    for (char c : string("abc")) {
        if (m[c] != 1) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"


template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef cc_hash_table<int, int, hash<int > > ht;


#define int long long 
#define  st first
#define  nd second

const int M = 1000000007;
const int  maxn = 100001;
const int  inf =  1e16;

int modular_pow(int  base, int exponent, int modulus=M)
{
    int result = 1;
    while (exponent > 0)
    {
        if (exponent % 2 == 1)
            result = (result * base) % modulus;
        exponent = exponent >> 1;
        base = (base * base) % modulus;
    }
    return result;
}
void solve(){
  int n ; 
  cin >> n ;
  int ans = 0 ; 
  ans = (ans + ((2*modular_pow(9,n))%M))%M;
  ans = ((ans - modular_pow(8,n))%M +M)%M;
  ans = ((modular_pow(10,n)-ans)%M +M)%M;
  cout << ans;
  

}
int32_t main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int te ; 
 // cin >> te ;
  te = 1; 
  while(te--){
    solve();
  }
  
  }

  
  

Measured memory_bytes: 3636
import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

N, X = map(int,input().split())
L = list(map(int,input().split()))
D = [0] * N
for i in range(N):
    D[i] = abs(L[i]-X)

print(gcd(D))


Measured memory_bytes: 16284
import java.lang.Math.sqrt

fun primes(upper:Int):List<Int>{
    val isPrime = Array(upper + 1){true}
    val res = mutableListOf<Int>()
    for (i in 2 .. sqrt(upper.toDouble()).toInt()){
        if (isPrime[i]){
            for (j in 2 * i .. upper step i){
                isPrime[j] = false
            }
        }
    }
    for (i in 6 .. upper step 5 ){
        if (isPrime[i]){
            res.add(i)
        }
    }
    return res
}
fun main(args:Array<String>):Unit{
    val prime = primes(55555)
    val n = readLine()!!.toInt()
    println(prime.subList(0, n).joinToString(" "))
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a == b && b == c && c == a) {
    cout << "No" << endl;
  }
  else if(a == b || b == c || c == a) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;
	int x[m];
	rep(i, m) cin >> x[i];
	
	if (n >= m) {
		cout << 0 << endl;
		return 0;
	}
	
	sort(x, x + m);
	
	if (n == 1) {
		cout << x[m - 1] - x[0] << endl;
		return 0;
	}
	
	int d[m - 1];
	rep(i, m - 1) {
		d[i] = x[i + 1] - x[i];
	}
	
	sort(d, d + m - 1);
	
	int sum = 0;
	rep(i, m - n) sum += d[i];
	
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7,mod1=1e9+9;
const int maxn=600;
char s[maxn+5][maxn+5];
int n;
ll base[maxn+5][maxn+5],base1[maxn+5][maxn+5];
ll pase[maxn+5][maxn+5],pase1[maxn+5][maxn+5];
ll pw[maxn+5],pw1[maxn+5];
ll calb(int h,int l,int r)
{
    ll ans=base[h][r]-base[h][l]*pw[r-l]%mod;
    ans=(ans+mod)%mod;
    return ans;
}
ll calp(int h,int l,int r)
{
    ll ans=pase[r][h]-pase[l][h]*pw[r-l]%mod;
    ans=(ans+mod)%mod;
    return ans;
}
ll calb1(int h,int l,int r)
{
    ll ans=base1[h][r]-base1[h][l]*pw1[r-l]%mod1;
    ans=(ans+mod1)%mod1;
    return ans;
}
ll calp1(int h,int l,int r)
{
    ll ans=pase1[r][h]-pase1[l][h]*pw1[r-l]%mod1;
    ans=(ans+mod1)%mod1;
    return ans;
}
bool check(int x,int y)
{
    for(int i=0;i<n;++i)
    {
        if(calb(x+i,y,y+n-1)==calp(y+i,x,x+n-1)&&calb1(x+i,y,y+n-1)==calp1(y+i,x,x+n-1));else return false;
    }
    return true;
}
int main()
{

    scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%s",s[i]+1);
    for(int i=1;i<=n;++i)
        for(int j=n+1;j<2*n;++j)
            s[i][j]=s[i][j-n];
    for(int j=1;j<2*n;++j)
        for(int i=n+1;i<2*n;++i)
            s[i][j]=s[i-n][j];
    pw[0]=1;
    for(int i=1;i<=2*n;++i) pw[i]=pw[i-1]*131%mod;
    pw1[0]=1;
    for(int i=1;i<=2*n;++i) pw1[i]=pw1[i-1]*233%mod1;
    for(int i=1;i<2*n;++i)
    {
        for(int j=1;j<2*n;++j)
            base[i][j]=(base[i][j-1]*131+s[i][j]-'a')%mod,base1[i][j]=(base1[i][j-1]*233+s[i][j]-'a')%mod1;
    }
    for(int j=1;j<2*n;++j)
    {
        for(int i=1;i<2*n;++i)
            pase[i][j]=(pase[i-1][j]*131+s[i][j]-'a')%mod,pase1[i][j]=(pase1[i-1][j]*233+s[i][j]-'a')%mod1;
    }
  /*  for(int i=1;i<2*n;++i)
    {
        for(int j=1;j<2*n;++j) printf("%c",s[i][j]);printf("\n");
    }*/
    int ans=0;
    for(int i=1;i<=n;++i)
        for(int j=1;j<=n;++j)
        {
            if(check(i,j)) ++ans;
        }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 12160
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
ll C[100005]={};
int n,m;
vector<int> v[100005];
int a[1001],b[1001];
bool ca[1004],cb[1005];

int main() {
	int a,b,v;
	cin>>a>>b>>v;
	cout<<(a*b)/2<<endl;
	return 0;
}


Measured memory_bytes: 2560
def main():
    n = int(input())
    A = list(map(int,input().split()))
    A.sort(reverse=True)

    k = n//2
    if n%2==0:
        print(A[0]+2*sum(A[1:k]))
    else:
        print(A[0]+2*sum(A[1:k])+A[k])
main()

Measured memory_bytes: 105276
#include <bits/stdc++.h>
using namespace std;
const int N = 3003;

int n;
int a[N];

long long dp[N][N];

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    for (int d = 1; d <= n; ++d)
    {
        for (int l = 1; l <= n - d + 1; ++l)
        {
            int r = l + d - 1;
            dp[l][r] = max(a[l] - dp[l + 1][r], a[r] - dp[l][r - 1]);
        }
    }
    cout << dp[1][n] << endl;
    return 0;
}


Measured memory_bytes: 70016
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
	static final long MOD = 1000000007L;
	static final int INF = 50000000;
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		
		String s=sc.next();
		int d = 0;
		for (char c: s.toCharArray()) {
			d += (c-'0');
		}
		
		if (d%9==0) {
			pw.println("Yes");
		} else {
			pw.println("No");
		}
		
		pw.close();
	}

    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        }
        
        int ni() { 
            return Integer.parseInt(next()); 
        }
  
        long nl() { 
            return Long.parseLong(next()); 
        } 
  
        double nd() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() {
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str;
        }
    }
}

Measured memory_bytes: 36476
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  int N; cin >> N;
  map<ll,int> mp;
  ll ans = 0;
  for(int i = 0;i < N;i++){
    ll A; cin >> A;
    if(mp[A] % 2 == 0)ans++;
    else ans--;

    mp[A]++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 6528