akhauriyash/Code-Regression huggingface dataset:
N = int(input())
a = list(map(int,input().split()))

ans = 0
right = 0
s = 0
for left in range(N):
    while right < N and ((s^a[right] == s + a[right])):
        s += a[right]
        right += 1


    ans += (right - left)

    if left == right:
        right += 1
    else:
        s -= a[left]
print(ans)


Measured memory_bytes: 77772
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<bits/stdc++.h>
#include<set>
using namespace std;
int main()
{
    long long int n,k=0,i,t=0,j,m,b,x=0,y=0;
    cin>>n;
    int a[2*n];
    for(i=0;i<2*n;i++)
       {
       		cin>>a[i];
       }
    sort(a,a+2*n);
    for(i=0;i<2*n;i+=2)
       {
       		k+=a[i];
       }
    cout<<k;   
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<iostream>
#include<cstring>

#define MAX 100005
using namespace std;

int seat[MAX];
int main(void){
	int n;
	memset(seat,0,sizeof(seat));
	scanf("%d",&n);
	int now = 0;
	char s[10];
	int left = 0,right = n;
		printf("%d\n",now);
		fflush(stdout);
		scanf("%s",s);
		if(s[0] == 'M'){
			seat[0] = 1;
			seat[n] = 1;
		}
		if(s[0] == 'F'){
			seat[0] = -1;
			seat[n] = -1;
		}
		if(s[0] == 'V'){
			return 0;
		}
	int mid;
	mid = left + (right - left)/2;
	for(int i = 1; i < 20; i++){
		printf("%d\n",mid);
		fflush(stdout);
		scanf("%s",s);
		if(s[0] == 'M'){
			seat[mid] = 1;
		}
		if(s[0] == 'F'){
			seat[mid] = -1;
		}
		if(s[0] == 'V')
			return 0;
		int left_mid = seat[mid] + seat[left];
		//和为0则是异性，不为0为同性 
		if((mid - left)%2)  //中间有偶数个，left与mid互为异性 
			if(left_mid != 0) // 同性是不正常 
				right = mid;
			else
				left = mid;
		else
			if(left_mid == 0)
				right = mid;
			else
				left = mid;
		mid = left + (right - left)/2;
	}
	printf("%d\n",mid);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
using namespace std;
typedef long long ll;
#define MAX 20

ll memo[MAX+1];
ll factorial(int n) {
  if(n == 0) return memo[n] = 1;
  else if(n == 1) return memo[n] = 1;
  else if(memo[n] != 0) return memo[n];
  return memo[n] = n*factorial(n-1);
}

int main() {
  int n;
  cin >> n;
  cout << factorial(n) << endl;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,K;
  cin>>N>>K;
  vector<int> balls(N);
  int sum=0;
  for(int i=0; i<N; i++){
    int x;
    cin>>x;
    int small = min(abs(x), abs(x-K));
    sum+=small*2;
  }
  cout<<sum<<endl;
}


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

#define sd(n) scanf("%d",&n) == 0
#define sl(n) scanf("%I64d",&n) == 0
#define ss(n) scanf("%s",n) == 0
#define sc(n) scanf(" %c",&n) == 0

#define pd(x) printf("%d", x)
#define ps(x) printf("%s", x)
#define pl(x) printf("%lld", x)

#define rep(i, begin, end) for (decltype(begin) i = begin; i < end; i++)
#define revrep(i, begin, end) for (decltype(begin) i = end - 1; i >= begin; i--)
#define all(a) a.begin(), a.end()


using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef pair<int, int> pii;


char arr[200000];
int alpha[26];

int main() {
	ss(arr);

	int n = strlen(arr);

	rep(i, 0, n) {
		alpha[arr[i] - 'a']++;
	}
	
	ll max = ((ll)(n - 1) * (ll)n) / (ll)2 + 1;

	rep(i, 0, 26) {
		if (alpha[i] > 1) {
			max -= ((ll)(alpha[i] - 1) * (ll)alpha[i]) / (ll)2;
		}
	}

	pl(max);
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main(){
  stack<int> st;
  string symbol;
  int x,y;
  while(cin >> symbol){
    switch((char)symbol[0]){
    case '+':
      x=st.top();
      st.pop();
      y=st.top();
      st.pop();
      st.push(y+x);
      break;
    case '-':
      x=st.top();
      st.pop();
      y=st.top();
      st.pop();
      st.push(y-x);
      break;
    case '*':
      x=st.top();
      st.pop();
      y=st.top();
      st.pop();
      st.push(y*x);
      break;
    default:
      st.push(std::stoi(symbol));
      break;
    }
  }

  cout << st.top() << endl;
  return 0;  
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    ll n;
    cin >> n;
    ll sum = 0;
    ll a[n];
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    if(sum % (n * (n + 1) / 2) != 0){
        cout << "NO" << endl;
        return 0;
    }
    ll d[n];
    ll k = sum / (n * (n + 1) / 2);
    for(int i = 0; i < n; i++){
        d[i] = a[(i + 1) % n] - a[i] - k;
    }
    sum = 0;
    for(int i = 0; i < n; i++){
        if(d[i] % n != 0 || d[i] > 0){
            cout << "NO" << endl;
            return 0;
        }
        sum -= d[i];
    }
    cout << (sum / n == k ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 1792
/*    特徴    */

/*    教訓    */

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-9; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x) == 1) return x; }
long long il() { long long x; if (scanf("%lld", &x) == 1) return x; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

#define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

// -------- template end - //




// - library ------------- //

 

// --------- library end - //



// - main() -------------- //

int main(){

  ll N, X, Y;
  cin >> N >> X >> Y;

  vector<ll> ans_buckets(N, 0);
  REP(i, 1, N){
    REP(j, i+1, N+1){
      // 1~N-1 : 2~N
      if (i==j) continue;

      ll dist = j - i;
      chmin(dist, abs(i - X) + 1 + abs(Y - j));
      chmin(dist, abs(i - Y) + 1 + abs(X - j));

      ans_buckets[dist]++;
    }
  }

  REP(i, 1, N){
    cout << ans_buckets[i] << endl;
  }

// ---------- main() end - //
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;
constexpr ll MOD = 1000000007;

// a^-1 mod p
ll inv(ll a,ll p){
  return ( a == 1 ? 1 : (1 - p*inv(p%a,a)) / a + p );
}

ll pow3(ll x) {
  if (x == 0) return 1;
  if ((x%2)==1) return 3*pow3(x-1)%MOD;
  ll h=pow3(x/2);
  return h*h%MOD;
}

int main()
{
  ll n,m,k;
  cin>>n>>m>>k;
  vecll fact(1000001);
  vecll factinv(1000001);
  fact[0] = 1;
  factinv[0] = 1;
  for(int i:irange(0,1000000)) {
    fact[i+1] = fact[i] * (i+1) % MOD;
    factinv[i+1] = inv(fact[i+1], MOD);
  }
  ll ans = 0;
  ll l=n+m+k;
  ll rsum = 1;
  for(ll i:irange(n,l+1)) {
    ll r = i-n;
    ll comb = fact[i-1] * factinv[n-1] % MOD;
    comb = comb * factinv[r] % MOD;
    ll pw = pow3(l-i);
    ll mul = comb * pw % MOD * rsum % MOD;
    ans += mul;
    ans %= MOD;
    rsum *= 2;
    rsum %= MOD;
    if (r >= k) {
      ll comb2 = fact[r] * factinv[r-k] % MOD;
      comb2 = comb2 * factinv[k] % MOD;
      rsum += MOD - comb2;
      rsum %= MOD;
    }
    if (r >= m) {
      ll comb2 = fact[r] * factinv[r-m] % MOD;
      comb2 = comb2 * factinv[m] % MOD;
      rsum += MOD - comb2;
      rsum %= MOD;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  string s;
  cin >> s;
  if(s == "SAT")cout << 1 << endl;
  else if(s == "FRI")cout<<2<<endl;
  else if(s=="THU")cout<<3<<endl;
  else if(s == "WED")cout<<4<<endl;
  else if(s=="TUE")cout<<5<<endl;
  else if(s=="MON")cout<<6<<endl;
  else cout<<7<<endl;
  
  return 0;
}

Measured memory_bytes: 256
// Aizu 3000: The Mean of Angles
// 2017.9.22 bal4u@uu

#include <stdio.h>

int main(void)
{
	int a, b, t;
	double ans;

	scanf("%d%d", &a, &b);
	ans = (a + b) / 2.0;
	t = a - b; if (t < 0) t = -t;
	if (t > 180) {
		if (ans >= 180.0) ans -= 180.0; else ans += 180.0;
	}
	printf("%lf\n", ans);
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		int n = sc.nextInt();
		int sum =0;
		int maxL=0;
		
		for ( int i = 0; i < n ; ++ i ) {
			int L=sc.nextInt();
			sum += L ;
			maxL = Math.max ( maxL , L );
			}
			if ( maxL < sum - maxL ) {
			 System.out.println("Yes");
			}
			else {
			System.out.println("No");
			}
	}
}

Measured memory_bytes: 23124
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		String st = sc.nextLine();

		int origin=0;
		for(int n=0;n<st.length();n++){
			origin += Character.getNumericValue(st.charAt(n));
		} 
		int res=0;
		res += 9*(st.length()-1);
		res += Character.getNumericValue(st.charAt(0)-1);

		if(origin > res) System.out.println(origin);
		else System.out.println(res);

	}
}

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

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n + 1, 0);
	for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; a[x]++; a[y]++; }
	for (int i = 0; i < n + 1; i++) { if (a[i] % 2 != 0) { cout << "NO" << endl; return 0; } }
	cout << "YES" << endl;
	return 0;

}

