akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int nax = 50+10;
const ll M = 1e4;
vector<tuple<int,ll,ll>> node[nax];
ll dist[nax][M+10];

ll rate[nax], rtime[nax];

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, m, s;
  cin >> n >> m >> s;
  priority_queue<tuple<ll,ll,ll>> pq;
  pq.emplace(0, 0, min((ll)s, M));

  for (int i = 0; i < m; i++) {
    int a, b, cost, time;
    cin >> a >> b >> cost >> time;
    a--, b--;
    node[a].emplace_back(b, cost, time);
    node[b].emplace_back(a, cost, time);
  }
  for (int i = 0; i < n; i++) {
    cin >> rate[i] >> rtime[i];
  }

  fill_n((ll*)dist, nax*(M+10), 1e18);

  while (pq.size()) {
    auto [d, p, c] = pq.top();
    pq.pop();
    d *= -1;
    if (d > dist[p][c]) continue;
    for (auto [i, cost, time] : node[p]) {
      ll nd = d+time;
      ll nc = c-cost;
      if (nc >= 0 && nd < dist[i][nc]) {
	dist[i][nc] = nd;
	pq.emplace(-nd, i, nc);
      }
    }
    {
      ll nd = d+rtime[p];
      ll nc = min(M, c+rate[p]);
      if (nd < dist[p][nc]) {
	dist[p][nc] = nd;
	pq.emplace(-nd, p, nc);
      }
    }
  }

  for (int i = 1; i < n; i++) {
    ll ans = 1e18;
    for (int c = 0; c <= M; c++)
      ans = min(ans, dist[i][c]);
    cout << ans << '\n';
  }

}


Measured memory_bytes: 20180
#include <iostream>
#define _USE_MATH_DEFINES
#include <cmath> 
#include <cstdio>
using namespace std;

int main(void) {
    int A,B,H,M;cin>>A>>B>>H>>M;
    double minute_angle = M / 60.0;
    double hour_angle = (H + (M / 60.0)) / 12.0;
    double cs = (minute_angle < hour_angle) ? cos(2 * M_PI * (hour_angle - minute_angle)) : cos(2 * M_PI * (minute_angle - hour_angle));
    double result = sqrt(pow(A,2) + pow(B,2) - 2 * A * B * cs);
    printf("%.10f\n", result);
    return 0;
}

Measured memory_bytes: 3544
import heapq
X,Y,Z,K = map(int,input().split())
A = sorted(list(map(int,input().split())),reverse=1)
B = sorted(list(map(int,input().split())),reverse=1)
C = sorted(list(map(int,input().split())),reverse=1)
Q = [(-A[0]-B[0]-C[0],0,0,0)]
heapq.heapify(Q)
abc = [(0,0,0)]
for i in range(K):
    n,a,b,c = heapq.heappop(Q)
    if a < X-1 and (a+1,b,c) not in abc:
        abc.append((a+1,b,c))
        heapq.heappush(Q,(n+A[a]-A[a+1],a+1,b,c))
    if b < Y-1 and (a,b+1,c) not in abc:
        abc.append((a,b+1,c))
        heapq.heappush(Q,(n+B[b]-B[b+1],a,b+1,c))
    if c < Z-1 and (a,b,c+1) not in abc:
        abc.append((a,b,c+1))
        heapq.heappush(Q,(n+C[c]-C[c+1],a,b,c+1))
    print(-n)

Measured memory_bytes: 4592
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int lli;
struct Matching{
//start Hopkraft Matching
    static const int MAXN1 = 500;
    static const int MAXN2 = 500;
    static const int MAXM = 20000;

    int n1, n2, edges, last[MAXN1], pre[MAXM], head[MAXM];
    int matching[MAXN2], dist[MAXN1], Q[MAXN1];
    bool used[MAXN1], vis[MAXN1];

    void init(int _n1, int _n2) 
    {
        n1 = _n1;
        n2 = _n2;
        edges = 0;
        fill(last, last + n1, -1);
    }

    void addEdge(int u, int v) 
    {
        head[edges] = v;
        pre[edges] = last[u];
        last[u] = edges++;
    }

    void bfs() 
    {
        fill(dist, dist + n1, -1);
        int sizeQ = 0;
        for (int u = 0; u < n1; ++u) {
            if (!used[u]) {
                Q[sizeQ++] = u;
                dist[u] = 0;
            }
        }
        for (int i = 0; i < sizeQ; i++) {
            int u1 = Q[i];
            for (int e = last[u1]; e >= 0; e = pre[e]) {
                int u2 = matching[head[e]];
                if (u2 >= 0 && dist[u2] < 0) {
                    dist[u2] = dist[u1] + 1;
                    Q[sizeQ++] = u2;
                }
            }
        }
    }

