akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
long long ans;
inline int dfs(int x,int y)
{
	ans++;int ul=x+y;
	if(ul>9)return dfs(1,ul%10);
	else return x+y;
}
inline int solve(int d,long long cnt)
{
	if(cnt==1)return d;
	int ul;ans+=cnt/2;
	if(d>=5)ans+=cnt/2,ul=solve(2*d-9,cnt/2);
	else ul=solve(2*d,cnt/2);
	if(cnt&1LL)ul=dfs(ul,d);
	return ul;
}
int main()
{
    //freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int m=read(),now=-1;
	for(int i=1;i<=m;i++)
	{
		int d;long long num;
		scanf("%d%lld",&d,&num);
		if(now==-1)now=solve(d,num);
		else now=dfs(now,solve(d,num));
	}printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int n1 = n / 2;
		int cnt = 0;

		if (n % 2 == 0) {
			cnt = n / 2 - 1;
		} else {
			cnt = n / 2;
		}
		System.out.println(cnt);
		
	}

}


Measured memory_bytes: 25172
#include<iostream>
#include<vector>
#include<iterator>
#include<algorithm>

using namespace std;

int main(void) {
    int n,m;
    cin >> n; // 人数
    cin >> m; // 食べ物の種類

    vector<int> count(m, 0);

    for(int i = 0 ; i < n ; ++i) {
        int k, a;
        cin >> k; // 好きな物の数
        for(int j = 0 ; j < k ; ++j) {
            cin >> a;
            count[a - 1]++; // 1 < Aij <= Mなので
        }
    }

    vector<int> dst;
    copy_if(count.begin(), count.end(), back_inserter(dst), [n](int x){ return x == n; });
    cout << dst.size() << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
using namespace std;
int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
struct axis { int x, y; };
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;  while (cin >> N && N != 0)
	{
		vector<axis> dat(N + 2);
		axis mx; mx.x = 0, mx.y = 0;
		axis mn; mn.x = 0, mn.y = 0;
		for(int i = 1; i < N; i++)
		{
			int pic = 0, dir = 0; cin >> pic >> dir;
			dat[i].x = dat[pic].x + dx[dir];
			dat[i].y = dat[pic].y + dy[dir];
			mx.x = max(mx.x, dat[i].x);
			mx.y = max(mx.y, dat[i].y);
			mn.x = min(mn.x, dat[i].x);
			mn.y = min(mn.y, dat[i].y);
		}
		printf("%d %d\n", abs(mx.x) + abs(mn.x) + 1, abs(mx.y) + abs(mn.y) + 1);
	}
}

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

/*Atcoder用
 * 		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		int a = Integer.parseInt(tmp[0]);
		int b = Integer.parseInt(tmp[1]);
		int c = Integer.parseInt(tmp[2]);


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String get = br.readLine();
		char[] s = get.toCharArray();
		for(char c:s)System.out.println(c);

		List<Integer> ls = new ArrayList<Integer>();
		String[] tmp = br.readLine().split(" ");
		for (int n = 0; n < N; n++) {
			ls.add(Integer.parseInt(tmp[n]));
		}
 */

public class Main {

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

		int[] ASCII = new int[26];

		for(int i = 0;i<26;i++){
			ASCII[i] = -1;
		}


		for(int i = 0;i<S.length();i++){
			int s = S.charAt(i);
			int r = T.charAt(i);

			if(ASCII[r-97] == -1){
				ASCII[r-97] = s;
			}else if(ASCII[r-97] != s){
				System.out.println("No");
				System.exit(0);
			}

		}

		for(int i = 0;i<26;i++){
			ASCII[i] = -1;
		}

		for(int j = 0;j<S.length();j++){
			int s = S.charAt(j);
			int r = T.charAt(j);

			if(ASCII[s-97] == -1){
				ASCII[s-97] = r;
			}else if(ASCII[s-97] != r){
				System.out.println("No");
				System.exit(0);
			}
		}
		System.out.println("Yes");
	}

}


Measured memory_bytes: 25540
#include<stdio.h>
int main(void){
  int n,a,i,j,b,aw,ans=10000;
  scanf("%d %d %d",&n,&a,&b);
  a = a*n;
  if(a>b){
      printf("%d\n",b);
  }
  else{
      printf("%d\n",a);
  }
  return 0;
}

Measured memory_bytes: 128
def hammingp(n):
    while n % 2==0:
        n /= 2
    while n % 3==0:
        n /= 3
    while n % 5==0:
        n /= 5
    return(n==1)

while True:
    s = list(map(int,input().strip().split()))
    if len(s)==1:
        break
    m,n = s

    c=0
    for i in range(m,n+1):
        if hammingp(i):
            c += 1
    print(c)



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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}


vector<vector<int>> G;
int dp[100001];

