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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
    int N, D;
    cin >> N >> D;
    cout << (N / (D*2+1) + (N % (D*2+1) != 0)) << endl;
}


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

using namespace std;

typedef long long int ll;

const ll N = 105;

int dp[N][N][305];

vector < int > wt(N), val(N);

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

  int n, W;
  cin >> n >> W;
  for(int i = 1; i <= n; i++){
    cin >> wt[i] >> val[i];
    if(i != 1) wt[i] = wt[i] - wt[1];
  }

  int tmp = wt[1];
  wt[1] = 0;

  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      for(int k = 0; k < 305; k++) dp[i][j][k] = -1e9;
      dp[i][j][0] = 0;
    }
  }


  int ans = 0;
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= i; j++){
      for(int k = 0; k < 305; k++){
        if(k - wt[i] >= 0) dp[i][j][k] = max(dp[i - 1][j - 1][k - wt[i]] + val[i], dp[i][j][k]);
        dp[i][j][k] = max(dp[i - 1][j][k], dp[i][j][k]);

        if((ll)j * (ll)tmp + (ll)k <= W) ans = max(ans, dp[i][j][k]);

        //if(dp[i][j][k] >= 0) cout << " dp[" << i << "][" << j << "][" << k << "] = " << dp[i][j][k] << " ans = " << ans << '\n';
      }
    }
  }

  cout << ans << '\n';
}


Measured memory_bytes: 16780
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    double ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += 1.0/v[i];
    }
    cout << setprecision(15) << 1/ans << "\n";
    return 0;
}

Measured memory_bytes: 256
// ~/Remember,remember the 6th of March
#include <functional>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<complex>
#include <unordered_map>
#include<unordered_set>
#include <numeric>
#include <string>
#include<iostream>
#include <fstream>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int N = 1000007;
void fast()
{
	std::ios_base::sync_with_stdio(0);
}

int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//	freopen("output.txt","w",stdout);
#endif*/

	int n, m;
	cin >> n >> m;
	vector<int>arr = { 300000,200000,100000 };
	int res = 0;
	if (n < 4)
		res += arr[n - 1];
	if (m < 4)
		res += arr[m - 1];
	if (n == 1 && m == 1)
		res += 400000;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <map>
#include <sstream>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    map<string, int> dic;
    string str, sfmax, slmax, tmp;
    int fmax = 0, lmax = 0;
    getline(cin, tmp);
    stringstream stream(tmp);
    while (getline(stream, str, ' ')){
    	dic[str]++;
    	if (fmax < dic[str]){
    		fmax = dic[str];
    		sfmax = str;
    	}
    	if (lmax < str.length()){
    		lmax = str.length();
    		slmax = str;
    	}
    }
    cout << sfmax << ' ' << slmax << endl;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int inf = 1<<30;
const ll mod = 1000000007;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

int main () {
  int K, X; cin >> K >> X;
  for (int i = X-K+1; i<=X+K-1; i++) {
    cout << i << endl;
  }
}

Measured memory_bytes: 256
loop do
  board = Array.new(3)
  break if (board[0] = $<.gets.chomp) == "0"
  board[1] = $<.gets.chomp
  board[2] = $<.gets.chomp
  
  check = ->(c) {
    gl = c * 3
    return true if board.map {|b| b == gl}.any?
    return true if 3.times.map {|i| board.map {|b| b[i]}.join == gl }.any?
    return true if board[0][0] + board[1][1] + board[2][2] == gl 
    return true if board[0][2] + board[1][1] + board[2][0] == gl
    false
  }
  str = case
        when check.("b") then "b"
        when check.("w") then "w"
        else "NA"
        end
  puts str
end


