akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
  static int[] par;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int L = sc.nextInt();
    par = new int[N];
    for(int i = 0; i < N; i++) {
      par[i] = i;
    }
    for(int i = 0; i < K; i++) {
      int p = sc.nextInt() - 1;
      int q = sc.nextInt() - 1;
      unite(p, q);
    }
    int[] road = new int[N];
    for(int i = 0; i < N; i++) {
      road[i] = root(i);
    }

    for(int i = 0; i < N; i++) {
      par[i] = i;
    }
    for(int i = 0; i < L; i++) {
      int r = sc.nextInt() - 1;
      int s = sc.nextInt() - 1;
      unite(r, s);      
    }
    int[] rail = new int[N];
    for(int i = 0; i < N; i++) {
      rail[i] = root(i);
    }

    HashMap<Long, Integer> map = new HashMap<Long, Integer>();
    for(int i = 0; i < N; i++) {
      long g = (long)N * (long)road[i] + (long)rail[i];
      if(map.containsKey(g)) {
        map.put(g, map.get(g) + 1);
      } else {
        map.put(g, 1);
      }
    }
    
    for(int i = 0; i < N; i++) {
      int ans = map.get((long)N * (long)road[i] + (long)rail[i]);
      if(i == N - 1) {
        System.out.print(ans);
      } else {
        System.out.print(ans + " ");
      }
    }
  }
  static int root(int x) {
    if(x == par[x]) return x;
    return par[x] = root(par[x]);
  }
  static void unite(int x, int y) {
    int rootx = root(x);
    int rooty = root(y);
    if(rootx != rooty) par[rootx] = rooty;
  }
}

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

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

N = INT()
A = LIST()
B = LIST()

ans = 0
for i in range(N):
	if A[i] > B[i]:
		ans += B[i]
	else:
		ans += A[i]
		B[i] -= A[i]  # のこり
		if B[i] > A[i+1]:
			ans += A[i+1]
			A[i+1] = 0
		else:
			ans += B[i]
			A[i+1] -= B[i]
print(ans)


Measured memory_bytes: 20516
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int n,i;

int solve(int num){

	if(num == 6174){
		return i;
	}

	i++;

	int k[5];
	k[0] = num/1000;
	k[1] = (num%1000)/100;
	k[2] = (num%100)/10;
	k[3] = num%10;

	sort(k,k+4);
	int s = k[0]*1000+k[1]*100+k[2]*10+k[3];

	reverse(k,k+4);
	int l = k[0]*1000+k[1]*100+k[2]*10+k[3];

	solve(l-s);

}



int main (){

	for(int d=0; d<10000; d++){
	
		i=0;

		cin >> n;
		if(n*1 == 0)break;

		if(n%1111 == 0){
			cout << "NA" << endl;
		}

		else{
			cout << solve(n) << endl;
	
		}
	}
	
	return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <vector>
static int c(std::vector<int> &a, int s)
{
    int ss = 0;
    for (const auto aa: a)
    {
        ss += (s - aa) * (s - aa);
    }
    return ss;
}
int main()
{
    int n; std::cin >> n;
    std::vector<int> a(n);
    int s = 0;
    for (int i = 0; i < n; i++)
    {
        std::cin >> a[i];
        s += a[i];
    }

    s /= n;

    std::cout << std::min(c(a, s), c(a, s+1)) << std::endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		
		var input = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		int N = input[0];
		int M = input[1];
		int C = input[2];
		var B = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		int[,] A = new int[N,M];
        for(int i = 0; i < N; i++)
		{
			var ain = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
			for (int j = 0; j < M; j++)
			{
				A[i, j] = ain[j];
			}
		}


		int ans = 0;
        for(int i = 0; i < N; i++)
		{
			int sum = 0;
            for(int j = 0; j < M; j++)
			{
				sum += A[i, j] * B[j];
			}
			if (sum + C > 0) { ans++; }
		}
		Console.WriteLine(ans);

		
	}
}

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

#define pb push_back

using namespace std;

vector<int> adj[100005];
vector<int> block[100005];
bool vis[100005];
int col[100005];
int numv[100005];

int bfs(int src, int color){
	int cnt = 1;
	queue<int> q;
	vis[src] = true;
	col[src] = color;
	q.push(src);
	while(!q.empty()){
		int u = q.front();
		for(int i=0;i<adj[u].size();i++){
			if(!vis[adj[u][i]]){
				vis[adj[u][i]] = true;
				col[adj[u][i]] = color;
				q.push(adj[u][i]);
				cnt++;
			}
		}
		q.pop();
	}
	return cnt;
}

int main(){
	int n, m, k;
	cin>>n>>m>>k;
	for(int i=0;i<m;i++){
		int a, b;
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	for(int i=0;i<k;i++){
		int c, d;
		cin>>c>>d;
		block[c].pb(d);
		block[d].pb(c);
	}
	memset(vis, false, sizeof vis);
	memset(col, 0, sizeof col);
	int cnt = 0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			int tmp = bfs(i, ++cnt);
			numv[cnt] = tmp;
		}
	}
	for(int i=1;i<=n;i++){
		//cout<<i<<" "<<col[i]<<" "<<numv[col[i]]<<"\n";
		int ans = numv[col[i]]-1;
		for(int j=0;j<block[i].size();j++){
			if(col[block[i][j]] == col[i])
				ans--;
		}
		ans-=adj[i].size();
		cout<<ans<<" ";
	}
	cout<<"\n";
	return 0;	
}

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


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

    if (S.length() <= K) {
        cout << S << endl;
        return 0;
    }

    rep(i, K) {
        cout << S[i];
    }

    cout << "..." << endl;

    return 0;
}

