akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s, t;
    cin>>s>>t;
    int n = s.size();
    int cnt = 0;
    forn(i,n){
        cnt+=(s[i]!=t[i]);
    }
    cout<<cnt<<"\n";
    return 0;
}

Measured memory_bytes: 3800
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let k: i32 = s.next().unwrap().parse().unwrap();
	let mut st = SegmentTree::new(300001, 0, |a, b| std::cmp::max(a, b));
	for _ in 0..n {
		let a: i32 = s.next().unwrap().parse().unwrap();
		let l = std::cmp::max(0, a - k);
		let r = std::cmp::min(300000, a + k);
		let m = st.fold(l as usize, r as usize + 1);
		st.set(a as usize, m + 1);
	}
	println!("{}", st.fold(0, 300001));
}

pub struct SegmentTree<T, F> {
	n: usize,
	data: Vec<T>,
	e: T,
	op: F,
}

impl<T, F> SegmentTree<T, F>
where
	T: Clone,
	F: Fn(T, T) -> T,
{
	pub fn new(n: usize, e: T, op: F) -> Self {
		Self {
			n: n,
			data: vec![e.clone(); n << 1],
			e: e,
			op: op,
		}
	}

	pub fn construct(src: Vec<T>, e: T, op: F) -> Self {
		let mut data = vec![e.clone(); src.len()];
		data.extend(src);
		for i in (1..data.len() / 2).rev() {
			data[i] = op(data[i << 1].clone(), data[i << 1 | 1].clone());
		}
		Self {
			n: data.len() / 2,
			data,
			e,
			op,
		}
	}

	pub fn fold(&self, l: usize, r: usize) -> T {
		let mut s = self.e.clone();
		let mut t = self.e.clone();
		let mut l = l + self.n;
		let mut r = r + self.n;
		while l < r {
			if l & 1 != 0 {
				s = (self.op)(s, self.data[l].clone());
				l += 1;
			}
			if r & 1 != 0 {
				t = (self.op)(self.data[r - 1].clone(), t);
			}
			l >>= 1;
			r >>= 1;
		}
		(self.op)(s, t)
	}

	pub fn set(&mut self, i: usize, v: T) {
		let mut i = i + self.n;
		self.data[i] = v;
		while {
			i >>= 1;
			i > 0
		} {
			self.data[i] = (self.op)(self.data[i << 1].clone(), self.data[i << 1 | 1].clone());
		}
	}

	pub fn get(&self, i: usize) -> Option<&T> {
		self.data.get(self.n + i)
	}

	pub fn len(&self) -> usize {
		self.n
	}
}


Measured memory_bytes: 6380
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 6001001001001001001;
long double EPS = 1e-6;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,double>>>;

// MOD確認

