akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<long, long> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const double EPS=1e-10;
 
typedef int Weight;
//typedef
//------------------------------------------
 
typedef int Weight;
//typedef
//------------------------------------------

int main(){
    int N;
    cin>>N;
    vector<long>A(N),B(N);
    long asum=0,bsum=0;
    REP(i,N){
        cin>>A[i];asum+=A[i];
    }
    REP(i,N){
        cin>>B[i];bsum+=B[i];
    }
    if(asum<bsum){
        cout<<-1<<endl;return 0;
    }
    int cnt=0;
    long df=0;
    REP(i,N){
        if(A[i]<B[i]){
            cnt++;df+=(B[i]-A[i]);
        }
    }
    vector<long>d;
    REP(i,N){
        if(A[i]>B[i]){
            d.PB(A[i]-B[i]);
        }
    }
    SORT(d);reverse(d.begin(),d.end());
    long sum=0;
    REP(i,SZ(d)){
        if(sum>=df){
            break;
        }
        sum+=d[i];cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 2428
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000


int main() {
	int a, b, t;
	cin >> a >> b >> t;
	if (a > t) {
		cout << 0 << endl;
		return 0;
	}
	else {
		cout << (t / a) * b << endl;
		return 0;
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static int a;
    public static int b;
    public static int c;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		float t_ds = (float)a/(float)c;
        if(b >= t_ds){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
	}
}

Measured memory_bytes: 35568
#[allow(unused_imports)]
use proconio::{
    fastout, input,
};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [i32; n],
        q: usize,
        bc: [(i32, i32); q],
    }
    let mut counter = std::collections::HashMap::new();
    let mut sum: i64 = 0;
    for &v in a.iter() {
        *(counter.entry(v).or_insert(0)) += 1;
        sum += v as i64;
    }
    for &(b, c) in bc.iter() {
        let increase = {
            let e = counter.entry(b).or_insert(0);
            std::mem::replace(e, 0)
        };
        sum += ((c - b) as i64) * (increase as i64);
        *(counter.entry(c).or_insert(0)) += increase;
        println!("{}", sum);
    }
}


Measured memory_bytes: 6808
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
const int use[10]={0,2,5,5,4,5,6,3,7,6};
int n,m,x[N],dp[N];
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)cin>>x[i];
	dp[0]=1;
	for(int i=0;i<m;i++)
	{
		for(int j=use[x[i]];j<=n;j++)
		{
			dp[j]=max(dp[j],dp[j-use[x[i]]]+1);
		}
	}
	sort(x,x+m);
	m--;
	while(n>0)
	{
		if(n>=use[x[m]]&&dp[n]==dp[n-use[x[m]]]+1)
			n-=use[x[m]],cout<<x[m];
		else
			m--;
	}
	return 0;
}

Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)
map = Array.new(h).map{Array.new(w)}
row = []
col = []
h.times do |i|
    str = gets.chomp
    w.times do |j|
        map[i][j] = str[j];
        if map[i][j] == "#"
            row.push(i)
            col.push(j)
        end
    end
end

h.times do |i|
    map.delete_at(h-i-1) unless row.include?(h-i-1)
end

map = map.transpose
w.times do |j|
    map.delete_at(w-j-1) unless col.include?(w-j-1)
end
map = map.transpose


map.each do |row|
    row.each do |col|
        print col
    end
    puts
end


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

int main() {
    int64_t N, Q;
    string S;
    cin >> N >> S >> Q;

    vector<set<int64_t>> appear_pos(26);
    //番兵を入れる
    for (int64_t i = 0; i < 26; i++) {
        appear_pos[i].insert(N + 1);
    }

    for (int64_t i = 0; i < N; i++) {
        appear_pos[S[i] - 'a'].insert(i);
    }

    for (int64_t _ = 0; _ < Q; _++) {
        int64_t q;
        cin >> q;
        if (q == 1) {
            int64_t i;
            char c;
            cin >> i >> c;
            i--;
            appear_pos[S[i] - 'a'].erase(appear_pos[S[i] - 'a'].lower_bound(i));
            S[i] = c;
            appear_pos[c - 'a'].insert(i);
        } else {
            int64_t l, r;
            cin >> l >> r;
            l--; r--;
            int64_t num = 0;
            for (int64_t i = 0; i < 26; i++) {
                int64_t appear = *appear_pos[i].lower_bound(l);
                if (appear <= r) {
                    num++;
                }
            }
            cout << num << endl;
        }
    }
}

