akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<stack>
#include<algorithm>
using namespace std;
const int maxn=2e5+5;
const int mod=998244353;
int n,dp[maxn];
pair<int,int> a[maxn];
stack < pair<int,int> > pos;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d %d",&a[i].first,&a[i].second);
    }
    sort(a+1,a+1+n);
    dp[n+1]=1;
    for(int i=n;i>=1;i--){
        int t=a[i].first+a[i].second,next=i+1;
        while(!pos.empty()&&t>a[pos.top().first].first){//注意没有等于号
            next=pos.top().second;
            pos.pop();
        }
        pos.push({i,next});
        dp[i]=(dp[i+1]+dp[next])%mod;
    }
    printf("%d\n",dp[1]);
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <math.h>
#include <iostream>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define MOD (1000000007)
using namespace std;
 
int main(){
  int n;
  cin >> n;
  long int h[n], max;
  bool flag = true;
  REP(i,n) cin >> h[i];
  for(int i=n-2;i>=0;i--){
    if(h[i]>h[i+1]){
      h[i] -= 1;
      if(h[i]>h[i+1]){
        flag = false;
      }
    }
  }
  if(flag){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(){
	LL n;
    set<LL> s;
    cin>>n;
    auto v=divisor(n);
    for(const auto k:v){
        //cerr<<k<<endl;
        LL t=n;
        if(k==1)continue;
        while(t%k==0&&t!=0){
            t/=k;
        }
        t%=k;
        if(t==1){
            s.insert(k);
        }

    }
    //cerr<<"test"<<endl;
    n--;
    auto v2=divisor(n);
    for(const auto k:v2){
        if(k==1)continue;
        if((n+1)%k==0){

        }else{
            s.insert(k);
        }
    }
    cout<<s.size()<<endl;


}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl

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

  int H,W; cin >> H >> W;
  vector<string> S(H);
  rep(i,H) cin>>S[i];

  rep(i,H)rep(j,W) {
    if(S[i][j] == '#')continue;

    int cnt = 0;
    if(i-1>=0) {
      if(j-1>=0) if(S[i-1][j-1] == '#') ++cnt;   //左上
      if(S[i-1][j] == '#') ++cnt;               // 上
      if(j+1<=W-1) if(S[i-1][j+1] == '#') ++cnt;   // 右上
    }
    if(j-1>=0) if(S[i][j-1] == '#') ++cnt;               // 左
    if(j+1<=W-1) if(S[i][j+1] == '#') ++cnt;               // 右
    if(i+1<=H-1) {
      if(j-1>=0) if(S[i+1][j-1] =='#') ++cnt;          // 左下
      if(S[i+1][j] =='#') ++cnt;                      // 下
      if(j+1<=W-1) if(S[i+1][j+1] =='#') ++cnt;          // 右下
    }

    S[i].replace(j, 1, to_string(cnt));
  }

  rep(i,H) {
    rep(j,W) cout << S[i][j];
    cout << endl;
  }
  
  return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    char c;
    cin >> c;
    cout << (c >= 'A' && c <= 'Z' ? "A" : "a") << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;

int main(void){

  int a,b,c,res[4]={};

  while(cin >> a >> b >> c){
    
    if(a+b<=c || a+c<=b || b+c<=a){
      for(int i=0;i<4;i++){
	cout << res[i];
	if(i<3)cout <<" "; 
      }
      cout <<endl;
      break;
    }

    res[0]++;
    if(a*a+b*b==c*c || a*a+c*c==b*b || b*b+c*c==a*a)res[1]++;

    if(a*a+b*b>c*c && a*a+c*c>b*b && b*b+c*c>a*a)res[2]++;
    else if(a*a+b*b<c*c || a*a+c*c<b*b || b*b+c*c<a*a)res[3]++;
 
  }


  return 0;
}

Measured memory_bytes: 1164
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < s.length(); i++){
            int next = (alp.indexOf(String.valueOf(s.charAt(i))) + n) % alp.length();
            sb.append(String.valueOf(alp.charAt(next)));
        }
        System.out.println(sb.toString());
    }
}



Measured memory_bytes: 24148
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int w, a, b;
	cin >> w >> a >> b;
	int ans = max(0, max(a, b) - (min(a, b) + w));
	dunk(ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    LL ans = 0;
    REP(i,1,n+1) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
}

