akhauriyash/Code-Regression huggingface dataset:
from sys import stdin

n = int(stdin.readline().rstrip())
g = []

for i in range(n):
    line = stdin.readline().rstrip().split()
    g.append([i+1, line[0], line[1].zfill(3)])

gg = [tuple(i) for i in g]

gg.sort(key=lambda x: x[2], reverse=True)
gg.sort(key=lambda x: x[1])

for i in range(n):
    print(gg[i][0])


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
string s;
int number(int &pos)
{
    int res = 0;
    while(isdigit(s[pos]))
    {
        res *= 10;
        res += (s[pos] - '0');
        pos++;
    }
    pos++;
    return res / 2 + 1;
}
int dfs(int &pos)
{
    vector<int> res;
    while(s[pos] == '[')
    {
        pos++;
        if(isdigit(s[pos])) res.push_back(number(pos));
        else res.push_back(dfs(pos));
    }
    pos++;
    sort(res.begin(), res.end());
    int sum = 0;
    for(int i = 0; i < res.size() / 2 + 1; i++) sum += res[i];
    return sum;
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    while(n--)
    {
        cin >> s;
        int pos = 0;
        cout << dfs(pos) << endl;
    }
    return 0;
}




Measured memory_bytes: 3220
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {


	int a, b, k;
	cin >> a >> b >> k;

	for (int i = 0; i < k; i++) {
		if (a % 2 == 1) {
			a--;
		}
		a /= 2;
		b += a;

		i++;
		if (!(i < k))
			break;

		if (b % 2 == 1) {
			b--;
		}
		b /= 2;
		a += b;
	}

	COUT(a << " " << b);


	return 0;
}


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

int prime[1000005], a, d, n, cnt;

void solve() {
    prime[0] = prime[1] = 1;
    for (int i = 2; i <= 1000000; ++i) {
        if (prime[i] == 0) {
            for (int j = 2; i * j <= 1000000; ++j) {
                prime[i * j] = 1;
            }
        }
    }
}

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

    solve();

    while (cin >> a >> d >> n, a | d | n) {
        cnt = 0;
        for (int i = 0; ; ++i) {
            if (prime[a + i * d] == 0) cnt++;
            if (cnt == n) {
                cnt = i;
                break;
            }
        }
        cout << a + cnt * d << endl;
    }

    return 0;
}

Measured memory_bytes: 6892
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  set<int> k;
  k.insert(2);
  int y=3;
  int p=2;
  while(p<n){
    int r=1;
    for(auto value: k){
      if(y%value==0){
        r=0;
        break;
      }
    }
    if(r==1){
      p=y;
      k.insert(p);
    }
    y++;
  }
  cout << p << endl;
}

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

const int MAX_N=16;

vector <pair<int,int> > g[MAX_N];
int N;
bool f[MAX_N];

bool check(){
	for(int i=0;i<N;i++) if(f[i]){
		for(int j=0;j<g[i].size();j++){
			int to=g[i][j].first,state=g[i][j].second;
			if(f[to]!=state) return false;
		}
	}
	return true;
}

int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		int M; scanf("%d",&M);
		for(int j=0;j<M;j++){
			int to,f; scanf("%d%d",&to,&f);
			to--; 
			g[i].push_back(make_pair(to,f));
		}
	}
	int ans=0;
	for(int mask=0;mask<(1<<N);mask++){
		for(int i=0;i<N;i++){
			if(mask&(1<<i)) f[i]=1;
			else f[i]=0;
		}
		int sum=0;
		if(check())
			for(int i=0;i<N;i++) if(f[i]) sum++;
		ans=max(ans,sum);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
void solve()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	forci(1,n+1)
		cin>>a[i];
	int visited[n+1]={0};
	visited[1]=1;
	int temp;
	vector<int> g;
	g.pb(1);
	int i=1;
	while(1)
	{
		if(visited[a[i]]==0)
		{
			visited[a[i]]+=1;
			g.pb(a[i]);
			i=a[i];
		}
		else
		{
			temp=a[i];
			break;
		}
	}
	int ans=0;
	for(int i=0;i<g.size();i++)
	{
		if(g[i]==temp)
		{
			ans=i;
		}
	}
	vector<int> hel;
	for(int i=ans;i<g.size();i++)
		hel.pb(g[i]);
	if(k>=ans)
		cout<<hel[(k-ans)%hel.size()]<<endl;
	else
		cout<<g[k]<<endl;
}
signed main()
{
	fastio;
	solve();
}