Measured memory_bytes: 24196
//Walk
public class Main{
	int h, w, n;
	class Scanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-') return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}
	}

	void run(){
		Scanner sc = new Scanner();
		while(true){
			h = sc.nextInt();
			w = sc.nextInt();
			n = sc.nextInt();
			if((h|w|n)==0)break;
			int[][] m = new int[h][w];
			for(int i=0;i<h;i++)for(int j=0;j<w;j++)m[i][j]=sc.nextInt();
			int[][] dp = new int[h][w];
			dp[0][0] = n-1;
			for(int j=1;j<w;j++)dp[0][j]=(dp[0][j-1]+m[0][j-1])/2;
			for(int i=1;i<h;i++)dp[i][0]=(dp[i-1][0]+(m[i-1][0]+1)%2)/2;
			for(int i=1;i<h;i++){
				for(int j=1;j<w;j++){
					dp[i][j] = (dp[i-1][j]+(m[i-1][j]+1)%2)/2 + (dp[i][j-1]+m[i][j-1])/2;
				}
			}
			int x = 0;
			int y = 0;
			while(!(x==w||y==h)){
				if((dp[y][x]+m[y][x])%2==0)y++;
				else x++;
			}
			System.out.println(++y+" "+ ++x);
		}
	}

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

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int a, b, c, d;
int main() {
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
    return 0;
}


Measured memory_bytes: 3532
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:String,
    }
    let mut v=a.chars().collect_vec();
    let mut ans = 0;
    for i in 0..4 {
        if v[i]=='-' {ans-=1 }
        if v[i]=='+' {ans+=1 }
    }
    println!("{}",ans)
}

Measured memory_bytes: 2188
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}


void solve(long long X, long long Y, long long Z){
    cout << Z << " " << X << " " << Y << endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    long long Z;
    scanf("%lld",&Z);
    solve(X, Y, Z);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((ll)(1e15))
#define pi (2*acos(0))
#define M ((int)(998244353))
#define NN ((int)(305))
#define N ((int)(1e5 + 5))
#define pq priority_queue
///#define Q queue
#define eps 0
#define log 20
#define pb push_back
#define MOD 998244353


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long lu;

typedef tree < int,  null_type,  less < int >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;

vector < int > v[N];

priority_queue < int > nibo, baad;

pair < int,int > arr[N];

int mx[N];

int main()
{
    int n, k;
    scanf("%d %d",&n,&k);
    for(int i = 0; i<n; i++){
        scanf("%d %d",&arr[i].second,&arr[i].first);
        mx[arr[i].second] = max(mx[arr[i].second],arr[i].first);
    }
    sort(arr,arr+n);
    ll ans = 0, tp = 0;
    for(int i = n-1; i>=0 && k>0; i--){
        k--;
        ans += arr[i].first;
        v[arr[i].second].push_back(arr[i].first);
    }
    for(int i = 1; i<=n; i++){
        if(v[i].size()>0){
            sort(v[i].begin(),v[i].end());
            tp++;
        }
        else if(mx[i]>0) nibo.push(mx[i]);
        for(int j = 0; j+1<v[i].size(); j++) baad.push(-v[i][j]);
    }
    ans += tp*tp;
    ll fans = ans;
    while(!baad.empty() && !nibo.empty()){
        ans += 2*tp+1+nibo.top()+baad.top();
        fans = max(ans,fans);
        nibo.pop();
        baad.pop();
        tp++;
    }
    printf("%lld\n",fans);
    return 0;
}


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

int main() {
    int n, m, t, ans = 0;
    cin >> n >> m;
    t = 100 * (n - m) + 1900 * m;
    ans = t * pow(2, m);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    int d;
    cin >> d;
    vector<int> c(26);
    rep(i, 26) cin >> c[i];
    vector<vector<int>> s(d, vector<int>(26));
    rep(i, d) rep(j, 26) cin >> s[i][j];
    vector<int> last(26, -1);
    int satisfy = 0;
    vector<int> ans;
    rep(i, d) {
        int an=1;
        int day=1;
        rep(j, 26) {
            int sa = satisfy;
            vector<int> la = last;
            sa += s[i][j];
            la[j] = i;
            int decrease = 0;
            rep(k, 26) decrease += c[k] * (i - la[k]);
            sa -= decrease;
            if (chmax(satisfy, sa)){
                an = j;}
        }
        ans.push_back(an);
        last[an] = i;
    }
	rep(i,d)
        cout << ans[i]+1 << endl;
}

Measured memory_bytes: 3688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String s = sc.nextLine();
			long k = sc.nextLong();

			for (char c : s.toCharArray()) {
				if (c == '1') {
					k--;
				} else {
					System.out.println(c);
					return;
				}
				if (k <= 0) {
					System.out.println(c);
					return;
				}
			}
		}
	}
}


