akhauriyash/Code-Regression huggingface dataset:
#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>;
const int INF=1001001;
int main(){
  int n;
  cin>>n;
  vector <int>a(n+2);
  a[0]=0;a[n]=0;
  rep(i,n)cin>>a[i+1];

  vector<int>l1(n+1,0);
  vector<int>l2(n,0);
  int tot=0;

  rep(i,n+1){
    l1[i]=abs(a[i+1]-a[i]);
    tot+=l1[i];
  }
  rep(i,n){
  l2[i]=abs(a[i+2]-a[i]);
}
rep(i,n){
  int ans=tot-l1[i]-l1[i+1];
  ans+=l2[i];
  cout<<ans<<endl;
}








}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
 
using namespace std;
 
const int N=100005;
 
int n,a[N],las,t,g,s,f;
char str[2][10]={"First","Second"};
int gcd(int x,int y){return y?gcd(y,x%y):x;}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	while(true){
		s=t=0;
		for(int i=1;i<=n;i++){
			if(a[i]&1)t++,las=i;else s^=1;
		}
		if(s){puts(str[f]);break;}
		if(t>1||a[las]==1){puts(str[f^1]);break;}
		a[las]--;g=0;f^=1;
		for(int i=1;i<=n;i++)g=gcd(g,a[i]);
		for(int i=1;i<=n;i++)a[i]/=g;
	}
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

namespace practice
{ 

    class MainClass
    {

        public static void Main(string[] args)
        {
            List<string> suitList = new List<string>() { "S", "H", "C", "D" };
            List<string> deck = new List<string>();
            foreach (string suit in suitList)
            {
                for (int i = 1; i <= 13; i++)
                {
                    deck.Add(suit + " " + i);
                }
            }
            int n = int.Parse(Console.ReadLine());
            List<string> inputCards = new List<string>();
            for (int i = 0; i < n; i++)
            {
                inputCards.Add(Console.ReadLine());
            }
            foreach(string card in deck)
            {
                bool isIncluded = false;
                foreach(string inputCard in inputCards)
                {
                    if(card == inputCard)
                    {
                        isIncluded = true;
                        break;
                    }
                }
                if (!isIncluded)
                {
                    Console.WriteLine(card);
                }
            }
        }
    }
}


Measured memory_bytes: 18048
// 1行にintが1つだけ入っているときに読み取る
fn read_int() -> i32{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().parse().unwrap()
}

// 1行に複数のintが含まれている
fn read_int_s() -> Vec<i32>{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let v : Vec<i32> = s.trim().split(' ').collect::<Vec<_>>().iter().map(|x| x.parse().unwrap()).collect();
    v
}

fn main(){
    let v = read_int_s();
    let (a,b) = (v[0],v[1]);
    println!("{} {}",a*b,2*(a+b));
}


Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long x,ans;
  cin >> x;
  ans=x/11*2;
  if (x%11){
    if (x%11<=6) ans++;
    else ans+=2;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

static int maxn=200000;

int main(int argc, char const *argv[])
{
	int n,r[maxn];
	cin>>n;

	for (int i = 0; i < n; ++i)
	{
		cin>>r[i];
	}
	int minr=r[0];
	int maxv=-1000000000;

	for (int i = 1; i < n; ++i)
	{
		maxv=max(maxv,r[i]-minr);
		minr=min(minr,r[i]);
	}

	cout<<maxv<<endl;

	return 0;
}


Measured memory_bytes: 3836
#include <stdio.h>
int main()
{
    char A;
    scanf("%c",&A);
    if(A=='A')
    {
        A='T';
    }
    else if(A=='T')
    {
        A='A';
    }
    else if(A=='G')
    {
        A='C';
    }
    else if(A=='C')
    {
        A='G';
    }
    printf("%c\n",A);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
    int a[100];
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++)
    {
        a[i] = s[i] - 48;
    }
    int minnn = 10000;

    for(int i = 2; i < s.size(); i++)
    {
        if(minnn > abs(100 * a[i - 2] + 10 * a[i - 1] + a[i] - 753))
        {
            minnn = abs(100 * a[i - 2] + 10 * a[i - 1] + a[i] - 753);
        }
    }

    cout << minnn;
}

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

