akhauriyash/Code-Regression huggingface dataset:
// AtCoder Beginner Contest 089 - Problem D: Practical Skill Test (https://atcoder.jp/contests/abc089/tasks/abc089_d)
#include <bits/stdc++.h>

using namespace std;
using ii = pair<int, int>;

const int MAX { 310 };

vector<ii> as(MAX*MAX);

vector<int> solve(int H, int W, int D, const vector<ii>& qs)
{
    vector<vector<int>> ps(D + 1);

    for (int x = 1; x <= D; ++x)
    {
        ps[x].push_back(0);
//cout << "-- x = " << x << " (" << as[x].first << ", " << as[x].second << ")" << endl;
        for (int y = x + D; y <= H*W; y += D)  
        {
            int dist = abs(as[y - D].first - as[y].first) + abs(as[y - D].second - as[y].second);
            ps[x].push_back(dist + ps[x].back());
//cout << "y = " << y << " (" << as[y].first << ", " << as[y].second << "), d = " << dist << ", ps = " << ps[x].back() << endl;
        }
    }

    vector<int> ans;

    for (auto q : qs)
    {
        auto L = q.first, R = q.second;

        auto r = (L % D) == 0 ? D : L % D;
        auto a = (L - r) / D, b = (R - r) / D;
        auto sum = ps[r][b] - ps[r][a];
        ans.push_back(sum);
//cout << "L = " << L << ", R = " << R << ", r = " << r << ", a = " << a << ", b = " << b << endl;
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int H, W, D;
    cin >> H >> W >> D;    

    for (int i = 1; i <= H; ++i)
        for (int j = 1; j <= W; ++j)
        {
            int a;
            cin >> a;

            as[a] = ii(i, j);
        }

    int Q;
    cin >> Q;

    vector<ii> qs(Q);

    for (int i = 0; i < Q; ++i)
        cin >> qs[i].first >> qs[i].second;

    auto ans = solve(H, W, D, qs);

    for (auto x : ans)
        cout << x << endl;

    return 0;
}


Measured memory_bytes: 7424
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            String s = in.next();
            int a = s.charAt(0);
            char ans = (char) ++a;
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
#define vecout(V) for(int i=0;i<V.size();i++) {cout<<V[i]<<endl;}


int main(void){
    int n, k;
    cin>>n>>k;
    vector<int> v(n);
    rep(i, n) cin>>v[i];
    if(n==1) {
        cout<<0<<endl;
        return 0;
    }
    int right=k;
    int ans=1;
    while(right<n){
        right+=k-1;
        ans++;
    }
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 640
/*
 _ _ _   _    _   _    _   _ _ _   _    _   _ __ _   __       __
|  _ _| | |  | | | |  | | |  _  | | |  | | |  __  | |   \   /   |
| |_ _  | |__| | | |  | | | |_| | | |__| | | |__| | | |\ \_/ /| |
|_ _  | |  __  | | |  | | |  _ <  |  __  | |  __  | | | \   / | |
 _ _| | | |  | | | |__| | | |_| | | |  | | | |  | | | |  \_/  | |  _   _   _
|_ _ _| |_|  |_| |_ __ _| |_ _ _| |_|  |_| |_|  |_| |_|       |_| |_| |_| |_|

*/

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

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
const int  MOD=1000000007;
const int N=100010;

ll powMod(ll x,long n){
    ll res=1;
    while(n){
        if(n&1)
            res=(res*x)%MOD;
        x=(x*x)%MOD;
        n/=2;
    }
    return res;
}

void solve(){
    ll ans=0;
    int n;
    cin>>n;
    vector<long> ZERO(64,0),ONE(64,0);

    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        for(int j=0;j<64;j++){
            if(x>>j & 1) ONE[j]++;
            else ZERO[j]++;
        }
    }

    for(int i=0;i<64;i++){
        ans=(ans+((ONE[i]*ZERO[i])%MOD*powMod(2LL,i)%MOD))%MOD;
    }

    cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t = 1;
    // cin>>t;
    for (long int tt = 1; tt <= t; tt++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;


int fast_expo(int b, int pow){
  int ans = 1;
  while(pow > 0) {
    if(pow % 2 == 1) {
      ans = ans*b%mod;
    }
    b = b*b%mod;
    pow /= 2;
  }
  return ans;
}

int comb(int n, int a) {
  int f1 = 1, f2 = 1, f3 = 1;
  for(int i = n-a+1; i <=n; i++) {
    f1 = f1*i%mod;
  }
  for(int i =1; i <= a;i++) {
    f2 = f2*i % mod;
  }
  int ans = f1 * fast_expo(f2, mod-2) % mod;
  return ans;
}


signed main() {
  int n,a, b; cin >> n >> a >> b;
  // /2*n - c(n,a) - c(n,b)
  if(n == 2){ cout << 0 << endl;return 0;}
  int ans = fast_expo(2, n);
  ans -= comb(n, a);
  if(ans <= 0) ans += mod;
  ans -= comb(n,b);

  if(ans <= 0) ans += mod;
  ans -= 1;
  if(ans <= 0) ans += mod;
  cout << ans;
}


Measured memory_bytes: 256
n = int(input())
list = []
for i in range(n):
    a = input()
    list.append(a)
def is_unique(seq):
    return len(seq) == len(set(seq))

if is_unique(list) == False:
    print('No')

else:
    s = 0
    for k in range(n-1):
        a = list[k]
        b = list[k + 1]
        if a[-1] == b[0]:
            s += 1
        else:
            print('No')
            break
    if (s+1) == n:
        print('Yes')
    else:
        pass


Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<cstring> 
#include<cstdlib>
#include<set>
#include<vector>
using namespace std;
#define ll long long
const int maxn = 2e5 + 5;
const int inf =9999999;

int main()
{     int t;
	cin>>t;
    char a[100];
    cin>>a;
    if(strlen(a)<=t)
    cout<<a<<endl;
    else{
    for(int i=0;i<t;i++)
    cout<<a[i];
    cout<<"..."<<endl;
}
    
	
}
	 
		
	  	
	  
	  


Measured memory_bytes: 3092
n=int(input())
c=[[] for i in range(n+1)]
d={}
for i in range(n-1):
    x,y,z=map(int,input().split())
    c[x].append(y)
    c[y].append(x)
    d[x,y]=z
d[1,1]=0
stack=[1]
parent=[None]*(n+1)
while stack:
    i=stack.pop()
    for j in c[i]:
        if j==parent[i]:
            continue
        parent[j]=i
        d[1,j]=d[1,i]+d[tuple(sorted([i,j]))]
        stack.append(j)
for i in range(1,n+1):
    print(d[1,i]%2)

Measured memory_bytes: 57692
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define ll long long
#define int long long

using namespace std;

const int maxn = 3010;
const int mod = 1e9+7;

int qsm(int i,int j)
{
	int ans=1;
	while (j)
	{
		if (j&1) ans=ans*i%mod;
		j>>=1;
	    i=i*i%mod;
	}
	return ans;
}

int dp[maxn][maxn];
int n,m;
int q;
int a[maxn];

signed main()
{
   scanf("%lld%lld",&n,&m);
   for (int i=1;i<=n;i++) scanf("%lld",&a[i]);//a[i]=read();
   for (int i=1;i<=n;i++)
     for (int j=1;j<=n;j++)
       dp[i][j]=(a[i]>a[j]);
   int inv = qsm(2,mod-2);
   for (int i=1;i<=m;i++)
   {
   	  int x,y;
   	  scanf("%lld%lld",&x,&y);
   	  dp[x][y]=dp[y][x]=(dp[x][y]+dp[y][x])*inv%mod;
   	  for (int i=1;i<=n;i++)
   	  {
   	  	if (i!=x && i!=y)
   	  	{
   	  		dp[x][i]=dp[y][i]=(dp[x][i]+dp[y][i])*inv%mod;
   	  		dp[i][x]=dp[i][y]=(dp[i][x]+dp[i][y])*inv%mod;
		}
	  }
   }
   int ans=0;
   for (int i=1;i<=n;i++)
     for (int j=i+1;j<=n;j++)
        ans=(ans+dp[i][j])%mod;
   cout<<ans*qsm(2,m)%mod;
   return 0;
}


Measured memory_bytes: 70784
#include<stdio.h>

void sosa(int);
int d[101],f[101],A[101][101],n;

int main(){
  int m,t,l,i,j;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&t,&m);
    for(j=1;j<=m;j++){
      scanf("%d",&A[t][j]);
    }
  }
  sosa(1);
  for(i=1;i<=n;i++){
    printf("%d %d %d",i,d[i],f[i]);
    printf("\n");
  }
  return 0;
}

void sosa(int a){
  static int b=1;
  int i=1;
  d[a]=b;
  b++;
  while(A[a][i]!=NULL){
    if(d[A[a][i]]==NULL){
      sosa(A[a][i]);
      b++;
     }
    i++;
  }
  f[a]=b;
  if(a==1 && n*2 !=b){
    b++;
    for(i=1;i<=n;i++){
      if(d[i]==NULL){
	sosa(i);
	b++;
      }
    }
  }
}




Measured memory_bytes: 2036
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>
#include <string>
#include <bits/stdc++.h>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;

static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;
using pint = pair<int,int>;


//D
//V1,V2
int main(){

    int N,K;
    cin >> N >> K;
    vector <ll> V(N);

    REP(i,N)
    {
        cin >> V[i];
    }
    ll res = 0;

    //操作A,Bについて全探索
    for(int p = 0; p <= min(K,N); ++p)
    {
        for(int q = 0; p + q <= min(K,N); ++q)
        {
            vector <ll> tmp_v;
            ll cur = 0;
            REP(i,p)
            {
                tmp_v.push_back(V[i]);
                cur += V[i];
            }
            REP(i,q)
            {
                tmp_v.push_back(V[N - (i+1)]);
                cur += V[N-(i+1)];
            }

            sort(tmp_v.begin(), tmp_v.end());

            //負の価値を捨てる
            for(int i = 0; i < min(K-p-q, (int)tmp_v.size()); ++i)
            {
                if(tmp_v[i] < 0)cur -= tmp_v[i];
            }
            res = max(res, cur);
        }
    }

    cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int i,s[10];
	for(i=0;i<10;i++){
		scanf("%d",&s[i]);
	}
	int sum=0;
	for(i=0;i<10;i++){
		sum=sum+s[i];
	}
	printf("%d\n",sum);
	return 0;
}



Measured memory_bytes: 2140
n = int(input())
ab = 0
a = 0
b = 0
ba = 0
for i in range(n):
    s = input()
    ab = ab + s.count('AB')
    start_b = s[:1] == 'B'
    end_a = s[-1:] == 'A'
    if start_b:
        b = b + 1
    if end_a:
        a = a + 1
    if start_b and end_a:
        ba = ba + 1

b = b - ba
a = a - ba

ans = ab #ABが普通に含まれた数
if ba > 0:
    ba_joind = ba - 1 #B*Aを連結して生じるAB
    if b > 0:
        b = b - 1
        ba_joind = ba_joind + 1
    if a > 0:
        a = a - 1
        ba_joind = ba_joind + 1
    ans = ans + ba_joind
if b > 0 and a > 0:
    ans = ans + min(a, b)
print(ans)

Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int kinds = sc.nextInt();
		int like[] = new int[kinds];
		for(int i = 0; i < kinds; i ++) {
			like[i] = 0;
		}
		for(int i = 0; i < num; i ++) {
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j ++) {
				like[sc.nextInt() - 1] ++;
			}
		}
		int count = 0;
		for(int i = 0; i < kinds; i ++) {
			if(like[i] == num) {
				count ++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 22100
#include <iostream>
#include <unordered_set>
#include <vector>
#include <queue>

using namespace std;

int main() {

    int V, E;
    cin >> V >> E;

    unordered_set<int> indeg[V], outdeg[V];
    vector<int> count;

    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        indeg[t].insert(s);
        outdeg[s].insert(t);
    }

    //
    queue<int> que;

    for (int i = 0; i < V; i++) {
        if (outdeg[i].empty()) {
            que.push(i);
        }
    }

    while (!que.empty()) {
        int u = que.front();
        que.pop();
        for (int v: indeg[u]) {
            outdeg[v].erase(u);
            if (outdeg[v].empty()) {
                que.push(v);
            }
        }
        count.push_back(u);
    }

    if (count.size() == V) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>

using namespace std;

int main(){

    string s;cin>>s;

//    string S="";
//    REP(i,s.size())if(s[i]!='x')S+=s[i];
//    int N = S.size();
//    REP(i,N/2){
//        if(S[i]!=S[N/2-1-i]){
//            cout<<-1<<endl;
//            return 0;
//        }
//    }
    int cnt=0;
    int front=0;
    int n=s.size();
    int back=n-1;

    while(front<back){
        if(s[front]==s[back]){
            ++front;
            --back;
            continue;
        }
        if(s[front]=='x'){
            ++cnt;
            ++front;
        }else if(s[back]=='x'){
            ++cnt;
            --back;
        }else{
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<cnt<<endl;


    return 0;
}

Measured memory_bytes: 512
fn main() {
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];
    println!("{}", (a + b) % 24);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

typedef long long ll;

void solve() {
    string s;
    cin >> s;
    int a = -1, b = -1;
    if (s[0] == s[1]) {
        a = 1;
        b = 2;
    }
    rep(i, s.size() - 2) {
        if (s[i + 1] == s[i + 2]) {
            a = i + 2;
            b = i + 3;
        }
        if (s[i] == s[i + 2]) {
            a = i + 1;
            b = i + 3;
        } 
    }
    cout << a << " " << b << endl;
    return;
}

int main() {
    solve();
}


Measured memory_bytes: 512
import collections


dq=collections.deque()
n=input()
dis=[100000]*100005
# print(dis[100])
dis[1]=1
dq.append(1)

while len(dq):
    a=dq[0]
    dq.popleft()
    if a==0:
        break
    b=(a*10)%n
    c=(a+1)%n
    if dis[b]> dis[a]:
        dis[b]=dis[a]
        dq.appendleft(b)
    if dis[c]>dis[a]+1:
        dis[c]=dis[a]+1
        dq.append(c)

print (dis[0])

Measured memory_bytes: 5112
#include<bits/stdc++.h>
#define MAXN 100000


using namespace std;
typedef long long ll;
int main()
{
	//freopen("t.txt","r",stdin);
	int a,b;
	cin>>a>>b;
	if (a>=6&&a<=12) {
		cout<<b/2; return 0;
	}
	if (a<=5) {
		cout<<0; return 0;
	}
	cout<<b;
}

Measured memory_bytes: 256
//g++  5.4.0

#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
    cin>>a;
    cin>>b;
     if(a<1||a>9||b<1||b>9)
         cout<<-1;
     else
         cout<<a*b;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	const double p = 3.1415926535898;
	double r, s, c;
	cin >> r;
	s = p*r*r;
	c = 2*p*r;
	cout << fixed << setprecision(6) << s << " " << c << endl; 
	return 0;
} 


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

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += min(2*abs(x[i]-0),2*abs(x[i]-k));
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	string s,t;
	cin>>s>>t;
	for(int i=0;i<s.length();i++)if(s[i]!=t[i]){
		cout<<"No\n";
		return 0;
	}
	cout<<"Yes\n";
	
	return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
 
using namespace std;
 
#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
const int N = 1e5 + 10;
int main()
{
    fast_cin();
    int a,b;
	cin>>a>>b;
    int arr[4]={0};
    arr[a]=a;arr[b]=b;
  for(int i=1;i<4;i++) {
    	if(arr[i]==0) {
          cout<<i;
        }
  }

} 

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

using namespace std;

char s[10];

int N;

int main() {
	int mn = 2e9;

	scanf("%d", &N);

	for (int A = 1; A < N; ++A) {
		int B = N - A;

		int sm = 0;

		int len = sprintf(s, "%d", A);
		for (int i = 0; i < len; ++i) sm += s[i] - '0';
		len = sprintf(s, "%d", B);
		for (int i = 0; i < len; ++i) sm += s[i] - '0';

		mn = min(mn, sm);
	}

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

Measured memory_bytes: 256
#!/usr/bin/perl
use POSIX qw(floor);

my ($n,$k) = map { $_ - 0 } split(/\s+/,<STDIN>);

my @d = ();
$#d = $n - 1;

for(my $i=0;$i<$k;$i++){
  my ($dd) = map { $_ - 0 } split(/\s+/,<STDIN>);
  my @aa = map { $_ - 0 } split(/\s+/,<STDIN>);
  for(my $j=0;$j<$dd;$j++){
    $d[$aa[$j]-1] ++;
  }
}

my $c = 0;
for(my $j=0;$j<$n;$j++){
  $c++ if $d[$j] - 0 == 0 ;
}
print "$c\n";



Measured memory_bytes: 6640
package main

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

func solve() {
	n := getInt()
	s := getString()

	ans := "No"
	if s[0:n/2] == s[n/2:n] {
		ans = "Yes"
	}
	fmt.Fprintln(wr, ans)
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
  int N; cin >> N;
  if (N % 1000 == 0) {
    cout << 0 << endl;
    return 0;
  }
  int t = N / 1000;
  int result = (t+1)*1000 - N;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3632
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = sum(a)
B = sum(b)
sa = []
num = B-A
flag = True
for i in range(N):
    sa.append(b[i]-a[i])
    if a[i] != b[i]:
        flag= False
if flag:
    print('Yes')
else:
    if num <= 0:
        print('No')
    else:
        cnt = 0
        for i in range(N):
            if sa[i] > 0:
                cnt += sa[i]-sa[i]//2
        if cnt <= num:
            print('Yes')
        else:
            print('No')

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

using namespace std;

int n;
typedef pair<int, int> P;
const int N = 1e5 + 10;
vector<P> G[N];
int dis[N];
bool vis[N];

void dijkstra() {
    memset(vis, false, sizeof(vis));
    for (int i = 0; i < n; i++) dis[i] = INT_MAX;
    priority_queue<P, vector<P>, greater<P>> heap;
    heap.push({0, 0});
    dis[0] = 0;

    while (!heap.empty()) {
        int u = heap.top().second, cost = heap.top().first;
        heap.pop();
        if (vis[u]) continue;
        vis[u] = true;
        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i].second, len = G[u][i].first;
            if (!vis[v] && dis[u] + len < dis[v]) {
                dis[v] = dis[u] + len;
                heap.push({dis[v], v});
            }
        }
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        int v, c;
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            G[u].push_back({c, v});
        }
    }

    dijkstra();

    for (int u = 0; u < n; u++) {
        cout << u << " " << dis[u] << endl;
    }

    return 0;
}


Measured memory_bytes: 10252
#include <bits/stdc++.h>
using namespace std;
#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 repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int n, m, q;
vector<ll> a, b, c, d;

ll score(vector<int> &A) {
  ll scr = 0;
  rep(i, q) if (A[b[i]] - A[a[i]] == c[i]) scr += d[i];
  return scr;
}

ll dfs(vector<int> &A) {
  if (A.size() == n) return score(A);
  ll ans = 0;
  int last = (A.empty() ? 0 : A.back());
  for (int v = last; v < m; ++v) {
    A.push_back(v);
    ans = max(ans, dfs(A));
    A.pop_back();
  }
  return ans;
}

int main() {
  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  rep(i, q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    --a[i];
    --b[i];
  }
  vector<int> A;
  cout << dfs(A) << endl;
  return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;
 
public class Main {
	static Scanner in = new Scanner(System.in);
	public static void main(String[] args){
		int n  = in.nextInt();
		int sum = 0;
		
		int i;
		for(i = 0; sum < n; i++){
			sum += i;
		}
		System.out.println(i - 1);
	}
}

Measured memory_bytes: 21972
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        String result = "No";
        if ((a*b) % 2 == 1) result = "Yes";
        System.out.println(result);
    }
}


Measured memory_bytes: 35572
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define xam INT_MIN
#define nim INT_MAX
#define mp make_pair

using namespace std;
///check n=1;
///check corner case;
int main()
{
    string a,b,c;
    cin>>a>>b;
    ll n,i,j,cc=0;
    cin>>i>>j;
    cin>>c;
    if(c==a){
        cout<<i-1<<spc<<j<<endl;
    }
    else cout<<i<<spc<<j-1<<endl;
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(y+r>H||y-r<0||x+r>W||x-r<0){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	
	return 0;
}


Measured memory_bytes: 2100
from collections import deque
class csr:
    def __init__(self,N,edges):
        self.start = [0]*(N+1)
        self.elist = [0]*len(edges)
        for e in edges:
            self.start[e[0]+1] += 1
        for i in range(1,N+1):
            self.start[i] += self.start[i-1] 
        counter = self.start[:]
        for e in edges:
            self.elist[counter[e[0]]] = e[1]
            counter[e[0]] += 1

class scc_graph:
    def __init__(self,N):
        self.N = N
        self.edges = []
    
    def add_edge(self,v,w):
        self.edges.append((v,w))

    def scc_ids(self):
        g = csr(self.N,self.edges)
        now_ord = group_num = 0
        visited = deque()
        low = [0]*self.N
        order = [-1]*self.N
        ids = [0]*self.N
        parent = [-1]*self.N
        for i in range(self.N):
            if order[i] == -1:
                stack = deque()
                stack.append(i)
                stack.append(i)
                while stack:
                    v = stack.pop()
                    if order[v] == -1:
                        low[v] = order[v] = now_ord
                        now_ord += 1
                        visited.append(v)
                        for i in range(g.start[v],g.start[v+1]):
                            to = g.elist[i]
                            if order[to] == -1:
                                stack.append(to)
                                stack.append(to)
                                parent[to] = v
                            else:
                                low[v] = min(low[v],order[to])
                    else:
                        if low[v] == order[v]:
                            while True:
                                u = visited.pop()
                                order[u] = self.N
                                ids[u] = group_num
                                if u == v:
                                    break
                            group_num += 1
                        if parent[v] != -1:
                            low[parent[v]] = min(low[parent[v]],low[v])
        for i,x in enumerate(ids):
            ids[i] = group_num-1-x

        return group_num,ids
    
    def scc(self):
        group_num,ids = self.scc_ids()
        groups = [[] for _ in range(group_num)]
        for i,x in enumerate(ids):
            groups[x].append(i)
        return groups
    
import sys
input = sys.stdin.buffer.readline
N,M = map(int,input().split())
sg = scc_graph(N)
for i in range(M):
    a,b = map(int,input().split())
    sg.add_edge(a,b)

scc = sg.scc()
print(len(scc))
for group in scc:
    print(str(len(group))+' '+' '.join(map(str,group)))

Measured memory_bytes: 198696
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

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

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

int N;
map<string, int> id;
bool adjacent[41][41];
int weight[41], wes[41];
int ans;

void dfs(ll S, int wsum, int curr) {

  ans = max(ans, wsum);

  if(wsum + wes[N-1] - (curr ? wes[curr-1] : 0) <= ans) return;

  if(curr == N-1) return;

  const int next = curr + 1;

  dfs(S, wsum, next);

  bool ok = 1;
  rep(k, next) if(adjacent[next][k] && (S >> k & 1)) { ok = 0; break; }

  if (ok) {
    dfs(S|(1LL<<next), wsum + weight[next], next);
  }
}

int main() {

  while(cin >> N && N) {
    rep(i, 41) weight[i] = 0;
    rep(i, 41) rep(j, 41) adjacent[i][j] = 0;
    id.clear();
    int v = 0;

    rep(i, N) {
      string s; cin >> s;
      if(id.find(s) == id.end()) id[s] = v++;
      cin >> weight[id[s]];
      int n; cin >> n;
      rep(_, n) {
        string t; cin >> t;
        if(id.find(t) == id.end()) id[t] = v++;
        adjacent[id[s]][id[t]] = 1;
      }
    }

    rep(i, N) wes[i] = weight[i] + (i ? wes[i-1] : 0);

    ans = 0;
    dfs(1LL<<0, weight[0], 0);

    cout << ans << endl;

  }
  
  return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    string s;
    int q;
    cin>>s>>q;

    vi que_t(q),que_f(q);
    vc<char> s1,s2,que_c(q);
    rep(i,q){
        cin>>que_t[i];
        if(que_t[i]==2){
            cin>>que_f[i]>>que_c[i];
        }
    }
    int rev=1;
    rep(i,q){
        if(que_t[i]==1)rev=!rev;
        else{
            if(que_f[i]-1==rev)s1.push_back(que_c[i]);
            else s2.push_back(que_c[i]);
        }
    }

    if(rev){
        rrep(i,s2.size())cout<<s2[i];
        cout<<s;
        rep(i,s1.size())cout<<s1[i];
        cout<<"\n";
    }else{
        reverse(all(s));
        rrep(i,s1.size())cout<<s1[i];
        cout<<s;
        rep(i,s2.size())cout<<s2[i];
        cout<<"\n";
    }

    return 0;
}

Measured memory_bytes: 2816
str10,str01 = '',''
for i in range(5 * (10**4) + 1):
    str10 += '10'
    str01 += '01'

s = str(input())
len_s = len(s)
str10 = str10[:len_s]
str01 = str01[:len_s]
#print(str10,str01)

cnt10,cnt01 = 0,0
for i in range(len_s):
    if s[i]!=str10[i]:
        cnt10 += 1
    if s[i]!=str01[i]:
        cnt01 += 1
print(min(cnt10,cnt01))

Measured memory_bytes: 9464
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true)cerr
void print(){cout<<endl;}
template<typename T,typename... Args>
void print(T a, Args... args) {cout<<a<<" ";print(args...);}
lli llipowerp(lli x, lli y, lli p=LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
inline void printvec(vector<T> inp){
    for(auto it:inp) cout<<it<<" ";
    cout << endl;
}
//---------------------------------------------------------------------------------
lli n,k;
vector<lli> a;

lli dp[110][100010], pref[110][100010];
lli get2(lli nr,lli kr);
lli get(lli nr,lli kr){
   // print("get", nr, kr);
    if(nr==0 || kr==0) return 1;
    if(dp[nr][kr]!=-1) return dp[nr][kr];

    if(nr==1){
        if(kr<=a[1])
            dp[nr][kr]=1;
        else{
            dp[nr][kr]=0;
        }
        return dp[nr][kr];
    }


    dp[nr][kr]=(get2(nr-1,kr)+mod-get2(nr-1,kr-a[nr]-1))%mod;
    return dp[nr][kr];


}
lli get2(lli nr, lli kr)
{
   // print("get2",nr,kr);
    if(kr<0) return 0;
    if (nr == 0 || kr == 0)
        return 1;
    if (pref[nr][kr] != -1)
        return pref[nr][kr];


    pref[nr][kr] = (get2(nr,kr-1)+get(nr,kr))%mod;
    return pref[nr][kr];
    
}

int main(){
    cin>>n>>k;
    lli x;
    memset(dp,-1,sizeof(dp));
    memset(pref, -1, sizeof(pref));
    a.resize(n+1);
    fori(n){
        
        cin>>a[i+1];

    }

    // printvec(a);
    // fori(n+1){
    //     forj(k+1){
    //         cout<<get(i,j)<<"   ";
    //     }
    //     cout<<endl;
    // }
    // fori(n + 1)
    // {
    //     forj(k + 1)
    //     {
    //         cout << get2(i, j) << "   ";
    //     }
    //     cout << endl;
    // }
    cout<<get(n,k)<<endl;
}

Measured memory_bytes: 176896
import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}

let MOD = 1_000_000_007

private func pow(_ b: Int, _ n: Int, _ p: Int) -> Int {
    var (b, n) = (b, n)
    var x = 1
    while n > 0 {
        if n % 2 == 1 {
            x = x * b % p
        }
        b = b * b % p
        n >>= 1
    }
    return x
}

func main() {
    // 考察過程
    // 対称性、偶奇性
    // A_iが0になるのは、nが奇数のとき。
    // nが奇数なら全てが偶数? 0は一つだけ。他は二つずつ。
    // nが偶数なら全てが奇数。二つずつ。
    // あとは重複あり順列? 人の位置はほぼ固定なので違った。
    // 二通り が n/2(小数点切り捨て)個分。
    // - 🐻 - - - 🐰 -
    // - 🐰 - - - 🐻 -
    // こんな感じ

    let n = Int(readLine()!)!
    let A = readWords { Int($0)! }
    var counter = [Int:Int]()
    for i in A {
        counter[i, default: 0] += 1
    }

    if n % 2 == 0 {
        for i in 1..<n where i % 2 == 1 {
            if let c = counter[i] {
                if c != 2 {
                    print(0)
                    return
                }
            } else {
                print(0)
                return
            }
        }
    } else {
        for i in 0..<n where i % 2 == 0 {
            if let c = counter[i] {
                if i == 0 && c != 1 || i != 0 && c != 2 {
                    print(0)
                    return
                }
            } else {
                print(0)
                return
            }
        }
    }

    
    print(pow(2, n/2, MOD))
}


main()

Measured memory_bytes: 18416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    ll p[n * n]; zep(i, 0, n * n){cin >> p[i]; p[i]--;}

    ll cnt[n][n];
    zep(i, 0, n)zep(j, 0, n)cnt[i][j] = min(min(i, n - 1 - i), min(j, n - 1 - j));

    ll ans = 0;
    bool out[n][n]; memset(out, 0, sizeof(out));
    zep(i, 0, n * n){
        ll x = p[i] / n, y = p[i] % n;
        out[x][y] = true;

        ans += cnt[x][y];

        queue<vector<ll>> q;
        q.push({x, y, cnt[x][y]});

        while(!q.empty()){
            auto v = q.front(); q.pop();
            if(!out[v[0]][v[1]])v[2]++;

            if(v[0] != 0 && cnt[v[0] - 1][v[1]] > v[2]){
                cnt[v[0] - 1][v[1]] = v[2];
                q.push({v[0] - 1, v[1], v[2]});
            }
            if(v[0] != n - 1 && cnt[v[0] + 1][v[1]] > v[2]){
                q.push({v[0] + 1, v[1], v[2]});
                cnt[v[0] + 1][v[1]] = v[2];
            }
            if(v[1] != 0 && cnt[v[0]][v[1] - 1] > v[2]){
                q.push({v[0], v[1] - 1, v[2]});
                cnt[v[0]][v[1] - 1] = v[2];
            }
            if(v[1] != n - 1 && cnt[v[0]][v[1] + 1] > v[2]){
                q.push({v[0], v[1] + 1, v[2]});
                cnt[v[0]][v[1] + 1] = v[2];
            }
        }
    }
    print(ans)

    return 0;
}