Measured memory_bytes: 10792
from collections import Counter, deque, defaultdict
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

N, M = list(map(int, input().split()))
S = [list(map(int, input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))

ans = 0
for pp in itertools.product([True, False], repeat=N):
    a = np.array((False,) + pp)
    ok = True
    for s, p in zip(S, P):
        if sum(a[s]) % 2 != p:
            ok = False
            break
    if ok:
        ans += 1
print(ans)


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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

int umi = 0;

int dep[MAXN], vis[MAXN];
int P[MAXN], Q[MAXN];

vector<int> E[MAXN];

void dfs(int u, int fa, int dp){
	dep[u] = dp;
	for (auto &v : E[u]) if (v != fa){
		if (dep[v] == 0){
			dfs(v, u, dp + 1);
		}
		else{
			if ((dep[u]&1) == (dep[v]&1))
				umi = 1;
		}
	}
}

ll ans;

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		E[x].push_back(y);
		E[y].push_back(x);
	}
	dfs(1, 0, 1);
	if (umi == 1){
		printf("%lld\n", 1ll * (n - 1) * n / 2 - m);
	}
	else{
		ans = 0;
		ll s = 0, t = 0;
		for (int i = 1; i <= n; i++)
			if (dep[i] & 1) s++;
			else t++;
		printf("%lld\n", s * t - m);
	}
}

void printans(){

}


int main(){
//	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}

Measured memory_bytes: 53760
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n],A=0,B=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	int x=0;
	for(int i=n-1;i>=0;i--){
		if(x%2==0){
			A+=a[i];
		}else{
			B+=a[i];
		}
		x++;
	}
	int ans = A-B;
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    int mi = p[0], ans = 1;
    for (int i = 1; i < n; i++) {
        if (p[i] < mi) ans++;
        mi = min(mi, p[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
N=input()
K=int(input())
dp_0 = [[0]*(len(N)) for i in range(K+1)]
dp_1 = [[0]*(len(N)) for i in range(K+1)]
dp_0[0][0]=1
dp_0[1][0]=int(N[0])-1
dp_1[1][0]=1
for i in range(len(N)-1):
    for j in range(K+1):
        if j==K:
            dp_0[j][i+1] += dp_0[j][i]
        elif j==0:
            dp_0[j][i+1] =dp_0[j][i]
            dp_0[j+1][i+1] += dp_0[j][i]*9
        else:
            dp_0[j][i+1] += dp_0[j][i]
            dp_0[j+1][i+1] += dp_0[j][i]*9
        if j != K and N[i+1] != '0':
            dp_0[j+1][i+1] += (int(N[i+1])-1)*dp_1[j][i]
            dp_0[j][i+1] += dp_1[j][i]
            dp_1[j+1][i+1] = dp_1[j][i]
        elif N[i+1] =='0':
            dp_1[j][i+1] = dp_1[j][i]
        else:

            dp_0[j][i+1] += dp_1[j][i]

print(dp_0[K][len(N)-1]+dp_1[K][len(N)-1])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;

void printA(vector<int> a, int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i];
		if (i < n - 1)
			cout << " ";
		else
			cout << endl;
	}
}

void insertionSort(vector<int>& a, int n) {
	for (int i = 1; i < n; i++) {
		int v = a[i];
		int j = i - 1;
		while ((j >= 0) && (a[j] > v))
		{
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		printA(a, n);
	}
}

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	printA(a, n);
	insertionSort(a, n);
	
	return 0;
}


Measured memory_bytes: 3140
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void warshall_floyd(vector<vector<int>>& d, int n) {
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}


void solve() {
    int H, W; cin >> H >> W;
    vector<vector<int>> c(10, vector<int>(10));

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }

    warshall_floyd(c, 10);

    int cost = 0;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int a; cin >> a;
            if (a == -1) continue;
            cost += c[a][1];
        }
    }

    cout << cost << endl;
}