int main(){
    /*ll N,X,Y;
    cin >> N >> X >> Y;
    FOR(i,1,N){
        ll res = 0;
        rep(j,N){
            if(j + i < N && abs(j-X) + abs(j-) )
        }
    }
    */
   ll X,Y,A,B,C;
   cin >> X >> Y >> A >> B >> C;
   vector<ll> r(A),g(B),n(C);
   rep(i,A) cin >> r[i];
   rep(i,B) cin >> g[i];
   rep(i,C) cin >> n[i];
   sort(ALL(r));sort(ALL(g));sort(ALL(n));
   reverse(ALL(r));reverse(ALL(g));reverse(ALL(n));
   priority_queue<ll> R,G,N;
   rep(i,X) R.push(-r[i]);
   rep(i,Y) G.push(-g[i]);
   rep(i,C){
       ll x = -R.top(),y = -G.top();
       if(x <= y && x < n[i]){
           R.pop();
           R.push(-n[i]);
       }else if(y < x && y < n[i]){
           G.pop();
           G.push(-n[i]);
       }else{
           break;
       }
   }
   ll ans = 0;
   rep(i,X){
       ans += -R.top();
       R.pop();
   }
   rep(i,Y){
       ans += -G.top();
       G.pop();
   }
   cout << ans << endl;
}


Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main()
{
    vector<int> e(4);
    rep(i,4) cin >>e[i];
    sort(all(e));

    string ans = "yes";
    rep(i,2)if(e[2*i]!=e[2*i+1]) ans = "no";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3152
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
bool N[102][102];
int map[102][102],R,ga,gb,w,h,f=0;
void block(int ,int);
int main()
{
	int i,n,c,d,X=0,Y=0,x,y;
	cin>>w>>h;
	while(w!=0||h!=0){
		memset(map,0,sizeof(map));
		memset(N,false,sizeof(N));
		cin>>X>>Y;
		cin>>ga>>gb;
		cin>>n;
		for(i=0;i<n;i++){
			cin>>c>>d>>x>>y;
			if(d){
				map[y][x]=c;
				map[y+1][x]=c;
				map[y+2][x]=c;
				map[y+3][x]=c;
				map[y][x+1]=c;
				map[y+1][x+1]=c;
				map[y+2][x+1]=c;
				map[y+3][x+1]=c;

			}
			else{
				map[y][x]=c;
				map[y+1][x+1]=c;
				map[y+1][x+2]=c;
				map[y+1][x+3]=c;
				map[y+1][x]=c;
				map[y][x+1]=c;
				map[y][x+2]=c;
				map[y][x+3]=c;

			}
		}
		R=map[Y][X];
		if(R==map[gb][ga]&&R!=0){
			block(Y,X);
			if(f==1) cout<<"OK"<<endl;
		        else cout<<"NG"<<endl;
		}
		else cout<<"NG"<<endl;
		//for(i=0;i<h;i++){
			//for(j=0;j<w;j++){
			//	cout<<map[i][j];
			//}
				
	//		cout<<endl;
		//}
		f=0;
		cin>>w>>h;
	}
	return 0;
}
void block(int b,int a)
{
	//if(f==1) return 1;
	N[b][a]=true;
	if(ga==a&&gb==b) f=1;
		if(map[b][a+1]==R&&N[b][a+1]==false) block(b,a+1); //???
		if(map[b+1][a]==R&&N[b+1][a]==false) block(b+1,a); //???
		if(map[b][a-1]==R&&N[b][a-1]==false) block(b,a-1); //???
		if(map[b-1][a]==R&&N[b-1][a]==false) block(b-1,a); //???
}

Measured memory_bytes: 1220
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		double w = sc.nextInt();
		double h = sc.nextInt();
		double x = sc.nextInt();
		double y = sc.nextInt();
		
		double ans1 = (w*h)/2;
		if (x==w/2&&y==h/2) {
			System.out.println(ans1 +" "+ 1);
		}
		else
			System.out.println(ans1 +" "+ 0);
		
				
		
		

	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// abc138d
int n, q;
vector<int> adj[200002];
ll cnt[200002];
void dfs(int s, int p){
    for(int i=0; i<adj[s].size(); i++){
        if (adj[s][i]==p) continue;
        cnt[adj[s][i]] += cnt[s];
        dfs(adj[s][i], s);
    }
}

int main(){
    cin >> n >> q;
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    rep(i, n) cnt[i] = 0;
    rep(i, q){
        int p, x;
        cin >> p >> x;
        p--;
        cnt[p] += x;
    }
    dfs(0, -1);
    rep(i, n) cout << cnt[i] << ' ';
    return 0;
}


Measured memory_bytes: 27392
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int,int> pii;
string pre,sux,s;
int main()
{
    int n;
    cin>>s>>n;
    int t=0;
    while(n--)
    {
        int op;cin>>op;
        if(op==1)t^=1;
        else{
            int oo;cin>>oo;oo--;
            string cc;cin>>cc;
            if(oo^t)sux+=cc;
            else pre+=cc;
        }
    }
    if(!t){
        reverse(pre.begin(),pre.end());
        cout<<pre;
        cout<<s<<sux<<endl;
    }
    else{
        reverse(sux.begin(),sux.end());
        reverse(s.begin(),s.end());
        cout<<sux<<s<<pre<<endl;
    }
    return 0;
}

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

const int MOD=(int)1e9+7;
const int MAX=210000;
long long fac[MAX],finv[MAX],inv[MAX];
//テーブルを作る前処理
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}
//二項係数の計算
long long COM(int n,int k){
  if(n<k) return 0;
  if(n<0 || k<0)  return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

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

  vector<int> div;
  for(int i=2;i*i<=M;i++){
    int count=0;
    while(M%i==0){
      M/=i;
      count++;
    }
    div.push_back(count);
  }
  if(M!=1)  div.push_back(1);
  //for(int i=0;i<div.size();i++) cout << div.at(i) << endl;
  long long ans=1;
  for(int i=0;i<div.size();i++){
    ans*=COM(div.at(i)+N-1,div.at(i));
    ans%=MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5248
def main():
    a,b,c,d = tuple([int(t)for t in input().split()])

    while a>0 and b>0:
        c-=b
        if c<=0:
            print("Yes")
            return
        a-=d
        if a<=0:
            print("No")
            return
    if a>0:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()

Measured memory_bytes: 9072
h,w=map(int,input().split())
a=['.'*(w+2)]
s=['.'+input()+'.' for _ in range(h)]
s=a+s+a
f=True
for i in range(1,h+1):
  for j in range(1,w+1):
    if s[i][j]=='#' and s[i][j-1]=='.' and s[i][j+1]=='.' and s[i-1][j]=='.' and s[i+1][j]=='.':
      f=False
if f:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9196
x = int(input())

if x <= 599:
    print(8)
elif x <= 799:
    print(7)
elif x <= 999:
    print(6)
elif x <= 1199:
    print(5)
elif x <= 1399:
    print(4)
elif x <= 1599:
    print(3)
elif x <= 1799:
    print(2)
elif x <= 1999:
    print(1)


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  char c;
  cin >> c;
  
  if(c>='a' && c<='z') {
    cout << 'a' << endl;
  }
  else {
    cout << 'A' << endl;
  }
}

Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
using namespace std;
long long n,l,a[100005];
int main(){
	scanf("%lld%lld",&n,&l);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<n;i++){
		if(a[i]+a[i+1]>=l){
			printf("Possible\n");
			for(int j=1;j<i;j++) printf("%d\n",j);
			for(int j=n-1;j>=i;j--) printf("%d\n",j);
			return 0;
		}
	}
	printf("Impossible\n");
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;
using ll = long long;

void ABC073C()
{
	int N;
	cin >> N;
	set<ll> numbers;
	for (int i = 0; i < N; ++i)
	{
		int x;
		cin >> x;
		auto p = numbers.find(x);
		if (p == numbers.cend())
			numbers.insert(x);
		else
			numbers.erase(p);
	}
	cout << numbers.size() << endl;
}
int main()
{
	ABC073C();
	return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int a;
    cin >> a;
    cout << a+a*a+a*a*a << "\n";
    return 0;
}

Measured memory_bytes: 3652
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        mon1 solver = new mon1();
        solver.solve(1, in, out);
        out.close();
    }
    static class mon1 {
	    public void solve(int testNumber, Scanner in, PrintWriter out) {
	      int left = in.nextInt();
	      int right = in.nextInt();
	      
	      if (((left*right) % 2) != 0) {
	        out.println("Odd");
	      } else {
	        out.println("Even");
	      }
	    }
    }
}

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