Measured memory_bytes: 22100
#include <stdio.h>
#include <string.h>
int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    int size = a + b + 1;
    char name[100];
    scanf("%s", name);
    int count = 0;
    if(name[a] == '-')// untuk mengecek hypen berada di letak a + 1 tidak, jika benar lanjut ke loop
    {
        for(int i = 0; i < size; i++){
            if (name[i] >= '0' && name[i] <= '9')//mengecek angka atau bukan di dalam string
            {
                count++;
            }
        }
        if(count == a + b) // jika count = banyak angka
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
        
    }
    else//jika tidak print no
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 3188
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int n; cin >> n;
    vector<int> s(n);
    for(int i = 0;i < n;i ++){
        cin >> s.at(i);
    }

    sort(s.begin(),s.end());
    int sum = 0;
    for(int i = 0;i < n;i ++) sum += s.at(i);

    if(sum % 10 > 0){
        cout << sum << endl;
        return 0;
    }

    for(int i = 0;i < n;i ++){
        if(s.at(i) % 10 > 0){
            cout << sum - s.at(i) << endl;
            return 0;
        }
    }

    cout << 0 << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    map<int, int> mp;
    mp[a]++; mp[b]++; mp[c]++;
    if (mp[5] == 2 && mp[7] == 1)
        cout << "YES";
    else 
        cout << "NO";
    return 0;
}

Measured memory_bytes: 256
//ABC165 A

#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = s; i < (int)(n); i++)
const lint mod = 1000000007;


lint ans = 0;
lint k,n,m;
string s;



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

/*   rep(i,n){
    scanf("%s",&s[i]);
  } */
  
  reps(i,n,m+1){
    if(i%k == 0){
      printf("OK\n");
      return 0;
    }
  }
  printf("NG\n");

  //printf("%lld\n",ans);
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>
#include <set>
#include <queue>
#include <climits>
#include <limits>
#include <map>
#define inf 1000000000000000000

#define ll long long
#define max(A, B) ((A) > (B) ? (A) : (B))
#define min(A, B) ((A) < (B) ? (A) : (B))
#define pair(A, B) make_pair(A, B)
#define fu(a, b, c) for(ll a = b; a < c; a++)
#define fd(a, b, c) for(ll a = b; a > c; a--)

using namespace std;

typedef pair<ll, ll> pi;
typedef pair<pair<ll, ll>, ll> pii;

void perform() {
  ll n; cin >> n;
  ll ans = 0;
  fu(i, 0, n + 1) {
    if ((i % 5) && (i % 3)) ans += i;
  }
  cout << ans << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t = 1; //cin >> t;
  while (t--) {perform();}
}


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

typedef long long ll;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int inf = 1e7;
const int N  = 1e5 + 5;

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

int n,h[N],dp[N];

int solve(int idx) {

  if(idx==n-1) return 0;

  int &ret = dp[idx];

  if(ret!=-1) return ret;

  ret = solve(idx+1) + abs(h[idx]-h[idx+1]);

  if(idx!=n-2)
    ret = min(ret,solve(idx+2) + abs(h[idx]-h[idx+2]));

  return ret;

}

int main() {

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

    cin >> n;

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

      cin >> h[i];

    }

    memset(dp,-1,sizeof(dp));

    cout << solve(0) << endl;

    return 0;
}


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

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

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

int main() {
	ll q;
	cin >> q;
	vector<int> ans(100005, 0);
	for (int i = 1; i <= 100000; i += 2) {
		if (isPrime(i) && isPrime((i + 1) / 2)) {
			ans[i]++;
		}
	}
	rep(i, 100005) {
		if (i > 0) {
			ans[i] += ans[i - 1];
		}
	}
	rep(i, q) {
		ll l, r;
		cin >> l >> r;
		cout << ans[r] - ans[l - 1] << endl;
	}
	return 0;
}



