akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define LL long long
char s[200010];
int cnt[10010];
LL ans;
int main(){
	int n,p,i,pow10=1,now=0;
	scanf("%d%d%s",&n,&p,s+1);
	if(p==2||p==5){
		for(i=n;i>=1;i--)//从数据的最低位开始处理
			if((s[i]-'0')%p==0)ans+=i;
	}else{//p!=2,p!=5
		cnt[0]=1;
		for(i=n;i>=1;i--){
			now=(now+(s[i]-'0')*pow10)%p;
			pow10=pow10*10%p;
			ans+=cnt[now];
			cnt[now]++;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", _dmp_(#__VA_ARGS__, __VA_ARGS__);
void _dmp_(const char*) { cerr << endl; }
template <class T, class... U>
void _dmp_(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; _dmp_(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.first >> p.second; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
template <class It> auto sumof(It b, It e) { return accumulate(b,e,typename iterator_traits<It>::value_type{}); }
#define YesNo(c) ((c) ? "Yes" : "No")
////////////////////////////////

int32_t main() {
    int n; cin >> n;
    vector<pair<int,int> > v(n);
    rep (i,n) {
        int a; cin >> a;
        v[i] = mp(a,i+1);
    }
    sort(all(v));
    rep (i,n) cout << v[i].snd << " ";
    cout << endl;
}


Measured memory_bytes: 2432
def gcd(a, b):
    while a:
        a, b = b % a, a
    return b


def main():
    n, y = map(int, input().split())
    xs = list(map(int, input().split()))
    res = abs(y - xs[0])
    for x in xs[1:]:
        res = gcd(res, abs(y - x))
    print(res)


if __name__ == '__main__':
    main()


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

namespace CompetitiveProgCsLib
{
	class MainProg
	{
		static string R => Console.ReadLine();
		static int RI => int.Parse(R);
		static double RD => double.Parse(R);
		static int[] RIs => R.Split(' ').Select(int.Parse).ToArray();
		static double[] RDs => R.Split(' ').Select(double.Parse).ToArray();
		static void Out(object obj) => Console.WriteLine(obj);
		static void OutLine<T>(IEnumerable<T> obj, string separateChar) => Out(String.Join(separateChar, obj));
		static void Outb(bool b) => Out(b ? "Yes" : "No");
		static void OutB(bool b) => Out(b ? "YES" : "NO");
		static bool IsIn(int y, int x, int h, int w) => 0 <= x && x < w && 0 <= y && y < h;

		static void Main(string[] args)
		{
			var inp = RIs;
			if (inp[0] <= 8 && inp[1] <= 8) Out("Yay!");
			else Out(":(");

		}
	}
}


Measured memory_bytes: 13268
object Main extends App {
  	val sc = new java.util.Scanner(System.in)
	val pw = new java.io.PrintWriter(System.out)
 
	val ok = Seq.fill(sc.nextInt)((sc.nextInt, sc.nextInt)).sortBy(_._2).foldLeft(Some(0): Option[Int]) {
		case (Some(now), (a, b)) if (now + a <= b) => Some(now + a)
		case _ => None
	}.isDefined
 
	pw.println(if (ok) "Yes" else "No")
	pw.flush()
}

Measured memory_bytes: 130100
N, C = map(int, input().split())
M = 200005
rec = [[0] * M for i in range(C)]
for i in range(N):
    s, t, c = map(int, input().split())
    rec[c - 1][2 * s - 1] += 1
    rec[c - 1][2 * t] -= 1

for j in range(C):
    for i in range(1, M):
        rec[j][i] += rec[j][i - 1]

num = 0
for j in range(M):
    tmp = 0
    for i in range(C):
        if rec[i][j] >= 1:
            tmp += 1
    num = max(tmp, num)

print(num)



Measured memory_bytes: 93400
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    S = input()
    ans = INF
    for i in range(len(S) - 3 + 1):
        ans = min(ans, abs(753 - int(S[i:i+3])))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3944
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int ans;
int n,m;
vector< vector<int> > g;

void solve(int pos, int cnt, int ok, vector<bool> &f){
  //printf("%d %d %d: ",pos,cnt,ok); REP(i,n) printf("%d ",(int)f[i]); puts("");
  if(cnt >= ans) return;
  if(ok == n){ ans = cnt; return; }
  if(pos == n) return;

  vector<bool> ff = f;
  int oo = ok;
  if(!ff[pos]){
    ff[pos] = true;
    oo++;
  }
  FOR(it,g[pos]){
    if(!ff[*it]){
      ff[*it] = true;
      oo++;
    }
  }
  solve(pos+1, cnt+1, oo, ff);
  solve(pos+1, cnt, ok, f);
}

int main(){
  while((n = getInt()) + (m = getInt())){
    vector<bool> f(n, false);

    g = vector< vector<int> >(n);
    REP(i,m){
      int a = getInt();
      int b = getInt();
      g[a].push_back(b);
      g[b].push_back(a);
    }

    ans = n;

    solve(0,0,0,f);

    print(ans);
  }
  return 0;
}

Measured memory_bytes: 880
#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  bool flag = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') {
      flag = 1;
    }
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  if (flag) {
    x = -x;
  }
}
const int N = 100005;
int n, q, a[N];
int main() {
  read(n), read(q);
  q *= 2;
  while (q--) {
    int x;
    read(x);
    a[x] ^= 1;
  }
  puts(*max_element(a + 1, a + n + 1) ? "NO" : "YES");
  return 0;
}

Measured memory_bytes: 3964
N, Q = map(int, input().split())
S = input()


cnt = [0] * (N)

for i in range(1, N):
	if S[i-1:i+1] == "AC":
		cnt[i] = cnt[i-1] + 1
	else:
		cnt[i] = cnt[i-1]

for _ in range(Q):
	l, r = map(int, input().split())
	print(cnt[r-1] - cnt[l-1])


Measured memory_bytes: 6140
def main():
    S = input()
    n = len(S)-1

    val_sum = 0
    for i in range(2**n):
        idx = 0
        for j in range(n):
            if 1 & (i >> j) == 1:
                val_sum += int(S[idx:j+1])
                idx = j+1
        val_sum += int(S[idx:])

    print(val_sum)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<long long, long long> pll;

using namespace std;

const long long MOD = 1000000007;

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

	int h, w, k;
	cin >> h >> w >> k;
	char** s;
	s = new char*[h];
	int ** ans;
	ans = new int*[h];

	rep(i, h) {
		s[i] = new char[w];
		ans[i] = new int[w];
		memset(ans[i], 0, sizeof(int)*w);

		rep(j, w) cin >> s[i][j];
	}

	int num = 0;
	rep(i, h) {
		int exist = 0;
		bool flag = false;
		rep(j, w) {
			if (s[i][j] == '#') {
				flag = true;

				++num;
				RREP(l, exist, j) {
					ans[i][l] = num;
				}

				exist = j + 1;
			}
			else if (flag) {
				ans[i][j] = num;
			}
		}
	}

	REP(i, 1, h) {
		rep(j, w) {
			if (ans[i][j] == 0) ans[i][j] = ans[i - 1][j];
		}
	}

	rrep(i, h - 2) {
		rep(j, w) {
			if (ans[i][j] == 0) ans[i][j] = ans[i + 1][j];
		}
	}

	rep(i, h) {
		rep(j, w) {
			cout << ans[i][j] << " ";
		}

		cout << "\n";
	}

	return 0;
}


Measured memory_bytes: 1280
// https://atcoder.jp/contests/abc092/tasks/abc092_b

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

int main()
{
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B);
    for (int i = 0; i < A; i++)
        cin >> a[i];
    for (int i = 0; i < B; i++)
        cin >> b[i];
    int ans = (*min_element(a.begin(), a.end())) + (*min_element(b.begin(), b.end()));
    for (int i = 0; i < M; i++)
    {
        int x, y, c;
        cin >> x >> y >> c;
        --x;
        --y;
        ans = min(ans, a[x] + b[y] - c);
    }

    cout << ans << endl;
    return 0;
}


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

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

  vector<int> v(n, 0);

  int a = 0, b = 0;
  for(int i = 0; i < m; ++i) {
    cin >> a;
    v.at(a-1) += 1;
    cin >> b;
    v.at(b-1) += 1;
  }

  for(int x : v){
    cout << x <<"\n";
  }
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair<int,int>; using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
////////////////

void solve(){
  ins(S);
  int N = sz(S);
  vl ans(N + 1 , -1);
  // 0の初期化
  if(S[0] == '<') ans[0] = 0;
  if(S[N-1] == '>') ans[N] = 0;
  rep(i , N - 1){
    if(S[i] == '>' && S[i+1] == '<') ans[i + 1] = 0;
  }
  rep(i , N){
    if(S[i] == '<'){
      if(ans[i + 1] == -1) ans[i + 1] = ans[i] + 1;
      else amax(ans[i + 1] , ans[i] + 1);
    }
  }
  repr(i , N){
    if(S[i] == '>'){
      if(ans[i] == -1) ans[i] = ans[i + 1] + 1;
      else amax(ans[i] , ans[i + 1] + 1);
    }
  }
  trc(ans);
  ll bns = 0; each(x , ans) bns += x; out(bns);

}

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

ll solve() {
    ll N;
    cin >> N;
    ll s, sum = 0, m = 1000;
    for ( int i = 0; i < N; i++ ) {
        cin >> s;
        sum += s;
        if ( s%10 != 0 && m > s ) m = s;
    }
    if ( sum % 10 != 0 ) return sum;
    else if ( m <= 100 ) return sum - m;
    else return 0;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 3005;

/* ...o(^-^)o... */
const lint mod = MOD;
class mint{
    public:
        long long x;

    constexpr mint(long long _x = 0) : x((_x%mod+mod)%mod) {}
    constexpr mint operator-() const{
        return mint(-x);
    }
    constexpr mint& operator+=(const mint& a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator-=(const mint& a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator*=(const mint& a){
        (x *= a.x) %= mod;
        return *this;
    }
    constexpr mint operator+(const mint& a) const{
        mint res(*this);
        return res+=a;
    }
    constexpr mint operator-(const mint& a) const{
        mint res(*this);
        return res-=a;
    }
    constexpr mint operator*(const mint& a) const{
        mint res(*this);
        return res*=a;
    }
    constexpr mint pow(long long x) const{
        if(!x) return 1;
        mint a = pow(x>>1);
        a *= a;
        if(x&1) a *= *this;
        return a; 
    }
    constexpr mint inv() const{
        return pow(mod-2);
    }
    constexpr mint& operator/=(const mint& a){
        return (*this) *= a.inv();
    }
    constexpr mint operator/(const mint& a) const{
        mint res(*this);
        return res/=a;
    }
    friend istream& operator>>(istream& is, mint& m){
        long long x; is >> x; m = x;
        return is;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x; return os;
    }
};

mint dp[MAX][MAX];

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

    rep(j, n+1) dp[0][j] = j;
    repp(i, 1, n) repn(j, n-i){
        if(s[i-1]=='>') dp[i][j] = dp[i][j-1]+dp[i-1][n-i+1]-dp[i-1][j];
        else dp[i][j] = dp[i][j-1]+dp[i-1][j];
    }
    out(dp[n-1][1]);
}


Measured memory_bytes: 70016
# -*- coding: utf-8 -*-
import itertools
ope = ['+','-']
ope_list = itertools.product(ope, repeat=3)

In = list(map(int, list(input())))

# print(In)
# print(list(ope_list))

for op1,op2,op3 in ope_list:
    if op1 == '+':
        tmp1 = In[0] + In[1]
    else:
        tmp1 = In[0] - In[1]

    if op2 == '+':
        tmp2 = tmp1 + In[2]
    else:
        tmp2 = tmp1 - In[2]

    if op3 == '+':
        tmp3 = tmp2 + In[3]
    else:
        tmp3 = tmp2 - In[3]

    if tmp3 == 7:
        print('{0}{1}{2}{3}{4}{5}{6}=7'.format(In[0],op1,In[1],op2,In[2],op3,In[3]))
        exit()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;



int main() {
    int n; cin >> n;
    vector<ll> a(n),r(n),l(n);
    rep(i,n) {
        cin >> a[i];
        r[i] = a[i];
        l[i] = a[i];
    }

    rep(i,n-1) l[i+1] += l[i];
    for(int i = n - 2; i >= 0; i--) r[i] += r[i+1];

    ll v = 20202020200;
    for(int i = 0; i < n - 1; i++){
        v = min(v,abs(l[i]-r[i+1]));
    }
    /*for(ll i : r) cout << i << " ";
    cout << endl;
    for(ll i : l ) cout << i << " ";
    cout << endl;*/
    cout << v << endl;
}

Measured memory_bytes: 8000
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int m,n,i,x,cost1=0,cost2=0,cost=0;
	cin>>n>>m>>x;
	int a[n+2]={0};
	for(i=0;i<m;i++)
	{
		int z;
		cin>>z;
		a[z]=1;
	}
	for(i=x;i>=1;i--)
	{
		if(a[i]==1)
			cost1++;
	}
	for(i=x;i<=n;i++)
	{
		if(a[i]==1)
			cost2++;
	}
	cost=min(cost1,cost2);
	cout<<cost;
	return 0;
}

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

int main(){
    int n,rank;
    char ch;
    bool cards[4][14];
    
    for(int j=0; j<4;j++)
      for(int r =1;r<=13;r++)
        cards[j][r] = 0;
        
    cin >> n;
    for(int i =0;i<n;i++){
        cin >> ch >> rank;
        if(ch =='S'){
            cards[0][rank] = 1;
        }
        if(ch == 'H'){
            cards[1][rank] = 1;
        }
        if(ch == 'C'){
            cards[2][rank] = 1;
        }
        if(ch == 'D'){
            cards[3][rank] = 1;
        }
    }
    
    for(int j = 0;j< 4;j++){
        for(int r = 1;r <=13;r++){
            if(cards[j][r]) continue;
            if(j == 0){
                ch ='S';
            }
            if(j == 1){
                ch ='H';
            }
            if(j == 2){
                ch ='C';
            }
            if(j == 3){
                ch ='D';
            }
            cout << ch << " " << r << endl;
        }
    }
    
    return 0;
    
}


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


int main()
{
    
    

    int a,b;
    cin >> a >> b;

    int array[b];
    int sum = 0;

    for(int i = 0;i < b; i ++){
        cin >> array[i]; 
        sum += array[i];
    }


    if(a < sum){
        cout << "-1" << endl;
    }else{
        cout << a - sum  << endl;
    }





    return 0;
    

}

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

using namespace std;
int main(){
//    freopen("in", "r", stdin);

    int n,m;
    cin >> n >> m;
    vector<int> v(m);
    vector<int> dp(50001, 1 << 29);
    for (int i = 0; i < m; ++i){
        int c;
        cin >> c;
        v[i] = c;
    }
    dp[0] = 0;
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j + v[i] <= n; ++j) {
            dp[j + v[i]] = min(dp[j + v[i]] , dp[j] + 1);
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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

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 long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int cnt = 0,ans = 1100;
    string s,t;
    cin >> s;
    cin >> t;
    for (int i = 0; i <= s.size()-t.size(); ++i) {
        cnt = 0;
        int i2 = i;
        for (int j = 0; j < t.size(); ++j) {
            if(s[i2] == t[j]) cnt++;
            i2++;
        }
        ans = min(ans,((int)t.size()-cnt));
    }
    cout << ans << endl;
    return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    string s;
    cin >> s;
    vector<int> t(4);
    string pm = "-+";
    rep(i, 4) t[i] = (s[i]-'0');
    rep(i, 2) rep(j, 2) rep(k, 2) {
        int ans = t[0];
        if (i) ans += t[1]; else ans -= t[1];
        if (j) ans += t[2]; else ans -= t[2];
        if (k) ans += t[3]; else ans -= t[3];
        if (ans == 7) {
            cout << t[0] << pm[i] << t[1] << pm[j] << t[2] << pm[k] << t[3] << "=7" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int count=0;
    int dummy=1;
    for(int i=0;i<n;i++)
    {
        if(arr[i]==dummy)
        {
            count++;
            dummy++;
        }
    }
    if(count==0)
    {
        cout<<-1;
    }else
    {
         cout<<n-count;
    }
    

     
}

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

ll fast(ll a, ll b)
{

    ll ans = 1;
    while (b)
    {
        if (b & 1)
            ans = (ans * a) % m;
        a = (a * a) % m;
        b = b / 2;
    }
    return ans;
}

int main()
{
    ll n, k;
    cin >> n >> k;
    ll arr[n + 3];
    arr[0] = 1;
    for (ll i = 1; i <= n + 2; i++)
    {
        arr[i] = (arr[i - 1] * i) % m;
    }
    ll sum = 0;
    //n++;
    for (ll j = k; j <= n; j++)
    {
        ll i = j - 1;
        ll sum1 = (i * (i + 1)) / 2;
        ll sum2 = (n * (n + 1)) / 2;
        ll p = n - i - 1;
        ll sum3 = (p * (p + 1)) / 2;
       // cout << sum1 << " " << sum2 << " " << sum3 << "\n";
        sum += (sum2 - sum1 - sum3 + 1 + m) % m;
    }
    cout << (sum + 1) % m << "\n";

    return 0;
}

Measured memory_bytes: 5140
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def print_array(a):
    print(" ".join(map(str, a)))


def insertion_sort(a, n):
    print_array(a)
    for i in range(1, n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j + 1] = a[j]
            j -= 1
        a[j + 1] = v
        print_array(a)
    return a


def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = insertion_sort(a, n)

if __name__ == "__main__":
    main()

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

using namespace std;

using ll = long long;
using ld = long double;

#ifdef EBUG
#define debug(x) cout << "\033[31m" << #x << ": " << x << "\033[0m\n";
#else
#define debug(x)
#endif

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

ll n, a[300000], s, s1, s2, s3, s4;

int main() {
  cin >> n;
  rep(i, n) {
    cin >> a[i];
    a[i] -= i + 1;
    s += a[i];
    debug(a[i]);
  }

  ll a1, a2, a3;
  a1 = s / n;
  a2 = s / n + 1;
  a3 = s / n - 1;

  debug(a1);
  debug(a2);

  rep(i, n) {
    s1 += abs(a[i] - a1);
    debug(abs(a[i] - a1));
  }
  rep(i, n) {
    s2 += abs(a[i] - a2);
    debug(abs(a[i] - a2));
  }
  rep(i, n) {
    s3 += abs(a[i] - a3);
    debug(abs(a[i] - a3));
  }

  sort(a, a + n);
  rep(i, n) {
    s4 += abs(a[i] - a[n / 2]);
  }

  cout << min(min(min(s1, s2), s3), s4) << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,m,i,j,k;
char c[110],ch[110];
bool f(int k){
	int j=k;
	for (int i=1;i<=n;i++){if (j+i-1<=n) if (c[i-1]!=ch[j+i-2]) return false;if (j+i-1>n) if (c[i-1]!=ch[j+i-2-n]) return false;}return true;
}
int main(){
	scanf("%s",c);scanf("%s",ch);n=strlen(c);for (i=1;i<=n;i++) if (f(i)){printf("Yes\n");return 0;}printf("No\n");return 0;
}

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

int main() {
	int H, W, N;
	cin >> H >> W >> N;
	vector<int> A(N + 1);
	for (int i = 0; i < N; i++) cin >> A[i];
	int NowColor = 1;
	int Rest = A[0];
	for (int i = 0; i < H; i++) {
		vector<int> Row(W);
		for (int j = 0; j < W; j++) {
			Row[j] = NowColor;
			Rest--;
			if (Rest == 0) {
				NowColor++;
				Rest = A[NowColor - 1];
			}
		}
		if (i % 2 == 0) for (int j = 0; j < W; j++) cout << Row[j] << " ";
		else  for (int j = W - 1; j >= 0; j--) cout << Row[j] << " ";
		cout << endl;
	}
}

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

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) 
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) 
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i)
#define deb(x) cout << #x << "= " << x << endl
#define pb push_back
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define tr(x) for(auto it = x.begin(); x != x.end(); it++)
#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int main() {
    fast;
    int t=1;
    while(t--){
        //begin code here
        ll a,b,c,d;
      	cin >>a>>b>>c>>d;
        ll arr[4];
        arr[0]=a*c;
        arr[1]= a*d;
        arr[2]= b*c;
        arr[3] = b*d;
        cout << *(std::max_element(arr,arr+4));
    }
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

    static int A;
    static int B;
    static int C;
    static int X;
    static int Y;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        A = sc.nextInt();
        B = sc.nextInt();
        C = sc.nextInt();
        X = sc.nextInt();
        Y = sc.nextInt();

        solve();
    }

    public static void solve() {
        long sum = 0;

        if (A + B > C * 2) {
            if (X > Y) {
                sum = C * Y * 2;

                if (A < C * 2) {
                    sum += (X - Y) * A;
                } else {
                    sum += (X - Y) * C * 2;
                }
            } else {
                sum = C * X * 2;

                if (B < C * 2) {
                    sum += (Y - X) * B;
                } else {
                    sum += (Y - X) * C * 2;
                }
            }
        } else {
            sum = A * X + B * Y;
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;




int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c/a*b<<endl;
	
	
//////////////////////////////////////////////////////
	return 0;
}








Measured memory_bytes: 256
N, K = map(int, input().split())
tricked_set = set(range(N))

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for j in A:
        if j-1 in tricked_set:
            tricked_set.remove(j-1)

print(len(tricked_set))



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

int main(){
    int n=0,k=0,i=0,ans=1;
    cin >> n >> k;
    while(i!=n){
        if(ans*2>ans+k)ans += k;
        else ans *= 2;
        i++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def insertionSort(a,n)
 1.upto(n-1){|i|
  v=a[i]
  j = i-1
  while j>=0 && a[j]>v
   a[j+1] = a[j]
   j-=1
   a[j+1] = v
  end
  puts a*' '
 }
end

n = gets.to_i
a = gets.split.map{|num|num.to_i}
puts a*' '
insertionSort a,n

Measured memory_bytes: 8832
import scala.io.StdIn

object Main extends App {

  var text = ""
  do {
    if(text != ""){
      var shuffleCnt = Integer.parseInt(StdIn.readLine())

      (0 until shuffleCnt).foreach{ _ =>
        val splitAt = Integer.parseInt(StdIn.readLine())
        text = text.slice(splitAt, text.length) + text.slice(0, splitAt)
      }
      println(text)
    }
    text = StdIn.readLine()
  } while(text != "-")
  
}


Measured memory_bytes: 43820
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* ---------- Functions */
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int N, M;
    cin >> N >> M;
    cout << N*(N-1)/2 + M*(M-1)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
x = [0 for _ in range(n)]
for j in range(m):
    a = list(map(int, input().split()))
    s = a[0] - 1
    t = a[1] - 1
    if h[s] < h[t]:
        x[s] = 1
    elif h[s] > h[t]:
        x[t] =1
    else:
        x[s] = 1
        x[t] = 1

print(x.count(0))    

        

Measured memory_bytes: 20032
#include <iostream>
using namespace std;
int main(){
    int a[20000];
    int b[20000];
    int ans[20000];
    int stop=0;
    char op;
        for(int i=0;i<20000;i++){
        cin >> a[i] >> op >> b[i];
        if(op=='?'){
            stop=i;
            break;
        }
        if(op=='+'){
            ans[i]=a[i]+b[i];
        }else if(op=='-'){
            ans[i]=a[i]-b[i];
        }else if(op=='*'){
            ans[i]=a[i]*b[i];
        }else if(op=='/'){
            ans[i]=a[i]/b[i];
        }
    }
    for(int j=0;j<stop;j++){
            cout << ans[j] << "\n";
        }
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD				1000000007
#define MOD1			998244353
#define EPS				1e-9
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)

using namespace std;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const int tam = 10000010;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("asd.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int n;
	ll k;
	cin>>n>>k;
	ll ar[n];
	fore(i, 0, n) cin>>ar[i];
	ll res = 0;
	if(k == 0)
	{
		fore(i, 0, n) res += ar[i];
		cout<<res<<'\n';
		return 0;
	}
	ll mik = 0;
	int bibi = (log2(k) + EPS);
	int conu, conc;
	for(int i = bibi+1; i > -1; i--)
	{
		if(k < (1ll<<i)) continue;
		conu = 0, conc = 0;
		fore(j, 0, n)
		{
			//cout<<((1ll<<i) ^ ar[j])<<' ';
			if(((1ll<<i) ^ ar[j]) > ar[j])
				conu++;
			else
				conc++;
		}
		//cout<<'\n';
		//cout<<i<<' '<<conu<<' '<<conc<<'\n';
		if(conu > conc)
		{
			mik |= (1ll<<i);
			k -= 1ll<<i;
		}
	}
	//cout<<mik<<'\n';
	fore(i, 0, n) res += ar[i]^mik;
	cout<<res<<'\n';
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 1024
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		long[] a = new long[3*n];
		for (i = 0; i < a.length; i++) {
			a[i] = parseLong(sc.next());
		}
		sc.close();
		Arrays.parallelSort(a);
		long sum=0;
		for (i = n; i < 3*n; i+=2) {
			sum+=a[i];
		}
		out.println(sum);
	}
}


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

int H, W;

int dr[4] = {1, 0, -1, 0},
    dc[4] = {0, 1, 0, -1};

string s[50];

bool isInside(int r, int c) {
    return 0 <= r and r < H and 0 <= c and c < W;
}

int main() {
    cin >> H >> W;

    for (int r = 0; r < H; r++) {
        cin >> s[r];
    }

    for (int r = 0; r < H; r++) {
        for (int c = 0; c < W; c++) {
            if (s[r][c] == '.') continue;
            bool flag = false;
            
            for (int i = 0; i < 4; i++) {
                int nr = r + dr[i],
                    nc = c + dc[i];
                if (isInside(nr, nc) and s[nr][nc] == '#') {
                    flag = true;
                }
            }

            if (!flag) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char ch;
	int x,y,ans=0;
	x=y=0;
	while(scanf("%c",&ch),ch=='p' || ch=='g')
		if(x<=y)
		{
			++x;
			if(ch=='p') --ans;
		}
		else
		{
			++y;
			if(ch=='g') ++ans;
		}
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main(){
    
    int a,b,c;
    cin >> a>>b>>c;
    
    if(a<=c&&c<=b){
        Yes;
    }else if(b<=c&&c<=a){
        Yes;
    }
    else{
        No;
    }
    
    return 0;
}


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


void solve(long long N, std::string S, std::string T){
    string str(2*N,'a');
    for(long long i =0;i<N;i++){
        str[2*i] = S[i];
        str[2*i + 1] = T[i];
    }
    cout << str << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(N, S, T);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string s;
    int K;
    cin >> s >> K;
    
    vector<string> S;
    rep(i, s.size()) {
        rep(j, min((int)s.size() - i, K)) {
            S.push_back(s.substr(i, j + 1));
        }
    }
    sort(S.begin(), S.end());
    int cnt = 0;
    rep(i, S.size()) {
        if (!binary_search(S.begin(), S.begin() + i, S[i])) ++cnt;
        if (cnt == K) {
            cout << S[i] << endl;
            return 0;
        }
    }
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  ll ans = 0;
  ll mx = a[0];
  int cnt = 1;
  int j = 0;
  for (int i = 1; i < n; i++) {
    ans += mx;
    cnt++;
    if (cnt == 2) {
      cnt = 0;
      j++;
      mx = a[j];
    }
    dump(i, j, cnt, mx, ans);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 4684
N = int(input())
A = list(map(int,input().split()))
lng_a = N
cnt = 0
for i in range(0,N):
    if i == 0:
        cnt = 1
        lng_a = A[i]
    else:
        if lng_a > A[i]:
            cnt += 1
            lng_a = A[i]
print(cnt)


Measured memory_bytes: 24744
#include <stdio.h>

int main(){
  int n,i,j,flag,cnt=0,tmp;
  int a[100];
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  
  flag=1;
  while(flag){
    flag=0;
    for(j=n-1;j>=1;j--){
      if(a[j]<a[j-1]){ 
	tmp=a[j-1];
	a[j-1]=a[j];
	a[j]=tmp;
        flag=1;
        cnt++;
      }
    }
  }
  for(i=0;i<n;i++){
     printf("%d",a[i]);
     if(i==n-1) printf("\n");
     else printf(" ");
  }
  printf("%d\n",cnt);

  return 0;
}

Measured memory_bytes: 604
import numpy as np

def process(src, dst):
    # 偶数：何もしない
    # 奇数：1枚ならべる(1枚減る)
    if src % 2 == 0:
        pass
    else:
        src -= 1

    # 半分を相手に渡す
    # 自分：半分減
    # 相手：半分の値増
    src = src / 2
    dst += src

    return src, dst


# 入力
indata = input().split()
A = int(indata[0])
B = int(indata[1])
K = int(indata[2])

# 初期所持枚数
takahashi = A
aoki = B

# 操作をK回繰り返す
for i in range(K):
    if i % 2 == 0:
        # 高橋君のターン
        takahashi, aoki = process(takahashi, aoki)
    else:
        # 青木君のターン
        aoki, takahashi = process(aoki, takahashi)

# 結果
print(int(takahashi), int(aoki))

Measured memory_bytes: 12496
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string w;
  cin >> w;
  int a=w.size();
  vector<char> v(a);
  for (int i=0;i<a;i++){
    v[i]=w[i];
  }
  sort(v.begin(),v.end());
  bool ans=true;
  if (a%2==1){
    ans=false;
  }
  else {
    for (int j=0;j<a;j+=2){
      if (v[j]!=v[j+1]){
        ans=false;
        break;
      }
    }
  }
  if (ans){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

enum{ Garo, Sero };

struct Dat{ int d, c; };

int n, m, rc, cc;
ll ans;
vector<Dat> v;

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 0, x; i < n; i++){
		scanf("%d", &x);
		v.push_back({Garo, x});
	}
	for(int i = 0, x; i < m; i++){
		scanf("%d", &x);
		v.push_back({Sero, x});
	}
	sort(v.begin(), v.end(), [](Dat a, Dat b){ return a.c < b.c; });
	for(auto &i : v){
		if(i.d == Garo){
			ans += ll(i.c) * (m + 1 - cc);
			rc++;
		}
		else{
			ans += ll(i.c) * (n + 1 - rc);
			cc++;
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。
int main () {
    int N;
    cin >> N;
    int K = N / 10;
    if(K == 9 || N - K * 10 == 9){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

int main(){
    int n,m,X,Y;
    cin >> n >> m >> X >> Y;
    vector<int> x(n), y(m);
    for(int i=0;i<n;i++){
        cin >> x[i];
    } 
    for(int i=0;i<m;i++){
        cin >> y[i];
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    int z1 = max(X,x[n-1]);
    int z2 = min(Y,y[0]);
    if(z1<z2){
        cout << "No War"<< endl;
    }else{
        cout << "War" << endl;
    }
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X, Y;
    cin >> X >> Y;

    ll ans = 0;
    while (X <= Y) {
        ans++;
        X *= 2LL;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long[] A;
        public long MOD = 1000000007;

        public void Run()
        {
            N = Input.ReadInt();
            A = new long[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = Input.ReadLong();
            }

            Array.Sort(A);

            if (N % 2 == 0)
            {
                int mm = N / 2 - 1;
                long ret = -A.Take(mm).Sum() * 2 - A[mm] + A[mm + 1] + A.Skip(mm + 2).Sum() * 2;
                Console.WriteLine(ret);
            }
            else
            {
                int mm1 = N / 2;
                int mm2 = N / 2 - 1;
                long ret1 = -A.Take(mm1).Sum() * 2 + A[mm1] + A[mm1 + 1] + A.Skip(mm1 + 2).Sum() * 2;
                long ret2 = -A.Take(mm2).Sum() * 2 - A[mm2] - A[mm2 + 1] + A.Skip(mm2 + 2).Sum() * 2;
                Console.WriteLine(Math.Max(ret1, ret2));
            }

        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}


Measured memory_bytes: 17464
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){ 
    int a,b,c,x,y,ans=0; 
    cin >> a >> b >> c >> x >> y ; 
    if (a+b>=2*c){ 
        int f = min(x,y) ; 
        ans = f*2*c; 
        x -= f;y-=f; 
        if (x){ 
            if (c*2<=a) ans += x*c*2;
            else ans += x*a;
        }
        else {
            if (c*2 <= b) ans += c*2*y;
            else ans += y*b;
        }
    }
    else 
        ans = x*a+y*b;
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3612