Measured memory_bytes: 6880
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,pas,f[209],z;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a>>b;
    for(c=1; c<=a; c++){
        f[c]=c+b-1;
        pas+=f[c];
    }
    z=abs(f[1]);
    e=1;
    for(c=2; c<=a; c++){
        if(z>abs(f[c])){
            z=abs(f[c]);
            e=c;
        }
    }
    cout<<pas-f[e];
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int H = sc.nextInt();
			int N = sc.nextInt();
			int[] A = new int[N];
			int[] B = new int[N];
			int max = 0;
			for (int i = 0; i < N; i++) {
				int a = sc.nextInt();
				A[i] = a;
				B[i] = sc.nextInt();
				if (a > max)
					max = a;
			}
			int[] dp = new int[H + max];
			for (int i = 1; i < H + max; i++) {
				dp[i] = -1;
			}
			for (int j = 0; j < H; j++) {
				for (int i = 0; i < N; i++) {
					if (dp[j] == -1) {
						continue;
					}
					if (dp[j] + B[i] < dp[j + A[i]] || dp[j + A[i]] == -1) {
						dp[j + A[i]] = dp[j] + B[i];
					}
				}
			}
			int ans = Integer.MAX_VALUE;
			for (int i = H; i < H + max; i++) {
				if (dp[i] < ans && dp[i] != -1) {
					ans = dp[i];
				}
			}
			System.out.print(ans);
		}
	}
}


