akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int ans = 0;
    for(int x=0; x<1000; ++x){
        int tmp = x;
        vector<int> v(3);
        for(int i=2; i>=0; --i){
            v[i] = tmp % 10;
            tmp /= 10;
        }

        int k = -1;
        for(int i=0; i<3; ++i){
            k = s.find(v[i] + '0', k + 1);
            if(k == string::npos)
                break;
        }
        if(k != string::npos)
            ++ ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**7)

n = int(input())

graph = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    graph[a].append([b,i])

    
ans = [0]*(n-1)

def col(now,color):
    c = 1
    for (b,j) in graph[now]:
        if c == color:
            c += 1
        ans[j] = c
        col(b,c)
        c += 1

col(0,0)
print(max(ans))
for a in ans:
    print(a)



Measured memory_bytes: 71000
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;

int main(){
    int n, m;
    cin >> n >> m;
    int ans = m*(m-1)/2 + n*(n-1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int N, A, B;
	scanf("%d", &N);
	if (N == 2) {
		scanf("%d %d", &A, &B);
		printf("%d", A + B);
    }
      else{
        printf("Hello World\n");
	}
	return 0;
}

Measured memory_bytes: 128
// AGC039A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
	string S;
	long long K;
	cin >> S >> K;
	struct MyStruct
	{
		char m;
		long long count;
	};
	vector<MyStruct> cd;
	int len = S.size();
	S = S + "Z";
	int j;
	int i = 0;
	while (i < len)
	{
		j = 0;
		while (S.at(i) == S.at(i + j))
		{
			j++;
		}
		MyStruct ms;
		ms.m = S.at(i);
		ms.count = j;
		cd.push_back(ms);
		i = i + j;
	}
	long long ans = 0;
	if (cd.size() == 1)
	{
		ans = len * K/2; //全てが同じ文字の時
	}
	if (cd.size() == 2)
	{
		ans = (cd.at(0).count / 2 + cd.at(1).count / 2) * K; // ２種類
	}
	if (cd.size() >= 3) // グループが３つ以上ある時
	{
		if (cd.at(0).m != cd.at(cd.size() - 1).m) { // aaabbbcccのパターン
			for (unsigned int k = 0; k < cd.size(); k++)
			{
				ans += cd.at(k).count / 2;
			}
			ans *= K;
		}
		else // aaabbbaaaのパターン  Kが１か２以上かで場合分けする
		{
			long long as = cd.at(0).count/2;
			long long ae = cd.at(cd.size() - 1).count / 2;
			long long ase = (cd.at(0).count + cd.at(cd.size() - 1).count) / 2;
			long long mid = 0;
			for (unsigned int m = 1; m < cd.size()-1; m++)
			{
				mid += cd.at(m).count/2;
			}
				ans = (as + mid + ae) * K-(as+ae-ase)*(K-1);
		}
	}
	//printf("%llu\n", ans* K);
	cout << ans << endl;
}


Measured memory_bytes: 256
import sys

X, Y = map(int, input().split())
if X > Y:
    X, Y = Y, X

ni1 = 0
ni2 = 0
while Y > X:
    ni1 += 1
    X -= 1
    Y -= 2
if X % 3 != 0:
    print(0)
    sys.exit()
ni1 += X // 3
ni2 += X // 3

MAX = ni1 + ni2
MOD = 10**9 + 7
fac = [0] * (MAX + 1)
finv = [0] * (MAX + 1)
inv = [0] * (MAX + 1)
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD

n = ni1 + ni2
k = ni1
if n < k or n < 0 or k < 0:
    ans = 0
else:
    ans = fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
print(ans)


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

int main(){
	
	int numA, numB, num, count = 0;
	while(scanf("%d %d", &numA, &numB) != EOF){
		count = 0;
		num = numA + numB;
		while(1){
			
			if(num / 10 != 0){
				count += 1;
				num = num / 10;				
			}
			
			else if(num / 10 == 0){
			    count += 1;
				break;
			}
		}
		printf("%d\n", count);
	}
	return 0;
} 


Measured memory_bytes: 1948
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>

//マクロ
#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 RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector < pair<int, int>> p;
	REPS(i, n) {
		int a;
		cin >> a;
		p.push_back(make_pair(a, i));
	}
	sort(All(p));
	REP(i, n) {
		cout << p[i].second;
		if (i == n - 1) {
			cout << endl;
		}
		else {
			cout << " ";
		}

	}
}

Measured memory_bytes: 1780
#define M 300000
int T[M];main(i,j,r){for(T[0]=T[1]=1,i=2;i<M;i++)if(!T[i])for(j=2*i;j<M;j+=i)T[j]=1;for(;scanf("%d",&i),i;printf("%d\n",r))for(r=0,j=i+1;j<=2*i;j++)if(!T[j])r++;exit(0);}