int main() {
    solve();
    return 0;
}

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

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static FastReader s = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);

    private static int[] rai(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextInt();
        }
        return arr;
    }

    private static int[][] rai(int n, int m) {
        int[][] arr = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = s.nextInt();
            }
        }
        return arr;
    }

    private static long[] ral(int n) {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextLong();
        }
        return arr;
    }

    private static long[][] ral(int n, int m) {
        long[][] arr = new long[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = s.nextLong();
            }
        }
        return arr;
    }

    private static int ri() {
        return s.nextInt();
    }

    private static long rl() {
        return s.nextLong();
    }

    private static String rs() {
        return s.next();
    }
    static int gcd(int a,int b)
    {
        if(b==0)
        {
            return a;
        }
        return gcd(b,a%b);
    }

    public static void main(String[] args) {
        StringBuilder ans = new StringBuilder();
//        int t = ri();
        int t=1;
        while (t-- > 0) {
            int l=ri();
            int r=ri();
            int d=ri();
            int res=(r/d)-((l-1)/d);
            ans.append(res).append("\n");
        }
        out.print(ans.toString());
        out.flush();

    }

}


Measured memory_bytes: 25468
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  
  
  
  string s = "abcdefghijklmnopqrstuvwxyz";
  string S = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
  for (int j = 0; j < 26; j++) {
    if (s1.at(0) == s.at(j)) {
      s1.at(0) = S.at(j);
    }
    if (s2.at(0) == s.at(j)) {
      s2.at(0) = S.at(j);
    }
    if (s3.at(0) == s.at(j)) {
      s3.at(0) = S.at(j);
    }
  }

  
  
  cout << s1.at(0) << s2.at(0) << s3.at(0) << endl;
  
  return 0;  
}

Measured memory_bytes: 256
<?php
$num = fgets(STDIN);
$monster = explode(" ",fgets(STDIN));
$hero = explode(" ",fgets(STDIN));
$kill = 0;
for ($i = 0; $i<$num; $i++) {
    if($monster[$i]+$monster[$i+1] >= $hero[$i]) {
        $kill += $hero[$i];
        if ($monster[$i] < $hero[$i]) {
            $monster[$i+1] = $monster[$i+1]-($hero[$i]-$monster[$i]);
        }
    } else {
        $kill += ($monster[$i] + $monster[$i+1]);
        $monster[$i+1] = 0;
    }
}

echo $kill;

Measured memory_bytes: 20980
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

vector<P> G[10000];
int used[10000];
int res1[10000];
int res2[10000];

P dfs(int n) {
	used[n] = 1;
	P res(n, 0);
	for (auto e : G[n]) {
		if (used[e.first] == 0) {
			auto p = dfs(e.first);
			if (p.second + e.second > res.second) {
				res = p;
				res.second += e.second;
			}
		}
	}
	used[n] = 0;
	return res;
}

void dfs1(int n, int d) {
	used[n] = 1;
	res1[n] = d;
	for (auto e : G[n]) {
		if (used[e.first] == 0) {
			dfs1(e.first, d + e.second);
		}
	}
	used[n] = 0;
}

void dfs2(int n, int d) {
	used[n] = 1;
	res2[n] = d;
	for (auto e : G[n]) {
		if (used[e.first] == 0) {
			dfs2(e.first, d + e.second);
		}
	}
	used[n] = 0;
}

int main()
{
	int n;
	cin >> n;
	for (int i = 0, s, t, w; i < n - 1; i++) {
		cin >> s >> t >> w;
		G[s].push_back(P(t, w));
		G[t].push_back(P(s, w));
	}
	auto s = dfs(0);
	auto t = dfs(s.first);
	dfs1(s.first, 0);
	dfs2(t.first, 0);
	for (int i = 0; i < n; i++) {
		cout << max(res1[i], res2[i]) << endl;
	}
	return 0;
}

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

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

const ll inf = 1e18;

int main(){
    int n;  
    while(cin>>n){
        vi a(n); forn(i,n) cin>>a[i];

        vl pre(n); pre[0] = a[0];
        fore(i,1,n) pre[i] = pre[i-1]+a[i];

        vvl dp(n, vl(n,inf));
        for(int l=n-1; l>=0; --l){
            dp[l][l] = 0;
            for(int r=l+1; r<n; ++r){
                ll s = pre[r] - (l ? pre[l-1] : 0);
                for(int i=l; i<r; ++i)
                    min_self(dp[l][r], dp[l][i] + dp[i+1][r] +s);
            }
        }
    
        // print_vv(dp);

        cout<<dp[0][n-1]<<endl;

    }
    return 0;
}

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