Measured memory_bytes: 28164
// ORZ YJZ
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define rep(i,a,b) for(int (i) = (a); (i) <= (b); i++)
#define repd(i,a,b) for(int (i) = (a); (i) >= (b); i--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define mp make_pair
#define pb push_back
using namespace std;
#define is_digit(c) ((c) >= '0' && (c) <= '9')
#define is_upper(c) ((c) >= 'A' && (c) <= 'Z')
#define is_lower(c) ((c) >= 'a' && (c) <= 'z')
#define readchar() ((char)fgetc(stdin))
#define printchar(c) fputc((c), stdout)
void readline(char *s) {int len=0;char c;for(c=readchar(); c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void readstr(char *s) {int len=0;char c;for(c=readchar(); c!=' '&&c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void printstr(const char *s) {int len=strlen(s);rep(i,0,len-1) printchar(s[i]);}
void to_lower(char *s, int L, int R) {rep(i,L,R) if (is_upper(s[i])) s[i]=s[i]-'A'+'a';}
void to_upper(char *s, int L, int R) {rep(i,L,R) if (is_lower(s[i])) s[i]=s[i]-'a'+'A';}
ll readll() {
	char c;ll ans=0, x=1;for (c=readchar(); !is_digit(c)&&c!='-'; c=readchar());
	if (c=='-') x=-1, c=readchar();for (; is_digit(c); ans=ans*10+c-'0', c=readchar());return ans*x;
}
void printll(ll x) {
	int a[25], cnt=0;if (x==0) { printchar('0'); return; }if (x<0) printchar('-'), x=-x;
	for (; x; a[cnt++]=x-x/10*10, x/=10);repd(i,cnt-1,0) printchar(a[i]+'0');
}
#define readint() ((int)readll())
#define printint(x) printll((ll)(x))
string s;
char tmp[100005];
bool is[100005];
int main() {
	readstr(tmp);
	int n=strlen(tmp);
	s="X"+(string)tmp;
	is[0]=1;
	rep(i,1,n) {
		if (i>=5&&s.substr(i-4,5)=="dream") is[i]|=is[i-5];
		if (i>=7&&s.substr(i-6,7)=="dreamer") is[i]|=is[i-7];
		if (i>=5&&s.substr(i-4,5)=="erase") is[i]|=is[i-5];
		if (i>=6&&s.substr(i-5,6)=="eraser") is[i]|=is[i-6];
	}
	printstr(is[n]?"YES":"NO");
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;
ll d[mm];
int main()
{
   ll n,m,i,j,t,a,b,c,p,k,kk; 
     char l;
     cin>>l;
     if(l>='a'&&l<='z')
	 printf("a\n");
	 else 
	 printf("A\n"); 
	  
	 
} 

Measured memory_bytes: 3028
<?php
while (($input = trim(fgets(STDIN))) !== '') {
	$input = intval($input);
	$count = 0;
	for ($i=0; $i < 10; $i++) { 
		for ($j=0; $j < 10; $j++) { 
			for ($k=0; $k < 10; $k++) { 
				for ($l=0; $l < 10; $l++) { 
					if ($i + $j + $k +$l === $input) {
						$count++;
					}
				}
			}
		}
	}
	echo $count."\n";
}

Measured memory_bytes: 15056
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s.substr(0,4)<="2019"){
		if(s.substr(5,2)<="04"){
			if(s.substr(8,2)<="30"){
				cout<<"Heisei"<<endl;
				return 0;
				}
			}
		}
	cout<<"TBD"<<endl;
	return 0;
}


Measured memory_bytes: 256
N,M,X=map(int,input().split())
AM=list(map(int,input().split()))
Ns=[0]*(N+1)
for a in AM:
  Ns[a]=1
  pass

i = X
mincost,cost=0,0
while i != 0:
  if Ns[i] == 1:cost+=1
  i-=1
  pass
mincost=cost
cost,i=0,X
while i != N:
  if Ns[i] == 1:cost+=1
  i+=1
  pass
mincost=min(mincost,cost)
print(mincost)


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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (int)(n); ++i)
#define fj(st,n) for (int j = (st); j <= (int)(n); ++j)
#define fk(st,n) for (int k = (st); k <= (int)(n); ++k)
#define fq(st,n) for (int q = (st); q <= (int)(n); ++q)
#define fw(st,n) for (int w = (st); w <= (int)(n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (int)(n); ++(i))
#define ei(st,n) for (int i = (st); i >= (int)(n); --i)
#define ej(st,n) for (int j = (st); j >= (int)(n); --j)
#define ek(st,n) for (int k = (st); k >= (int)(n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (int)(n); --(i))
#define ri(st,n) for (int i = (st); i < (int)(n); ++i)
#define rj(st,n) for (int j = (st); j < (int)(n); ++j)
#define rk(st,n) for (int k = (st); k < (int)(n); ++k)
#define rq(st,n) for (int q = (st); q < (int)(n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (int)(n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 1e5 + 5;
const int MX = (int) 1e5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(15);
//srand(time(0));

int n, k1, k2, k4;
int a[maxn];


int main()
{
//    fin("t.in");
    sync;
    cin >> n;
    fi(1, n)
    {
    	cin >> a[i];
    	if (a[i] % 4 == 0)
    		k4++;
    	else
    	if (a[i] % 2 == 0)
    		k2++;
    	else
    		k1++;
    }
    if (k1 <= k4 || (k1 == k4 + 1 && k2 == 0))
    	cout << "Yes" << endl;
    else
    	cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 640
K = input()
D = int(input())
L = len(K)
MOD = 10**9+7
dp = [[[0]*D for j in range(2)] for i in range(L+1)] #dp[i][less][modD]
dp[0][0][0] = 1
for i,c in enumerate(K):
    for less in range(2):
        lim = 9 if less else int(c)
        for r in range(D):
            for d in range(lim+1):
                dp[i+1][less or d < lim][(r+d)%D] += dp[i][less][r]
                dp[i+1][less or d < lim][(r+d)%D] %= MOD

print((dp[-1][0][0] + dp[-1][1][0] - 1) % MOD)

Measured memory_bytes: 65244
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n, c=0;
    cin>>n;
    int a[n+1], b[n];
    for(int i=0; i<=n; i++)
    {
        cin>>a[i];
    }
    for(int i=0; i<n; i++)
    {
        cin>>b[i];
    }
    for(int i=n-1; i>=0; i--)
    {
        if(b[i]>=a[i+1])
        {
            c+=a[i+1];
            b[i] -= a[i+1];
            a[i+1]=0;
        }
        else
        {
            c+=b[i];
            a[i+1]-= b[i];
            b[i]=0;
        }
        if(b[i]>=a[i])
        {
            c+=a[i];
            a[i]=0;
        }
        else
        {
            c+=b[i];
            a[i]-=b[i];

        }
    }
    cout<<c<<endl;

}

Measured memory_bytes: 4384
import sys
A, B, K = map(int, input().split())

if A >= K:
    A -= K
    print(A, B)
    sys.exit(0)
else:
    K -= A
    if B >= K:
        B -= K
        print(0, B)
        sys.exit(0)
    else:
        print(0, 0)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
int main()
{
	long long ans=0;
	string s;	cin>>s;
	for(int i=0;i<s.size();i++)
		ans+=s[i]-'0';
	if(ans%9==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 3704
import Control.Applicative
import Control.Monad


main = do
  [n,x] <- map read . words <$> getLine :: IO [Int]
  ms <- replicateM n $ read <$> getLine :: IO [Int]
  print $ n + solve ms x

solve ms x =
  div rest m  
  where
    rest = x - sum ms
    m = minimum ms
  
  
  
  


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

ll solve() {
    ll N;
    cin >> N;
    ll ans = 0;
    for ( ll i = 1; i <= N; i++ ) {
        for ( ll k = i; k <= N; k+=i ) {
            ans += k;
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;
public class Main{
        public static void main(String[] args){
             Scanner sc = new Scanner(System.in);
             int n,i,P,Q,R,C,han;
             int[] p = new int[1000];
             int[] q = new int[1000];
             int[] r = new int[1000];
             int[] kei = new int[1000];
             int[] hoz = new int[1000];
        n = sc.nextInt();
        while(n!=0){
            for(int j=0; j<n; j++){
                i = sc.nextInt();
                p[j] = sc.nextInt();
                q[j] = sc.nextInt();
                r[j] = sc.nextInt();
                kei[j] = ((p[j]*4)+(q[j]*9)+(r[j]*4));
                hoz[j] = i;
            }
            P = sc.nextInt();
            Q = sc.nextInt();
            R = sc.nextInt();
            C = sc.nextInt();
            han = 0;
            for(int j=0; j<n; j++){
                if(p[j]>P || q[j]>Q || r[j]>R || kei[j]>C){
                }else{
                    han+=1;
                    System.out.println(hoz[j]);
                }
            }
            if(han==0){
                System.out.println("NA");
            }
            n = sc.nextInt();
        }
    }
}

Measured memory_bytes: 64116
N = int(input())
T = list(map(int,input().split()))
M = int(input())
for i in range(M):
    Pi,Xi=map(int,input().split())
    a = T[Pi-1]
    T[Pi-1] = Xi
    b = 0
    for j in range(N):
        b = b + T[j]
    print(b)
    T[Pi-1] = a

Measured memory_bytes: 9000
from sys import stdin
import numpy as np
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    A=np.array([list(map(int,readline().split())) for _ in range(n)],dtype="int64")

    ans=-float("inf")
    for i in (-1,1):
        for j in (-1,1):
            for k in (-1,1):
                B=np.array([i,j,k],dtype="int64")
                res=np.sort(np.dot(A,B))[::-1][:m].sum()
                ans=max(ans,res)
                
    print(ans)
    
if __name__=="__main__":
    main()

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

int memo[10][10];
int uenoketa(int x) {
    while(x >= 10) {
        x /= 10;
    }
    return x;
}
int sitanoketa(int x) {
    return x % 10;
}
int main() {
	int n;cin >> n;
	for (int i = 1; i <= n; ++i) {
	    int ue   = uenoketa(i);
	    int sita = sitanoketa(i);
	    memo[ue - 1][sita - 1]++;
	}
	int ans = 0;
	for (int i = 0; i < 10; ++i) {
	     for (int j = 0; j < 10; ++j) {
	         ans += memo[i][j] * memo[j][i];
	     }
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

import copy
import itertools

from functools import lru_cache
#@lru_cache(maxsize = None)

# 整数の入力
#n = int(input())

# スペース区切りの整数の入力
#a = [x for x in map(int, input().split())]
n, m = map(int, input().split())
#print("sp", n, q, file=sys.stderr)

# 改行区切りの整数の入力
a = []
for x in range(m):
  a.append([int(x) for x in input().split()])
p = [int(x) for x in input().split()]

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))

#cache = dict()


def doit(s):
  ok = True
  for x in range(m):
    res = 0
    for y in range(a[x][0]):
      if s[a[x][y+1]-1] == 1:
        res = res + 1
    #print("res", res, file=sys.stderr)
    if res % 2 != p[x]:
      ok = False
      break
  #print("ok", ok, file=sys.stderr)
  return ok

def createSw(n):
  if n <= 1:
    return [[0,], [1,]]

  ret = []
  for x in createSw(n-1):
    #print("sw0", x, file=sys.stderr)
    ret.append(x + [0])
    ret.append(x + [1])
    #print("ret", ret, file=sys.stderr)
  #print("ret", ret, file=sys.stderr)
  return ret

#print(doit([0] * 4))
try:
  res = 0
  for x in createSw(n):
    if doit(x):
      res = res + 1
  print(res)
except Exception as e:
  print("e", e, file=sys.stderr)


Measured memory_bytes: 3964
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

std::vector<int> count(int N) {
  std::vector<int> values(N);
  for (int i = 0; i < N; i++) {
    std::cin >> values[i];
  }
  std::vector<int> ret(1500000);
  for (int i = 0; i < N; i++) {
    int sum = 0;
    for (int j = i; j < N; j++) {
      sum += values[j];
      ret[sum]++;
    }
  }
  return ret;
}

int solve(int N, int M) {
  auto N_values = count(N);
  auto M_values = count(M);
  int sum = 0;
  for (int i = 0; i < N_values.size(); i++) {
    sum += N_values[i] * M_values[i];
  }
  return sum;
}

int main() {
  int N, M;
  while(std::cin >> N >> M) {
    if (N == 0 && M == 0) {
      break;
    }
    std::cout << solve(N, M) << std::endl;
  }
}

Measured memory_bytes: 14468
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> vector<T> divisor(T n){
    vector<T> res;
    for (long long i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i * i != n) { res.emplace_back(n/i); }
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    long long n;
    cin >> n;
    vector<long long> div = divisor(n), v = divisor(n - 1);
    
    auto f = [&] (long long k) {
        if (k == 1) return false;
        long long x = n;
        while (x % k == 0) x /= k;
        return (x % k == 1);
    };
    
    set<long long> ans;
    for (const auto &e : div) if (f(e)) ans.emplace(e);
    for (const auto &e : v) if (e != 1) ans.emplace(e);
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] num = new int[6];
		for (int i = 0; i < 6; i++) {
			num[i] = sc.nextInt();
		}
		Dice dice = new Dice(num);
		String str = sc.next();
		dice.order(str);
		System.out.println(dice.getFace());
		sc.close();
	}
}

class Dice {

	private int face[] = new int[6];

	Dice(int[] num) {
		for (int i = 0; i < 6; i++) {
			this.face[i] = num[i];
		}
	}

	public void order(String str) {
		char[] order = str.toCharArray();
		for (int i = 0; i < order.length; i++) {
			switch (order[i]) {
			case 'N':
				rollToNorth();
				break;
			case 'S':
				rollToSouth();
				break;
			case 'E':
				rollToEast();
				break;
			case 'W':
				rollToWest();
				break;
			}
		}
	}

	public void rollToNorth() {
		int tmp;
		tmp = face[0];
		face[0] = face[1];
		face[1] = face[5];
		face[5] = face[4];
		face[4] = tmp;
	}

	public void rollToSouth() {
		int tmp;
		tmp = face[0];
		face[0] = face[4];
		face[4] = face[5];
		face[5] = face[1];
		face[1] = tmp;
	}

	public void rollToEast() {
		int tmp;
		tmp = face[0];
		face[0] = face[3];
		face[3] = face[5];
		face[5] = face[2];
		face[2] = tmp;
	}

	public void rollToWest() {
		int tmp;
		tmp = face[0];
		face[0] = face[2];
		face[2] = face[5];
		face[5] = face[3];
		face[3] = tmp;
	}

	public int getFace() {
		return face[0];
	}
}


Measured memory_bytes: 26308
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

main :: IO ()
main = do
	r <- readLn :: IO Double
	print $ 3.141592654 * 2 * r 

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x = max(a, c);
  int y = min(b, d);
  if(y-x>0) cout << y-x << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3556
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

const string NO = "-1";
signed main() {
    int N, K; cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }

    vector<int> ans;
    int rem = K+1, pre = -1;
    while(rem) {
        int piv = -1, mi = INF;
        for(int i=0; i<N; i++) {
            if(i == pre) continue;
            if(A[i] < mi) {
                piv = i;
                mi = A[i];
            }
        }
        // fprintf(stderr, "# piv = %lld, pre = %lld\n", piv, pre);

        if(A[piv] == 0) {
            cout << NO << endl;
            return 0;
        }

        for(int i=0; i<N; i++) {
            if(i != piv and i != pre) {
                ans.push_back(i + 1);
                // fprintf(stderr, "# %lld\n", i + 1);
                A[i]--;
            }
        }

        ans.push_back(piv + 1);
        // fprintf(stderr, "# %lld\n", piv + 1);
        A[piv]--;

        rem--;
        pre = piv;
    }

    cout << ans.size() << endl;
    for(size_t i=0; i<ans.size(); i++) {
        cout << ans[i] << " \n"[i + 1 == ans.size()];
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr <<__LINE__<< ": " << #x << " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
}

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


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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    ll n;
    cin >> n;
    vector <ll> a(n), b(n), c(n);
    ll ans[n][3] = {0};
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];

    ans[0][0] = a[0];
    ans[0][1] = b[0];
    ans[0][2] = c[0];

    for (int i = 1; i < n; i++) {
        chmax(ans[i][0], max(ans[i-1][1], ans[i-1][2]) + a[i]);
        chmax(ans[i][1], max(ans[i-1][0], ans[i-1][2]) + b[i]);
        chmax(ans[i][2], max(ans[i-1][0], ans[i-1][1]) + c[i]);
    }
    cout << max({ans[n-1][0], ans[n-1][1], ans[n-1][2]}) << endl;
    return 0;
}



Measured memory_bytes: 4992
S = gets.chomp.split("").to_a
T = gets.chomp.split("").to_a

cnt1 = []
cnt2 = []

S.uniq.each do |i|
  cnt1 << S.count(i)
end

T.uniq.each do |i|
  cnt2 << T.count(i)
end

if cnt1.sort == cnt2.sort then
  puts "Yes"
else
  puts "No"
end


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

using namespace std;

int main(){
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  int aa=0,bb=0,cc=0; //ccは偶数
  int cc_max;
  if(X>=Y) cc_max = X;
  else cc_max = Y;
  int min;
  for(cc=0;cc <= cc_max*2;cc+=2){
    aa=X-(cc/2);
    bb=Y-(cc/2);
    if(aa<0) aa=0;
    if(bb<0) bb=0;
    int answer = A*aa + B*bb + C*cc;
    if(cc==0) min = answer;
    if(answer<min) min = answer;
  }

  cout << min << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	string s;
	cin>>s;
	bool flag=true;
	rep(i,s.size()){
		if(i%2!=0 && s[i]=='R') flag=false;
		if(i%2==0 && s[i]=='L') flag=false;
	}
	cout<<(flag?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

while True:
    n, w = map(int, raw_input().split())
    if n == 0:
        break
    lst = []
    for i in range(n):
        num = input()
        num /= w
        lst.append(num)
    max_num = max(lst)

    ans = 0.0
    cnt = [0 for i in range(100)]
    for i in range(n):
        num = max_num - lst[i]
        ans += num
        cnt[num] += 1
    
    max_cnt = max(cnt)
    print ans / max_num / max_cnt + 0.01
    pass


Measured memory_bytes: 5072
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)

    val x = sc.nextLong()

    var count = 1L

    var nums = Vector(0L)
    var map = Map[Long, Long]()
    map = map + (0L -> 0L)

    while (math.pow(count, 5) <= x * x) {
      val n = math.pow(count, 5).toLong
      nums = nums :+ n
      nums = nums :+ (-n)
      map = map + (n -> count) + (-n -> -count)
//      debug(count, n)
      count += 1
    }

    val index = (count - 1) * 2 + 1
    debug(nums.length, index)

    for {
      i <- 0 until index.toInt
      j <- 0 until index.toInt
    } {
      if (nums(i) - nums(j) == x) {
        println(s"${map(nums(i))} ${map(nums(j))}")
        sys.exit(0)
      }
    }
  }

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }

  def printExecTime(process: => Unit): Unit = {
    val start = System.currentTimeMillis
    process
    debug("処理時間： " + (System.currentTimeMillis - start) + " ミリ秒")
  }

}


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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N + 1, 0), D(N + 1, 0), E(N + 1, 0), F(N + 1, 0);
    rep(i, N) {
        cin >> A[i];
        E[A[i]]++;
    }
    rep(i, N) {
        cin >> B[i];
        F[B[i]]++;
    }
    rep(i, N) {
        if (E[i + 1] + F[i + 1] > N) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    rep(i, N) {
        C[i + 1] = C[i] + E[i + 1];
        D[i + 1] = D[i] + F[i + 1];
    }
    int x = -N;
    rep(i, N) {
        x = max(x, C[i + 1] - D[i]);
    }
    rep(i, N) {
        cout << B[(i - x + N) % N];
        if (i == N - 1) cout << "\n";
        else cout << " ";
    }
}