using namespace std;

const int N = 100000 + 77;
int n , a[N] , dp[N];
int main(){
   ios::sync_with_stdio(0);cin.tie(0);
   cin >> n;
   for(int i = 1;i <= n;++ i)
      cin >> a[i];
   dp[2] = abs(a[1] - a[2]);
   for(int i = 3;i <= n;++ i)
      dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]) , dp[i - 2] + abs(a[i] - a[i - 2]));
   cout << dp[n];
   return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){
    int n,k,x,y;
    scanf("%d%d%d%d",&n,&k,&x,&y);
    int sum=0;
    for(int i=1;i<=n;i++){
        if(i<=k){
            sum+=x;
        }else{
            sum+=y;
        }
    }
    printf("%d\n",sum);
}

Measured memory_bytes: 128
#include "stdio.h"

int main()
{
	//入力用の変数
	int N = 0,POS[110];
	for (int i = 0; i < 110; i++) {
		POS[i] = 0;
	}

	//最小・最大をとるための変数
	int MAX = 0, MIN = 10000;

	//標準入力
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &POS[i]);
	}

	//すべての家で、一番座標が小さいところと大きいところをチェック
	for (int i = 0; i < N; i++) {
		//今見ているところが、最大値の暫定より大きければ最大値を更新
		if (POS[i] > MAX)
			MAX = POS[i];
		//今見ているところが、最小値の暫定より小さければ最小値を更新
		if (POS[i] < MIN)
			MIN = POS[i];
	}

	//座標の最大値と最小値の差が必要な移動距離となる。
	printf("%d", MAX - MIN);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#define INF 1e+9
using namespace std;

int main(){
	int n,ma,mb,a[40],b[40],c[40];
	int dp[41][401][401];
	cin >> n >> ma >> mb;
	for(int i = 0;i < n;i++) cin >> a[i] >> b[i] >> c[i];
	for(int i = 0;i <= n;i++){
		for(int j = 0;j <= 400;j++){
			for(int k = 0;k <= 400;k++) dp[i][j][k] = INF;
		}
	}
	dp[0][0][0] = 0;
	for(int i = 0;i < n;i++){
		for(int j = 0;j <= 400;j++){
			for(int k = 0;k <= 400;k++){
				dp[i + 1][j][k] = min(dp[i + 1][j][k],dp[i][j][k]);
				if(j + a[i] <= 400 && k + b[i] <= 400) dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]],dp[i][j][k] + c[i]);
			}
		}
	}
	int mi = INF;
	for(int i = 0;i <= n;i++){
		for(int j = 1;j <= 400;j++){
			for(int k = 1;k <= 400;k++){
				if(j % ma == 0 && k % mb == 0 && j / ma == k / mb) mi = min(dp[i][j][k],mi);
			}
		}
	}
	if(mi != INF) cout << mi << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 25984
#include<stdio.h>