signed main() {
    solve();
    
    return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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 ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll d,g; cin>>d>>g;
  
  vll p(d), c(d);
  rep(i,d) cin>>p[i]>>c[i];
  
  ll ans=1000;
  for(ll bit=0; bit<(1<<d); bit++){
    ll cnt=0, sum=0;
    rep(i,d){
      if(bit&(1<<i)){
        cnt+=p[i];
        sum+=c[i]+100*(i+1)*p[i];
      }
    }
    if(sum>=g){
      chmin(ans,cnt);
      continue;
    }
    
    ll rem=g-sum;
    rrep(i,d){
      if(bit&(1<<i)) continue;
      ll x=(rem+(100*(i+1)-1))/(100*(i+1));
      if(x<=p[i]){
        cnt+=x;
        chmin(ans,cnt);
        break;
      }else{
        sum-=(100*(i+1))*p[i];
      }
    }
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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


		Scanner sc = new Scanner(System.in);

		//入力表示
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		
		int use=Math.min(C, A-B);
		
		if(A-B > C) {
			System.out.println(0);
		}else {
			System.out.println(C-use);
			
		}
	}

}

Measured memory_bytes: 22100
import java.util.Scanner;

public class Main {
	int field[][];
	int h;
	final static int VOID = -1;
	void run(){
		Scanner s = new Scanner(System.in);
		while(true){
			h = s.nextInt();
			if(h == 0)break;
			field = new int[h][5];
			for(int i = 0;i < h;i++){
				for(int j = 0;j < 5;j++){
					field[i][j] = s.nextInt();
				}
			}
			System.out.println(calcPts());
		}
	}
	/*
4
9 5 4 7 5
5 2 6 6 4
3 6 8 6 8
4 7 9 9 9
60
	 */

	int calcPts(){
		int pts = 0;
		while(true){
			boolean chainFlag = false;
			for(int i = 0;i < h;i++){
				int sameNum = 0;//????????¨??°??????????????°?????¨???????????´??????
				int sameCnt = 0;//????????????????????¨?????°???????????????
				int j;
				for(j = 0;j < 5;j++){
					if(sameNum == field[i][j]){
						if(field[i][j] == VOID)continue;
						sameCnt++;
					}else{
/*
 * ??????????????°?????¨????????´???????????????????????????????????????????????????
 * ??????????????¢???????????\???????????°?????????????????£???????????´??????
 * ????????´??????break??§???????¨?????????????????????????????¨????????????????
 * ?????????????¨??????¨????¶???????????????????break?????????
 * ??????????????????????´?????????£?????´??????????????´???????????????????¶??¶??????????????????????
 */
						if(sameCnt >= 2)break;
						sameNum = field[i][j];
						sameCnt = 0;
					}
				}
				if(sameCnt >= 2){
					/*
					System.out.println("setVOID");
					for(int x = 0;x < h;x++){
						for(int y = 0;y < 5;y++){
							System.out.print(field[x][y] + " ");
						}
						System.out.println();
					}
					*/
					j--;
					pts += (sameCnt+1) * sameNum;//?????????????¨????
					chainFlag = true;
					for(int k = 0;k <= sameCnt;k++)
						field[i][j-k] = VOID;
				}
			}
			if(chainFlag){
				/*
				System.out.println("fieldUpdate");
				for(int i = 0;i < h;i++){
					for(int j = 0;j < 5;j++){
						System.out.print(field[i][j] + " ");
					}
					System.out.println();
				}
				*/
				fieldUpdate();
			}else{
				break;
			}
		}
		return pts;
	}

	void fieldUpdate(){
		for(int i = h - 1;i > 0;i--)
			for(int j = 0;j < 5;j++)
				field[i][j] = getUpside(i,j,field[i][j]);
	}

	int getUpside(int x,int y,int set){
		if(field[x][y] != -1){
			int tmp = field[x][y];
			field[x][y] = set;
			return tmp;
		}else{
			if(x == 0){
				return -1;
			}else{
				return getUpside(x-1,y,set);
			}
		}
	}

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

Measured memory_bytes: 56576
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		(new Solver()).Solve();
	}
}


public class Solver
{
	private int N;
	private int M;
	private int[] A;
	private int[] B;
	private List<int>[] adj;

	public Solver()
	{
		N = GetInt();
		M = GetInt();
		A = new int[M];
		B = new int[M];
		adj = Enumerable.Range(0, N).Select(_ => new List<int>()).ToArray();
		for(int i = 0; i < M; i++)
		{
			A[i] = GetInt() - 1;
			B[i] = GetInt() - 1;
			adj[A[i]].Add(B[i]);
			adj[B[i]].Add(A[i]);
		}
	}

