akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<stack>
#include<bitset>
#include<map>
#include<numeric>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;
const ll mod = 1000000007;
const long double eps = 1e-8;
typedef pair<ll, ll> LP;

#define int short int
typedef pair<int, int> P;

typedef long double ld;

int h, w;

typedef pair<vector<int>, P> speP;

void solve() {
	vector<vector<int>> v(h),sz;
	map<speP, bool> mp;
	sz.resize(h);
	rep(i, h) {
		v[i].resize(w); sz[i].resize(w,0);
		rep(j, w)cin >> v[i][j];
	}
	rep(i, h) {
		rep(j, w) {
			if (v[i][j] == 0)continue;
			rep1(k, 11) {
				bool f = true;
				Rep(x, i, i + k) {
					Rep(y, j, j + k) {
						if (x >= h || y >= w) {
							f = false; break;
						}
						if (v[x][y] == 0) {
							f = false; break;
						}
					}
				}
				if (f) {
					sz[i][j] = k;
				}
				else break;
			}
		}
	}
	vector<int> sta;
	rep(i, h)rep(j, w)sta.push_back(v[i][j]);
	deque<speP> q;
	map<speP, int> ans;
	q.push_back({ sta,{0,0} }); ans[{sta, { 0,0 }}] = 0; mp[{sta, { 0,0 }}] = true;
	while (!q.empty()) {
			speP p = q.front(); q.pop_front();
			if (p.second == P{ h,0 }) {
				cout << ans[p] << endl; return;
			}
			vector<int> &v = p.first;
			int& x = p.second.first, y = p.second.second;
			//cout << x << " " << y << endl;
			int nd = ans[p];
			int nx = x, ny = y + 1;
			if (ny == w) {
				nx++; ny = 0;
			}
			
			speP nex; nex.second = { nx,ny };
			if (v[x*w+y] == 0) {
				//cout << nx << " " << ny << endl;
				nex.first = v;
				if (!mp[nex]) {
					mp[nex] = true;
					ans[nex] = nd;
					q.push_front(nex);
				}
				else {
					if (nd < ans[nex]) {
						ans[nex] = nd;
						q.push_front(nex);
					}
				}
			}
			else if (v[x*w+y] == 1) {
				int len = sz[x][y];
				Rep(i, x, x + len) {
					Rep(j, y, y + len) {
						v[i*w+j] = 2;
					}
				}
				nex.first = v;
				if (!mp[nex]) {
					mp[nex] = true;
					ans[nex] = nd + 1;
					q.push_back(nex);
				}
			}
			else {
				//non
				nex.first = v;
				if (!mp[nex]) {
					mp[nex] = true;
					ans[nex] = nd;
					q.push_front(nex);
				}
				else {
					if (nd < ans[nex]) {
						ans[nex] = nd;
						q.push_front(nex);
					}
				}
				bool exi = false;
				int len = sz[x][y];
				Rep(i, x, x + len) {
					Rep(j, y, y + len) {
						if (v[i*w+j] != 2)exi = true;
						v[i*w+j] = 2;
					}
				}
				if (exi) {
					nex.first = v;
					if (!mp[nex]) {
						mp[nex] = true;
						ans[nex] = nd+1;
						q.push_back(nex);
					}
				}
			}
	}
	//cout << dfs(v, 0, 0) << endl;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//string s = "-0=0";
	//cout << valid(s) << endl;
	//cout << fixed << setprecision(10);
	while (cin >> w >> h, w) {
		solve();
		//cout << "end" << endl;
	}
	//solve();
	//stop
		return 0;
}