Measured memory_bytes: 0
#include <stdio.h>
void max(int *x,int *y)
{
	if(*x>*y)
	{
		int t=*x;
		*x=*y;
		*y=t;
	}
}
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	max(&a,&b);
	max(&a,&c);
	max(&b,&c);
	printf("%d %d %d\n",a,b,c);
	return 0;
}


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

int main(void) {
	const int inf = 100000000;
	int n,m;
	cin >> n >> m;
	int a[1000],b[1000],c[1000],dist[100][100];
	for(int i = 0; i < m; ++i) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--,b[i]--;
	}

	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < n; ++j) {
			if(i==j)
				dist[i][j]=0;
			else
				dist[i][j]=inf;
		}
	}
	for(int i = 0; i < m; ++i) {
		dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
		dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
	}
	for(int k = 0; k < n; ++k) {
		for(int i = 0; i < n; ++i) {
			for(int j = 0; j < n; ++j) {
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	int ans=m;
	for(int i = 0; i < m; ++i) {
		bool shortest=false;
		for(int j = 0; j < n; ++j) if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true;
		if(shortest==true) {
			ans=ans-1;
		}
	}

	cout << ans << endl;
}

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

int main(){
  int n,d;
  cin >> n >> d;
  std::vector<std::vector<int>> x(n,std::vector<int>(d));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> x[i][j];
    }
  }
  int ans = 0;
  // ----組み合わせ----
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      // --------------
      int norm = 0;
      for (int k = 0; k < d; k++) {
        // D次元空間上の値をnormに格納していく
        int diff = abs(x[i][k] - x[j][k]);
        norm += diff * diff;
      }
      // normが整数か判定する
      bool flag = false;
      for (int k = 0; k <= norm; k++) {
        if (k * k == norm) {
          flag = true;
        }
      }
      if (flag) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3616
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  int a[n], sumU[n], sumL[n], x, y[n];
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (i == 0) sumU[i] = x;
    else sumU[i] = sumU[i - 1] + x;
  }
  for (int i = 0; i < n; i++) {
    cin >> y[i];
  }
  for (int i = n - 1; i >= 0; i--) {
    if (i == n - 1) sumL[i] = y[i];
    else sumL[i] = sumL[i + 1] + y[i];
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (sumL[i] + sumU[i] >= ans) ans = sumL[i] + sumU[i];  
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(void)
{
    long long k;
    string input;
    cin >> input >> k;
    for (int i = 0; i < min(k, (long long)(input.size())); i++)
    {
        if (input[i] >= '2')
        {
            printf("%c\n", input[i]);
            return 0;
        }
    }
    printf("1\n");
 
    return 0;
}

Measured memory_bytes: 256
n, w = map(int, input().split())
vw_lst = []
for i in range(n):
    vw_lst.append(list(map(int, input().split())))
dp = [[0] * (w+1) for i in range(n+1)]
for i in range(n):
    for j in range(w+1):
        if j >= vw_lst[i][1]:
            dp[i+1][j] = max(dp[i][j - vw_lst[i][1]] + vw_lst[i][0], dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]
# for i in dp:
#     print(i)
print(dp[n][w])


Measured memory_bytes: 41884
from functools import lru_cache
import sys
sys.setrecursionlimit(100000000)
money = [0,1,2,3,4,5]
n = int(input())
p = 0
lm = n//100
need = n - (lm*100)
@lru_cache(None)
def dfs( cur,limit):
    global p,need
    if not p:
        for i in range(6):
            now = cur+money[i]
            if limit+1 == lm:
                if now == need:
                    p =1
                    break
            elif limit+1<=lm:
                dfs(now,limit+1)
if n>=100:
    dfs(0,0)
    print(1 if p else 0)
else:
    print(0)


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    if (
        ((a == 5) && (b == 5) && (c == 7)) ||
        ((a == 5) && (b == 7) && (c == 5)) ||
        ((a == 7) && (b == 5) && (c == 5))
    ) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import bisect

def main():
    a, b = map(int, input().split())
    s1 = ''.join([chr(a + ord('0'))] * b)
    s2 = ''.join([chr(b + ord('0'))] * a)
    x = int(s1)
    y = int(s2)
    print(max(x, y))

if __name__ == "__main__":
    main()


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

typedef long long ll;

int n, k;
int d, a;
int cnt[2333];
	
int main(){
	cin >> n >> k;
	while(k--){
		cin >> d;
		while(d--){
			cin >> a;
			cnt[a]++;
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) if(cnt[i] == 0) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
open Printf
open Scanf

type ap = {a:int; p:int}

let () =
  let n, q = scanf "%d %d " (fun a b -> (a, b)) in
  let st = Array.make (4*n) {a=0; p=0} in
  let add s t x =
    let rec iter k l r =
      if r <= s || t <= l then ()
      else
        if s <= l && r <= t then
          st.(k) <- {st.(k) with a = st.(k).a + x}
        else
          begin
            let v = (min t r - max s l) * x in
            st.(k) <- {st.(k) with p = st.(k).p + v};
            let m = (l + r) / 2 in
            iter (2 * k) l m;
            iter (2 * k + 1) m r
          end
    in iter 1 0 n
  in
  let get_sum s t =
    let rec iter k l r =
      if r <= s || t <= l then 0
      else
        if s <= l && r <= t then
          (r - l) * st.(k).a + st.(k).p
        else
          let m = (l + r) / 2 in
          (min t r - max s l) * st.(k).a +
            iter (2 * k) l m + iter (2 * k + 1) m r
    in iter 1 0 n
  in
  let rec iter u =
    if u = 0 then ()
    else
      begin
        (let com = scanf "%d " (fun a -> a) in
         if com = 0 then
           let s, t, x = scanf "%d %d %d " (fun a b c -> (a-1, b, c)) in
           add s t x
         else
           let s, t = scanf "%d %d " (fun a b -> (a-1, b)) in
           get_sum s t |> printf "%d\n");
        iter (u-1)
      end
  in
  iter q

Measured memory_bytes: 16024
n, m = gets.split.map(&:to_i)
l_lim = 1
r_lim = n
m.times.each{|i|
    l, r = gets.split.map(&:to_i)
    l_lim = [l_lim, l].max
    r_lim = [r_lim, r].min
}
puts [0, r_lim - l_lim + 1].max


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

int main()
{
int n;
cin>>n;
if(n%1000==0)
    cout<<"0"<<endl;
else
{
    int a=n%1000;
    int b=1000-a;
    cout<<b<<endl;
}
return 0;
}


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

int main(){
  int N;
  cin>>N;
  
  set<string> st;
  string str;
 
  rep(i,N){
    cin>>str;
    st.insert(str);
  }
  int ans=st.size();
    cout<<ans<<endl;
   

}

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

class Program{
    static void Main(){
        int n = int.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        int count = 0;
        for (int i = 0;i < n;i++){
            if (a[i] < 0) count++;
            a[i] = Abs(a[i]);
        }
        Array.Sort(a);
        long ans = a.Sum();
        if (count % 2 == 1) ans -= 2 * a[0];
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 33628
/**
* From:
* Qingdao Agricultural University
* Created by XiangwangAcmer
* Date : 2019-10-27-08.23.10
* Talk is cheap.Show me your code.
*/
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<cctype>
#include<set>
#include<stack>
#include<map>
#include<string>
#include<cstdlib>
#define ll long long
using namespace std;
const ll maxn = 1e6 + 5;
const ll minn = 1e9 + 5;
const ll mod = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LIMIT = 4294967295LL;
vector<int>v[maxn];
int dp[maxn];
vector<int>G[maxn];
bool row[maxn], col[maxn];
bool flag = 0;
queue<int>q;
set<int >s;
set<set<char> >ss;
int level[maxn];
ll a[maxn];
int vis[maxn];
bool cmp(int x, int y)
{
    return x > y;
}
int main()
{
    ios::sync_with_stdio(false);
    int n, m, k;
    int sum = 0;
    cin >> n >> m >> k;
    if(n + k > m)
    {
        for(int i = n;i <= m;i++)
            cout << i <<endl;
        return 0;
    }
    for(int i = n; i <= n+k-1; i++)
    s.insert(i);
    for(int i = m;i >= m-k+1;i--)
    s.insert(i);
    for(set<int>::iterator it = s.begin();it !=  s.end();it++)
        cout << *it <<endl;
        return 0;
}



Measured memory_bytes: 54272
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int arr[n];
	map<int,int> m;
	for(int i=0;i<n-1;i++){
		cin>>arr[i];
	}

	for(int i=0;i<n-1;i++){
		m[arr[i]]++;
	}

	

	for(int i=1;i<n;i++){
		if(m.count(i)==0){
			cout<<0<<endl;
			continue;
		}
		cout<<m[i]<<endl;
	}

	cout<<0<<endl;


}

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

int main(){
  int K,S,count=0;
  cin>>K>>S;
  for(int x =0;x<=K;x++){
    for(int y=0;y<=K;y++){
      if(0<= S-y-x && K>= S-y-x){
        count++;
      }
    }
  }
  cout<< count<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int k;
  cin >> k;
  int cnt = 0;
  ll n = 0;
  ll d = 1;
  while(cnt < k) {
    n += d;
    d = 1;
    ll m = n;
    bool ok = true;
    while(m / 10) {
      ll r = m % 10;
      ll l = (m / 10) % 10;
      if(abs(l - r) > 1) {
        ok = false;
        break;
      }

      m /= 10;
      d *= 10;
    }
    if(ok) {
      cnt++;
      d = 1;
    } else {
      d -= n % d;
    }
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
Y = []
Y.append(1)
for i in range(998):
    Y.append(Y[-1] + i + 2)
for i in range(998):
    l = Y[i]
    r = Y[i + 1]
    if l - a == r - b:
        print(l - a)
        exit()

Measured memory_bytes: 3060
//D-Knapsack1 approch3- space optimised
#include<bits/stdc++.h>
#define int long long
using namespace std;
class event{
public:
  int wt,val;  
};
int32_t main(){
    int n,w;
    cin>>n>>w;
    event arr[n+1];
    for(int i=1;i<=n;i++){
        cin>>arr[i].wt;
        cin>>arr[i].val;
    }
    int dp[2][w+1];
    memset(dp,0,sizeof dp);
    for(int j=0;j<=w;j++){
        dp[0][j]=0;
    }
    int flag=1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=w;j++){
            dp[flag][j]=dp[flag^1][j];
            if(arr[i].wt<=j){
                dp[flag][j]=max(dp[flag][j],arr[i].val+dp[flag^1][j-arr[i].wt]);
            }
        }
        
        flag=flag^1;
    }
    cout<<dp[flag^1][w]<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int MAXN = 1e6 + 5;
char s[MAXN];
long long ans;
int main() {
	scanf("%s",s + 1);
	int n = strlen(s + 1);
	for(int i = 1;i <= n;i ++)
	ans += s[i] - '0';
	if(ans % 9 == 0)
	printf("Yes");
	else
	printf("No");
	return 0;
}

Measured memory_bytes: 1900
s = input()
n = len(s)
ans = 1
last = s[0]
i = 1
while i < n:
  if len(last) == 2:
    last = s[i]
    i += 1
  else:
    if s[i] != last:
      last = s[i]
      i += 1
    else:
      if i != n-1:
        last = s[i:i+2]
        i += 2
      else:
        break
  ans += 1
  #print(last,ans)
print(ans)

Measured memory_bytes: 3500
def solve():
    N, W = map(int, input().split())
    w, v = [0] * N, [0] * N
    for i in range(N):
        w[i], v[i] = map(int, input().split())
    
    V = sum(v)
    dp = [W+1] * (V + 1)
    dp[0] = 0
    for i in range(N):
        for j in range(V, -1, -1):
            if dp[j] + w[i] <= W:
                dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i])
    
    for i in range(V, -1, -1):
        if dp[i] <= W:
            print(i)
            exit()


if __name__ == '__main__':
    solve()


Measured memory_bytes: 40304
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int y = in.nextInt();
        int z = in.nextInt();
        int a = x;
        x = y;
        y = a;
        a = x;
        x = z;
        z = a;
        System.out.print(x);
        System.out.print(' ');
        System.out.print(y);
        System.out.print(' ');
        System.out.println(z);
    }
}


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

#define INF 1000000

using namespace std;

int main(void){
	int n;
	while(cin >> n && n){
		int f[10][10];
		fill((int*)f, (int*)f+10*10, INF);
		int s,t,cost;
		int maxi=0;
		for(int i=0;i<n;i++){
			cin >> s >> t >> cost;
			maxi = max(max(maxi,s),t);
			f[s][t] = cost;
			f[t][s] = cost;
		}
		for(int i=0;i<=maxi;i++) f[i][i] = 0;
		//WF
		for(int k=0;k<=maxi;k++){
			for(int i=0;i<=maxi;i++){
				for(int j=0;j<=maxi;j++){
					f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
				}
			}
		}
		int tmp,index;
		int ret = INF;
		for(int i=0;i<=maxi;i++){
			tmp = 0;
			for(int j=0;j<=maxi;j++){
				tmp += f[i][j];
			}
			if(tmp < ret){
				ret = tmp;
				index = i;
			}
		}
		cout << index << " " << ret << endl;
	}
}

Measured memory_bytes: 0
S = input()
K = int(input())


one_idx = -1
next_char = "_"
for i, c in enumerate(S):
    if c == "1":
        one_idx = i
    else:
        next_char = c
        break


if (one_idx >= 0) and (one_idx >= K-1):
    print("1")
else:
    print(next_char)


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    double START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 n; cin >> n;
    vi a(n); rep(i,n) cin >> a[i];
    i32 m, q; cin >> m;
    vec<bool> out;
    while(m--) {
        cin >> q;
        vii dp(n+1, vi(q+1));
        dp[0][0] = 1;
        rep(i,n) {
            for(i32 j = 0; j <= q; ++j) {
                dp[i+1][j] |= dp[i][j];
                if(j+a[i] <= q) dp[i+1][j+a[i]] |= dp[i][j];
            }
        }
        cout << (dp[n][q] ? "yes" : "no") << '\n';
        dp.clear();
    }

//     printf("ElapsedTime: %5.3f ms\n",1000*((clock()-START_TIME)/CLOCKS_PER_SEC));
}