Measured memory_bytes: 8012
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		StringBuilder output = new StringBuilder();
		StringBuilder all = new StringBuilder();

		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();

			if (H + W == 0)
				break;

			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					output = output.append("#");
				}
				output = output.append("\n");
			}
			all = all.append(output + "\n");
			output.delete(0,output.length());
		}
		System.out.print(all);
		sc.close();
	}

}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 3005;
double P[MAX_N];

double dp[MAX_N][MAX_N];

int main2() {
  int N = nextInt();
  REP(i, N) cin >> P[i];
  CLR(dp, 0);
  dp[0][0] = 1.0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i + j < N) {
        dp[i+1][j] += P[i + j] * dp[i][j];
        dp[i][j+1] += (1.0 - P[i + j]) * dp[i][j];
      }
    }
  }

  double ans = 0;
  for (int i = 0; i <= N; i++) {
    int j = N - i;
    if (i > j) ans += dp[i][j];
  }
  printf("%.10f\n", ans);

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

namespace abc125
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var anums = Console.ReadLine().Split(' ')
                .Select(s =>long.Parse(s))
                .ToArray();

            var plusNum = 0;
            var zeroNum = 0;
            var minusNum = 0;
            long absTotal = 0;
            long absMin = long.MaxValue;

            foreach (var a in anums)
            {
                var abs = Math.Abs(a);
                absTotal += abs;
                absMin = Math.Min(abs, absMin);

                if (a > 0)
                {
                    plusNum++;
                }
                else if (a < 0)
                {
                    minusNum++;
                }
                else
                {
                    zeroNum++;
                }
            }

            var output = absTotal;

            if (zeroNum == 0 && minusNum % 2 == 1)
            {
                output -= 2 * absMin;
            }

            Console.WriteLine(output);
        }
    }
}


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

