akhauriyash/Code-Regression huggingface dataset:
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
int n,q;
string s;
const int N = 1e5 + 5;

struct BIT
{
	int N;
	vector<int> bit;

	void init(int n)
	{
		N = n;
		bit.assign(n + 1, 0);
	}

	void update(int idx, int val)
	{
		while(idx <= N)
		{
			bit[idx] += val;
			idx += idx & -idx;
		}
	}

	void updateMax(int idx, int val)
	{
		while(idx <= N)
		{
			bit[idx] = max(bit[idx], val);
			idx += idx & -idx;
		}
	}

	int pref(int idx)
	{
		int ans = 0;
		while(idx > 0)
		{
			ans += bit[idx];
			idx -= idx & -idx;
		}
		return ans;
	}

	int rsum(int l, int r)
	{
		return pref(r) - pref(l - 1);
	}

	int prefMax(int idx)
	{
		int ans = -2e9;
		while(idx > 0)
		{
			ans = max(ans, bit[idx]);
			idx -= idx & -idx;
		}
		return ans;
	}
};
BIT bit[27];
 main()

{
    fast
    cin>>n;
    for(int i=0;i<26;i++)bit[i].init(n+2);
    cin>>s;
    f(i,0,n-1)
    {
        int c=s[i]-'a';
        bit[c].update(i+1,1);
    }
    cin>>q;
    while(q--)
    {
         int typ;
         cin>>typ;
         if(typ==1)
         {
             int id;
             char ch;
             cin>>id>>ch;
             int c=ch-'a';
             int pc=s[id-1]-'a';
             bit[pc].update(id,-1);
             s[id-1]=ch;
             bit[c].update(id,1);
         }
         else
         {
             int lft,rgt,ses=0;
             cin>>lft>>rgt;
             for(int i=0;i<26;i++)
             {
                 int tmp=bit[i].rsum(lft,rgt);
                 if(tmp>=1)ses++;
             }
             cout<<ses<<endl;
         }

    }
    return 0;

}





































Measured memory_bytes: 102804
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
 
int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    long count = 0;
    long i;
    for(i=0; i<n; i++) {
        long a;
        scanf("%ld", &a);
        while(a%2==0) {
            a=a/2;
            count ++;
        }
    }

    printf("%d\n", count);
 
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

#define debug(x) cout << #x << "==" << x << endl;
#define INF INT_MAX
typedef long long ll;


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

  int K, S;
  cin >> K >> S;

  int ans = 0;

  if( K + K + K < S  ) {
    cout << "0" << endl;
    return 0;
  }

  for(int x = 0; x <= K; x++) {
    for(int y = 0; y <= K; y++) {
      int s = S - (x + y);
      if(  0 <= s && s <= K ) {
        ans++;
      }
    }

  }

  cout << ans << "\n";

  return 0;
}


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

using namespace std;

int n;
vector<vector<int> > tree;
vector<int> t;

void dfs(int now, int pre,int sum) {
	for (auto v : tree[now]) {
		if (v == pre) continue;
		dfs(v, now, sum + t[now]);
	}
	t[now] += sum;
}

int main() {
	int q; cin >> n >> q;
	tree.assign(n + 1, vector<int>());
	t.assign(n + 1, 0);
	for (int i = 0; i < n - 1; ++i) {
		int a, b; cin >> a >> b;
		tree[a].push_back(b);
	}
	for (int i = 0; i < q; ++i) {
		int p, x; cin >> p >> x;
		t[p] += x;
	}
	dfs(1, -1, 0);
	for (int i = 0; i < n; ++i) {
		if (i) cout << " ";
		cout << t[i + 1];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 26624
n = int(input())
p = [int(x) for x in input().split()]

cnt = 0

for i in range(1,n-1):
  if p[i-1]<p[i] and p[i]<p[i+1]:
    cnt +=1
  elif p[i-1]>p[i] and p[i]>p[i+1]:
    cnt +=1
print(cnt)

Measured memory_bytes: 3060
#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 int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int a, b, n;
	cin >> a >> b >> n;
	cout << ((a * min(n, b - 1)) / b);

	return 0;
}

Measured memory_bytes: 3608
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scanf("%d", &n)
	fmt.Scanf("%s", &s)

	fmt.Println(answer(n, s))
}