int rec(int v){
    if(dp[v] != -1) return dp[v];

    int res = 0;
    for(auto nxt : G[v]){
        res = max(res, rec(nxt)+1);
    }
    return dp[v] = res;
}


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    G.assign(n, vector<int>());
    rep(i, m){
        int x, y;
        cin >> x >> y;
        G[x-1].push_back(y-1);
    }

    fill_n(dp, 100001, -1);
    int ans = 0;
    rep(i, n){
        ans = max(ans, rec(i));
    }
    ppp(ans);

    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
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;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

struct Edge {
    ll to;
    ll cost;
    Edge(ll to, ll cost) : to(to), cost(cost) {}
};
using Graph = vector<vector<Edge>>;
using P = pair<long, int>;
vll dist;
vector<int> pre;

/* dijkstra(G,s,dis,prev)
    入力：グラフ G, 開始点 s, 距離を格納する dis, 最短経路の前の点を記録するprev
    計算量：O(|E|log|V|)
    副作用：dis, prevが書き換えられる
*/
void dijkstra(const Graph &G, int s, vector<long long> &dis, vector<int> &prev) {
    int N = G.size();
    dis.resize(N, INF);
    prev.resize(N, -1); // 初期化
    priority_queue<P, vector<P>, greater<P>> pq;
    dis[s] = 0;
    pq.emplace(dis[s], s);
    while (!pq.empty()) {
        P p = pq.top();
        pq.pop();
        int v = p.second;
        if (dis[v] < p.first) {
            continue;
        }
        for (auto &e : G[v]) {
            if (dis[e.to] > dis[v] + e.cost) {
                dis[e.to] = dis[v] + e.cost;
                prev[e.to] = v; // 頂点 v を通って e.to にたどり着いた
                pq.emplace(dis[e.to], e.to);
            }
        }
    }
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, M;
    cin >> N >> M;
    Graph g(N);
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g[a].emplace_back(b, 1);
        g[b].emplace_back(a, 1);
    }

    dijkstra(g, 0, dist, pre);

    rep(i, N) if(dist[i] >= INF) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    for(ll i = 1; i < N; i++) cout << pre[i] + 1 << endl;

}


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

int x[8];