int main(){
    int a,b,x;
    char op;
    op = '+';
    while(1){
        cin >> a >> op >> b; 
        if(op == '+'){
            x = a + b;
            cout << x << endl;
        }
        else if(op == '-'){
            x = a - b;
            cout << x << endl;
        }
        else if(op == '*'){
            x = a * b;
            cout << x << endl;
        }
        else if(op == '/'){
            x = a / b;
            cout << x << endl;
        }
        else{
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3112
// https://atcoder.jp/contests/agc023/tasks/agc023_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
    int n;
    cin >> n;
    vector<ll> dp(n + 1, 0);
    REP(i, n) {
        ll t;
        cin >> t;
        dp[i + 1] = dp[i] + t;
    }
    ll cnt = 0;
    map<ll, int> mp;
    REPR(i, n + 1) {
        cnt += mp[dp[i]];
        mp[dp[i]]++;
    }
    cout << cnt << endl;

    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n,k,q;
  cin>>n>>k>>q;
  vll a(n);
  REP(i,n)cin>>a[i];

  ll ans=LLINF;
  REP(i,n){
    ll m=a[i];
    vll tmp,vec;
    vec.push_back(m);

    REP(j,n){
      if(j==i)
        continue;

      if(a[j]<m){
        sort(ALL(tmp));
        REP(h,tmp.size()-k+1)
          vec.push_back(tmp[h]);

        tmp.clear();
      }
      else
        tmp.push_back(a[j]);
    }
    //nokori
    sort(ALL(tmp));
    REP(h,tmp.size()-k+1)
      vec.push_back(tmp[h]);

    if(vec.size()<q)
      continue;

    sort(ALL(vec));
    ans=min(ans,vec[q-1]-vec[0]);
  }

  cout<<ans<<endl;
}



Measured memory_bytes: 3712
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
mod=10**9+7
ans=1
i=0
j=-1
k_1=k
while k_1>1:
  if a[i]*a[i+1]>a[j]*a[j-1]:
    ans=ans*a[i]*a[i+1]%mod
    i+=2
    k_1-=2
  else:
    ans=ans*a[j]%mod
    j-=1
    k_1-=1
if k_1==1:
  ans=ans*a[j]%mod
if a[-1]<0 and k%2==1:
  ans=1
  for i in a[n-k:]:
    ans=ans*i%mod
print(ans)


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

int main(){
  int64_t K,N;
  cin>>K>>N;
  vector<int64_t> A(N);
  for(int i=0;i<N;++i) cin>>A[i];
  sort(A.begin(),A.end());

  int64_t M=K-(A[N-1]-A[0]);
  for(int i=0;i<N;++i){
    M=max(M,A[i]-A[i-1]);
  }

  cout<<K-M<<endl;
}

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

using namespace std;
const int maxn = 3e3 + 5, mod = 1e9 + 7;
int n, c[maxn][maxn], a[maxn];
long long f[maxn][maxn];

long long dp(int l, int r)
{
    if (l > r) return 0;
    long long &res = f[l][r];
    if (c[l][r]) return res;
    c[l][r] = true;
    int turn = (l + (n - r + 1)) % 2;
    if (turn) {
        res = 1e13;
        res = min(dp(l + 1, r) - a[l], res);
        res = min(dp(l, r - 1) - a[r], res);
    } else {
        res = -1e13;
        res = max(dp(l + 1, r) + a[l], res);
        res = max(dp(l, r - 1) + a[r], res);
    }
    return res;
}

int main()
{
    #ifdef NTMA 
        freopen("abc.inp", "r", stdin);
    #endif
    //memset(f, 255, sizeof(f));
    cin >> n;
    for(int i=1; i<=n; ++i) cin >> a[i];
    cout << dp(1, n);
    return 0;
}

Measured memory_bytes: 105344
#include <vector>
#include <iostream>

#pragma GCC optimize ("O3")

using namespace std;

bool get(int ip, int ind)
{
    int cv = (1<<ind);
    return ip & cv;
}

int unset(int ip, int ind)
{
    return ip & ~(1<<ind);
}

struct dpstruct
{
    vector<vector<int>> states;
    int mod;
    int n;
    vector<vector<bool>> comp;

    int dp(int i, int j)
    {
        if (i == 0 && j == 0) return 1;
        if (i == 0) return 0;
        if (states[i][j] != -1) return states[i][j];

        long long l = 0;
        for (int k = 0; k < n; k++)
        {
            if (!get(j, k)) continue;
            if (!comp[i - 1][k]) continue;
            l += dp(i - 1, unset(j, k));
        }
        return states[i][j] = l % mod;
    }
};

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

    vector<vector<bool>> comp(n, vector<bool>(n, false));

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            int in;
            cin >> in;
            comp[i][j] = in;
        }
    }

    int mod = 1e9 + 7;

    int pm = 1;
    for (int i = 0; i < n; i++)
    {
        pm *= 2;
    }

    dpstruct dps;
    dps.comp = comp;
    dps.mod = mod;
    dps.n = n;
    dps.states.resize(n + 1, vector<int>(pm, -1));

    cout << dps.dp(n, pm - 1) << "\n";
}

Measured memory_bytes: 188800
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define NINTH_POWER_OF_TEN 1000000000
#define LL_INF (numeric_limits<long long>::max()/2)
#define int long long

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

const int kMaxN = 100000;

int N, X;
int x[kMaxN];
int ans = 1;

int Pow(int a, int b) {
  int r = 1;
  REP(i, b) { r *= a; }
  return r;
}

signed main() {
  cin >> N >> X;
  REP(i, N) { cin >> x[i]; }

  REP(i, N) { x[i] = ABS(x[i]-X); }

  map<int, int> pf;
  int n = x[0];
  for (int i = 2; i*i <= n; ++i) {
    // cout << n << " " << i << endl;
    while (n%i == 0) {
      // cout << "hey" << endl;
      ++pf[i];
      n /= i;
    }
  }
  if (n != 1) { ++pf[n]; }

  FOR(i, 1, N-1) {
    map<int, int> pf2;
    int n = x[i];
    for (int j = 2; j*j <= n; ++j) {
      while (n%j == 0) {
        ++pf2[j];
        n /= j;
      }
    }
    if (n != 1) { ++pf2[n];}

    for (auto it = pf.begin(); it != pf.end(); ++it) {
      int n = it->first;
      // cout << n << " " << it->second << " " << pf2[n] << endl;
      it->second = MIN(it->second, pf2[n]);
    }
  }

  for (auto it = pf.begin(); it != pf.end(); ++it) {
    // cout << it->first << " " << it->second << endl;
    ans *= Pow(it->first, it->second);
  }

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


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

const int MAX_N = 300000;
bool msp[MAX_N + 10];

void init()
{
    for (int i = 0; i <= MAX_N; i++) {
        if (i % 7 == 1 || i % 7 == 6)
            msp[i] = true;
        else
            msp[i] = false;
    }

    msp[0] = msp[1] = false;
    for (int i = 6; i * i <= MAX_N; i++) {
        if (msp[i])
            for (int j = 2 * i; j <= MAX_N; j += i)
                msp[j] = false;
    }
}

int main()
{
    int num;

    init();

    while (cin >> num, num != 1) {
        cout << num << ":";
        for (int i = 0; i <= num; i++)
            if (msp[i] && num % i == 0)
                cout << " " << i;
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1452
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		int h[] = new int[N];
		for(int i=0;i<N;i++) {
			h[i]=sc.nextInt();
		}
		int cost[] = new int[N];
		cost[N-1] = 0;
		cost[N-1-1] = Math.abs(h[N-1] - h[N-1-1]);
		
		for(int i=N-2-1;i>=0;i--) {
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int j=1;j<=Math.min(K,N-1-i);j++) {
				list.add(cost[i+j]+Math.abs(h[i+j]-h[i]));
			}
			Collections.sort(list);
			cost[i] = list.get(0);
		}
		
		System.out.println(cost[0]);
	}

}