int main() {
  int a, b; cin >> a >> b;
  int c = stoi(to_string(a) + to_string(b));
  double r = pow(c, 0.5);
  cout << (floor(r) == r ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,sum,input;
    
    while(1){
        cin >> n;
        if(n == 0) break;
        sum = 0;
        for(int i = 0; i < n/4 ; i++){
            cin >> input;
            sum += input;
            
        }
        cout << sum << endl;
    }
    
    return 0;
}


Measured memory_bytes: 2984
N, M = [int(i) for i in input().split()]
l = []
isOK = True
# 3の場合'000'作っておく
resultList = list('0' * N)
# N桁の整数の最小値
minResult = 0
if N == 2:
    minResult = 10
elif N > 2:
    minResult = 10
    for i in range(N - 2):
        minResult *= 10
for i in range(M):
    sc = list(map(int, input().split()))
    l.append(sc)
    # N桁の指定が1桁でない場合、左から1桁目が0だとおかしい
    if N != 1 and sc[0] == 1 and sc[1] == 0:
        isOK = False
        break
    for j in l:
        # s桁目指定が一緒なのに、数値cが違ったらおかしい
        if j[0] == sc[0] and j[1] != sc[1]:
            isOK = False
            break
        # s桁目指定が元の桁数を越えていたらおかしい
        if j[0] > N:
            isOK = False
            break
        # おかしく無い場合、指定の通りにする
        resultList[sc[0] - 1] = str(sc[1])

if isOK == False:
    print(-1)
else:
    intResult = int("".join(resultList))
    if intResult < minResult:
        # 桁を足す
        intResult += minResult
    print(intResult)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, A, B;
  cin >> N >> A >> B;
  if((N == 1 && A != B) || A > B){
    cout << 0 << endl;
    return 0;
  }
  N -= 2;
  cout << (B - A) * N + 1 << endl;
  return 0;
}


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

ll mod = 1000000007;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    ll ans =0;
    for(int i=1;i<n;i++){
        ans += ((n-1)/i);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3640
N,M = map(int,input().split())
A = list(map(int,input().split()))
S1 = sorted(A,reverse=True)
S2 = S1[0:M]
sum = sum(A)
ans = 'Yes'
for i in range(1,M+1):
    if S2[-1*i] >= sum/(4*M):
        continue
    else:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 3064
n = int(input())
mod = int(1e9) + 7

a = 1
b = 1
c = 1

for i in range(n):
    a = (a * 10) % mod
    b = (b * 8) % mod
    c = (c * 9) % mod

ans = (a - (2*c - b % mod)%mod + mod) % mod

print(ans)

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		cout << n*n << "\n";
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

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

int main(){
    int n,m,x;
    cin>>n>>m>>x;
    
    vector<vector<int>> a(n,vector<int>(m+1));
    
    rep(i,n) rep(j,m+1) cin>>a[i][j];
    
    int minv=10000005;
    bool exist=false;
    for(int bit=0;bit<(1<<n);bit++){
        int sum=0;
        bool flag=true;
        vector<int> cnt(m,0);
        rep(i,n){
            if(bit & (1<<i)){
                for(int j=0;j<m;j++){
                    cnt[j]+=a[i][j+1];
                }
                sum+=a[i][0];
            }
        }
        for(int j=0;j<m;j++){
            if(cnt[j]<x){
                flag=false;
                break;
            }
        }
        if(flag){
            minv=min(minv,sum);
            exist=true;
        }
    }
    
    if(exist) cout<<minv<<endl;
    else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3612
import java.util.*;

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

        int rangeL = Math.min(b,a+k-1);
        int rangeR = Math.max(b-k+1,a+k);

        for(int i = a;i <= rangeL;i++)
            System.out.println(i);

        for(int i = rangeR;i <= b;i++)
            System.out.println(i);
        
    }
}

Measured memory_bytes: 21972
#include <stdio.h>
#define SIZE 2001

char resultTable[SIZE];
int n,q,elems[20];

void calc(int sum,int index){
	if(index == n){
		if(sum >= 1 && sum <= 2000){
			resultTable[sum] = 'y';
		}
	}else{
		calc(sum+elems[index],index+1);
		calc(sum,index+1);
	}
}