Measured memory_bytes: 7780
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int n, tmp = 1;
double ans;
int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

int main() {

    cin >> n;
    REP(i, 1, n + 1) {
        cin >> x[i] >> y[i];
    }

    vector<int> v(n);
    for (int i = 0; i < n; i++) v[i] = i + 1;

    do {
        
        rep(i, n - 1) {
            ans += dist(v[i], v[i + 1]);
        }

    } while (next_permutation(v.begin(), v.end()));

    REP(i, 2, n + 1) tmp *= i;

    ans /= tmp;

    cout << fixed << setprecision(10) << ans << endl;

	return 0;
}

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

int main(){
   int A,B,C,D;
   cin >> A >> B >> C >> D;
   if((A + B) > (C + D)){
     cout << "Left" << endl;
   }else if((A + B) == (C + D)){
     cout << "Balanced" << endl;
   }else{
     cout << "Right" << endl;
   }
   return 0;
}

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

int main(){
    int n;
    while(cin >> n, n){
        string res = "";
        while(n != 0){
            int x = n%10;
            if(x < 0)   x += 10;            
            res = (char)('0'+x) + res;
            if(n < 0 && n%10 != 0)  while(n%10 != 0)    n--;
            n /= -10;
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
n = int(input())
s = list(input())

fi = [False]*10
se = [False]*100
th = [False]*1000

for e in s:
    num = int(e)
    for i in range(100):
        if se[i]:
            th[i*10+num] = True
    for i in range(10):
        if fi[i]:
            se[i*10+num] = True
    fi[num] = True

res = 0
for e in th:
    if e:
        res += 1
print(res)

Measured memory_bytes: 43756
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define ll long long 
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//typedef long long  MOD=1000000009;
ll MOD=998244353;
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll lcm(ll x, ll y) {ll res = (x * y) / __gcd(x, y); return res;}
ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}

void iofoj(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}


void solution()
{
    ll k,i,j,n,m,w;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=a*c;
    ans=max(ans,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout<<ans;
}

int main(){
    fio
    //iofoj();
    // ll t;
    // cin>>t;
    // while(t--)
    solution();
    return 0; 
}



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

int main(void) {
	int k, a, b;

	cin >> k >> a >> b;
 
	int largest = (b / k) * k;
	if (a <= largest) {
		cout << "OK" << endl;
	} else {
		cout << "NG" << endl;
	}

	return 0;
}


Measured memory_bytes: 3600
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int[] a = new int[n];
		int[] k = new int[n];
		for ( int i=0; i<n; i++ ) {
			a[i] = sc.nextInt() - 1;
			k[a[i]]++;
		}

		long c = 0;
		for ( int i=0; i<n; i++ ) {
			c = c + (long)k[i]*((long)k[i]-1l)/2l;
		}
		for ( int i=0; i<n; i++ ) {
			long c0 = (long)k[a[i]]*((long)k[a[i]]-1l)/2l;
			long c1 = 0;
			if ( k[a[i]]!=0) {
				c1 = ((long)k[a[i]]-1l)*((long)k[a[i]]-2l)/2l;
			}

			System.out.println(c-c0+c1);
		}

	}
}

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

int main() {
  int a, b, c; cin >> a >> b >> c;
  if(a==b && b==c)cout << 1;
  else if(a==b && b!=c) cout << 2;
  else if(b==c && c!=a) cout << 2;
  else if(c==a && a!=b) cout << 2;
  else cout << 3;
}

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

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl
#define prseq(var, n)    rep(i,n){cout << var[i] << " ";} cout << endl
#define prseql(var, n)   rep(i,n){cout << var[i] << " " << endl;}

//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arrll(h,n);

  int ans=0, tmp=0;
  rep(i,n-1){
    if(h[i+1]<=h[i]){
      tmp++;
    } else {
      tmp = 0;
    }
    ans = max(tmp, ans);
  }

  prt(ans);

}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define MAX_C 1000000001