	public void Solve()
	{
		bool[] visited = new bool[N];
		var deq = new Deque<int>(N + 2);
		deq.PushBack(A[0]);
		deq.PushBack(B[0]);
		visited[A[0]] = true;
		visited[B[0]] = true;

		while(true)
		{
			bool update = false;

			int front = deq.PeekFront();
			foreach(int v in adj[front])
			{
				if(visited[v])
					continue;

				deq.PushFront(v);
				visited[v] = true;
				update = true;
				break;
			}

			int back = deq.PeekBack();
			foreach(int v in adj[back])
			{
				if(visited[v])
					continue;

				deq.PushBack(v);
				visited[v] = true;
				update = true;
				break;
			}

			if(!update)
				break;
		}

		var ans = new List<int>(deq.Count);
		while(deq.Count > 0)
			ans.Add(deq.PopFront() + 1);
		Console.WriteLine(ans.Count);
		Console.WriteLine(string.Join(" ", ans.Select(x => x.ToString()).ToArray()));
	}
}


public class Deque<T>
{
	private int size;
	private T[] buf;
	private int front;
	private int back;

	public int Count => (front > back) ? front - back : back - front;

	public Deque(int N)
	{
		size = N;
		buf = new T[N];
		front = 0;
		back = 0;
	}

	public void PushBack(T data)
	{
		if(Count == size)
			throw new Exception();

		buf[back] = data;
		back = (back == size - 1) ? 0 : back + 1;
	}

	public T PeekBack() => buf[(back == 0) ? size - 1 : back - 1];

	public T PopBack()
	{
		if(Count == 0)
			throw new Exception();

		back = (back == 0) ? size - 1 : back - 1;
		return buf[back];
	}
	
	public void PushFront(T data)
	{
		if(Count == size)
			throw new Exception();

		front = (front == 0) ? size - 1 : front - 1;
		buf[front] = data;
	}

	public T PeekFront() => buf[front];

	public T PopFront()
	{
		if(Count == 0)
			throw new Exception();

		T res = buf[front];
		front = (front == size - 1) ? 0 : front + 1;
		return res;
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


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

int main() {
  int A,B,K;
  cin >> A >> B >> K;
  vector<int> a={1};
  for(int i=1;i<=min(A,B);i++){
    if(A%i==0 && B%i==0) a.push_back(i);
  }
  sort(a.rbegin(),a.rend());
  cout << a[K-1];
}


Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

void dijkstra(int n) {
	priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>>que;
	fill(all(dij), INF);
	dij[n] = 0;
	que.push(pair<long long, long long>(0, n));

	while (!que.empty()) {
		pair<long long, long long>p = que.top();
		que.pop();
		long long mon = p.second;
		if (dij[mon] < p.first) continue;
		for (int i = 0; i < G[mon].size(); ++i) {
			edge e = G[mon][i];
			if (dij[e.to] > dij[mon] + e.cost) {
				dij[e.to] = dij[mon] + e.cost;
				que.push(pair<long long, long long>(dij[e.to], e.to));
			}
		}
	}
}


int main() {
	int n, m;
	cin >> n >> m;
	dij.resize(n + 1);
	G.resize(n + 1);
	for (int i = 0; i < m; ++i) {
		int a, b, c, d;
		char yu, ru, sann;
		cin >> a >> yu >> b >> ru >> c >> sann >> d;
		--a; --b;
		G[a].push_back({ b,c });
		G[b].push_back({ a,d });
	}
	int q, w, e, r, ans;
	char ze, tta, i;
	cin >> q >> ze >> w >> tta >> e >> i >> r;
	--q; --w;
	ans = e - r;
	dijkstra(q);
	ans -= dij[w];
	dijkstra(w);
	cout << ans - dij[q] << endl;
}


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

typedef long long ll;

using namespace std;

int n;

int toint(string &m){
    int j=1;
    int sum=0;
    for(int i=0;i<m.size();i++){
        if(m[i]=='m' ){
            sum += j*1000;
            j=1;
        }else if(m[i]=='c'){
            sum += j * 100;
            j=1;
        }else if(m[i]=='x'){
            sum += j * 10;
            j=1;
        }else if(m[i]=='i'){
            sum += j;
            j=1;
        }
        else{
            j = m[i] -48;
        }
    }
    return sum;
}

void tostr(int mi){
    while(mi != 0){
        if(mi/1000 >= 1){
            int t = mi/1000;
            if(mi/1000 == 1){
                printf("m");
            }else{
            
                printf("%c",t+48);
                printf("m");
            }
            mi -= t*1000;
        }else if(mi/100 >= 1){
            int t = mi/100;
            if(mi/100 == 1){
                printf("c");
            }else{
            
                printf("%c",t+48);
                printf("c");
            }
            mi -= t*100;
        }else if(mi/10 >= 1){
            int t = mi/10;
            if(mi/10 == 1){
                printf("x");
            }else{
            
                printf("%c",t+48);
                printf("x");
            }
            mi -= t*10;
        }else if(mi >= 1){
            int t = mi;
            if(mi == 1){
                printf("i");
            }else{
                printf("%c",t+48);
                printf("i");
            }
            mi -= t;
        }
    }
    
    puts("");

    return ;
}

int main(){
    string m1,m2;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> m1 >> m2;
        int mi1 = toint(m1);
        //cout << mi1 << endl;
        int mi2 = toint(m2);
        //cout << mi2 << endl;
        tostr(mi1+mi2);

    }
}


Measured memory_bytes: 3020
n = int(input())
h = [int(hi) for hi in input().split()]

inf = float('inf')

dp = [inf] * n

dp[0] = 0

for i in range(1, n):
  dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
  if i > 1:
    dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[-1])