Measured memory_bytes: 768
N = int(input())
K = int(input())

"""
dp[i][j][k]
i: 決定した桁数
j: N以下確定
k: 0出ない数字がちょうどk個(k = 0,1,2,3)
   4個以上(k=4)
"""

def solve(a):
	a = str(a)
	L = len(a)
	dp = [[[0]*5 for i in range(2)] for j in range(L+1)]
	dp[0][0][0] = 1
	for i in range(L):
		D = int(a[i])
		for j in range(2):
			for k in range(5):
				for d in range(10 if j else D+1):
					if k>=4:
						dp[i+1][j or (d<D)][k] += dp[i][j][k]
					else:
						if d!=0:
							dp[i+1][j or (d<D)][k+1] += dp[i][j][k]
						else:
							dp[i+1][j or (d<D)][k] += dp[i][j][k]
	return dp[L][0][K] + dp[L][1][K]

print(solve(N))

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

int a[4];

int main()
{
    for (int i = 0; i < 4; i++)
        scanf("%d", &a[i]);
    sort(a, a + 4);
    if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;


int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	string s;
	string t;
	cin >> s >> t;
	vector<set<int>> pos(26);
	for (int i = 0; i < sz(s); i++)
	{
		pos[s[i] - 'a'].insert(i);
	}
	long long res = 0;
	int cur_pos = -1;
	for (int i = 0; i < sz(t); i++)
	{
		int c = t[i] - 'a';
		if (pos[c].empty())
		{
			cout << -1;
			return 0;
		}
		if (pos[c].upper_bound(cur_pos) == pos[c].end())
		{
			res += sz(s);
			cur_pos = -1;
		}
		cur_pos = *pos[c].upper_bound(cur_pos);
		
	}
	cout << res + cur_pos + 1;
	return 0;
}