Measured memory_bytes: 7612
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main()
{
  int A, B;
  cin >> A >> B;
  int a_min, a_max;
  int ans = -1;
  if(A%2==0){
    a_min = A * 12.5;
    a_max = int((A+1) * 12.5);
  }else{
    a_min = int(A * 12.5) + 1;
    a_max = (A+1) * 12.5  - 1;
  }
  for(int i=a_min; i<=a_max; ++i){
    if(int(i / 10) == B){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

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

map<int, vector<int> > Graph;
set<int> Q;
const int N = 1e5 + 10;
int A[N], B[N], H[N], n, m;
int ans = 0;

void build(){
	for(int i=1; i <= n; i++) Q.insert(i);
	for(int i=1; i <= m; i++){
		Graph[A[i]].push_back(B[i]);
		Graph[B[i]].push_back(A[i]);
	}
}

void solve(){
	while(Q.size()){
		int node = *Q.begin();
		int node_h = H[node];
		bool flag = true;
		for(int i=0; i < Graph[node].size(); i++){
			int other = Graph[node][i];
			int other_h = H[other];
			if(other_h >= node_h) flag = false;
			else Q.erase(other); 
		}
		Q.erase(node);
		if(flag) ans++;
	}
}

int main(){
	cin >> n >> m;
	for(int i=1; i <= n; i++) cin >> H[i];
	for(int i=1; i <= m; i++) cin >> A[i] >> B[i];
	
	build();
	solve();

	cout << ans << endl;
}


Measured memory_bytes: 19092
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(vec) vec.begin(), vec.end()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define repc(bit, k, n) for (ll bit = (1 << k) - 1; bit < (1 << n); bit = next_combination(bit))
#define repi(itr, vec) for (auto itr = vec.begin(); itr != vec.end(); ++itr)
using namespace std;
struct UnionFind
{
  //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
  //そうでなければ親のid
  vector<int> r;

  UnionFind(int N)
  {
    r = vector<int>(N, -1);
  }

  int root(int x)
  {
    if (r[x] < 0)
      return x;
    return r[x] = root(r[x]);
  }

  bool unite(int x, int y)
  {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (r[x] > r[y])
      swap(x, y);
    r[x] += r[y];
    r[y] = x;
    return true;
  }

  int size(int x)
  {
    return -r[root(x)];
  }
};

struct Graph
{
  bool color;
  unordered_map<int, bool> path;
  void add(int to, bool p)
  {
    path[to] = p;
  }
  void print() { cout << color << endl; }
};

void rec(int v, vector<Graph> &G, vector<bool> &seen, bool color)
{
  seen[v] = true;
  G[v].color = color;
  for (auto next : G[v].path)
  {
    if (seen[next.first])
      continue;
    if (next.second)
      rec(next.first, G, seen, !color);
    else
      rec(next.first, G, seen, color);
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<Graph> G(n + 1);
  UnionFind even(n + 1);
  rep(i, n - 1)
  {
    int u, v, w;
    cin >> u >> v >> w;
    G[u].add(v, w % 2);
    G[v].add(u, w % 2);
    if (w % 2 == 0)
      even.unite(u, v);
  }
  vector<bool> seen(n + 1);
  rep(i, n)
  {
    if (seen[i + 1])
      continue;
    rec(even.root(i + 1), G, seen, false);
  }
  rep(i, n) G[i + 1].print();

  return 0;
}

Measured memory_bytes: 21156
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <map>

using namespace std;


int main(){

	long long N,M;
	cin>>N>>M;
	long long H[N+1];
	int highest[N+1];
	for(int i=1;i<=N;i++){
		highest[i]=1;
	}
	long long A[M+1],B[M+1];
	for(int i=1;i<=N;i++){
		cin>>H[i];
	}
	for(int i=1;i<=M;i++){
		cin>>A[i]>>B[i];
		
	}

	for(int i=1;i<=M;i++){
		if(H[A[i]]>H[B[i]]){
			highest[B[i]]=0;
		}else if(H[A[i]]<H[B[i]]){highest[A[i]]=0;
		}else{
			highest[A[i]]=0;
			highest[B[i]]=0;
		}
	}
	long long ryo=0;
	for(int i=1;i<=N;i++){
		ryo=ryo+highest[i];
	}

	cout<<ryo<<endl;


}


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

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (ll)n; ++i)
#define repr(i, n) for (int i = n - 1; i >= 0; --i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

void solve(void)
{
    string n;
    cin >> n;
    cout << count(all(n), '2') << endl;
}

int main(void)
{
    solve();
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

ll sum[100001], msum[100001];
 
int main(){
  int n,k;
  cin>>n>>k;
  ll a[n];
  sum[0]=0, msum[0]=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum[i+1]=sum[i]+a[i];
    msum[i+1]=msum[i]+max(1LL*0,a[i]);
  }
  ll ans=-LLONG_MAX;
  for(int i=1;i<=n+1-k;i++){
    ll tmp=sum[i+k-1]-sum[i-1];
    ll tmp2=msum[n]-(msum[i+k-1]-msum[i-1]);
    if(tmp>=0){
      ans=max(ans,tmp+tmp2);
    }else{
      ans=max(ans,tmp2);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2560
def solve():
    N = int(input())
    S = input()
    ans = 0

    for i in range(10):
        s1 = S.find(str(i), 0, -2)
        if s1 == -1:
            continue
        for j in range(10):
            s2 = S.find(str(j), s1+1, -1)
            if s2 == -1:
                continue
            ans += len(set(S[s2+1:]))
    print(ans)


if __name__ == '__main__':
    solve()

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

using namespace std;

using ll = long long;

const int MX = 2007;
vector<int> g[MX];

int curAns = 0;
void dfs(int v, int h, int p = -1) {
    if (h < 0) {
        curAns++;
    }
    for (int to : g[v]) {
        if (to != p) {
            dfs(to, h - 1, v);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    int n, k;
    cin >> n >> k;
    vector<pair<int, int> > e;
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
        e.emplace_back(u, v);
    }
    int ans = 2 * n;

    if (k % 2 == 0) {
        for (int i = 1; i <= n; i++) {
            curAns = 0;
            for (int v : g[i]) {
                dfs(v, k / 2 - 1, i);
            }
            ans = min(ans, curAns);
        }
    } else {
        for (auto& ee : e) {
            curAns = 0;
            dfs(ee.first, k / 2, ee.second);
            dfs(ee.second, k / 2, ee.first);
            ans = min(ans, curAns);
        }
    }
    cout << ans << "\n";
}




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

int main() {
  string S;
  cin >> S;

  string ans;

  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != 'B') ans += S.at(i);
    else if (ans != "") ans.pop_back();
  }

  cout << ans << endl;
}

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

const int nmax=8;
bool graph[nmax][nmax];

int dfs(int v,int N,bool visited[nmax]){
    bool all_visited=true;
    for(int i=0;i<N;i++){
        if(visited[i]==false) all_visited=false;
    }
    if(all_visited){
        return 1;
    }
    int ret=0;
    for(int i=0;i<N;i++){
        if(graph[v][i]==false) continue;
        if(visited[i]) continue;
        visited[i]=true;
        ret+=dfs(i,N,visited);
        visited[i]=false;
    }
    return ret;
}

int main(){
    int N,M;
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int A,B;
        cin>>A>>B;
        graph[A-1][B-1]=graph[B-1][A-1]=true;
    }
    bool visited[nmax];
    for(int i=0;i<N;i++){
        visited[i]=false;
    }
    visited[0]=true;
    cout<<dfs(0,N,visited)<<endl;
    
}

Measured memory_bytes: 256
// Problem : E - Coprime
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define int long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define mod 998244353
#define bug cout<<"HY"<<endl
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define numize(A) A.numize(unique(A.begin(), A.end()) - A.begin())
typedef pair<int,int> P;
int power(int a,int b)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return (power((a*a)%mod,b/2))%mod;
    return (a*(power((a*a)%mod,b/2))%mod)%mod;
}
int modInv(int n)
{
    return power(n, MOD-2);
}
int nCr(int n, int r, int p=MOD)
{
   if (r==0)
      return 1;
    int Fact[n+1];
    Fact[0] = 1;
    for (int i=1 ; i<=n; i++)
    {
        Fact[i] = (Fact[i-1]*i)%p;
    }
    return (((Fact[n]* modInv(Fact[r])) % MOD) *(modInv(Fact[n-r]) % MOD)) % MOD;
}
double PI=3.14159265359;
void solve()
{
	int n,i,j;
	cin>>n;
	int A[n];
	int g1=0;
	unordered_map<int,int> M;
	int m=0;
	for(i=0;i<n;i++)
	{
		cin>>A[i];
		m=max(m,A[i]);
		M[A[i]]++;
		g1=__gcd(g1,A[i]);
	}
	bool visited[1000005];
	memset(visited,0,sizeof(visited));
	bool f=false;
	for(i=2;i<=m;i++)
	{
		if(visited[i])
			continue;
		int cnt=0;
		for(j=i;j<=m;j+=i)
		{
			visited[i]=true;
			cnt+=M[j];
		}
		if(cnt>1)
		{
			if(g1!=1)
			{
				cout<<"not coprime"<<endl;
				return;
			}
			f=true;
		}
	}
	if(f)
	{
		cout<<"setwise coprime"<<endl;
	}
	else
	{
		cout<<"pairwise coprime"<<endl;
	}
}
int32_t main()
{
    boost;
    int  t=1;
    // cin>>t;
    while(t--)
    {
    	solve();
    }
}


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

using namespace std;

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

    vector<tuple<int, int, char, long long, string>> tpl;
    for (int i = 0; i < n; ++i) {
        int v;
        int w;
        char t;
        long long d;
        string s;
        cin >> v >> w >> t >> d >> s;
        tpl.emplace_back(v, w, t, d, s);
    }
    sort(tpl.begin(), tpl.end());

    for (auto x:tpl) {
        cout << get<0>(x) << " " << get<1>(x) << " " <<
             get<2>(x) << " " << get<3>(x) << " " << get<4>(x) << endl;
    }
    return 0;
}


Measured memory_bytes: 12248
n=int(input())
ans=1
sub=1
sub2=1
for i in range(n):
    ans*=10
    ans%=(10**9+7)
    sub*=9
    sub%=(10**9+7)
    sub2*=8
    sub2%=(10**9+7)
ans-=2*sub-sub2
print(ans%(10**9+7))




Measured memory_bytes: 63544
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>

using namespace std;


int main(){
  int a,b;
  cin >> a >> b;
  double a_double = (double) a;
  double b_double = (double) b;
  printf("%d %d %.7f\n",a/b,a%b,a_double/b_double);

 } 



Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#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 INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll calp(ll x,ll y){
  ll ans =1;

}
ll dp[1005][1005];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  int ans = n;
  FOR(i,1,n){
    if(s[i]!=s[i-1]){
      int tmp = max(i,n-i);
      ans = min(ans,tmp);
    }
  }
  cout<<ans << endl;

}




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