Measured memory_bytes: 3628
s = input()
p = 2019
n = 0
ans = 0
mods = [0]*p
mods[0] = 1
for i, j in enumerate(reversed(s)):
  n += int(j)*pow(10, i, p)
  n %= p
  mods[n] += 1
for i in mods:
  ans += i*(i-1)//2
print(ans)

Measured memory_bytes: 9360
h, w = [int(v) for v in input().split()]
a = []
for i in range(h):
    a.append([int(v) for v in input().split()])

yx = []
for y in range(1, h+1):
    if y % 2 == 1:
        yx.extend([(y, x) for x in range(1, w+1)])
    else:
        yx.extend([(y, x) for x in range(w, 0, -1)])

n = 0
op_list = []
for i in range(h * w - 1):
    sy, sx = yx[i]
    if a[sy-1][sx-1] % 2 == 1:
        ey, ex = yx[i+1]
        a[sy-1][sx-1] -= 1
        a[ey-1][ex-1] += 1
        n += 1
        op_list.append((sy, sx, ey, ex))

print(n)
for op in op_list:
    print(' '.join(map(str, op)))

Measured memory_bytes: 40028
package main

import (
        "fmt"
)

func solution(a, b string) string {
        l := max(len(a), len(b))
        a = helper(a, l)
        b = helper(b, l)
        if a > b {
                return "GREATER"
        }

        if a == b {
                return "EQUAL"
        }
        return "LESS"
}

func max(x, y int) int {
        if x > y {
                return x
        }
        return y
}

func helper(s string, l int) string {
        sl := len(s)
        if sl < l {
                buf := make([]byte, 0, l)
                for i := 0; i < l; i++ {
                        if i < l-sl {
                                buf = append(buf, '0')
                        } else {
                                buf = append(buf, s[i-l+sl])
                        }
                }
                return string(buf)
        }
        return s
}

func main() {
        var a, b string
        fmt.Scan(&a, &b)
        fmt.Println(solution(a, b))
}

Measured memory_bytes: 512
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}


ll a[100009];


int main() {
	ll N, K;
	cin >> N >> K;
	vector<pair<ll, ll>> A(N);
	rep(i, N) {
		ll a, b;
		cin >> a >> b;

		A.at(i)=make_pair(a,b);
	}
	sort(A.begin(), A.end());
	rep(i, N) {
		K -= A.at(i).second;
		if (K <= 0) {
			cout << A.at(i).first << endl;
			return 0;
		}
	}
}


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

int main() {
	int n, d, x;
	cin >> n >> d >> x;
	int ans = x;
	for (int i = 0;i < n;i++) {
		int a;
		cin >> a;
		for (int j = 0;1 + j * a <= d;j++) {
			ans++;
		}
	}
	cout << ans << endl;




	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=200005;

int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,i,s=0;
    scanf("%d%d",&n,&i);
    while(n){n/=i;++s;}
	printf("%d",s);
    return 0;
}

Measured memory_bytes: 256
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

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

int main()
{
    int N;
    cin >> N;
    cout << "ABC" << N << endl;
    return 0;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())

