akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        k: usize,
        td: [(usize1, i64); n],
    }
    let mut dt = vec![];
    for (t, d) in td {
        dt.push((d, t));
    }
    dt.sort(); dt.reverse();
    let mut que = BinaryHeap::new();
    let mut seen = vec![false; n];
    let mut tot = 0;
    let mut kind = 0;
    for i in 0 .. k {
        let (d, t) = dt[i];
        tot += d;
        if seen[t] {
            que.push((-d, t));
        } else {
            seen[t] = true;
            tot += 2 * kind + 1;
            kind += 1;
        }
    }
    let mut ma = tot;
    for i in k .. n {
        let (d, t) = dt[i];
        // No point of picking it. Skip.
        if seen[t] { continue; }
        let profit = d + 2 * kind + 1;
        if let Some((tap, _ris)) = que.pop() {
            let tap = -tap;
            tot += profit - tap;
            seen[t] = true;
            kind += 1;
        }
        ma = max(ma, tot);
    }
    puts!("{}\n", ma);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

#include <iostream>


#define MOD 1000000007

typedef unsigned long long ull;
typedef long long ll;

using namespace std;
auto f=[]()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
};

int main()
{
	f();
	int r,d,x;cin>>r>>d>>x;
	int i=10;
	int prev=x;
	while(i--)
	{
		int n=r*prev-d;
		cout<<n<<'\n';
		prev=n;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int a;
	cin >> a;
    int ans = a*a*a + a*a + a;
	cout << ans << "\n";
	return 0;
}


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

int main() {
	long long max=0,max2=0,n,a;
	vector<int> v;
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a;
		if (a>max){
			max2=max;
			max=a;}
		else if (a>max2)
		  max2=a;
		v.push_back(a);}
	
	for (int i=0;i<n;i++){
		if (v[i]!=max)
		cout<<max<<endl;
		else
		cout<<max2<<endl;
	}
  return 0;
}

Measured memory_bytes: 2548
#include<cstdio>

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

using namespace std;

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

struct edge{ int x1,y1,x2,y2,cost; };

int h,w,d;
int sig[20][20]; // 交差点 [y][x] にある信号の周期
int n_ban,n_jam;
edge ban[800],jam[800];
int sx,sy,gx,gy;

int solve(){
	static bool dp[101][20][20][4];
	rep(t,101) rep(i,h) rep(j,w) rep(k,4) dp[t][i][j][k]=false;
	dp[0][sy][sx][0]=true;
	rep(t,101) rep(i,h) rep(j,w) rep(k,4) {
		if(!dp[t][i][j][k]) continue;
		if(sig[i][j]!=0 && t/sig[i][j]%2==k%2) continue; // 信号が赤ならそこで打ち止め

		rep(k2,4) if((k-k2+4)%4!=2) { // k2 方向に進む
			int i2=i+dy[k2],j2=j+dx[k2];
			if(0<=i2 && i2<h && 0<=j2 && j2<w){
				// 道路が封鎖されていたらそこで打ち止め
				bool isban=false;
				rep(l,n_ban){
					if(ban[l].x1==j && ban[l].y1==i && ban[l].x2==j2 && ban[l].y2==i2
					|| ban[l].x2==j && ban[l].y2==i && ban[l].x1==j2 && ban[l].y1==i2) isban=true;
				}
				if(isban) continue;

				int t_jam=0;
				rep(l,n_jam){
					if(jam[l].x1==j && jam[l].y1==i && jam[l].x2==j2 && jam[l].y2==i2
					|| jam[l].x2==j && jam[l].y2==i && jam[l].x1==j2 && jam[l].y1==i2) t_jam=jam[l].cost;
				}

				int t2=t+d+t_jam;
				if(t2<=100){
					dp[t2][i2][j2][k2]=true;
				}
			}
		}
	}

	rep(t,101) rep(k,4) if(dp[t][gy][gx][k]) return t;
	return -1;
}