int n;
long long int max_w;
long long int w[101];
int v[101];
long long int dp[101][100001];
int main()
{
    cin >> n >> max_w;
    for (int i = 0; i < n; i++)
    {
        cin >> w[i] >> v[i];
    }
    for (int i = 0; i < 101; i++)
    {
        for (int j = 0; j < 100001; j++)
        {
            dp[i][j] = 1000000001;
        }
    }
    dp[0][0] = 0;
    //dp[0][v[0]] = w[0];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= 1000 * i + 1000; j++)
        {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            if (j + v[i] <= 100000)
            {
                dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
            }
        }
    }
    for (int i = 100000; i >= 0; i--)
    {
        if (dp[n][i] <= max_w)
        {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    cout << *max_element(a, a + n) - *min_element(a, a + n) << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

tminm = 0
for k in range(N):
  tminm += (A[k] - 1)**2

ma = max(A)
for i in range(1,ma+1):
  minm = 0
  for j in range(N):
    minm += (A[j] - i)**2
  
  if minm < tminm:
    tminm = minm

print(tminm)

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var imp = Console.ReadLine().Split(' ');
            int A = int.Parse(imp[0]);
            int B = int.Parse(imp[1]);

            if(B%A==0)
            {
                Console.Write(A + B);
            }
            else
            {
                Console.Write(B - A);
            }

            System.Threading.Thread.Sleep(1000);
        }
    }
}


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