int main()
{
    int n;
    cin >> n;
    int tourist = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if(a < 400) x[0]++;
        else if(a < 800) x[1]++;
        else if(a < 1200) x[2]++;
        else if(a < 1600) x[3]++;
        else if(a < 2000) x[4]++;
        else if(a < 2400) x[5]++;
        else if(a < 2800) x[6]++;
        else if(a < 3200) x[7]++;
        else tourist++;
    }
    int ans = 0;
    rep(i, 8) {
        if(x[i] != 0) ans++;
    }
    if(tourist == 0) cout << ans << " " << ans << endl;
    else {
        cout << max(ans, 1) << " " << ans + tourist << endl;
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> v(9);
  
  for (int i = 0; i < 9; i++) {
    v.at(i) = i + 1;
  }
  
  bool b = false;
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      if (v.at(i) * v.at(j) == n) {
        b = true;
      }
    }
  }
  
  if (b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
float c[8];j;f(i){return c[i+1]*(c[(i+2)%6]-c[6])+c[(i+3)%6]*(c[6]-c[i])+c[7]*(c[i]-c[(i+2)%6]);}main(){for(;~scanf("%f",c+j++);j%8||puts(f(j=0)*f(2)>0&&f(2)*f(4)>0?"YES":"NO"));}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <limits>
#include <unordered_map>

int factorise_count(int n)
{
	int count = 0;
	for (int i = 1; i <= n; i++)
	{
		if (n % i == 0) count++;
	}
	return count;
}

int main()
{
	int N;
	std::cin >> N;

	int ans = 0;
	for (int i = 105; i <= N; i+=2)
	{
		if (factorise_count(i) == 8) ans++;
	}

	std::cout << ans;

}

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

using namespace std;

class cMon {
public:
  long X;
  long H;
  void vset(long x, long h) {
    X=x; H=h;
  }
  void pr() {
    printf("X=%ld, H=%ld\n", X, H);
  }
};

long N,D,A;
vector<cMon> vm1, vm2;

bool cmp1(const cMon &a, const cMon &b) { return a.H > b.H; }
bool cmp2(const cMon &a, const cMon &b) { return a.X < b.X; }

int main()
{
  int i, j;
  cMon m;
  long right;
  long r=0;
  long b;
  long ret;

  cin >> N >> D >> A;

  vector<cMon> vm(N);
  vector<long> s(N+1);

  for(i=0; i<N; i++) {
    cin >> vm[i].X >> vm[i].H;
  }

  sort(vm.begin(), vm.end(), cmp2 );

  ret = 0;
  for (i=0; i<N; i++) {
//printf("vm[%d].H = %ld, s[%d] = %ld\n", i, vm[i].H, i, s[i]); fflush(stdout);
    vm[i].H -= s[i];
    right = vm[i].X+D*2;
    while (r<N&&vm[r].X<=right) r++;
//printf("r = %ld\n", r); fflush(stdout);
    if (vm[i].H>0) {
      b = (vm[i].H+A-1)/A;
      ret += b;
      s[i] += b*A;
      s[r] -= b*A;
    }
    s[i+1] += s[i];
  }
  printf("%ld\n", ret);
  return 0;
}



Measured memory_bytes: 4992
import java.util.*;

public class Main {
    public static void main(String[] args) {
        int input = 0;
        Scanner sc = new Scanner(System.in);
        input = sc.nextInt();
        if (input == 0)
            System.out.println(1);
        if (input == 1)
            System.out.println(0);
    }
}


Measured memory_bytes: 35756
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

int main() {
    int a, b;
    cin >> a >> b;

    if (a >= 13) {
        cout << b << endl;
    } else if (a >= 6) {
        cout << b / 2 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}



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

long long dp[3001][3001];
long long nCr[3001][3001];
long long x[3001];
int n; long long m;

long long gopp(long long x, long long y, long long z){
    long long ret = 1;
    long long gop = x % z;
    while(y){
        if(y & 1LL) ret = (ret * gop) % z;
        gop = (gop * gop) % z;
        y /= 2;
    }
    return ret;
}

int main(){
    scanf("%d%lld",&n,&m);
    dp[0][0] = 1;
    nCr[0][0] = 1;
    for(int i=1;i<=n;i++){
        dp[i][0] = 1;
        nCr[i][0] = 1;
        for(int j=1;j<=i;j++){
            dp[i][j] = (dp[i-1][j-1] + (dp[i-1][j] * (j+1))) % m;
            nCr[i][j] = (nCr[i-1][j-1] + nCr[i-1][j]) % m;
        }
    }
    long long ans = 0;
    for(int i=0;i<=n;i++){
        long long sum = 0;
        for(int j=0;j<=i;j++){
            long long cal = gopp(2LL, ((long long)j * (long long)(n - i)), m);
            dp[i][j] = (dp[i][j] * cal) % m;
            sum = (sum + dp[i][j]) % m;
        }
        long long cal2 = gopp(2LL, gopp(2LL, n-i, m-1), m);
        sum = (sum * cal2) % m;
        sum = (sum * nCr[n][i]) % m;
        if(i%2 == 1) sum = (m - sum) % m;
        ans = (ans + sum) % m;
    }
    printf("%lld\n", ans);
}


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

int main(){
    int m,f,r;
    do{
        cin >> m >> f >> r;
        if(m == -1 && f == -1)
        break;
        if ((m == -1 || f == -1) || m+f < 30){
            cout << "F"  << endl;
        }
        else if(m+f >= 30 && m+f < 50){
            if(r < 50){
                cout << "D" << endl;
            }else {
                cout << "C" << endl;
            }
        }
        if(m+f >= 50 && m+f < 65){
            cout << "C" << endl;
        }
        if( m+f >= 65 && m+f < 80){
            cout << "B" << endl;
        }
        if(m+f >= 80){
            cout << "A" << endl;
        }
    }while( m != -1 || f != -1);
}


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

int main() {
    int n; cin >> n;
    long long a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    long long sum = 0;
    long long res = 0, l = 0, r = 0;
    for (l = 0; l < n; l++)
    {
        while (r < n && (sum ^ a[r]) == (sum + a[r]))
        {
            sum += a[r];
            r++;
        }
        res += r - l;
        sum -= a[l];
        if(r == l) r++;
    }
    cout << res << endl;
    return 0;
}

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

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

#define Yes "Yes"
#define No "No"

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

    int n;
    cin >> n;

    int x = n;
    int ans = 0;
    while(x > 0){
        ans += x % 10;
        x /= 10;
    }

    if(n % ans == 0) p("Yes")
    else p("No");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <map>
#include<string>
#include <cmath>
using namespace std;
typedef long long ll;

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

  int Y = sqrt(X);
  bool odd = true, even = true;

  if(Y == 1) cout << X << endl;
  else{
    while(odd || even){
      odd = false;
      even = false;
      for(int i = 3; i <= Y; i += 2){
        if(X%i==0){
          odd = true;
          break;
        }
      }
      if(X%2==0) even = true;
      ++X;
    }
    --X;
    cout << X << endl;
  }


 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool up_min(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool up_max(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }

    ll operator"" _64(unsigned long long x){ return ll(x); }
    ull operator"" _64u(unsigned long long x){ return ull(x); }

    template<class T>
    vector<T> make_mdvector(int n, T t){
        return vector<T>(n, t);
    }
    template<class ...Ts>
    auto make_mdvector(int n, Ts ... ts){
        return vector<decltype(make_mdvector(ts...))>(n, make_mdvector(ts...));
    }

    inline ll bit(int x){
        return 1ll << x;
    }

    template<class T>
    istream& operator>>(istream& is, vector<T>& v){
        for (auto &&x : v) { is >> x; } return is;
    }

    template<class T>
    ostream& operator<<(ostream& os, const vector<T>& v){
        for (auto &&x : v) { os << x << ' '; } cout << endl; return os ;
    }
}
using namespace utils;

class solver{
    istream& is;
    ostream& os;

public:
    solver(istream& I, ostream& O) :is(I), os(O) {}
    ll N;
    void run();
};

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef XELMH
    string test_cases = "test_C.txt";
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int loop = 0;
    while(fs) {
        loop++;
        cout << '#' << loop << "#------\n";
        solver(fs, cout).run();
    }
    if(loop <= 1) {
        cout << "===" << endl;
        while(cin) solver(cin, cout).run();
    }
#else
    solver(cin, cout).run();
#endif
    return 0;
}


void solver::run(){
    is >> N;
    if(!is) return;
    vector<pair<int, int>> v(N);
    for (auto &&i : v) {
        int a, b;
        is >> a >> b;
        i = make_pair(a, b);
    } // end i
    double ave = 0;
    double mx = 1;
    while(N > 0) mx *= N--;
    sort(ALL(v));
    do{
        double t = 0;
        for (int i = 1; i < v.size(); ++i) {
            double a = v[i].first - v[i-1].first;
            double b = v[i].second - v[i-1].second;
            t += hypot(a, b);
        } // end i
        ave += t;
    }while(next_permutation(ALL(v)));
    os << ave / mx << endl;

}


Measured memory_bytes: 256
A, B, C, X, Y= map(int, input().split())

ans = 10 ** 15
for i in range(max(X, Y) * 2 + 1):
    N = C * i * 2 + max(0, X - i) * A + max(0, Y - i) * B
    ans = min(ans, N)
print(ans)  

Measured memory_bytes: 9052
// #include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
// #include <deque>
// #include <queue>
// #include <array>
// #include <ctime>
// #include <list>
#include <map>
#include <set>
// #include <cassert>
// #include <complex>
// #include <sstream>
// #include <forward_list>
// #include <unordered_set>
// #include <unordered_map>

using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define scani(n) scanf("%d",&n);
#define EPS 1e-9
#define FOR(i,n) for(int i=0; i<n; i++)
#define X first
#define Y second
#define arrinput for(int i=0; i<n; i++) cin>>arr[i];
#define arrsum for(int i=0; i<n; i++) sum+=arr[i];
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,n) for(int i=n-1; i>=0; i--)
#define sz(a) (int)(a.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