func answer(n int, s string) int {
	res := 0
	var buf int32
	for _, v := range s {
		if buf != v {
			buf = v
			res += 1
		}
	}

	return res
}



Measured memory_bytes: 1280
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  //A
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(c, b / a) << endl;
  return 0;	
}

Measured memory_bytes: 256
#include<stdio.h>
#include <string.h>
#define N 100000

char S[4]={};

int main(void)
{ scanf("%s",S);
 if((S[0]=='0'&&S[1]!='0')||(S[0]=='1'&&(S[1]=='0'||S[1]=='1'||S[1]=='2'))){if(S[2]=='0'&&S[3]!='0')printf("AMBIGUOUS\n");else if(S[2]=='1'&&S[3]<'3'){printf("AMBIGUOUS\n");}else printf("MMYY\n");}
 else if((S[2]=='0'&&S[3]!='0')||(S[2]=='1'&&(S[3]=='0'||S[3]=='1'||S[3]=='2')))printf("YYMM\n");else printf("NA\n");

}

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

using namespace std;

vector<int> s;

int main(){
    
    int n;
    cin >> n;
    
    for(int i=0; i< n; i++){
        int temp;
        cin >> temp;
        s.push_back(temp);
    }
    
    sort(s.begin(), s.end());
    
    long long res = ((long long) n)*(n-1)*(n-2)/6;
    
    for(int i=0; i<n; i++){
        
        for(int j=i+1; j<n; j++){
            int a = s[i];
            int b = s[j];

            // achar o menor numero que nao satisfaz c < a+b
            auto x = lower_bound(s.begin(), s.end(), a+b);
            
            res -= (s.end()-x);
        }
    }
    
    cout << res << endl;

}

Measured memory_bytes: 256
A,B=map(int,input().split())
result=0

flg=0
X=1
# 処理
while X*0.1<=100:
    if int(X*0.08)==A and int(X*0.1)==B:
        flg=1
        result=X
        break
    X+=1
    

if flg==0:
    result=-1

print(result)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    long long int n,now=1;
    cin>>n;
    vector<long long int> a(10000000);

    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]==0){
            now=0;
            break;
        }
        if(a[i] <=1000000000000000000/now&&now>0){
            now*=a[i];
        }
        else{
            now=-1;
        }
    }
    cout<<now<<endl;

    return 0;
}


Measured memory_bytes: 81404
def test():

	W = input()
	counter = 0

	while True:

		tmp_T = input()
		if tmp_T == "END_OF_TEXT":
			break

		T = tmp_T.split()

		for word in T:
			if word.upper() == W.upper():
				counter += 1

	print(counter)


if __name__ == "__main__":
	test()



Measured memory_bytes: 5556
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main(){
	cin>>a>>b>>c;
	for(int i=1;i<=b;i++)
	    if(a*i%b==c){
	    	cout<<"YES";
	    	return 0;
		}
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const int INF=1000100010;
int main(){
    int x;cin>>x;
    int A=0;
    int B=0;
    bool ok=false;
    for(int a=-120;a<120;a++){
     for(int b=-120;b<120;b++){
         if(a*a*a*a*a-b*b*b*b*b==x){
            ok=true;
            A=a,B=b;
            break;
         }
     }
    }
   if(ok)cout<<A<<" "<<B<<endl;
}

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

int n;
vector<int> g[200005];
int a[200005];
int dp[200005];//value of dp[i] is the minimal value where |LIS| = i
int ans[200005];

void dfs(int x,int p){
    int pos=lower_bound(dp+1,dp+1+n,a[x])-dp;
    ans[x]=max(pos,ans[p]);
    int tmp=dp[pos];
    dp[pos]=a[x];
    for(int &y:g[x])if(y!=p){
        dfs(y,x);
    }
    dp[pos]=tmp;
}

int main(){

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

    cin>>n;
    memset(dp,0x3f,sizeof(dp));
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<n;i++){
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1,0);
    for(int i=1;i<=n;i++){
        cout<<ans[i]<<'\n';
    }

    return 0;
}