int main()
{
	int a,b,c,d,i,j;
	scanf("%d\n",&d);
	for(i=0;i<d;i++){
		scanf("%d %d %d",&a,&b,&c);
		if(a<b){
			j=a;
			a=b;
			b=j;
		}
		if(a<c){
			j=a;
			a=c;
			c=j;
		}
		if(a*a==b*b+c*c)
		    printf("YES\n");
		else
		    printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll minele(vector<ll> a,ll N){
    ll min = a[0];
    rep(i,N){
        if(min > a[i]){
            min = a[i];
        }
    }
    return min;
}

int main()
{
    ll A,B,M;
    cin >> A >> B >> M;
    vector<ll> a(A),b(B);
    vector<ll> x(M),y(M),c(M);
    vector<ll> k(M+1);
    rep(i,A) cin >> a[i];
    rep(i,B) cin >> b[i];
    rep(i,M) cin >> x[i] >> y[i] >> c[i];
    ll mina = minele(a,A);
    ll minb = minele(b,B);
    k[0] = mina + minb;
    //cout << k[0] << endl;
    for (size_t i = 0; i < M; i++)
    {
        k[i+1] = a[x[i]-1] + b[y[i]-1] -c[i];
        //cout << k[i+1] << endl;
    }
    ll ans = minele(k,M+1);
    cout << ans << endl;
    


}

Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<string>
#include<set>

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

    int ans = 0;
    int cnt;
    for (int i = 0; i < n; i++)
    {
        cnt = 0;
        std::set<char> x;
        std::set<char> y;
        for (int j = 0; j < n; j++)
        {
            if(j <= i) {
                x.insert(s[j]);
            } else {
                y.insert(s[j]);
            }
        }

        for (int j = 'a'; j <= 'z'; j++) {
            if(x.find((char)(j))!= x.end() && y.find((char)(j)) != y.end()) {
                cnt++;
            }
        }

        ans = std::max(ans, cnt);
    }

    std::cout << ans << "\n";

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int[] charArr = new int[26];

		String str;
		while (scan.hasNext()) {
			str = scan.nextLine();
			for (char c : str.toCharArray()) {
				if (c > 64 && c < 91) {
					charArr[c - 65]++;
				}
				if (c > 96 && c < 123) {
					charArr[c - 97]++;
				}
			}
		}

		for (int i = 0; i < 26; i++) {
			System.out.println((char) (i + 97) + " : " + charArr[i]);
		}

		scan.close();
	}
}



Measured memory_bytes: 26308
#![allow(non_snake_case)]

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let N:usize = sc.read();
    let M:usize = sc.read();
    let mut tree:Vec<usize> = (0..(M+1)).collect();
    let mut person:Vec<usize> = vec![];
    for _ in 0..N{
        let k:usize = sc.read();
        let t:usize = sc.read();
        person.push(t);
        for _ in 1..k{
            let s:usize = sc.read();
            union(&mut tree, t, s);
        }
    }
    let mut ans = true;
    let f = find(&mut tree, person[0]);
    for i in 1..N{
        if f != find(&mut tree, person[i]) {
            ans = false;
            break
        }
    }
    if ans{
        println!("YES");
    }else{
        println!("NO");
    }

}

fn find(v:&mut Vec<usize>, x: usize) -> usize{
    let p = v[x];
    if p == x{
        return x
    }
    let a = find(v,p);
    v[x] = a;
    a
}

fn union(v:&mut Vec<usize>, x:usize, y:usize) {
    let bx: usize;
    let by: usize;

    if find(v, x) > find(v,y) {
        bx = find(v,y);
        by = find(v,x);
    }else{
        bx = find(v,x);
        by = find(v,y);
    }
    v[y] = bx;
    v[by] = bx;
}


pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




Measured memory_bytes: 6396
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
#define PI 3.14159265359

void findFactors(ll num, vector<ll> &vec){
  while (num % 2 == 0) {
    vec.push_back(2);
    num /= 2;
  }
  for (ll i = 3; i <= num; i+=2) {
    while (num % i == 0) {
      vec.push_back(i);
      num /= i;
    }
  }
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

ll calc(ll N) {
  if (N == 0) {
    return 0;
  }
  if (N == 1) {
    return 1;
  }
  ll ret = 1;
  while ( (ret * (ret + 1) / 2) <= N) {
    ret ++;
  }
  ret --;
  return ret;
}

int main() {
  ll N;
  cin >> N;
  map<ll, int> m = prime_factor(N);
  ll ret = 0;
  for (auto it = m.begin(); it != m.end(); it ++) {
    ret += calc(it->second);
  }
  cout << ret << endl;
  return 0;
}

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

a = []
aa = []

for i in range(n):
    ai = int(input())
    a.append(ai)
    aa.append(ai)

aa.sort()
firsta = aa[-1]
seconda = aa[-2]


if firsta == seconda:
    for i in range(n):
        print(firsta)
else:
    for i in range(n):
        if a[i] == firsta:
            print(seconda)
        else:
            print(firsta)

Measured memory_bytes: 14124
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
	//Implement solution here.
		int n = ni();
		int[] w = na(n);
		int[] l = new int[n];
		int[] r = new int[n];
		
		l[0] = w[0];
		for(int i = 1; i < n; i++) {
			l[i] = l[i - 1] + w[i];
		}
		
		r[n - 1] = w[n - 1];
		for(int i = n - 2; i >= 0; i--) {
			r[i] = r[i + 1] + w[i];
		}
		
		int result = Integer.MAX_VALUE;
		
		for(int i = 1; i < n - 1; i++) {
			result = Math.min(result, Math.abs(l[i] - r[i + 1]));
		}
		System.out.println(result);
	}

    //Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
            	br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21204
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]


