akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void)
{
	int a,h,m,s;
	scanf("%d",&a);
	h=a/3600;
	m=(a%3600)/60;
	s=(a%3600%60);
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}



Measured memory_bytes: 2736
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

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


int main(){
    ll h, w;
    cin >> h >> w;

    ll ans = h * w;
    vector<ll> s(3, 0);
    rep(i, 2) {
        for (ll j=1;j<h;++j) {
            // 縦割り
            s[0] = j * w;
            s[1] = (h - j) * (w / 2);
            s[2] = h * w - (s[0] + s[1]);
            sort(all(s));
            ans = min(ans, s[2] - s[0]);

            // 横割り
            s[0] = j * w;
            s[1] = ((h - j) / 2) * w;
            s[2] = h * w - (s[0] + s[1]);
            sort(all(s));
            ans = min(ans, s[2] - s[0]);
        }
        swap(h, w);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <thread>
#include <tuple>
#include <vector>
using namespace std;

struct TreeNode {
    int val;
    TreeNode* left;
    TreeNode* right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};

#define PI 3.14159265358979323846264338327950L

int main() {
    long double a, b, h, m;
    cin >> a;
    cin >> b;
    cin >> h;
    cin >> m;

    long double theta_a = (h + m / 60.0L) * 30.0L;
    long double theta_b = m * 6.0L;
    long double diff = (theta_a - theta_b) / 180.0L * PI;

    long double c = a * a + b * b - 2 * a * b * cosl(diff);

    printf("%20.20Lf\n", sqrtl(c));

    return 0;
}


Measured memory_bytes: 3524
#include <stdio.h>
int main(void) {
	int N, M, X, Y;
	scanf("%d%d%d%d", &N, &M, &X, &Y);
	int x[100];
	int y[100];
	int a = -100;
	int b = 100;
	for (int i = 0; i < N; i++) {
		scanf("%d", &x[i]);
		if (x[i] > a) {
			a = x[i];
		}

	}
	for (int i = 0; i < M; i++) {
		scanf("%d", &y[i]);
		if (y[i] < b) {
			b = y[i];
		}
	}

	for (int i = X; i <= Y;i++) {
		if (a < i&&i<= b&&X<i&&i<=Y) {
			printf("No War");
			break;
		}
		else if (i == Y) {
			printf("War");
			break;
		}
		
	}



	return 0;
}

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

using namespace std;

struct edge
{
  int u, v, cost;

  edge(int u, int v, int c) : u(u), v(v), cost(c) {}
};

const int INF = 1 << 30;

int main()
{
  int N, C;
  int A[200], O[200], B[200], S[200], D[200];

  auto bellman_ford = [&]()
  {
    vector< edge > edges;
    vector< int > v(N, INF);
    v[0] = 0;
    for(int i = 0; i < C; i++) {
      if(O[i] == 1) swap(A[i], B[i]);
      edges.emplace_back(B[i], A[i], 0);
      if(S[i] == 0) edges.emplace_back(B[i], A[i], -D[i]);
      else edges.emplace_back(A[i], B[i], D[i]);
      if(O[i] == 1) swap(A[i], B[i]);
    }
    for(int i = 0; i <= N; i++) {
      for(auto &e : edges) {
        if(v[e.u] + e.cost < v[e.v]) {
          v[e.v] = v[e.u] + e.cost;
          if(i == N || v[e.v] < 0) return (-1);
        }
      }
    }
    return (*max_element(begin(v), end(v)));
  };

  cin >> N >> C;
  vector< int > undefined;
  for(int i = 0; i < C; i++) {
    string str;
    cin >> str;
    int tail = 0, a = 0, b = 0, o, s, d = 0;
    while(isdigit(str[tail])) a = a * 10 + str[tail++] - '0';
    if(str[tail] == '*') o = 2;
    else if(str[tail] == '<') o = 0, ++tail;
    else o = 1, ++tail;
    ++tail;
    while(isdigit(str[tail])) b = b * 10 + str[tail++] - '0';
    if(str[tail] == '+') s = 0;
    else s = 1;
    ++tail;
    while(tail < str.size()) d = d * 10 + str[tail++] - '0';
    A[i] = --a, B[i] = --b, O[i] = o, S[i] = s, D[i] = d;
    if(o == 2) undefined.push_back(i);
  }
  int ret = -1;

  for(int i = 0; i < (1 << undefined.size()); i++) {
    for(int j = 0; j < undefined.size(); j++) O[undefined[j]] = (i >> j) & 1;
    ret = max(ret, bellman_ford());
  }

  if(ret >= INF) cout << "inf" << endl;
  else cout << ret << endl;
}

Measured memory_bytes: 3212
#include <cstdio>
#include <algorithm>
#include <cctype>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e5+5;
struct Edge
{
    int next, to;
    Edge(int next = 0, int to = 0):next(next), to(to) {};
}edge[N<<1];
int tot, head[N];
void _add(int x, int y) { edge[++tot] = Edge(head[x], y), head[x] = tot; }
void add(int x, int y) { _add(x, y), _add(y, x); }
int n, f[N], ans;
void dfs(int x, int fa)
{
    int s = 0, d = 20;
    for(int i = head[x]; i; i = edge[i].next)
    {
        int y = edge[i].to; if(y == fa) continue;
        dfs(y, x), s |= f[x]&f[y], f[x] |= f[y];
    }
    while(~d&&~s>>d&1) --d; ++d; while(f[x]>>d&1) ++d;
    f[x] = (f[x]>>d|1)<<d, ans = max(ans, d);
}
int main()
{
    n = read();
    for(int i = 1, x, y; i < n; ++i) x = read(), y = read(), add(x, y);
    dfs(1, 0), printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 7168
n = int(input())

ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
  s = input()
  if s == "AC":
    ac += 1
  if s == "WA":
    wa += 1
  if s == "TLE":
    tle += 1
  if s == "RE":
    re += 1

print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))

Measured memory_bytes: 9216
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c; cin >> c;
    cout << (c == 'A' ? 'T' : c == 'T' ? 'A' : c == 'C' ? 'G' : 'C') << '\n';
}