const int MOD = 1e9+7;
const int n_ = 1e5+1000;
const long double PI = acos(-1.0);

ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}

bool vowel(char ch) {
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') return true;
    else return false;
}

// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
class UnionFind {                                              // OOP style
private:
    vi p, rank, setSize;                       // remember: vi is vector<int>
    int numSets;
public:
    UnionFind(int N) {
        setSize.assign(N, 1); numSets = N; rank.assign(N, 0);
        p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; }
    int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
    bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
    void unionSet(int i, int j) { 
        if (!isSameSet(i, j)) { numSets--; 
        int x = findSet(i), y = findSet(j);
        // rank is used to keep the tree short
        if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
        else                   { p[x] = y; setSize[y] += setSize[x];
                                 if (rank[x] == rank[y]) rank[y]++; } } }
    int numDisjointSets() { return numSets; }
    int sizeOfSet(int i) { return setSize[findSet(i)]; }
};

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, t;
    cin>>n>>t;
    int arr[n];
    arrinput;
    int ans = t;
    for0(i,n-1) {
        ans += min(t, arr[i+1]-arr[i]);
    }
    cout<<ans;

    return 0;
}      

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#define ll long long int
#define MOD 1000000007
using namespace std;

int main() {
	int a,b;
	cin>>a>>b;
	if(a>b) cout <<"safe"<<endl;
	else cout <<"unsafe"<<endl;

	return 0;
}


Measured memory_bytes: 3588
<?php

$s = trim(fgets(STDIN));

if ($s[0]>$s[1] || ($s[0]==$s[1] && $s[0]>=$s[2])){
  echo $s[0].$s[0].$s[0];
} else {
  $ss = $s[0]+1;
  echo $ss.$ss.$ss;
}
  
?>

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  int n,l;cin >> n >> l;
  int r = n+l-1;
  int a;
  if(r<=0) a=r;
  else if(l>=0) a=l;
  else a = 0;
  cout << (n*(r+l))/2 - a << endl;
}


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