Measured memory_bytes: 13980
#include <bits/stdc++.h>
    
#define int long long
    
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
    
using namespace std;
    
int dy[4]={1, -1, 0, 0};
int dx[4]={0, 0, 1, -1};

int32_t main(){
    int n;
    cin >> n;
    vector<int> v(n), a;
    REP(i, n){
        cin >> v[i];
        a.pb(v[i]);
    }
    SORT(v);

    double m = ((double)v[n/2-1]+(double)v[n/2])/2;
    REP(i, n){
        if(a[i]<m){
            cout << v[n/2] << endl;
        }
        else if(a[i]>m){
            cout << v[n/2-1] << endl;
        }
        else{
            cout << (int)m << endl;
        }
    }
}

Measured memory_bytes: 5488
#include<stdio.h>

int main(void){
  long long int n;
  scanf("%lld",&n);
  
  if(n%2==1){
    printf("0");
  }else{
    long long int k=0;
    n=n/2;
    while(n!=0){
      n=n/5;
      k=k+n;
    }
    printf("%lld",k);
  }
  
  return 0;
}

Measured memory_bytes: 128
def main():
    import sys
    inf = 100100100
    ans = inf
    H, W, K = map(int, input().split())
    S = [0]*H
    for i in range(H):
        S[i] = [int(x) for x in sys.stdin.readline().strip()]
    for i in range(2**(H-1)):
        group = [0]
        g = 0
        for j in range(H-1):
            if (i >> j) & 1:
                g += 1
            group.append(g)
        g += 1
        c = [[0 for _ in range(W)] for __ in range(g)]
        for j in range(H):
            for k in range(W):
                c[group[j]][k] += S[j][k]
        num = g-1
        now = [0]*g
        def large(now):
            for n in now:
                if n > K:
                    return True
            else:
                return False
        def v_vec(twodlis, k):
            ans = []
            for lis in twodlis:
                ans.append(lis[k])
            return ans
        for k in range(W):
            for n in range(len(now)):
                now[n] = now[n] + v_vec(c,k)[n]
            if large(now):
                now = v_vec(c,k)
                num += 1
                if large(now):
                    num = inf
                    break

        ans = min(ans, num)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 61532
a,b,c=(int(x) for x in input().split())
num = [a , b , c]
for i in range(2):
    for j in range(i , 2):
        if num[i] > num[j+1]:
            n = num[i]
            num[i] = num[j+1]
            num[j+1] = n

print(' '.join(map(str, num)))


Measured memory_bytes: 5604
M=10**9+7
x,y=map(int,input().split())
ans=0
if (x+y)%3==0:
  a=(2*y-x)//3
  b=(2*x-y)//3
  if a>=0 and b>=0:
    f1,f2=1,1
    for i in range(a+1,a+b+1):
      f1*=i
      f1%=M
    for i in range(1,b+1):
      f2*=i
      f2%=M
    ans=f1*pow(f2,M-2,M)

print(ans%M)


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

int main()
{
  int n;
  cin >> n;
  vector<int> p(n);
  int cnt = 0;

  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }

  for (int i = 0; i < n; i++) {
    if (p[i] == i + 1) {
      if (i != n - 1) {
        swap(p[i], p[i + 1]);
        cnt++;
      }
      else {
        swap(p[i], p[i - 1]);
        cnt++;
      }
    }
  }

  cout << cnt << endl;

  return (0);
}

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