Measured memory_bytes: 3360
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  string s;
  cin >> s;
  int n = s.length();
  map<char,int> m;
  REP(i, 0, n) { m[s[i]]++; }
  REP(i, 0, n) { if(m[s[i]]!=1){
      cout << "no" << endl;
      
      return 0;
    }
  }
  cout << "yes" << endl;

  return 0;
}


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

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

    int n;
    cin >> n;
    int max_a = -1;
    int res;

    rep(i, n){
        int a, b;
        cin >> a >> b;

        if(a > max_a){
            max_a = a;
            res = b;
        }
    }

    cout << res + max_a << endl;

    return 0;
}

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

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

Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9 + 7;
const int maxn = 300005;
#define endl '\n'
#define ld long double
#define int ll
#define all(x) (x).begin(),(x).end()
  ll power(ll x, ll n) {
      ll res = 1;
      for (; n > 0; n >>= 1) {
      if (n & 1) res = (res * x) % mod;
      x = (x * x) % mod;
      }
      return res;
  }
int32_t main()
{ 
  IOS

  int n;
  cin >> n;
  if(n == 1){
    cout << 0 << endl;
    return 0;
  }
  int ans = power(10,n);
  ans = (ans - (2*power(9,n)) + 2*mod )%mod;
  ans = (ans + power(8,n))%mod;
  cout << ans  << endl;
    
    
} 



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