#define ll long long
#define f first
#define s second

const ll mod = 1e9+7;

using namespace __gnu_pbds;
using namespace std;

template <class T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

void usaco(string name = "")
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(name.size())
    {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

const int mxN = 1e5+1;
vector <int> adj[mxN];
vector <int> vis(mxN), dp(mxN);
int ans = 0;

void dfs(int u)
{
    for (int v : adj[u])
        if (!vis[v])
            dfs(v);
    vis[u] = 1;
    for (int v : adj[u])
        dp[u] = max(dp[u], 1+dp[v]);
    ans = max(ans, dp[u]);
}

int main()
{
    usaco();
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i)
    {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
    }
    for (int i = 1; i <= n; ++i) if (!vis[i]) dfs(i);
    cout << ans << '\n';
}


Measured memory_bytes: 11436
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main(void) {

    int n,k;
    cin>>n>>k;
    int ans=0;
    rep(i,n){
        int x;cin>>x;
        ans+=2*(min(abs(k-x),abs(x)));
    }
    fin(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int solve(const string& A, const string& B){
    const int N = A.size();
    int s = B.find('1');
    if(s == string::npos) return (A.find('1') == string::npos ? 0 : -1);
    vector<int> nextL(N), nextR(N);
    int p = 0;
    for(int i=0;i<N;i++){
        if(B[(s+i)%N] == '1') p = (s+i)%N;
        nextL[(s+i)%N] = p;
    }
    for(int i=0;i<N;i++){
        if(B[(s+N-i)%N] == '1') p = (s+N-i)%N;
        nextR[(s+N-i)%N] = p;
    }
    int res = 10 * N;
    for(int shift=0;shift<N;shift++){
        int cur = 0;
        vector<pair<int, int>> vp;
        for(int i=0;i<N;i++){
            if(A[i] == B[(i+shift)%N]) continue;
            ++cur;
            if(A[i] == '0') continue;
            if(i+shift < N && i <= nextR[i] && nextR[i] <= i+shift) continue;
            if(i+shift >= N && (nextR[i] <= (i+shift)%N || i <= nextR[i])) continue;
            int left = nextL[i] - i;
            if(left > 0) left -= N;
            int right = nextR[(i+shift)%N] - (i+shift)%N;
            if(right < 0) right += N;
            vp.emplace_back(left, right);
        }
        sort(vp.begin(), vp.end());
        int addMove = 3*N;
        int maxR = 0;
        for(auto& v : vp){
            addMove = min(addMove, -v.first + maxR);
            maxR = max(maxR, v.second);
        }
        addMove = min(addMove, maxR);
        res = min(res, cur + shift + 2 * addMove);
    }
    return res;
}

int main(){
    string A, B;
    while(cin >> A >> B){
        int a = solve(A, B);
        reverse(A.begin(), A.end());
        reverse(B.begin(), B.end());
        int b = solve(A, B);
        cout << min(a, b) << endl;
    }
}

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


vector<ll> divisor(ll x)
{
	vector<ll> ret;
	for(ll i=1;i<=(ll)sqrt(x);i++)
	{
		if(x%i==0)
		{
			ret.push_back(i);
			if(x/i!=i) ret.push_back(x/i);
		}
	}
	return ret;
}
int main()
{
	ll N,M;
	cin>>N>>M;
	vector<ll> divs=divisor(M);
	sort(divs.begin(),divs.end());
	ll ans=0;
	for(ll x : divs)
	{
		if(x*N<=M) ans=x;
		else break;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
#define fi first
#define se second
typedef pair<int,int> P;
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
vector<P> a(n);
for(int i=0;i<n;i++){
    cin>>a[i].fi;
    a[i].se=i+1;
}
sort(all(a));
for(int i=0;i<n;i++){
   cout<<a[i].se<<" ";
}
cout<<endl;
}


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

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret), std::greater<int64_t>());
  return (ret);
}