int main() {
    int n;
    cin >> n;
    vector< int> v(n);
    for(int &e: v) cin >> e;
    sort(v.begin(), v.end());
    int k = unique(v.begin(), v.end()) - v.begin();
    cout << k << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <stdexcept>

class biglong {
	static const int part_digits = 8;
	static const int max_parts = 10;
	static const int max_digits = part_digits * max_parts;
	static const unsigned long max_part_value = 100000000;
	unsigned long parts[max_parts];
public:
	biglong(unsigned long value) : parts() { parts[0] = value; }
	biglong(const biglong& rhs) {
		std::copy(rhs.parts, rhs.parts + max_parts, parts);
	}
	explicit biglong(const std::string& rhs) : parts() {
		if (rhs.size() > max_digits) {
			throw std::overflow_error("biglong overflow");
		}
		int part_count = (static_cast<int>(rhs.size()) + part_digits - 1) / part_digits;
		int pos = static_cast<int>(rhs.size());
		for (int i = 0; i < part_count; ++i) {
			pos -= part_digits;
			if (pos < 0) {
				parts[i] = std::atol(rhs.substr(0, pos + part_digits).c_str());
			} else {
				parts[i] = std::atol(rhs.substr(pos, part_digits).c_str());
			}
		}
	}
	biglong& operator+=(const biglong& rhs) {
		for (int i = 0; i < max_parts - 1; ++i) {
			parts[i] += rhs.parts[i];
			if (parts[i] >= max_part_value) {
				parts[i] -= max_part_value;
				++parts[i + 1];
			}
		}
		parts[max_parts - 1] += rhs.parts[max_parts - 1];
		if (parts[max_parts - 1] >= max_part_value) {
			throw std::overflow_error("biglong overflow");
		}
		return *this;
	}
	std::string c_str() const {
		std::string result;
		for (int i = max_parts - 1; i >= 0; --i) {
			if (!result.empty() || parts[i] != 0) {
				char buff[12] = {};
				if (result.empty()) {
					sprintf(buff, "%lu", parts[i]);
				} else {
					sprintf(buff, "%0*lu", part_digits, parts[i]);
				}
				result += buff;
			}
		}
		if (result.empty()) {
			result = "0";
		}
		return result;
	}
};

biglong operator+(const biglong& lhs, const biglong& rhs)
{
	return biglong(lhs) += rhs;
}

std::ostream& operator<<(std::ostream& os, const biglong& value)
{
	return os << value.c_str();
}

int main()
{
	int count = 0;
	std::cin >> count;
	for (int i = 0; i < count; ++i) {
		std::string input1, input2;
		std::cin >> input1 >> input2;
		try {
			biglong value1(input1);
			biglong value2(input2);
			biglong sum = value1 + value2;
			std::cout << sum << std::endl;
		}
		catch (const std::overflow_error&) {
			std::cout << "overflow" << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1340
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    int sum = accumulate(A.begin(), A.end(), 0LL);
    int base = N * (N + 1) / 2;
    if (sum % base != 0) {
        cout << "NO" << endl;
        return 0;
    }
    vector<int> dif;
    for (int i = 0; i < N; i++) {
        if (i == 0) dif.push_back(A[i] - A[N - 1]);
        else dif.push_back(A[i] - A[i - 1]);
    }
    int calc = sum / base;
    for (int & i : dif) i -= calc;
    for (auto temp : dif) {
        if (abs(temp) % N != 0 || temp > 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 2168
use proconio::input;

fn f1(a:usize, b:usize) -> usize {
  if a == 0 {
    0
  } else {
    a/b + f1(a/b, b)
  }
}

fn f2(a:usize, b:usize) -> usize {
  if a % 2 == 1 {
    return f1(a, b) - f2(a-1, b);
  }
  let mut result = f1(a/2, b);
  if b == 2 {
    result += a/2;
  }
  result
}

fn main() {
  input!{
    mut n: usize,
  }
    
  println!("{}", std::cmp::min(f2(n, 2), f2(n, 5)));
}

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

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i<N; i++) {
    cin >> vec.at(i);
  }
  
  int ans = vec.at(0);
  for (int i = 1; i<N; i++) {
    ans = GCD(ans,vec.at(i));
  }
  
  cout << ans << endl;
  
  

  
  
}


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

bool f[214514];
ll a[214514];
int main(){
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	ll ans=0;
	vector<ll>num;
	for(int i=n;i>=1;i--){
		ll x=i,cnt=0;
		while(1){
			if(x>n)break;
			if(f[x])cnt^=1;
			x+=i;
		}
		if(cnt&&a[i]==0||!cnt&&a[i]==1){
			f[i]=1;
			num.push_back(i);
			ans++;
		}
	}
	cout<<ans<<endl;
	for(int i=0;i<ans;i++){
		if(i==ans-1)cout<<num[i]<<endl;
		else cout<<num[i]<<' ';
	}
	return 0;
}


Measured memory_bytes: 3700
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
c = "check"
for i in range(n):
    v = int(input())
    ind = 0
    if v in a1 :
        ind = a1.index(v)
        a1[ind] = c
    if v in a2 :
        ind = a2.index(v)
        a2[ind] = c
    if v in a3 :
        ind = a3.index(v)
        a3[ind] = c

if ((a1[0] == c and a2[0] == c and a3[0] == c) or  
    (a1[1] == c and a2[1] == c and a3[1] == c) or 
    (a1[2] == c and a2[2] == c and a3[2] == c) or 
    (a1[0] == c and a2[1] == c and a3[2] == c) or
    (a1[2] == c and a2[1] == c and a3[0] == c) or
    a1.count(c) == 3 or
    a2.count(c) == 3 or
    a3.count(c) == 3):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split()))
box = [0]*(N+1)
for i in range(N) :
    box[A[i]] += 1

x = list(map(lambda x: x*(x-1)//2 , box))
ans = sum(x)
for j in range(N) :
    print(ans-(box[A[j]] - 1))
    


Measured memory_bytes: 32264
#include <stdio.h>
#include <string.h>
int main()
{
    char S[10];
    gets(S);
    int i,flag = 0,len;
    len = strlen(S);
    for(i=0;i<len;i++)
    {
        if(S[5]=='0')
        {
            if(S[6]>='1' && S[6]<='4')
            {
                if(S[8]>='0' && S[8]<='2')
                {
                    if(S[9]>='0' && S[9]<='9')
                    {
                        flag = 1;
                    }
                }
                else if(S[8]=='3')
                {
                    if(S[9]=='0')
                    {
                        flag = 1;
                    }
                }
            }
        }
    }
    if(flag==1)
    {
        printf("Heisei\n");
    }
    else
    {
        printf("TBD\n");
    }
    return 0;
}


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

using namespace std;

struct data{
    int x,y,dir,cost;
    bool operator < (const data & a) const{
        if(cost != a.cost) return cost > a.cost;
        if(dir != a.dir) return dir < a.dir;
        if(x != a.x) return x < a.x;
        return y < a.y;
    }
};

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

int main(void){
    int w,h,i,j,k,s[30][30],c[4];

    while(1){
        scanf("%d %d",&w,&h);
        if(w == 0 && h == 0)break;

        for(i=0;i<h;++i){
            for(j=0;j<w;++j){
                scanf("%d",&s[i][j]);
            }
        }

        for(i=0;i<4;++i){
            scanf("%d",&c[i]);
        }

        priority_queue <data> Q;

        for(i=0;i<30;i++){
            for(j=0;j<30;j++){
                for(k=0;k<4;k++){
                    memo[i][j][k] = INT_MAX;
                }
            }
        }
        memo[0][0][0] = 0;

        Q.push((data){0,0,0,0});

        while(!Q.empty()){
            data temp;
            temp = Q.top();
            Q.pop();
            if(temp.x == h-1 && temp.y == w-1){
                printf("%d\n",temp.cost);
                break;
            }
            for(i=0;i<4;++i){
                int ncost = temp.cost, ndir = (temp.dir+i)&3;
                int nx = temp.x+dx[ndir], ny = temp.y+dy[ndir];
                if(s[temp.x][temp.y] != i){
                    ncost = temp.cost + c[i];
                }
                if(nx >= 0 && nx < h && ny >= 0 && ny < w){
                    if(memo[nx][ny][ndir] > ncost){
                        memo[nx][ny][ndir] = ncost;
                        Q.push((data){nx,ny,ndir,ncost});
                    }
                }
            }
        }

    }
}

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

int main()
{
	int N; 
	cin >> N;
	vector<pair<int, int>> w(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> w[i].first >> w[i].second;
	}

	sort(w.begin(), w.end(), [&](const auto& lhs, const auto& rhs) {return (lhs.second == rhs.second) ? lhs.first < rhs.first : lhs.second < rhs.second; });

	int done = 0;
	for (auto item : w)
	{
		done += item.first;
		if (done > item.second)
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}



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

int x[200000], y[200000];
int32_t main() {
	int n;
	cin >> n;
	int a;

	for (int i = 1; i <= n; ++i) {
		cin >> a;
		if (a + i < n)
			x[a + i]++;
		if (i - a > 0)
			y[i - a]++;
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += x[i] * y[i];
	}
	cout << ans << "\n";
}


Measured memory_bytes: 6708
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;


 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);
  
 

ll sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

void Solve();
/*
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}
*/


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 

signed main(){
  ll n;
    cin>>n;
  vll A(n);
  vll B(n);
  vll C(n);
  ll a=0;
  ll b=0;

  FOR(i,0,n){
    cin>>A[i];
    a+=A[i];
    C[i]+=A[i];
  }
  FOR(i,0,n){
    cin>>B[i];
    b+=B[i];
    C[i]-=B[i];
  }

  
  ll ans=0;
  if(a<b){
    cout<<-1<<endl;
    return 0;
  }

  SORT(C);
  
  ll c=0;
  FOR(i,0,n){
    if(C[i]<0){
      ans++;
      c+=C[i];
    }
    else{
      break;
    }
  }

  REV(C);
  ll I=0;
  while(c<0){
      c+=C[I];
      ans++;
      I++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b&&b!=c&&a!=c)||(a==c&&a!=b)||(c==b&&a!=c))cout<<"Yes";
	else cout<<"No"; 
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
char m[91];N,y;B(p){m[p]-49||(m[p]--,B(p+1)||B(p+2)||B(p+3),B(p-1)||B(p-2)||B(p-3),B(p+9)||B(p+18)||B(p+27),B(p-9)||B(p-18)||B(p-27));return m[p]-48;}main(n){for(scanf("%d",&n);n--;printf("Data %d:%s",++N,m+9))fread(m+8,1,74,stdin),scanf("%d%d",m,&y),B(y*9+*m);exit(0);}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define pi          3.14159265358979323


void solve()
{
       ll n;
       cin>>n;
       ll ans=0;
       vl fac;
       ll tn = n;
       for(ll i=1; i*i <= tn; i++)
       {
              if(tn%i==0)
              {
                     fac.pb(i);
                     if(tn/i!=i) fac.pb(n/i);
              }
       }
       set<ll>s;
       for(ll x : fac)
       {
              ll m = x-1;
              if(m!=0)
              {
                     ll ot = n / m;
                     if(ot * (m+1) == n)
                     {
                            if(s.find(m)==s.end())
                            {
                                   ans+=m;
                                   s.insert(m);
                            }
                     }
              }
       }
       cout<<ans;
}

int main()
{
       speed_up;
       ll T=1;
       //cin>>T;
       while(T--) solve();
	return 0;
}


Measured memory_bytes: 512
n=int(input())
l=list(map(int,input().split()))
c=1
lmax=l[0]
for i in range(1,n):
    if(lmax<=l[i]):
        c+=1 
        if(l[i]>lmax):
            lmax=l[i]
    elif(l[i]>lmax):
        lmax=l[i]
print(c)


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N; cin >> N;	
	string s,t; cin >> s; cin >> t;
	vector<int> vs(N+1),vt(N+1);
	vs[0] = s[0]-'0';
	vt[0] = t[0]-'0';
	repp(i,1,N){
		vs[i] = (s[i-1] != s[i]);
		vt[i] = (t[i-1] != t[i]);
	}
	vs[N] = s[N-1]-'0';
	vt[N] = t[N-1]-'0';
	vector<int> x,y;
	int c = 0;
	repp(i,0,N+1){
		if(vs[i] == 0){
			--c;
			x.push_back(i);
		}
		if(vt[i] == 0){
			++c;
			y.push_back(i);
		}
	}
	if(c < 0){
		swap(vs,vt);
		swap(x,y);
		c = -c;
	}
	int ans = 1e9+7;
	repp(i,-(x.size()/2),c/2+(x.size()/2)+1){
		vector<int> p = x, q = y;
		repp(j,i,0){
			q.push_back(0);
			q.push_back(1);
		}
		repp(j,0,i){
			p.push_back(0);
			p.push_back(1);
		}
		repp(j,i,c/2){
			p.push_back(N-1);
			p.push_back(N);
		}
		repp(j,c/2,i){
			q.push_back(N-1);
			q.push_back(N);
		}
		sort(p.begin(),p.end());
		sort(q.begin(),q.end());
		int d = 0;
		repp(i,0,p.size()) d += abs(p[i]-q[i]);
		ans = min(ans,d+c/2+max(0,max(-i,i-c/2))*2);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>


#define N 8 /* マス目の数 */

int PreQueen[N]; /* クイーンの初期配置 */

void printQueen(int queen[N])
{
    int i,j;

    for (i = 0; i < N; i++) {
        for (j = 0; j < N; j++)
        {
            if(queen[i] == j)
            {
                printf("Q");
            }
            else
            {
                printf(".");
            }
        }
        printf("\n");
    }
}

/* (i,j)の位置から縦横斜めの方向にある board のすべての要素の値に dを加える */
void changeBoard(int board[N][N], int i, int j, int d)
{
    int k;
    
    for (k = 0; k < N; k++)
    { 
        board[i][k] += d;             /* 横方向 */
        board[k][j] += d;             /* 縦方向 */
    }
    if (i > j)
    {
        for (k = 0; k < N-(i-j); k++)
        {
            board[k+(i-j)][k] += d;   /* 右下がり斜め方向 (i > jのとき） */
        }
    }
    else
    {
        for (k = 0; k < N-(j-i); k++)
        {
            board[k][k+(j-i)] += d;   /* 右下がり斜め方向 (i <= jのとき） */
        }
    }
    if (i+j < N)
    {
        for (k = 0; k <= i+j; k++)
        {
            board[i+j-k][k] += d;     /* 左下がり斜め方向（i +j < Nのとき） */
        }
    }
    else
    {
        for (k = i+j-N+1; k < N; k++)
        {
            board[i+j-k][k] += d;     /* 左下がり斜め方向（i+j >= Nのとき） */
        }
    }
}

/* i 行目のクイーンの位置を設定して， setQueen(queen, board, i+1) を呼び出す
   ただし， i == N のときは，一つの解が queen に入っているのでそれを表示するだけである */
void setQueen(int queen[N], int board[N][N], int i)
{
    int j;
    
    if (i == N)                     /* 解が見つかった */
    {
        printQueen(queen);
        return;
    }
    
    for (j = 0; j < N; j++)
    {
        if ( (board[i][j] == 0) || (PreQueen[i] == j) )  /* (i,j) の位置に置ける(または初期配置されている)ならば */
        {
            queen[i] = j;                      /* (i,j) の位置にクイーンを置く */
            changeBoard(board, i, j, +1);      /* (i,j) から縦横斜めの方向のboard値を+1する */
            setQueen(queen, board, i+1);       /* i+1 行目のクイーンの位置を決める */
            changeBoard(board, i, j, -1);      /* (i,j) から縦横斜めの方向のboard値を元に戻す */
        }
    }
}

int main()
{
    int k,n,C,R;
    int queen[N];
    int board[N][N];
    
    scanf("%d",&n);     /* 既にクイーンが配置されているマスの個数 */

    memset(board, 0, sizeof(board));
    memset(PreQueen, -1, sizeof(PreQueen));

    for(k = 0; k < n; k++)
    {
        scanf("%d%d",&C,&R);            /* 既にクイーンが配置されているマスの行と列 */
        PreQueen[C] = R;                /* (C,R) の位置にクイーンを置く */
        changeBoard(board, C, R, +1);   /* クイーンを配置するマスと襲撃可能なマスをセット */
    }

    setQueen(queen, board, 0);
    
    return 0;
}


Measured memory_bytes: 2052
/**
 *    +--+--+--++--++--In the name of ALLAH--++--++--+--+--+
 *
 *    author:  skmonir
 *    created: 02-Aug-2020 18:00:29
**/

#include <bits/stdc++.h>

using namespace std;

#define endl                '\n'
#define TN                  typename
#define mod                 1000000007LL
#define len(x)              (int) x.size()
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define mem(x, y)           memset(x, y, sizeof x)
#define FOR(x, l, r)        for (int x = l; x <= r; ++x)
#define ROF(x, l, r)        for (int x = l; x >= r; --x)

template <TN T> inline void INT(T &n) {
    n = 0; int f = 1; int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> inline void umin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void umax(T &a, T b) {a = a > b ? a : b;}
template <TN T, TN W> inline void INT(T &x, W &y) {INT(x), INT(y);}
template <TN T, TN W, TN Q> inline void INT(T &x, W &y, Q &z) {INT(x, y), INT(z);}

const int N = 1e5 + 7;
const int inf = 1e9 + 7;


int solve() {
    int n; cin >> n;
    puts(n >= 30 ? "Yes" : "No");

    return 0;
}

int main() {
    int tests = 1, CaseNo = 0;
    // INT(tests);
    while (tests--) {
        //printf("Case %d: ", ++CaseNo);
        solve();
    }
    return 0;
}

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

int main(){
  long N;
  cin >> N;
  long A[N];
  
  for(long i=1;i<N+1;i++){
    long x;
    cin >> x;
    A[x] = i;
  }
  for(long j=1;j<N+1;j++){
    cout << A[j] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1536