Measured memory_bytes: 151800
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    if all(s.count(c) > 0 for c in "753"):
        ret = 1
    else:
        ret = 0
    
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0')) 

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>

using namespace std;

int main() {
	int n;
	while (true) {
		cin >> n;
		if (!n) {
			break;
		}
		int a = 0, b = 0;
		for (int i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			if (x > y) {
				a += x + y;
			} else if (x < y) {
				b += x + y;
			} else {
				a += x;
				b += y;
			}
		}
		cout << a << ' ' << b << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <string>
using namespace std;
int W,H,m,f,MAP[15][15];
int DP[11][11][55][11][11];
struct state{
	int x,y,s,e,o,f;
	state(int xx,int yy,int oo,int ss,int ee,int ff){
		x=xx;y=yy;s=ss;e=ee;o=oo;f=ff;
	}
	state(){}
};
bool operator>(state a,state b){return a.f>b.f;}
int solve(int o){
	memset(DP,0x10,sizeof(DP));
	if(o<=1)return -1;

	priority_queue<state,vector<state>,greater<state> > que;
	for(int i=0;i<W;i++){
		int no=o-1;int now=0;
		if(MAP[i][0]>0){
			no+=MAP[i][0];if(no>m)no=m;
		}else{
			now-=MAP[i][0];
		}
		DP[i][0][no][i][i]=now;
		que.push(state(i,0,no,i,i,now));
	}
	state temp;
	while(!que.empty()){
		temp=que.top();que.pop();
		temp.o--;
		state nstate=temp;
		if(nstate.y==H-1){
			return nstate.f;
		}
		if(nstate.o==0)continue;

		nstate.y+=1;
		nstate.s=nstate.x;nstate.e=nstate.x;
		if(MAP[nstate.x][nstate.y]>0){
			nstate.o+=MAP[nstate.x][nstate.y];if(nstate.o>m)nstate.o=m;
		}else{
			nstate.f-=MAP[nstate.x][nstate.y];
		}
		if(DP[nstate.x][nstate.y][nstate.o][nstate.s][nstate.e]>nstate.f){
			DP[nstate.x][nstate.y][nstate.o][nstate.s][nstate.e]=nstate.f;
			que.push(nstate);
		}

		nstate=temp;
		nstate.x+=1;
		if(nstate.x<W){
			if(nstate.e<nstate.x){
				nstate.e=nstate.x;
				if(MAP[nstate.x][nstate.y]>0){
					nstate.o+=MAP[nstate.x][nstate.y];if(nstate.o>m)nstate.o=m;
				}else{
					nstate.f-=MAP[nstate.x][nstate.y];
				}
			}
			if(DP[nstate.x][nstate.y][nstate.o][nstate.s][nstate.e]>nstate.f){
				DP[nstate.x][nstate.y][nstate.o][nstate.s][nstate.e]=nstate.f;
				que.push(nstate);
			}
		}
		nstate=temp;
		nstate.x-=1;
		if(nstate.x>=0){
			if(nstate.s>nstate.x){
				nstate.s=nstate.x;
				if(MAP[nstate.x][nstate.y]>0){
					nstate.o+=MAP[nstate.x][nstate.y];if(nstate.o>m)nstate.o=m;
				}else{
					nstate.f-=MAP[nstate.x][nstate.y];
				}
			}
			if(DP[nstate.x][nstate.y][nstate.o][nstate.s][nstate.e]>nstate.f){
				DP[nstate.x][nstate.y][nstate.o][nstate.s][nstate.e]=nstate.f;
				que.push(nstate);
			}
		}
	}
	return -1;
}

int main(){
	for(;scanf("%d%d",&W,&H),W;){
		int o=0;
		scanf("%d%d%d",&f,&m,&o);

		for(int y=0;y<H;y++)
			for(int x=0;x<W;x++)
				scanf("%d",&MAP[x][y]);
		int res=solve(o);
		if(res==-1||res>f){
			puts("NA");
		}else{
			printf("%d\n",res);
		}
	}
	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    int count = 0;
    int total = 1;
    while (total < b) {
        count++;
        total += a - 1;
    }

    cout << count << '\n';

    return 0;
}

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

int main() {
	int n; cin >> n;
	int t = 7;
	for (int i=1; i<=n; i++) {
		if (t % n == 0) {
			cout << i;
			return 0;
		}
		else {
			t *= 10;
			t += 7;
			t %= n;
		}
	}
	cout << -1;
}


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

int main() {
  int a, p;
  cin >> a >>p;
  p += a*3;
  int ans = p / 2;
  cout << ans << endl;
}

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


// int N, M, A[10010], B[10010], COST[10010];
// pair<int, int> bridge[10010];
int P[10010];//村のrootが保存

void init(int N){
  for(int i=0; i< N; ++i){
    P[i]= i;
  }
}

int root(int a){//aのroot(代表元)を決める
  if(P[a]==a) return a;//aはroot
  return (P[a] = root(P[a]));//aの親のrootを求め,aの親とする
}
bool is_same_set(int a, int b){
  return root(a) == root(b);
}
void unite(int a, int b){
   P[root(a)] = root(b);
}


int main(){
  int N, M, A[10010], B[10010], COST[10010];
  pair<int, int> bridge[10010];

  //root決める
  while(cin >> N >> M  && N>0){
    int allcost = 0;
    // int bridgenum = 0;
    init(N);
    for (int i = 0; i < M; ++i)
    {
      cin >> A[i] >> B[i] >> COST[i];
      bridge[i].first = COST[i];
      bridge[i].second = i ;
    }
    sort(bridge,bridge+M);
    for (int i = 0; i < M; ++i)
    {
      int cost = bridge[i].first;
      int a = A[bridge[i].second];
      int b = B[bridge[i].second];

      // if (bridgenum == M-1)
      // {
      //   unite(a,b);
      //   // allcost += cost;
      // }
      if(is_same_set(a,b)){

      }else{
        unite(a,b);
        allcost += cost;
        // cout <<  allcost << endl;
        // bridgenum += 1;
      }
      // 「a から b に cost の橋がかかっている」と表示
    }
    cout <<  allcost << endl;
  }
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
#define int  long long
#define tc(t)  int t; cin>>t; while(t--)
#define f(n)    for(int i=0;i<n;i++)
#define endl   "\n"
int compare(pair<string,pair<int,int>>p1,pair<string,pair<int,int>>p2)
{


    if(p1.first==p2.first)
    {
        return p1.second.first>p2.second.first;

    }
    return p1<p2;




}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

 int n;
 cin>>n;
 vector<pair<string,pair<int,int>>>v(n);
  for(int i=0;i<n;i++)
  {
      string name;
      int point;
      cin>>name>>point;
      v[i]=(make_pair(name,make_pair(point,i+1)));

  }

 sort(v.begin(),v.end(),compare);

  for(int i=0;i<v.size();i++)
  {
      cout<<v[i].second.second<<endl;
  }






}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===

//const ll mod = static_cast<int>(1e9 + 7);



int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (C <= A - B) {
		cout << 0 << endl;
	}
	else {
		cout << C - (A - B) << endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main() {
  int i, N, T, *c, *t, min = 1001;
  scanf("%d %d%*c", &N, &T);
  c = (int *)malloc(sizeof(int) * N);
  t = (int *)malloc(sizeof(int) * N);
  for (i = 0; i < N; i++) {
    scanf("%d %d%*c", &c[i], &t[i]);
    if (t[i] > T) continue;
    if (c[i] < min) min = c[i];
  }
  if (min == 1001) printf("TLE\n");
  else printf("%d\n", min);
  free(c); free(t);
  return 0;
}

Measured memory_bytes: 128
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

let ints = readInts()
let n = ints[0]
let sum = ints[1]

func main() {
    for i in 0...n {
        for j in 0...(n - i) {
            let k = n - i - j
            if k < 0 {
                break
            }
            if i * 10_000 + j * 5_000 + k * 1_000 == sum && i + j + k == n {
                print(i, j , k)
                return
            }
        }
    }
    print("-1 -1 -1")
}

main()

Measured memory_bytes: 8176
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){
  int N, a;
  cin >> N;
  vector<int> vec(N);

  for (int i = 0; i < N; i++){
    cin >> a;
    vec.at(i) = a;
  }

  int max = *std::max_element(vec.begin(), vec.end());
  int min = *std::min_element(vec.begin(), vec.end());

  cout << max - min << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll, ll> pii;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

int N, M;

vi nodes[100001];
int dp[100001];

int dfs(ll idx)
{
    if (dp[idx] != -1)
    {
        return dp[idx];
    }
    else
    {
        int maxima = 0;
        REP(i, nodes[idx].size())
        {
            maxima = max(maxima, dfs(nodes[idx][i]) + 1);
        }
        dp[idx] = maxima;
        return maxima;
    }
}

int main()
{
    cin >> N >> M;
    REP(i, N + 1)
    {
        dp[i] = -1;
    }
    int temp_x, temp_y;
    REP(i, M)
    {
        cin >> temp_x >> temp_y;
        nodes[temp_x].push_back(temp_y);
    }
    int max_L = 0;
    REP(i, N + 1)
    {
        max_L = max(max_L, dfs(i));
    }
    cout << max_L;
    // system("pause");
}

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

using namespace std;
using int64 = long long int;

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

	if (n >= 10)
	{
		cout << r << endl;
	}
	else
	{
		cout << (r + 100 * (10 - n)) << endl;
	}
}

Measured memory_bytes: 256
A, B, C = gets.split.map(&:to_i)
odds = [A, B, C].select(&:odd?)
evens = [A, B, C].select(&:even?)
if odds.size == 3 || evens.size == 3
  max = [A, B, C].max
  count = [A, B, C].map { |n| (max - n) / 2 }.reduce(&:+)
  puts count
elsif odds.size == 2
  n, m = odds
  max = [n, m].max
  count = (n - m).abs / 2
  if evens[0] < max
    count += (max - evens[0] + 1) / 2 + 1
  else
    count += evens[0] - max
  end
  puts count
else # evens.size == 2
  n, m = evens
  max = [n, m].max
  count = (n - m).abs / 2
  if odds[0] < max
    count += (max - odds[0] + 1) / 2 + 1
  else
    count += odds[0] - max
  end
  puts count
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}

void solve(long long N, long long P, string S){
    if(P==2||P==5){
        ll ans=0;
        rep(i,N){
            ll x=S[i]-'0';
            if(x%P==0){
                ans+=i+1;
            }
        }
        cout<<ans<<endl;
        return;
    }

    vl cnt(P);
    cnt[0]=1;
    ll tmp=0;
    ll d=1;
    rrep(i,N){
        tmp=(tmp+d*(S[i]-'0'))%P;
        cnt[tmp]++;
        d=(d*10)%P;
    }
    ll ans=0;
    rep(i,P){
        ans+=cnt[i]*(cnt[i]-1)/2;
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long P;
    scanf("%lld",&P);
    string S;cin>>S;
    solve(N, P, S);
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

constexpr int max_n = 41;
constexpr int max_m = 500;
int dp[max_n][max_m][max_m];

int main() {
  int N, Ma, Mb; cin >> N >> Ma >> Mb;
  vector<int> a(N), b(N), c(N);
  rep(i, N) {
    cin >> a[i] >> b[i] >> c[i];
  }
  rep(i, max_n) rep(j, max_m) rep(k, max_m) {
    dp[i][j][k] = inf;
  }

  dp[0][0][0] = 0;
  int min_value = inf;
  rep(i, N) rep(j, max_m) rep(k, max_m) {
    if (dp[i][j][k] >= inf) continue;
    minimize(dp[i + 1][j][k], dp[i][j][k]);
  
    auto& target = dp[i + 1][j + a[i]][k + b[i]];
    minimize(target, dp[i][j][k] + c[i]);
    if (j + a[i] > 0 && (j + a[i]) * Mb == (k + b[i]) * Ma) {
      minimize(min_value, target);
    }
  }
  cout << (min_value < inf ? min_value : -1) << "\n";
}


Measured memory_bytes: 40320
S = input()

abc = 'abcdefghijklmnopqrstuvwxyz'

less_abc = abc

for s in S:
    less_abc = less_abc.replace(s,'')

ans = ''
if len(S) != 26:
    ans = S + less_abc[0]
elif S == 'zyxwvutsrqponmlkjihgfedcba':
    ans = -1
else:
    bef_tmp = -1
    tmp = ''
    for s in S[::-1]:
        ind = abc.index(s)
        if ind > bef_tmp:
            bef_tmp = ind
            tmp += s
        else:
            ans = S[:S.index(s)]

            tar_s = s
            ind = abc.index(tar_s)
            for ss in abc[ind:]:
                if ss in tmp:
                    break

            ans += ss
            break

    # long_now = ''
    # long_s = ''
    # num = 0
    # ind = 27
    # for s in S:
    #     ind_now = abc.index(s)
    #     if ind > ind_now:
    #         ind = ind_now
    #         long_now += s
    #     else:
    #         if len(long_s) <= len(long_now):
    #             long_s = long_now

    #         long_now = s
    #         ind = ind_now

    # if len(long_s) <= len(long_now):
    #     long_s = long_now

    # ind = S.index(long_s)
    # S = S[:ind]
    # for s in abc[abc.index(S[-1])+1:]:
    #     if s in long_s:
    #         ans = S + s
    #         break

print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int A, B, M;
  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &M);
  std::vector<int > a(A);
  std::vector<int > b(B);
  std::vector<int > x(M), y(M), c(M);
  int Amin = 100005;
  int Bmin = 100005;
  for (int i=0; i<A; i++){
    scanf("%d", &a[i]);
    Amin = std::min(Amin, a[i]);
  }
  for (int i=0; i<B; i++){
    scanf("%d", &b[i]);
    Bmin = std::min(Bmin, b[i]);
  }
  for (int i=0; i<M; i++){
    scanf("%d", &x[i]);
    scanf("%d", &y[i]);
    scanf("%d", &c[i]);
    x[i]--;
    y[i]--;
  }
  int ans = Amin+Bmin;
  for (int i=0; i<M; i++){
    int Aindex = x[i];
    int Bindex = y[i];
    //printf("i=%d, %d+%d-%d\n",i,a[Aindex],b[Bindex],c[i]);
    ans = std::min(ans, a[Aindex]+b[Bindex]-c[i]);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define sf1(a); scanf("%d",&a);
#define sf2(a,b); scanf("%d %d",&a, &b);
#define sf3(a,b,c); scanf("%d %d %d",&a, &b,&c);
#define sf4(a,b,c,d); scanf("%d %d %d %d",&a, &b,&c,&d);
#define pf1(a); printf("%d\n",a);
#define pf2(a,b); printf("%d %d\n",a,b);
#define pf3(a,b,c); printf("%d %d %d\n",a,b,c);
#define pf4(a,b,c,d); printf("%d %d %d %d\n",a,b,c,d);

using namespace std;

int main()
{
    int h,w;
    sf2(h,w);
    char a[h][w],b[h][w],c[h][w];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>a[i][j];
        }
    }

    int r=0,cl=0;

    for(int i=0;i<h;i++)
    {
        int f=0;
        for(int j=0;j<w;j++)
        {
            if(a[i][j]!='.')
            {
                f = 1;
                break;
            }
        }
        if(f)
        {
            for(int j=0;j<w;j++)
            {
                b[r][j]=a[i][j];
            }
            r++;
        }
    }

    int k=0;
    for(int i=0;i<w;i++)
    {
        int f=0;
        for(int j=0;j<r;j++)
        {
            if(b[j][i]!='.')
            {
                f = 1;
                break;
            }
        }
        if(f)
        {
            for(int j=0;j<r;j++)
            {
                c[j][cl]=b[j][i];
            }
            cl++;
        }
    }

    if(cl==1)
    {
        for(int i=0;i<r;i++)
        {
            cout<<c[i][0];
        }
        cout<<endl;
        return 0;
    }

    for(int i=0;i<r;i++)
    {
        for(int j=0;j<cl;j++)
        {
            cout<<c[i][j];
        }
        cout<<endl;
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(){
  int n;
  int i, j;
  int l;
 
  scanf("%d", &n);
  char w[n][100];
  for (i = 0; i < n; i++){
  	scanf("%s", w[i]);
  }
  for (i = 0; i < n-1; i++){
  	l = strlen(w[i]);
    if(w[i][l-1] != w[i+1][0]){
      printf("No");
      return 0;
    }
  }
  for (i = 0; i < n; i++){
    for (j = i+1; j < n; j++){
      if(strcmp(w[i],w[j]) == 0){
        printf("No");
        return 0;
      }
    }
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 128
/*************************************************************************
	> File Name: AT2165.cpp
	> Author: s-k-y
	> Mail: zhoutianyi0330@qq.com 
	> Created Time: 2019年11月07日 星期四 08时54分07秒
 ************************************************************************/

#include<bits/stdc++.h>
#define ll long long
#define ul unsigned long long
#define F(i,a,b) for(register long long i=a;i<=b;i++)
#define K(i,a,b) for(register long long i=a;i>=b;i--)
using namespace std;
ll a[1000001],n,f[1000001],t,k,l,r,o;
ll pd(ll x){
	t=0;
	if(a[1]>x)f[1]=1;
	else f[1]=0;
	o=f[1];
	F(i,2,n*2-1){
		if(a[i]>x)f[i]=1;
		else f[i]=0;
		if(t==0){
			if(f[i]==f[i-1]){
				t=i;
				o=f[i];
			}
		}
		else if(f[i]==f[i-1]&&abs(n-i+1)<abs(n-t+1)){
			t=i;
			o=f[i];
		}
	}
	return o;
}
int main(){
	cin>>n;
	F(i,1,n*2-1)cin>>a[i];
	l=1;r=n*2-1;
	while(l<r){
		ll mid=(l+r)>>1;
		if(pd(mid)==0){
			r=mid;
		}
		else l=mid+1;
	}
	cout<<r;
	return 0;
}

Measured memory_bytes: 5888
n,k,c = map(int,input().split())
s = input()
cnt = 0
e = 0
l = []
for i,si in enumerate(s):
  if e == k:
    break
  if cnt > 0:
    cnt -= 1
    continue
  if si == 'o':
    l.append(i+1)
    cnt = c
    e += 1
  
r = []
cnt = 0
d = 0
for i,si in enumerate(s[::-1]):
  if d == k:
    break
  if cnt > 0:
    cnt -= 1
    continue
  if si == 'o':
    r.append(n-i)
    cnt = c
    d += 1
    
for i in range(k):
  if l[i] == r[k-1-i]:
    print(l[i])

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

using namespace std;
using ll = long long;

vector<ll> A;
ll N,K;
ll maxA;

bool isOK(ll len){
    ll res = 0LL;
    if(len == 0)return false;
    for(ll a : A){
        res += ((a%len==0) ? a/len-1 : a/len);
    }
    // cout << "len: " << len << "\t" << ((res<=K) ? "ok" : "ng") << endl;
    return res <= K;
}

ll binary_search(){
    ll ng = 0LL;
    ll ok = maxA+1;

    while(abs(ok-ng) > 1){
        ll mid = (ok+ng)/2;

        if(isOK(mid))ok = mid;
        else ng = mid;
    }

    return ok;
}

int main(){
    cin >> N >> K;

    A = vector<ll>(N);
    maxA = 0LL;
    for(int i=0; i<N; i++){
        cin >> A.at(i);
        maxA = max(maxA, A.at(i));
    }

    ll res = binary_search();

    cout << res << endl;
}

Measured memory_bytes: 4828
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;
using ll = long long;

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

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

  vector<set<int>> al(26);
  rep(i, n) { al[s[i] - 'a'].insert(i); }

  rep(qi, nq) {
    int q;
    cin >> q;
    if (q == 1) {
      int i;
      char c;
      cin >> i >> c;
      --i;
      al[s[i] - 'a'].erase(i);
      s[i] = c;
      al[c - 'a'].insert(i);
    } else {
      int l, r;
      cin >> l >> r;
      --l, --r;
      int ans = 0;
      rep(i, 26) {
        auto it = al[i].lower_bound(l);
        if (it != al[i].end() && *it <= r) ++ans;
      }
      // for (auto a : al) {
      //   auto idx = a.lower_bound(l);
      //   if (idx != a.end() && *idx <= r) ++ans;
      // }
      printf("%d\n", ans);
    }
  }
  return 0;
}


Measured memory_bytes: 24196
n=io.read("*n","*l")
t={}
frequency=0
for i=1,n do
    s=io.read()
    if not t[s] then
        t[s]=1
    else
        t[s]=t[s]+1
    end
    frequency=math.max(frequency,t[s])
end
w={}
for k,v in pairs(t) do
    if v==frequency then
        table.insert(w,k)
    end
end
table.sort(w)
for k,v in pairs(w) do
    print(v)
end

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

int digit[4];

int result(int op1, int op2, int op3){
	return digit[0] + op1 * digit[1] + op2 * digit[2] + op3 * digit[3];
}

void printExpression(int op1, int op2, int op3){
	char cop1, cop2, cop3;
	if(op1 == 1)	cop1 = '+'; else cop1 = '-';
	if(op2 == 1)	cop2 = '+'; else cop2 = '-';
	if(op3 == 1)	cop3 = '+'; else cop3 = '-';
	cout << digit[0] << cop1 << digit[1] << cop2 << digit[2] << cop3 << digit[3] << "=7";
}


int main(){
	
	char c[4];
	for(int i=0; i<4; i++){
		cin >> c[i];
		digit[i] = c[i] - '0';
	}
	
	if(result( 1, 1, 1)	== 7) printExpression( 1, 1, 1);
	else if(result( 1, 1,-1)	== 7) printExpression( 1, 1,-1);
	else if(result( 1,-1, 1)	== 7) printExpression( 1,-1, 1);
	else if(result( 1,-1,-1)	== 7) printExpression( 1,-1,-1);
	else if(result(-1, 1, 1)	== 7) printExpression(-1, 1, 1);
	else if(result(-1, 1,-1)	== 7) printExpression(-1, 1,-1);
	else if(result(-1,-1, 1)	== 7) printExpression(-1,-1, 1);
	else if(result(-1,-1,-1)	== 7) printExpression(-1,-1,-1);
	
	return 0;

}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, D) = readLine()!!.split(" ").map { it.toInt() }
    val Xi: MutableList<List<Int>> = java.util.ArrayList()

    val values = (0..150).map { it * it }

    for (i in 1..N) {
        val line = readLine()!!.split(" ").map { it.toInt() }
        Xi.add(line)
    }

    var cnt = 0

    for (ai in 0 until N) {
        for (je in ai + 1 until N) {
            if (dist2(Xi[ai], Xi[je]) in values) cnt++
        }
    }
    println(cnt)
}

fun dist2(a: List<Int>, b: List<Int>): Int {
    var sum = 0
    for (i in 0 until a.size) {
        sum += (a[i] - b[i]) * (a[i] - b[i])
    }
    return sum
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> ans(n + 1, 0);
  int res = 0;
  for (int x = 1; x * x <= n; x++) {
    for (int y = 1; y * y <= n; y++) {
      for (int z = 1; z * z <= n; z++) {
        int v = x * x + y * y + z * z + x * y + y * z + z * x;
        if (v > n) continue;
        ans[v]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

int a,b,c;

int main(){
    cin>>a>>b>>c;
    out(min(min(a+b,c+a),c+b));
    
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif
#define found(m,x) ((m).find(x)!=(m).end())
#define uset unordered_set
#define umap unordered_map
#define a(x) x.begin(),x.end()
#define fo(i,n) for(int i=0;i<(int)n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<=(int)n:i>=(int)n;k<n?i++:i--)
#define input(v,n) fo(i,n)cin>>v[i]
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pi;

const int nax = 1e5+7;
const int mod = 1e9+7; //1e9+2667
const int inf = numeric_limits<int> :: max();
// ===================== MANASH =================== //


void test() {
    int k,n;
    cin >> k >> n;
    vector<int> v(2*n);
    fo(i,n) cin >> v[i], v[i+n] = k + v[i];
    int s = 0;
    for( int i = 1; i < n; i++) {
        s += v[i] - v[i-1];
    }
    int min_sum = s;
    for( int i = n; i < (int) v.size(); ++i) {
        int j = i - n + 1;
        s += v[i] - v[i-1];
        s -= v[j] - v[j-1];
        min_sum = min(min_sum,s);
    }
    
    cout << min_sum;
}

signed main() {

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

    #ifdef LOCAL
    freopen("input.txt","r",stdin);
    cout<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec.\n";
    #endif

    int T = 1;
    //cin >> T;
    while(T--) {
        test();
        cout << "\n";
    }
    return 0;

}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vector<int>h(n);
	for(int i=0; i<n; i++) {
		cin>>h[i];
	}
	long long ans=0,tmp=0;
	for(int i=0; i<n-1; i++) {
		if(h[i]>=h[i+1]) {
			tmp++;
		} else {
			tmp=0;
		}
		if(ans<tmp) ans=tmp;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int isprime(int n) {
 for(int i = 2; i * i <= n; i++) {
	 if(n % i == 0) return 0;
 }
 return 1;
}

int main(){
	int n,i,min,max;
	int number[1000000+2] = {0};
	for(i = 2;i < 1000000;i++){
		number[i] = isprime(i);
	}
	while(scanf("%d",&n)){
		if(n == 0)break;
		max = 0; min = 0;
		for(i = n;i > 0;i--){
			//printf("%d  ",i);
			if(number[i] && number[i-2]){
				min = i-2;
				max = i;
				//printf("%d %d\n",i,i-2);
				break;
			}
		}
		printf("%d %d\n",min,max);
	}
	return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second


int main(){
    string s;
    cin >> s;
    s += " ";
    
    vector<ll> vec;
    rep(i,0,s.size()-1){
        if(s[i] == 'A') vec.push_back(2);
        else if(s[i] == 'B' && s[i+1] == 'C'){
            vec.push_back(1);
            i++;
        }
        else{
            vec.push_back(0);
        }
    }

    ll cnt = 0,ans = 0;
    rep(k,0,vec.size()){
        ll i = vec.size()-k-1;
        if(vec[i] == 1) cnt++;
        else if(vec[i] == 2) ans += cnt;
        else cnt = 0;
    }

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


Measured memory_bytes: 5512
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int N,i,a,j,s,t,u;
	cin >> N;
	for (i = 0; i < N; i++) {
		s = 0;
		t = 0;
		u = 0;
		for (j = 0; j < 10; j++) {
			cin >> a;
			if (a > s) {
				s = a;
			}
			else if (a<s&&a>t) {
				t = a;
			}
			else if (a < s&&a < t) {
				u = 1;
			}
		}
		if (u == 0) {
			cout << "YES" << endl;
		}
		else if (u == 1) {
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2948
#include <bits/stdc++.h>
#define maxn 1000010
#define modn 1000003
int fac[maxn],q,x,y,d,n,k,i,ans;
int power(int x,int y)
{
	int s=1,i=x;
	for (;y;y>>=1)
	{
		if (y&1) s=1LL*s*i%modn;
		i=1LL*i*i%modn;
	}
	return s;
}
int main()
{
	fac[0]=1;
	for (i=1;i<modn;i++)
		fac[i]=1LL*fac[i-1]*i%modn;
	scanf("%d",&q);
	for (;q;q--)
	{
		scanf("%d%d%d",&x,&d,&n);
		if (d==0) printf("%d\n",power(x,n));
			else
			{
				x=1LL*x*power(d,modn-2)%modn;
				ans=power(d,n);
				if ((x+n>modn) || (x==0)) ans=0;
					else ans=1LL*ans*fac[x+n-1]%modn*power(fac[x-1],modn-2)%modn;
				printf("%d\n",ans);
			}
	}
	return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    for(auto &i:s){
        i = 'x';
    }
    cout << s << endl;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    string s;
    cin >> s;

    if (s[0] == '9' || s[1] == '9')
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
from collections import deque


def bfs():
    d = [[float("inf")]*w for i in range(h)]
    que = deque([])
    que.append((0, 0))
    d[0][0] = 1

    while que:
        p = que.popleft()
        if p[0] == h - 1 and p[1] == w - 1:
            break

        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            if 0 <= nx < h and 0 <= ny < w and f[nx][ny] != "#" and d[nx][ny] == float("inf"):
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1

    return d[h-1][w-1]


dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]

h, w = map(int, input().split())
f = [list(input()) for i in range(h)]

white = 0
for i in range(h):
    for j in range(w):
        if f[i][j] == ".":
            white += 1

ans = bfs()
if ans != float("inf"):
    print(white - ans)
else:
    print(-1)


Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <cmath>
#include <map>
#include <string>

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;
#define pb push_back
#define mp make_pair
#define F first
#define S second

int main()
{
    string s;
    cin >> s;
    int n = s.length();

    vector<ll> goal(n);

    int from = 0;
    int g = 0;
    rep (i, n) {
        if (s[i] == 'L') {
            if (s[i - 1] == 'R') g = i;
            for (int j = from; j <= i; j++) {
                goal[j] = g;
            }
            from = i + 1;
        }
    }

    // rep (i, n) cout << goal[i] << "\n";

    vector<ll> ans(n);
    rep (i, n) {
        ans[i] = 0;
    }

    rep (i, n) {
        int to;
        int diff = i - goal[i];

        to = goal[i] - (abs(diff) % 2);

        // cout << "i: " << i << " / goal: " << goal[i] << " / to: " << to << "\n";

        ans[to]++;
    }

    rep (i, n) {
        if (i != 0) cout << " ";
        cout << ans[i];
    }
    cout << "\n";

    return 0;
}


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

#define repfrom(i, from, n) for (ll i = (from); i < (n); i++)
#define rep(i, n) repfrom(i, 0, n)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)

using namespace std;

using ll = long long;
using p  = pair<ll, ll>;
using uc = unsigned char;
constexpr ll INF = 1LL << 62;
constexpr ll MOD = 1e9 + 7;

ll dp[256][256][256];

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, K;
    cin >> N >> K;
    
    vector<ll> A(N);
    for (auto&& a : A) {
        cin >> a;
    }
    
    vector<ll> fact(N + 1, 1);
    reps(i, N) {
        fact[i] = (i * fact[i - 1]) % MOD;
    }
    
    dp[0][0][0] = 1;
    
    rep(i, N) rep(j, 256) rep(k, N) {
        dp[i + 1][j][k] += dp[i][j][k];
        dp[i + 1][j][k] %= MOD;
        dp[i + 1][j ^ A[i]][k + 1] += dp[i][j][k];
        dp[i + 1][j ^ A[i]][k + 1] %= MOD;
    }
    
    ll ans = 0;
    reps(i, N) {
        ans += (dp[N][K][i] * fact[i]);
        ans %= MOD;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 52992
#include <stdio.h>

int main() {
    
    int n, i, j, minj, temp;
    int A[100];
    int count = 0;
    
    scanf("%d", &n);
    for(i = 0; i < n; i++)
        scanf("%d", &A[i]);

    for(i = 0; i < n; i++){
        minj = i;
        for(j = i + 1; j < n; j++){
            if(A[j] < A[minj])
                minj = j;
        }
        if(minj != i){
            temp = A[i];
            A[i] = A[minj];
            A[minj] = temp;
            count++;
        }
    }
    
    for(i = 0; i < n; i++){
        printf("%d", A[i]);
        if(i != n - 1)
            printf(" ");
    }
    printf("\n%d\n", count);
}

Measured memory_bytes: 1848
function main(input){

    inputArray=input.split('\n');
    NK=inputArray[0].split(' ');
    N = parseInt(NK[0]);
    K = parseInt(NK[1]);
    out=0;
    sunukeArray=new Array(N-1);//all sunuke
    for(i=0;i<N;i++){
        sunukeArray[i]='0';
    }
    
    for(i=1;i<=2*K;i=i+2){
        kashiSnk=inputArray[i+1].split(' ');//sunuke have kashi
        for(j=0;j<parseInt(inputArray[i]);j++){
            sunukeArray[parseInt(kashiSnk[j])-1]='1';
        }
        kashiSnk.length=0;
    }

    for(i=0;i<N;i++){
        if(sunukeArray[i]=='0'){
            out++;
        }
    }
    console.log(out);
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29656