Measured memory_bytes: 31216
//	-*- mode: C++ -*-
//	Prime Numbers
//		A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
//
//		Write a program which reads a list of N integers and prints the number of prime numbers in the list.
//
//	Input
//		The first line contains an integer N, the number of elements in the list.
//
//		N numbers are given in the following lines.
//
//	Output
//		Print the number of prime numbers in the given list.
//
//	Constraints
//		1 ≤ N ≤ 10000
//
//		2 ≤ an element of the list ≤ 10^8
//
//	Sample Input 1
//		5
//		2
//		3
//		4
//		5
//		6
//	Sample Output 1
//		3
//	Sample Input 2
//		11
//		7
//		8
//		9
//		10
//		11
//		12
//		13
//		14
//		15
//		16
//		17
//	Sample Output 2
//		4

#include <iostream>
#include <vector>
#include <cmath>

bool IsPrime(unsigned int	num)
{
	if(num < 2)	return	false;
	else if(num == 2) return	true;
	else if((num % 2) == 0) return	false;

	double	sqrtNum	= sqrt(num);

	for(unsigned int i = 3; i <= sqrtNum; i+=2){
		if((num % i) == 0) return	false;
	}

	return true;
}

int	main(int	argc,
		 char*	argv[])
{
	unsigned int	N				{0};
	std::vector<unsigned int>	a	{0};

	std::cin >> N;

	for(unsigned int i = 0; i < N; i++){
		unsigned int	element	{0};
		std::cin >> element;
		a.push_back(element);
	}

	unsigned int	count	{0};

	for(auto e : a){
		if(IsPrime(e)){
			count++;
		}
	}

	std::cout << count << '\n';
    return 0;
}



Measured memory_bytes: 3200
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;
typedef long long ll;

int gcd(int a, int b) {
  return b == 0 ? a : gcd(b, a % b);
}