int main() {
  int64_t N, total = 0;
  vector< int64_t > div;
  cin >> N;
  div = divisor(N);
//  cout << N << endl;
  int64_t size = div.size();
  for( int64_t i=0; i<size; ++i ) {
//     cout << div[i] << endl;
     int64_t m = div[i] - 1;
     if( m <= (N/div[i]) ) break;
     total += m;
//     cout << " " << m << endl;
  }
  cout << total << endl;

  
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
/*bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}*/

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


// ******************************CODE**********************************//





int main(){


        int n,M;
        cin >> n >> M;
        vector<int> a(n);
        for(int i = 0; i < a.size(); i++)
        {
                cin >> a[i];
        }

        map<int,int> m;
        vector<int> sum(n+1);
        sum[0] = 0;
        //累積和を作る
        for(int i = 0; i < n; i++)
        {
                sum[i+1] = (sum[i] + a[i]) % M;
        }

        //見ていく中で同じものが出たらその分を足してあげるとわかる。
        ll ans = 0;
        for(int i = 0; i < sum.size(); i++)
        {
                ans += m[sum[i]];
                m[sum[i]]++;
        }

        cout << ans << endl;



}


Measured memory_bytes: 3968
#include <stdio.h>
#include <vector>
using namespace std;

int linersearch(vector<int> a, int n, int key)
{
    int i = 0;
    a.push_back(key);
    while (a[i] != key)
    {
        i++;
    }
    return (i == n) ? 0 : 1;
}

int main()
{
    int count = 0;
    int n;
    scanf("%d", &n);
    vector<int> s(n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &s[i]);
    }
    int q;
    scanf("%d", &q);
    int key;
    for (int i = 0; i < q; i++)
    {
        scanf("%d", &key);
        count += linersearch(s, n, key);
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 2888
#include <cstdio>
void read(int &a){
	a=0;
	char c=getchar();
	while(c<'0'||c>'9'){
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		a=(a<<1)+(a<<3)+(c^48);
		c=getchar();
	}
}
const int Maxn=200000;
int a[Maxn+5];
int n;
int pos[Maxn+5],num[Maxn+5],len;
bool check(int x){
	len=0;
	num[0]=0;
	for(int i=1;i<=n;i++){
		if(a[i]>a[i-1]){
			continue;
		}
		if(len==0){
			pos[++len]=a[i];
			num[len]=1;
			continue;
		}
		while(len>0&&pos[len]>a[i]){
			len--;
		}
		if(len>0&&pos[len]==a[i]){
			num[len]++;
			while(len>0&&num[len]==x){
				int now=pos[len]-1;
				len--;
				if(pos[len]==now){
					num[len]++;
				}
				else{
					pos[++len]=now;
					num[len]=1;
				}
			}
		}
		else{
			pos[++len]=a[i];
			num[len]=1;
		}
		if(num[0]>0){
			return 0;
		}
	}
	return 1;
}
int main(){
	read(n);
	bool one=1;
	for(int i=1;i<=n;i++){
		read(a[i]);
		if(a[i]<=a[i-1]){
			one=0;
		}
	}
	if(one){
		puts("1");
		return 0;
	}
	int left=2,right=n,mid;
	while(left<right){
		mid=(left+right)>>1;
		if(check(mid)){
			right=mid;
		}
		else{
			left=mid+1;
		}
	}
	printf("%d\n",left);
	return 0;
}


Measured memory_bytes: 1024
N = int(input())
B = list(map(int, input().split()))

ans = []
removed = [False] * N

flag = True
while flag:
    flag = False
    
    idx_remove = -1
    idx = 0
    for i in range(N):
        if removed[i]:
            continue

        if idx + 1 == B[i]:
            idx += 1
            idx_remove = i

        else:
            idx += 1
    
    if idx_remove != -1:
        ans.append(B[idx_remove])
        removed[idx_remove] = True
        flag = True


if all(removed):
    for a in ans[::-1]:
        print(a)
else:
    print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
int main()
{
  ll a; cin >> a;
  string b; cin >> b;

  ll c = (b[0] - '0')*100 + (b[2] - '0')*10 + (b[3] - '0');
  cout << a*c/100 << "\n";
  
  return 0;
}


Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int cnt1 = 0;
        int cnt2 = 0;
        int cnt3 = 0;
        
        for (int i = 0; i < n; i++) {
            int p = sc.nextInt();
            if (p <= a)
                cnt1++;
            else if (p <= b)
                cnt2++;
            else
                cnt3++;
        }
        
        System.out.println(Math.min(cnt1, Math.min(cnt2, cnt3)));
    }
}



Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int a=stdIn.nextInt();
        int b=stdIn.nextInt();
		int c=stdIn.nextInt();
        if(a < b){
			if(b < c){System.out.println("Yes");return;}
        }
		
		System.out.println("No");

	}
}