int main() {
  string S;
  cin >> S;
  int sum;
  for (int i = 0; i < 3; i++) {
    if (S[i] == 'o') sum++;
  }
  cout << 700 + 100 * sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
/*
  Author: @yash_31
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#define ll long long int
#define eb emplace_back
#define fatafat ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define ft first
#define sd second
#define mkpr make_pair
#define deb(x) std::cout<<#x<<":"<<x<<endl;
#define whole(x) (x).begin(),(x).end()
#define revwhole(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define fbo find_by_order
#define ook order_of_key
#define init0(x) memset(x,0,sizeof(x));

using namespace std; 
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> gharKaSet;
 
const int maxlimit=2e5+2;
const ll inf=1e18;
//TTBDC

int main()
{
  fatafat
  int n,m;
  cin>>n>>m;
  string mat[n];
  for(int i=0;i<n;i++)cin>>mat[i];
  ll dp[n][m];
  memset(dp,0,sizeof(dp));
  dp[0][0]=1;
  for(int i=1;i<m;i++)dp[0][i]=dp[0][i-1]*(mat[0][i]=='.');
  for(int i=1;i<n;i++)dp[i][0]=dp[i-1][0]*(mat[i][0]=='.');
  for(int i=1;i<n;i++){
    for(int j=1;j<m;j++){
      if(mat[i][j]=='.'){
        dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
      }
    }
  }
  cout<<dp[n-1][m-1];
  return 0;
}

Measured memory_bytes: 12516
import sys
input = sys.stdin.readline
from itertools import accumulate
from functools import reduce
from operator import xor, add


def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A):
    L = list(accumulate(A, xor))
    R = list(accumulate(A[::-1], xor))[::-1]
    ans = [0 for i in range(N)]
    for i in range(N):
        a = 0
        l = L[i-1] if i > 0 else 0
        a ^= l
        r = R[i+1] if i+1 < N else 0
        a ^= r
        ans[i] = a
    print(*ans)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 43000
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define fr                first
#define sc                second
#define vc                vector
#define endl              '\n'
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define LSB(i)            ((i)&-(i))

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve()
{
    int h, a;
    cin >> h >> a;
    if (h % a == 0)
    {
        cout << h / a << endl;
    }
    else
    {
        cout << h / a + 1 << endl;
    }
}
signed main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

void solve() {
    int n; sc(n);
    int a[n]; sca(a, n);
    int ans = 0;
    int curAns = 0;
    int idx = 0;
    while (idx < n-1) {
        if (a[idx] >= a[idx+1]) curAns++;
        else {
            ans = max(ans, curAns);
            curAns = 0;
        }
        idx++;
    }
    ans = max(ans, curAns);
    pd(ans);

}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(int i=0;i<N;i++)
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll count=0;
    ll N;
    cin>>N;
    ll n=ceil((-1+sqrt(1+4*N))/2)-1;
    vector<int>div;
    for(int i=1;i<=n;i++){
        if(N%i==0)count+=N/i-1;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        String s = sc.next();
        char[] arr = s.toCharArray();

        for (int i=0; i<s.length()/2; i++) {
            if (arr[i]!=arr[s.length()-1-i] && i!=s.length()-1-i) {
                out.print("No");
                out.flush();
                return;
            }
        }

        for (int i=0; i<s.length()/2-1; i++) {
            if (arr[i]!=arr[(s.length()/2)-1-i] && i!=(s.length()/2)-1-i) {
                out.print("No");
                out.flush();
                return;
            }
            if (arr[(s.length()/2)+1+i]!=arr[s.length()-1-i] && (s.length()/2)+1+i!=s.length()-1-i) {
                out.print("No");
                out.flush();
                return;
            }
        }

        out.print("Yes");
        out.flush();
    }

}


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    string s;
    cin >> s;

    bool N, W, S, E;
    N = W = S = E = false;
    REP(i, s.size()) {
        if (s[i] == 'N') N = true;
        if (s[i] == 'W') W = true;
        if (s[i] == 'S') S = true;
        if (s[i] == 'E') E = true;
    }

    if (N^S || W^E) cout << "No" << '\n';
    else cout << "Yes" << '\n';
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 3223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
//#define leng length()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.fi.se>b.fi.se;
}
ll cmp2(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.se<b.se;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //------------------------------
    ll n;cin>>n;
    ll mina=0,minb=INF;
    for(ll i=0;i<n;i++){
        ll a,b;cin>>a>>b;
        if(minb>b){
            minb=b;
            mina=a;
        }
    }
    cout<<(minb+mina)<<endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------


















































Measured memory_bytes: 3664
package main

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

// 配列で入力を受ける関数
var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	// 入力を受ける
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	for {
		c = c - b
		if c <= 0 {
			fmt.Println("Yes")
			break
		}
		a = a - d
		if a <= 0 {
			fmt.Println("No")
			break
		}

	}

}


Measured memory_bytes: 1836
import java.util.Scanner;

//Angel Stairs
public class Main{
	
	String[] f = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};
	int trans(String s){
		for(int k=0;k<12;k++)if(f[k].equals(s))return k;
		return 0;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		int[] t = new int[50002], s = new int[50002];
		while(T--!=0){
			int n = sc.nextInt(), m = sc.nextInt();
			t[0] = t[n+1] = -1;
			for(int i=1;i<=n;i++)t[i]=trans(sc.next());
			for(int i=0;i<m;i++)s[i]=trans(sc.next());
			int p = n;
			boolean con = true;
			for(int k=m-1;k>=0&&con;k--){
				con = false;
				if(p==0||p==n+1)break;
				int np = p-2;
				if(0<=np&&s[k]==(t[p]+1)%12){
					con = true; p = np; continue;
				}
				np = p-1;
				if(0<=np&&s[k]==t[p]){
					con = true; p = np; continue;
				}
				np = p+1;
				if(np<=n&&s[k]==(t[p]+11)%12){
					con = true; p = np; continue;
				}
			}
			if(con&&p==0){
				System.out.println("Yes"); continue;
			}
			p = n-1;
			if(0<=p){
				con = true;
				for(int k=m-1;k>=0&&con;k--){
					con = false;
					if(p==0||p==n+1)break;
					int np = p-2;
					if(0<=np&&s[k]==(t[p]+1)%12){
						con = true; p = np; continue;
					}
					np = p-1;
					if(0<=np&&s[k]==t[p]){
						con = true; p = np; continue;
					}
					np = p+1;
					if(np<=n&&s[k]==(t[p]+11)%12){
						con = true; p = np; continue;
					}
				}
				if(con&&p==0){
					System.out.println("Yes"); continue;
				}
			}
			System.out.println("No");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
N = int(input())
a = list(map(int, input().split()))

l = a[0]
r = sum(a[1:])
ans = abs(l - r)

for i in range(1, N-1):
    now = a[i]
    l += now
    r -= now
    ans = min(ans, abs(l-r))
print(ans)


Measured memory_bytes: 76752