int main(void) {
  int n;
  scanf("%d", &n);
  int g = 0;
  REP(i, n) {
    int v;
    scanf("%d", &v);
    g = gcd(g, v);
  }
  cout << g << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 500000
ll MOD=1e9+7;

main(){
    int n=in();
    vec x;
    rep(i,n){
        x.pb(in());
    }
    vec X=x;
    sort(all(X));
    int left=X[n/2-1],right=X[n/2];
    rep(i,n){
        cout<<(x[i]<=left ? right : left)<<endl;
    }
    return 0;
}




Measured memory_bytes: 3828
using static System.Math;using static System.Console;using System.Collections.Generic;using System.Linq;using System;using System.Collections;

class Program
{
    #region Reader
    static string ReadStr => Console.ReadLine();
    static string[] ReadStrs => Console.ReadLine().Split(' ');
    static int ReadInt => Convert.ToInt32(Console.ReadLine().Trim());
    static int[] ReadInts => Console.ReadLine().Trim().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
    static long ReadLong => Convert.ToInt64(Console.ReadLine().Trim());
    static long[] ReadLongs => Console.ReadLine().Trim().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
    #endregion
    #region Method
    const int mod = 1000000007;
    public static int Mod(int a,int mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    public static long Mod(long a, long mod = mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    #endregion

    static void Main()
    {

        string S = ReadStr;

        if(S[0] == 'R'&& S[1] == 'R' && S[2] == 'R' )WriteLine(3);
        else if (S[0] == 'R' && S[1] == 'R' || S[1] == 'R' && S[2] == 'R') WriteLine(2);
        else if(S[0] != 'R' && S[1] != 'R' && S[2] != 'R') WriteLine(0);
        else WriteLine(1);
    }
}


Measured memory_bytes: 25760
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, string &S){
    vector<vll> rec(10);
    REP(i, N){
        rec[S[i]-'0'].push_back(i);
    }
    ll cnt = 0;
    set<ll> a;
    REP(i, 10){
        REP(j, 10){
            REP(k, 10){
                if(i==j && j==k){
                    if(rec[i].size()>=3){
                        a.insert(i*100+j*10+k);
                    }
                    continue;
                }

                if(i==j && j!=k){
                    if(rec[i].size()>=2 && rec[k].size()>=1){
                        if(rec[k][rec[k].size()-1]>rec[i][1])
                            a.insert(i*100+j*10+k);
                    }
                    continue;
                }

                if((i != j) && j==k){
                    if(rec[i].size()>=1 && rec[j].size()>=2){
                        if(rec[i][0]<= rec[j][rec[j].size()-2])
                            a.insert(i*100+j*10+k);
                    }
                    continue;
                }

                if(i == k && i !=j){
                    if(rec[i].size()>=2 && rec[j].size()>=1){
                        ll x = rec[i][0], y = rec[i][rec[i].size()-1];
                        for(auto z: rec[j]){
                            if(x < z && z < y){
                                a.insert(i*100+j*10+k);
                                continue;
                            }
                        }
                    }
                    continue;
                }

                if(rec[i].size()&& rec[j].size() && rec[k].size()){
                    ll x = rec[i][0];
                    ll y = rec[k][rec[k].size()-1];
                    if(x > y)
                        continue;
                    for(auto z: rec[j]){
                        if(x < z && z < y){
                            a.insert(i*100+j*10+k);
                            continue;
                        }

                    }
                    
                    
                }
                
            }
        }
    }
    cout << a.size() << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    string S; cin >> S;
    solve(N, S);
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    float prob,imp;
    cin>>n;
    if(n%2==0){
        imp=n/2;
    }
    else
    {
       imp=n/2+1;
    }
    prob=imp/n;
    cout<<setprecision(10)<<prob;
    return 0;


}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
using ll = long long;

int main(){
    int A, B;
    cin >> A >> B;
    if(A == 1&& B ==2)cout << 3;
    if(A == 2&& B ==3)cout << 1;
    if(A == 3&& B ==2)cout << 1;
    if(A == 1&& B ==3)cout << 2;
    if(A == 2&& B ==1)cout << 3;
    if(A == 3&& B ==1)cout << 2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int M;
  cin>>M;
  cout<<24+(24-M)<<endl;
  return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(void){
    int x,y;
    int g[13]={0,1,2,1,4,1,4,1,1,4,1,4,1};
    
    scanf("%d %d",&x,&y);
    
    if(g[x]==g[y])
        printf("Yes\n");
    else
        printf("No\n");
}


Measured memory_bytes: 128
N,T=(int(i) for i in input().split())
ctlist=[[int(i) for i in input().split()]for j in range(N)]
A=[ctlist[i] for i in range (N) if ctlist[i][1]<=T]
if A==[]:
  print('TLE')
else:
  B=[A[i][0] for i in range(len(A))]
  print(min(B))
    

Measured memory_bytes: 3060
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;
int main()
{
	long long a, b;
	cin >> a >> b;

	if (a*b == 0 || a * b < 0) {
		cout << "Zero";
	}

	else if (a > 0) {
		cout << "Positive";
	}

	else {
		if (abs(a - b) % 2 == 0) {
			cout << "Negative";
		}
		else {
			cout << "Positive";
		}
	}

	return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

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

    ll t,ans=1;

    rep(i,n){
        cin>>t;
        ans=ans/__gcd(t,ans)*t;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <map>
using namespace std;
typedef long long lint;

int main() {
    int n, m;
    cin>>n>>m;
    int sum=0;
    vector<int> a(n);
    for(int i=0; i<n; i++) {
        cin>>a[i];
        sum+=a[i];
    }
    int count=0;
    for(int i=0; i<n; ++i) {
        if(a[i]*4*m>=sum) ++count;
    }
    if(count>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

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

using namespace std;

const int MAX_N = 105;
const int MAX_W = 100005;

struct Iten {
  int weight, value;
};

int n, w;

Iten arr[MAX_N];

long long dp[2][MAX_W];

int main() {
  scanf("%d %d", &n, &w);
  for (int i = 1; i <= n; ++i) {
    scanf("%d %d", &arr[i].weight, &arr[i].value);
  }
  int t = 1;
  for (int i = 1; i <= n; ++i) {
    t = 1 - t;
    for (int j = 0; j <= w; ++j) {
      dp[t][j] = dp[1 - t][j];
      if (arr[i].weight <= j) {
        dp[t][j] = max(dp[1 - t][j], (dp[1 - t][j - arr[i].weight] + arr[i].value));
      }
    }
  }
  printf("%lld", dp[t][w]);
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll X, K, D;
  cin>>X>>K>>D;
  if(K%2){
    if(X>=0)X-=D;
    else{
      X+=D;
    }
    K--;
  }
  if(X<0)X*=-1;
  if(X>=0){//
    ll Need=X/D;
    if(Need>=K){
      cout<<X-K*D<<endl;
      return 0;
    }
    X%=D;
    K-=Need;
    if(K%2){
      X-=D;
    }
    cout<<abs(X)<<endl;
    return 0;
  }

}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);

    int n; cin>>n;
    vector<int> a(n); for(e: a) { cin>>e; --e; }
    
    int res=0;
    for(int i=0; i<n; ++i)
        res+=a[a[i]]==i;
    cout<<res/2<<endl;
}


Measured memory_bytes: 640
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()

    rr = []
    if n % 2 == 1:
        t = n // 2 + 1
        for i in range(1, m+1):
            rr.append((t-i,t+i))
    else:
        t1 = (m+1) // 2
        t2 = n - m // 2
        for i in range(t1):
            rr.append((t1-i,t1+1+i))
        for i in range(1, m // 2 + 1):
            rr.append((t2-i, t2+i))

    return JAA(rr, "\n", " ")

print(main())





Measured memory_bytes: 30608
using AtCoderBeginnerContest154.Questions;
using AtCoderBeginnerContest154.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest154.Questions
{
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            yield return string.Concat(Enumerable.Repeat('x', inputStream.ReadLine().Length));
        }
    }
}


namespace AtCoderBeginnerContest154
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest154.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest154.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

//プロトタイプ宣言
void faster(void);
ll gcd(auto , auto);
ll get_digent(auto);
ll POW(auto , auto);
ll vec_max(auto & , string);
ll vec_min(auto & , string);

int main(){
  faster();
  ll a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  ll ma = max(x,y);
  ll mi = min(x,y);
  ll ex1 = a*x + b*y;
  ll ex2 = c*ma*2;
  ll ex3 = c*x*2 + b*abs(y-x);
  ll ex4 = c*y*2 + a*abs(x-y);
  if(ex3 <= 0) ex3 = 1e12;
  if(ex4 <= 0) ex4 = 1e12;
  ll ans = min(ex1 , min(ex2 , min(ex3 , ex4)));
  cout << ans << endl;
}






























//以下、ライブラリ

//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
ll gcd(auto a, auto b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
ll get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
ll POW(auto x, auto y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//配列内の最大要素のイテレータ取得or要素取得
ll vec_max(auto &v, string s){
  auto itr = max_element(v.begin(),v.end());
  ll element = *itr;
  ll place = itr - v.begin();
  if(s == "element") return element;
  else if(s == "place") return place;
  else return -1;
}

ll vec_min(auto &v, string s){
  auto itr = min_element(v.begin(),v.end());
  ll element = *itr;
  ll place = itr - v.begin();
  if(s == "element") return element;
  else if(s == "place") return place;
  else return -1;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int n, m;
    cin >> n >> m;
    string s(n, 'a');

    int a;
    char b;
    bool flag = true;
    rep (i, m)
    {
        cin >> a >> b;
        --a;
        if (s[a] != 'a' && s[a] != b)
        {
            flag = false;
        }
        s[a] = b;
    }

    if (s[0] == 'a') s[0] = (n > 1 ? '1' : '0');
    rep (i, n) s[i] = (s[i] == 'a' ? '0' : s[i]);
    cout << (!flag || (n > 1 && s[0] == '0') ? "-1" : s) << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	int a,b;
	cin>>a>>b;
	int x=a+b;
	int y=a-b;
	int z=a*b;
	if(x>=y && x>=z)
		cout<<x;
	else if(y>=x && y>=z)
		cout<<y;
	else
		cout<<z;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
struct edge{ int from,to,cost;};
edge es[5001];
int d[2501],V,E,INF=1e9;
int shortest_path(){
    rep(i,V) d[i+1]=INF;
    d[1]=0;
    while(true){
        int x=0;
        rep(i,E){
            edge e=es[i];
            if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost) d[e.to]=d[e.from]+e.cost,x=1;
        }
        if(!x) break;
    }
    return d[V];
}
int r[200001][2]={0};
vector<int> A[200001],B[200001];
int search(int x,int y){
    if(r[x][y]) return 0;
    r[x][y]=1;
    if(y==0) for(auto i:A[x]) search(i,y);
    else for(auto i:B[x]) search(i,y);
}
int find_negative_loop(){
    search(V,0);
    search(1,1);
    rep(i,V) d[i+1]=INF;
    d[1]=0;
    rep(i,2*V)rep(j,E){
        edge e=es[j];
        if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
            d[e.to]=d[e.from]+e.cost;
            if(i>=V-1&&r[e.to][0]&&r[e.to][1]) return 1;
        }
    }
    return 0;
}
int main(){
    int P,a,b,c;
    cin>>V>>E>>P;
    rep(i,E) cin>>a>>b>>c,es[i]={a,b,-(c-P)},A[b].push_back(a),B[a].push_back(b);
    if(find_negative_loop()) cout<<-1;
    else if(shortest_path()>0) cout<<0;
    else cout<<-shortest_path();
}

Measured memory_bytes: 10752
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    D = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [A, B] = [int(input_raw[0]), int(input_raw[1])]
        D.append((A, B))
    D.sort()

    cost = 0L
    for i in range(N):
        if M <= 0:
            break
        M -= D[i][1]
        buy = D[i][1]
        if M < 0:
            buy += M

        cost += long(buy) * D[i][0]
    print cost

if __name__ == '__main__':
    main()


Measured memory_bytes: 18796
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
ll zeller(ll y, ll m, ll d){
    if (m <= 2){
        y--;
        m += 12;
    }
    return (365 * y) + (y / 4) - (y / 100) + (y / 400) + (306 * (m + 1)) / 10 + d - 429;
}

int main(int argc, char ** argv) {
    int y, m, d;
    ll z1 = zeller(1868, 9, 8);
    ll z2 = zeller(1912, 7, 30);
    ll z3 = zeller(1926, 12, 25);
    ll z4 = zeller(1989, 1, 8);
    while (~scanf("%d%d%d", &y, &m, &d)){
        ll z = zeller(y, m, d);
        int idx = -1;
        char gen[][10] = {
            "heisei",
            "showa",
            "taisho",
            "meiji"
        };
        int zg = -1;
        if (z >= z4){
            idx = 0;
            zg = y - 1989 + 1;
        }
        else if (z >= z3){
            idx = 1;
            zg = y - 1926 + 1;
        }
        else if (z >= z2){
            idx = 2;
            zg = y - 1912 + 1;
        }
        else if (z >= z1){
            idx = 3;
            zg = y - 1868 + 1;
        }
        if (zg != -1){
            printf("%s %d %d %d\n", gen[idx], zg, m, d);
        }
        else{
            printf("pre-meiji\n");
        }
    }
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  VI xs(N);
  cin >> xs;
  cout << accumulate(ALL(xs), 0) - N << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		Dice dice=new Dice();
		for(int i=0;i<6;i++){
			dice.set(sc.nextInt(),i);
		}
		dice.roll(sc.next());
		System.out.println(dice.get(1));
	}

}
class Dice {
	int d[]=new int[6];
	void set(int a,int i){
			d[i]=a;
	}
	void roll(String s){
		for(int i=0;i<s.length();i++){
			int temp=d[0];
			switch(s.charAt(i)) {
			case 'N':
				d[0]=d[1];
				d[1]=d[5];
				d[5]=d[4];
				d[4]=temp;
				break;
			case 'S':
				d[0]=d[4];
				d[4]=d[5];
				d[5]=d[1];
				d[1]=temp;
				break;
			case 'E':
				d[0]=d[3];
				d[3]=d[5];
				d[5]=d[2];
				d[2]=temp;
				break;
			case 'W':
				d[0]=d[2];
				d[2]=d[5];
				d[5]=d[3];
				d[3]=temp;
				break;
			}
		}
	}
	int get(int i){
		return d[i-1];
	}
}

Measured memory_bytes: 26416
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

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

	int n;
	scanf("%d", &n);
	vi v(n), c(n);
	for (int i = 0; i < n; i++) scanf("%d", &v[i]);
	for (int i = 0; i < n; i++) scanf("%d", &c[i]);
	int ans = 0;
	for (int i = 0; i < n; i++)
		if (v[i] > c[i]) ans += v[i] - c[i];
	printf("%d\n", ans);
}


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

string s;

void solve(){
	long long ans = 0, b = 0;
	for(int i = 0; i < s.length(); i++){
		if(s[i] == 'B'){
			b++;
		}
		else{
			ans += b;
		}
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 720
while True:
  l = int(input())
  if l == 0:
    break
  acc = 0
  ans = 0
  for i in range(1, 13):
    m, n = map(int, input().split())
    acc += (m - n)
    if not ans and acc >= l:
      ans = i
  if not ans:
    print("NA")
  else:
    print(ans)


Measured memory_bytes: 5612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			string str = Console.ReadLine();

			int a = int.Parse(str.Substring(0, 2));
			int b = int.Parse(str.Substring(2));
			if (1 <= a && a <= 12 && 1 <= b && b <= 12) {
				Console.WriteLine("AMBIGUOUS");
			} else if (0 <= a && a <= 99 && 1 <= b && b <= 12) {
				Console.WriteLine("YYMM");
			} else if (1 <= a && a <= 12 && 0 <= b && b <= 99) {
				Console.WriteLine("MMYY");
			} else {
				Console.WriteLine("NA");
			}
		}
	}
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)

signed main(){
	IOS();
	int N;
	string s;
	cin >> N >> s;
	vector<int>dp(N + 1);
	dp[0] = 1;
	FOR(i, 1, N + 1) {
		dp[i] += dp[i % __builtin_popcountll(i)] + 1;
	}
	vector<int>ans;
	int MOD = 0;
	REP(i, N) {
		if(s[i] == '1')++MOD;
	}
	int plusMod = MOD + 1;
	int minusMod = MOD - 1;
	if(minusMod <= 0)minusMod = 1000000007;
	vector<int>plusPow(N);
	vector<int>minusPow(N);
	int plusNow = 1;
	int minusNow = 1;
	REP(i, N) {
		plusPow[N - 1 - i] = plusNow;
		minusPow[N - 1 - i] = minusNow;
		plusNow *= 2;
		plusNow %= plusMod;
		minusNow *= 2;
		minusNow %= minusMod;
	}
	int plus = 0, minus = 0;
	REP(i, N) {
		if(s[i] == '1') {
			plus += plusPow[i];
			minus += minusPow[i];
		}
	}
	REP(i, N) {
		if(s[i] == '1') {
			if(MOD == 1){
				out(0);
				continue;
			}
			int t = minus;
			t -= minusPow[i];
			t = (t + minusMod) % minusMod;
			out(dp[t]);
		} else {
			int t = plus;
			t += plusPow[i];
			t = (t + plusMod) % plusMod;
			out(dp[t]);
		}
	}
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

const ll mod = 1e9 + 7;

const ll INF = 1e15;

int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll sum = 0;
	if (a < k) {
		sum += a;
		k -= a;
		if (b < k) {
			k -= b;
			sum -= min(k, c);
		}
	}
	else {
		sum += k;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pii(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int main()
{   ios;
    int n;
    cin>>n;
    int ar[n];
    f(i,0,n)cin>>ar[i];
    int ans=0,count=0;
    f(i,0,n-1)
    {
        if(ar[i]>=ar[i+1])
         count++;
        else
        {
             ans=max(ans,count);
             count=0;
        }
    }
    ans=max(ans,count);
    cout<<ans;
}

Measured memory_bytes: 640
//abc103 a-task scheduling problem

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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
  int a[3];
  int cost=0;
  int mini=200;
  rep(i,3){
    scanf("%d",&a[i]);
  }
  rep(i,3){
    rep(j,3){
      rep(k,3){
      if(i==j ||i==k ||j==k){
        continue;
      }
      cost=0;
      cost+=max(a[i],a[j])-min(a[i],a[j]);
      cost+=max(a[j],a[k])-min(a[j],a[k]);
      //printf("a[i]=%d,a[j]=%d,a[k]=%d\n",a[i],a[j],a[k]);

      if(mini>cost){
        mini=cost;
      }
      //printf("cost=%d\n",cost);
    }
    }
  }
  cout<<mini<<endl;
  return 0;
}


Measured memory_bytes: 256
H, W = list(map(int, input().split()))
s = [[c for c in input()] for _ in range(H)]
accept = True

s = [["."]*(W+2)] + s + [["."]*(W+2)]
for i in range(1, H+1):
    s[i] = ["."] + s[i] + ["."]

for y in range(1, H+1):
    for x in range(1, W+1):
        if s[y][x] == "#":
            if s[y-1][x] == "." and s[y+1][x] == "." and s[y][x-1] == "." and s[y][x+1] == ".":
                accept = False

if accept:
    print("Yes")
else:
    print("No")

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

int main() {
  int n;
  cin>>n;
  vector<int> a(100),b(100),c(100);
  int cnt=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
   for(int i=1;i<=n;i++){
    cin>>b[i];
  }
   for(int i=1;i<=n-1;i++){
    cin>>c[i];
  }
   for(int i=1;i<=n;i++){
    cnt+=b[a[i]];
     if(a[i]+1==a[i+1])cnt+=c[a[i]];
   }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define N 100000

typedef struct pp{
	char name[100];
	int time;
}Process;

int head, tail, n, c=0, q;
Process Q[N];

void enqueue(){
	Q[head].time = Q[head].time -q;
	Q[tail] = Q[head];
	if(tail > n+1) tail = 0;
	else tail++;
}

void dequeue(){
	printf("%s %d\n",Q[head].name, Q[head].time+c);
}

int main(){
	int i;
	scanf("%d %d", &n, &q);
	for ( i = 1; i <= n; i++){
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].time);
	}
	head = 1;
	tail = n+1;
	i = 1;
	while(head != tail){
		if(Q[head].time > q){
			enqueue();
			c = c + q;
		}
		else{
			dequeue();
			c = c + Q[head].time;
		}
		if(head > n+1) head = 0;
		else head++;
	}
	return 0;
}

Measured memory_bytes: 6740
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
using namespace std;


int main() {
    int a;
    cin >> a;
    int paid = a*800;
    int ret = (a/15)*200;
    cout << paid - ret;
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    string s;
    cin>>s;
    bool f=true;
    for(int i=0;i<s.size();i++)if(!(s[i]=='U'||s[i]=='D'||i%2&&s[i]=='L'||!(i%2)&&s[i]=='R'))f=false;
    cout<<(f?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;


    static void Main(string[] args)
    {
        Solve();
    }




    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        int N = sc.intarr[0];

        int[] X = new int[N];
            X=sc.intarr;
        int[] Y = new int[N];
            
        for(int i = 0; i < N; ++i)
        {
            Y[i] = X[i];
        }

        Array.Sort(Y);

        int a = Y[N / 2 - 1];
        int b = Y[N / 2];
        for(int i = 0; i < N; i++)
        {
            if (a<X[i])
            {
                wr.wri(a);
            }
            else wr.wri(b);
        }

    }
}
    




class Scan
{
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
    public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 38208
n=int(input())
s=input()
ans=0
 
for i in range(10):
    for j in range(10):
        for k in range(10):
            x=s.find(str(i))
            if x!=-1:
                y=s.find(str(j),x+1)
                if y!=-1:
                    z=s.find(str(k),y+1)
                    if z!=-1:
                        ans+=1
print(ans)

Measured memory_bytes: 3060
# coding: utf-8
from itertools import permutations
N = int(input())
P = list(map(str, input().split()))
Q = list(map(str, input().split()))

l = list(permutations(P))
l.sort()
ll = []
for i in range(len(l)):
    a = list(map(str, l[i]))
    ll.append("".join(a))
p_idx = ll.index("".join(P))
q_idx = ll.index("".join(Q))
print(abs(p_idx - q_idx))

Measured memory_bytes: 10868
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))

dp = [[0] * 2 for _ in range(N)]
dp[0][0] = A[0] + A[1]
dp[0][1] = - A[0] - A[1]

for i in range(1, N - 1):
    bidx = i - 1
    nidx = i + 1
    dp[i][0] = max(dp[bidx][0] + A[nidx],
                   dp[bidx][1] + A[nidx])
    dp[i][1] = max(dp[bidx][0] - 2 * A[i] - A[nidx],
                   dp[bidx][1] + 2 * A[i] - A[nidx])

print(max(dp[N - 2]))

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

int main() {
    char test_str[201], search_string[101], copied_test_str[101];
    cin >> test_str >> search_string;
    strcpy(copied_test_str, test_str);
    strcat(test_str, copied_test_str);

    cout << (strstr(test_str, search_string) ? "Yes" : "No") << endl;
    return 0;
}

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

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

int main(int argc, char const *argv[])
{
    int N,K;
    cin >> N >> K;
    int res = (int)(N%K!=0);
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;



int main(){
 int n; cin>>n;
 int a[n]; 
 int four=0;
 int odds=0;
 REP(i,n){
     int a; cin>>a;
     if(a%2==1)odds++;
     else if(a%4==0)four++;
 }
 if(four>=odds)cout<<"Yes"<<endl;
 else if(n%2==1&&odds==(n+1)/2&&four==(n-1)/2)cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
}

Measured memory_bytes: 256