Measured memory_bytes: 5200
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <cmath>
#include <cstdio>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

typedef long long ll;

int main(){
    int c=0;
    while(true){
        c++;
        int n;
        if(cin>>n,!n)break;
        if(c!=1)cout << endl;
        int cs[5][5][5];
        REP(z,5)REP(y,5)REP(x,5){
            char c;
            cin >> c;
            cs[x][y][z]=c-'0';
        } 
        int M1,M2;
        int as[27];
        int bs[27];
        memset(as,0,sizeof as);
        memset(bs,0,sizeof bs);
        cin >> M1;
        REP(i,M1){
            int a;
            cin >> a;
            as[a]=1;
        }

        cin >> M2;
        REP(i,M2){
            int b;
            cin >> b;
            bs[b]=1;
        }
        int buf[5][5][5];
        REP(t,n){
            REP(z,5)
                REP(y,5)
                REP(x,5){
                    int cnt=0;
                    FOR(dz,-1,2){
                        FOR(dy,-1,2){
                            FOR(dx,-1,2){
                                if(dx==0&&dy==0&&dz==0){
                                    continue;
                                }
                                int nz=z+dz;
                                int ny=y+dy;
                                int nx=x+dx;
                                if(nz<0||ny<0||nx<0||nz>4||ny>4||nx>4)continue;
                                cnt+=cs[nx][ny][nz];
                            }
                        }
                    }
                    if(cs[x][y][z]){
                        buf[x][y][z]=bs[cnt];
                    }

                    if(!cs[x][y][z])buf[x][y][z]=as[cnt];
                }
            REP(z,5)REP(y,5)REP(x,5)cs[x][y][z] = buf[x][y][z];
        }
        cout << "Case " << c << ":" << endl;
        REP(z,5){
            REP(y,5){
                REP(x,5){
                    cout << cs[x][y][z];
                }
                cout << endl;
            }
            if(z!=4)cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1172
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

const int maxn = 1e5+100;

int n,k,T,m;
long long x,y,a[maxn],mp[maxn],ans[maxn];
long long sum =0;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	cin>>m;
	for(int i=1;i<=n;i++) mp[a[i]]++,sum+=a[i];
	for(int i=1;i<=m;i++)
	{
		cin>>x>>y;
		//cout<<mp[x]<<" "<<mp[y]<<endl;
		mp[y]+=mp[x];
		sum-=(mp[x]*x);
		sum+=(y*mp[x]);
		mp[x] = 0;
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 5160
S=input()
K=int(input())
total=0
count=0
flag=0
ss=0
flag2=1
if len(S)==1:
    print(K//2)
    exit(0)
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        count+=1
    else:
        if flag==0:
            ss=count+1
        flag=1
        count+=1
        total+=count//2
        count=0
    #print(count)

if flag==0:
    print((len(S)*K)//2)
    exit(0)


count+=1
if S[len(S)-1]==S[0]:
    flag2=0
    count+=1
total+=count//2
if (count+ss-1)%2==0 and flag2==0:
    print(total*K-1)
else:
    if ss%2==0 and flag2==0:
        print(total*K-K)
    else:
        print(total * K )

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

using namespace std;

int n,k;
int v;
int a[52];
int b[52];
int ans = 0;

int main()
{
    scanf("%d%d",&n,&k);
    for(int i = 1;i <= n;i++)
    {
        scanf("%d",&v);
        a[i] = v;
    }
    for(int i = n;i >= 1;i--)
        b[i] = a[n - i + 1];
    for(int i = 1;i <= k && i <= n;i++)
    {
        int s = 0;
        int t[52];
        for(int j = 1;j <= i;j++)
            t[j] = a[j];
        sort(t + 1,t + 1 + i);
        for(int j = 1;j <= i;j++)
            s += a[j];
            for(int j = 1;j <= k - i && j <= i;j++)
            {
                if(t[i] >= 0)
                    break;
                s -= t[i];
            }
        ans = max(ans,s);
    }
    for(int i = 1;i <= k && i <= n;i++)
    {
        int s = 0;
        int t[52];
        for(int j = 1,l = n;j <= i;j++,l--)
        {
            s += a[l];
            t[j] = a[l];
        }
        sort(t + 1,t + 1 + i);
            for(int l = 1;l <= k - i && l <= i;l++)
            {
                if(t[l] >= 0)
                    break;
                s -= t[l];
            }
        ans = max(ans,s);
    }
    for(int i = 1;i < k;i++)
        for(int j = 0;i + j <= k && i + j <= n;j++)
        {
            int s = 0;
            int cou = 0;
            int t[52];
            for(int l = 1;l <= i;l++)
            {
                t[++cou] = a[l];
                s += a[l];
            }
            for(int l = 1;l <= j;l++)
            {
                t[++cou] = b[l];
                s += b[l];
            }
            sort(t + 1,t + 1 + cou);
                for(int l = 1;l <= k - i - j && l < i + j;l++)
                {
                    if(t[l] >= 0)
                        break;
                    s -= t[l];
                }
            ans = max(ans,s);
        }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

int dx[] = { -1, 0, 1, 0, -1, -1, 1, 1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};


int main() {

	int n; cin >> n;
	string s; cin >> s;

	for (char &i : s) {
		int curr = (i - 'A');
		int nw = (curr + n) % 26;
		char f = nw + 'A';
		debug(curr, nw, f);
		i = f;
	}
	cout << s;

	return 0;
}

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

typedef long long ll;
typedef long double ld;

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

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

int main(){

    ll X, Y;

    cin >> X >> Y;

    cout << X + Y /2 << endl;

    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    n, m = map(int, input().split())
    lista=[]
    listb =[]
    for i in range(0,n):
        a = input()
        lista.append(a)

    for i in range(0,m):
        a = input()
        listb.append(a)
    flag =0

    for i in range(0,n-m+1):
        for j in range(0,n-m+1):
            count = 0
            for k in range(m):
                if listb[k] == lista[i+k][j:j+m]:
                    count +=1
            if count == m:
                flag=1
    if flag ==1:
        print("Yes")
    else:
        print("No")




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

int a,b,c;
cin >> a>>b>>c;
if(b/a!=c/a){cout<<"OK"<<endl;}
else if(b*1.0/a==b/a){cout<<"OK"<<endl;}
  else{cout<<"NG"<<endl;}

}

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

public class Program
{

	static void Main(string[] args)
	{
		// 文字の入力
		var N = int.Parse(Console.ReadLine());
		var s = Console.ReadLine();

		var redCount = s.Count(x => x == 'R');
		var blueCount = s.Count(x => x == 'B');

		var result = redCount > blueCount ? "Yes" : "No";
		Console.WriteLine(result);
	}

}


Measured memory_bytes: 11220
#include <stdio.h>

#define SIZE 26

int main(){
    int i,num;
    char ch;
    int count[SIZE];
    
    for(i = 0; i < SIZE; i++){
        count[i] = 0;
    };
    
    while (scanf("%c", &ch) != EOF ){
        if('A' <= ch && ch <= 'Z'){
            ch = ch - 'A' + 'a';
        }
        
        num = ch - 'a';
        count[num]++;
    }
    
    for(i = 0; i < SIZE; i++){
        printf("%c : %d\n",i + 'a', count[i]);
    }
    return 0;
}

Measured memory_bytes: 540
package main

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

func out(x ...interface{}) {
	// fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

type bit []int

func (p *bit) init(n int) {
	*p = make([]int, n+1)
}
func (p bit) sum(i int) int {
	if i == 0 {
		return 0
	}
	return p[i] + p.sum(i-(i&-i))
}
func (p bit) add(i, x int) {
	if i >= len(p) {
		return
	}
	p[i] += x
	p.add(i+(i&-i), x)
}

func main() {
	sc.Split(bufio.ScanWords)
	N, K := getInt(), getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt() - K
	}

	s := make([]int, N+1)
	for i := 0; i < N; i++ {
		s[i+1] = s[i] + a[i]
	}

	b := make([]int, N)
	for i := 1; i <= N; i++ {
		b[i-1] = s[i]
	}
	out(s)
	sort.Ints(b)
	out(b)
	bm := make(map[int]int)
	for i := 0; i < N; i++ {
		bm[b[i]] = i + 1
		out(bm)
	}
	var tree bit
	tree.init(N + 2)
	for i := 0; i < N; i++ {
		tree.add(bm[b[i]], 1)
		out(bm[b[i]], tree)
	}
	// tree.add(bm[0], -1)
	out("---")
	out(tree)

	ans := 0
	for i := 1; i <= N; i++ {
		pos := lowerBound(b, s[i-1])
		ans += tree.sum(N+1) - tree.sum(pos)
		tree.add(bm[s[i]], -1)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 15744
#include <bits/stdc++.h>
        using namespace std;
        #define int long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 998244353 
        #define inf 2e18
 
        bool check(int n,int k){
            while(n%k==0){
                n=n/k;
            }
            return n%k==1;
        }
        
        signed main() {
 
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        int n;
        cin>>n;
        int ans=0;
        for(int i=1;i<=n;i++){
            if(i%3!=0&&i%5!=0){
                ans+=i;
            }
        }
        cout<<ans;
 
 
        return 0;
    }

Measured memory_bytes: 3604
-- SPDX-License-Identifier: X11
-- 2020-09-23
-- ... (Triple Dots) (200pt)

f :: [String] -> String
f [n, s] = g (read n :: Int) s []
  where
    g :: Int -> String -> String -> String
    g _ [] acc       = reverse acc
    g 0 _ acc        = reverse ("..." ++ acc)
    g m (t : ts) acc = g (m - 1) ts (t : acc)
f _      = error "f: Unhandled case"

main :: IO ()
main = getContents >>= \x -> putStrLn . f . lines $ x


Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
 #define fast() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll  long long
#define int long long
#define f(i,a,b) for(int i=a; i<b; i++)
#define pb push_back
#define MP make_pair
#define vi vector<int>
#define F     first
#define S    second
#define all(x) x.begin(), x.end()

const int N = 1e9+7;
signed main()
{
    fast();
    int  n;
    cin >> n;
    double e = n / 2, o;
    if(n % 2 != 0)
        o = e + 1;
    else
    o = e;

    cout << setprecision(9) << fixed << o / n << endl;  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

class TEST{
	static void Main(){
		while(true){
			var s=Console.ReadLine().Split(' ');
			if(s[0]=="0" & s[1]=="0")break;
			Sol mySol=new Sol(int.Parse(s[0]),int.Parse(s[1]));
			mySol.Solve();
		}
	}
}

class Sol{
	int W;
	int Q;
	int[] wall;
	public Sol(int w_,int q_){
		W=w_;Q=q_;
		wall=new int[W];
		for(int i=0;i<W;i++){
			wall[i]=-1;
		}
	}
	
	public void Solve(){
		for(int q=0;q<Q;q++){
			var s=Console.ReadLine().Split(' ');
			if(s[0]=="w"){
				int cat=int.Parse(s[1]);
				for(int i=0;i<W;i++){if(wall[i]==cat)wall[i]=-1;}
			}
			if(s[0]=="s"){
				int cat=int.Parse(s[1]);
				int size=int.Parse(s[2]);
				int start=-1;
				int scan=0;
				bool isok=false;
				for(int i=0;i<W;i++){
					if(start==-1 && wall[i]==-1){
						start=i;
						scan=0;
					}
					if(wall[i]==-1)scan++;
					if(wall[i]!=-1){
						start=-1;
					}
					
					if(scan==size){
						isok=true;
						for(int j=start;j<=i;j++)wall[j]=cat;
						break;
					}
				}
				if(isok)Console.WriteLine("{0}",start);
				if(!isok)Console.WriteLine("impossible");
			}
		}
		Console.WriteLine("END");
	}
}

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

vector<int> t[(1<<18)];

void update(int i,int a){
  i+=(1<<17)-1;
  while(1){
    t[i].push_back(a);
    if(i==0)break;
    else i=(i-1)/2;
  }
}

int query(int a,int b,int x,int k,int l,int r){
  if(b<=l || r<=a)return 1e9;
  if(a<=l && r<=b){
    vector<int> :: iterator ti=lower_bound(t[k].begin(),t[k].end(),x);
    int res=1e9;
    if(ti!=t[k].end()){
      res=min(res,(*ti)-x);
    }
    if(ti!=t[k].begin()){
      ti--;
      res=min(res,x-(*ti));
    }
    return res;
  }
  int m=(l+r)/2;
  return min(query(a,b,x,k*2+1,l,m),query(a,b,x,k*2+2,m,r));
}



int main(){
  int N,a,Q,L,R,D;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d",&a);
    update(i,a);
  }
  for(int i=0;i<(1<<18);i++)sort(t[i].begin(),t[i].end());

  scanf("%d",&Q);
  for(int i=0;i<Q;i++){
    scanf("%d %d %d",&L,&R,&D);
    printf("%d\n",query(L,R+1,D,0,0,(1<<17)));
  }
  return 0;
}


Measured memory_bytes: 19020
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
int h, w, n;
string data[1100];
int main() {
  while (cin >> h >> w >> n) {
    rep(i, h) cin >> data[i];

    pair<int, int> ce[10];
    rep(i, h) rep(j, w) {
      if (data[i][j] == 'S') {
        ce[0] = pair<int, int>(i, j);
      }
      if (isdigit(data[i][j])) {
        ce[data[i][j] - '0'] = pair<int, int>(i, j);
      }
    }
    int sum = 0;
    rep(i, n) {
      int mp[1100][1100];
      rep(i, 1100) rep(j, 1100) mp[i][j] = INF;
      bool used[1100][1100] = {};

      mp[ce[i].first][ce[i].second] = 0;
      used[ce[i].first][ce[i].second] = true;
      queue<pair<int, int>> que;
      que.push(ce[i]);
      while (que.size()) {
        int y = que.front().first;
        int x = que.front().second;
        que.pop();
        int dx[] = {0, 1, 0, -1};
        int dy[] = {1, 0, -1, 0};
        rep(i, 4) {
          int ddy = y + dy[i];
          int ddx = x + dx[i];
          if (ddy >= 0 && ddy < h && ddx >= 0 && ddx < w &&
              data[ddy][ddx] != 'X' && !used[ddy][ddx]) {
            used[ddy][ddx] = true;
            mp[ddy][ddx] = mp[y][x] + 1;
            que.push(pair<int, int>(ddy, ddx));
          }
        }
      }
      sum += mp[ce[i + 1].first][ce[i + 1].second];
    }
    cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 9868
import java.util.*; 
import java.io.*;

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));

        String N = "" + nextInt();

        if(N.contains("7")){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 36552
#include<iostream>
#include <cstring>
#include<string>
using namespace std;

int main()
{
  string S;
  
  cin>>S;
  
  if(S=="ABC")
  {
    cout<<"ARC"<<endl;
  }
  else
  {
    cout<<"ABC"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string.h>

int main(){

    int num = 0;
    std::cin >> num;
    if (num <= 0) return 0;
  
    std::string *array;
    array = new std::string[num];
    for(int i = 0; i < num; i++){
        std::cin >> array[i];
    }

    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    
    for(int i = 0; i < num; i++){
        if(array[i] == "AC"){
            ac++;
        }else if(array[i] == "WA"){
            wa++;
        }else if(array[i] == "TLE"){
            tle++;
        }else if(array[i] == "RE"){
            re++;
        }
    }
  
    std::cout << "AC x " << ac << std::endl;
    std::cout << "WA x " << wa << std::endl;
    std::cout << "TLE x " << tle << std::endl;
    std::cout << "RE x " << re << std::endl;
  
    delete[] array;
}


Measured memory_bytes: 6380
function main(input) {
    input = input.trim().split("\n");
    var m = input[0].split(" ")[1];
    var a = input[1].split(" ").map(x => Number(x));
    var sum = a.reduce((a, c) => a + c);
    var border = sum / (4*m);

    var ans = a.filter(x => {
        return x >= border;
    });

    if (ans.length >= m) {
        console.log("Yes");
    } else {
        console.log("No");
    }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>

using namespace std;

int main()
{
    long long s;
    cin >> s;
    long long l=0,r=1000000001;
    while(l<r-1)
    {
        long long m=(l+r)/2;
        if(m*m>=s) r=m;
        else l=m;
    }
    cout << "0 0 1 " << r << " " << r << " " << r*r-s << endl;
    return 0;
}


Measured memory_bytes: 256
// Date: 2020-01-27

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

struct edge {
	int u, v, w;
};
vector<edge> E;
void add(int u, int v, int w) {
	E.pb({u, v, w});
}
int main() {
	int L, LL;
	scanf("%d", &L);
	LL = L;
	VI vec;
	while(L) {
		vec.pb(L % 2);
		L /= 2;
	}
	L = LL;
	int n = vec.size();
	for(int i = 1; i < n; i++) {
		add(i, i+1, 0);
		add(i, i+1, 1 << (i-1));
	}
	int y = L-(1<<(n-1)), cur = (1 << (n-1));
	while(y) {
		int x = 0;
		while((1 << (x+1)) < y) x++;
		add(x+1, n, cur);
		y -= (1 << x);
		cur += (1 << x);
	}
	printf("%d %d\n", n, E.size());
	for(auto e : E) {
		printf("%d %d %d\n", e.u, e.v, e.w);
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>par;
ll f[305][305][305],ms=1e9+7;
int n,m;
vector<par>v[405];
int check(int r,int g,int b){
	int k=max(r,max(g,b));
	for (int i=0;i<v[k].size();i++){
		int cnt=0;
		int l=v[k][i].first,x=v[k][i].second;
		if (r>=l) cnt++;
		if (g>=l) cnt++;
		if (b>=l) cnt++;
		if (cnt!=x) return 0;
	}
	return 1;
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++){
		int l,r,x; scanf("%d%d%d",&l,&r,&x);
		v[r].push_back(par(l,x));
	}
	f[0][0][0]=1; ll ans=0;
	for (int r=0;r<=n;r++){
		for (int g=0;g<=n;g++){
			for (int b=0;b<=n;b++){
				if (f[r][g][b]==0) continue;
				if (check(r,g,b)==0){
					f[r][g][b]=0; continue;
				}
				int p=max(r,max(g,b))+1;
				if (p==n+1) ans=(ans+f[r][g][b])%ms;
				f[p][g][b]=(f[p][g][b]+f[r][g][b])%ms;
				f[r][p][b]=(f[r][p][b]+f[r][g][b])%ms;
				f[r][g][p]=(f[r][g][p]+f[r][g][b])%ms;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 221440
N, M = [int(x) for x in input().split()]
H=[0]
H += [int(x) for x in input().split()]

X=[0]
for i in range(M):
    X += [[int(x) for x in input().split()]]

ma = [0] * (N+1)

for i in range(1,M+1):
    ma[X[i][0]] = max(ma[X[i][0]], H[X[i][1]])
    ma[X[i][1]] = max(ma[X[i][1]], H[X[i][0]])

ans = 0
for i in range(1,N+1):
    if H[i] > ma[i]:
        ans += 1

print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int>data(n);
  for(int i = 0;i < n;i++){
    cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  cout << data.at(n/2)-data.at(n/2-1) << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int a,b,c,d,p,x,y,z;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&p);
	x=a*p;
	if(c<p)	y=b+d*(p-c);
	else	y=b;
	if(x<y)	printf("%d\n",x);
	else	printf("%d\n",y);
	return 0;
}		


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


void solve(std::string a, std::string b){
    if(a == "H") {
        cout << b << endl;
    }
    if(a == "D"){
        if(b == "H") cout << "D" << endl;
        else cout << "H" << endl;
    }
}

int main(){
    std::string a;
    std::cin >> a;
    std::string b;
    std::cin >> b;
    solve(a, b);
    return 0;
}


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

int n,a[105],m,ans,sum;

int main()
{
	scanf("%d%d",&n,&m);
	
	for (int i=1 ;i<=n ; i++) scanf("%d",&a[i]),sum+=a[i];
	
	for (int i=1 ; i<=n ; i++)
	{
		if (a[i]>=sum*1.0/(4*m))
		{
			ans++;
			if (ans>=m) {
				printf("Yes\n");return 0;
			} 
		} 
	}
	printf("No\n");
	return 0;
 } 

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

int main()
{
  int n;
  cin>>n;
  unordered_map<string,int> cnt;
  for(int i=0;i<n;i++)
  {
    string s;
    cin>>s;
    cnt[s]++;
  }
  cout<<"AC x "<<cnt["AC"]<<endl;
  cout<<"WA x "<<cnt["WA"]<<endl;
  cout<<"TLE x "<<cnt["TLE"]<<endl;
  cout<<"RE x "<<cnt["RE"]<<endl;
  return 0;
}

Measured memory_bytes: 3572
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>
#include <limits.h>

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

int main(void){
    long long int a,b,g,l;
    while(scanf("%lld%lld",&a,&b)!=EOF){
        g=gcd(a,b);
        l=a*b/g;
        printf("%lld %lld\n",g,l);
    }
    return 0;
}


Measured memory_bytes: 1972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define Sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<int,int> P;
const long long MOD=1000000007;


void solve(long long N, std::vector<long long> H){
    ll ans_max=0,tmp=0;
    for (ll i = 0; i < N; i++)
    {
        if (i==N-1) {
            ans_max = max(tmp, ans_max);
            tmp=0;
            break;
        }
        
        if (H[i]>=H[i+1])
        {
            tmp++;
        } else {
            ans_max = max(tmp, ans_max);
            tmp=0;
        }
    }
    std::cout << ans_max << std::endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, std::move(H));
    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);

		int c = n * (n - 1) / 2;
		int c2 = m * (m - 1) / 2;

		System.out.println(c + c2);
	}
}

Measured memory_bytes: 32528
#include<stack>
#include<cstdio>
std::stack<int>stk;char str[5007],ans[2];
int ask(int a,int b){return printf("? %d %d\n",a-1,b-1),fflush(stdout),scanf("%s",ans),ans[0]=='Y';}
int main()
{
    int n,a,b;scanf("%d%d",&a,&b),n=a+b;
    if(a<=b) return puts("Impossible"),0;
    for(int i=1;i<=n;++i) stk.empty()||ask(stk.top(),i)? stk.push(i):stk.pop();
    for(int i=1;i<=n;++i) str[i]=ask(stk.top(),i)+'0';
    printf("! %s",str+1);
}


Measured memory_bytes: 848
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

struct bridge
{
    int a;
    int b;
}dict[100005];

int parent[100005], trank[100005];
ll sum;
ll ans[100005] = {0};
ll s[100005];

void init()
{
    for(int i = 0; i < 100005; ++i)
    {
        parent[i] = -1;
        trank[i] = 0;
    }
}

int find_root(int x)
{
    int x_root = x;
    while(parent[x_root] != -1)
        x_root = parent[x_root];
    return x_root;
}

int union_set(int x, int y)
{
    int x_root = find_root(x);
    int y_root = find_root(y);
    if(x_root == y_root)
        return 0;
    else
    {
        if(trank[x_root] > trank[y_root])
        {
            parent[y_root] = x_root;
            sum -= s[x_root]*s[y_root];
            s[x_root] += s[y_root];
        }
        else if(trank[y_root] > trank[x_root])
        {
            parent[x_root] = y_root;
            sum -= s[x_root]*s[y_root];
            s[y_root] += s[x_root];
        }
        else
        {
            parent[y_root] = x_root;
            trank[x_root]++;
            sum -= s[x_root]*s[y_root];
            s[x_root] += s[y_root];
        }
    }
    return 1;
}

int main()
{
    init();
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i = 0; i < m; ++i)
    {
        scanf("%d %d", &dict[i].a, &dict[i].b);
    }
    for(int i = 0; i <= n; ++i)
        s[i] = 1;
    sum = 1ll*n*(n-1)/2;
    for(int i = m - 1; i >= 0; --i)
    {
        ans[i] = sum;
        int x = dict[i].a;
        int y = dict[i].b;
        union_set(x, y);
    }
    for(int i = 0; i < m; ++i)
        cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 4480
#include<iostream>
using namespace std;
int main() {
	int a,b,c,d;
		d = 0;
		cin >> a >> b >> c;
		for (; a < b+1; a = a + 1) {
			if (c % a == 0) {
				d = d + 1;
			}
		}
		cout << d << endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
  
 int N;
 cin>>N;
 
  vector<int>d(N);
  
  for(int i=0;i<N;i++){
    cin>>d.at(i);
  }
  
  int ans=0;
  
  for(int j=0;j<101;j++){
    for(int i=0;i<N;i++){
      if(d.at(i)==j){
        ans++;
        break;
      }
    }
  }
  cout<<ans<<endl;
}
   

Measured memory_bytes: 3636
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
fn main() {
    input! { n, a: [isize; n] };
    let v1 = a
        .iter()
        .take(n - 1)
        .scan(0, |acc, &x| {
            *acc += x;
            Some(*acc)
        })
        .collect::<Vec<_>>();
    let mut v2 = a
        .iter()
        .rev()
        .take(n - 1)
        .scan(0, |acc, &x| {
            *acc += x;
            Some(*acc)
        })
        .collect::<Vec<_>>();
    v2.reverse();
    let ans: isize = v1
        .iter()
        .zip(v2.iter())
        .map(|(x, y)| (x - y).abs())
        .min()
        .unwrap();
    println!("{}", ans);
}


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

#define endl '\n'

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

    long long n, a, b; cin >> n >> a >> b;
    cout << (n/(a+b)) * a + min(a, n%(a+b)) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int lele,wikwik,pepaya,disaster=0;
	scanf("%d %d %d",&lele,&wikwik,&pepaya);
	for(int i=lele;i<=wikwik;i++){
		if(pepaya%i==0){
			disaster++;
		}
	}
		printf("%d\n",disaster);
		
	return 0;
}


Measured memory_bytes: 2724
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll a, b;
    cin >> a >> b;

    string s, t;
    Rep (i, b) s += '0' + a;
    Rep (i, a) t += '0' + b;

    if (s <= t) cout << s << endl;
    else cout << t << endl;
}

Measured memory_bytes: 256