int main() {
  int n;
  cin >> n;
  vector<pii> cities(n);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    cities[i] = pii(a,b);
  }

  sort(cities.begin(), cities.end());

  double dist = 0;
  int c = 0;

  do {
    double tmp = 0;
    for (int i = 0; i < n-1; i++) {
      tmp += sqrt((cities[i+1].first - cities[i].first) * (cities[i+1].first - cities[i].first) + (cities[i+1].second - cities[i].second) * (cities[i+1].second - cities[i].second));
    }
    dist += tmp;
    c++;
  } while (next_permutation(cities.begin(), cities.end()));

  //cout << dist / c << endl;
  printf("%lf", dist/c);
}


Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]
import collections
c = collections.Counter(s)
d = c.most_common()
# print(d)
e = [d[0][0]]
for i in range(len(d)-1):
    if d[i][1] == d[i+1][1]:
        e.append(d[i+1][0])
    else:
        break
# print(e)
f = sorted(e)
# print(f)
[print(i) for i in f]

Measured memory_bytes: 50260
// https://atcoder.jp/contests/abc052/tasks/arc067_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
const int MOD = 1e9 + 7;

// constexprな素数列挙(エラトステネスの篩)
template <int N> struct Prime {
    bool b[N + 1]; // trueなら素数
    constexpr Prime() : b() {
        for (int_fast64_t i = 0; i <= N; ++i)
            b[i] = true;
        b[0] = b[1] = false;
        for (int_fast64_t i = 2; i <= N; ++i) {
            for (int_fast64_t j = i * i; j <= N; j += i)
                b[j] = false;
        }
    }
};

