akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;
template <typename Functor>
struct fix_type
{
    Functor functor;
    template <typename... Args>
    decltype(auto) operator()(Args&&... args) const& { return functor(functor, std::forward<Args>(args)...); }
};
template <typename Functor>
fix_type<typename std::decay<Functor>::type> fix(Functor&& functor) { return {std::forward<Functor>(functor)}; }

class DisjointSets
{
public:
    DisjointSets(const int v) : parent(v), rank(v, 0), size(v, 1) { iota(parent.begin(), parent.end(), 0); }
    bool same(const int a, const int b) { return find(a) == find(b); }
    int find(const int a) { return parent[a] == a ? a : parent[a] = find(parent[a]); }
    void unite(int a, int b)
    {
        a = find(a), b = find(b);
        if (a == b) { return; }
        if (rank[a] < rank[b]) { swap(a, b); }
        size[a] += size[b];
        rank[a] += rank[b];
        parent[b] = a;
    }
    int getSize(const int a) { return size[find(a)]; }

private:
    vector<int> parent;
    vector<int> rank;
    vector<int> size;
};

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
        p[i]--;
    }
    DisjointSets uf(N);
    for (int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        uf.unite(u, v);
    }
    vector<set<int>> ind(N);
    vector<vector<int>> num(N);
    for (int i = 0; i < N; i++) {
        ind[uf.find(i)].insert(i);
        num[uf.find(i)].push_back(p[i]);
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (const int n : num[i]) {
            if (ind[i].find(n) != ind[i].end()) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int A, B, C, D, E, F, ansSugar, ansSugarWater;
bool used[10000][10000];
double maxConc = 0.0;

void rec(int water = 0, int sugar = 0) {
    if (water * 100 + sugar > F) return;

    if (used[water][sugar]) return;
    used[water][sugar] = true;

    double per = (water + sugar == 0) ? 0.0 : (100.0 * sugar) / (100.0 * water + sugar);

    if (E * water >= sugar) {
        if (maxConc <= per) {
            maxConc = per;
            ansSugarWater = water * 100 + sugar;
            ansSugar = sugar;
        }
    }

    rec(water + A, sugar    );
    rec(water + B, sugar    );
    rec(water    , sugar + C);
    rec(water    , sugar + D);
}

int main() {
    cin >> A >> B >> C >> D >> E >> F;
    rec();
    cout << ansSugarWater << " " << ansSugar << endl;
    return 0;
}

Measured memory_bytes: 384
function Main(input) {
var cards=input.split(" ");
var cardA=parseInt(cards[0]);
var cardB=parseInt(cards[1]);
if(cardA==1){
cardA=14;
}
if(cardB==1){
cardB=14;
}
if(cardA>cardB){
	console.log("Alice");
}else if(cardA<cardB){
	console.log("Bob");
}else if(cardA==cardB)
	console.log("Draw");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <sstream>
#include <bitset>

#define REP(i,n) for (long i = 0;i < n;i++)
#define FOR(i,m,n) for (long i = m;i < n;i++)

using namespace std;

int main(void) {
	long m,n;
	while (1) {
		cin >> m >> n;
		if (m == 0 && n == 0) break;
		bitset<7368792> a(0);
		long lim = 7368792;
		long ans;
		FOR(i,m,lim) { 
			if (!a[i]) {
				if (n == 0) {
					ans = i;
					break;
				}
				n--;
				long val = i;
				for(int j = 1;j*val < lim;j++) {
					a.set(j*val);
				}
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3988
from collections import Counter


n = int(input())
a = list(map(int, input().split()))
counter = Counter(a)
ini_sum = sum(a)
q = int(input())
s = [ini_sum] + [0] * q

for i in range(1, q+1):
    b, c = map(int, input().split())
    x = c - b
    s[i] = s[i-1] + x*counter[b]
    counter[c] += counter[b]
    counter[b] = 0

for i in range(1, q+1):
    print(s[i])


Measured memory_bytes: 27684
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n, k = readInts()
dic = defaultdict(int)
for i in range(1, n+1):
    dic[i%k] += 1
res = 0
for a in range(k):
    b = (k-a)%k
    c = (k-a)%k
    if ((b+c)%k != 0):
        continue
    #print(a,b,c)
    res += dic[a] * dic[b] * dic[c]
print(res)


Measured memory_bytes: 20568
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;
int main() {
  ll a, b;
  cin >> a >> b;
  if (a > 9 || b > 9) {
    cout << -1 << endl;
    return 0;
  }
  cout << a * b << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()
cnt = [0]*(N+1)
ans = []
M = 0
for i in range(N-1,-1,-1):
  tmp = sum(cnt[i::i+1])
  if tmp%2 != a[i]:
    ans.append(str(i+1))
    cnt[i] = 1
    M += 1

if M == 0:
  print(0)
else:
  print(M)
  print(" ".join(ans))

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

int main(void) {
    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<long> > a(n, vector<long>(m, 0));
    vector<vector<long> > b(m, vector<long>(l, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a.at(i).at(j);
        }
    }
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < l; j++) {
            cin >> b.at(i).at(j);
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l - 1; j++) {
            long sum = 0;
            for (int k = 0; k < m; k++) {
                sum += a.at(i).at(k) * b.at(k).at(j);
            }
            cout << sum << " ";
        }
        long sum = 0;
        for (int k = 0; k < m; k++) {
            sum += a.at(i).at(k) * b.at(k).at(l - 1);
        }
        cout << sum << endl;
    }
    return 0;
}



Measured memory_bytes: 3288
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;


int n,m,a;
int main()
{
    cin>>n>>m;
    for (int i=1; i<=m; ++i)
    {
        cin>>a;
        n-=a;
    }
    if (n>=0) cout<<n<<endl;
    else cout<<-1<<endl;
    return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i = 0; i < n; i++)  cin >> h[i];
  vector<int> dp(n + 1, 0);
  dp[0] = 0;
  dp[1] = abs (h[1] - h[0]);

  for(int i = 2; i < n; i++)
    dp[i] = min (abs (h[i] - h[i - 2]) + dp[i - 2], abs (h[i] - h[i - 1]) + dp[i - 1]);

  cout << dp[n - 1] << endl;
  return 0;
}


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

int main(){
	string s;
	cin >> s;
	for(char c = 'a';c <= 'z';c++){
		for(int i = 0;i + 1 < s.size();i++){
			if(s[i] == c && s[i + 1] == c){
				cout << i + 1 << ' ' << i + 2 << endl;
				return 0;
			}
		}
		for(int i = 0;i + 2 < s.size();i++){
			if(s[i] == c && s[i + 2] == c){
				cout << i + 1 << ' ' << i + 3 << endl;
				return 0;
			}
		}
	}
	cout << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

bool fc(int x){
  bool f3 = false, f5 = false, f7 = false;
  while(x != 0){
    int m = x % 10;
    if(m == 3) f3 = true;
    if(m == 5) f5 = true;
    if(m == 7) f7 = true;
    x /= 10;
  }
  return f3 && f5 && f7;
}

int main(){
  int n;
  cin >> n;
  queue<int> q;
  if(3 <= n) q.push(3);
  if(5 <= n) q.push(5);
  if(7 <= n) q.push(7);
  int ans = 0;
  while(!q.empty()){
    int now = q.front(); q.pop();
    if(fc(now) == true) ans++;
    if((ll)now*10+3 <= n) q.push(now*10+3);
    if((ll)now*10+5 <= n) q.push(now*10+5);
    if((ll)now*10+7 <= n) q.push(now*10+7);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,dp[1005][1005],mod=1e9+7;
char c[1005][1005];
main () {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m;
	
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=m; j++) {
			cin>>c[i][j];
			if (i==1 && j==1) {
				if (c[i][j]!='#') dp[i][j]=1;
			}

			if (c[i][j]=='.') 
				dp[i][j]=(dp[i][j]+dp[i][j-1]+dp[i-1][j])%mod;
		}
	}
	
	cout<<dp[n][m]<<endl;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
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; }
using namespace std;

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w; cin>>h>>w;
    vector<vector<char>> red(h,vector<char>(w,'.')),blue(h,vector<char>(w,'.'));
    rep(i,h)rep(j,w){
        char c; cin>>c;
        if(c=='#')red[i][j]=blue[i][j]='#';
        if(j==0)red[i][j]='#';
        if(j==w-1)blue[i][j]='#';
        if(i%2==0 and j!=w-1)red[i][j]='#';
        if(i%2==1 and j!=0)blue[i][j]='#';
    }
    rep(i,h){
        rep(j,w)cout<<red[i][j];
        cout<<endl;
    }
    cout<<endl;
    rep(i,h){
        rep(j,w)cout<<blue[i][j];
        cout<<endl;
    }
}

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

#define M 1046527
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch == 'A') return 1;
  else if(ch == 'C') return 2;
  else if(ch == 'G') return 3;
  else if(ch == 'T') return 4;
  else return 0;
}

long long getkey(char str[]){
  int sum=0,p=1,i;
  for(i = 0;i<strlen(str);i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }

  return sum;
}

int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}

int find(char str[]){
  long long key,i,h;
  key =getkey(str);
  for(i=0;;i++){
    h = (h1(key) + i*h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getkey(str);
  for(i=0;;i++){
    h = (h1(key)+i*h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i,n,h;
  char str[L],com[9];
  for(i=0;i<M;i++) H[i][0] = '\0';
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);

    if(com[0] == 'i'){
      insert(str);
    }else{
      if(find(str)){
	printf("yes\n");
      }else{
	printf("no\n");
      }
    }
  }
  return 0;
}



Measured memory_bytes: 16100
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int n, m, dp[2010][2010][2], s[2010], t[2010];
string ss, tt;
signed main(void)
{
  cin >> n >> m >> ss >> tt;
  REP(i, n) s[i] = ss[i]=='I'?0:1;
  REP(i, m) t[i] = tt[i]=='I'?0:1;
  REP(i, n) if(!s[i] || dp[i][0][0]) {
    chmax(dp[i+1][0][s[i]], dp[i][0][!s[i]]+1);
  }
  REP(i, m) if(!t[i] || dp[0][i][0]) {
    chmax(dp[0][i+1][t[i]], dp[0][i][!t[i]]+1);
  }
  REP(i, n) REP(j, m) {
    if(!s[i] || dp[i][j+1][0]) chmax(dp[i+1][j+1][s[i]], dp[i][j+1][!s[i]]+1);
    if(!t[j] || dp[i+1][j][0]) chmax(dp[i+1][j+1][t[j]], dp[i+1][j][!t[j]]+1);
  }
  int ma = 0;
  REP(i, n+1) {
    REP(j, m+1) {
      chmax(ma, dp[i][j][0]);
      // cout << dp[i][j][0] << "," << dp[i][j][1] << " ";
    }
    // cout << endl;
  }
  cout << ma << endl;

  return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll N, M; cin >> N >> M;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];

    vector<ll> s(N+1, 0);
    rep(i, N) s[i+1] = s[i] + a[i];

    unordered_map<ll, ll> um;
    rep(i, N+1){
        um[s[i]%M]++;
    }

    ll res = 0;
    for(auto m: um){
        ll tmp = m.second;
        res += tmp*(tmp-1)/2;
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 9356
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template <typename T,T INF,bool isMin>
struct ConvexHullTrick {
  using P = pair<T, T>;
  deque<P> L;

  inline T getY(const P &a,const T &x){
    return a.first*x+a.second; 
  }

  inline bool check(const P &a,const P &b,const P &c){
    return (b.first-a.first)*(c.second-b.second)
      >= (b.second-a.second)*(c.first-b.first);
  }
  
  void add(T a,T b){
    if(!isMin) a*=-1,b*=-1;
    P line(a,b);
    if(!L.empty()&&L.back().first==a){
      line.second=min(line.second,L.back().second);
      L.pop_back();
    }
    while(L.size()>=2&&check(L[L.size()-2],L[L.size()-1],line)) L.pop_back();
    L.emplace_back(line);    
  }

  T get(T x){
    if(L.empty()) return isMin?INF:-INF;
    Int low=-1,high=L.size()-1;
    while(low+1<high){
      Int mid=(low+high)>>1;
      if(getY(L[mid],x)>=getY(L[mid+1],x)) low=mid;
      else high=mid;
    }
    return (!isMin?-1:1)*getY(L[high],x);
  }
  
  T getMonotone(T x){
    if(L.empty()) return isMin?INF:-INF;
    while(L.size()>=2&&getY(L[0],x)>=getY(L[1],x)) L.pop_front();
    return (!isMin?-1:1)*getY(L[0],x);
  }
};


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n,c;
  cin>>n>>c;
  vector<Int> h(n);
  for(Int i=0;i<n;i++) cin>>h[i];
  const Int INF = 1e18;
  ConvexHullTrick<Int, INF, true> cht;
  cht.add(-2*h[0],h[0]*h[0]);
  for(Int i=1;i<n;i++){
    Int val=cht.get(h[i])+h[i]*h[i]+c;
    if(i==n-1) cout<<val<<endl;
    cht.add(-2*h[i],val+h[i]*h[i]);
  }
  return 0;
}


Measured memory_bytes: 5120
using System;
/// <summary>
/// imitating http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2590247#1
/// </summary>
/// practice de get set
/// 
namespace HelloWorld
{
    internal class Vector
    {
        internal double x { get; set; }
        internal double y { get; set; }
    }
    class Program
    {
        static void Main()
        {
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                double[] num = Array.ConvertAll(line.Split(), double.Parse);
                Vector a = new Vector { x = num[0], y = num[1] };
                Vector b = new Vector { x = num[2], y = num[3] };
                Vector c = new Vector { x = num[4], y = num[5] };
                Vector p = new Vector { x = num[6], y = num[7] };
                Console.WriteLine(Check(a, b, c, p) ? "YES" : "NO");
            }
        }
        public static bool Check(Vector a, Vector b, Vector c, Vector p)
        {
            var ab = mkVector(b, a);            
            var bc = mkVector(c, b);
            var ca = mkVector(a, c);
            var ap = mkVector(p, a);
            var bp = mkVector(p, b);
            var cp = mkVector(p, c);
            var c1 = ab.x * bp.y - ab.y * bp.x;                 //Getting Squares using vector
            var c2 = bc.x * cp.y - bc.y * cp.x;
            var c3 = ca.x * ap.y - ca.y * ap.x;
            if ((c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0)) // if existing
                return true;
            else
                return false;
        }
        /// <summary>
        /// Getting Each distances
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static Vector mkVector(Vector a, Vector b)
        {
            var c = new Vector();
            c.x = a.x - b.x;
            c.y = a.y - b.y;
            return c;
        }
    }
}


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

typedef long long ll;
const int mod= 1e9+7;
ll power(ll x,ll y){ll res=1;x=x%mod;while(y>0){if(y&1)res=((res%mod)*(x%mod))%mod;y=y>>1;x=((x%mod)*(x%mod))%mod;}return res;}
int main ()
{
   ll n;
   cin>>n;

   set <ll> s;
   for (ll i=0;i<n;i++)
   {
      ll a;

      cin>>a;
      s.insert(a);
   }
   if (s.size()!=n)
   {
      cout<<"NO";
   }
   else
      cout<<"YES";
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
const int N=2e3+20;
typedef long long ll;
//ÌâÒâ:n*m¾ØÕó,n,m<=2e3,¾ØÕóÖÐµÄ1ÄÜ×ßµ½ÏàÁÚ4¸ö1ÉÏ,0´ú±íÕÏ°­,ÈôÁ½¸ö1ÁªÍ¨ ÔòÖ»ÓÐÒ»ÌõÂ·¾¶ 
//q¸öÑ¯ÎÊ,q<=2e5,Ã¿´ÎÑ¯ÎÊÒ»¸ö×Ó¾ØÕóÖÐÓÐ¶àÉÙ¸öÁ¬Í¨·ÖÁ¿?

//Í¬Ò»¸öÁ¬Í¨·ÖÁ¿ÖÐÈÎÒâÁ½µãÖ»ÓÐÒ»ÌõÂ·¾¶,ÓÚÊÇ¶ÔÏàÁÚµÄÃ¿¸ö1Á¬½ÓÒ»Ìõ±ß,Ã¿Ò»¸öÁ¬Í¨·ÖÁ¿ÏÔÈ»¶¼ÎªÒ»¿ÅÊ÷
//Èô×Ó¾ØÐÎÓÐkÁªÍ¨·ÖÁ¿,ÒòÎªÃ¿¸öÁªÍ¨·ÖÁ¿¶¼ÎªÊ÷,Ôò×Ó¾ØÐÎÖÐµãÊý-±ßÊýµÈÓÚk ÀûÓÃ¶þÎ¬Ç°×ººÍÇó³ö×Ó¾ØÐÎ1µÄ¸öÊý(µã)ºÍÏàÁÚ1(±ß)¸öÊý¼´¿É
 
int n,m,q;
int f[N][N],h[N][N],g[N][N];//f[i][j] (0,0)~(i,j)ÖÐÓÐ¶àÉÙ¸ö1 
//h,g Ë®Æ½ºÍÊúÖ±ÏàÁÚµÄ±ß 
char s[N][N];
int main()
{
	while(cin>>n>>m>>q)
	{
		for(int i=1;i<=n;i++)
			scanf("%s",s[i]+1);
		memset(f,0,sizeof(f));
		memset(h,0,sizeof(h));
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				f[i][j]=f[i-1][j]+f[i][j-1]-f[i-1][j-1]+(s[i][j]-'0');
				int cnt=0,res=0;
				if(s[i][j]=='1')
				{
					if(s[i-1][j]=='1')
						res++;
					if(s[i][j-1]=='1')
						cnt++;
				}
				h[i][j]=h[i-1][j]+h[i][j-1]-h[i-1][j-1]+cnt;
				g[i][j]=g[i-1][j]+g[i][j-1]-g[i-1][j-1]+res;
			//	cout<<g[i][j]<<' ';
			}
		}
		int x1,y1,x2,y2;
		while(q--)
		{
			scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
			int ans=f[x2][y2]-f[x2][y1-1]-f[x1-1][y2]+f[x1-1][y1-1];
			int cnt=h[x2][y2]-h[x2][y1]-h[x1-1][y2]+h[x1-1][y1];
			int res=g[x2][y2]-g[x1][y2]-g[x2][y1-1]+g[x1][y1-1];	
			ans-=cnt+res;
			printf("%d\n",ans);
		}
	}
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  vector<string> t = {"SAT","FRI","THU","WED","TUE","MON","SUN"};
  for(int i = 0; i < 7; i++){
    if(s == t[i]){
      cout << i+1 << endl;
      return 0;
    }
  }
}

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

using namespace std;


long long h,w,f[1005][1005];
char a[1005][1005];

 main()
{
    cin>>h>>w;
    for (long long i=1;i<=h;i++)
        for (long long j=1;j<=w;j++)
    {
        cin>>a[i][j];
    }
    f[1][1]=1;
    for (long long i=1;i<=h;i++)
        for (long long j=1;j<=w;j++)
    {
        if (a[i][j]=='#') {
                f[i][j]=0;
        continue;
        }
        f[i][j]+=(f[i-1][j]+f[i][j-1])%1000000007;
    }
    cout<<f[h][w];
    return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
struct Tree {
    long long val[N << 2] = {};
    inline void pull(int idx) {
        val[idx] = max(val[idx << 1], val[idx << 1 | 1]);
    }
    void build(int l, int r, int idx) {
        if (l == r) return;
        int L = (idx << 1), R = (idx << 1 | 1), mid = (l + r) >> 1;
        build(l, mid, L);
        build(mid + 1, r, R);
    }
    long long query(int ql, int qr, int l, int r, int idx) {
        if (ql == l && qr == r) return val[idx];
        int L = (idx << 1), R = (idx << 1 | 1), mid = (l + r) >> 1;
        if (qr <= mid) return query(ql, qr, l, mid, L);
        else if (mid + 1 <= ql) return query(ql, qr, mid + 1, r, R);
        else return max(query(ql, mid, l, mid, L), query(mid + 1, qr, mid + 1, r, R));
    }
    void modify(int m, int l, int r, int idx, long long v) {
        if (l == m && r == m) {
            val[idx] = v;
            return;
        }
        int L = (idx << 1), R = (idx << 1 | 1), mid = (l + r) >> 1;
        if (m <= mid) modify(m, l, mid, L, v);
        else if (mid + 1 <= m) modify(m, mid + 1, r, R, v);
        pull(idx);
    }
} tr;
pair<int, int> arr[N];
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    tr.build(1, n, 1);
    for (int i = 1; i <= n; i++)
        cin >> arr[i].first;
    for (int i = 1; i <= n; i++)
        cin >> arr[i].second;
    for (int i = 1; i <= n; i++) {
        tr.modify(arr[i].first, 1, n, 1, tr.query(1, arr[i].first, 1, n, 1) + arr[i].second);
    }
    cout << tr.val[1] << '\n';
    return 0;
}


Measured memory_bytes: 9304
sankaku = 0
eikaku = 0
donkaku = 0
chokkaku = 0

for xi in range(1, 10000000000000000):
    inline = input().split()
    a, b, c = (int(xi) for xi in inline)
    if c <a:
        sub = a
        a = c
        c = sub
    if c <b:
        sub = b
        b = c
        c = sub
    if c >= a + b:
        break

    c2 = c**2
    b2 = b**2
    a2 = a**2

    if c2 == b2+a2:
        chokkaku += 1

    if c2 < b2+a2:
        eikaku += 1

    if c2 > b2+a2:
        donkaku += 1

    sankaku += 1

print(sankaku, chokkaku, eikaku, donkaku)



Measured memory_bytes: 5604
S = list(input())

cnt0 = 0
cnt1 = 0
key = 0
for i in range(len(S)):
    if key == 1:
        if S[i] == "0":
            cnt0 += 1
        else:
            cnt1 += 1
        key = 0
    else:
        if S[i] == "1":
            cnt0 += 1
        else:
            cnt1 += 1
        key = 1

print(min(cnt0, cnt1))

Measured memory_bytes: 3956
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(void) {
  ll n,m,d;
  cin>>n>>m>>d;
  ll p = max(0LL,(n-d));
  if(d!=0){
    p*=2;
  }
  double ld = 1.*p/n/n;
  double ans = ld * (m-1);
  printf("%20.20f\n", ans);
  return 0;
}

Measured memory_bytes: 256
S=input()
if S=='SUN':
    print(7)
elif S=='MON':
    print(6)
elif S=='TUE':
    print(5)
elif S=='WED':
    print(4)
elif S=='THU':
    print(3)
elif S=='FRI':
    print(2)
elif S=='SAT':
    print(1)

Measured memory_bytes: 9044
import sys

N, K = map(int, input().split())
S = input()


def nexti(n):
    while S[n] == '1':
        n += 1
    while S[n] == '0':
        n += 1
    return n


def nextj(n):
    while S[n] == '0':
        n += 1
        if n == N:
            return N
    while S[n] == '1':
        n += 1
        if n == N:
            return N
    return n


i = 0
j = 0
while S[j] == '1':
    j += 1
    if j == N:
        print(N)
        sys.exit(0)
for _ in range(K):
    j = nextj(j)
    if j == N:
        print(N)
        sys.exit(0)

ans = j - i
while True:
    i = nexti(i)
    j = nextj(j)
    ans = max(ans, j - i)
    if j == N:
        break

print(ans)

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

using LL = long long;
using LD = long double;
 
LL mod = 1e9+7;

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

	vector<LL> a(m);
	LL sum = 0;
	for (auto &e : a) {
		cin >> e;
		sum += e;
	}

	if (sum > n) {
		cout << -1 << "\n";
	}
	else {
		cout << n-sum << "\n";
	}
}



Measured memory_bytes: 3636
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int count=0;
		int ans=0;
		for(int i=1;i<=a;i+=2){
			for(int j=1;j<=i;j+=2){
				if(i%j==0){
					count++;
				}
			}
			if(count==8){
				ans++;
			}
          	count=0;
		}
		System.out.println(ans);
		
		
	}
}