Measured memory_bytes: 1024
/*
* @Author: _dp95
* @Date:   2019-06-30 03:48:36
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 2*1000*100 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;


double dp[ MAX ] , ar[ MAX ] ;

int main( ){
  timesaver ;
  int n ;
  cin >> n ;
  for( int i = 0 ; i < n ; i++ ){
    cin >> ar[ i ] ;
  }
  dp[ 0 ] = 1 ;
  for( int i = 0 ; i < n ; i++ ){
    for( int j = i + 1 ; j >= 0 ; j-- ){
        if( j == 0 )
            dp[ j ] = dp[ j ] * ( 1 - ar[ i ] ) ;
        else
            dp[ j ] = dp[ j - 1 ] * ar[ i ] + dp[ j ] * ( 1 - ar[ i ] ) ;
    }
  }
  double ans = 0 ;
  for( int i = 0 ; i <= n ; i++ ){
    int tails = n - i ;
    if( i > tails )
        ans += dp[ i ] ;
  }
  deci( 10 ) ;
  cout << ans << nl ;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  string s;
  while(getline(cin,s)){
    while(s.find("this")==string::npos&&s.find("that")==string::npos&&s.find("the")==string::npos){
      rep(i,s.size()){
	if(s[i]=='z')s[i]='a';
	else if(isalpha(s[i]))s[i]++;
      }
    }
    cout<<s<<endl;


  }


}

Measured memory_bytes: 1180
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        int[] alphabets = new int[26];

        Scanner sc = new Scanner(System.in);

        try {
            while (true) {
                String line = sc.nextLine();

                char[] cs = line.toLowerCase().toCharArray();

                // aを0とする

                for (int i = 0; i < cs.length; i++) {
                    if (cs[i] >= 'a' && cs[i] <= 'z') {
                        alphabets[cs[i] - 'a']++;
                    }
                }
            }
        } catch (java.util.NoSuchElementException e) {
            for (int i = 0; i < 26; i++) {
                char a = (char) ('a' + i);
                System.out.println(a + " : " + alphabets[i]);
            }

        }

    }

}


Measured memory_bytes: 26108
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,sum=0;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    sort(a,a+n);
    for(i=0;i<n-1;i++)
    sum=sum+a[i];
    if(a[n-1]<sum)
    printf("Yes");
    else
    printf("No");
    return 0;
}


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

int main()
{
    string s,f="";
    cin>>s;
    rep(0,i,s.length()){
        string s0=s.substr(i,1);
        if(f==s0){
            cout<<"Bad"<<endl;
            return 0;
        }
        f=s0;
    }
    cout<<"Good"<<endl;
    return 0;
}


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

using namespace std;

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll, ll>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

int main()
{
    boost;
    time_t tic, toc;

    ll tt = 1, n, m, k = 0, i, j, p, q;
    ll a, b, h, w, u, v, x, y;
    ll l = 0, r = 0;
    ll ans = 0;

    bool poss = true;

    string s, t, tmp;

    // cin >> tt;
    tic = clock();
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> n;
        map<string, ll> mp;
        for(i = 0; i < n; i++){
            cin >> s;
            mp[s]++;
        }
        cout << "AC x " << mp["AC"] << nl;
        cout << "WA x " << mp["WA"] << nl; 
        cout << "TLE x " << mp["TLE"] << nl; 
        cout << "RE x " << mp["RE"] << nl; 
    } 
    // cerr << (clock() - tic*1.0) / CLOCKS_PER_SEC << nl;
    return 0;
}

Measured memory_bytes: 3688
#ifndef __cplusplus
    cat << EOF
#endif
#include <bits/stdc++.h>
using namespace std;

#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()

template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if(lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if(lhs > rhs) { lhs = rhs; return 1; } return 0; }

int N;
int A[200000];

int main() {

    cin >> N;
    rep(i, N) cin >> A[i];

    int now = 0;
    rep(i, N) {
        if(A[i] == now + 1) ++now;
    }

    if(now == 0) cout << -1 << '\n';
    else cout << N - now << '\n';

}


Measured memory_bytes: 1024
a,b,k=map(int,input().split())
cnt=0
c=min(a,b)
d=c
for i in range(c):
    if a%d==b%d==0:
        cnt+=1
        if cnt==k:
            break
        else:
            d-=1
    else:
        d-=1
print(d)

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

int k , ans = 1 , mod , pos;

int main(){
	scanf("%d" , &k);
	mod = 7 % k;
	while(mod){
		ans++ , mod = (mod * 10 + 7) % k;
		if(++pos > k) return puts("-1") , 0;
	}
	printf("%d" , ans); 
	return 0;
} 

Measured memory_bytes: 3808
//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <ctime>
#include <bitset>

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
int keta(ll a) {int res=0; while(a>0) res+=a%10, a/=10; return res;}
const int up[]={1,-1,0,0}, lf[]={0,0,1,-1};

int main() {
  int n; cin>>n;
  ll a[n]; for(int i=0;i<n;i++) cin>>a[i];
  ll p1=0, p2=0;
  for(int i=0;i<n;i++) {
    add(p1,a[i]); add(p2,a[i]*a[i]%M);
  }
  mul(p1,p1);
  ll an = p1 - p2 + M; an %= M;
  //cout<<p1<<" "<<p2<<" "<<an<<endl;
  an *= mod_pow(2,M-2); an %= M;
  cout<<an<<endl;
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest


Measured memory_bytes: 5160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Circle_in_a_Rectangle
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');

            int[] num = { 0, 0, 0, 0, 0 };

            for (int i = 0; i < input.Length; ++i)
            {
                num[i] = int.Parse(input[i]);
            }

            if (num[2] > 0 && num[3] > 0)
            {
                if (num[0] - num[4] >= num[2] && num[1] - num[4] >= num[3])
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}



Measured memory_bytes: 17920
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7

N = int(input())
edge = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    x, y = map(int, input().split())
    edge[x].append(y)
    edge[y].append(x)

# 頂点iから伸びてる枝それぞれのサイズ
ans = 0
pow2 = [1] * (N + 1)
for i in range(1, N + 1):
    pow2[i] = pow2[i - 1] * 2 % mod


def dfs(s, p=-1):
    global ans
    res = 1
    tmp = pow2[N-1] - 1
    for t in edge[s]:
        if t == p:
            continue
        size = dfs(t, s)
        res += size
        tmp = (tmp - pow2[size] + 1 + mod) % mod
    if N != res:
        tmp = (tmp - pow2[N-res] + 1 + mod) % mod
    ans = (ans + tmp) % mod
    return res


dfs(1)
div = pow2[N]
print(ans*pow(div, mod-2, mod) % mod)

Measured memory_bytes: 207856
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   int n,ans=0;
   cin>>n;
   vector<int> d(n);
   rep(i,n){
    cin>>d.at(i);
     if(d.at(i)!=i+1)ans++;
   }
   if(ans==0||ans==2)
     cout<<"YES"<<endl;
   else
     cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a,b,c,d,i,j,k,cnt=0;
	cin>>a>>b>>c>>d;
	for(i=0;i<=a;i++){
		for(j=0;j<=b;j++){
			for(k=0;k<=c;k++){
				if(500*i+100*j+50*k == d){
					cnt++;
				}
			}
		}
	}
	cout<<cnt;
	return 0;	
} 


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

using namespace std;

//1-indexであることに注意
struct BIT {
    int n;
    vector<int> data;

    BIT(int n) : n(n), data(n + 1, 0) {}
    
    int sum(int i) {
        int s = 0;
        while (i > 0) {
            s += data[i];
            i -= i & -i;
        }
        return s;
    }
    
    void add(int i, int x) {
        while (i <= n) {
            data[i] += x;
            i += i & -i;
        }
    }
};

typedef pair<int, int> P;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> l(n), r(n);
	vector<P> d(n);
	for (int i = 0; i < n; i++) {
		cin >> l[i] >> r[i];
		d[i].first = (r[i] - l[i] + 1);
		d[i].second = i;
	}
	sort(d.begin(), d.end());

	int cnt = n;
	BIT b(m + 1);
	for (int i = 1, j = 0; i <= m; i++) {
		while (j < n) {
			if (d[j].first > i) break;
			cnt--;
			b.add(l[d[j].second], 1);
			b.add(r[d[j].second] + 1, -1);
			j++;
		}

		int ans = cnt;
		for (int k = i; k <= m; k += i) {
			ans += b.sum(k);
		}
		cout << ans << endl;
	}
	return 0;
}

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


/* SegTreeLazy<X,M>(n,fx,fa,fm,ex,em): モノイド(集合X, 二項演算fx,fa,fm, 単位元ex,em)についてサイズnで構築
    set(int i, X x), build(): i番目の要素をxにセット。まとめてセグ木を構築する。O(n)
    update(a,b,x): a 番目から b-1 番目の要素を x に更新。O(log(n))
    query(a,b):  [a,b) 全てにfxを作用させた値を取得。O(log(n))
*/
using X=ll;
using M=ll;
template <typename X, typename M>
struct SegTreeLazy {
    using FX = function<X(X, X)>;
    using FA = function<X(X, M)>;
    using FM = function<M(M, M)>;
    int n;
    FX fx;
    FA fa;
    FM fm;
    const X ex;
    const M em;
    vector<X> dat;
    vector<M> lazy;
    SegTreeLazy(int n_, FX fx_, FA fa_, FM fm_, X ex_, M em_)
        : n(), fx(fx_), fa(fa_), fm(fm_), ex(ex_), em(em_), dat(n_ * 4, ex), lazy(n_ * 4, em) {
        int x = 1;
        while (n_ > x) x *= 2;
        n = x;
    }