int main(){

	for(int i = 0;i < SIZE; i++) resultTable[i] = 'n';

	scanf("%d",&n);
	for(int i = 0; i < n; i++) scanf("%d",&elems[i]);
	calc(0,0);

	scanf("%d",&q);

	int tmp;
	for(int i = 0; i < q; i++){
		scanf("%d",&tmp);
		if(resultTable[tmp] == 'y'){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}
}


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

int main(void) {
    while (true) {
        int m,f,r;cin>>m>>f>>r;
        if (m == -1 && f == -1 && r == -1) break;
        if (m == -1 || f == -1) {
            cout << "F" << endl;
            continue;
        }
        if (m + f >= 80) cout << "A" << endl;
        else if (65 <= m + f && m + f < 80) cout << "B" << endl;
        else if (50 <= m + f && m + f < 65) cout << "C" << endl;
        else if (30 <= m + f && m + f < 50) {
            if (r >= 50) cout << "C" << endl;
            else cout << "D" << endl;
        } else if (30 > m + f) cout << "F" << endl;
    }
    return 0;
}


Measured memory_bytes: 3060
using System;
using System.Linq;

class Program {
  static void Main() {
    var arr= Console.ReadLine().Split().Select(int.Parse).ToArray();
    int n = arr[0];
    int x = arr[1];
    var m = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine()).Select(int.Parse).OrderBy(e => e).ToArray();
    Console.WriteLine(n + (x - m.Sum()) / m[0]);
  }
}

Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int> > v1;
int main()
{
    int N,i,x;
    cin>>N;
    for(i=0;i<N;i++)
    {
        cin>>x; v1.push_back(make_pair(x,i));
    }
    sort(v1.begin(),v1.end());
    for(i=0;i<N;i++)
    {
        cout<<v1[i].second+1<<" ";
    }
    return 0;
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> deg(n);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        --a, --b;
        deg[a]++;deg[b]++;
    }
    for(auto i : deg)
        cout << i << endl;
}

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

int main(){
	// sengen
	int n;
	int a;
	// nyuryoku
	map<int,int> mp;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a;
		mp[a] = i+1;
	}
	// keisan
	for(auto x:mp){
		cout << x.second << ' ';
	}
	// syutsuryoku
}

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

int main()
{
  int n,m;
  cin>>n;
  int sum=0;
  m=n;
  for(int i=0;i<9;i++)
  {
    sum+=m%10;
    m/=10;
  }
  if(n%sum==0)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b, c = MAP()

print(a+b+c-max(a, b, c))


Measured memory_bytes: 5328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		double radius = 0.0;
		double pi = 3.141592653589;

		try(Scanner scan = new Scanner(System.in)) {
			radius = scan.nextDouble();
			double area = radius * radius * pi;
			double len = (radius * 2) * pi;
			String a = String.format("%.6f", area);
			String l = String.format("%.6f", len);

			System.out.println(a + " " + l);
		}
	}
}

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

using namespace std;

int main(){
  string s;
  cin >> s;
  if(s[5] == '1') cout << "TBD" << endl;
  else if(s[6] == '1' || s[6] == '2' || s[6] == '3' || s[6]  == '4') cout << "Heisei" <<endl;
  else cout << "TBD" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
  cout << 
  min(2*C*max(X,Y), //すべてC
      A*X+B*Y+min(2*C-A-B,0)*min(X,Y))
  << endl;
}

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

typedef long long ll;
typedef long double ld;

vector <int> desno[100005];

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n, m;
    cin >> n >> m;
    for(int i=1; i<=m; i++){
        int a, b;
        cin >> a >> b;
        desno[b].push_back(a);
    }
    int l = 0;
    int res = 0;
    for(int i=1; i<=n; i++){
        int cut = 0;
        for(auto c : desno[i]){
            if(c > l){
                l = i-1;
                cut = 1;
            }
        }
        res += cut;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 4864
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

S=get_nsp
N=S.size
a=0
ans=0
i=0
while i<N
    if S[i]=="A"
        a+=1
        i+=1
    elsif i+1<N and S[i]=="B" and S[i+1]=="C"
        ans+=a
        i+=2
    else
        a=0
        i+=1
    end
end
puts ans

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

#define MOD 1000000007

long long fact[2000006], mmi[2000006];

long long power(long long N, long long expo)
{
    long long ans = 1;

    while(expo)
    {
        if(expo % 2)
            ans = ans * N % MOD;
        
        N = N * N % MOD;
        expo /= 2;
    }

    return ans;
}

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

    long long x, y;
    cin >> x >> y;

    fact[0] = mmi[0] = 1;

    for(int i=1; i<=2000000; i++)
    {
        fact[i] = fact[i-1] * i % MOD;
        mmi[i] = power(fact[i], MOD-2);
    }

    long long num = (x + y) + 3 * (x - y);

    if(num % 6)
    {
        cout << 0 << "\n";
        return 0;
    }

    long long b = num / 6;
    long long a = x - 2 * b;

    if(a < 0 || b < 0)
    {
        cout << 0 << "\n";
        return 0;
    }

    cout << fact[a + b] * mmi[a] % MOD * mmi[b] % MOD << "\n";

    return 0;
}