Measured memory_bytes: 26188
#include<stdio.h>

int output(int *A, int N, int count){
  for(int i = 0; i < N; i++){
    printf("%d", A[i]);
    if(i < N - 1){
      printf(" ");
    }
  }
  printf("\n");
  
  printf("%d\n", count);

  return 0;
}

int bubble_sort(int *A, int N){
  int flag = 1;
  int count = 0;
  while(flag){
    flag = 0;
    for(int j = N - 1; j > 0; j--){
      if(A[j] < A[j-1]){
        int tmp = A[j];
        A[j] = A[j - 1];
        A[j - 1] = tmp;
        flag = 1;
        count++;
      }
    }
  }

  return count;
}

int main(void){
  int N;
  int A[101];

  scanf("%d", &N);
  for(int i = 0; i < N; i++){
    scanf("%d", &A[i]);
  }

  int count = bubble_sort(A, N);
  output(A, N, count);

  return 0;
}



Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e10;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 




////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////
int n;int a[210000];
signed main(){
  cin>>n;
  if(n % 2 == 1){
    cout << 0 << endl;return 0;
  }
  int cnt2 = 0;
  int m = n;
  while(m > 0){
    cnt2 += m/2;m /= 2;
  }
  int cnt5 = 0;m = n/2;
  while(m > 0){
    cnt5 += m/5;m /= 5;
  }
  cout << min(cnt5, cnt2) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  map<int,int> mp;
  for (int i = 0; i < n; ++i)
  {
    int tmp;
    cin>>tmp;
    mp[tmp]++;
  }
  vector<int> vec;
  for(auto&& e: mp) {
    vec.emplace_back(e.second);
  }
  int cnt=0;
  for(auto&& e: vec) {
    if(e%2==0) cnt++;
  }
  if(cnt%2==0) cout<<mp.size();
  else cout<<mp.size()-1;

}

Measured memory_bytes: 5628
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int w, a, b;
  cin >> w >> a >> b;
  int ret = max(0, abs(b - a) - w);
  cout << ret << endl;
  return 0;
}


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

#define FOR(i,s,e) for(int i = (s);i <= (e);i++)

int N;

int main()
{
	int a;
	set<int> s;
	cin >> N;
	FOR(i,0,N - 1)
	{
		cin >> a;
		if(s.find(a) == s.end())
		{
			s.insert(a);
		}
		else
		{
			s.erase(a);
		}
	}
	cout << s.size() << endl;
	return 0;
}