    bool dfs(int u1) 
    {
        vis[u1] = true;
        for (int e = last[u1]; e >= 0; e = pre[e]) {
            int v = head[e];
            int u2 = matching[v];
            if (u2 < 0 || ((!vis[u2] && dist[u2] == dist[u1] + 1) && dfs(u2))) {
                matching[v] = u1;
                used[u1] = true;
                return true;
            }
        }
        return false;
    }

    int maxMatching() 
    {
        fill(used, used + n1, false);
        fill(matching, matching + n2, -1);
        for (int res = 0;;) {
            bfs();
            fill(vis, vis + n1, false);
            int f = 0;
            for (int u = 0; u < n1; ++u)
                if (!used[u] && dfs(u))
                    ++f;
            if (!f)
                return res;
            res += f;
        }
    }
} M;
typedef pair <int, int> pi;
int main() {fio; // remove during scanf
	vector <pi> R, B;
	int N;
	cin >> N;
	M.init(N, N);
	for(int i = 0; i < N; i++) {
		int u, v;
		cin >> u >> v;
		R.push_back({u, v});
	}
	for(int i = 0; i < N; i++) {
		int u, v;
		cin >> u >> v;
		B.push_back({u, v});
	}
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < N; j++) {
			if(B[i].first > R[j].first && B[i].second > R[j].second) {
				// cout << i << ' ' << j << endl;
				M.addEdge(i, j);
			}
		}
	}
	cout << M.maxMatching();
    return 0;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,K;
  cin >> N >> K;
  ll A[N];
  ll ans = 1;
  vector<pair<ll,ll>> Z;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    Z.push_back(make_pair(abs(A[i]),i));
  }
  sort(Z.begin(),Z.end());
  reverse(Z.begin(),Z.end());
  int minus = 0;
  for (int i = 0; i < K; i++) {
    if (A[Z[i].S] < 0) {
      minus++;
    }
    if (A[Z[i].S] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  if (minus % 2 == 0) {
    for (int i = 0; i < K; i++) {
      ans *= A[Z[i].S];
      ans %= Mod;
    }
    cout << ans << endl;
    return 0;
  } else {
    // 最小- を + に
    // 最小+ を - に
    long double way1 = -1.0;
    long double way2 = -1.0;
    int in1 = -1;
    int in2 = -1;
    for (int i = K; i < N; i++) {
      if (A[Z[i].S] > 0) {
        in1 = i;
        break;
      }
    }
    for (int i = K; i < N; i++) {
      if (A[Z[i].S] < 0) {
        in2 = i;
        break;
      }
    }
    int in1_2 = -1;
    int in2_2 = -1;
    for (int i = K-1; i >= 0; i--) {
      if (A[Z[i].S] < 0) {
        in1_2 = i;
        break;
      }
    }
    for (int i = K-1; i >= 0; i--) {
      if (A[Z[i].S] > 0) {
        in2_2 = i;
        break;
      }
    }

    if (in1 != -1 && in1_2 != -1) {
      way1 = (long double)A[Z[in1_2].S] / (long double)A[Z[in1].S];
      way1 *= -1;
    }
    if (in2 != -1 && in2_2 != -1) {
      way2 = (long double)A[Z[in2_2].S] / (long double)A[Z[in2].S];
      way2 *= -1;
    }

    if (way1 == -1 && way2 == -1) {
      for (int i = N-1; i >= N - K; i--) {
        ans *= A[Z[i].S];
        ans %= Mod;
      }
      if (ans < 0) ans += Mod;
      cout << ans << endl;
      return 0;
    } else if (way1 == -1 || way2 == -1) {
      if (way1 == -1) {
        for (int i = 0; i < K; i++) {
          if (i == in2_2) {
            ans *= A[Z[in2].S];
          } else {
            ans *= A[Z[i].S];
          }
          ans %= Mod;
        }
        if (ans < 0) ans += Mod;
        cout << ans << endl;
        return 0;
      } else {
        for (int i = 0; i < K; i++) {
          if (i == in1_2) {
            ans *= A[Z[in1].S];
          } else {
            ans *= A[Z[i].S];
          }
          ans %= Mod;
        }
        if (ans < 0) ans += Mod;
        cout << ans << endl;
        return 0;
      }
    } else {
      if (way1 >= way2) {
        for (int i = 0; i < K; i++) {
          if (i == in2_2) {
            ans *= A[Z[in2].S];
          } else {
            ans *= A[Z[i].S];
          }
          ans %= Mod;
        }
        if (ans < 0) ans += Mod;
        cout << ans << endl;
        return 0;
      } else {
        for (int i = 0; i < K; i++) {
          if (i == in1_2) {
            ans *= A[Z[in1].S];
          } else {
            ans *= A[Z[i].S];
          }
          ans %= Mod;
        }
        if (ans < 0) ans += Mod;
        cout << ans << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 8432
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}

int main()
{
    ios;
    ll a,b;
    cin>>a>>b;
    ll g=__gcd(a,b);
    map<ll,ll>m;
    m[1]=1;
    for(ll i=2;i*i<=g;i++)
    {
        if(g%i==0)
        {
            m[i]=1;
            while(g%i==0)
                g/=i;
        }
    }
    m[g]=1;
    ll sum=0;
     map<ll,ll>::iterator it;
     for(it=m.begin();it!=m.end();it++)
        sum+=it->ss;
    cout<<sum<<endl;



}







Measured memory_bytes: 3620
fn main() {
    let (a, b) = {
        let v = read_vec::<u32>();
        (v[0], v[1])
    };

    println!("{}", solve(a, b));
}

fn solve(a: u32, b: u32) -> String {
    let ret = a * b;
    if ret % 2 == 0 {
        "Even".to_string()
    } else {
        "Odd".to_string()
    }
}

#[test]
fn test1() {
    assert_eq!("Even", solve(3, 4));
}

#[test]
fn test2() {
    assert_eq!("Odd", solve(1, 21));
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
import sys
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

if(a[0] - b[0] == a[1] - b[1] == a[2]-b[2]):
    if(b[1]-c[1]==b[0]-c[0]==b[2]-c[2]):
        print("Yes")
        sys.exit()
print("No")

Measured memory_bytes: 3064
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		//(0)～12までの数字をグループ化
		int t[] = {0, 1,3,1,2,1,2,1,1,2,1,2,1};
		//()内にif文のようなものを入れる
		System.out.println(t[x] == t[y] ? "Yes" : "No");
	}
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
//F6編譯，右上三角形執行，ctrl+c強制停止執行  F5開啟exe
#define ll long long
#define maxn 505
#define mod 998244353
using namespace std;

typedef pair<int, int> P;

ll S;
ll a, b, c, d;

int main()
{
    cin >> S;
    ll n = (ll)floor(sqrt(S));
    if (n == 1000000000)
        printf("0 0 0 1000000000 1000000000 0");
    else if (S <= n * (n + 1))
    {
        a = 1;
        b = n;
        c = S - n * n;
        d = n * (n + 1) - S;
        printf("0 0 %lld %lld %lld %lld", a, c + d, a + b, d);
    }
    else
    {
        a = 1;
        b = n;
        c = S - n * (n + 1);
        d = (n + 1) * (n + 1) - S;
        printf("0 0 %lld %lld %lld %lld", a, c + d, a + b, d);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){

  vector<int> A(3);
  cin>>A.at(0)>>A.at(1)>>A.at(2);
  
  int sum = A.at(0)+A.at(1)+A.at(2);
  
  if(sum>=22){
    cout<<"bust"<<endl;
  }
  
  else if(sum<=21){
    cout<<"win"<<endl;
  }
  return 0;
  
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(;;){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			int[] dp=new int[n+4];
			dp[0]=1;
			for(int i=0; i<=n; i++){
				dp[i+1]+=dp[i];
				dp[i+2]+=dp[i];
				dp[i+3]+=dp[i];
			}
			int ans=((dp[n]+9)/10+364)/365;
			println(ans+"");
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#!/usr/bin/env python3
import sys
# input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    X = input()

    LENX = len(X)

    T_count = 0
    answer = LENX
    for i in range(LENX-1,-1,-1):
        if X[i] == "T":
            T_count += 1
        else:
            if T_count > 0 :
                T_count -= 1
                answer -= 2
        
    print(answer)

    return

if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
        string a, b;
        cin>>a>>b;
        if(a==b){
                cout<<"EQUAL"<<endl;
        }
        else if(a.size()<b.size()){
                cout<<"LESS"<<endl;
        }
        else if(a.size()>b.size()){
                cout<<"GREATER"<<endl;
        }
        else{
                int i=0;
                while(a[i]==b[i]){
                        i++;
                }
                if(a[i]>b[i]){
                        cout<<"GREATER"<<endl;
                }
                else{
                        cout<<"LESS"<<endl;
                }
        }
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    int ans = 0;
    rep(i, N) {
        int a;
        cin >> a;
        ans += a - 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		Arrays.fill(X, 0);
		for(int i = 0; i < N - 1; i++) {
			X[sc.nextInt() - 1]++;
		}

		for(int i = 0; i < N; i++) {
			System.out.println(X[i]);
		}
	}
}

Measured memory_bytes: 61844
using System;

namespace A___Sharing_Cookies
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
            {
                Console.WriteLine("Possible");
            }
            else
            {
                Console.WriteLine("Impossible");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
	double x, q, y;
	while(scanf("%lf", &q), q >= 0.0){
		x = 0.5 * q;
		while(1){
			y = x * x * x - q;
			if(abs(y) < 1e-5 * q){
				break;
			}
			x -= y / (3.0 * x * x);
		}
		printf("%f\n", x);
	}
}

Measured memory_bytes: 1076
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,m,tmp,cnt=0;
  vector <int> a,spread;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>tmp;
    a.push_back(tmp);
  }
  for(int i=0,tmp=1;tmp<=n;i++){ //make spread vector                                                                                                                                          
    spread.insert(spread.begin(),tmp);
    tmp=3*tmp+1;
  }
  m=spread.size();
  cout<<m<<endl; //output spread amount                                                                                                                                                        
  for(int i=0;i<m-1;i++) cout<<spread[i]<<" ";
  cout<<spread[m-1]<<endl; //output all spread                                                                                                                                                 
  for(int k=0;k<m;k++) for(int i=0;i+spread[k]<n;i++){
      int end=i+spread[k],first=i%spread[k]; //list first                                                                                                                                      
      // for(int j=1;j<amount;j++){ //inserting sort                                                                                                                                           
        if(a[end]>a[end-spread[k]]) continue;
        int l;
        for(l=1;l<(end-first)/spread[k]+1;l++){
          if(a[end-(l-1)*spread[k]]<a[end-l*spread[k]]){
            swap(a[end-(l-1)*spread[k]],a[end-l*spread[k]]);
            cnt++;
          } else break;
        }
        // cout<<"check vector cnt:"<<cnt<<endl; //debug                                                                                                                                       
        // for(int i=0;i<n-1;i++) cout<<a[i]<<" ";                                                                                                                                             
        // cout<<a[n-1]<<endl<<endl;                                                                                                                                                           
    }
  cout<<cnt<<endl; //output cnt&answer vector                                                                                                                                                  
  for(int i=0;i<n;i++) cout<<a[i]<<endl;
  return 0;
}

Measured memory_bytes: 6964
#include<iostream>

using namespace std;

int main(){
	int R,G,B,N;
	cin>>R>>G>>B>>N;
	int count=0;
	for(int r=0;r<=N/R;r++){
		for(int g=0;g<=(N-r*R)/G;g++){
			int b=(N-r*R-g*G)/B;
			if(r*R+g*G+b*B==N) count++;
		}
	}
	cout<<count;
}

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

int main() {
  int N;
  cin>>N;
  vector<double>a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  double sum=1.0;
  for(int i=0;i<N;i++){
    sum*=a.at(i);
  }
  double nibu=0.0;
  for(int i=0;i<N;i++){
    nibu+=sum/a.at(i);
  }
  double ans=sum/nibu;
  cout<<ans<<endl;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int n, m;
	cin >> n >> m;

	cout << (n * (n - 1) + m * (m - 1)) / 2 << endl;
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

using namespace std;

int a, b, c, cnt = -1;

int calc(int a, int b, int c) {
    if (cnt > int(1e4)) return -1;
    ++cnt;
    if (a%2 == 1 || b%2 == 1 || c%2 == 1) return cnt;
    else return calc((b+c)/2, (a+c)/2, (a+b)/2);
}

int main() {
    cin >> a >> b >> c;
    cout << calc(a, b, c);
}


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

int main(){
	string S;
	cin >> S;
	
	int L=S.size();
	
	vector<int> ans(L,0);
	ans[0]=1;
	for(int i=1;i<L;i++){
		if(S[i-1]==S[i]){
			if(i==1)ans[i]=1;
			else if(i==2)ans[i]=2;
			else ans[i]=ans[i-3]+2;
		}
		else{
			ans[i]=ans[i-1]+1;
		}
	}
	cout << ans[L-1] << endl;
	return 0;
}

Measured memory_bytes: 1412
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long now = 0;
        HashSet<Long> hs = new HashSet<>();
        while(c != now){
            now += a;
            now %= b;
            if(hs.contains(now)){
                System.out.println("NO");
                return;
            }else{
                hs.add(now);
            }
        }
        System.out.println("YES");
    }
}


Measured memory_bytes: 21712
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <cmath>

using namespace std;
typedef uint uint32_t;

int main() {
    uint N, D, X;
    cin >> N >> D >> X;
    uint sum = X;
    for (int i = 0; i < N; i++) {
        uint a;
        cin >> a;
        sum += ceil(float(D) / float(a));
    }
    cout << sum << endl;
    // cout << x * x * x << endl;
    // scanf("%u %u", &x, &y);
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

cnt = 0
res = 0
for i in range(N):
    enm = min(A[i]+A[i+1]-res, B[i])
    res = max(res + enm - A[i], 0)
    cnt += enm

print(cnt)


Measured memory_bytes: 19116
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    map<char, char> mp;
    mp['A'] = 'T';
    mp['T'] = 'A';
    mp['G'] = 'C';
    mp['C'] = 'G';

    char b;
    cin >> b;
    cout << mp[b] << endl;
}

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

using namespace std;

#define int long long

int dp[3010][3010];
int mod;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> sum(n + 1);
	for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum[i + 1] = sum[i] + a[i];
    }
    for (int len = 2; len <= n; len++) {
        for (int l = 0; l + len <= n; l++) {
            int r = l + len - 1;
            dp[l][r] = 2e18;
            for (int m = l + 1; m <= r; m++) {
                dp[l][r] = min(dp[l][r], dp[l][m - 1] + dp[m][r] + sum[r + 1] - sum[l]);
            }
        }
    }
    cout << dp[0][n - 1] << endl;
    return 0;
}


Measured memory_bytes: 5812
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

int gcd(long long int a,long long int b){
    if(a<b){
        int tmp=a;
        a = b;
        b = tmp;
    }

    long long int r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

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

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

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

    long long int res=0;
    for(int i=0;i<v.size();i++){
        res += v[i]-1;
    }
    p(res)
} 

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

 int main() {
        int N,m = 0,n = 0; 
        std::cin >> N;
        int arr[N];
        for (int i=1; i<=N; i++) {
            std::cin >> arr[N];
            if(arr[N]>N)
            {
                std::cout << "NO" << std::endl;
                return 0;
            }
            if (i == arr[N])
            m = m+1;
            else if (i!=arr[N])
            n = n+1;
            
        }
        if((m==N)||(n == 2))
        std::cout << "YES" << std::endl;
        else  
        std::cout << "NO" << std::endl;
        
        
        return 0;
    }

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007
#define pi atan(1) * 4

int main()
{
	long long int N;
	cin >> N;
	for(long long int h = 1; h <= 3500; h++){
		for(long long int n = 1; n <= 3500; n++){
			long long int tmp = 4 * h * n - N * n - N * h;
			if(tmp > 0 && (N * h * n) % tmp == 0){
				cout << h << " " << n << " " << (long long int)(N * h * n) / tmp << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

bool check[1000];
char ans[30000],mid[31];

int main(){

	int N,L;
	scanf("%d %d",&N,&L);

	for(int i = 0; i < N; i++)check[i] = false;

	vector<string> V;

	string tmp;

	for(int i = 0; i < N; i++){
		cin >> tmp;
		V.push_back(tmp);
	}

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

	int mid_len = 0,index = 0;

	bool FLG;

	for(int i = 0; i < N-1; i++){
		if(check[i])continue;

		for(int k = i+1; k < N; k++){
			if(check[k])continue;

			FLG = true;

			for(int p = 0; p < L; p++){
				if(V[i][p] != V[k][L-1-p]){
					FLG = false;
					break;
				}
			}

			if(FLG){
				check[i] = true;
				check[k] = true;
				for(int p = 0; p < L; p++){
					ans[index++] = V[i][p];
				}
				break;
			}
		}
	}

	if(L == 1){

		for(int i = 0; i < N; i++){
			if(check[i])continue;

			mid[0] = V[i][0];
			mid_len = 1;
			break;
		}

	}else{

		for(int i = 0; i < N; i++){
			if(check[i])continue;

			FLG = true;

			for(int k = 0; k < L/2; k++){
				if(V[i][k] != V[i][L-1-k]){
					FLG = false;
					break;
				}
			}

			if(FLG){
				for(int k = 0; k < L; k++)mid[k] = V[i][k];
				mid_len = L;
				break;
			}
		}
	}

	if(index == 0 && mid_len == 0){
		printf("\n");
	}else if(index > 0 && mid_len == 0){
		for(int i = 0; i < index; i++){
			printf("%c",ans[i]);
		}
		for(int i = index-1; i >= 0; i--){
			printf("%c",ans[i]);
		}
		printf("\n");
	}else if(index == 0 && mid_len > 0){

		for(int i = 0; i < mid_len; i++){
			printf("%c",mid[i]);
		}
		printf("\n");
	}else if(index > 0 && mid_len > 0){
		for(int i = 0; i < index; i++){
			printf("%c",ans[i]);
		}
		for(int i = 0; i < mid_len; i++){
			printf("%c",mid[i]);
		}
		for(int i = index-1; i >= 0; i--){
			printf("%c",ans[i]);
		}
		printf("\n");
	}

	return 0;
}

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


int main(){
    double N,T,A;
    cin >> N >> T >> A;
    vector<double> H(N);
    for (int i=0;i<N;++i) cin >> H[i];
    double tmp[2] = {abs(A - (T - H[0] * 0.006)),1};
    for (int i=0;i<N;++i){
        if(tmp[0] > abs(A - (T - H[i] * 0.006))){
            tmp[0] = abs(A - (T - H[i]*0.006));
            tmp[1] = i+1;
        }
    }
    cout << tmp[1] << endl;
}





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

using namespace std;

int main()
{
	for(int n;cin>>n,n;){
		int taro[100],hana[100];
		bool btaro[100],bhana[100];
		for(int i=0;i<n;i++)cin>>taro[i],btaro[i]=bhana[i]=true;
		sort(taro,taro+n);
		for(int a=1,i=0,j=0;a<=2*n;a++){
			if(i<n && taro[i]==a)	i++;
			else	hana[j++]=a;
		}

		int now=0,cnttaro=0,cnthana=0;
		while(1){
			int i;
			bool ok=false;
			for(i=0;i<n;i++){
				if(btaro[i] && taro[i]>now){ ok=true; break; }
			}
			if(ok){
				now=taro[i];
				btaro[i]=false;
				cnttaro++;
				if(cnttaro==n)	break;
			}
			else	now=0;

			ok=false;
			for(i=0;i<n;i++){
				if(bhana[i] && hana[i]>now){ ok=true; break; }
			}
			if(ok){
				now=hana[i];
				bhana[i]=false;
				cnthana++;
				if(cnthana==n)	break;
			}
			else	now=0;
		}
		cout<<n-cnthana<<endl<<n-cnttaro<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

const int N = 100005;

vector<pair<int, int>> adj[N];
bool color[N], visited[N];

void bfs(int node) {
	queue<int> q;
	q.push(node);
	color[node] = false;
	while (!q.empty()) {
		int size = (int) q.size();
		while (size--) {
			int cur_node = q.front();
			q.pop();
			for (int i = 0; i < (int) adj[cur_node].size(); i++) {
				if (!visited[adj[cur_node][i].first]) {
					visited[adj[cur_node][i].first] = true;
					q.push(adj[cur_node][i].first);
					if (adj[cur_node][i].second == 1) {
						color[adj[cur_node][i].first] = !color[cur_node];
					} else {
						color[adj[cur_node][i].first] = color[cur_node];
					}
				}
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	for (int i = 0, u, v, w; i < n - 1; i++) {
		cin >> u >> v >> w;
		adj[u].emplace_back(v, w & 1);
		adj[v].emplace_back(u, w & 1);
	}
	bfs(1);
	for (int i = 1; i <= n; i++) {
		cout << color[i] << '\n';
	}
	return 0;
}


Measured memory_bytes: 6656
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, llint> E;

const int FACT_MAX = 10005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

llint divide(llint n, llint k)
{
	return comb(n+k-1, n);
}

llint k, n;

llint calc(llint n, llint k, llint cnt)
{
	llint ret = 0;
	for(int i = 0; i <= cnt; i++){
		if(n-2*i < 0) break;
		llint tmp = divide(n-2*i, k) * comb(cnt, i) % mod;
		if(i % 2) ret += mod - tmp, ret %= mod;
		else ret += tmp, ret %= mod;
	}
	return ret;
}

int main(void)
{
	make_fact();
	cin >> k >> n;
	if(k == 1){
		cout << 0 << endl;
		return 0;
	}
	
	for(int i = 2; i <= 2*k; i++){
		llint cnt = 0;
		for(int j = 1; j <= k; j++){
			llint cj = i-j;
			if(cj <= j || cj < 1 || cj > k) continue;
			cnt++;
		}
		llint ans = 0;
		if(i % 2) ans = calc(n, k, cnt), ans %= mod;
		else ans = calc(n, k-1, cnt) + calc(n-1, k-1, cnt), ans %= mod;
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

ll H,W,h,w,ans[505][505],tot;

int main()
{
	cin>>H>>W>>h>>w;
	if(H%h==0&&W%w==0) return puts("No"),0;
	for(int i=h;i<=H;i+=h)
	{
		for(int j=w;j<=W;j+=w) ans[i][j]=-1000000000;
	}
	for(int i=1;i<=H;i+=h)
	{
		for(int j=1;j<=W;j+=w) ans[i][j]=999999999;
	}
	puts("Yes");
	rep(i,1,H)
	{
		rep(j,1,W) printf("%lld ",ans[i][j]); puts("");
	}
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

/*
int main(void){
	int32 N;
	cin >> N;
	vector<int64> v(N);
	REP(i, N) cin >> v[i];

	int64 maxi = 0;
	int64 res = 0;
	REP(i, N){
		int64 cnt = (v[i]-1)/(maxi+1);
		if(cnt){ res += cnt; chmax(maxi, 1); }
		else maxi = v[i];
	}
	cout << res << endl;
}
*/

int main(void){
	int32 N, M;
	cin >> N >> M;
	vector<int64> X(N), cnt(M, 0), same(M, 0);
	map<int64, int64> mp;
	REP(i, N){
		cin >> X[i];
		cnt[X[i]%M]++;
		mp[X[i]]++;
		if(mp[X[i]]%2 == 0){
			same[X[i]%M]+=2;
		}
	}
	int64 res = 0;
	for(int32 i = 0;i < M/2+1;i++){
		int64 maxi = min(cnt[i], cnt[(M-i)%M]);
		if(i == (M-i)%M) maxi /= 2;
		res += maxi;
		cnt[i] -= maxi; cnt[(M-i)%M] -= maxi;
		res += min(cnt[i], same[i])/2;
		if(i!=(M-i)%M) res += min(cnt[M-i], same[M-i])/2;
	}
	cout << res << endl;
}

Measured memory_bytes: 8832
import Data.List.Split
import Control.Applicative

main = do
  ss <- getLine
  let ns = map read $ splitOn " " ss
  let s1 = ns!!0
  let s2 = ns!!1
  let area = s1 * s2
  let perim = (s1+s2) * 2
  putStrLn $ (show area) ++ " " ++ (show perim)


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll q, h, s, d;
  cin >> q >> h >> s >> d;
  ll n; cin >> n;

  ll two = min(d, min(s*2, min(h*4, q*8)));
  ll one = min(s, min(h*2, q*4));
  cout << n/2*two + n%2*one << endl;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    string s = read!string;
    string t = read!string;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == t[i]) ans++;
    }
    writeln(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibutan(auto a,auto b);
class Modulo{
public:
    int val;
    static const int mod = 1e9+7;
    vector<int> factable = {1};
    vector<int> invtable = {1};
    int pro(int x,int y){return ((x%mod)*(y%mod))%mod;}
    int sum(int x,int y){return ((x%mod)+(y%mod))%mod;}
    int dif(int x,int y){int d =((x%mod)-(y%mod))%mod;if(d>=0){return d;}else{return d+mod;}}
    int quo(int x, int y){return pro(x,pow(y,mod-2));}
    int pow(int x,int y){
        if(y<=0){return 1;}
        if(y%2==0){int d = pow(x,y/2);return ((d%mod)*(d%mod))%mod;}
        else{return (x*pow(x,y-1))%mod;}
    }
    void operator=(int n){this->val = n%mod;}
    int operator+(int n){return sum(this->val,n);}
    int operator-(int n){return dif(this->val,n);}
    int operator*(int n){return pro(this->val,n);}
    int operator/(int n){return quo(this->val,n);}
    void operator+=(int n){this->val = sum(this->val,n);}
    void operator-=(int n){this->val = dif(this->val,n);}
    void operator*=(int n){this->val = pro(this->val,n);}
    void operator/=(int n){this->val = quo(this->val,n);}
    int fac(int x){
        //x! mod mod
        if(factable.size()<=x){
            int s = factable.size();
            FOR(i,s,x+1){
                factable.push_back(pro(i,factable.back()));
                invtable.push_back(quo(1,factable.back()));
            }
        }
        if(x<0) return 1;
        else return factable[x];
    }
    int facinv(int x){
        if(invtable.size()<=x){
            int s = invtable.size();
            FOR(i,s,x+1){
                factable.push_back(pro(i,factable.back()));
                invtable.push_back(quo(1,factable.back()));
            }
        }
        if(x<0) return 1;
        else return invtable[x];
    }
    int com(int x,int y){
        //xCy mod mod = x!/((x-y)!*y!) mod mod
        if(x-y<y)return com(x,x-y);
        return pro(fac(x),pro(facinv(x-y),facinv(y)));
    }
};

signed main(){
    string s;
    cin >> s;
    int zero=0,iti=0;
    REP(i,s.size()){
        if(s[i] == '0')zero++;
        else iti++;
    }
    cout << min(zero,iti)*2 << endl;


    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibutan(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    return x-1;
}

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

int main(){
    string S;
    cin >> S;

    if (S[0] == '7' || S[1] == '7' || S[2] == '7'){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <queue>
#include <cstring>
#include <set>
#include <list>
#include <map>
#include <random>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vvi> vvvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;

#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define forn(i, a, b) for(int i = a; i < b; i++)

#define pb push_back
#define mp make_pair

int main()
{

    int h,w;
    scanf("%d %d\n", &h, &w);
    vs a(h);
    forn(i,0,h) getline(cin, a[i]);
    vs u(h, string(w, '.'));
    vs v(h, string(w, '.'));
    forn(i,0,h) u[i][0] = '#';
    forn(i,0,h) v[i][w-1] = '#';
    forn(i,1,h-1) {
        forn(j,1,w-1) {
            if(i%2 == 0) u[i][j] = '#';
            else v[i][j] = '#';
        }
    }
    forn(i,0,h) forn(j,0,w) {
        if(a[i][j] == '#') {
            u[i][j] = '#';
            v[i][j] = '#';
        }
    }
    forn(i,0,h) printf("%s\n", u[i].c_str());
    printf("\n");
    forn(i,0,h) printf("%s\n", v[i].c_str());
    
    
}



Measured memory_bytes: 1536
<?php
  fscanf(STDIN, "%d%d", $n, $k);
  $vals = [];
  $counts = [];
  for($i=0; $i<$n; $i++){
      fscanf(STDIN, "%d%d", $a, $b);
      $vals[$i] = $a;
      $counts[$i] = $b;
  }
  $f = 0;
  asort($vals);
  foreach($vals as $key => $val){
      $f += $counts[$key];
      if($f >= $k){
          echo $val;
          break;
      }
  }

Measured memory_bytes: 27956
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    for i in range(1,50001):
        k=int(i*1.08)
        if(n==k):
            print(i)
            return
        elif(n<k):
            print(":(")
            return
resolve()

Measured memory_bytes: 39280
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
using namespace std;

int main(){
    int N,H[100010],ans=0,k=0;cin>>N;
    cin>>H[0];
    for(int i=1;i<N;++i){
        cin>>H[i];
        if(H[i-1]>=H[i])++k;
        else {
            ans=max(ans,k);
            k=0;
        }
    }
    ans=max(ans,k);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
def createData
  data = Array.new
  while input = $stdin.gets
    break if input == "\n"
    v = input.chomp.split(",")
    data << v[0]
  end
  return data
end

dataCurrentMonth = createData
dataPreviousMonth = createData

result = Hash.new
dataCurrentMonth.each{ |id|
  next if dataPreviousMonth.index(id) == nil
  c = dataCurrentMonth.count(id) + dataPreviousMonth.count(id)
  result.store(id.to_i, c)
}

result.sort.each{ |k, v| printf("%d %d\n", k, v) }

Measured memory_bytes: 6104
fun main(args:Array<String>){
    val numOfInt = readLine()!!.toInt()
    val prog = readLine()!!.split(" ").map(String::toInt)
    var ans = 0.0
    for(i in 0..numOfInt-1){
        ans += 1 / prog[i].toDouble()
    }

    print(1 / ans)
}

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

int main(){
    ll a,b;
    cin >> a >> b;
    //vector<ll> Seivea(1000005),Seiveb(1000005);
    int ans=1;
    for(ll i=2; i<=1000003; i++){
        ll ctra=0,ctrb=0;
        while(a%i==0){
            ctra++;
            a /= i;
        }
        while(b%i==0){
            ctrb++;
            b /= i;
        }
        if(ctra&&ctrb) ans++;
    }
    if(a>1&&b>1&&a==b) ans++;
    cout << ans << endl;
    return 0;
}

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

struct Edge {
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

ll C[100001];

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

  int N; cin >> N;

  Graph G(N + 1);
  rep(_, N - 1) {
    int from, to, weight;
    cin >> from >> to >> weight;
    G[from].push_back(Edge(to, weight));
    G[to].push_back(Edge(from, weight));
  }

  int Q,K; cin >> Q >> K;
  queue<int> QU;
  QU.push(K);

  while(!QU.empty()) {
    int cur = QU.front(); QU.pop();
    rep(i, G[cur].size()) {
      Edge next = G[cur][i];  
      if(C[next.to] == 0) {
        QU.push(next.to);
        C[next.to] = C[cur] + next.weight;
      } else {
        C[next.to] = min(C[next.to], C[cur] + next.weight);
      }
    }
  }

  rep(i, Q) {
    int from, to;
    cin >> from >> to;

    cout << C[from] + C[to] << endl;
  }

  return 0;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 2005;


int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);

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

    repD(i,min(a,b),1) {
        if(!(a%i) and !(b%i)) {
            if(k==1) {
                cout << i << '\n';
                return 0;
            }
            k--;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cassert>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX/3
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cout<<#x<<":"<<x<<endl
#define debug2(x,y) cout<<#x","<<#y":"<<x<<","<<y<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

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

int main(){
    int a,d,n;
    while(cin>>a>>d>>n){
        if(a==0 && d==0 && n==0) break;
        int cnt=0;
        while(n){
            if(isprime(a)) n--;
            a += d;
        }
        cout << a-d << endl;
    }
}

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

int N;
int a[101], b[101];
int Ai, Bi, Ci, Di;

signed main()
{
	cin >> N;
	rep(i,N*(N-1)/2) {
		cin >> Ai >> Bi >> Ci >> Di;
		if (Ci < Di) {
			a[Bi] += 3;
		} else if (Ci == Di) {
			a[Ai] += 1;
			a[Bi] += 1;
		} else if (Ci > Di) {
			a[Ai] += 3;
		}
	}

	rep(i,101) b[i] = 1;

	for (int i=2; i<=N; i++) {
		for (int j=1; j<=i-1; j++) {
			if (a[j] > a[i]) b[i]++;
			if (a[j] < a[i]) b[j]++;
		}
	}

	for (int i=1; i<=N; i++) {
		cout << b[i] << endl;
	}
}

Measured memory_bytes: 1160