Measured memory_bytes: 31488
n,m=map(int,input().split())
city=[]
for i in range(m):
    a=i
    b,c=map(int,input().split())
    city.append([a,b,c])
city=sorted(city,key=lambda x:(x[1],x[2]))
city[0].append(1)
for i in range(1,m):
    if city[i][1]!=city[i-1][1]:
        city[i].append(1)
    else:
        city[i].append(city[i-1][3]+1)
for i in range(m):
    city[i].append(str(city[i][1]).zfill(6)+str(city[i][3]).zfill(6))
city=sorted(city,key=lambda x:(x[0]))
for i in range(m):
    print(city[i][4])

Measured memory_bytes: 38308
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
//vectorの中身を表示する
int main(){

    int N,K;

    cin >> N >> K;

    std::set<int> set;

    for(int i=0;i<K;i++)
    {
        int d=0;
        cin >> d;
        for(int j=0;j<d;j++)
        {
            int a=0;
            cin >> a;
            set.insert(a);
        }
    }

    cout << N - set.size();

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

ll comb[51][51];

ll dfs(const vecll& a, ll s, ll t, ll i, ll k) {
  if (i == 18) {
    ll n = size(a);
    ll ans = 0;
    FOR(i,1,k+1) {
      if (i > n) break;
      ans += comb[n][i];
    }
    return ans;
  }
  if ((s>>i)&1) {
    return dfs(a, s, t, i+1, k);
  }
  if (((t>>i)&1) == 0) {
    return dfs(a, s, t, i+1, k);
  }
  vecll zero, one;
  for(auto&&e:a) {
    if ((e>>i)&1) {
      one.push_back(e);
    } else {
      zero.push_back(e);
    }
  }
  if (one.empty() || zero.empty()) return 0;
  return dfs(a, s, t, i+1, k) - dfs(zero, s, t, i+1, k) - dfs(one, s, t, i+1, k);
}

int main() {
  comb[0][0] = 1;
  REP(i,50) {
    REP(j,i+1) {
      comb[i+1][j] += comb[i][j];
      comb[i+1][j+1] += comb[i][j];
    }
  }
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,k,s,t;
  cin>>n>>k>>s>>t;
  vecll a;
  ll vs = (1 << 18) - 1;
  ll vt = 0;
  REP(i,n) {
    ll v;
    cin>>v;
    if ((v & s) != s) continue;
    if ((v | t) != t) continue;
    vs &= v;
    vt |= v;
    a.push_back(v);
  }
  if (vs != s || vt != t) {
    cout<<0<<endl;
    return 0;
  }
  n = size(a);
  cout<<dfs(a, s, t, 0, k)<<endl;
  return 0;
}


Measured memory_bytes: 3696
n = int(input())
lst = [int(input()) for _ in range(5)]
t = 0
m = 0

for (index, ele) in enumerate(lst):
    done = min((t-index) * ele, n-m) #すでに運んだ人数
    m = n - done # 最後の組が到着時に, 最後の組みの者を含めて島にいる人数
    #print("m = {}, ele = {}".format(m, ele))
    if m % ele == 0:
        t += m // ele
        m = ele
        #print("1 : t = {}".format(t))
    else:
        t += m // ele + 1
        m =  m % ele
        #print("2 : t = {}".format(t))
print(t)

Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cassert>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define FOR(j,k,n) for (int j = k; j < (int)(n); j++)
#define MAXN 100000000000000000
#define newl printf("\n")
#define test(t)  int t; cin>>t; for(int tes = 0; tes < t; tes++)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int lli;
const int MM = 220000;
lli m,n,k,p1,p2,p3,p,f,a[MM];
string s,s1,s2;
set<lli> g[MM];
void doi(lli x)
{
    lli u = n%x;

    cout<<x<<endl;
    lli alf = (n/x) + x-1;
    for(int i=0 ; i< u; i++)
    cout<<alf + x - (u-1)<<" ";
    
    for (int i=u; i<x; i++) {
        cout<<alf-u<<" ";
    }
}
lli mm(lli x)
{
    return 1;
}
int main(){
    fio;
        // Have you solved the problem completely?
    cin>>n;
    lli mn = 10000000000001000;
    for (lli i=50; i>=1; i--) {
        if(mm(i) <= mn)
        {
            doi(i);
            return 0;
        }
    }
    assert(false);
    return 0;
}


Measured memory_bytes: 10624
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll x, ll y){return x / gcd(x, y) * y % MOD;};