Measured memory_bytes: 4864
/*
    Problem 67
    https://atcoder.jp/contests/abc065/tasks/arc076_b
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* class */
class DisjointSet {
public:
    vector<int> d;
    DisjointSet () {}
    DisjointSet (int len) { d.assign(len, -1); }

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)];}
};
class Edge {
public:
    int u, v, w;
    Edge () {}
    Edge (int u, int v, int w) : u(u), v(v), w(w) {}
    bool operator < (const Edge &e) const {
        return w < e.w;
    }
};
class Point {
public:
    int x, ind;
    Point () {}
    Point (int x, int ind) : x(x), ind(ind) {}
    bool operator < (const Point &p) const {
        return x < p.x;
    }
};
/* global variables */
/* function */
/* main */
int main() {
    // 点たちを x 座標でソートした列において隣接する 2 点と、y 座標でソートした列において,
    // 隣接2点の間にそれぞれ辺を張ったグラフの最小全域木を求めればよい
    int N;
    cin >> N;
    vector<Point> X(N, Point()), Y(N, Point());
    for (int i = 0; i < N; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        X[i] = Point(x, i);
        Y[i] = Point(y, i);
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());

    vector<Edge> edges;
    int cnt = 0;
    for (int i = 0; i < N-1; i++) {
        edges.push_back(Edge(X[i].ind, X[i+1].ind, abs(X[i].x - X[i+1].x)));
        edges.push_back(Edge(Y[i].ind, Y[i+1].ind, abs(Y[i].x - Y[i+1].x)));
    }
    // kruscal
    sort(edges.begin(), edges.end());
    DisjointSet ds = DisjointSet(N);
    int totalCost = 0;
    for (Edge e : edges)
        if (ds.unite(e.u, e.v))
            totalCost += e.w;
    cout << totalCost << '\n';
}

Measured memory_bytes: 8068
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define sz(a)       (ll)(a.size())
#define cr(P)       cout<<P<<"\n";return;
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
using namespace std;


const ll N   =  500005;
const ll mod = 1e9 + 7;



void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k;
  cin>>n;
  	
  	fr(i,1,n+1){
  	fr(j,1,n+1){
  	fr(k,1,n+1){
  		c+= __gcd(i,__gcd(j,k));
  	}}
  	}
  	c(c);
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  //int T;cin >> T;while (T--)
  solve();
  return 0;
}


Measured memory_bytes: 3652
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef list<int> LI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EMP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000

const double EPS = 1e-10;
const double PI  = acos(-1.0);
////////////////////////////////////////////////
struct vec{double x;double y;};
double naiseki(vec a,vec b)
{
    return a.x*b.x+a.y*b.y;
}
 
int main()
{
    double xp1,xp2,yp1,yp2;
    cin>>xp1>>yp1>>xp2>>yp2;
    int q;cin>>q;
    vec base;
    base.x=xp2-xp1;
    base.y=yp2-yp1;
    cout<<fixed<<setprecision(10);
     
    for(int i=0;i<q;i++)
    {
        double s,t;
        cin>>s>>t;
        vec hypo;
        hypo.x=s-xp1;
        hypo.y=t-yp1;
        double x,y;
        x=xp1+base.x*naiseki(hypo,base)/naiseki(base,base);
        y=yp1+base.y*naiseki(hypo,base)/naiseki(base,base);
        cout<<x+x-s<<" ";
        cout<<y+y-t<<endl;
    }
    return 0;
}

Measured memory_bytes: 3284
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = Integer.valueOf(s);
        if(n<10){
            System.out.println(n);
            return;
        }
        int len = s.length();
        String r = "";
        for(int i=1;i<len;i++){
            if(i%2==1){
                r = "9" + r;
            }
            else{
                r = "0" + r;
            }
        }
        Integer b = Integer.valueOf(r);
        if(len%2==1){
            b += n - (int)Math.pow(10, len-1) + 1;
        }
        System.out.println(b);
    }
}