struct Stock {
  ll price;
  ll num_bottles;
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  ll n, m;
  cin >> n >> m;
  vector<Stock> stock(n);
  rep(i, n) {
    cin >> stock[i].price;
    cin >> stock[i].num_bottles;
  }
  sort(stock.begin(), stock.end(),
       [](const Stock& a, const Stock& b) {
         return a.price < b.price;
       });
  ll ans = 0;
  rep(i, n) {
    ll num = min(stock[i].num_bottles, m);
    ans += stock[i].price * num;
    m -= num;
    if (m <= 0) break;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
	 char ch;
    int a[26] = {0};
    while ( cin >> ch ){
        if ( ch >='A' && ch <='Z' ) {
            ch-='A'-'a';
        }
        if ( ch >='a' && ch <='z' ) {
            a[ch-'a']++;
        }
    }
    for ( int i = 0 ;i<26 ;i++ ) {
        ch = 'a'+i;
        cout << ch << " : " << a[i] << endl;
    }
	return 0;
}



Measured memory_bytes: 3100
#include<stdio.h>
int main()
{
    int a,b,c,d,i;
    while(scanf("%d %d %d %d",&a,&b,&c,&d)!=EOF)
    {
        for(i=1;i>0;i++)
        {
            if(i%2!=0)
            {
                c=c-b;
                if(c<=0)
                {
                    printf("Yes\n");
                    i=-1;
                }
            }
            else
            {
                a=a-d;
                if(a<=0)
                {
                    printf("No\n");
                    i=-1;
                }
            }
        }
    }
    return 0;
}


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

using namespace std;
const ll INF = 1LL << 60;


ll N,minutes = 0;
ll M[5];
ll Min = INF;

int main(){
  cin >> N;
  rep(i,5){
    cin >> M[i];
    if(Min > M[i]) Min = M[i];
  }
  minutes += ((N/Min)+4);
  if(N%Min != 0) minutes++;
  cout <<  minutes << endl;
  return 0;

}


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

int abs(int value) {
  if (value < 0) {
    return -value;
  }
  return value;
}

int main() {
  int n, x, y, i, j, target, dist, count;
  assert(scanf("%d %d %d", &n, &x, &y) == 3);
  x -= 1;
  y -= 1;
  for (i = 1; i < n; i++) {
    count = 0;
    for (j = 0; j < n - i; j++) {
      target = j + i;
      dist = abs(x - j);
      if (dist >= i) {
        count++;
      } else {
        if (target < y && dist + 1 + y - target >= i) {
          count++;
        }

        if (i - dist == 1) {
          count++;
        } else {
          target = y - (i - dist - 1);

          if (target - j > i) {
            count++;
          }

          target = y + (i - dist - 1);

          if (target < n) {
            count++;
          }
        }
      }
    }
    printf("%d\n", count);
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

int main()
{
    ll K;
    cin >> K;

    string S;
    cin >> S;

    if (S.size() <= K)
    {
        cout << S << endl;
    }
    else
    {
        cout << S.substr(0, K) << "..." << endl;
    }

    return 0;
}


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

#define int long long

int get(int one, int two, int three){
    return max(one, max(two, three)) - min(one, min(two, three));
}

int answer(int h, int w){
    int ans = LLONG_MAX;
    for(int i = 0;i < h;i++){
        int one = i*w;
        int two = (h-i)/2*w;
        int three = (h-i+1)/2*w;
        ans = min(ans, get(one, two, three));

        two = (w)/2 * (h-i);
        three = (w+1)/2 * (h-i);
        ans = min(ans, get(one, two, three));
    }

    return ans;
}

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

    cout << min(answer(h, w), answer(w, h)) << endl;

    return 0;
}

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

string s[100010];
map<string,long long int>mp;
map<string,long long int>:: iterator it;

int main()
{

    string x,y;
    long long int n,i,c=0,d,j,k;

    cin>>n;
    for(i=1; i<=n; i++)
    {
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
        mp[s[i]]++;

    }

    for(it=mp.begin(); it!=mp.end(); it++)
    {
        d=it->second;
        d--;
        k=(d*(d+1))/2;
        c+=k;
    }
    cout<<c<<endl;


    return 0;
}


Measured memory_bytes: 18176
sa = list(input())
sb = list(input())
sc = list(input())

next = sa[0]
del sa[0]
while len(sa) >= 0 and len(sb) >= 0 and len(sc) >= 0:
    if next == "a":
        if len(sa) == 0:
            print("A")
            break
        next = sa[0]
        del sa[0]
    elif next == "b":
        if len(sb) == 0:
            print("B")
            break
        next = sb[0]
        del sb[0]
    elif next == "c":
        if len(sc) == 0:
            print("C")
            break
        next = sc[0]
        del sc[0]

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <climits>
#include <string>
using namespace std;

unsigned long long to(string w , int base){
	unsigned long long ans = 0;
	for(int i = 0 ; i < w.size() ; i++) ans = ans * base + (w[i] >= 'A' ? w[i] - 'A' + 10 : w[i] - '0');
	return ans;
}

map<int,int> factor(int n){
	map<int,int> w;
	for(int i = 2 ; i*i<=n ; i++)
		while(n%i==0) w[i]++ , n /= i;
	if(n!=1) w[n]++;
	return w;
}

int main(){
	int n;
	string m;
	while(cin >> n >> m, n){
		unsigned long long v = to(m,n) , ans = -1;
		map<int,int> r = factor(n);
		for( map<int,int>::iterator it = r.begin() ; it != r.end() ; ++it){
			int a = it->first;
			int d = it->second;
			unsigned long long t = v;
			unsigned long long ok = 0;
			while(t){ ok += (t / a) ; t /= a;}
			ans = min(ok / d , ans);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 936
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

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


const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

ll memo[201000];
int N;
int c[201000];
int nex[201000];
int las[201000];


ll func(int x){
    if(memo[x] != -1){
        return memo[x];
    }

    //塗る場合
    ll res1 = 0;
    if(nex[x] > x+1) {
        res1 = func(nex[x]);
    }
    //塗らない
    ll res2 = func(x+1);

    ll res = add(res1, res2);
    memo[x] = res;
    return res;
}



int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> c[i];
        c[i]--;
    }

    fill(nex, nex+201000, -1);
    fill(las, las+201000, N);
    for(int i = N-1; i >= 0; i--){
        nex[i] = las[c[i]];
        las[c[i]] = i;
    }
    fill(memo, memo+201000, -1);
    memo[N] = 0;
    memo[N-1] = 1;

    cout << func(0) << endl;


    return 0;
}


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

int main() {
    int N, j;

    cin >> N;

    for (int i = 1; i <= N; i++) {
      j = i;
      if (j%3 == 0) cout << " " << i;

      else {
        while (j) {
          if (j%10 == 3) {
            cout << " " << i;
            break;
          }

          j /= 10;
        }
      }
    }
    cout << endl;

    return 0;
}



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

int main() {
  int a,b,d=0;
  cin>>a>>b;
  vector<int> c(a);
  for(int i=0;i<a;i++){
    cin>>c.at(i);
  }
  sort(c.begin(),c.end());
  for(int i=0;i<b;i++){
    d+=c.at(i);
  }
  cout<<d<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+1;
const int mod = 1e9+7;
int main() {
	int x;
	sd(x);
	int ans=x/500;ans*=1000;
	x%=500;x-=(x%5);
	pd(ans+x);
	return 0;
}

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

using namespace std;

int main()
{
  string s;
  cin >> s;
  int month = atoi(s.substr(5,2).c_str());
  int day = atoi(s.substr(8,2).c_str());
  
  if(month <= 4)
    cout << "Heisei" << endl;
  else
    cout << "TBD" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 1;
//-----------------------------------------------//

int N, K;
int sum[2][2001][2001];

int func(int y2, int x2, int y1, int x1, int col) {
	chmin(x2, 2*K-1); chmin(y2, 2*K-1);
	chmax(x1, 0); chmax(y1, 0);
	if (x1 > x2 || y1 > y2) return 0;
	return sum[col][y2+1][x2+1] - sum[col][y1][x2+1] - sum[col][y2+1][x1] + sum[col][y1][x1];
}

int solve(int col) {
	int res = 0;
	REP(y, K) {
		REP(x, K) {
			int cur = func(2*K-1, 2*K-1, 0, 0, col^1);
			REP(k, 2) {
				int s = 0;
				s += func(y+K-1, x+K-1, y, x, k^col);
				s += func(y+2*K-1, x+2*K-1, y+K, x+K, k^col);
				s += func(y+2*K-1, x-1, y+K, x-K, k^col);
				s += func(y-1, x-1, y-K, x-K, k^col);
				s += func(y-1, x+2*K-1, y-K, x+K, k^col);
				if (k) s = -s;
				cur += s;
			}
			chmax(res, cur);
		}
	}
	return res;
}

int main() {
	cin >> N >> K;
	REP(i, N) {
		int x, y;
		char c;
		scanf("%d %d %c", &x, &y, &c);
		x %= 2*K;
		y %= 2*K;
		sum[c=='W'][y + 1][x + 1]++;
	}
	
	REP(k, 2) {
		REP(i, 2*K+1) REP(j, 2*K) sum[k][i][j + 1] += sum[k][i][j];
		REP(j, 2*K+1) REP(i, 2*K) sum[k][i + 1][j] += sum[k][i][j];
	}
	
	int ans = max(solve(0), solve(1));

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


Measured memory_bytes: 31488
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
#define dbg(x) cout<<#x<<" = "<<x<<endl
const int INF = 0x3f3f3f3f;
const int maxn = 1e5+5;
char str[maxn];
int a[maxn];
int b[maxn];
int main()
{
    scanf("%s",str);
    int len=strlen(str);
    for(int i=0;i<len;i++) b[i]=str[i]-'a';
    for(int i=0;i<26;i++)
    {
        for(int j=0;j<len;j++)
        {
            if(b[j]==i) a[j]=1;
            else a[j]=-1;
        }
        int st,en,pos=0;
        int maxx=-100005;
        int sum=0;
        for(int j=0;j<len;j++)
        {
            sum+=a[j];
            if(sum>maxx)
            {
                maxx=sum;
                st=pos;
                en=j;
            }
            else if(sum==maxx)
            {
                if(j-pos+1>en-st)
                {
                    maxx=sum;
                    st=pos;
                    en=j;
                }
            }
            if(sum<0)
            {
                pos=j+1;
                sum=0;
            }
        }
        if(en-st+1>=2&&maxx>0)
        {
            printf("%d %d\n",st+1,en+1);
            return 0;
        }
//        dbg(maxx);
//        cout<<en<<" "<<st<<endl;
    }
    printf("-1 -1\n");

    return 0;
}


Measured memory_bytes: 1152
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
flug = False
kaizen=0

for i in range(1,N):
    if A[i-1]>A[i]:
        kaizen=i
        flug=True
        break
    
if flug==False:
    print(0)
    exit()

keisu=0
keisuichi=0
for i in range(N):
    if abs(A[i])>abs(keisu):
        keisu=A[i]
        keisuichi=i
if keisu>0:
    Ansx=[]
    Ansy=[]
    for i in range(N):
        Ansx.append(keisuichi)
        Ansy.append(i)
        Ansx.append(keisuichi)
        Ansy.append(i)
        A[i]=A[i]+A[keisuichi]*2
        keisuichi=i
        
        
    print(len(Ansx))
    for i in range(len(Ansx)):
        print(Ansx[i]+1,Ansy[i]+1)
    
else:
    Ansx=[]
    Ansy=[]
    for i in range(N):
        Ansx.append(keisuichi)
        Ansy.append(N-i)
        Ansx.append(keisuichi)
        Ansy.append(N-i)
        A[N-i-1]=A[N-i-1]+A[keisuichi]*2
        keisuichi=N-i-1
        
        
    print(len(Ansx))
    for i in range(len(Ansx)):
        print(Ansx[i]+1,Ansy[i])
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)

int main() {
	int N; char S[51]; cin >> N >> S;
	int ans = 0;
	for (int i = 0; i < strlen(S)-2; i++) {
		if (memcmp(&S[i], "ABC", 3) == 0) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long int i64;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string>) {}
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl; err(++it, args...); }
template<typename T1,typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& buf) {
  return os << "(" << buf.first << ": " << buf.second << ")"; }
#define DefOut(Con) template<typename T>ostream&operator<<(ostream&os,Con<T>&A){ bool f = false; os << "{"; \
  for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
#define DefOut2(Con) template<typename K,typename V>ostream&operator<<(ostream&os,Con<K,V>&A) \
{ bool f = false; os << "{"; for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
template<typename T>ostream &operator << (ostream &os,vector<vector<T>>& A) {
  for (auto &B: A) os << '\n' << B; return os; }
DefOut(vector) DefOut(set) DefOut(multiset) DefOut2(map) 
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1000000007;
long long const INF = 1e18;
#define PI 3.14159265358979323846
/***********************************************************************/
#define int i64
int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  int ans = 0;
  for (auto &z: a) cin >> z;
  for (int i = 0; i <= k && i <= n; ++i) {
    for (int j = 0; j <= k && j <= n; ++j) {
      if (i + j > k) continue;
      int rem = k - i - j;
      int sum = 0;
      vector<int> neg;
      for (int p = 0; p < i; ++p) {
        sum += a[p];
        if (a[p] < 0) neg.push_back(a[p]);
      }
      for (int p = 0; p < j; ++p) {
        if (n - p - 1 < i) break;
        sum += a[n - p - 1];
        if (a[n - p - 1] < 0) neg.push_back(a[n - p - 1]);
      }
      sort(ALL(neg));
      for (int p = 0; p < rem && p < SZ(neg); ++p) {
        sum -= neg[p];
      }
      if (sum > 0) error(sum, i, j);
      uax(ans, sum);
    }
  }
  cout << ans << '\n';
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int c,i;

int lefttime(int x);

int main(){
    int N,M; //飯盛山行きのバスはＮ本　鶴ヶ城行きのバスはＭ本
    
    int h[101],m[101]; //飯盛山行きｈ時ｍ分発
    int k[101],g[101]; //鶴ヶ城行きｋ時ｇ分発
    
    for(c=0;c<101;c++){ //エラー防止のために中身を最大値に
        h[c]=24;
        m[c]=60;
        k[c]=24;
        g[c]=60;
    }
    
    scanf("%d",&N);
    
    for(c=0;c<N;c++){ //時刻読み込み
        h[c]=lefttime(c);
        m[c]=lefttime(c);
    }
    
    scanf("%d",&M);
    
    for(c=0;c<M;c++){ //時刻読み込み
        k[c]=lefttime(c);
        g[c]=lefttime(c);
    }
    
    int hk[201],mg[201]; //二つのバスの時刻表を一つにしたもの
    
    for(c=0;c<201;c++){
        hk[c]=24;
        mg[c]=60;
    }
    
    int flag_h=0,flag_k=0;
    c=0;
   while(1){ //時刻比較
       if(flag_h==N&&flag_k==M)break;

        if(h[flag_h]<k[flag_k]){
            hk[c]=h[flag_h];
            mg[c]=m[flag_h];
            flag_h++;
            c++;
        }
        else if(h[flag_h]==k[flag_k]){
            if(m[flag_h]<g[flag_k]){
                hk[c]=h[flag_h];
                mg[c]=m[flag_h];
                flag_h++;c++;
            }
            else if(m[flag_h]==g[flag_k]){
                hk[c]=h[flag_h];
                mg[c]=m[flag_h];
                flag_h++;flag_k++;c++;
            }
            else{
                hk[c]=k[flag_k];
                mg[c]=g[flag_k];
                flag_k++;c++;
            }
        }
        else{
            hk[c]=k[flag_k];
            mg[c]=g[flag_k];
            flag_k++;c++;
        }
    }
    
    for(c=0;c<N+M;c++){
        if(hk[c]!=24){
  
            printf("%d:%02d",hk[c],mg[c]);
            
            if(c!=N+M-1 && hk[c+1]!=24){printf(" ");}
        }
    }
    printf("\n");
    
    return 0;
}

int lefttime(int x){
    int a[100]={0};
    scanf("%d",&a[x]);
    
    return a[x];
}


    
    
    
    

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll L, D, d;

    cin >> L >> D >> d;

    ll count = 0;
    for( int i = L ; i < D+1; i++ ){
            if( i % d == 0 ) count++;

    }
    cout << count << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(3 * n);
    rep(i, 3 * n) cin >> a[i];
    sort(all(a));
    ll ans = 0;
    
    rep(i, n) {
        ans += a[n + i * 2];
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <math.h> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;

    string res = "No";

    REP(i,s.size())
    {
        if(s[i] == '9')res = "Yes";
    }

    cout << res << endl;
    return 0;    
}



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

#define INF 1000000

int n;
int cost[110][110], d[110];
bool used[110];

void dijkstra(int s){

  //initialization
  for(int i = 0;i < n;i++) d[i] = INF;
  for(int i = 0;i < n;i++) used[i] = false;

  //distance of starting position is 0
  d[s] = 0;
  
  while(true){
    int v = -1;
    
    for(int u = 0;u < n;u++){
      if(!used[u] && (v == -1 || d[u] < d[v])) v = u;
    }
    
    if(v == -1) break; //finish
    used[v] = true; //use v

    //update distance
    for(int u = 0;u < n;u++){
      d[u] = min(d[u], d[v] + cost[v][u]);
    }
  }
}

int main(){
  
  int u, k, v, c;

  //input and initialization
  cin >> n;
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      cost[i][j] = INF;
    }
  }
  for(int i = 0;i < n;i++){
    cin >> u >> k;
    for(int j = 0;j < k;j++){
      cin >> v >> c;
      cost[u][v] = min(cost[u][v], c);
    }
  }
  
  dijkstra(0);

  //output
  for(int i = 0;i < n;i++) cout << i << " " << d[i] << endl;
  
  return 0;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[3001][3001];
ll arr[3001];ll n;ll m;
ll solve(ll i,ll j)
{
	if(i>j)return 0;
	if(dp[i][j]!=-1)return dp[i][j];
	ll p=(j-i+1);p%=2;
	if(p==m)
	{
		dp[i][j]=max(solve(i+1,j)+arr[i],solve(i,j-1)+arr[j]);
	}
	else
	dp[i][j]=min(solve(i+1,j)-arr[i],solve(i,j-1)-arr[j]);
	return dp[i][j];
}
int main() {
	cin>>n;
	for(int i=0;i<n;i++)cin>>arr[i];
	for(int i=0;i<3001;i++)
	for(int j=0;j<3001;j++)
	dp[i][j]=-1;
	m=n%2;
	cout<<solve(0,n-1);
}	

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

int power(int x, int y, int p)
{
    int res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}


int32_t main(){
	int n;
	string s;
	cin>>n>>s;
	int x = 0, ans = 0;
	for(int i=0; i<n; i++){
		if(s[i]=='I')++x;
		if(s[i]=='D')--x;
		ans = max(ans, x);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256