int main(){
	char a;
	int b;
	for(;scanf("%d%d%d",&h,&w,&d),h;){
		rep(i,h) rep(j,w) sig[i][j]=0; // 0 なら信号がない

		int n_sig; scanf("%d",&n_sig);
		rep(i,n_sig){
			int t;
			scanf(" %c%*c%d%d",&a,&b,&t);
			sig[a-'a'][b-1]=t;
		}

		scanf("%d",&n_ban);
		rep(i,n_ban){
			scanf(" %c%*c%d",&a,&b);
			ban[i].x1=b-1;
			ban[i].y1=a-'a';
			scanf(" %c%*c%d",&a,&b);
			ban[i].x2=b-1;
			ban[i].y2=a-'a';
		}

		scanf("%d",&n_jam);
		rep(i,n_jam){
			int t;
			scanf(" %c%*c%d",&a,&b);
			jam[i].x1=b-1;
			jam[i].y1=a-'a';
			scanf(" %c%*c%d%d",&a,&b,&t);
			jam[i].x2=b-1;
			jam[i].y2=a-'a';
			jam[i].cost=t;
		}

		{
			scanf(" %c%*c%d",&a,&b);
			sx=b-1;
			sy=a-'a';
			scanf(" %c%*c%d",&a,&b);
			gx=b-1;
			gy=a-'a';
		}

		printf("%d\n",solve());
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
void solve() {
   string s1,s2;
   cin>>s1>>s2;
   if(s2.substr(0,s2.length()-1) == s1) cout<<"Yes\n";
   else cout<<"No\n";
}
int main() {
    int t; t = 1;
    while(t--) {
        solve();
    }
}

Measured memory_bytes: 3628
package main

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

func main() {
	//a := 123456789
	//b := 31415926535897932384626433832795028841971693993751058209749445923078164062862089986280
	reader := bufio.NewReader(os.Stdin)
	input, _ := reader.ReadString('\n')

	t := 0
	for _, v := range input {
		if v < '1' || v > '8' {
			continue
		}

		cv := int(v - '0')
		//fmt.Println(cv)

		t = (t + cv) % 9
	}
	if t == 0 {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ul n;
  cin >> n;
  vector< ul > a(n);
  for (ul i=0; i<n; ++i) cin >> a[i];
  vector< ul > cum(n+1);
  cum[0] = 0;
  ul ans = 0;
  for (ul i=0; i<n; ++i) cum[i+1] = cum[i]+a[i];
  for (ul i=0; i<n; ++i) {
    auto it1 = upper_bound(cum.begin(), cum.begin()+i, cum[i]/2) - cum.begin();
    auto it2 = upper_bound(cum.begin()+1, cum.end(), (cum[i]+cum[n])/2) - cum.begin();
    vector< ul > p(4);
    for (ll x1=it1-1; x1<=it1+1; ++x1) {
      for (ll x2=it2-1; x2<=it2+2; ++x2) {
	if (0>=x1 || x1>=i || i>=x2 || x2>=n) continue;
	p[0] = cum[x1], p[1] = cum[i]-cum[x1], p[2] = cum[x2]-cum[i], p[3] = cum[n]-cum[x2];
	sort(p.begin(), p.end());
	if (ans == 0) ans = p[3]-p[0];
	else ans = min(ans, p[3]-p[0]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3456
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
for l in range(len(N)):
    S = N[l]
    skip = 0
    for i in range(len(S)):
        if skip > 0:
            skip -= 1
        elif S[i] == "@":
            n = int(S[i+1])
            for j in range(n):
                print(S[i+2],end="")
            skip = 2
        else:
            print(S[i],end="")
    print("")



Measured memory_bytes: 5592
#include <stdio.h>
#include <stdlib.h>

struct word{
    char w[31];
    int p;
}wo[1000];

int compare(const void *a,const void *b){
    int i;
    for(i=0;;i++){
        if(((struct word *)a)->w[i]!='\0'&&((struct word *)b)->w[i]=='\0')return 1;
        if(((struct word *)a)->w[i]=='\0'&&((struct word *)b)->w[i]!='\0')return -1;
        if(((struct word *)a)->w[i]=='\0'&&((struct word *)b)->w[i]=='\0'){
            return ((struct word *)a)->p-((struct word *)b)->p;
        }
        if(((struct word *)a)->w[i]!=((struct word *)b)->w[i]){
            return ((struct word *)a)->w[i]-((struct word *)b)->w[i];
        }

    }
    return 0;
}

int main(void) {
    int i=0,j,k,d;
    char s;

    while(scanf("%s%d",wo[i].w,&(wo[i].p))!=EOF)i++;
    /*
    puts("");
    for(j = 0;j < i;j++){
        printf("%s %d\n",wo[j].w,wo[j].p);
    }
    */
    qsort(wo,i,sizeof(struct word),compare);

    /*
    puts("");
    for(j = 0;j < i;j++){
        printf("%s %d\n",wo[j].w,wo[j].p);
    }
    */

    for(j=0;j<i;j++){
        printf("%s\n%d",wo[j].w,wo[j].p);
        for(k=j+1;strcmp(wo[j].w,wo[k].w)==0;k++){
            printf(" %d",wo[k].p);
        }
        puts("");
        j=k-1;
    }
    i=0;

    return 0;
}

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

int main (){
    int H,W;
    cin >> H >> W;
    int c[10][10];
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin >> c[i][j];
        }
    }
    int a[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> a[i][j];
        }
    }
    for(int k=0;k<10;k++){
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
            }
        }
    }
    int ans=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(a[i][j]!=-1&&a[i][j]!=1){
                ans+=c[a[i][j]][1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
using namespace std;
typedef long long ll;

vector<pair<int, int>> to[100010];
bool visited[100010];
ll dist[100010];
ll gcd(ll a, ll b)
{
   if (b == 0)
   {
       return a;
   }
    return gcd(b, a%b);
}
void dfs(int now, ll d) {
  visited[now] = true;
  dist[now] = d;
  for (auto p : to[now]) {
    if (visited[p.first]) continue;
    dfs(p.first, d + p.second);
  }
}
vector<int>ans(10050,0);
void f(ll n){
    for (ll x = 1; x<n;x++){
        for (ll y = 1; y<n;y++){
            for (ll z = 1; z<n;z++){
                ll v = (x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(z*x);
                if(v<10050) ans[v]++;
            }
        }
    }
}

int main() {
    int n;
    f(105);
    string s;
    cin>>n;
    rep(i,1,n+1){
        cout << ans[i]<<endl;
    }
   
   
    return 0;
}


Measured memory_bytes: 5976
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n, k;
	int sum = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		int a = k - x;
		if (x > a)
		{
			sum += 2 * a;
		}
		else{
			sum += 2 * x;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
const int INF = 1001001001;
const ll MOD = 1e9+7;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill((T*)array, (T*)(array+N),val);}

class CompareDist
{
public:
    bool operator()(PLL n1,PLL n2) {
				if(n1.first!=n2.first) return n1.first<n2.first;
				else return n1.second<n2.second;
    }
};


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n; cin>>n;
  string s; cin>>s;
  int ans = 0;
  // set a,b,c;
  rep(i,1000){
    ostringstream oss;
    oss << setw(3) << setfill('0') <<i;
    string key = oss.str();
    // string key = i.ToString("000");
    // cerr << key << ' ';
    int idx = 0;
    rep(j,n){
      if(key[idx]==s[j]){
        idx++;
      }
    }
    if(idx>2) ans++;
    // cerr << idx << endl;
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
        return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
        return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
                in >> x;
        return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
    for (const vector<T> &x : v)
                out << x << '\n';
        return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
    for (const T &x : v)
                out << x << ' ';
        return out;
}
 
template <class T>
ostream& operator << (ostream& out,const set<T> &s)
{
    for (const T &x : s)
            out << x << ' ';
        return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define epsilon 0.00000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl "\n"
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

ll dp[2001];
ll fun(ll n)
{
    if(n==0)
        return 1;
    if(n<3)
        return 0;
    if(dp[n]!=-1)
        return dp[n];
    ll ans=0;
    for(ll i=3;i<=n;i++)
    {
        ans+=fun(n-i);
        ans%=mod;
    }
    return dp[n]=ans;
}
int main()
{
    for(ll i=0;i<=2000;i++)
        dp[i]=-1;
    fast();
    ll n;
    cin>>n;
    cout<<fun(n)<<nl;
}


Measured memory_bytes: 3644
import java.util.Scanner;

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

		inbase += inbase;
		if(inbase.indexOf(inmatch) == -1){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 26220
#include<algorithm>
#include<cmath>
#include<cctype>
#include<iomanip>
#include<iostream>
#include<map>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define each(e, v) for (auto&& e : v)
#define clamp(v,lo,hi) min(max(v,lo),hi)
#define debug(i) cout<<"point :"<< i << endl;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef vector<int> vint;
typedef vector<long> vl;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef map<string, int> mapstri;
typedef map<int, int> mapii;
typedef std::pair<int, int> pairii;

int main () {
    double n,m;
    cin >> n >> m;
    vdouble v(n);
    for (int i = 0; i < n; ++i) cin >> v.at(i);
    sort(v.begin(), v.end(), greater<double>());
    bool j = true;
    double sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += v.at(i);
    }

    for (int i = 0; i < m; ++i) {
        if(v.at(i) < (sum / (4 * m))) {
            j = false;
        }
    }
    if (j) {
        out("Yes")
    } else {
        out("No")
    }

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main()
{
    int n;cin>>n;
    vector<queue<int>> a(n);
    REP(i,n){
        REP(j,n-1){
            int t;cin>>t;t--;
            a[i].push(t);
        }
    }

    LL day = 0;
    LL zan = n*(n-1)/2;

    VI kouho;
    REP(i,n){
        kouho.PB(i);
    }

    for(;!kouho.empty();day++){
        VI next_kouho;
        set<int> matched;
        for(auto jibun : kouho){
            if(matched.find(jibun)!=matched.end()){
                continue;
            }
            int aite = a[jibun].front();
            if(matched.find(aite)!=matched.end()){
                continue;
            }
            if(a[aite].front() == jibun){
                zan--;
                a[jibun].pop();
                a[aite].pop();
                matched.insert(jibun);
                matched.insert(aite);
                if(!a[jibun].empty()){
                    next_kouho.PB(jibun);
                }
                if(!a[aite].empty()){
                    next_kouho.PB(aite);
                }
            }
        }
        kouho = next_kouho;
    }

    if(zan!=0){
        cout<<-1<<endl;
        return;
    }
    cout<<day<<endl;
    
	return;
}

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

Measured memory_bytes: 8104
n,a,b,c,d=map(int,input().split())
s=list(str(input()))
for i in range(a+1,max(c,d)-1):
    if s[i]==s[i+1]=='#':
        print('No')
        break
else:
    if c<d:
        print('Yes')
    else:
        for i in range(b-2,d-1):
            if s[i]==s[i+1]==s[i+2]=='.':
                print('Yes')
                break
        else:
            print('No')

Measured memory_bytes: 61296
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>
#include <sstream>
#include <bitset>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
#define MOD ((int)1e9+7)
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

struct Combination {
	const int num=51e4;			//要素数
	const int mod=1e9+7;
	vector<ll> fact,inv,finv; //階乗,逆元,逆元の階乗.
	
	Combination():fact(num),inv(num),finv(num){
		fact[0]=fact[1]=1;
		inv[1]=1;
		finv[0]=finv[1]=1;
		for(int i=2;i<num;++i){
			fact[i]=fact[i-1]*i%mod;
			inv[i]=mod-inv[mod%i]*(mod/i)%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	
	int nCk(int n,int k){
		if(n<k) return 0;
		if(n<0 or k<0) return 0;
		return fact[n]*(finv[k]*finv[n-k]%mod)%mod;
	}
	int big_nCk(int n,int k){ //nが大きいとき
		ll res=1LL;
		for (int i = 0; i < k; i++) {
			res=res*(n-i)%mod;
		}
		res = res*finv[k]%mod;
		return res;
	}
	int nHk(int n,int k){return nCk(n+k-1,n-1);}//重複組み合わせ.
};

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

ll pow_mod(ll n, ll k, ll p) { // n^k(mod p)
	if (k == 0) {
		return 1;
	}
	ll res = pow_mod(n * n % p, k / 2, p);
	if (k & 1) {
		res = res * n % p;
	}
	return res;
}

bool vector_finder(std::vector<int> vec, int number) { // vector 内にnumberがあるかどうか
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance( vec.begin(), itr );
	if (index != vec.size()) { // 発見できたとき
		return true;
	}
	else { // 発見できなかったとき
		return false;
	}
}

int main() {
	int n, x, t;
	cin >> n >> x >> t;
	int ans = (n % x == 0) ? n/x : n/x + 1;
	return cout << ans * t , 0;
}

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

int main()
{
  i64 n, c;
  cin >> n >> c;
  vector<i64> p(c);
  for (i64 i = 0; i < c; i++)
    cin >> p[i];
  i64 sum = 0;
  for (i64 i = 0; i < c; i++)
    sum += p[i];
  cout << (sum + n) / (n + 1) << endl;
  return 0;
}



Measured memory_bytes: 3084
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    for(int n, m, p, res; cin >> n >> m >> p, n; cout << res << endl){
        res = 0;
        m--;

        int sum = 0, num;
        rep(i, n){
            int x; cin >> x;

            sum += x;
            if(i == m) num = x;
        }

        if(num) res = sum * (100 - p) / num;
    }

	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <map>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
/*---------------------------------------*/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int k, s; cin >> k >> s;
  int ans = 0;
  REP(i, k+1) {
    REP(j, k+1) {
      if (s-i-j >= 0 && s-i-j<=k) ++ans;
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

/* 200*(200+1)*(200+2)/6==1353400 */
int num_list[200];

int result_normal[1000001];
int result_kisuu[1000001];

int main(void) {
	int n;
	for(n=1;n<=200;n++) {
		num_list[n-1]=n*(n+1)*(n+2)/6;
	}
	result_normal[0]=result_kisuu[0]=0;
	for(n=1;n<1000000;n++) {
		int i;
		int normal=10000000;
		int kisuu=10000000;
		for(i=0;i<200 && num_list[i]<=n;i++) {
			int nowresult;
			nowresult=result_normal[n-num_list[i]]+1;
			if(nowresult<normal)normal=nowresult;
			if(num_list[i]%2==1) {
				nowresult=result_kisuu[n-num_list[i]]+1;
				if(nowresult<kisuu)kisuu=nowresult;
			}
		}
		result_normal[n]=normal;
		result_kisuu[n]=kisuu;
	}
	while(scanf("%d",&n)==1 && n>0) {
		printf("%d %d\n",result_normal[n],result_kisuu[n]);
	}
	return 0;
}

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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int N;
    int ans=0;
    cin >> N;
    vector<string> s;
    vector<int> t;
    string title_tmp;
    int time_tmp;
    bool sleep_flag;

    rep(i,N){
        cin >> title_tmp >> time_tmp;
        s.push_back(title_tmp);
        t.push_back(time_tmp);
    }
    string X;
    cin >> X;
    int target_idx;

    rep(i,N){
        if(X ==  s.at(i)){
            target_idx = i;
            break;
        }
    }

    target_idx++;

    for(int i = target_idx;i<N;i++){
        ans += t[i];
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>

using namespace std;

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

    int one_index = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '1')
        {
            one_index++;
        }
        else
        {
            break;
        }
    }
    if (one_index >= K)
    {
        cout << 1 << endl;
        return 0;
    }
    else
    {
        cout << s[one_index] << endl;
        return 0;
    }
}

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

int main() {
    int n;
    cin>>n;
    vector<int> vi(n,0);
    for (size_t i = 0; i < n; i++)
    {
        cin >> vi[i];
    }
    std::sort(vi.begin(),vi.end());
    int a,b;
    a=vi[n/2-1];
    b=vi[n/2];
    cout << b-a<<endl;
    return 0;
}

Measured memory_bytes: 640
# 3 3 1 1
#
# 100
# 010
# 001

# 1 5 2 0
# 01010

# 4 4 2 2 
# 1100
# 1100
# 0011
# 0011

# 3 5 2 1
# 11000
# 11000
# 00111

H,W,A,B=map(int,input().split())
for i in range(B):
  print("1" * A + "0" * (W-A))
for i in range(H-B):
  print("0" * A + "1" * (W-A))

Measured memory_bytes: 3956
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue
import scala.collection.mutable
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val A = Array.fill(sc.nextInt)(sc.nextInt).sorted.reverse
    var ans = 0
    for (i <- A) {
      ans += i
      ans *= -1
    }
    println(math.abs(ans))
  }

  def gcd(i: Int, j: Int): Int = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 25536
#include <bits/stdc++.h>
#define For(i, l, r) for(int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x << 1) + (x << 3) + (ch ^ '0');
    return x * fh;
}


void File() {
#ifdef zjp_shadow
	freopen ("F.in", "r", stdin);
	freopen ("F.out", "w", stdout);
#endif
}

const int N = 55, M = 205;

typedef long long ll;
const ll Mod = 1e9 + 7;

ll fpm(ll x, int power) {
	ll res = 1;
	for (; power; power >>= 1, (x *= x) %= Mod)
		if (power & 1) (res *= x) %= Mod;
	return res;
}

ll fac[M], ifac[M];

void Init(int maxn) {
	fac[0] = ifac[0] = 1ll;
	For (i, 1, maxn) fac[i] = fac[i - 1] * i % Mod;
	ifac[maxn] = fpm(fac[maxn], Mod - 2);
	Fordown (i, maxn - 1, 1) ifac[i] = ifac[i + 1] * (i + 1) % Mod;
}

ll C(int m, int n) {
	if (m > n || n < 0 || m < 0) return 0ll;
	return fac[n] * ifac[m] % Mod * ifac[n - m] % Mod;
}

set <int> Point;
int n, m, k; ll ans = 1ll;

ll Polya(int n) {
	ll res = 0;
	For (i, 1, n) (res += fpm(k, __gcd(n, i))) %= Mod;
	return res * fpm(n, Mod - 2) % Mod;
}

ll Permu(int m) { return C(k - 1, m + k - 1); }

vector<int> G[N];
int dfn[N], lowlink[N], sta[N], top;
void Tarjan(int u, int fa) {
	static int clk = 0;
	dfn[u] = lowlink[u] = (++ clk); sta[++ top] = u;

	for (int v : G[u]) if (!dfn[v]) {
		Tarjan(v, u), chkmin(lowlink[u], lowlink[v]);
		if (lowlink[v] >= dfn[u]) {
			Point.clear();
			int n = 0, m = 0, Last;
			do Point.insert(Last = sta[top --]), ++ n; while (Last != v);
			Point.insert(u), ++ n;
			for (int x : Point) for (int v : G[x])
				if ((bool)Point.count(v)) ++ m;
			m >>= 1;

			if (m < n) (ans *= k) %= Mod;
			if (m == n) (ans *= Polya(n)) %= Mod;
			if (m > n) (ans *= Permu(m)) %= Mod;
		}
	} else chkmin(lowlink[u], dfn[v]);
	//if (!fa) -- top;
}

int main () {
	File();
	n = read(), m = read(); k = read();
	Init(m + k + 5);

	For (i, 1, m) {
		int u = read(), v = read();
		G[u].push_back(v);
		G[v].push_back(u);
	}

	For (i, 1, n) if (!dfn[i]) Tarjan(i, 0);
	printf ("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
local read = io.read

local W, H, N = read("*n", "*n", "*n")
local rectangle = {}
for x = 1, W do
	rectangle[x] = {}
	for y = 1, H do
		rectangle[x][y] = true
	end
end

local function paint(x_i, y_i, a_i)
	if a_i == 1 then
		for x = 1, x_i do
			for y = 1, H do
				rectangle[x][y] = false
			end
		end
	elseif a_i == 2 then
		for x = x_i + 1, W do
			for y = 1, H do
				rectangle[x][y] = false
			end
		end
	elseif a_i == 3 then
		for x = 1, W do
			for y = 1, y_i do
				rectangle[x][y] = false
			end
		end
	else
		for x = 1, W do
			for y = y_i + 1, H do
				rectangle[x][y] = false
			end
		end
	end
end

for i = 1, N do
	paint(read("*n", "*n", "*n"))
end

local out = 0
for x = 1, W do
	for y = 1, H do
		if rectangle[x][y] then
			out = out + 1
		end
	end
end

print(out)


Measured memory_bytes: 2772
import sys

N= int(input())

*A, = map(int, input().split())


S = [0]*(len(A)+1)

for i in range(1, len(S), 1):

    S[i] = S[i-1] + A[i-1]

x = 0
y = 0
min = float('inf')

for i in range(1, N, 1):
    x = S[i]
    y = S[len(S)-1] - S[i]

    if min > abs(x-y):
        min = abs(x-y)
print(min)

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

#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

void solve()
{
	ll n,m,k,final=0;
	cin>>n>>m>>k;
	
	char arr[n][m];
	for(ll i=0;i<n;i++) 
	{
		for(ll j=0;j<m;j++)
		{
			cin>>arr[i][j];
		}
	}
	
	for(ll i=0;i<pow(2,n);i++)
	{
		vector<ll> vr;
		for(ll j=0;j<n;j++) if(i & (1<<j)) vr.push_back(j);
		for(ll j=0;j<pow(2,m);j++)
		{
			vector<ll> vc;
			for(ll kk=0;kk<m;kk++) if(j & (1<<kk)) vc.push_back(kk);
			
			char temp[n][m];
			for(ll t1=0;t1<n;t1++) for(ll t2=0;t2<m;t2++) temp[t1][t2]=arr[t1][t2];
			
			for(ll t1=0;t1<vr.size();t1++)
			{
				for(ll t2=0;t2<m;t2++) temp[vr[t1]][t2]='.';
			}
			for(ll t1=0;t1<vc.size();t1++)
			{
				for(ll t2=0;t2<n;t2++) temp[t2][vc[t1]]='.';
			}
			
			ll cnt=0;
			for(ll t1=0;t1<n;t1++) for(ll t2=0;t2<m;t2++) if(temp[t1][t2]=='#') cnt++;
			if(cnt==k) final++;
		}
	}
	cout<<final;
}

int main()
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

Measured memory_bytes: 3956
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var ans = false;

            var X = cin.ReadInt;
            var Y = cin.ReadInt;

            for (int i = 0; i <= X; i++)
            {
                var foots = 2 * i + 4 * (X - i);
                if (foots == Y) 
                {
                    ans = true;
                    break;
                }
            }

            WriteLine(ans ? "Yes" : "No");
        }

        public void Display(int[] array)
        {
            var txt = "";
            foreach (var item in array)
            {
                txt += " " + item.ToString();
            }
            WriteLine("{0}", txt);
        }

        public void Display(int index,int[] array)
        {
            var txt = "";
            foreach (var item in array)
            {
                txt += " " + item.ToString();
            }
            WriteLine("{0} : {1}", index,txt);
        }

        public void Display(List<int>[] list) 
        {
            for (int i = 0; i < list.Length; i++)
            {
                Display(i, list[i].ToArray());
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 27876
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string s;
	cin>>s;
	s="A"+s;
	int co=0;
	rep(i,s.size()-1)if(s[i]>=s[i+1])co++;
	cout<<co<<endl;
}







Measured memory_bytes: 3220
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,x,m=nii()

ans=x
x_list=[x]
zan=0
for i in range(n-1):
  a=(x**2)%m
  ans+=a
  x=a
  if x in x_list:
    inx=x_list.index(x)
    zan=(n-1)-i-1

    inx=x_list.index(x)+1
    nx_list=x_list[inx:]+[x_list[inx-1]]

    if zan<=len(nx_list):
      ans+=sum(nx_list[:zan])
    else:
      num=zan//len(nx_list)
      q=zan%len(nx_list)
      ans+=sum(nx_list)*num
      ans+=sum(nx_list[:q])
    break
  else:
    x_list.append(x)

print(ans)

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

int main() {
  int n; cin >> n;
  vector<int> li(n);
  int m = 0;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> li.at(i);
    m = max(m, li.at(i));
    sum += li.at(i);
  }
  if (m < sum-m) cout << "Yes" << endl;
  else cout << "No" << endl; 
}

Measured memory_bytes: 256
s = input()

s1 = int(s[0:2])
s2 = int(s[2:4])

if (s1 == 0 or s1 > 12) and (s2 == 0 or s2 > 12):
    print("NA")
elif (0 < s1 < 13) and (0 < s2 < 13):
    print("AMBIGUOUS")
else:
    if (0 < s1 < 13):
        print("MMYY")
    else:
        print("YYMM")


Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

ll inv(ll x){
    // MOD=10e9+7
	ll n=MOD-2,a=1;
	while(n>0){
		if(n%2) a=a*x%MOD;
		x=x*x%MOD;
		n=n/2;
	}
	return a;
}

ll Comb(ll n,ll m){
    ll ans = 1; 
    for(int i=0;i < m; i++){
        ans *= ((n-i)*inv(i+1)) % MOD;
        ans %= MOD;
    }
    return ans;
}

ll PowMod(ll N,ll P,ll M){
    ll ans = 1;
    while(P >= 1){
        if(P % 2)ans = ans * N % M;
        N = N*N %M;
        P /= 2;
    }
    ans %= M;
    return ans;
}

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans = (PowMod(2,n,MOD)-Comb(n,a)-Comb(n,b)-1)%MOD;
    while(ans < 0)ans+=MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<string.h>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



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


int H = 0;
int M = 0;
int S = 0;

void input(void) {
	CI H >> M >> S;

	return;
}


int main(void) {
	int sum = 0;
	int remain = 0;
	int remain3 = 0;
	int hour = 0;
	int minute = 0;
	int second = 0;

	while (1) {
		input();
		if (H == -1) {
			return 0;
		}
		sum = H * 3600 + M * 60 + S;
		remain = 2 * 3600 - sum;
		remain3 = remain * 3;
		second = remain % 60;
		remain -= remain % 60;
		remain /= 60;
		minute = remain % 60;
		remain -= remain % 60;
		remain /= 60;
		hour = remain;
		printf("0%d:", hour);
		if (minute < 10) {
			printf("0%d:", minute);
		}
		else {
			printf("%d:", minute);
		}
		if (second < 10) {
			printf("0%d", second);
		}
		else {
			printf("%d", second);
		}
		CO "\n";

		second = remain3 % 60;
		remain3 -= remain3 % 60;
		remain3 /= 60;
		minute = remain3 % 60;
		remain3 -= remain3 % 60;
		remain3 /= 60;
		hour = remain3;
		printf("0%d:", hour);
		if (minute < 10) {
			printf("0%d:", minute);
		}
		else {
			printf("%d:", minute);
		}
		if (second < 10) {
			printf("0%d", second);
		}
		else {
			printf("%d", second);
		}
		CO "\n";
	}

	return 0;
}

Measured memory_bytes: 3192
# A - AtCoDeerくんとペンキ / AtCoDeer and Paint Cans

A = list(map(str, input().split()))
count = 0
for i in range(len(A)-1):
    if A[i] != A[i+1]:
        count += 1
    else:
        pass
if A[0] != A[2]:
    count += 1
else:
    pass
if A[0] == A[1] ==A[2]:
    count = 1

print(count)

Measured memory_bytes: 3060
H,W=map(int,input().split())
N=10
c=[[int(i) for i in input().split()] for i in range(N)]
A=[[int(i) for i in input().split()] for i in range(H)]
for i in range(N):
    for j in range(N):
        for k in range(N):
            if c[i][k]+c[k][j]<c[i][j]:
                c[i][j]=c[i][k]+c[k][j]
for i in range(N):
    for j in range(N):
        for k in range(N):
            if c[i][k]+c[k][j]<c[i][j]:
                c[i][j]=c[i][k]+c[k][j]
for i in range(N):
    for j in range(N):
        for k in range(N):
            if c[i][k]+c[k][j]<c[i][j]:
                c[i][j]=c[i][k]+c[k][j]

ans=0
for i in range(H):
    for j in range(W):
        if A[i][j]==-1:
            continue
        ans+=c[A[i][j]][1]
print(ans)


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

#include <climits>

#define DEBUG if(false)

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N, 0);
  int which_1 = -1;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(A[i] == 1){
      which_1 = i;
    }
  }
  int K_left = (which_1-K+1>0)?which_1-K+1:0; //デフォルト
  DEBUG printf("K_left : %d\n", K_left);
  int minimum = INT_MAX;
  for(int i = 0; i < K; i++){
    int l_left = K_left + i;
    int r_left = l_left + K-1;
    if(r_left > N-1) break;
    DEBUG printf("l_left : %d\n", l_left);
    DEBUG printf("r_left : %d\n", r_left);

    int count = 1;
    count += (l_left + K-2)/(K-1);
    count += (N-1 - r_left + K-2)/(K-1);
    DEBUG printf("%d\n", count);
    if(minimum > count){
      minimum = count;
    }
  }
  cout << minimum << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    string ans = "";
    while(n>0)
    {
        ans = ans + char(97 + (n-1)%26);
        n = (n-1)/26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <algorithm>
#define maxn 55
using namespace std;
int n,m,q,st=maxn,ed=0,sum;
int a[maxn],b[maxn],c[maxn],d[maxn],p[15];
void dfs(int step){
	int i,j;
	if(step==ed+1){
		int t=0;
		for(j=1;j<=q;j++)//尝试测试数据
			if(p[b[j]]-p[a[j]]==c[j])t+=d[j];
		sum=max(sum,t);
		return;
	}
	for(i=p[step-1];i<=m;i++){
		p[step]=i;
		dfs(step+1);
	}
}
int main(){
	int i;
	scanf("%d%d%d",&n,&m,&q);
	for(i=1;i<=q;i++)scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]),st=min(st,a[i]),ed=max(ed,b[i]);
	ed=ed-st+1,st=1,p[0]=1;
	dfs(1);
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 1716
import java.util.*; 
class Main 
{
public static void main(String args[]) 
{
Scanner sc = new Scanner(System.in); 
int n = Integer.parseInt(sc.nextLine()); 
String s = sc.nextLine(); 
int l= s.length(); 
if(l<=n) 
{
System.out.print(s);
} 
else 
{ 
System.out.print((s.substring(0,n))+"...");    
}
} 
}

Measured memory_bytes: 27036