akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
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; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    int n, k; cin >> n >> k;
    ll a[n];
    ll b[n];
    rep(i, n) cin >> a[i];

    for(int i=k; i<n; i++){
        ll t = a[i]/a[i-k];
        ll r = a[i]%a[i-k];
        if(t>1){out("Yes");
        }
        else if(t==1&&r>0){out("Yes");}
        else{out("No");}

    }
    
}

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

#define Int long long int
#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()

int main(){
    map<string, int> card;
    int n;
    cin >> n;
    string s;
    REP(i,n){
        cin >> s;
        if(!card[s])card[s]=1;
        else card[s]++;
    }
    int m;
    cin >> m;
    REP(i,m){
        cin >> s;
        if(!card[s])card[s]=-1;
        else card[s]--;
    }
    //sort(All(card));
    //reverse(All(card));
    int ma=0;
    for(pair<string, int> p:card){
        ma=max(ma,p.second);
    }
    cout << ma << endl;
}


Measured memory_bytes: 256
n = int(input())
k = int(input())
x = list(map(int,input().split()))
ans = 0
for i in range(len(x)):
  f = k - x[i]
  if(f>x[i]):
    ans += 2*x[i]
  else:
    ans += 2*f
print(ans)
    



Measured memory_bytes: 2940
using System.Linq;
using System;
using static System.Console;

class Program
{
  static void Main() => new Program().solve();

  void solve()
  {
    var c = Enumerable.Range(0, 5).Select(_ => int.Parse(ReadLine())).ToArray();

    var minRem = c.Select(i => (i % 10) == 0 ? 10 : (i % 10)).Min();
    var cSorted = c.OrderBy(i => (i % 10) == 0 ? 10 : (i % 10));

    var ans = (minRem == 10) ? c.Sum()
      : cSorted.First() + cSorted.Skip(1).Select(i => ((i + 9) / 10) * 10).Sum();
    WriteLine(ans);
  }
}

Measured memory_bytes: 11476
#include <stdio.h>
#define MIN(x,y) (((x) > (y)) ? (y) : (x))
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))

char s[4001];
int rgb[4001][3];
int rest(char a, char b) {
  if ((a == 'R' && b == 'G') || (a == 'G' && b == 'R')) {
    return 2; // B
  } else if ((a == 'R' && b == 'B') || (a == 'B' && b == 'R')) {
    return 1; // G
  } else {
    return 0;
  }
}
char restc(char a, char b) {
  if ((a == 'R' && b == 'G') || (a == 'G' && b == 'R')) {
    return 'B'; // B
  } else if ((a == 'R' && b == 'B') || (a == 'B' && b == 'R')) {
    return 'G'; // G
  } else {
    return 'R';
  }
}
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", s);
  long long sum = 0;
  for (int i = n - 1; i >= 0; i--) {
    rgb[i][0] = rgb[i+1][0] + (s[i] == 'R' ? 1 : 0);
    rgb[i][1] = rgb[i+1][1] + (s[i] == 'G' ? 1 : 0);
    rgb[i][2] = rgb[i+1][2] + (s[i] == 'B' ? 1 : 0);
  }
  for (int i = 0; i < n; i++) {
    //printf("%d %d %d\n", rgb[i][0], rgb[i][1], rgb[i][2]);
    for (int j = i; j < n; j++) {
      if (s[i] != s[j]) {
        int r = rest(s[i], s[j]);
        int rc = restc(s[i], s[j]);
        int d = j - i;
        sum += rgb[j + 1][r] - ((j + d < n && s[j + d] == rc) ? 1 : 0);
      }
    }
  }
  printf("%lld", sum);
  return 0;
}