from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

N = int(input())
A = list(map(int,input().split()))

c = dict(Counter(A))
c = sorted(c.items(), key=lambda x: x[0])

max_one = None
max_two = None
max_sub = None
for k, v in c[::-1]:
    if v >= 4:
        if max_sub is None:
            max_sub = k
    if v >= 2:
        if max_one is None:
            max_one = k
        else:
            max_two = k
            break

if max_two is None:
    print(0)
elif max_sub is not None:
    sub_S = max_sub**2
    S = max_one * max_two
    if sub_S > S:
        print(sub_S)
    else:
        print(S)
else:
    print(max_one*max_two)

Measured memory_bytes: 37260
#include <iostream>

using namespace std;

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

    uint64_t x = 0;
    for(int i=0;i<n.length();i++){
        x += (uint8_t)n.at(i) - '0';
    }

    if(x%9 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3716
#include<iostream>
 
int main() {
	int n = 0, y = 0;
	std::cin >> n >> y;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
				if (i + j + n-(i+j) == n && i * 1000 + j * 5000 == y - 10000*(n-(i+j)) && n-(i+j) >=0) {
					std::cout << n-(i+j) << " " << j <<" "<< i << std::endl;
					return 0;
			}
		}
	}
	std::cout << "-1 " << "-1 " << "-1" << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
using namespace std;

int main() {
	int D, N, ans = 1;
	cin >> D >> N;
	for (int i = 0; i < D; i++)
	{
		ans *= 100;
	}
	if (N%10==0)
	{
		N++;
	}
	cout << ans*N;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define BIG 1000000000
#define N 100010
using namespace std;
int n,k,cnta,cntb,Ans,a[N],b[N];

int main() {
	scanf("%d%d",&n,&k);
	for (int i=1; i<=n; i++) a[i]=b[i]=BIG;
	for (int i=1; i<=n; i++) {
		int x; scanf("%d",&x);
		if (x<0) a[++cnta]=-x;
		else b[++cntb]=x;
	}
	for (int i=1; i<=(cnta/2); i++) swap(a[i],a[cnta-i+1]);
	Ans=b[k];
	for (int i=1; i<=min(cnta,k); i++)
		Ans=min(Ans,a[i]+b[k-i]*2);
	Ans=min(Ans,a[k]);
	for (int i=1; i<=min(cntb,k); i++) 
		Ans=min(Ans,b[i]+a[k-i]*2);
	printf("%d",Ans);
}


Measured memory_bytes: 1024
def larger(x, y):
	if x > y: return x
	else: return y

N = int(raw_input())
V = map(int, raw_input().split())
C = map(int, raw_input().split())

max = 0
for i in range(0, N):
	if V[i] > C[i]:
		max += V[i]-C[i]

print max

Measured memory_bytes: 2568
c500 = int(input())
c100 = int(input())
c50 = int(input())
x = int(input())

ans = 0
for i in range(c500+1):
    for j in range(c100+1):
        for k in range(c50+1):
            if i*500 + j*100 + k*50 == x:
                ans += 1
print(ans)

Measured memory_bytes: 3060
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


s = inp()

A = []

while s not in A:
    A.append(int(s))
    if s % 2 == 0:
        s = int(s/2)
    else:
        s = int(3*s + 1)
print(len(A)+1)


Measured memory_bytes: 3060
#include <iostream>
#include<string>
#include <math.h>

using namespace std;

int main(){
        string s;
        int zeronum=0,onenum;
        cin>>s;

        for(int i=0; i<s.size(); i++){
                if(s[i]=='0') zeronum++;
        }
        onenum=s.size()-zeronum;
        cout<<min(zeronum,onenum)*2<<endl;
        return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <set>

using namespace std;

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

	vector<int> ans(n+1, 0);
	for (long long x = 1; x * x <= n; x++) {
		for (long long y = x; x*x + y*y + x*y <= n; y++) {
			for (long long z = y; ; z++) {
				long long val = x*x + y*y + z*z + x*y + y*z + z*x;
				if (val > n) {
					break;
				}

				set<long long> num = {x, y, z};
				if (num.size() == 3) {
					ans[val] += 6;
				} else if (num.size() == 2) {
					ans[val] += 3;
				} else {
					ans[val]++;
				}
			}
		}
	}

	for (int i = 1; i <= n; i++) {
		// cout << i << " ";
		cout << ans[i] << endl;
	}
	return 0;
}


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

const long long maxn = 4e3 + 10;

long long n;
long long dp[maxn][maxn];
long long ind[2][maxn];
long long fen[maxn];

void in();
void solve();
void out();
void add(long long x, long long v);
long long get(long long x);

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> n;
    for(long long i = 0; i < 2 * n; i++){
        char c;
        long long x;
        cin >> c >> x;
        if(c == 'W')
            ind[0][x] = i;
        else
            ind[1][x] = i;
    }
}