    void set(int i, X x) { dat[i + n - 1] = x; }
    void build() {
        for (int k = n - 2; k >= 0; k--) dat[k] = fx(dat[2 * k + 1], dat[2 * k + 2]);
    }

    /* lazy eval */
    void eval(int k) {
        if (lazy[k] == em) return;  // 更新するものが無ければ終了
        if (k < n - 1) {            // 葉でなければ子に伝搬
            lazy[k * 2 + 1] = fm(lazy[k * 2 + 1], lazy[k]);
            lazy[k * 2 + 2] = fm(lazy[k * 2 + 2], lazy[k]);
        }
        // 自身を更新
        dat[k] = fa(dat[k], lazy[k]);
        lazy[k] = em;
    }

    void update(int a, int b, M x, int k, int l, int r) {
        eval(k);
        if (a <= l && r <= b) {  // 完全に内側の時
            lazy[k] = fm(lazy[k], x);
            eval(k);
        } else if (a < r && l < b) {                     // 一部区間が被る時
            update(a, b, x, k * 2 + 1, l, (l + r) / 2);  // 左の子
            update(a, b, x, k * 2 + 2, (l + r) / 2, r);  // 右の子
            dat[k] = fx(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    void update(int a, int b, M x) { update(a, b, x, 0, 0, n); }

    X query_sub(int a, int b, int k, int l, int r) {
        eval(k);
        if (r <= a || b <= l) {  // 完全に外側の時
            return ex;
        } else if (a <= l && r <= b) {  // 完全に内側の時
            return dat[k];
        } else {  // 一部区間が被る時
            X vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            X vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return fx(vl, vr);
        }
    }
    X query(int a, int b) { return query_sub(a, b, 0, 0, n); }
};

int main()
{
    int n,k;
    cin>>n>>k;
    auto fx = [](X x1, X x2) -> X { return max(x1, x2); };
    auto fa = [](X x, M m) -> X { return max(x,m); };
    auto fm = [](M m1, M m2) -> M { return max(m1,m2); };
    ll ex = 0;
    ll em = 0;
    SegTreeLazy<X, M> rmq(300030, fx, fa, fm, ex, em);
    vector<int> dat(n+1);
    rep(i,n){
        cin>>dat[i];
    }
    rep(i,n){
        ll l=max(dat[i]-k,0);
        ll r=min(dat[i]+k,300030);
        ll t=rmq.query(dat[i],dat[i]+1);
        //cout<<dat[i]<<"   "<<l<<" "<<r<<" "<<t+1<<endl;
        rmq.update(l,r+1,t+1);
    }
    cout<<rmq.query(0,300030)<<endl;
    return 0;
}

Measured memory_bytes: 23336
#include <iostream>
#include <algorithm>
using namespace std;
int A[2][128];
int dp[2][128];

int main() {
  int N; cin>>N;
  for(int i = 0; i < 2; i++) {
    for(int j =	0; j < N; j++) {
      cin>>A[i][j];
      dp[i][j] = 0;
    }
  }
  dp[0][0] = A[0][0];
  for(int i = 0; i < 2; i++) {
    for(int j = 0; j < N; j++) {
      if(i+1<2) dp[i+1][j] = max(dp[i+1][j], dp[i][j]+A[i+1][j]);
      if(j+1<N) dp[i][j+1] = max(dp[i][j+1], dp[i][j]+A[i][j+1]);
    }
  }
#ifdef DEBUG
  for(int i = 0; i < 2; i++) {
    for(int j = 0; j < N; j++) {
      cout << dp[i][j] << " " ;
    }
    cout << endl;
  }
#endif
  cout << dp[1][N-1] << endl;
  return 0;
}


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

void solve();

signed main () {
    cout.precision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;	
    int tt = t;
    while (t--) { 
        solve();
    }
    return 0;
}

void solve() {
	int m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;
	if (m2 == m1 + 1)
		cout << 1;
	else
		cout << 0;
}     	

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	int N = Integer.parseInt(br.readLine());
    	String line = br.readLine();
    	for(int i=0;i<N;i++){
    		String[] lines = line.split(" ");
    		int a = Integer.parseInt(lines[0]);
    		int b = Integer.parseInt(lines[1]);
    		int c = Integer.parseInt(lines[2]);
    		
    		if(a*a+b*b==c*c || a*a+c*c==b*b || b*b+c*c==a*a){
    			System.out.println("YES");
    		}else{
    			System.out.println("NO");
    		}
    		
    		line = br.readLine();
    	}
	}
}

Measured memory_bytes: 25864
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pi> vpi;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vld> vvld;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define popcount(x) __builtin_popcount(x)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define umap unordered_map

int n;
vll T = vll(4*2*pow(10, 5) + 100, 0);

void update(int i, ll val, int v=1, int tl=0, int tr=n-1){
	if (tl == tr){
		T[v] = val;
	}else{
		int mid = (tl + tr)/2;
		if (i <= mid){
			update(i, val, 2*v, tl, mid);
		}else{
			update(i, val, 2*v+1, mid+1, tr);
		}
		T[v] = max(T[2*v], T[2*v+1]);
	}
}

ll range_max(int l, int r, int v=1, int tl=0, int tr=n-1){
	if (r < tl or l > tr) return 0;
	if (l <= tl and tr <= r) return T[v];
	int mid = (tl + tr)/2;
	ll L = range_max(l, r, 2*v, tl, mid);
	ll R = range_max(l, r, 2*v+1, mid+1, tr);
	return max(L, R);
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n;
	vpi H = vpi(); //
	vi B = vi();
	rep(i, n){
		int x; cin >> x;
		H.pb({i, x});
	}	
	rep(i, n){
		int x; cin >> x;
		B.pb(x);
	}
	sort(
		all(H),
		[](pi a, pi b){return a.second < b.second;}
		);
	ll ans = 0;
	for(const auto& [orig_index, height] : H){
		ll locmax = B[orig_index] + range_max(0, orig_index);
		ans = max(ans, locmax);
		update(orig_index, locmax);
	}
	cout << ans;
}

Measured memory_bytes: 12884
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N; scanf("%d", &N);