constexpr lint mod = 1e9 + 7;
inline lint emod(lint a, lint p = mod) { return (a % p + p) % p; }
inline lint invm(lint a, lint p = mod) { a %= p; return a == 1 ? 1 : -p / a * invm(p % a) % p; }

V<lint> fact, ifact;
void init_table(int n) {
  fact.assign(n + 1, 1), ifact.assign(n + 1, 1);
  for (int i = 2; i < n + 1; ++i) fact[i] = i * fact[i - 1] % mod;
  ifact[n] = invm(fact[n]);
  for (int i = n; i > 2; --i) ifact[i - 1] = i * ifact[i] % mod;
}

lint comb(lint n, lint r) {
  if (r < 0 or r > n) return 0;
  return fact[n] * ifact[r] % mod * ifact[n - r] % mod;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  lint n, k; cin >> n >> k;
  if (n > k) return cout << 0 << '\n', 0;
  cout << 1 << '\n';
}


Measured memory_bytes: 3224
class UnionFind:
    def __init__(self, N):
        self.N = N

        # the parent of all node is itself
        # self.parent = list(range(N))
        self.parent = [-1] * N

    def root(self, i):
        if self.parent[i] < 0:
            return i

        r = self.root(self.parent[i])
        self.parent[i] = r
        return r

    def unite(self, i, j):
        i = self.root(i)
        j = self.root(j)

        if i == j:
            return

        if i > j:
            i, j = j, i

        self.parent[i] += self.parent[j]
        self.parent[j] = i
        # print(self.parent)

    def same(self, i, j):
        return self.root(i) == self.root(j)

    def size(self, i):
        return -self.parent[self.root(i)]