void solve(){
    for(long long i = 0; i <= n; i++){
        if(i != 0)
            add(ind[0][i] + 1, 1);
        for(long long j = 0; j <= n; j++){
            if(j != 0)
                add(ind[1][j] + 1, 1);
            if(i + j != 0)
                dp[i][j] = 1e9;
            if(i != 0)
                dp[i][j] = min(dp[i][j], dp[i - 1][j] + i + j - get(ind[0][i] + 1));
            if(j != 0)
                dp[i][j] = min(dp[i][j], dp[i][j - 1] + j + i - get(ind[1][j] + 1));
        }
        for(long long j = 1; j <= n; j++)
            add(ind[1][j] + 1, -1);
    }
}

void out(){
    cout << dp[n][n];
}

void add(long long x, long long v){
    for(; x <= n * 2; x += x & -x)
        fen[x] += v;
}

long long get(long long x){
    long long s = 0;
    for(; x; x -= x & -x)
        s += fen[x];
    return s;
}


Measured memory_bytes: 62976
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]", B: "List[int]"):

    n = 0
    for i in range(len(B)):
        n1 = min(A[i],B[i])
        n += n1
        B[i] -= n1
        n2 = min(A[i+1],B[i])
        n += n2
        A[i+1] -= n2
    print(n)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N+1) ]  # type: "List[int]"
    B = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19452
import java.util.*;
import java.io.*;
class Main{
  public static void main(String args[]){
    int n = readI();
    int a[]=new int[n];
    for(int i=0;i<n;i++){
      a[i]=readI();
    }
    long sum=0;
    long now = a[n-1];
    for(int i=n-2;i>=0;i--){
      sum=(sum+now*a[i])%1000000007;
      now=(now+a[i])%1000000007;
    }
    pl(sum+"");
  }