Measured memory_bytes: 888
#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; }

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

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





int main(int argc, const char * argv[]) {
   

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,k; cin >> n >> k;
    vector<ll> tree(n);
    rep(i,n) cin >> tree[i];
    
    sort(tree.begin(),tree.end());
    ll ans = 1000000000000;
    for (int i = 0; i < n - k + 1; i++) {
        ans = min(ans,tree[i+k-1] - tree[i]);
    }
    
    cout << ans << endl;
    
    
    
    
    
    
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(int argc, char* argv[]) {
  int N, M;
  cin >> N;

  map<long long, int> m;
  for (int i = 0; i < N; ++i) {
    long long d;
    cin >> d;
    if (m.find(d) == m.end())
      m[d] = 0;
    ++m[d];
  }

  cin >> M;

  long long t[M];
  for (int i = 0; i < M; ++i)
    cin >> t[i];

  for (int i = 0; i < M; ++i) {
    if (m.find(t[i]) == m.end() || m[t[i]] == 0) {
      cout << "NO" << endl;
      return 0;
    } else {
      --m[t[i]];
    }
  }

  cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 14336
X=int(input())
if X >= 400 and X<=599:
    print(8)
elif X>=600 and X<=799:
    print(7)
elif X>=800 and X<=999:
    print(6)
elif X>=1000 and X<=1199:
    print(5)
elif X>=1200 and X<=1399:
    print(4)
elif X>=1400 and X<=1599:
    print(3)
elif X>=1600 and X<=1799:
    print(2)
elif X>=1800 and X<=1999:
    print(1)

Measured memory_bytes: 9192
#include <stdio.h>
#include <cmath>

using namespace std;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  double ans = 0.0;
  for (int i = 1; i <= n; i++) {
    if (i >= k) {
      ans += 1.0 / n;
    } else {
      ans += pow(0.5, ceil(log2(k/(double)i))) / n;
    }
  }

  printf("%.12f", ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y<a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[101101];
int l[101111][4];
int j[1];

long long x,y,z,mod=1000000007;
//string r;
char r[1];

P u[1];
queue<int> q;
//stack<P> s;

vector<int> v[1111];

bool as(P a,P b)
{
  return a.x<b.x;
}

int main()
{
  scanf("%d %d",&a,&b);
  l[0][0]=a;
  for(int t=1;t<=b+1;t++)
  {
    if(t<=b) scanf("%d",&o[t]);
    else o[t]=1000000010;
    if(t%2)
    {
      l[t][0]=max(l[t-1][0]-(o[t]-o[t-1]),0);
      l[t][1]=max(l[t-1][1]-(o[t]-o[t-1]),0);
      l[t][2]=l[t-1][2];
      if(l[t][1]==0)l[t][3]=min(a-l[t][2],l[t-1][3]-l[t-1][1]+(o[t]-o[t-1]));
      else l[t][3]=l[t-1][3];
    }
    else
    {
      l[t][0]=min(l[t-1][0]+(o[t]-o[t-1]),a);
      l[t][1]=min(l[t-1][1]+(o[t]-o[t-1]),a);
      l[t][3]=l[t-1][3];
      if(l[t][0]==a)l[t][2]=min(a-l[t][3],l[t-1][2]+(l[t-1][0]+(o[t]-o[t-1])-a));
      else l[t][2]=l[t-1][2];
    }
  }
  b++;
  scanf("%d",&c);
  for(int t=1;t<=c;t++)
  {
    scanf("%d %d",&n,&m);
    for(;o[e+1]<=n&&e<b;e++);
    int p;
    if(m<=l[e][3]) p=l[e][1];
    else if(a<=m+l[e][2]) p=l[e][0];
    else p=l[e][1]+m-l[e][3];
    if(e%2) p+=n-o[e];
    else p-=n-o[e];
    printf("%d\n",max(min(a,p),0));
  }
}
//3




Measured memory_bytes: 3200
package main

import "fmt"

func main() {
	var h, w, n, sr, sc int
	var s, t string
	fmt.Scan(&h, &w, &n, &sr, &sc, &s, &t)

	ans := "YES"

	ri := w
	li := 1
	for i := n - 1; i >= 0; i-- {
		if t[i] == 'L' && ri < w {
			ri++
		} else if t[i] == 'R' && li > 1 {
			li--
		}
		if s[i] == 'L' {
			li++
		} else if s[i] == 'R' {
			ri--
		}
		if li > ri {
			ans = "NO"
			break
		}
	}
	if sc < li || ri < sc {
		ans = "NO"
	}

	di := h
	ui := 1
	for i := n - 1; i >= 0; i-- {
		if t[i] == 'U' && di < h {
			di++
		} else if t[i] == 'D' && ui > 1 {
			ui--
		}
		if s[i] == 'U' {
			ui++
		} else if s[i] == 'D' {
			di--
		}
		if ui > di {
			ans = "NO"
			break
		}
	}
	if sr < ui || di < sr {
		ans = "NO"
	}

	fmt.Println(ans)
}


Measured memory_bytes: 2176
#include <iostream>
#include<string>
using namespace std;
int main(void) {
	// Your code here!
	string a, b;
	cin >> a >> b;

	if (a == "H")
	{
		if (b == "H")		cout << "H" << endl;
		else if (b == "D")	cout << "D" << endl;
	}
	else if (a == "D") {
		if (b == "H") cout << "D" << endl;
		else if (b == "D") cout << "H" << endl;
	}

	return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;
int sum=0,ans=1e9;
int m,a[105];
int main(){
    ios::sync_with_stdio(false);
    cin>>m;
    for(int i=1;i<=m;i++)cin>>a[i],sum+=a[i];
    int pre=0;
    for(int i=1;i<=m;i++){
        pre+=a[i];
        ans = min(ans,abs(sum-pre-pre));
    }
    cout<<ans<<endl;
}


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

#define endl '\n'

#define PI 2 * acos(0.0);
#define INFLL 1e18
#define CLEAR(v, val) memset(v, val, sizeof(v))
#define print(x) cout << x << endl, exit(0)
#define watch(x) cerr << #x << " -> " << x << endl
// #define int long long

typedef long long ll;
typedef long double ld;

typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1000000000;
const int MOD = 1000000007; // 998244353

signed main() {  
   ios::sync_with_stdio(false);
   cin.tie(nullptr);
   int n, m;
   cin >> n >> m;
   int res[n + 1];
   CLEAR(res, 0);
   map<int, bool> done;
   while (m--) {
      int prob;
      cin >> prob;
      string s;
      cin >> s;
      if (s == "AC") {
         done[prob] = 1;
      } else {
         if (!done[prob])
            ++res[prob];
      }
   } 
   int ans = 0, bad = 0;
   for (int i = 1; i <= n; i++) {
      if (done[i]) {
         ++ans, bad += res[i];
      }
   }
   cout << ans << ' ' << bad << endl;
   return 0;
}

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

using namespace std;

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

#define all(x) x.begin(),x.end()

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

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

ll f(ll b,ll n){
	if(n<b) return n;
	return f(b,n/b) + n%b;
}

int main()
{
	ll n,s;
	cin>>n>>s;
	if(n==s){
		cout<<n+1<<endl;
		return 0;
	}
	ll ans = 1e18;
	for (ll b = 2; b*b <= n; b++){
		if(f(b,n) == s) ans = min(b,ans);
	}

	for (ll p = 1; p*p < n; p++){
		if((n-s)%p!=0) continue;
		ll b = (n-s)/p + 1;
		if(b<2)continue;
		if(f(b,n) == s) ans = min(b,ans);
	}
	if(ans==1e18)ans=-1LL;
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    if((b-a) % 2==0)
        return cout<<"Alice",0;
    cout<<"Borys",0; 
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	char str[101];
	int i,j,len;
	int a;
	
	while(scanf("%s",str)!=EOF){
		len=strlen(str);
		for(i=0;i<len;i++){
			if(str[i]=='@'){
				a=str[i+1]-'0';
				for(j=0;j<a;j++){
					printf("%c",str[i+2]);
				}
				i+=2;
			}
			else {
				printf("%c",str[i]);
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <numeric>

int main()
{
	int house[4][3][10] = {};
	int n;
	std::cin >> n;

	int b, f, r, v;
	for (int i = 0; i < n; ++i)
	{
		std::cin >> b >> f >> r >> v;
		house[b - 1][f - 1][r - 1] += v;
	}

	int count = 0;
	int roop = 4;
	for (auto& building : house)
	{
		for (auto& floor : building)
		{
			for (auto& room : floor)
			{
				std::cout << " " << room;
			}
			std::cout << std::endl;
		}
		count++;

		if (count != roop)
		{
			std::cout << "####################" << std::endl;
		}
		else
		{

		}
	}
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x;
    cin>>x;
    for(long long a=-1200;a<=1200;a++){
        for(long long b=-1200;b<=1200;b++){
            if(a*a*a*a*a-b*b*b*b*b==x){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>
int main()
{
    int n;
    std::string s;
    std::cin >> n >> s;
    std::string s1 = s.substr(0, n), s2 = s.substr(n);
    std::vector<std::pair<std::string, std::string>> v1(1 << n), v2(1 << n);
    for (int i = 0; i < 1 << n; ++i) {
        for (int j = 0; j < n; ++j) (i & (1 << j) ? v1[i].first : v1[i].second) += s1[j];
    }
    for (int i = 0; i < 1 << n; ++i) {
        for (int j = 0; j < n; ++j) (i & (1 << j) ? v2[i].first : v2[i].second) += s2[j];
        std::reverse(v2[i].first.begin(), v2[i].first.end());
        std::reverse(v2[i].second.begin(), v2[i].second.end());
    }
    std::sort(v2.begin(), v2.end());
    long long ans = 0;
    for (auto vv : v1) {
        auto p = std::make_pair(vv.second, vv.first);
        ans += std::upper_bound(v2.begin(), v2.end(), p) - std::lower_bound(v2.begin(), v2.end(), p);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 35972
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();//最初に太郎が持っているカードの枚数n
		int[][] bucket = new int[4][13];

		for (int i = 0; i < n; i++) {
			String a = sc.next();
			int b = sc.nextInt();
			if ("S".equals(a)) {
				bucket[0][b - 1] = 1;
			} else if ("H".equals(a)) {
				bucket[1][b - 1] = 1;
			} else if ("C".equals(a)) {
				bucket[2][b - 1] = 1;
			} else {
				bucket[3][b - 1] = 1;
			}
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 13; j++) {
				if (bucket[i][j] == 0) {
					if (i == 0) {
						System.out.println("S" + " " + (j + 1));
					}
					if (i == 1) {
						System.out.println("H" + " " + (j + 1));
					}
					if (i == 2) {
						System.out.println("C" + " " + (j + 1));
					}
					if (i == 3) {
						System.out.println("D" + " " + (j + 1));
					}
				}
			}

		}
	}
}



Measured memory_bytes: 26300
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
from copy import *

N, W = map(int, input().split())
dp1, dp2 = [0] * (W+1), [0] * (W+1)
for i in range(N):
    w, v = map(int, input().split())
    for j in range(W+1):
        if w <= j:
            dp2[j] = max(dp2[j], dp1[j-w]+v)
    dp1 = deepcopy(dp2)
print(max(dp1))


Measured memory_bytes: 126244
N = int(input())
M = []
for i in range(N):
    a = list(map(int,input().strip().split()))
    b = [int(i+1 in a[2:]) for i in range(N)]
    M.append(b)

time = 1
D = [-1 for _ in range(N)]
F = [-1 for _ in range(N)]
def dfs(src):
    global time # 関数内でglobal変数の書き換えることを宣言
    D[src] = time # 訪問時刻を記録
    time += 1
    for dst in range(N):
        # srcからdstに移動可能で、dstが未訪問だったら
        if M[src][dst] == 1 and D[dst] == -1:
            dfs(dst)
    F[src] = time # 訪問終了時刻を記録
    time += 1
    # 関数の終わりで親に戻る(青矢印)

for root in range(N):
    # 番号が若い節点から
    if D[root] == -1:
        # D[root]が未訪問だったら
        dfs(root) # dfsを始める

[print(i+1, D[i], F[i]) for i in range(N)]



Measured memory_bytes: 5792
// https://github.com/atcoder-live/library
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,(e))
#define irp(i,s,e) for(int i=(s);i>(e);--i)
#define irpz(i,s) irp(i,(s),-1)
template<class T> T in(){T x;cin>>x;return x;}
// long long a = in<long long>();
template<class T> void inarr(int s,int e,T &v){rp(i,s,e)cin>>v[i];}
// inarr<vi>(0,N,V);
#define NMAX 1000000
int N;
vi P(NMAX);

int solve(){
	int ans=0;
	int minP = INT_MAX;
	rpz(i,N){
		if(minP>=P[i]){
			minP = P[i];
			ans++;
		}
		else{

		}
	}
	return ans;
}

int main(){
	cin>>N;
	rpz(i,N) cin>>P[i];
	ote(solve());
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int a, b, c, n, x, y;
  vector<int> v(3);
  rep(i, 3) cin >> v[i];
  sort(v.begin(), v.end());
  if (v[2] == v[1] + v[0])

    Yes();
  else
    No();
  return 0;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
string ss;
int tot;
int main() {
	cin >> ss;
	for (unsigned int i = 1; i < ss.length(); i++) {
		if (ss[i] == ss[i - 1]) {
			if (ss[i] == '0')ss[i] = '1';
			else ss[i] = '0';
			tot++;
		}
	}
	int tmp = ss.length() - tot;
	cout << min(tot, tmp);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
using namespace std;
using ll = long long;

int main() {
	string s;
	cin >> s;
	vector<ll>a(s.length() + 1, 0), b(s.length() + 1, 0);
	ll sum = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '<')a[i + 1] = a[i] + 1;
	}
	for (int i = s.length() - 1; 0 <= i; i--) {
		if (s[i] == '>')b[i] = b[i + 1] + 1;
	}
	for (int i = 0; i <= s.length(); i++) {
		sum += max(a[i] , b[i]);
	}
	cout << sum << endl;
}

Measured memory_bytes: 8708
#include<bits/stdc++.h>
using namespace std;
long long int  a,b,ar[100008],i,j,k,m,x,y,cnt,sum,d,e,f,c,sum1;
string s[1000];

int main()
{
        cin>>a;
        sum1=0;
        sum=0;
        k=0;
        for(i=1; i<=a; i++)
        {
            cin>>s[i]>>ar[i];
            sum+=ar[i];
        }
        cin>>s[i];
        for(j=1; j<=a; j++)
        {
            if(s[j]!=s[i])
            {
                sum-=ar[j];
                k++;
            }
            else
            {sum-=ar[j];
            break;}

        }
            cout<<sum<<endl;
    }











Measured memory_bytes: 256
/*******************************\
   Name:    REAJUL HAQUE REAYZ  |
   School:  COMILLA UNIVERSITY  |
            CSE (5TH BATCH)     |
********************************/
#include<bits/stdc++.h>
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define mem(x,y) memset(x , y , sizeof(x))
using namespace std;
typedef long long ll;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const ll MOD = 1000000007;
const int MAX = 100005;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll a[3];
    cin>>a[0]>>a[1]>>a[2];
    int k;
    cin>>k;
    while(k--){
        sort(a,a+3);
        a[2]*=2;
    }
    cout<<a[0]+a[1]+a[2]<<endl;
	return 0;
}


Measured memory_bytes: 256
A, B, K = [int(i) for i in input().split()]

for i in range(0, K):

    if (i % 2 == 0):

        if (A % 2 != 0):
            A = A - 1

        a = A / 2
        A -= a
        B += a
    else:

        if (B % 2 != 0):
            B = B - 1

        b = B / 2
        B -= b
        A += b

print(int(A), int(B))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	vector<int> a(3);
	cin >> a;

	sort(all(a));
	int x = a[2] - a[0];
	int y = a[2] - a[1];

	int ans = x / 2 + y / 2;
	int odd = x % 2 + y % 2;
	if(odd == 1) ans += 2;
	if(odd == 2) ans += 1;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,S=0,i;cin>>N;int A[N];
  for(i=0;i<N;i++)cin>>A[i];
  i=0;
  while(i<N){
    S++;int j=i,x=0;
    while(j<N-1&&(A[j]-A[j+1])*x>=0){
      if(x==0&&A[j]!=A[j+1]){
        if(A[j]>A[j+1])x++;
        else x--;
      }
      j++;
    }
    i=j+1;
  }
  cout<<S<<endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define lin "\n"
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(0)
#define mod 1000000007
ll dp[2005];

void khelo() {
    dp[3] = dp[4] = dp[5] = 1;
    for (int i = 6; i <= 2000; ++i) {
        dp[i] = (dp[i - 1] + dp[i - 3]) % mod;
    }
}

void solve() {
    int n;
    cin >> n;
    cout << dp[n];
}

int main() {
//        fast_io;
    khelo();
    int t = 1;
    //    cin >> t;
//    scanf("%d", &t);
    int c = 1;
    while (t--) {
//        printf("Case %lld:\n", c);
        //        cout<<"Case "<<c<<": ";
        solve();
        c++;
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

class RMQ {
private:
    vector<ll> val;
    int N;
public:
    RMQ(int n, ll init);
    void update(int i, int x);
    ll find(int r, int l, int fn, int fr, int fl);
    ~RMQ();
};

RMQ::RMQ(int n, ll init) {
    N = n;
    val.resize(2*N-1, init);
}

void RMQ::update(int i, int x) {
    i += N-1;
    val[i] = x;
    while (i > 0) {
        i = (i-1)/2;
        val[i] = min(val[i*2+1], val[i*2+2]);
    }
}

ll RMQ::find(int a, int b, int k, int l, int r) {
    // [a, b)のクエリ
    // ノードk(区間[a, b)担当)が答える
    if (b <= l || r <= a) return LINF; // 区間がかぶらなければLINF
    if (a <= l && r <= b) return val[k]; // 区間が完全にかぶっていればval[k]
    else {
        // 一部だけかぶる場合は左右の子に委託する
        ll c1 = find(a, b, 2*k+1, l, (l+r)/2);
        ll c2 = find(a, b, 2*k+2, (l+r)/2, r);
        return min(c1, c2);
    }
}

RMQ::~RMQ() {
}

int main(int argc, char const *argv[]) {
    ll n, x;
    cin >> n >> x;
    int N = 1;
    while (N < n) {
        N *= 2;
    }
    RMQ seg(N, LINF);
    REP(i,n) {
        int a;
        cin >> a;
        seg.update(i, a);
    }

    ll ans = LINF;


    REP(k,n) {
        ll now = 0ll;
        REP(i,n) {
            if (i-k >= 0) {
                now += seg.find(i-k, i+1, 0, 0, N);
            }
            else {
                ll tmp1 = seg.find(0, i+1, 0, 0, N);
                ll tmp2 = seg.find(n+(i-k), n, 0, 0, N);
                now += min(tmp1,tmp2);
            }
        }
        ll t = k*x;
        now += t;
        ans = min(ans, now);
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int N;
    cin >> N;
    long long int prev;
    cin >> prev;
    int flag = 0;
    int cut = 1;
    for (int i=1; i<N; ++i) {
        long long int A;
        cin >> A;
        if (flag==0) {
            if (A - prev > 0) flag = 1;
            else if (A - prev < 0) flag = -1;
        } else if (flag==1) {
            if (A - prev < 0) {
                flag = 0;
                ++cut;
            }
        } else {
            if (A - prev > 0) {
                flag = 0;
                ++cut;
            }
        }
        prev = A;
    }

    cout << cut << endl;

    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
typedef long long lint;

using namespace std;

int main(){
	lint N;
	lint Y;
	cin >> N >> Y;
	lint sum=0;
	rep(y,N+1) rep(z,N-y+1){
		sum=5000*y+9000*z;
		if(sum==10000*N-Y) {
			cout << N-y-z << " " << y << " " << z << endl;
			return 0;
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int A[90][90], B[90][90];
bool dp[90][90][25441]; //12720*2+1

int main() {
    int H, W;
    cin >> H >> W;
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            cin >> A[i][j];
        }
    }
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            cin >> B[i][j];
        }
    }

    dp[0][0][A[0][0] - B[0][0] + 12720] = true;
    dp[0][0][B[0][0] - A[0][0] + 12720] = true;

    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            for (int k=0; k<25441; ++k) {
                if (dp[i][j][k]) {
                    if (i+1 < H) {
                        dp[i+1][j][k + A[i+1][j] - B[i+1][j]] = true;
                        dp[i+1][j][k + B[i+1][j] - A[i+1][j]] = true;
                    }
                    if (j+1 < W) {
                        dp[i][j+1][k + A[i][j+1] - B[i][j+1]] = true;
                        dp[i][j+1][k + B[i][j+1] - A[i][j+1]] = true;
                    }
                }
            }
        }
    }

    int mn = INT_MAX;
    for (int i=0; i<25441; ++i) {
        if (dp[H-1][W-1][i]) {
            mn = min(mn, abs(i - 12720));
        }
    }
    cout << mn << endl;

    return 0;
}

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

using namespace std;
using int_vec = vector<int>;

bool combination(int m, int_vec& v, int k) {
    if (m == 0)
        return true;
    if (k >= v.size())
        return false;

    return combination(m-v[k], v, k+1) || combination(m, v, k+1);
}

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

    int_vec v;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        v.push_back(x);
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int m;
        cin >> m;

        if (combination(m, v, 0)) {
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }
}

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

int buff[][7] = {
  {0, 1, 2, 4, 6, 7, 9},
  {1, 3, 4, 6, 8, 9, 11},
  {2, 4, 5, 7, 9, 10, 12},
  {4, 6, 7, 9, 11, 12, 14},
  {6, 8, 9, 11, 13, 14, 16},
  {7, 9, 10, 12, 14, 15, 17},
  {9, 11, 12, 14, 16, 17, 18}
};
int main()
{
  string S;
  int arr[7];
  
  while(cin >> S, S != "#") {
    bool f = true;
    for(int i = 0; i < 1 << 19; i++) {
      int sum = 0;
      for(int j = 0; j < 7; j++) {
        arr[j] = 0;
        for(int k = 0; k < 7; k++) arr[j] += ((i >> buff[j][k]) & 1) << k;
        sum += (S[arr[j]] - '0') << j;
      }
      if(S[sum] != S[arr[3]]) {
        f = false;
        break;
      }
    }
    cout << (f ? "yes" : "no") << endl;
  }
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#define LL long long
#define dl double
template <class T>
void rd(T &x){
  x=0;T f=1;char ch=getchar();
  while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
  while(ch<='9' && ch>='0')x=x*10+ch-'0',ch=getchar();x*=f;
}
using namespace std;
int cnt;
int h,w,k;
char c[10][10];
bool check(int x,int y){
 int ans=0;
 for(int i=1;i<=h;i++)
  for(int j=1;j<=w;j++){
   if((1<<i-1)&x)continue;
   if((1<<j-1)&y)continue;
   if(c[i][j]=='#')ans++;
  }
 return ans==k;
}
int main(){
 // freopen("in.txt","r",stdin);
 // freopen("o.txt","w",stdout);
 scanf("%d%d%d",&h,&w,&k);
 for(int i=1;i<=h;i++)scanf("%s",c[i]+1);
 for(int i=0;i<(1<<h);i++)
  for(int j=0;j<(1<<w);j++)
   cnt+=check(i,j);
 printf("%d\n",cnt);
 return 0;
}
/**/

Measured memory_bytes: 3756
a, b = map(int,input().split())
p = [1,3,5,7,8,10,12]
q = [4,6,9,11]
if a == b:
    print("Yes")
else:
    if a in p and b in p:
        print("Yes")
    elif a in q and b in q:
        print("Yes")
    else:print("No")

Measured memory_bytes: 3060
S = str(input())
def remove_word(S):
  S1 = S
  if S[-5:] == 'dream':
    S1 = S[:-5]
  if S[-7:] == 'dreamer':
    S1 = S[:-7]
  if S[-5:] == 'erase':
    S1 = S[:-5]
  if S[-6:] == 'eraser':
    S1 = S[:-6]
  if S1 != S:
    return S1
  else:
    return'NO'
while len(S)>0:
  S = remove_word(S)
  if S == 'NO':
    break
if S == 'NO':
  print('NO')
else:
  print('YES')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define f(i,q,a) for(long long i=q; i<a; i++)
#define ll long long
#define pb push_back
#define mod 1000000007
using namespace std;
int main()
{
    long double n, x;
    cin>>n>>x;
    ll t;
    cin>>t;
    ll q=ceil(n/x);
    cout<<q*t<<endl;
    return 0;
}


Measured memory_bytes: 3692
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
dif = []
ans = 0
for i in range(M-1):
    dif.append(X[i+1] - X[i])
dif.sort()
if M > N:
    for i in range(0,M-N):
        ans += dif[i]
print(ans)


Measured memory_bytes: 13968
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ull B = 1e7 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }



int n, m;
string s;
ull h[1000000];
ull BB[1000000];
set<ull> ss;

int main() {
	cin >> n >> m >> s;
	rep(i, n) {
		if (i == 0) {
			h[i] = s[i];
			BB[i] = 1;
		}
		else {
			h[i] = h[i - 1] * B + s[i];
			BB[i] = BB[i - 1] * B;
		}
	}

	string t;
	int l = 0, r = 0;
	rep(i, m) {
		cin >> t;
		if (t == "L++")l++;
		else if (t == "L--")l--;
		else if (t == "R++")r++;
		else r--;
		if (l == 0)ss.insert(h[r]);
		else ss.insert(h[r] - h[l - 1] * BB[r - (l - 1)]);
	}
	cout << ss.size() << endl;
}


Measured memory_bytes: 21792
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define repr(i, a, n) for (ll i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int a, b;
  string s;
  cin >> a >> b >> s;
  rep(i, 0, a) {
    if (!('0' <= s[i] && s[i] <= '9')) {
      puts("No");
      return;
    }
  }
  if (s[a] != '-') {
    puts("No");
    return;
  }
  rep(i, a + 1, a + b + 1) {
    if (!('0' <= s[i] && s[i] <= '9')) {
      puts("No");
      return;
    }
  }
  puts("Yes");
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // CとC++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
typedef long long ll;
const int INF = 1<<29;
const int N = 1e6 + 9;
ll a[N];
int main()
{
    fio;
    ll n, k = 0;
    cin >> n;
    for(int i = 0; i < n; i ++){
        cin >> a[i];
        if(a[i] % 2 == 0)
        {
            if(a[i] % 3 != 0 && a[i] % 5 != 0) k = 1;
        }
    }
    if(k == 1){
        cout << "DENIED" << endl;
    }
    else cout << "APPROVED" << endl;
    return 0;
}


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

int main()
{
  int a;
  cin>>a;
  for(int t=1;t<=9;t++)
    for(int r=1;r<=9;r++)
  {
    if(a==t*r)
    {
    cout<<"Yes";
    return 0;
    }
  }
  cout<<"No";
}


Measured memory_bytes: 256
object Main extends App {
  import io.StdIn._
  val Array(a, b) = readLine().split(" ")
  val (x, y) = (a.toLong, b.toDouble)
  val z =
    if (x * y < 1.0) 0L
  	else (x * math.round(y * 100)) / 100
  println(z)
}


Measured memory_bytes: 54860
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if (b - a == c - b) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
  
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <climits>

using namespace std;

int main()
{
    int N = 0;
    cin >> N;
    int minP = INT_MAX;
    int count = 0;
    for(int i = 0; i < N; ++i){
        int p;
        cin >> p;
        minP = min(p, minP);
        count = minP == p ? count + 1 : count;
    }

    cout << count << '\n';
}


Measured memory_bytes: 256
package main

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

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	sc := bufio.NewScanner(os.Stdin)
	s := make([]string, h)
	for i := range s {
		sc.Scan()
		s[i] = sc.Text()
	}

	ls := make([][]int, h)
	rs := make([][]int, h)
	for i := range ls {
		ls[i] = make([]int, w)
		for j := 0; j < w; j++ {
			if s[i][j] == '#' {
				ls[i][j] = 0
				continue
			}
			if j == 0 {
				ls[i][j] = 1
				continue
			}
			ls[i][j] = ls[i][j-1] + 1
		}

		rs[i] = make([]int, w)
		for j := w - 1; j >= 0; j-- {
			if s[i][j] == '#' {
				rs[i][j] = 0
				continue
			}
			if j == w-1 {
				rs[i][j] = 1
				continue
			}
			rs[i][j] = rs[i][j+1] + 1
		}
	}

	ts := make([][]int, h)
	ds := make([][]int, h)
	for i := range ts {
		ts[i] = make([]int, w)
		ds[i] = make([]int, w)
	}
	for j := 0; j < w; j++ {
		for i := 0; i < h; i++ {
			if s[i][j] == '#' {
				ts[i][j] = 0
				continue
			}
			if i == 0 {
				ts[i][j] = 1
				continue
			}
			ts[i][j] = ts[i-1][j] + 1
		}

		for i := h - 1; i >= 0; i-- {
			if s[i][j] == '#' {
				ds[i][j] = 0
				continue
			}
			if i == h-1 {
				ds[i][j] = 1
				continue
			}
			ds[i][j] = ds[i+1][j] + 1
		}
	}

	ans := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if v := ls[i][j] + rs[i][j] + ts[i][j] + ds[i][j] - 3; v > ans {
				ans = v
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 138240
#include <iostream>
#include <stack>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <cmath>
#include <stdlib.h>
#include <unordered_map>
#define ll long long
using namespace std;
ll x[1010],y[1010],h[1010];
int main() {
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>h[i];
    }
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            ll a=i,b=j,H=-1;
            int f=1;
            for(int k=0;k<n;k++)
                if(h[k]>0)
                    H=h[k]+abs(i-x[k])+abs(j-y[k]);
            
            
            for(int k=0;k<n;k++){
                if(max(H-abs(x[k]-a)-abs(y[k]-b),(ll)0)!=h[k])
                    f=0;
            }
            if(f&&H>0){
                printf("%lld %lld %lld",a,b,H);
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

void solve(int N, int num, char *str) {
    char ch = str[num - 1];
    int i;
    for(i = 0; str[i] != '\0'; ++i) {
        if(str[i] != ch) { str[i] = '*'; }
    }
    printf("%s\n", str);
}

int main()
{
    int n, k;
    scanf("%d", &n);
    char *str = (char*)malloc((n+5)*sizeof(char));
    scanf("%s", str);
    scanf("%d", &k);
    //printf("%s", str);
    solve(n, k, str);
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;

inline char nc(){
  static char buf[100000],*p1=buf,*p2=buf;
  return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline void read(int &x){
  char c=nc(),b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}

const int N=100005;

struct edge{
  int u,v,next;
}G[N<<2];
int head[N],inum;
inline void add(int u,int v,int p){
  G[p].u=u; G[p].v=v; G[p].next=head[u]; head[u]=p;
}
#define V G[p].v
int del[N],size[N];
int sum,minv,rt;
inline void Root(int u,int fa){
  size[u]=1; int maxv=0;
  for (int p=head[u];p;p=G[p].next)
    if (V!=fa && !del[V])
      Root(V,u),size[u]+=size[V],maxv=max(maxv,size[V]);
  maxv=max(maxv,sum-size[u]);
  if (maxv<minv) minv=maxv,rt=u;
}

int val[N];
int cnt1[N],cnt2[N];
ll ans=0;

inline void dfs1(int u,int fa,int d1,int d2,int d3,int d4){
  if (val[u]==-1){
    if (d2) d2--; else d1++;
  }else
    d2++;
  if (val[u]==1){
    if (d3) d3--; else d4++;
  }else
    d3++;
  if (!d2) ans+=cnt1[d1];
  if (!d3) ans+=cnt2[d4];
  for (int p=head[u];p;p=G[p].next)
    if (V!=fa && !del[V])
      dfs1(V,u,d1,d2,d3,d4);
}
inline void dfs2(int u,int fa,int d1,int d2,int d3,int d4){
  size[u]=1;
  if (val[u]==-1){
    if (d2) d2--; else d1++;
  }else
    d2++;
  if (val[u]==1){
    if (d3) d3--; else d4++;
  }else
    d3++;
  if (!d2) cnt2[d1]++;
  if (!d3) cnt1[d4]++;
  for (int p=head[u];p;p=G[p].next)
    if (V!=fa && !del[V])
      dfs2(V,u,d1,d2,d3,d4),size[u]+=size[V];
}

inline void Divide(int u){
  del[u]=1;
  if (val[u]==1) cnt1[1]++;
  if (val[u]==-1) cnt2[1]++;
  for (int p=head[u];p;p=G[p].next)
    if (!del[V]){
      dfs1(V,0,0,0,0,0);
      dfs2(V,0,val[u]==-1,val[u]==1,val[u]==-1,val[u]==1);
    }
  for (int p=head[u];p;p=G[p].next)
    if (!del[V]){
      sum=size[V]; minv=1<<30;
      Root(V,0);
      memset(cnt1,0,sizeof(int)*sum);
      memset(cnt2,0,sizeof(int)*sum);
      Divide(rt);
    }
}

int n;

int main(){
  int iu,iv;
  read(n);
  char c=nc(); for (;!(c=='(' || c==')');c=nc());
  for (int i=1;i<=n;i++) val[i]=c=='('?1:-1,c=nc();
  for (int i=1;i<n;i++)
    read(iu),read(iv),add(iu,iv,++inum),add(iv,iu,++inum);
  sum=n; minv=1<<30; Root(1,0);
  Divide(rt);
  printf("%lld\n",ans);
  return 0;
}

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

int euclid(int n,int m){
  if(n<m){
    swap(n,m);
  }
  if(n%m == 0){
    return m;
  }
  else{
    return euclid(m,n%m);
  }
}


int main(){
  int N,X;
  cin>>N>>X;
  int temp;
  int saisyo;
  cin>>saisyo;
  saisyo = abs(saisyo-X);
  for(int i = 1;i < N;i++){
    cin>>temp;
    temp = abs(temp-X);
    saisyo = euclid(saisyo,temp);
  }
  cout << saisyo << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Edge {
    long long from;
    long long to;
    long long cost;
};
typedef vector<Edge> Graph;
const long long INF = 1e17;
void Bellman_Ford(Graph& G, vector<long long>& D, long long V, long long s, long long E) {
    D.resize(V, INF);
    D.at(s) = 0;
    bool check = true;
    long long i = 0;
    while (true) {
        check = false;
        if (i == V - 1) {
            cout << "NEGATIVE CYCLE" << endl;
            return;
        }
        for (long long j = 0; j < E; j++) {
            if (D.at(G.at(j).from) != INF && D.at(G.at(j).to) > D.at(G.at(j).from) + G.at(j).cost) {
                check = true;
                D.at(G.at(j).to) = D.at(G.at(j).from) + G.at(j).cost;
            }
        }
        i++;
        if (!check) break;
    }
    for (long long i = 0; i < V; i++) {
        if (D.at(i) != INF) cout << D.at(i) << endl;
        else cout << "INF" << endl;
    }
    return;
}
int main() {
    long long V, E; cin >> V >> E;
    long long start;
    cin >> start;
    Graph G;
    vector<long long>D(V, INF);
    D.at(start) = 0;
    if (E == 0) {
        for (long long i = 0; i < V; i++) {
            cout << D.at(i) << endl;
        }
        return 0;
    }
    for (long long i = 0; i < E; i++) {
        Edge A;
        cin >> A.from >> A.to >> A.cost;
        G.push_back(A);
    }
    Bellman_Ford(G, D, V, start, E);
}


Measured memory_bytes: 3176
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a[] = new int[3];
		int b[] = new int[3];
		int k[] = new int[4];
		for(int i = 0; i < 3; i++) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;
			k[a[i]]++;
			k[b[i]]++;
		}
		for(int i = 0; i < 4; i++) {
			if(k[i] > 2) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}


Measured memory_bytes: 23124
n, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [0]
for i in a:
    b.append((b[-1] + i) % m)
c = {}
for i in b:
    if i in c:
        c[i] += 1
    else:
        c[i] = 1
d = 0
for i in c:
    d += c[i] * (c[i] - 1) // 2
print(d)

Measured memory_bytes: 63768
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,m,K;
int in[N];
multiset<int>S;
multiset<int>::iterator it;
void solve(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&in[i]);
		it=S.lower_bound(in[i]);
		if(it==S.begin()){
			S.insert(in[i]);
		}else{
			it--;
			int x=*it;
			S.erase(it);
			S.insert(in[i]);
		}
	}
	printf("%d\n",S.size());
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int road_num[n];
    memset(road_num, 0, sizeof(road_num));
    for(int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        road_num[a]++;
        road_num[b]++;
    }
    for(int i=0; i<n; i++){
        cout << road_num[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256