Measured memory_bytes: 35672
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
a=lmp()
ans=0
for i in a:
    ans+=1/i
print(1/ans)

Measured memory_bytes: 72704
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char c = sc.next().charAt(0);
        if (c >= 'a' && c <= 'z') {
            System.out.println('a');
        } else {
            System.out.println('A');
        }
    }
}

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

void swap(int& x, int& y)
{
	int t = x;
	x = y;
	y = t;
}

void sort(int& a, int& b, int& c)
{
	if (a > b) swap(a, b);
	if (b > c) swap(b, c);
	if (a > b) swap(a, b);
}

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	sort(a, b, c);
	cout << a << " " << b << " " << c << endl;
	return 0;
}

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

bool comp(pair<long,long> a, pair<long,long> b){
  if(a.second != b.second){
    return a.second < b.second;
  }else{
    return a.first < b.first;
  }
}

bool xcomp(pair<int, pair<long,long>> a, pair<int, pair<long,long>> b){
  if(a.second.first != b.second.first){
    return a.second.first < b.second.first;
  }else{
    return a.second.second < b.second.second;
  }
}

bool ycomp(pair<int, pair<long,long>> a, pair<int, pair<long,long>> b){
  if(a.second.second != b.second.second){
    return a.second.second < b.second.second;
  }else{
    return a.second.first < b.second.first;
  }
}