Measured memory_bytes: 22996
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

    int N,C,K;
    int[] T;

    public void randomSort(int[] array) {
        for(int i = 0;i < array.length;i++) {
            int ri = (int)(Math.random() * array.length);
            int tmp = T[i];
            T[i] = T[ri];
            T[ri] = tmp;
        }
    }

    public void solve() {
        N = nextInt();
        C = nextInt();
        K = nextInt();

        T = new int[N];
        for(int i = 0;i < N;i++) {
            T[i] = nextInt();
        }

        randomSort(T); //Arrays.sort()の最悪ケース対策
        Arrays.sort(T);

        int minTime = Integer.MAX_VALUE; //バスの到着時間の最小値
        int nowC = 0; //現在の乗客数
        int ans = 0; //必要なバスの数の最小値
        for(int i = N - 1;i >= 0;i--){
            if(T[i] + K < minTime || nowC >= C) {
                minTime = T[i];
                nowC = 0;
                ans++;
            }
            nowC++;
        }
        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 38252
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,A,B; cin >> N >> A >> B;
    res = min(A*N,B);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int main(void){
  int A[3][3];
  int N;
  int ans[3][3];
  bool bingo = false;
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> A[i][j];
    }
  }
  cin >> N;
  int b[N];
  for(int i = 0; i < N; i++){
    cin >> b[i];
  }
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      ans[i][j] = false;
    }
  }
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < N; k++){
	if(A[i][j] == b[k])
	  ans[i][j] = true;
      }
    }
  }
  for(int i = 0; i < 3; i++){
    if(ans[i][0] == 1 && ans[i][1] == 1 && ans[i][2] == 1)
      bingo = true;
  }
  for(int i = 0; i < 3; i++){
    if(ans[0][i] == 1 && ans[1][i] == 1 && ans[2][i] == 1)
      bingo = true;
  }
  if(ans[0][0] == 1 && ans[1][1] == 1 && ans[2][2] == 1) bingo = true;
  if(ans[0][2] == 1 && ans[1][1] == 1 && ans[2][0] == 1) bingo = true;
  if(bingo) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


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

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, ll>> p(n);
  rep(i, n) cin >> p[i].second >> p[i].first;

  sort(p.begin(), p.end());

  ll t = 0;
  for (auto pp : p) {
    t += pp.second;
    if (t > pp.first) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3328
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;

long H,N;
int A[100000];

string ans;
 
void solve(){
	sort(A,A+N,greater<int>());
	for(int i=0;i<N;i++){
		H-=A[i];
	}
	if(H<=0) ans="Yes";
	else ans="No";
}
 
int main(){
	cin>>H>>N;
	for(int i=0;i<N;i++) cin>>A[i];

	solve();

	cout << ans;
	return 0;
}

Measured memory_bytes: 640
use proconio::{input, marker::Chars};

fn main() {
    input! {
        n: usize,
        s: Chars,
    }

    let mut count_white = vec![];
    let mut count_black = vec![];
    for &c in s.iter() {
        let a = if c == '#' { 1 } else { 0 };
        if let Some(&last) = count_black.last() {
            count_black.push(last + a);
        } else {
            count_black.push(a);
        }
    }
    for &c in s.iter() {
        let a = if c == '.' { 1 } else { 0 };
        if let Some(&last) = count_white.last() {
            count_white.push(last + a);
        } else {
            count_white.push(a);
        }
    }
    let num_white = *count_white.last().unwrap();
    for e in count_white.iter_mut() {
        *e = num_white - *e;
    }

    let mut ans = n;
    for i in 0..=n {
        let mut temp = 0;
        if i > 0 {
            temp += count_black[i - 1];
        }
        if i < n {
            temp += count_white[i];
        }

        ans = std::cmp::min(ans, temp);
    }

    println!("{}", ans);
}


Measured memory_bytes: 6284
#include <stdio.h>
#include <stdlib.h>
#define ll long long
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
ll a[200010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%lld",a+i);
	sortup(a,n);
	for(int i=1;i<n;i++)if(a[i-1]==a[i]){
		puts("NO");
		return 0;
	}
	puts("YES");
}

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

int main()
{
    long long l,r,y,mod = 2019;
    long long x,mn = 2019;

    cin>>l>>r;

    if(r-l+1 >= 673){
        cout<<0<<endl;
        exit(0);
    }


    for(int i=l; i<r; i++){
        for(int j=i+1;j<=r;j++){
            x = ((i%mod)*(j%mod))%mod;
            mn = min(mn,x);
        }

    }

    cout<<mn<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,(n))
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	int x, y;
	cin >> x >> y;

	int ans = INT_MAX;
	if (x <= y) {
		ans = min(ans, y - x);
	}

	int mx = -1 * x;
	int my = -1 * y;
	if (mx <= y) {
		ans = min(ans, y - mx + 1);
	}
	if (x <= my) {
		ans = min(ans, my - x + 1);
	}
	if (mx <= my) {
		ans = min(ans, my - mx + 2);
	}

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

Measured memory_bytes: 256