if a + 2 < b:
    if n < a:
        print(n + 1)
    else:
        n -= a - 1
        if n % 2 == 0:
            print(n//2 * (b - a) + a)
        else:
            print(n//2 * (b - a) + 1 + a)
else:
    print(n + 1)

Measured memory_bytes: 2940
#include<iostream>
#include<sstream>
#include<algorithm>
#include<string>

using namespace std;

typedef long long ll;

int main(){
	ll n; cin >> n;
	ll res = 11;
	for(ll i = 1; i * i <= n; i++){
		if(n % i != 0) continue;
		stringstream ss; ss << n / i;
		string s; ss >> s;
		res = min(res, (ll)s.length());
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, P, odd = 0, even = 0;
    cin >> N >> P;
    vector<ll> A(N);
    rep(0, i, N)
    {
        cin >> A.at(i);
        if (A.at(i) % 2 == 0)
        {
            even++;
        }
        else
        {
            odd++;
        }
    }
    if (odd == 0)
    {
        if (P == 0)
        {
            cout << ((ll)1 << even) << endl;
        }
        else
        {
            cout << 0 << endl;
        }
    }
    else
    {
        cout << ((ll)1 << (N - 1)) << endl;
    }
}

Measured memory_bytes: 3616
from collections import deque

n = int(input())
a = list(map(int, input().split()))

b = deque([])
rev = 1
for i in a:
    if rev == 1:
        b.append(i)
    elif rev == -1:
        b.appendleft(i)
    rev *= -1

print(*(b if rev == 1 else list(b)[::-1]))


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

#define MAX_N 100000

int N;
int A[MAX_N];
vector<int> G[MAX_N];

int dp[MAX_N];

bool dfs(int u, int p)
{
  // 葉は必ず貫いて通過する
  if(G[u].size() == 1) {
    dp[u] = A[u];
    return true;
  }

  for(int& v : G[u]) {
    if(v == p) continue;
    if(!dfs(v, u)) return false;
  }

  int sum = 0;
  for(int& v : G[u]) {
    if(v != p) sum += dp[v];
  }

  // uを貫いて通過するか折り返すかの2通り

  if(sum < A[u] || sum > 2*A[u]) return false;

  dp[u] = 2*A[u] - sum;

  int mx = 0;
  for(int& v : G[u]) {
    if(v != p) mx = max(mx, dp[v]);
  }

  if(A[u] < mx) return false;
  return true;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N;
  rep(i, N) cin >> A[i];

  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  if(N == 2) {
    cout << (A[0] == A[1] ? "YES" : "NO") << endl;
    return 0;
  }

  int root = 0;
  while(root < N && G[root].size() == 1) root++;
  cout << (dfs(root, -1) && dp[root] == 0 ? "YES" : "NO") << endl;

  return 0;
}


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

main() {
  int a;
  string c;
  cin >> a;
  
  for (int i = 0; i < a; i++) {
    cin >> c;
    if(c == "Y") {
      cout << "Four" <<endl;
      break;
    }
    if(i == a-1)
      cout << "Three" <<endl;
  }
}
     

Measured memory_bytes: 256
from heapq import heappush, heappop

n, m = map(int, input().split())
a = list(map(int, input().split()))

heapq = []
for i in range(n):
    heappush(heapq, -a[i])
    
for i in range(m):
    saidai = heappop(heapq)
    heappush(heapq, -(-saidai//2))

cost = 0
for i in range(n):
    cost += -heappop(heapq)

print(cost)

Measured memory_bytes: 14180
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        while (true) {
            int x = scan.nextInt(), y = scan.nextInt();

            if (x == 0 && y == 0) {
                break;
            }
            System.out.println(x < y? x + " " + y : y + " " + x);
        }
    }
}

Measured memory_bytes: 36468
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
 	string s;
 	cin>>s;
 	int i,n=s.length();
 	ll val,x,cnt[26]={0};
 	rep(i,s.length()){
 		cnt[s[i]-'a']++;
 	}
 	val=n;
 	val*=(n-1);
 	val/=2;
 	rep(i,26){
 		x=cnt[i];
 		x*=(cnt[i]-1);
 		x/=2;
 		val-=x;
 	}
 	cout<<val+1<<endl;

} 


Measured memory_bytes: 720
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <utility>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = (int) s.length();
    int64_t result = 0;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'W') {
            result += i;
            result -= cnt;
            cnt += 1;
        }
    }
    cout << result << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	int n, ans = 0;
	int p[51];

	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &p[i]);
	}

	for (int i = 0; i < n; ++i) {
		if (p[i] != i+1) {
			ans += 1;
		}
	}
	printf(ans == 2 || ans == 0 ? "YES" : "NO");


	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> f(n);
  for(int i=1; i<sqrt(n); i++){
    for(int j=1; j<sqrt(n); j++){
      for(int k=1; k<sqrt(n); k++){
        int m=i*i+j*j+k*k+i*j+j*k+k*i;
        if(m<=n){
        f[m-1]++;
        } 
      }
    }
  }

  rep(i, n){
    cout << f[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
using cpx = complex<double>;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

vector<cpx> convexhull(vector<cpx> ps) {
    int k = 0, n = ps.size();
    sort(ps.begin(), ps.end(), [&](cpx a, cpx b) {
        return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
    });
    vector<cpx> res(2 * n);
    for (int i = 0; i < n; i++) {
        while (k > 1 && imag(conj(res[k - 1] - res[k - 2]) * (ps[i] - res[k - 1])) <= 0)
            k--;
        res[k++] = ps[i];
    }
    for (int i = n - 2, t = k; i >= 0; i--) {
        while (k > t && imag(conj(res[k - 1] - res[k - 2]) * (ps[i] - res[k - 1])) <= 0)
            k--;
        res[k++] = ps[i];
    }
    res.resize(k - 1);
    return res;
}

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

    int n;
    cin >> n;
    if (n == 2) {
        rep(i, 0, 2) cout << "0.5" << endl;
        return 0;
    }
    vector<cpx> a(n);
    rep(i, 0, n) {
        int x, y;
        cin >> x >> y;
        a[i] = cpx(x, y);
    }
    vector<cpx> b = convexhull(a);
    b.emplace_back(b[0]);
    map<pair<int, int>, double> mp;
    rep(i, 0, b.size() - 1) {
        cpx z = (b[i + 1] - b[i]) * cpx(0, -1);
        double t = arg(z);
        mp[{b[i].real(), b[i].imag()}] += t;
        mp[{b[i + 1].real(), b[i + 1].imag()}] -= t;
    }
    cout << fixed << setprecision(10);
    double s = acos(-1) * 2.0;
    rep(i, 0, n) {
        double x = mp[{a[i].real(), a[i].imag()}];
        if (x == 0) {
            cout << 0.0 << endl;
            continue;
        }
        if (x < 0) x += 2.0 * acos(-1);
        cout << x / s << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define F first
#define S second
#define MAXN   1000005
#define Tsetso ios_base::sync_with_stdio(0) ; cin.tie(0) ;
using namespace std;
const int N = 120, mod = 998244353 ;
int n, F[N][12], P[N][12];
int main()
{
    Tsetso ;
    cin >> n;
    for ( int i = 0 ; i < n ; i++)
        for ( int j = 0 ; j < 10 ; j++)
            cin >> F[i][j];
    for ( int i = 0 ; i < n ; i++)
        for ( int j = 0 ; j <= 10 ; j++)
            cin >> P[i][j];
    int  ans = -1e9 ;
    for ( int msk = 1 ; msk < (1<<10); msk++)
    {
        int res = 0;
        for ( int i = 0 ; i < n ; i++)
        {
            int cnt = 0 ;
            for ( int j = 0 ; j < 10 ; j++)
                if ( F[i][j] && (msk & (1<<j)))
                        cnt++ ;
            res += P[i][cnt];
        }
        ans = max(ans,res);
    }
    cout << ans;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string.h>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
int main()
{
	int n,a[100000][3],i,j,k;
	cin>>n;
	for(i=0;i<n;i++)
		for(j=0;j<3;j++)
			cin>>a[i][j];
	int b[100000][3]={0};
	for(i=0;i<3;i++)
		b[0][i]=a[0][i];
	for(i=1;i<n;i++)
	{
		for(j=0;j<3;j++)
		{
			for(k=0;k<3;k++)
				if(j!=k)
					b[i][j]=max(b[i][j],a[i][j]+b[i-1][k]);
				
		}
	}
	int ans=0;
	for(i=0;i<3;i++)
		ans=max(ans,b[n-1][i]);
	cout<<ans<<endl;
	
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
	ll N,A,B;
	cin>>N>>A>>B;
	ll res;
	if(A>B)res=0;
	else if(N==1&&A<B) res=0;
	else{
		ll ma=B*N-(B-A);
		ll mi=A*N+(B-A);
		res=ma-mi+1;
	}
	cout<<res<<endl;
	return 0;
}


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

long long n, q, s, t;

long long d(long long v) {
  if (v > 0) return -v * s;
  return -v * t;
}

int main() {
  cin >> n >> q >> s >> t;

  vector<long long> a(n + 1);
  for (auto &in : a) cin >> in;

  vector<long long> v;
  for (int i = 1; i < a.size(); ++i) {
    v.push_back(a[i] - a[i - 1]);
  }

  long long sum = 0;
  for (int i = 0; i < v.size(); ++i) {
    sum += d(v[i]);
  }

  while (q--) {
    long long l, r, x;
    cin >> l >> r >> x;
    l--;

    sum -= (d(v[l]) + d(v[r]));

    v[l] += x;
    if (r != n) v[r] -= x;

    sum += (d(v[l]) + d(v[r]));

    cout << sum << endl;
  }
}

Measured memory_bytes: 6516
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,n) for(ll i=n-1;i>=0;i--)
#define rloop(i,a,b) for(ll i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define precision cout<<fixed<<setprecision(10)
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
#define setbits(x) __builtin_popcountll(x)
const double pi=3.1415926535897932384626;
//const ll mod = 998244353;
const ll mod=1e9+7;
int main()
{
  IOS
  ll n;
  cin>>n;
  ll a[n];
  fo(i,n)
  cin>>a[i];
  ll s=0;
  for(ll i=1;i<n;i++)
    s=s^a[i];
  vector <ll> v;
  v.pb(s);
  for(ll i=1;i<n;i++)
  {
    s=s^a[i]^a[i-1];
    v.pb(s);
  }
  for(auto x:v)
    cout<<x<<" ";
  cout<<kk;
  return 0;
}

Measured memory_bytes: 6900
// https://atcoder.jp/contests/abc089/tasks/abc089_c

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

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

#define EPS (1e-7)
#define INF (1e9)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }

/* 組み合わせを作成 */
template <class BidirectionalIterator>
bool next_combination(BidirectionalIterator first1, BidirectionalIterator last1,
                      BidirectionalIterator first2,
                      BidirectionalIterator last2) {
    if ((first1 == last1) || (first2 == last2)) {
        return false;
    }
    BidirectionalIterator m1 = last1;
    BidirectionalIterator m2 = last2;
    --m2;
    while (--m1 != first1 && !(*m1 < *m2)) {
    }
    bool result = (m1 == first1) && !(*first1 < *m2);
    if (!result) {
        while (first2 != m2 && !(*m1 < *first2)) {
            ++first2;
        }
        first1 = m1;
        iter_swap(first1, first2);
        ++first1;
        ++first2;
    }
    if ((first1 != last1) && (first2 != last2)) {
        m1 = last1;
        m2 = first2;
        while ((m1 != first1) && (m2 != last2)) {
            iter_swap(--m1, m2);
            ++m2;
        }
        reverse(first1, m1);
        reverse(first1, last1);
        reverse(m2, last2);
        reverse(first2, last2);
    }
    return !result;
}

template <class BidirectionalIterator>
bool next_combination(BidirectionalIterator first, BidirectionalIterator middle,
                      BidirectionalIterator last) {
    return next_combination(first, middle, middle, last);
}

template <class BidirectionalIterator>
inline bool prev_combination(BidirectionalIterator first,
                             BidirectionalIterator middle,
                             BidirectionalIterator last) {
    return next_combination(middle, last, first, middle);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    long sum = 0;
    string s;
    cin >> n;
    int cnt[5] = {0};

    for (int i = 0; i < n; i++) {
        cin >> s;
        if (s[0] == 'M')
            cnt[0]++;
        else if (s[0] == 'A')
            cnt[1]++;
        else if (s[0] == 'R')
            cnt[2]++;
        else if (s[0] == 'C')
            cnt[3]++;
        else if (s[0] == 'H')
            cnt[4]++;
    }

    // n C k を計算
    const int N = 5;
    const int K = 3;
    array<int, N> ar;
    iota(ar.begin(), ar.end(), 0);
    do {
        long tmp = 1;
        for (int i = 0; i < K; i++) {
            tmp *= cnt[ar[i]];
        }
        sum += tmp;
    } while (next_combination(ar.begin(), ar.begin() + K, ar.end()));

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int sum = X;
		int count = 1;
		while(sum % 360 != 0) {
			sum = sum + X;
			count++;
//			System.out.println(sum);
		}

		System.out.println(count );
	}

}


Measured memory_bytes: 35660
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	int s,ans;
	while(1)
	{
		cin >> s;
		if(s==0)break;
		ans=0;
		while(1)
		{
			ans += s/5;
			s /= 5;
			if(s==0)break;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
s = input()
c = Counter(s)
res = 1
for key in list(c):
    res *= c[key]+1
    res %= mod
print((res-1)%mod)


Measured memory_bytes: 65516
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
ll n,t;
ll a[200005];
ll ans;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>t;
	for(int i=0;i<n;i++) cin>>a[i];
	ans+=t;
	for(int i=1;i<n;i++){
		ans+=t;
		if(a[i]<a[i-1]+t) ans-=a[i-1]+t-a[i]; 
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 5144
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=math.floor,math.ceil
from collections import deque
Yes=lambda b:print('Yes')if b else print('No');YES=lambda b:print('YES')if b else print('NO')
is_even=lambda x:True if x%2==0 else False

def is_palindrome(s):
  n=len(s);ans=True
  for i in range(int(0.5*n)):
    if s[i]!=s[n-i-1]:
      ans=False
  return ans

def main():
  s=input();n=len(s)
  Yes(is_palindrome(s)and is_palindrome(s[:int(0.5*(n-1))]))
  

if __name__ == '__main__':
  main()

Measured memory_bytes: 3316
import qualified Data.ByteString.Char8 as C
import qualified Data.IntSet as S
import Data.List

main = C.interact $ put . sol . get

get = unfoldr (C.readInt . C.dropWhile (==' ')) . last . C.lines

put = C.pack . show

sol = (\x -> (x-1)`div`2*2+1) . S.size . S.fromList


Measured memory_bytes: 2684
#include<stdio.h>

int main(){
  int T[5],t[5],sa[5];
  scanf("%d %d %d %d %d",&T[0],&T[1],&T[2],&T[3],&T[4]);
  int i;
  int num = 0;
  for(i=0;i<=4;i++){
    t[i] = T[i]/10;
    if(T[i] % 10 ==0)
    sa[i] = 0;
  else sa[i] = (t[i] + 1)*10 -T[i];
  };
  int max = 0;
  for(i=0;i<=4;i++)
    if(sa[i] > max) max = sa[i];
  int time;
  for(i=0;i<=4;i++)
    if(T[i] % 10 == 0) num++;
  time = (t[0] + t[1] + t[2] + t[3] + t[4] + 5 - num)*10 - max;
  printf("%d",time);
}

Measured memory_bytes: 128
a, b, c = sorted(map(int, input().split()))
ans = 0
if (b - a) % 2 == 0:
    ans += ((b - a) // 2)
else:
    b += 1
    c += 1
    ans += 1
    ans += ((b - a) // 2)
ans += (c - b)
print(ans)

Measured memory_bytes: 9076
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <limits>

using namespace std;

#include <iostream>
#include <vector>
#include <complex>

using namespace std;

typedef long double DOUBLE;
typedef complex<DOUBLE> COMPLEX;
typedef vector<DOUBLE> VD;
typedef vector<int> VI;
typedef vector<COMPLEX> VC;

struct FFT {
  VC A;
  int n, L;

  int ReverseBits(int k) {
    int ret = 0;
    for (int i = 0; i < L; i++) {
      ret = (ret << 1) | (k & 1);
      k >>= 1;
    }
    return ret;
  }

  void BitReverseCopy(VC a) {
    for (n = 1, L = 0; n < a.size(); n <<= 1, L++) ;
    A.resize(n);
    for (int k = 0; k < n; k++) 
      A[ReverseBits(k)] = a[k];
  }
  
  VC DFT(VC a, bool inverse) {
    BitReverseCopy(a);
    for (int s = 1; s <= L; s++) {
      int m = 1 << s;
      COMPLEX wm = exp(COMPLEX(0, 2.0 * M_PI / m));
      if (inverse) wm = COMPLEX(1, 0) / wm;
      for (int k = 0; k < n; k += m) {
	COMPLEX w = 1;
	for (int j = 0; j < m/2; j++) {
	  COMPLEX t = w * A[k + j + m/2];
	  COMPLEX u = A[k + j];
	  A[k + j] = u + t;
	  A[k + j + m/2] = u - t;
	  w = w * wm;
	}
      }
    }
    if (inverse) for (int i = 0; i < n; i++) A[i] /= n;
    return A;
  }

  // c[k] = sum_{i=0}^k a[i] b[k-i]
  VD Convolution(VD a, VD b) {
    int L = 1;
    while ((1 << L) < a.size()) L++;
    while ((1 << L) < b.size()) L++;
    int n = 1 << (L+1);

    VC aa, bb;
    for (size_t i = 0; i < n; i++) aa.push_back(i < a.size() ? COMPLEX(a[i], 0) : 0);
    for (size_t i = 0; i < n; i++) bb.push_back(i < b.size() ? COMPLEX(b[i], 0) : 0);
    
    VC AA = DFT(aa, false);
    VC BB = DFT(bb, false);
    VC CC;
    for (size_t i = 0; i < AA.size(); i++) CC.push_back(AA[i] * BB[i]);
    VC cc = DFT(CC, true);

    VD c;
    for (int i = 0; i < a.size() + b.size() - 1; i++) c.push_back(cc[i].real());
    return c;
  }

};

int main()
{
    long long P = 200003;
  	long long p2[200002];
  
  	p2[0] = 1;
    for (int i = 0; i < 200002-1;i++){
    	p2[i + 1] = (p2[i] * 2) % P;
    }
  
 	int rev[200003];
  	for (int i = 0; i < 200002; i++){
    	rev[p2[i]] = i;
    }	
  
	VD a = VD (P);
  	long long sub = 0;
  	long long n,v;
  	cin >> n;
  	for (int i = 0; i < n; i++){
    	cin >> v;
      	sub += (v * v) % P;
      	if (v != 0){
          a[rev[v]] += 1;
        }
    }
  	FFT fft;
	VD b = fft.Convolution(a, a);
	long long out = 0;
	for (int i = 0; i < b.size(); i++){
      	long long val = (b[i] + 0.5);
      	//if (val){
        //	cout << i << " " << val << "\n"; 
        //}
		out += val * p2[i % (P - 1)];
    }
  	out -= sub;
  	out /= 2;
  	cout << out;
	return 0;
}

Measured memory_bytes: 146024
#include "bits/stdc++.h"
using namespace std;
int main() {
	long N, M;
	cin >> N >> M;
	vector<long>P(M);
	vector<string>S(M);
	vector<bool>Ques(N, false);
	vector<long>Penalty(N, 0);
	long ans = 0, pena = 0;
	for (long i = 0; i < M; i++) {
		cin >> P.at(i) >> S.at(i);
		if (S.at(i) == "AC") {
			Ques.at(P.at(i) - 1) = true;
		}
		else if (S.at(i) == "WA" && !Ques.at(P.at(i) - 1)) {
			Penalty.at(P.at(i) - 1)++;
		}
	}
	for (long i = 0; i < N; i++) {
		if (Ques.at(i)) ans++;
		if (Ques.at(i)) pena += Penalty.at(i);
	}
	cout << ans << ' ' << pena << endl;
}

Measured memory_bytes: 7296
x_1,y_1,x_2,y_2 = gets.split.map(&:to_i)
if x_2 <= x_1 && y_1 <= y_2
    x_3 = x_2 - (y_2-y_1)
    y_3 = y_2 - (x_1-x_2)
    x_4 = x_3 + (x_1-x_2)
    y_4 = y_3 - (y_2-y_1)
elsif x_1 <= x_2 && y_1 <= y_2
    x_3 = x_2 - (y_2-y_1)
    y_3 = y_2 + (x_2-x_1)
    x_4 = x_3 - (x_2-x_1)
    y_4 = y_3 - (y_2-y_1)
elsif x_2 <= x_1 && y_2 <= y_1
    x_3 = x_2 + (y_1-y_2)
    y_3 = y_2 - (x_1-x_2)
    x_4 = x_3 + (x_1-x_2)
    y_4 = y_3 + (y_1-y_2)
elsif x_1 <= x_2 && y_2 <= y_1
    x_3 = x_2 + (y_1-y_2)
    y_3 = y_2 + (x_2-x_1)
    x_4 = x_3 - (x_2-x_1)
    y_4 = y_3 + (y_1-y_2)
end

puts "#{x_3} #{y_3} #{x_4} #{y_4}"



Measured memory_bytes: 1788
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())

for i in range(N):
    b = int(input())
    for t in range(3):
        if A1[t] == b:
            A1[t] = -1
        elif A2[t] == b:
            A2[t] = -1
        elif A3[t] == b:
            A3[t] = -1

if A1 == [-1, -1, -1] \
        or A2 == [-1, -1, -1] \
        or A3 == [-1, -1, -1] \
        or A1[1] == A2[1] == A3[1] == -1 \
        or A1[2] == A2[2] == A3[2] == -1 \
        or A1[0] == A2[0] == A3[0] == -1 \
        or A1[0] == A2[1] == A3[2] == -1 \
        or A1[2] == A2[1] == A3[0] == -1 \
        or A1[0] == A2[0] == A3[0] == -1 \
        or A1[1] == A2[1] == A3[1] == -1 \
        or A1[2] == A2[2] == A3[2] == -1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	int M,D;
	cin>>M>>D;
	int c=0;
	REP(i,M){
		int x=i+1;
		REP(j,D){
			int y=(j+1)%10;
			int z=(j+1)/10;
			if(y<=1||z<=1)continue;
			if(y*z==x){
				//cout<<y<<" "<<z<<" "<<x<<endl;
				c++;
			}
		}
	}
	
	cout<<c<<endl;
}

Measured memory_bytes: 256
hex_list = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']

x, y = map(str, input().split())
if(hex_list.index(x) > hex_list.index(y)):
  print(">")
elif(hex_list.index(x) < hex_list.index(y)):
  print("<")
else:
  print("=")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pll pair<int ,int >
#define ppll pair < pll , pll >
#define mod 1000000007
unsigned int bp(int n) // built_in_pop_count // 
{ 
    unsigned int count = 0; 
    while (n) { 
        n &= (n - 1); 
        count++; 
    } 
    return count; 
} 
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    char alpha[26] = {'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y'};
    string ans ="";
    while(n > 0){
        int m = n % 26;
        ans += alpha[m];
        if(m == 0){
            n -= 1;
        }
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans ;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
template<typename T>
class SegmentTree{
public:
    int n;
    vector<T> node;
    const T id = 0;
    SegmentTree(const vector<T>&d){
        n = 1;
        while(d.size() > n)n *= 2;
        node.resize(2 * n - 1, id);
        for(int i = 0; i < d.size(); i++){
            node[i + n - 1] = d[i];
        }
        for(int i = n - 2; i >= 0; i--){
            node[i] = node[2 * i + 1] | node[2 * i + 2];
        }
    }
    SegmentTree(int sz){
        n = 1;
        while(n < sz)n *= 2;
        node.resize(2 * n - 1, id);
    }
    void update(int x, T k){
        x += n - 1;
        node[x] = k;
        while(x){
            x = (x - 1) / 2;
            node[x] = node[2 * x + 1] | node[2 * x + 2];
        }
    }
    T query(const int a, const int b, int k = 0, int l = 0, int r = -1){
        if(r < 0)r = n;
        if(r <= a or b <= l){
            return id;
        }
        if(a <= l and r <= b){
            return node[k];
        }else{
            T lv = query(a, b, 2 * k + 1, l, (l + r) / 2);
            T rv = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return lv | rv;
        }
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    string s;
    cin >> n >> s >> q;
    SegmentTree<int> seg(n);
    rep(i,n){
        seg.update(i, 1 << (s[i] - 'a'));
    }
    while(q--){
        int t;
        cin >> t;
        if(t == 1){
            int i;
            char c;
            cin >> i >> c;
            seg.update(i - 1, 1 << (c - 'a'));
        }else{
            int l, r;
            cin >> l >> r;
            cout << __builtin_popcount(seg.query(l - 1, r)) << "\n";
        }
    }
}


Measured memory_bytes: 5020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define ll long long
#define pp pair<int,int> 
//int 2×10の9乗

//vector<vector<int>> a(n, vector<int>(m));
  //rep(i,n){
    //rep(j,m) cin >> a[i][j]; 
  //}
 
int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  reverse(h.begin(), h.end());
  int ans = 0;
  int val = 0;
  for (int i = 1; i < n; i++) {
    if (h[i-1] <= h[i]) val++;
    else val = 0;
    ans = max(ans, val);
  }
  cout << ans << endl;
} 

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

using namespace std;

int main()
{
	string res;
	long long n;
	cin>>n;
	res = "";
	while (n > 0)
	{
		n --;
		res = char('a' + n % 26) + res;
		n /= 26;
	}
	cout<<res<<endl;
	return 0;
}

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

int main() {
	int low = 9, total = 0;
	bool check = true;
	for(int i = 0, k; i<5; i++){
		cin >> k;
		if(k%10 != 0){
			total += (k/10)*10+10;
			low = min(low, k%10);
			check = false;
		}
		else{
			total += k;
		}
	}

	if(!check)	
		cout << total-10+low << endl;
	else
		cout << total << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 998244353;
ll fact[210200];
ll invfact[210200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll powMod(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return powMod(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

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

    ll h[101000], dp[101000];
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    for(int i = N; i <= N+K; i++){
        h[i] = 1e9+7;
    }

    fill(dp, dp+101000, 1e9+7);
    dp[0] = 0;
    for(int i = 0; i < N; i++){
        for(int j = 1; j <= K; j++){
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
        }
    }

    cout << dp[N-1] << endl;


    return 0;
}


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

const ll INF=1e14;

int main() {
  int n; cin>>n;
  vector<ll> a(n);
  for (int i=0; i<n; i++) cin>>a[i];

  vector<ll> b(n+1, 0);
  for (int i=0; i<n; i++) b[i+1]=b[i]+a[i];

  vector<vector<ll>> dp(n, vector<ll>(n, INF));
  for (int i=0; i<n; i++) dp[i][i]=0;

  ll res=0;
  for (int length=2; length<=n; length++) {
    for (int left=0; left+length-1<n; left++) {
      int right=left+length-1;
      for (int k=left; k<right; k++) {
        ll cost=b[right+1]-b[left];
        dp[left][right]=min(dp[left][right], dp[left][k]+dp[k+1][right]+cost);
      }
    }
  }
  cout<<dp[0][n-1]<<endl;
}


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

Measured memory_bytes: 1024
N = int(input())
s = [input() for i in range(N)]

count_ac = s.count('AC')
count_wa = s.count('WA')
count_tle = s.count('TLE')
count_re = s.count('RE')

print('AC x', count_ac)
print('WA x', count_wa)
print('TLE x', count_tle)
print('RE x', count_re)

Measured memory_bytes: 16300
use proconio::{input, marker::Chars};

fn main() {
    input! {
        s: Chars,
    }

    let mut ans = 0;

    for i in 0..s.len()/2 {
        if s[i] != s[s.len()-i-1] {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2112
//love yjl forever
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF=0x3f3f3f3f,N=3000+5;
const ll mo=998244353;
ll n,s;
ll a[N];
ll dp[N];
ll ans;
int main()
{
/*	freopen("","r",stdin);
	freopen("","w",stdout);*/
	int i;
	cin>>n>>s;
	for(i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	
//	dp[0]=1;
	for(i=1;i<=n;i++)
	{
		if(a[i]>s) continue;		
		if(a[i]==s)
			ans=(ans+(n-i+1)*i%mo)%mo;
		else 
			ans=(ans+dp[s-a[i]]*(n-i+1)%mo)%mo;
		

			
		for(int j=s;j>0;j--)
		{
			if(j+a[i]<s)
				dp[j+a[i]]=(dp[j+a[i]]+dp[j])%mo;
		}
		if(a[i]<s)
			dp[a[i]]=(dp[a[i]]+i)%mo;

	}
	cout<<ans<<endl;
}

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

main() {
  int N;
  cin >> N;
  
  vector<string> W(N);
  for(int i=0; i<N; i++)
    cin >> W.at(i);
  
  string Ans="Yes";
  
  for(int i=0; i<N-1; i++){
    string a=W.at(i);
    string b=W.at(i+1);
    if(a.back() != b.front()){
      Ans ="No";
      cout << Ans;
      return 0;
    }  
  }
  
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N; j++){
      if(W.at(i) == W.at(j)){
        Ans ="No";
        cout << Ans;
        return 0;
      }  
    } 
  }
  cout << Ans;
  return 0;
}  
  
    
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;

int main(){
  int n,k,q;
  cin>>n>>k>>q;
  vector<int> shouri(n,k+(-1)*q);
  rep(i,q){
    int m;
    cin>>m;
    shouri[m-1]++;
  }
  rep(i,n){
    if(shouri[i]>0){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
}

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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;cin>>n;
  int a[n],b[n],c[n];
  rep(i,n){
    cin>>a[i];
    --a[i];
  }
  rep(i,n)cin>>b[i];
  rep(i,n-1)cin>>c[i];
  int cnt=0;
  rep(i,n){
    if(i!=n-1){
      if(a[i]+1==a[i+1]){
        cnt+=c[a[i]];
      }
    }
    cnt+=b[a[i]];
  }
  cout<<cnt<<endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

bool is_good(string n, set<char> s = {'2', '8'}) {
    EACH(d, n) {
        if (s.count(d) == 0) {
            return false;
        }
    }
    return true;
}
ll power(ll x, ll n) {
    ll res = 1;
    REP(i, n) res *= x;
    return res;
}
vector<ll> gns;
ll solve(ll n, ll idx) {
    if (idx == gns.size()) return -1;
    ll res = -1;
    if (is_good(to_string(n))) res = max(res, 1LL);
    if (n % gns[idx] == 0) {
        ll r = solve(n/gns[idx], idx);
        if (r >= 0) {
            res = max(res, r+1);
        }
    }
    res = max(res, solve(n, idx+1));
    return res;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    string nstr; cin >> nstr;
    ll n = stoll(nstr);
    vector<ll> gn = {2, 8};
    FOR(w, 1, 17) {
        REP(i, (1<<w)) {
            ll val = 0;
            REP(j, w) {
                val = val * 10 + gn[(i>>(w-j-1))&1];
            }
            if (val == 222888288 || is_good(to_string(val), {'8'})) continue;
            if (n % val == 0) gns.pb(val);
        }
    }
    cout << solve(n, 0) << endl;
}

Measured memory_bytes: 3284