int main(){
  int n;
  cin >> n;
  vector<pair<int, pair<long,long>>> xy(n),origin(n);
  rep(i,n){
    cin >> xy[i].second.first >> xy[i].second.second;
    xy[i].first = i;
  }
  origin = xy;
  vector<int> root(n);
  rep(i,n)root[i] = i;
  vector<pair<long,pair<long,long>>> dist(2*n-2);
  sort(xy.begin(), xy.end(), xcomp);
  rep(i,n-1){
    long dis = xy[i+1].second.first - xy[i].second.first;
    dist[i].first = dis;
    dist[i].second.first = xy[i].first;
    dist[i].second.second = xy[i+1].first;
  }
  sort(xy.begin(), xy.end(), ycomp);
  rep(i,n-1){
    long dis = xy[i+1].second.second - xy[i].second.second;
    dist[n-1+i].first = dis;
    dist[n-1+i].second.first = xy[i].first;
    dist[n-1+i].second.second = xy[i+1].first;
  }
  sort(dist.begin(), dist.end());
  long ans = 0, cnt = 0;
  rep(i,2*n-2){
    // long x = origin[dist[i].second].second.first;
    // long y = origin[dist[i].second].second.second;
    long x = dist[i].second.first;
    long y = dist[i].second.second;
    long tmpx = 0, tmpy = 0;
    while(root[x] != x){
      x = root[x];
      tmpx++;
    }
    while(root[y] != y){
      y = root[y];
      tmpy++;
    }
    if(x != y){
      if(tmpx<tmpy){
        root[x] = y;
      }else{
        root[y] = x;
      }
      ans += dist[i].first;
      cnt++;
    }
    if(cnt == n)break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 13040
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define MAX 100010
#define aout(a) REP(i,sizeof(a)) cout << a[i] << " "; cout << endl;
#define vout(v) REP(i,v,size()) cout << v[i] << " "; cout << endl;
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main() {
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll ans = -1000000000000000010;
  ans = max(ans,a*c);
  ans = max(ans,a*d);
  ans = max(ans,b*c);
  ans = max(ans,b*d);
  cout<<ans;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<pair<int, ll>>>;

const int INF = 1001001001;
ll h, w;

ll solve1(ll a){
    ll res = h - a;
    ll b = res/2, c = res - b;
    return max(abs(a-b), max(abs(a-c), abs(b-c))) * w;
}

ll solve2(ll a){
    ll res = h - a;
    ll b = w/2, c = w - b;
    return max(abs(a*w - res*b), max(abs(a*w - res*c), abs(res*b - res*c)));
}

int main(){
    cin >> h >> w;
    ll ans = INF;
    for(ll a = 1; a <= h-1; a++){
        ll tmp1 = solve1(a);
        ll tmp2 = solve2(a);
        ans = min(ans, min(tmp1, tmp2));
    }
    swap(h, w);
    for(ll a = 1; a <= h-1; a++){
        ll tmp1 = solve1(a);
        ll tmp2 = solve2(a);
        ans = min(ans, min(tmp1, tmp2));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vs vector<string>
#define mii map<int, int>


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

  string s, t;
  cin>>s>>t;
  int sl = s.length(), tl = t.length(); 
  int dp[sl+1][tl+1];
  for(int i = 0; i<= sl; i++){
  	for(int j = 0; j <= tl; j++){
  		dp[i][j] = 0;
  	}
  }

  for(int i = 1; i<= sl; i++){
  	for(int j = 1; j <= tl; j++){
  		if(s[i-1] == t[j-1]){
  			dp[i][j] = dp[i-1][j-1] + 1;
  		}else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
  	}
  }

  int i = sl, j = tl;
  string ans = "";
  while(i >= 1 && j >= 1){
  	if(s[i-1] == t[j-1]){
  		ans += s[i-1];
  		i--;
  		j--;
  	}else if(dp[i-1][j] > dp[i][j-1]) i--;
  	else j--;
  }
  reverse(ans.begin(), ans.end());
  cout<<ans<<endl;

}

Measured memory_bytes: 35456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int c = line.indexOf(' ');
			System.out.println(
					parseInt(line.substring(0, c))
							+ +parseInt(line.substring(c + 1)
					));
		}
	}
}

Measured memory_bytes: 24248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    vector<ll> b;
    vector<ll> a;
    rep(i, 0, n){
        ll tmp;
        cin >> tmp;
        tmp--;
        b.push_back(tmp);
    }

    while(b.size()){
        bool flag = true;
        rrep(i, b.size() - 1, 0){
            if(i == b[i]){
                a.push_back(b[i] + 1);
                b.erase(b.begin() + i);
                flag = false;
                break;
            }
        }
        if(flag){
            cout << -1 << endl;
            return 0;
        }
    }

    rrep(i, n - 1, 0){
        cout << a[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
ll inv[SIZE],f[SIZE],finv[SIZE];
void make_table(){
	int i;
	f[0]=f[1]=1; finv[0]=finv[1]=1;
	inv[1]=1;
	FOR(i,2,SIZE+1){
		inv[i]=MOD-(MOD/i)*inv[MOD%i]%MOD;
		f[i]=(f[i-1]*(ll)i)%MOD;
		finv[i]=(finv[i-1]*inv[i])%MOD;
	}
	return;
}
ll comb(int n,int k){
	if(n<0||k<0||n<k) return 0;
	return (((f[n]*finv[k])%MOD)*finv[n-k])%MOD;
}
int pos[100001];
int main(void)
{
	int n,a,s,t,i;
	ll res;
	make_table();
	scanf("%d",&n);
	FOR(i,0,n+1){
		scanf("%d",&a);
		if(!pos[a]) pos[a]=i+1;
		else{
			s=pos[a];
			t=i+1;
		}
	}
	FOR(i,1,n+2){
		res=comb(n+1,i)-comb(s+n-t,i-1);
		if(res<0) res+=MOD;
		printf("%lld\n",res);
	}
	return 0;
}


Measured memory_bytes: 3840
IDENTIFICATION DIVISION.
	PROGRAM-ID. IDEONE.

	ENVIRONMENT DIVISION.

	DATA DIVISION.
	WORKING-STORAGE SECTION.
	01 INP PIC X(100).
	01 A PIC 9(10).
	01 B PIC 9(10).
	01 temp1 PIC 9(10).
    01 temp2 PIC 9(10).
    01 N PIC 9(10).
	
	PROCEDURE DIVISION.
	MAIN.
		ACCEPT INP.
        PERFORM VARYING temp1 FROM 1 BY 1 UNTIL INP(temp1:1)=SPACE
        END-PERFORM.
        SUBTRACT 1 FROM temp1.
        MOVE INP(1:temp1) TO A.
        ADD 2 TO temp1.
        PERFORM VARYING temp2 FROM temp1 BY 1 UNTIL INP(temp2:1)=SPACE
        END-PERFORM.
        COMPUTE N=temp2 - temp1.
        MOVE INP(temp1:N) TO B.
        COMPUTE A = A * B.
        COMPUTE B = A / 2.
        COMPUTE B = B * 2.
		IF A = B THEN
			DISPLAY "Even"
		ELSE 
			DISPLAY "Odd"
		END-IF.
		STOP RUN.

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#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
//おまじない
//UnionFind

int main(){
    
    int a,p;
    cin >> a>>p;
    cout << (a*3+p)/2<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fr first
#define sc second
typedef long long ll;
////////////////////////////////////////////////////////////

typedef struct RollingHash {
    typedef long long int_type;
    typedef pair<int_type,int_type> hash_type;

    int_type base1;
    int_type base2;
    int_type mod1;
    int_type mod2;
    vector<int_type> hash1;
    vector<int_type> hash2;
    vector<int_type> pow1;
    vector<int_type> pow2;

    RollingHash() : base1(1009), base2(1007), mod1(1000000007), mod2(1000000009) {}

    void init(const string &s) {
        int n = s.size();

        hash1.assign(n+1,0);
        hash2.assign(n+1,0);
        pow1.assign(n+1,1);
        pow2.assign(n+1,1);

        for(int i=0;i<n;i++) {
            hash1[i+1] = (hash1[i]+s[i]) * base1 % mod1;
            hash2[i+1] = (hash2[i]+s[i]) * base2 % mod2;
            pow1[i+1] = pow1[i] * base1 % mod1;
            pow2[i+1] = pow2[i] * base2 % mod2;
        }
    }

    hash_type get(int l,int r) {
        int_type t1 = ((hash1[r] - hash1[l] * pow1[r-l]) % mod1 + mod1) % mod1;
        int_type t2 = ((hash2[r] - hash2[l] * pow2[r-l]) % mod2 + mod2) % mod2;
        return make_pair(t1, t2);
    }

    RollingHash::hash_type concat(hash_type h1, hash_type h2, int h2_len) {
        return make_pair((h1.fr*pow1[h2_len]+h2.fr)%mod1, (h1.sc*pow2[h2_len]+h2.sc)%mod2);
    }

}rh;

int main(){
	int n,m;
	string s;
	cin >> n >> m >> s;
	
	rh r;
	r.init(s);
	
	typedef unsigned long long ull;
	vector<pair<ull,ull>> ans;
	
	ll rr = 1 , l = 0;
	rep(i,0,m){
		string in;
		cin >> in;

		if( in == "R++") rr++;
		else if(in == "R--") rr--;
		else if(in == "L++") l++;
		else l--;
		
		ans.push_back( r.get(l,rr) );	
	}

	vsort(ans);
	cout << unique( ans.begin() , ans.end() ) - ans.begin() << endl;

	ret 0;
}


Measured memory_bytes: 21096
nm = input().split()
n = int(nm[0])
m = int(nm[1])
pylist = [input().split() for _ in range(m)]
yplist = [(int(py[1]), int(py[0]), i) for i, py in enumerate(pylist)]
yplist.sort()
city_counts = {}

anslist = {}

for y, p, i in yplist:
    if p not in city_counts:
        city_counts[p] = 0
    city_counts[p] += 1
    anslist[i] = '%06d%06d' % (p, city_counts[p])


for i in range(m):
    print(anslist[i])


Measured memory_bytes: 117720
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int max = 0;
    int sum = 0;
    for(int i = 0; i < N; i++){
      int tmp = sc.nextInt();
      max = max > tmp ? max : tmp;
      sum += tmp;
    }
    
    System.out.println(sum - max / 2);
  }
}
    

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

int main()
{
    int a,b,c,k;
    std::cin >> a >> b >> c>> k;

    if (k <= a) {
        std::cout << k << std::endl;
        return 0;
    }
    k -= a;
    if (k <= b) {
        std::cout << a << std::endl;
        return 0;
    }
    k -= b;

    std::cout << a - k << std::endl;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
ll N, K, Q;
vector<int> A;
const ll INF = 1e12;

int main()
{
    cin >> N >> K >> Q;
    A.resize(Q);
    for (int i = 0; i < Q; ++i)
    {
        cin >> A[i];
        --A[i];
    }

    vector<int> ans(N);
    ll sum = Q;
    for (int i = 0; i < Q; ++i)
    {
        int ind = A[i];
        ans[ind]++;
    }

    for (int i = 0; i < N; ++i)
    {
        if (Q - ans[i] < K)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string w; cin >> w;
  map<char, int> mp;
  for (char c : w) ++mp[c];
  REP(i, 26) if (mp['a' + i] & 1) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int a, b, c, d, e, f;
	while(cin >> a >> b >> c >> d >> e >> f){
		double detA;
		double ansx, ansy;
		
		detA = (a*e)-(b*d);
		
		ansx = ((c*e)-(b*f))/detA;
		ansy = ((a*f)-(c*d))/detA;
		
		if(ansx == 0){
			ansx = 0;
		}
		if(ansy == 0){
			ansy = 0;
		}
		
		printf("%.3lf %.3lf\n",ansx,ansy);
	}
}

Measured memory_bytes: 0
import bisect

N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))

Upper = []
for i in B:##上の台について二分探索
    middle = bisect.bisect(A,i-1)
    Upper.append(middle)
for i in range(N-1):##累積和
    Upper[i+1] += Upper[i]
Upper = [0] + Upper

ans = 0
for i in C:
    bottom = bisect.bisect(B,i-1)
    ans += Upper[bottom]

print(ans)

Measured memory_bytes: 23092
S = input()
pattern1 = "".join([str(x%2) for x in range(len(S))])
pattern2 = "".join([str((x+1)%2) for x in range(len(S))])

def energy(st1, st2):
  ene = 0
  for i in range(len(st1)):
    ene += abs(int(st1[i])-int(st2[i]))
  return ene

print(min(energy(S, pattern1), energy(S, pattern2)))


Measured memory_bytes: 9588
N = int(input())
H = list(map(int, input().split()))

for i in range(N - 1):
    if H[i + 1] - H[i] >= 1:
        H[i + 1] -= 1
    elif H[i + 1] - H[i] < 0:
        print("No")
        exit()
    else:
        pass

print("Yes")


Measured memory_bytes: 63856
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")
#pragma GCC optimize("unroll-loops")
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
using namespace std;
int dp[20][2];
int main()
{
	// std::ios::sync_with_stdio(false);
	// cin.tie(0);
	// cout.tie(0);
	int i,j;
	string n;
	cin>>n;
	for(i=sz(n)-1;i>=0;i--){
		dp[i][0]=9*(sz(n)-i);
		for(j=0;j<=n[i]-'0';j++)
			if(j<n[i]-'0')
				dp[i][1]=max(dp[i][1],j+dp[i+1][0]);
			else
				dp[i][1]=max(dp[i][1],j+dp[i+1][1]);
	}
	cout<<dp[0][1];
	return 0;
}

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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;


//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


struct Edge {
    int to, from;
    ll cost;
    Edge(int from, int to, ll cost): from(from), to(to), cost(cost) {}
};

typedef vector<vector<Edge>> AdjList;
AdjList graph;

vector<pair<ll, int>> vp;
int main() {
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    
    int W, H; cin >> W >> H;

    REP(i, W){
        ll p; cin >>p;
        vp.push_back({p, 0});
    }

    REP(i, H){
        ll q; cin >> q;
        vp.push_back({q, 1});
    }

    sort(all(vp));

    ll ans = 0;

    REP(i, vp.size()){
        if(vp[i].second == 0){
            ans += vp[i].first * (H+1);
            W--;
        }else{
            ans += vp[i].first * (W+1);
            H--;
        }
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 6256
n = int(input())
p = [int(input()) for _i in range(n)]

visit = [-1 for _i in range(n+1)]
for i in p:
    if visit[i-1] < 0:
        visit[i] = 1
    else:
        visit[i] = visit[i-1]+1
print(n-max(visit))

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

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  cout << min(n*a,b) << endl;


  return 0;
}

Measured memory_bytes: 256