const int SZ = 1e3;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    constexpr auto prime = Prime<SZ>();
    ll ans = 1;
    FOR(i, 2, n + 1) {
        // 素数の場合
        if (prime.b[i]) {
            // n!の中で素因数iは何乗か？
            ll tot = 0;
            for (int j = i; j <= n; j *= i) { // 2,4,8...
                tot += n / j;                 // 12/2 + 12/4 + 12/8
            }
            //約数の個数*(tot+1)%modで更新
            ans = (ans * (tot + 1)) % MOD;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;

bool isprime(int x){
    int y=x;
    for(int i=2;i<=sqrt(x);i++){
        while(y%i==0)y/=i;
    }
    if(y==x)return true;
    return false;
}

signed main(){
    int N;cin>>N;
    int count=0;
    for(int i=6;count<N;i+=5){
        if(isprime(i)){
            cout<<i<<" ";
            count++;
        }
    }
}

Measured memory_bytes: 256
from math import ceil
dp = [1] + [0 for i in range(33)]
for i in range(0,30):
	for step in [1,2,3]:
		dp[i+step] += dp[i]
unit = 3650.
while 1:
	n = int(raw_input())
	if n == 0:
		break
	print int(ceil(dp[n] / unit))

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
using namespace std;
int a,b,c,i,j,dir,n;
struct type{
	type *n1,*n0;
	int x;
}*end1,*end0;
int main(){
	cin>>n;
	cin>>a;
    dir=1;
    end1=new(type);
    end0=end1;
    end1->x=a;
    for(i=2;i<=n;i++){
    	dir=!dir;
    	cin>>a;
    	if(dir){
    		end1->n1=new(type);
    		end1->n1->n0=end1;
    		end1->n1->x=a;
    		end1=end1->n1;
    	}else{
    		end0->n0=new(type);
    		end0->n0->n1=end0;
    		end0->n0->x=a;
    		end0=end0->n0;
    	}
    }
    type *k;
    if(dir){
    	k=end1;
    	while(k!=end0){
    		cout<<k->x<<' ';
    		k=k->n0;
    	}
    	cout<<k->x<<endl;
    }else{
    	k=end0;
    	while(k!=end1){
    		cout<<k->x<<' ';
    		k=k->n1;
    	}
    	cout<<k->x<<endl;
    }
}


Measured memory_bytes: 8448
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]

from itertools import combinations_with_replacement as com
ans = 0
for A in com(range(1, M+1), N):
    score = 0
    for a, b, c, d in abcd:
        if A[b-1] - A[a-1] == c:
            score += d
    if ans < score:
        ans = score
print(ans)

Measured memory_bytes: 67724