N, M = map(int, input().split())
p = [int(i) - 1 for i in input().split()]

forest = UnionFind(N)

for _ in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    forest.unite(x, y)

ans = 0
for i in range(N):
    if forest.same(i, p[i]):
        ans += 1

print(ans)


Measured memory_bytes: 20540
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define VI vector<int>
#define VL vector<lint>
#define VB vector<bool>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVL vector<VL>
#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int n;
    cin >> n;
    VI a(n);
    rep(i, n){
        cin >> a[i];
    }
    int ans = IINF;
    for(int i = -100 ; i <= 100 ; i++){
        int t = 0;
        rep(j, n){
            t += ((a[j] - i) * (a[j] - i));
        }
        ans = min(ans, t);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
  int N, M, R;
  cin >> N >> M >> R;
  vector<int> r(R);
  for (int i = 0; i < R; i++) {
    cin >> r[i];
  }

  vector<vector<int> > d;
  int inf = 1e9;
  d = vector<vector<int> >(N + 1, vector<int>(N + 1, inf));
  for (int i = 1; i <= N; i++) {
    d[i][i] = 0;
  }
  for (int i = 1; i <= M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    d[a][b] = d[b][a] = c;
  }

  for (int k = 1; k <= N; k++) {
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= N; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  int ans = 1e9;
  sort(r.begin(), r.end());
  do {
    int sum = 0;
    for (int i = 0; i < R - 1; i++) {
      sum += d[r[i]][r[i + 1]];
    }
    ans = min(ans, sum);
  } while (next_permutation(r.begin(), r.end()));

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <functional>
#include <time.h>
using namespace std;
clock_t fi, endtime;

const int r_c = 0;
const int r_t = 1;
const int MAX_V = 10;
const int MAX_E = 45;
const int MAX_D = 100;
const int MIN_D = 0;

const int INF = MAX_V * MAX_E * MAX_D;

int main()
{
	while (1) {
		int wf[MAX_V][MAX_V];
		int sum[MAX_V] = { 0 };
		int ansi,ans;
		int n, a, b, c, m;
		m = 0;
		scanf("%d", &n);
		if (n == 0) break;
		for (int i = 0; i < MAX_V; ++i) {
			for (int j = 0; j < MAX_V; ++j) {
				wf[i][j] = INF;
				if (i == j) wf[i][j] = 0;
			}
		}
		for (int i = 0; i < n; ++i) {
			scanf("%d %d %d", &a, &b, &c);
			if (a > m) m = a;
			if (b > m) m = b;
			wf[a][b] = c; wf[b][a] = c;
		}
		for (int k = 0; k <= m; ++k) {
			for (int i = 0; i <= m; ++i) {
				for (int j = 0; j <= m; ++j) {
					if (wf[i][j] > wf[i][k] + wf[k][j])
						wf[i][j] = wf[i][k] + wf[k][j];
				}
			}
		}
		for (int i = 0; i <= m; ++i) {
			sum[i] = 0;
			for (int j = 0; j <= m; ++j) {
				sum[i] += wf[i][j];
			}
			if (i == 0) {
				ans = sum[0]; ansi = 0;
			}
			if (ans > sum[i]) {
				ans = sum[i]; ansi = i;
			}
		}
		printf("%d %d\n", ansi, ans);
	}
}

Measured memory_bytes: 3196
<?php
  	fscanf(STDIN,"%s",$n);
	$res = 0;
	$a_li = explode(" ",trim(fgets(STDIN)));
	for($i=1;$i<$n;$i++){
      if($a_li[$i] < $a_li[$i-1]){
        $res += ($a_li[$i-1]-$a_li[$i]);
        $a_li[$i] = $a_li[$i-1];
      }
    }

	echo $res;
	

Measured memory_bytes: 31920
#include <stdio.h>
#define NUM (1000000000 + 7)

int main(void)
{
  long long int n;
  long long int k;
  long long int i;
  long long int count = 0;

  scanf("%lld%lld", &n, &k);
  /*
  for (i = k; i <= n + 1; k++) {
    count += i * n + 1 - i * (i - 1);
    count %= NUM;
  }
  */

  count = (n+1)*(n+k+1)*(n-k+2)/2 + (n-k+2) - (n+1)*(n+2)*(2*n+3)/6 + (k-1)*k*(2*k-1)/6;

  count %= NUM;

  printf("%lld\n", count);

  return 0;
}



Measured memory_bytes: 1704
#include<iostream>
#include<cmath>

using namespace std;

int n,v,l[200005],b,e;

int main(void)
{
    cin>>n;
    
    b=ceil((double)(n+1)/2);
    e = n % 2 == 0 ? -1 : 1 ;
    
    for(int i=1;i<=n;i++)
    {
        cin>>v;
        l[b]=v;
        b+=i*e;
        e*=-1;
    }
    
    for(int i=1;i<=n;i++)
        cout<<l[i]<<" ";
        
    return 0;
}

Measured memory_bytes: 2944
eps = 1.0 / 10**10
def LI(): return [int(x) for x in input().split()]

def main():
    n,q = LI()
    na = [LI() for _ in range(n)]
    qa = [LI() for _ in range(q)]
    rr = []

    def k(a,b):
        return sum([(a[i]-b[i]) ** 2 for i in range(3)]) ** 0.5

    def f(a,b,c,r):
        ab = k(a,b)
        ac = k(a,c)
        bc = k(b,c)
        if ac <= r or bc <= r:
            return True
        at = (ac ** 2 - r ** 2) ** 0.5
        bt = (bc ** 2 - r ** 2) ** 0.5
        return ab >= at + bt - eps

    for x1,y1,z1,x2,y2,z2 in qa:
        tr = 0
        for x,y,z,r,l in na:
            if f((x1,y1,z1),(x2,y2,z2),(x,y,z),r):
                tr += l
        rr.append(tr)

    return '\n'.join(map(str,rr))


print(main())




Measured memory_bytes: 5720
import java.util.*;

public class Main {
  public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
    	String op = sc.next();
    	int b = sc.nextInt();
    	if("+".equals(op)) {
          System.out.println(a + b);
        } else {
          System.out.println(a - b);
        }
  }
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define int int64_t
#define ll long long
#define re(s) reverse((s).begin(),(s).end())
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;
using namespace std;

signed main(){
    char a;
    cin>>a;

    cout<<char(a+1)<<'\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string x,y,z;
	cin>>x>>y>>z;
	for(int i=0;i<100;i++)
	if(65<=(int)y[i]<=90){
		cout<<"A"<<y[0]<<"C";
		break;
	}
}

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

int main(){
    int n;
    cin >> n;
    vector<ll>a(3*n);
    rep(i,n*3)cin >> a[i];
    ll ans = 0;
    sort(all(a));
    reverse(all(a));
    rep(i,n)a.pop_back();
    for(int i = 0;i < n;i++){
        ans += a[2*i+1];
        //cout << a[2*i] << endl;
    }
    cout << ans << endl;
    return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    int n, h, w;
    cin >> n >> h >> w;
    int ans = (n - h + 1) * (n - w + 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
N = int(input())
value = []
for _ in range(N):
    value.append(int(input()))
minv = value[0]
maxv = value[1] - minv
minv = min([minv,value[1]])
for i in range(2,N):
    maxv = max([maxv,value[i]-minv])
    minv = min([minv,value[i]])
print(maxv)



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

bool SortComp(long long int num1, long long int num2) { return num1 > num2 ? true : false; }

long long int FindRes(int check, long double rate, long long int charge, int year, long long int fund)
{
	long long int sum= 0;
	if(check == 0)
	{
		for(int i= 0; i < year; i++)
		{
			sum+= fund*rate;
			fund-= charge;
		}
		sum+= (long long int)fund;
	}
	else
	{
		sum= fund;
		for(int i= 0; i < year; i++)
			sum+= (long double)(sum*rate)-charge;
	}

	return sum;
}

int main(void)
{
	int num;
	cin>>num;
	for(int i= 0; i < num; i++)
	{
		long long int fund;
		cin>>fund;

		int year, operations;
		cin>>year>>operations;

		long long int sum[100]= {};
		for(int j= 0; j < operations; j++)
		{
			int check;
			long double rate;
			long long int charge;
			cin>>check>>rate>>charge;

			sum[j]= FindRes(check, rate, charge, year, fund);
		}

		sort(sum, sum+operations, SortComp);
		cout<<sum[0]<<endl;
	}

	return 0;
}

Measured memory_bytes: 3248
n, m = map(int, input().split())
a = list(map(int, input().split()))

sum_vote = sum(a)
limit = sum_vote * (1 / (4 * m))

select = 0
for num in range(0, n):
  if a[num] >= limit:
    select += 1
    if select == m:
      print('Yes')
      exit()
print('No')


Measured memory_bytes: 3064
n = int(input())
x = input().split()

for i in range(1, 101):
  goukei = 0
  for j in x:
    basyo = int(j)
    tasu = (i - basyo) ** 2
    goukei += tasu
  if i == 1:
    r = goukei
  if goukei < r:
    r = goukei

print(r)


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

namespace abc139_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            int tap = 0; //最小で必要な電源タップ数
            int plug = 1;　//電源プラグの差込口


                while (plug < b)
                {
                    plug = plug + a-1; //使えるプラグ数(plug)＝残りの差込口(plug)+新しい電源タップ(a)-使用プラグ(1)
                    tap++;   
                    
                   
                }
            Console.WriteLine(tap);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define int long long 
using namespace std;
int32_t main(){
    int n;cin>>n;
    vector<pair<int,int>> arrmv;
    for(int i=0;i<n;i++){
        int c,r;cin>>c>>r;
        arrmv.push_back({c+r,c-r});
        }
    sort(arrmv.begin(),arrmv.end());
    int sz=arrmv.size();
    int nr=-1e9-1;
    int ans=0;
    for(int i=0;i<sz;i++){
        if(arrmv[i].second<nr)continue;
        nr=arrmv[i].first;
        ans++;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2420
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
using namespace std;
using lint = long long;
template<class T> using grid = vector<vector<T>>;
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; }
static const lint MOD = (lint)1e9+7;

int main()
{
    lint N;
    cin >> N;
    vector<lint> H(N);
    rep (i, N) { cin >> H[i]; }

    bool f = false;
    for (lint i = 0; i+1 < N; ++i)
    {
        if (H[i] >= H[i+1])
        {
            f = true;
            break;
        }
    }
    if (!f)
    {
        cout << 0 << endl;
        return 0;
    }

    lint res = 0;
    lint right = 1;
    for (lint left = 0; left < N; ++left)
    {
        while (right < N && (right <= left || H[right - 1] >= H[right]))
        {
            ++right;
        }
        chmax(res, right - left);
        if (left == right) ++right;
    }

    cout << res-1 << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <math.h> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int a,b,c;
    cin >> a >> b >> c;

    ll res = a + b + c - max(a,max(b,c));

    cout << res << endl;
    return 0;    
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000],arr1[1000000];
int main()
{
	long long m,n;
	cin>>n>>m;
	if (m==n)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
///-----Bismillahir Rahmanir Rahim-----///

#include<bits/stdc++.h>
using namespace std;

///---FAST I/O---///
#define Boost() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

///---DATA TYPE---///
typedef long long ll;
typedef long long int lli;
///vector
typedef vector<int> vi;
typedef vector<ll> vl;
///pair
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;

///---LOOP---///
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)

///---I/O---///
#define sf scanf
#define pf printf

///---OTHERS---///
#define pb push_back
#define all(c)		c.begin(),c.end()
#define MK make_pair
#define F first
#define S second
#define endl '\n'


///---INITIALIZATION---//
#define mem(a,b) memset(a, b, sizeof(a) )

///---CALCULATE---///
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

///---BIT OPERATION---///
inline bool checkBit(ll n, int i) { return n&(1LL<<i); }
inline ll setBit(ll n, int i) { return n|(1LL<<i);; }
inline ll resetBit(ll n, int i) { return n&(~(1LL<<i)); }

///---CONSTANT---///
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

int main()
{
        char c;
        cin>>c;
        if(c>='a' && c<='z')
        {
            cout<<"a"<<endl;
        }
        else
        {
            cout<<"A"<<endl;
        }
    return 0;
}


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

namespace ABC042
{
    class Program
    {
        static void Main(string[] args)
        {
            //a();
            b();
            //c();
        }

        public static void a()
        {
            int[] abc = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            Array.Sort(abc);
            if (abc[0] == 5 && abc[1] == 5 && abc[2] == 7)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }

        public static void b()
        {
            int[] nl = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            string[] s = new string[nl[0]];
            for (int i = 0; i < nl[0]; i++)
            {
                s[i] = Console.ReadLine();
            }
            Array.Sort(s);
            foreach (var x in s)
            { Console.Write(x); }
            Console.WriteLine();
        }

        public static void c()
        {
            int[] nk = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            int[] d = Console.ReadLine().Split(' ').Select(b => int.Parse(b)).ToArray();
            int ans = nk[0];
            bool flg = false;
            while(flg == false)
            {
                string s = ans.ToString();
                foreach (var x in d)
                {
                    if(s.Contains(x.ToString()))
                    {
                        ans++;
                        break;
                    }
                    else
                    {
                        flg = true;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    if ((b - a - 1) % 2) cout << "Alice" << endl;
    else cout << "Borys" << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    char c[1301];
    int i = 0, j;
    while (1)
    {
        scanf("%c", &c[i]);
        if (c[i] == '\n')
        {
            break;
        }
        i++;
    }
    for (j = 0; j < i; j++)
    {
        if (c[j] >= 'A' && c[j] <= 'Z')
            c[j] += 32;
        else if (c[j] >= 'a' && c[j] <= 'z')
            c[j] -= 32;
        printf("%c", c[j]);
        if (j == i - 1)
            printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2096
#include <cstdio>
#include <cstdlib>
#include <csetjmp>
#include <queue>

#define N 10
#define ABS(X) \
  ( (X) < 0 ? -(X) : (X) )

using namespace std;

typedef struct arw
{
  int no;
  int x;
  int y;

  arw (
    int x,
    int y,
    int no = 0
    )
  {
    this->x = x;
    this->y = y;
    this->no = no;

    return ;
  }
} arw;

static const int vx[ 12 ]
  = { -1,  0,  1, -1,  0,  1, -2, -2, -2,  2,  2,  2 };
static const int vy[ 12 ]
  = { -2, -2, -2,  2,  2,  2, -1,  0,  1, -1,  0,  1 };

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    queue<arw> lis;
    jmp_buf cont;
    int dx[ N ], dy[ N ];
    int x, y, n;

    scanf ( "%d%d", &x, &y );
    if ( x == 0 && y == 0 ) break ;
    scanf ( "%d", &n );
    for ( i = 0; i < n; ++i )
    {
      scanf ( "%d%d", &dx[ i ], &dy[ i ] );
    }

    lis.push ( arw ( x, y ) );
    if ( setjmp ( cont ) == 0 )
    {
      while ( !lis.empty ( ) )
      {
        const arw c = lis.front ( );
        lis.pop ( );

        if ( c.no == n )
        {
          puts ( "OK" );
          longjmp ( cont, 0 );
        }

        for ( i = 0; i < 12; ++i )
        {
          const int nx = c.x + vx[ i ];
          const int ny = c.y + vy[ i ];

          if ( nx < 0 || nx >= 10 || ny < 0 || ny >= 10 )
            continue ;

          if ( ABS( dx[ c.no ] - nx ) <= 1
            && ABS( dy[ c.no ] - ny ) <= 1 )
          {
            lis.push ( arw ( nx, ny, c.no + 1 ) );
          }
        }
      }
      puts ( "NA" );
    }
  }

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 1040