Measured memory_bytes: 2184
using System;
using System.Collections.Generic;
using System.Linq;
class P
{
    static List<long> lucas = new List<long>();
    static void Main()
    {
        var i = int.Parse(Console.ReadLine());
        lucas.Add(2);
        lucas.Add(1);
        for (int j = 2; j <= i; j++) lucas.Add(lucas[j - 1] + lucas[j - 2]);
        Console.WriteLine(lucas.Last());
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
    string s, p;
    cin >> s >> p;
    for (int i = 0; i < s.size(); i++) {
        rotate(s.begin(), s.begin() + 1, s.end());
        if (s.find(p) != -1) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main(){
  	long long N,res = 0,minAB = 0;
  	cin >> N;
  	vector<long long> A(N+1);
  	vector<long long> B(N);
  	for(int i = 0; i < N+1; i++){
    	cin >> A[i];
    }
  
  	for(int i = 0; i < N; i++){
    	cin >> B[i];
    }
  
  	for(int i = 0; i < N; i++){
		minAB = min(A[i],B[i]);
      	A[i] -= minAB;
      	B[i] -= minAB;
      	res += minAB;
      
      	minAB = min(A[i+1],B[i]);
      	A[i+1] -= minAB;
      	B[i] -= minAB;
      	res += minAB;
    } 
  	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main() {
  uint32_t N = 0, L = 0;
  std::cin >> N >> L;

  std::vector<std::string> S(N);
  for (auto &&S_n : S) std::cin >> S_n;

  std::sort(S.begin(), S.end());

  for (auto &&S_n : S) std::cout << S_n;
  std::cout << std::endl;

  return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  priority_queue<int> price;
  long long sum = 0;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    price.push(x);
    sum += x;
  }
  
  long long dec = 0;
  for (int i = 0; i < M; i++) {
    int a = price.top();
    price.pop();
    dec += (a+1)/2;
    price.push(a/2);
  }
  
  cout << sum-dec << endl;
}

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

namespace ConsoleApp15
{
    class Class131
    {
        static void Main()
        {
            string S = Console.ReadLine();
            long ans = 0;
            for(int i = 0; i < (1 << S.Length - 1); i++)
            {
                long sum = int.Parse(S[0].ToString());
                for(int j = 1; j < S.Length; j++)
                {
                    if ((i & (1 << j - 1)) > 0)
                    {
                        ans += sum;
                        sum = int.Parse(S[j].ToString());
                    }
                    else
                    {
                        sum *= 10;
                        sum += int.Parse(S[j].ToString());
                    }
                }
                ans += sum;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,d=0;
  bool z=0;
  cin>>a;
  for(int i=1;i<=a;i++)
  {
    int b,c;
    cin>>b>>c;
    if(b==c)
     {
	  d++;
      if(d>=3)
      z=1;
     }
    else
      d=0;
  
  }
  if(z)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <set>
#include <map>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define for_p(i, a, b) for(int i = a; i < b; i++)
#define for_m(i, a, b) for(int i = a - 1; i >= b; i--)

//a = s1.size();
//vector<string> s1;
//string s2 = accumulate( s1.begin(), s1.end(), string() );

using namespace std;

int main()
{
  int a = 0 , b = 0, c = 0, d = 0, e = 0, f = 0;
  int i = 0, j = 0;
  double d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0;
  int a1[256], a2[512], a3[1024];
  char s1[200000], s2[200000], s3[200000];
  
  cin >> a;
  
  for(i = 0; i < a; i++){
    cin >> a1[i];
  }
  for(i = 0; i < a; i++){
    cin >> a2[i];
  }
  for(i = 0; i < a - 1; i++){
    cin >> a3[i];
  }
  for(i = 0; i < a; i++){
    if(i != a - 1 && a1[i] == a1[i + 1] - 1){
      b += a2[a1[i] - 1] + a3[a1[i] - 1];
    }else{
      b += a2[a1[i] - 1];
    }
  }
  cout << b << endl;
}

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

struct Edge {
    int from, to;
    int cost;
}

struct State {
    int v;
    int cost;
    int opCmp(const ref State s) const {
        return cost - s.cost;
    }
}

void main() {
    int N, M, K;
    readf("%d %d %d\n", &N, &M, &K);
    Edge[][] G = new Edge[][N];
    foreach (i; 0 .. M) {
        int a, b, l; readf("%d %d %d\n", &a, &b, &l);
        a--; b--;
        G[a] ~= Edge(a, b, l);
        G[b] ~= Edge(b, a, l);
    }
    int[] D = new int[N];
    D[] = int.max / 2;
    BinaryHeap!(Array!State, "a > b") Q;
    foreach (i; 0 .. K) {
        int s; readf("%d\n", &s);
        s--;
        D[s] = 0; 
        Q.insert(State(s, 0));
    }
    // dijkstra
    while (!Q.empty) {
        State s = Q.front; Q.removeFront;
        foreach (e; G[s.v]) {
            if (D[e.to] > D[s.v] + e.cost) {
                D[e.to] = D[s.v] + e.cost;
                Q.insert(State(e.to, D[e.to]));
            }
        }
    }
    int ans = 0;
    foreach (i; 0 .. N) {
        ans = max(ans, D[i]);
    }
    foreach (i; 0 .. N) {
        foreach (e; G[i]) {
            static int div2(int x) {
                return (x + 1) / 2;
            }
            ans = max(ans, div2(D[e.from] + D[e.to] + e.cost));
        }
    }
    ans.writeln;
}

Measured memory_bytes: 8348
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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; }

vector< vector<int> > Graph;
vector< int > value;









int main(int argc, const char * argv[]) {
    
   
    
    int n,k,q; cin >> n >> k >> q;
    vector<int> A;
    rep(i,q) {
        int a; cin >> a;
        A.push_back(a-1);
    }
    
    
    
    vector<ll> AnswerCount(n);
    rep(i,q) AnswerCount[A[i]]++;
    
    vector<ll> RUISEKI(n);
    
    RUISEKI[0] = AnswerCount[0];
    for (int i = 1; i < n; i++) RUISEKI[i] = AnswerCount[i] + RUISEKI[i-1];
    
    
    
    
    if(RUISEKI[n-1] - RUISEKI[0] < k) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    for (int i = 1; i < n; i++) {
        if(RUISEKI[n-1] + RUISEKI[i-1] - RUISEKI[i] < k) cout << "Yes" << endl;
        else cout << "No" << endl;
        
    }
    
    
    
    
    
    
}


Measured memory_bytes: 2680
object Main {
  def main(args: Array[String]): Unit = {
    val lines = io.Source.stdin.getLines().toArray
    println(D.solve(lines))
  }
}

object D {
  val ACGT = List('A', 'C', 'G', 'T')
  val modulus = 1000 * 1000 * 1000 + 7


  def solve(input: Array[String]) = {
    var memo = initMemo()
    val N = input(0).toInt
    (3 to N).foreach { n =>
      memo  = memo ++ Array(forward(memo(n-1)))
    }
    memo(N).values.reduce { (src, dst) =>
      (src + dst) % modulus
    }
  }

  def initMemo() = {
    var memo: Array[Map[String, Int]] = Array(Map.empty, Map.empty, Map.empty)
    memo(2) = ACGT.flatMap { c1 =>
      ACGT.map { c2 =>
        f"$c1$c2" -> 1
      }
    }.toMap
    memo
  }


  def forward(currentMemo: Map[String, Int]) = {
    var nextMemo = Map[String, Int]().withDefaultValue(0)
    currentMemo.keys.foreach { last =>
      ACGT.foreach { c =>
        if (isOK(last + c)) {
          val nextLast = last.takeRight(2) + c
          val added = (nextMemo(nextLast) + currentMemo(last)) % modulus
          val newItem = (nextLast) -> added
          nextMemo += newItem
        } else {
          //println(s"out!${last + c}")
        }
      }
    }
    nextMemo
  }

  def isOK(last: String) = {
    unContainsAGC(last) &&
      (0 until last.length-1).forall { i =>
        unContainsAGC(swapAdjacent(last, i))
      }
  }

  def unContainsAGC(s: String) = {
    !s.contains("AGC")
  }

  def swapAdjacent(last: String, idx: Int) = {
    val sArray = last.toArray
    val tmp = sArray(idx)
    sArray.update(idx, sArray(idx+1))
    sArray.update(idx+1, tmp)
    sArray.mkString("")
  }
}

Measured memory_bytes: 59456
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
#define inf 1e9
using namespace std;
 
inline void up(int &x,const int &y){if(x<y)x=y;}
inline void down(int &x,const int &y){if(x>y)x=y;}
const int maxn = 11000;
 
int n;
char s1[maxn],s2[maxn];
int pre1[maxn],pre2[maxn],topre[maxn],nex[maxn];
 
int cal(const int x,const int y)
{
	if(x<y) return pre2[x]+pre2[n]-pre2[y-1];
	else return pre2[x]-pre2[y-1];
}
int find_pre(const int x)
{
	if(topre[x]) return x-topre[x];
	else return x+n-topre[n];
}
int find_nex(const int x)
{
	if(nex[x]!=n+1) return nex[x]-x;
	else return nex[1]+n-x;
}
struct node{int left,right;}t[maxn]; int tp,mx[maxn];
inline bool cmp(const node x,const node y){return x.left<y.left;}
int solve()
{
	int re=inf;
	for(int i=0;i<n;i++)
	{
		int now=0; tp=0;
		for(int j=1;j<=n;j++)
		{
			int r=j-i<=0?j-i+n:j-i;
			if(s1[j]!=s2[r]) 
			{
				now++;
				if(s1[j]=='0') continue;
				if(cal(j,r)==0)	t[++tp]=(node){find_pre(r),find_nex(j)};
			}
		}
		sort(t+1,t+tp+1,cmp);
		int cost; mx[tp+1]=0;
		for(int j=tp;j>=1;j--) mx[j]=max(mx[j+1],t[j].right);
		cost=mx[1]*2;
		for(int j=1;j<=tp;j++)
		{
			int k=j+1;for(;k<=tp&&t[k].left==t[j].left;k++);k--;
			down(cost,2*(t[j].left+mx[k+1]));
			j=k;
		}
		if(!tp) cost=0;
		down(re,now+cost+i);
	}
	return re;
}
 
int main()
{
	scanf("%s",s1+1); scanf("%s",s2+1); n=strlen(s1+1);
	for(int i=1;i<=n;i++)
		pre1[i]=pre1[i-1]+(s1[i]-'0'),
		pre2[i]=pre2[i-1]+(s2[i]-'0');
	for(int las=0,i=1;i<=n;i++)
	{
		if(s2[i]=='1') las=i;
		topre[i]=las;
	}
	for(int las=n+1,i=n;i>=1;i--)
	{
		if(s2[i]=='1') las=i;
		nex[i]=las;
	}
	if(pre1[n]&&!pre2[n]) {puts("-1");return 0;}
	
	int ans=solve();
	
	for(int i=1;i*2<=n;i++)
		swap(s1[i],s1[n-i+1]),
		swap(s2[i],s2[n-i+1]);
	for(int i=1;i<=n;i++)
		pre1[i]=pre1[i-1]+(s1[i]-'0'),
		pre2[i]=pre2[i-1]+(s2[i]-'0');
	for(int las=0,i=1;i<=n;i++)
	{
		if(s2[i]=='1') las=i;
		topre[i]=las;
	}
	for(int las=n+1,i=n;i>=1;i--)
	{
		if(s2[i]=='1') las=i;
		nex[i]=las;
	}
	down(ans,solve());
	
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using P = pair<int,int>;
const int INF = 1000100100;

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int mod = 1000000007;

int main()
{
    int h, w; cin >> h >> w;
    int a[h][w];
    rep(i,h){
        rep(j,w){
            char moji; cin >> moji;
            if(moji == '.'){
                a[i][j] = 0;
            }else{
                a[i][j] = 1;
            }
        }
    }

    ll dp[h][w];
    rep(i,h) rep(j,w) dp[i][j] = 0;
    dp[0][0] = 1;
    rep(i,h){
        rep(j,w){
            if(a[i][j] == 1) continue;
            if(i == 0 && j == 0) continue;
            else if(i == 0){
                dp[i][j] = dp[i][j-1];
            }else if(j == 0){
                dp[i][j] = dp[i-1][j];
            }else{
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
            }
            dp[i][j] %= mod;
        }
    }

    cout << dp[h-1][w-1] << endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
typedef map<int,int> mp;

const int MOD = 1e9 + 7;


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

    ll n;
    vector<ll> v(5);
    cin >> n;
    rep(i, 5){
        cin >> v[i];
    }

    ll tmp = v[0];
    FOR(i, 1, 5){
        tmp = min(tmp, v[i]);
    }

    ll ans;
    if(n % tmp == 0){
        ans = n / tmp + 4;
    }else{
        ans = n / tmp + 5;
    }

    cout << ans << endl;

    return 0;
}



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

const int limit = 50 ;
int n , m ;
int a[limit], b[limit] ;
bool graph[limit][limit] ;
bool visit[limit] ;


void dfs(int x){
    visit[x] = true ;
    for(int x2 = 0 ; x2 < n ; ++x2){
        if( graph[x][x2] == false ) continue ;
        if( visit[x2] == true ) continue ;
        //visit[i] == true ;
        dfs(x2) ; 
    } 
}

int main(){
    cin >> n >> m ;
    rep(i,m){
        cin >> a[i] >> b[i] ;
        a[i]-- ; b[i]-- ;
        graph[a[i]][b[i]] =  graph[b[i]][a[i]] = true ;
    }
    int ans = 0 ;
    rep(i,m){
        graph[a[i]][b[i]] =  graph[b[i]][a[i]] = false ;
        rep(j,n)  visit[j] = false ;
        dfs(0) ;
        bool bridge = false ;
        rep(j,n) if( visit[j] == false ) bridge = true ;
        if(bridge) ans += 1 ;
        graph[a[i]][b[i]] =  graph[b[i]][a[i]] = true ;

    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int a,b;
    cin >> a >> b;
    cout << max(a * 2 - 1, max(a + b, b * 2 - 1)) << endl;

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

int main() {
	int n;
	cin >> n;
	
	vector<ll> v(n);
	int minus = 0;
	for(int i = 0; i < n; i++) {
		cin >> v[i];
		if(v[i] < 0) {
			minus++;
		}
	}
	
	ll sum = 0;
	ll min = 10000000000;
	for(int i = 0; i < n; i++) {
		sum += abs(v[i]);
		if(min > abs(v[i])) {
			min = abs(v[i]);
		}
	}
	
	ll ans = 0;
	if(minus % 2 == 0) {
		cout << sum << endl;
	}
	else {
		cout << sum - (2 * min) << endl;
	}
	
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = [int(input()) for _ in range(N)]

from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort

def solve(N,A):
    ans = 0
    lis = []
    for i in range(N):
        ind = bisect_right(lis,-A[i])
        if ind == len(lis):
            lis.append(-A[i])
        else:
            lis[ind] = -A[i]
    ans = len(lis)
    return ans
print(solve(N,A))

Measured memory_bytes: 11032
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	int32_t min = 999999;
	for (int32_t i = 1; i < N; i++)
	{
		auto s = std::to_string(i);
		auto s2 = std::to_string(N-i);

		int32_t tmp = 0;
		for (auto& c : s) { tmp += c - '0'; }
		for (auto& c : s2) { tmp += c - '0'; }
		min = std::min(min, tmp);
	}
	out << min << endl;

	return 0;
}
#endif


Measured memory_bytes: 888
def read():
    r, D, x0 = list(map(int, input().strip().split()))
    return r, D, x0


def solve(r, D, x0):
    x = list()
    for i in range(10):
        x1 = r * x0 - D
        x.append(x1)
        x0 = x1
    return x


if __name__ == '__main__':
    inputs = read()
    for x in solve(*inputs):
        print("%d" % x)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vll vector<ll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,s,e) for(ll i=(s);(s>e)?i>e:i<e;(s>e)?i--:i++)
ll mod1 = 1e9 + 7;
ll mod2 = 998244353;

//ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}

ll g(ll x,ll y){
	ll ans = 1;
    while(y>1){
    	ll temp = __gcd(x,y);
    	y/= temp;
    	ans*= temp;
    	if(temp == 1)break;
    }
    return ans;
}
const long double pi = 3.141592653589793238;
void solve(){
 	ll n,m;
 	cin>>n>>m;
 	ll sum = 0;
 	fo(i,m){
 		ll t;
 		cin>>t;
 		sum+=t;
 	}
 	if(n>=sum)cout<<n-sum<<endl;
 	else cout<<-1<<endl;
}





int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
    #endif
    ll t = 1;
    //cin>>t;
    while(t--){
    	solve();
    }
    
    		






}

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

namespace ConsoleApp1
{
    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            B();
        }

        static void B()
        {
            var w = Read();
            var hash = new HashSet<char>();
            foreach (var a in w)
                hash.Add(a);
            Println(hash.All(x => w.Count(b => b == x) % 2 == 0) ? "Yes" : "No");
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();

        static void Print(object value = null) => Console.Write(value.ToString());
        static void Println(object value = null) => Console.WriteLine(value.ToString());
    }
}


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

int main(){
    int N;
    cin >> N;
    double x[N],sum=0;
    string u[N];
    for (int i=0;i<N;++i){
        cin >> x[i] >> u[i];
        if(u[i]=="JPY") sum += x[i];
        else sum += x[i]*380000.0;
    }
    cout << sum << endl;
}





Measured memory_bytes: 256
s = gets.strip.split('')
t = gets.strip.split('')

target_indice = []
(s.length-t.length+1).times do |index|
  target_indice.push(index) if s.slice(index, t.length).zip(t).all? {|c_s, c_t| c_s==c_t || c_s=='?' }
end

if target_indice.empty?
  puts 'UNRESTORABLE'
  exit
end

result = target_indice.map {|i|
  tmp = s.dup
  tmp[i..i+t.length-1]=t
  tmp.map {|c| c=='?' ? 'a' : c }.join('')
}.sort.first
puts result


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
/* ちゃんと考えてわかって実装 */

const int MAX_V = 50;
const int MAX_S = 50 * MAX_V + 5;
const ll INF = 1e18;

struct Edge{
    int to, a, b;

    // これを書いたらerrorが取れた。どうして必要なのｫぉ
    Edge(int to, int a, int b):to(to),a(a),b(b) {}
};

struct State{
    int v, s; // state = (頂点, 所持金)
    ll x; // その状態までの経過時間

    // これを書いたらerrorが取れた。どうして必要なのｫぉ
    State(int v, int s, ll x):v(v),s(s),x(x) {}

    bool operator<(const State& a) const {
        return x > a.x; // (x < a.x だとちゃんと動かねぇ)
    }
};

vector<Edge> g[MAX_V]; // 各頂点から伸びている辺の集合として保持。
ll min_time[MAX_V][MAX_S+5]; // 状態(v, s)までの最小の時間を記録。


int main(void){
    int n, m, s;
    cin >> n >> m >> s;

    for(int i=0; i<m; i++){
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        g[u].emplace_back(v, a, b);
        g[v].emplace_back(u, a, b);
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<MAX_S+5; j++){
            min_time[i][j] = INF;
        }
    }

    vector<int> c(n), d(n);
    for(int i=0; i<n; i++){
        cin >> c[i] >> d[i];
    }

    s = min(s, MAX_S); // 十分な値で切り捨てる。
    priority_queue<State> pq;

    // pqに状態(v, s, x)を emplace するときに、
    // min_time[v][s]の値を x に更新する。(xが最小じゃないなら更新しない。)
    auto push = [&](int v, int s, ll x){
        if(s < 0) return;
        if(min_time[v][s] <= x) return;
        min_time[v][s] = x;
        pq.emplace(v, s, x);
    };
    // 初期状態は(0, s, 0)
    push(0, s, 0);
    while(!pq.empty()){
        State now = pq.top(); pq.pop();
        int v = now.v, s = now.s;
        ll x = now.x;

        //if(min_time[v][s] != x) continue; // なぜ?????
        
        // 遷移その1 : 換金
        int next_s = min(s+c[v], MAX_S);
        push(v, next_s, x+d[v]);
        

        // 遷移その2 : 電車に乗る
        // そこから伸びている辺を全てみる
        for(Edge e : g[v]){
            push(e.to, s-e.a, x+e.b);
        }
    }

    for(int i=1; i<n; i++){
        ll ans = INF;
        for(int j=0; j<MAX_S+5; j++){
            ans = min(ans, min_time[i][j]);
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

long long findGcd (long long a, long long b) {
    return a == 0 ? b : findGcd(b % a, a);
}

long long findLcm (long long a, long long b) {
    return a * b / findGcd(a, b);
}

int main () {
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    long long N;
    scanf("%lld", &N);
    printf("%lld\n", findLcm(2, N));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,n;
    cin>>a>>b>>n;
    if(b-1<n) n=b-1;
    cout<<n*a/b-a*(n/b);
}

Measured memory_bytes: 3640
N, M, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
    E[a].append(b)
    E[b].append(a)

visited = [False] * (N + 1)
visited[a] = True
visited[b] = True

A = [a]
while True:
    for v in E[a]:
        if not visited[v]:
            A.append(v)
            visited[v] = True
            a = v
            break
    else:
        break

B = [b]
while True:
    for v in E[b]:
        if not visited[v]:
            B.append(v)
            visited[v] = True
            b = v
            break
    else:
        break

ans = A[::-1] + B
print(len(ans))
print(*ans)

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

using namespace std;


const int L = 15; 
const int N = 1<<L; 
int d[L][L];
//int ss[L][N];
int comp[N];
int dp[N][L];

int n,MSK;

//void sub_sum(int i){
//    vector<int> pos(n, 0); // [j..0] : + - - - - 
//    int sum = 0;
//    for (int j = 0; j < n; j++) {
//        pos[j] = d[i][j] - sum;
//        sum += d[i][j];
//    }
//    sum = 0;
//    // since ...1000 by ...0111 add +---
//    for (int msk = 1; msk < MSK; msk++) {
//        sum += pos[__builtin_ctz(msk)];
//        ss[i][msk] = sum;
//    }
//}

void calc_comp(){
    for (int msk = 0; msk < MSK; msk++) {
        for (int i = 0; i < n; i++) {
            if (!(msk&(1<<i))) continue;
            for (int j = i+1; j < n; j++) {
                if (!(msk&(1<<j))) continue;
                comp[msk] += d[i][j];
            }
        }
    }
}

void solve() {
    int m;
    cin >> n >> m;
    MSK = 1<<n;
    //memset(d, 0x3f, sizeof d);
    for (int _ = 0; _ < m; _++) {
        int x,y,c;
        cin >> x >> y >> c;
        x--;y--;
        d[x][y] = d[y][x] = c;
    }
    for (int i = 0; i < n; i++) {
        d[i][i] = 0;
    }
    //for (int i = 0; i < n; i++) {
    //    sub_sum(i);
    //}
    calc_comp();
    memset(dp, 0x3f, sizeof dp);
    dp[1][0] = 0;
    for (int msk = 1; msk < MSK; msk++) {
        for (int sub = msk; sub; (sub-=1)&=msk) {
            int T = msk^sub;
            for (int j = 0; j < n; j++) {
                if (sub & (1<<j)) {
                    //int sum = 0;
                    //for (int i = 0; i < n; i++) {
                    //    if (i!=j && (sub & (1<<i)))
                    //        sum += ss[i][T];
                    //}
                    dp[msk][j] = min(dp[msk][j], dp[sub][j] - comp[sub^(1<<j)] - comp[T] +comp[msk^(1<<j)]);
                }
            }
        }
        for (int i = 0; i < n; i++) {
            if (msk & (1<<i)) continue;
            for (int j = 0; j < n; j++) {
                if ((msk & (1<<j)) && d[i][j]) {
                    dp[msk^(1<<i)][i] = min(dp[msk^(1<<i)][i], dp[msk][j] - comp[msk^(1<<j)] + comp[msk^(1<<j)^(1<<i)]);
                }
            }
        }
    }

    //for (int msk = 0; msk < MSK; msk++) {
    //    for (int i = 0; i < n; i++) {
    //        cout << dp[msk][i] << ' ';
    //    }cout << "\n";
    //}
    cout << dp[MSK-1][n-1];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
string s;
int ans=-1,cnt;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>s;
	for (int i=0;i<s.size();++i)
	{
		cnt=0;
		for (int j=i;j<s.size();++j)
		{
			if (s[j]!='A' && s[j]!='G' && s[j]!='C' && s[j]!='T') break;
			else ++cnt;
		}
		ans=max(ans,cnt);
	}
	cout<<ans;
	return 0;
}

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

#define MAX 1000000

using namespace std;

int eratos[MAX];
int primes[MAX];
int max_primes;

void MakePrimes(){
	int n = 0;
	eratos[0] = 1;
	eratos[1] = 1;
	eratos[2] = 0;
	for(int i = 2; i < MAX; ++i){
		if( eratos[i] == 0 ){
			for(int j = 2; i * j < MAX; ++j){
				eratos[i*j] = 1;
			}
			primes[n++] = i;
		}
	}
	primes[n++] = 1000003;
	max_primes = n;
}
int bin_search_prime(int n){
	int r = max_primes - 1, l = 0, m;

	while( r > l + 1 ){
		m = ( r + l ) / 2; 
		if( primes[m] > n )
			r = m;
		else if( primes[m] < n )
			l = m;
		else
			return m;
	}
	return l;
}

int main()
{
	MakePrimes();
	while(true){
		int n;
		int ans = 0;
		
		scanf("%d", &n);
		if( n == 0 ) break;

		for(int i = 0 ; i < n ; ++i){
			int X = 0;
			int p,m;
			scanf("%d%d", &p,&m);

			int l = bin_search_prime( std::max(0,p - m) );
			int r = bin_search_prime( std::min(MAX-1,p + m) );
			
			if( primes[l] < p-m ) ++l;
			X = (r - l) + 1;

			ans += X - 1;
		}

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

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,w,i,j;
  cin>>n>>w;
  long long int wt,p;
  long long int knap[w+1];
  for(i=0;i<=w;i++)
  knap[i]=0;
  for(i=0;i<n;i++)
  {
    cin>>wt>>p;
    for(j=w;j>=wt;j--)
    {
      knap[j]=max(knap[j-wt]+p,knap[j]);
    }
  }
  i=0;
  for(j=0;j<=w;j++)
    i=max(i,knap[j]);
  cout<<i;
  
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		ArrayList<Integer> lst = new ArrayList<Integer>();
		for(int i=0; i<10; i++)	lst.add(in.nextInt());
		Collections.sort(lst);
		System.out.println(lst.get(9));
		System.out.println(lst.get(8));
		System.out.println(lst.get(7));
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;

int main(){
  int i;
  int count = 0;
  int N;
  cin >> N;
  int d[N-1];
  for (i = 0; i < N; i++) {
    cin >> d[i];
  }

  sort(d, d + N, greater<int>());
  for (i = 0; i < N-1; i++) {
    if(d[i] == d[i+1])
    continue;
    count++;
  }

  cout << count + 1 << endl;
}


Measured memory_bytes: 256
from heapq import heappop, heappush
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M, S = map(int, input().split())
S = min(2500, S)

# INPUT
PATH = [[] for _ in range(N + 1)]
CHANGES = [None] * (N + 1)

for _ in range(M):
    U, V, A, B = map(int, input().split())
    PATH[U].append((V, A, B))
    PATH[V].append((U, A, B))

for i in range(N):
    C, D = map(int, input().split())
    CHANGES[i + 1] = (C, D)

Q = []
INF = float("inf")
TIME = [[INF] * 2501 for _ in range(N + 1)]
USED = [[False] * 2501 for _ in range(N + 1)]

Q.append((0, 1, S))
TIME[1][S] = 0

while Q:
    t, u, g = heappop(Q)

    # そこで銀貨を増やす
    # 2500枚未満の場合
    if g < 2500:
        c, d = CHANGES[u]
        ng = min(g + c, 2500)
        nt = t + d

        if nt < TIME[u][ng]:
            TIME[u][ng] = nt
            heappush(Q, (nt, u, ng))

    # 次の頂点に進む
    for v, a, b in PATH[u]:
        if g < a:
            continue

        ng = g - a
        nt = t + b
        if nt < TIME[v][ng]:
            TIME[v][ng] = nt
            heappush(Q, (nt, v, ng))

ANS = [min(x) for x in TIME[2:]]
print("\n".join(map(str, ANS)))


Measured memory_bytes: 25344
import scala.io.StdIn.readInt

object Main {
   def main(args: Array[String]) = {
     val n = readInt()
     val r0 = readInt()
     val r1 = readInt()
     var max = r1 - r0
     var min = if(r0 > r1) r1 else r0

     for( i <- 2 to n-1 ) {
       val m = readInt()
       if( max < m - min) {
         max = m - min
         if( min > m )
           min = m
       }
       else if( min > m ) {
         min = m
       }
     }
     println(max)
  }
}

Measured memory_bytes: 62940
#include<bits/stdc++.h>                                                      
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for(int64_t i=0; i<N; i++){
    cin >> A.at(i);
  }
  int64_t max=0;
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(i!=j){
        if(abs(A.at(i)-A.at(j))>max)
          max=abs(A.at(i)-A.at(j));
      }
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

int N;
vector<int> A;

int main() {
	cin >> N;
	A.resize(N+1);
	A[0] = INT_MIN;
	for (int n = 1; n <= N; n++) {
		cin >> A[n];
		A[n] -= n;
	}
	sort(A.begin(), A.end());
	int b;
	if (N % 2 == 0)b = A[N / 2];
	else b = A[N / 2 + 1];
	long long ans = 0;
	for (int n = 1; n <= N; n++) {
		if (A[n] < b)ans += (long long)b - A[n];
		else ans += (long long)A[n] - b;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
mod=998244353

def cmb(n,r):
  if r<0 or r>n:
    return 0
  return (g1[n]*g2[r]*g2[n-r])%mod

g1=[1,1]
g2=[1,1]
inv=[0,1]
for i in range(2,100003):
  g1.append((g1[-1]*i)%mod)
  inv.append((-inv[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inv[-1])%mod)
K,N=map(int,input().split())
C=[0]*(2*K)
for i in range(K):
  for j in range(i+1,K):
    C[i+j]+=1
for i in range(2*K-1):
  P=0
  if i&1:
    for j in range(C[i]+1):
      P=(P+cmb(K+N-2*C[i]-1,N-j)*pow(2,j,mod)*cmb(C[i],j))%mod
  else:
    for k in range(2):
      for j in range(C[i]+1):
        P=(P+cmb(K+N-2*C[i]-2-k,N-j-k)*pow(2,j,mod)*cmb(C[i],j))%mod
  print(P)

Measured memory_bytes: 91728
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define fr(i,x,n) for(int i=x;i<=n;i++)
#define rf(i,n,x) for(int i=n;i>=x;i--)
#define mst(x,i) memset(x,i,sizeof(x))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define PB push_back
#define X first
#define Y second
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int maxn=1E5+5;
const int maxm=1E5+5;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const LL mod=1E9+7;
const double eps=1E-6;
const double PI=acos(-1.0);
template<class T>
bool scan(T &ret){
    char c;int sgn;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    ret*=sgn;
    return 1;
}
template<class T>
T gcd(T a,T b){
    return b==0?a:gcd(b,a%b);
}
template<class T>
T qpow(T a,T b,T mod){
    T ret=1;
    a%=mod;
    while(b){
        if(b&1) ret=(a*ret)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return ret%mod;
}
int a[maxn];
void solve(){
    int n;cin>>n;
    rep1(i,n) cin>>a[i];
    int mark=-1,cur=0,mx=0;
    rf(i,n,1){
        if(mark==-1) mark=a[i];
        else{
            if(a[i]>=mark) mark=a[i],cur++;
            else mark=a[i],cur=0;
            mx=max(mx,cur);
        }
    }
    cout<<mx<<endl;
}
int main(){
#ifdef LOCAL
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif
    IOS;
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const int N=200005;
int a[N],n;
bool big (int x,int y,int k)	{return a[x]>=k&&a[y]>=k;}
bool small (int x,int y,int k)	{return a[x]<k&&a[y]<k;}
bool check (int x)
{
	for (int u=0;u<n-1;u++)
	{
		if (big(n+u,n+u+1,x)||big(n-u,n-u-1,x)) return true;
		if (small(n+u,n+u+1,x)||small(n-u,n-u-1,x)) return false;
	}
	return big(1,1,x);
}
int main()
{
	scanf("%d",&n);
	for (int u=1;u<=n*2-1;u++) scanf("%d",&a[u]);
	int l=1,r=n*2-1;
	int lalal;
	while (l<=r)
	{
		int mid=(l+r)>>1;
		if (check(mid)) {l=mid+1;lalal=mid;}
		else r=mid-1;
	}
	printf("%d\n",lalal);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize(-O3)
#pragma GCC optimize(0fast)
#pragma GCC optimize("unroll-loops")

#define fi first
#define se second
#define sqr(x) (x) * (x)
#define p_b push_back
#define m_p make_pair
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
#define pw(x) (1ll << x)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
const ll MAXN = 1123456;
const ll N = 1e6;
const ll MOD = 1e9 + 7;

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

template <typename T> void vout(T s){cout << s << endl; exit(0);}


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

    ll n, k, t;
    cin >> n >> k;
    t = n;

    set <pll> res;

    res.insert({1ll, 2ll});

    for(int i = 3; i <= n; i++){
        res.insert({1ll, i});

        for(int j = 2; j < i; j++){
            if(!k){
                res.insert({j, i});
            }else k--;
        }

    }


    if(k)vout(-1);
    cout << res.size() << "\n";
    for(auto i : res)cout << i.fi << " " << i.se << "\n";


    return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    A = [None] * N
    B = [None] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    print(max(A)+B[A.index(max(A))])

if __name__ == "__main__":
    main()


Measured memory_bytes: 17192
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,m;
    cin>>n>>m;
    if(n==m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x;
string s;

// <---------------------- > //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	vll a(n+1);
	for(ll i=1;i<=n;i++) cin>>a[i];
	
	vll l(n+1), r(n+2);
	r[n+1] = 0;
	
	for(ll i=1;i<=n;i++) {
		l[i] = __gcd(l[i-1],a[i]);
	}

	for(ll i=n;i>=1;i--) {
		r[i] = __gcd(r[i+1],a[i]);
	}

	ll maxi = 0;
	/*for(ll i=1;i<=n;i++) {

	}*/

	for(ll i=1;i<=n;i++) {
		maxi = max(maxi , __gcd(l[i-1],r[i+1]));
	}

	cout<<maxi;
}


int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {

		MAIN();
	}
	return 0;
}


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int total;
    total = H2 * 60 + M2 - (H1 * 60 + M1);
    cout << total - K << endl;
    
    return 0;
}


Measured memory_bytes: 3616
import sys
import math
import collections
import bisect
import copy

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, m = ns()
    d = []
    for _ in range(m):
        a, b = ns()
        d.append([a - 1, b - 1])

    d.sort(key=lambda x: x[1])

    down = -1
    ans = 0
    for a, b in d:
        if down < a:
            down = b-1
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25956
# include<iostream>
# include<string>
# include<algorithm>
using namespace std;
# define N 1001
# define L 1001

int main(){
    string A[2][N];
    int cnt[2];
    for(int i=0; i<2; i++){
        int j=0;
        while((A[i][j] = cin.get()) != "\n"){
            j++;
            cnt[i]++;
        }
    }

    int B[L][L];
    for(int i=0; i<=cnt[0]; i++){
        string str;
        if(i!=0) str = A[0][i-1];
        for(int j=0; j<=cnt[1]; j++){
            if(i==0) B[i][j] = j;
            else if(j==0) B[i][j] = i;
            else if(A[1][j-1] != str) B[i][j] = min({B[i-1][j]+1, B[i][j-1]+1, B[i-1][j-1]+1});
            else B[i][j] = B[i-1][j-1];
        }
    }

    cout << B[cnt[0]][cnt[1]] << "\n";
    return 0;
}



Measured memory_bytes: 7192
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <numeric>
#include <limits>

using namespace std;

typedef long long ll;

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

int main()
{
    int a,b,c;
    
    scanf("%d%d%d",&a,&b,&c);
    int g=gcd(a,b);
    int r=c%b;
    if(r%g) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}


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

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> as(n);
	for (auto &&a : as)
	{
		cin >> a;
	}

	vector<int64_t> cnt(n + 1, 0);
	for (auto &&a : as)
	{
		cnt[a]++;
	}

	int64_t sum = 0;
	for (auto &&x : cnt)
	{
		sum += (x * (x - 1)) / 2;
	}

	for (auto &&a : as)
	{
		cout << (sum - cnt[a] + 1) << endl;
	}

	return 0;
}

Measured memory_bytes: 5760