  static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
  public static String read(){
    try{
      return ctos((char)br.read());
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static char readC(){
    try{
      return (char)br.read();
    }catch(IOException e){
      e.printStackTrace();
      return (char)-1;
    }
  }
  public static String readL(){
    try{
      return br.readLine();
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static String readS(){
    StringBuilder sb = new StringBuilder();
    while(true){
      try{
        int k = br.read();
        if(k==-1||(char)k==' '||(char)k=='\n'){break;}
        sb.append((char)k);
      }catch(IOException e){
        e.printStackTrace();
      }
    }
    return sb.toString();
  }
  public static int readI(){
    return stoi(readS());
  }
  public static long readLong(){
    return stol(readS());
  }
  public static long stol(String s){
    return Long.parseLong(s);
  }
  public static String[] readSs(){
    return readL().split(" ");
  }
  public static int[] readIs(){
    return stoi(readSs());
  }
  public static int stoi(String s){
    return Integer.parseInt(s);
  }
  public static int[] stoi(String s[]){
    int a[]=new int[s.length];
    for(int i=0;i<s.length;i++){
      a[i]=stoi(s[i]);
    }
    return a;
  }
  public static String itos(int i){
    return String.valueOf(i);
  }
  public static String[] itos(int[] a){
    String s[]=new String[a.length];
    for(int i=0;i<a.length;i++){
      s[i]=itos(a[i]);
    }
    return s;
  }
  public static String ctos(char c){
    return String.valueOf(c);
  }
  public static String cstos(char[] c){
    return new String(c);
  }
  public static char stoc(String s){
    return s.charAt(0);
  }
  public static char[] stocs(String s){
    return s.toCharArray();
  }
}


Measured memory_bytes: 54996
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Omar Yasser
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner sc, PrintWriter out) {
            int n = sc.nextInt();
            int arr[] = new int[n];
            for (int i = 0; i < n; i++) arr[i] = sc.nextInt();
            Arrays.sort(arr);
            out.println(arr[n - 1] - arr[0]);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader f) {
            br = new BufferedReader(f);
        }

        public String next() {
            while (st == null || !st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++){
        cin >> vec.at(i);
    }
    int count = 0;
    for (int i = 0; i < N; i++){
        if (vec.at(i) != i+1){
            count += 1;
        }
    }
    if (count == 0 || count == 2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
require 'matrix'
n, m, *steps = gets.split.map(&:to_i)

mat = (0..n).map { (0..n).map { 0 } }
m.times do
    i, j = gets.split.map(&:to_i)
    mat[i][j] = 1
end
mat = Matrix[*mat]
trans = steps.map {|s| mat ** s}

dist = { n => 0 }

loop do
    changed = false
    (1..n-1).each do |u|
        d = trans.map {|mat| (1..n).map {|v| mat[u, v] >= 1 ? (dist[v] || Float::INFINITY) : Float::INFINITY}.min}.max + 1
        next if d == Float::INFINITY
        if !dist[u] || d < dist[u]
            dist[u] = d
            changed = true
        end
    end
    break unless changed
end

puts dist[1] || 'IMPOSSIBLE'

Measured memory_bytes: 10892
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        long[] x = new long[26];
        for (char c : new Scanner(System.in).next().toCharArray()) x[c - 'a']++;
        long ans = 1;
        for (int i = 0; i < 26; i++) for (int j = i + 1; j < 26; j++) ans += x[i] * x[j];
        System.out.println(ans);
    }
}

Measured memory_bytes: 40932
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;


int main() {
  int x,y,z;
  cin >> x >> y >> z;
  int w= x-z;
  int ans=0;

  while(true){
    if(w<(y+z))break;
    w-=(y+z);
    ans++;
  }
  cout << ans;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/04/21  Problem: ARC 096 A / Link: http://arc096.contest.atcoder.jp/tasks/arc096_a  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL A, B, C, X, Y;

LL ans = 0LL;

int main() {

	cin >> A >> B >> C >> X >> Y;
	ans = 1e18;

	LL N = min(X, Y);
	ans = N*min(A + B, 2 * C);
	X -= N, Y -= N;
	ans += Y*min(2 * C, B) + X*min(2 * C, A);
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=1000005;
int p[N][26],l[N],r[N],n,x,cnt,ans;
char s[N],t[N];

int main(){
	read(n);
	scanf("%s",s+1);
	scanf("%s",t+1);
	rep(i,1,n){
		REP(j,26){
			p[i][j]=p[i-1][j];
		}
		p[i][s[i]-'a']=i;
	}
	x=n;
	per(i,n,1){
		int y=p[x][t[i]-'a'];
		if(!y){
			puts("-1");
			return 0;
		}
		if(x!=y){
			r[++cnt]=i;
			l[cnt]=y;
			x=y;
		}
		if(x==i){
			x--;
		}
	}
	reverse(l+1,l+cnt+1);
	reverse(r+1,r+cnt+1);
	int cur=1;
	l[cnt+1]=r[cnt+1]=n+1;
	rep(i,1,cnt){
		while(cur<=cnt&&l[cur]-cur+i<r[i]) cur++;
		ans=max(ans,cur-i);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0; i<N; i++) cin >> d[i];
    
    int num[110] = {0};
    for(int i=0; i<N; i++){
        num[d[i]]++;
    }
    int res=0;
    for(int i=1; i<=100; i++){
        if(num[i]) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,M;
  cin >> N >> M;
  vector<pair<int,int>> AB(N);
  rep(i,N)  cin >> AB.at(i).fi >> AB.at(i).se;
  sort(all(AB));
  AB.p_b(m_p(1e9,0));

  int ans=0;
  priority_queue<int> pq;
  int now=0;
  REP(i,0,M+1){
    while(AB.at(now).fi == i){
      pq.push(AB.at(now).se);
      now++;
    }
    if(!pq.empty()){
      ans+=pq.top();
      pq.pop();
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4876
#include<iostream>
using namespace std;
int main()
{
int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  while( a>0 && c>0)
  {
    c=c-b;
if(c<=0){

  cout<<"Yes"<<endl;
    
    break;
    }


a=a-d;
    
    if(a<=0)
   { cout<<"No"<<endl;
   }}
}


Measured memory_bytes: 3620
s = input()
n = len(s)
k = int(input())
dp = [[[0 for _ in range(2)] for _ in range(k + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
for a in range(n):
  for b in range(k + 1):
    for c in range(2):
      nd = int(s[a])
      for d in range(10):
        na, nb, nc = a + 1, b, c
        if d != 0:
          nb += 1
        if nb > k:
          break
        if 0 == nc:
          if d > nd:
            break
          if d < nd:
            nc += 1
        dp[na][nb][nc] += dp[a][b][c]
print(sum(dp[-1][-1]))
          

Measured memory_bytes: 3064
size = list(map(int, input().split()))
sheet = []

for i in range(size[0]):
    value = list(map(int, input().split()))
    sheet.extend(value)
    sheet.append(sum(value))

for i in range(size[1]+1):
    
    point = i
    vsum = 0
    
    for j in range(size[0]):
        vsum += sheet[point]
        point += size[1] +1
    sheet.append(vsum)
    
for i in range(len(sheet)):
    if (i+1) % (size[1]+1)  == 0:
        print(sheet[i])
    else:
        print(str(sheet[i])+" ", end="")

Measured memory_bytes: 8344
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long x,r=0;cin >> x;
  vector<long long> a(150);
  for (long long i=0;i<150;i++) a[i]=i*i*i*i*i;
  for (int i=0;i<150;i++) {
    for (int j=0;j<150;j++) {
	  if (a[i]+a[j]==x && r==0) {r++;cout << min(i,j) << " " << -1*max(i,j) << endl;}
	  else if (max(a[i],a[j])-min(a[i],a[j])==x && r==0) {r++;cout << max(i,j) << " " << min(i,j) << endl;}
      else if (a[i]+a[j]==-1*x && r==0) {r++;cout << -1*min(i,j) << " " << max(i,j) << endl;}
      else if (max(a[i],a[j])-min(a[i],a[j])==-1*x && r==0) {r++;cout << -1*max(i,j) << " " << -1*min(i,j) << endl;}
	}
  }
}

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

ll a, b, q;

int main()
{
    cin >> a >> b >> q;
    vector<ll> s(a), t(b);
    for (int i = 0; i < a; i++)
    {
        cin >> s[i];
    }
    for (int i = 0; i < b; i++)
    {
        cin >> t[i];
    }
    for (int i = 0; i < q; i++)
    {
        ll x;
        cin >> x;
        vector<ll> ans;
        //x以上となる最小のindexを取得
        auto s_ind = distance(s.begin(), lower_bound(s.begin(), s.end(), x));
        auto t_ind = distance(t.begin(), lower_bound(t.begin(), t.end(), x));
        if (s_ind != 0 && t_ind != 0)
        {
            ans.push_back(x - min(s[s_ind - 1], t[t_ind - 1]));
        }
        if (s_ind != a && t_ind != b)
        {
            ans.push_back(max(s[s_ind], t[t_ind]) - x);
        }
        if (s_ind != a && t_ind != 0)
        {
            ans.push_back(2 * abs(s[s_ind] - x) + abs(t[t_ind - 1] - x));
            ans.push_back(abs(s[s_ind] - x) + 2 * abs(t[t_ind - 1] - x));
        }
        if (s_ind != 0 && t_ind != b)
        {
            ans.push_back(2 * abs(s[s_ind - 1] - x) + abs(t[t_ind] - x));
            ans.push_back(abs(s[s_ind - 1] - x) + 2 * abs(t[t_ind] - x));
        }
        sort(ans.begin(), ans.end());
        cout << ans[0] << endl;
    }
}

Measured memory_bytes: 2944
n = gets.chop.to_i
p = gets.chop.split.map(&:to_i)

count = 0
for i in 0..n-3
  sort_array = []
  sort_array << p[i]
  sort_array << p[i+1]
  sort_array << p[i+2]
  sort_array.sort!

  if sort_array[1] == p[i+1]
    count += 1
  end
end

puts count

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

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    const int lower = max(A, C);
    const int upper = min(B, D);

    cout << max(0, upper - lower) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(void){
    //手前に自分より小さい整数があったらだめゲーム
    int n;
    std::cin >> n;
    std::vector<int> p(n);
    rep(i, n) std::cin >> p.at(i);
    int min = p.at(0), ans = n;
    rep(i, n){
        if(p.at(i) > min) ans--;
        if(p.at(i) < min) min = p.at(i);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<tuple>
#include<set>
using namespace std;

typedef tuple<int,int,int> T;

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

int main(){
  long long a, b, c;
  int n;
  cin >> a >> b >> c >> n;

  long long ans = 2 * (a * b + b * c + c * a);
  set<T> t;
  for(int i = 0; i < n; i++){
      int x, y, z;
      cin >> x >> y >> z;
      t.emplace(x,y,z);
  }

  for(auto i : t){
    ans += 6;
    int x, y, z;
    tie(x, y, z) = i;

    int cnt = 0;
    if(x == 0) ans-=2;
    if(x == a - 1) ans -= 2;
    if(y == 0) ans-=2;
    if(y == b - 1) ans -= 2;
    if(z == 0) ans-=2;
    if(z == c - 1) ans -= 2;

    for(int j = 0; j < 6; j++){
      int nx = x + dx[j];
      int ny = y + dy[j];
      int nz = z + dz[j];
      if(t.count(T(nx,ny,nz))) ans--;
    }
  }
  cout << ans << endl;

}



Measured memory_bytes: 3156