int main(){
  int A, B;
  char o;
  cin >> A >> o >> B;
  if(o == '+'){
    cout << A + B << endl;
  }else{
    cout << A - B << endl;
  }
}


Measured memory_bytes: 256
import math
atan = math.atan
deg = math.degrees
a,b,x = map(float,input().split())
if 2*x >= a*a*b:
    h = x/(a*a)
    print(deg(atan(2*(b-h)/a)))
else:
    h = x/(a*a)
    print(90.0-deg(atan(2*a*h/(b*b))))

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

int c[10];
const int INF = 1 << 25;
int dist[200][1 << 10];

struct edge {
	int from, to, cost;
};

struct State {
	int v, bit, d;
	bool operator <(const State& x) const {
		return d > x.d;
	}
};

int main() {
	int M, N, K, D;
	while(cin >> M >> N >> K >> D, M + N + K + D) {
		for(int i = 0; i < M; i++) {
			cin >> c[i];
		}

		int s = M + N, g = s + 1;
		vector<vector<edge>> G(M + N + 2);
		for(int i = 0; i < D; i++) {
			char t;
			int a, b, x;
			cin >> t;
			if(t == 'H') a = s;
			else if(t == 'D') a = g;
			else if(t == 'L') cin >> a, a += M - 1;
			else cin >> a, a--;

			cin >> t;
			if(t == 'H') b = s;
			else if(t == 'D') b = g;
			else if(t == 'L') cin >> b, b += M - 1;
			else cin >> b, b--;

			cin >> x;

			//cerr << "a : " << a << ", b : " << b << ", x : " << x << endl;
			G[a].push_back({ a, b, K * x });
			G[b].push_back({ b, a, K * x });
		}

		fill((int*)begin(dist), (int*)end(dist), INF);
		dist[s][0] = 0;

		priority_queue<State> q;
		q.push({ s, 0, 0 });

		while(q.size()) {
			int v = q.top().v, bit = q.top().bit;
			int d = q.top().d;
			q.pop();
			if(dist[v][bit] < d) continue;
			for(auto e : G[v]) {
				int to = e.to;
				int cost = e.cost;
				int nb = bit;
				if(to < M) {
					if(~bit >> to & 1) {
						nb |= 1 << to;
						cost -= c[to];
					}
					else continue;
				}
				if(dist[to][nb] > d + cost) {
					dist[to][nb] = d + cost;
					q.push({ to, nb, d + cost });
				}
			}
		}

		int ans = INF;
		for(int i = 0; i < 1 << M; i++) {
			ans = min(ans, dist[g][i]);
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 3984
#include <iostream>
#include <string>
#include <map>
using namespace std;
using Int = int64_t;
int main() {
    Int N, K, R, S, P, ans = 0;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    map<char, char> win = {
        {'r', 'p'},
        {'s', 'r'},
        {'p', 's'}
    };
    map<char, Int> score = {
        {'r', R},
        {'s', S},
        {'p', P}
    };
    for (Int i = 0; i < N; i++) {
        char c;
        if (i >= K && T[i] == T[i - K]) {
            c = win[win[T[i]]];
            T[i] = win[T[i]];
            if (i + K < N && T[i] == T[i + K]) T[i] = win[T[i]];
        }
        else {
            c = win[T[i]];
            ans += score[c];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const ll MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vll h(n);
    rep(i, n)
        cin >> h[i];
    int cnt = 0, ans = 0;
    rep(i, n-1) {
        if (h[i] >= h[i+1])
            cnt++;
        else {
            if (ans < cnt) {
                ans = cnt;
            }
                cnt = 0;
        }
    }
    if (ans < cnt)
        ans = cnt;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	while (true) {
		int n; cin >> n;
		if (n == 0)break;

		// <<勝ち数, -負け数>, 入力順>, 名前
		vector<pair<pair<pair<int, int>, int>, string>> d(n);

		rep(i, n) {
			string name; cin >> name;
			int c0 = 0, c1 = 0, c2 = 0;
			rep(j, n - 1) {
				int x; cin >> x;
				switch (x) {
				case 0:
					c0++; break;
				case 1:
					c1++; break;
				case 2:
					c2++; break;
				}
			}

			d[i] = mp(mp(mp(-c0, c1), i), name);
		}

		sort(all(d));

		rep(i, n)Cout(d[i].second);
	}
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e4;
bool y[N];
int s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  int ans = 0;
  while(true){
    ans++;
    if(y[s]) break;
    y[s] = true;
    s = s&1 ? s*3+1 : s>>1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall
h,w=map(int,input().split())
meiro=[input() for _ in range(h)]
n=w*h
e=[[0]*n for _ in range(n)]
d=[(1,0),(0,1),(-1,0),(0,-1)]
for i in range(h):
  for j in range(w):
    if meiro[i][j]==".":
      for x,y in d:
        ni,nj=i+x,j+y
        if 0<=ni<h and 0<=nj<w and meiro[ni][nj]==".":
          e[w*i+j][w*ni+nj]=1

ans=floyd_warshall(e)
INF=float("inf")
print(int(max(max(a if a != INF else 0 for a in a) for a in ans)))

Measured memory_bytes: 21780
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

const double pi = 3.14159265358979323846;
const int mod = 1000000007;

int main(){
  long long Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;

  long long min1L = min(4*Q,min(2*H,S));
  long long min2L = min(2*min1L,D);

  cout << (N/2) * min2L + (N%2) * min1L << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,p[21],i,j,k,cnt=0;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&p[i]);
  }
  for(i=0; i<n-2; i++){
    j=i+1;
    k=i+2;
    if((p[j]<=p[k] && p[j]>=p[i]) || (p[j]<=p[i] && p[j]>=p[k])){
      cnt++;
    }
  }
  printf("%d\n",cnt);
  return 0;
}


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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }




signed main() {

	int N, K;
	cin >> N >> K;
	string s;
	cin >> s;

	int LR = 0;
	int RL = 0;
	int ans = 0;
	rep(i, N-1) {
		if (s[i] == s[i + 1]) ans++;
		if (s[i] == 'L' && s[i + 1] == 'R') LR++;
		if (s[i] == 'R' && s[i + 1] == 'L') RL++;
	}

	if (min(LR, RL) >= K) {
		ans += K * 2;
		K -= min(LR, RL);
		LR -= K;
		RL -= K;
	}
	if (K > 0 && LR > 0) {
		ans += min(K, LR);
//		LR -= min(K, LR);
	}
	if (K > 0 && RL > 0) {
		ans += min(K, RL);
//		RL -= min(K, RL);
	}



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


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  vector<ll> a(n+1), b(m+1);
  a[0] = 0; b[0] = 0;
  for(int i = 1; i < n+1; i++){
    int x;
    cin >> x;
    a[i] = a[i-1] + x;
  }
  for(int i = 1; i < m+1; i++){
    int x;
    cin >> x;
    b[i] = b[i-1] + x;
  }
  
  int ans = 0;
  for(int i = 0; i < n+1; i++){
    if(a[i] > k) continue;
    auto border = upper_bound(b.begin(), b.end(), (ll)k-a[i]);
    int maxi = distance(b.begin(), border) - 1;
    ans = max(ans, i + maxi);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6424
N=int(input())
H=list(map(int, input().split()))
import numpy as np

H=np.array(H)
ans=0
for i in range(H.max()):
    #print(H)
    count=0
    now=(H[0]==0)
    if not now:
        count+=1
    for j in range(1,N):
        if now:
            if H[j]!=0:
                count+=1
        
        now=(H[j]==0)
    ans+=count
    #print(count)
    H[H>0]-=1
print(ans)



Measured memory_bytes: 21400
#include <cstdio>
#include <utility>
#include <algorithm>

/*
Z[r] - Z[l-1] = S

1 S+1 2S+1 3S+1
S S S S ... S
*/


int n, k, s;

int main(){
  scanf("%d%d%d", &n, &k, &s);

  for(int i = 0; i < k; i++) printf("%d ", s);
  for(int i = k; i < n; i++) printf("%d ", s == 1000000000 ? 1 : s+1);
  puts("");


  return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>
#include<memory.h>
#include<stdlib.h>
#include<string.h>


int main(void){

        int N=0;
        int flag = 0;
        scanf("%d",&N);        

        for(int i=1;i<10;i++){
                if(N%i == 0){
                        if(N/i < 10){
                                printf("Yes\n");
                                i = 20;
                                flag = 1;
                        }
                }
        }
        if(!flag){
                printf("No\n");
        }

        return 0;
}       

Measured memory_bytes: 128