	int ans = 0;
	FOR(i,1,N+1) ans += i;
	printf("%d\n", ans);


	return 0;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] lis = new int[n];
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            lis[i] = sc.nextInt();
            sum += lis[i];
        }


        int sum2 = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; ++i) {
            sum -= lis[i];
            sum2 += lis[i];
            min = Math.min(min, Math.abs(sum - sum2));
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  long n,k;
  cin >> n >> k;
  int a[n];
  int i,j;
  for(i=0;i<n;i++)cin>>a[i];
  long ans = 0;
  long const mod = 1e9+7;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(a[i]>a[j]){
        if(i>j){
          ans += k*(k-1)/2;
        }else if(i<j){
          ans += k*(k+1)/2;
        }
      }
      ans %= mod;
    }
  }
  cout<<ans<<endl;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

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

  rep(i, n){
    cin >> a[i];
    a[i] -= i;
  }

  map<ll, int> mp;
  rep(i, n){
    mp[a[i]]++;
  }

  ll ans = 0;
  rep(i, n){

    ll now = a[i];
    ll tar = -2* i - a[i];

    mp[now]--;
    
    ans += mp[tar];

  }

  cout << ans << endl;

  
  return 0;
}


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

int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;

  if (u == s)
    --a;
  if (u == t)
    --b;
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

#define INF 2000000000

struct edge{ int to, cost;};
struct P{ int d, to;};

int n;
int sz = 0; //heap size
P heap[20000];
vector<edge> G[10000]; //adjacency list
int d[10000];

//minimum heap
void push(P x){
  
  int i = sz++;
  
  while(i > 0){
    int p = (i - 1) / 2;
    
    if(heap[p].d <= x.d) break;
    
    heap[i] = heap[p];
    i = p;
  }
  
  heap[i] = x;
}

P pop(){
  
  P ret = heap[0];
  P x = heap[--sz];
  
  int i = 0;
  while(i * 2 + 1 < sz){
    
    int a = i * 2 + 1, b = i * 2 + 2;
    if(b < sz && heap[b].d < heap[a].d) a = b;
    
    if(heap[a].d >= x.d) break;
    
    heap[i] = heap[a];
    i = a;
  }
  
  heap[i] = x;
  
  return ret;
}

void dijkstra(int s){

  //initialization
  for(int i = 0;i < n;i++) d[i] = INF;
  d[s] = 0;
  push((P){0, s});
  
  while(sz){
    P p = pop();
    int v = p.to;
    
    if(d[v] < p.d) continue;
    for(int i = 0;i < (int)G[v].size();i++){
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        push((P){d[e.to], e.to});
      }
    }
  }
}

int main(){
  
  int u, k;
  edge e;

  //input
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> u >> k;
    for(int j = 0;j < k;j++){
      cin >> e.to >> e.cost;
      G[u].push_back(e);
    }
  }
  
  dijkstra(0);

  //output
  for(int i = 0;i < n;i++) cout << i << " " << d[i] << endl;
  
  return 0;
}



Measured memory_bytes: 7996
#include <iostream>
#include <cstdio>
using namespace std;
int Min(int a,int b){
  return a<b?a:b;
}
int Max(int a,int b){
  return a<b?b:a;
}
int a[100001];
int b[100001];
int main(){
  int N,T;
  int count=0;
  scanf("%d %d",&N,&T);
  for(int i=0;i<N;i++)scanf("%d",&a[i]);
  int min=a[0];
  int max=0;
  for(int i=1;i<N;i++){
    min=Min(min,a[i-1]);
    b[i]=a[i]-min;
    max=Max(max,b[i]);
  }
 
  for(int i=1;i<N;i++) {
    if(b[i]==max)count++;
  }
  printf("%d\n",count);
  return 0;
}


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

#ifdef _LOCAL_DEBUG
#include "templates/debug.h"
#else
#define debug(...)
#endif

bool is_palindrome(const string& s) {
    if (s.size() <= 1u)
        return true;
    int l = 0, r = (int)s.size() - 1;
    while (l < r) {
        if (s[l] != s[r])
            return false;
        l++, r--;
    }
    return true;
}

ll ans = 2e18;
map<pair<string, string>, ll> dis;
priority_queue<pair<ll, pair<string, string>>> que;

void push(const string& s1, const string& s2, ll cost) {
    auto pr = make_pair(s1, s2);
    auto it = dis.find(pr);
    if (it == dis.end() || it->second > cost) {
        dis[pr] = cost;
        que.emplace(-cost, pr);
    }
}

void consider(const string& s1, const string& s2, ll cost) {
    if (cost >= ans)
        return;
    int l1 = s1.size(), l2 = s2.size(), mn = min(l1, l2);
    for (int i = 0; i < mn; i++) {
        if (s1[i] != s2[l2 - i - 1])
            return;
    }
    if (l1 == l2) {
        ans = min(ans, cost);
        return;
    }
    if (l1 > l2) {
        string new_str = s1.substr(mn);
        if (is_palindrome(new_str))
            ans = min(ans, cost);
        else
            push(new_str, "", cost);
    } else {
        string new_str = s2.substr(0, l2 - l1);
        if (is_palindrome(new_str))
            ans = min(ans, cost);
        else
            push("", new_str, cost);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<string> strs(n);
    vector<ll> cost(n);
    for (int i = 0; i < n; i++) {
        cin >> strs[i] >> cost[i];
        consider(strs[i], "", cost[i]);
    }
    while (que.size()) {
        auto [d, pr] = que.top();
        que.pop();
        d *= -1;
        if (d != dis[pr]) {
            continue;
        } else {
            for (int i = 0; i < n; i++) {
                if (pr.first.empty())
                    consider(strs[i], pr.second, d + cost[i]);
                else
                    consider(pr.first, strs[i], d + cost[i]);
            }
        }
    }
    if (ans >= 2e18)
        cout << "-1\n";
    else
        cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3708
def main():
    n = int(input())
    ps = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        if ps[i] == i+1:
            if ps[i] == n:
                ps[i-1], ps[i] = ps[i], ps[i-1]
            else:
                ps[i], ps[i+1] = ps[i+1], ps[i]
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int count =0;
    int res = 0;
    for(int i=0;i<s.length();i++){
        if(s[i] == 'R'){
            count++;
            res = max(res,count);
        }
        else{
            count =0;
        }
            
    }
    cout<<res;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

template <class T> struct fenwick_tree {

  public:
    fenwick_tree() : _n(0) {}
    fenwick_tree(int n) : _n(n), data(n) {}

    void add(int p, T x) {
        assert(0 <= p && p < _n);
        p++;
        while (p <= _n) {
            data[p - 1] += x;
            p += p & -p;
        }
    }

    T sum(int l, int r) {
        assert(0 <= l && l <= r && r <= _n);
        return sum(r) - sum(l);
    }

  private:
    int _n;
    std::vector<T> data;

    T sum(int r) {
        T s = 0;
        while (r > 0) {
            s += data[r - 1];
            r -= r & -r;
        }
        return s;
    }
};

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

    int n, q;
    cin >> n >> q;
    fenwick_tree<ll> t(n);
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        t.add(i, x);
    }
    for (int i = 0; i < q; i++)
    {
        int tp, a, b;
        cin >> tp >> a >> b;
        if (tp == 0)
        {
            t.add(a, b);
        }
        else
        {
            cout << t.sum(a, b) << "\n";
        }
    }
}


Measured memory_bytes: 8248
h,w,k = map(int,input().split())
c = list(input() for _ in range(h))
ans = 0
for i in range(1<<h):
    for j in range(1<<w):
        b = 0
        for y in range(h):
            for x in range(w):
                if i>>y&1 and j>>x&1 and c[y][x] == "#":
                    b+=1
        if b==k:
            ans+=1
print(ans)

Measured memory_bytes: 9208
import sys
from bisect import bisect_left
read = sys.stdin.read
readline = sys.stdin.readline


def main():
    N, *A = map(int, read().split())

    a = [-1] * N

    for i in A:
        n = bisect_left(a, i)
        a[n - 1] = i

    print(N - a.count(-1))


if __name__ == '__main__':
    main()

Measured memory_bytes: 14092
#include <iostream>
#include <algorithm>

using namespace std;

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

    int a[N], i;
    for(i=0; i<N; i++) {
        cin >> a[i];
    }

    sort(a, a+N);

    int count=0;
    for(i=0; i<N; i++) {
        x -= a[i];
        if(x<0) {
            break;
        } else if(x==0){
            count += 1;
            break;
        } else {
            count += 1;
        }
    }

    if(x>0) {
        count -= 1;
    }

    cout << count << endl;

    return 0;

}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define _P(...) (void)fprintf(stderr, __VA_ARGS__)

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
 
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n), b(n), c(n);
	rep(i,n) cin >>a[i];
	rep(i,n) cin >>b[i];
	rep(i,n) cin >>c[i];
	
	sort(all(a));
	sort(all(b));
	sort(all(c));
	ll ans = 0;
	rep(i, n){
	
		int crb= b[i];
		
		auto it = lower_bound(all(a), crb);
		ll asu = it - a.begin();
		
		auto it2 = upper_bound(all(c), crb);
		ll csu = n -(it2 - c.begin()) ;
		ans += asu * csu;
		dbg("b=",crb,"a,c=",*it,asu,*it2,csu,ans);
	}
	
	cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 1408