akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s,t;
    cin >> s >> t;
    if(s == t.substr(0, t.length()-1)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> a(n, vector<int>(m));
	vector<int> b(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		int res = 0;
		for (int j = 0; j < m; j++) {
			res += a[i][j] * b[j];
		}
		cout << res << endl;
	}
	return 0;
}

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

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define rep1(a, b, c)  for(int a = (b); a < (c); ++a)
#define each(a, b)     for(auto& a : b)

#define sz(x)       (int)(x).size()
#define all(a)      (a).begin(),(a).end()

#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define dbg(x) cout << #x << " = " << x << endl;
#define vt vector
#define pii pair<int, int>
#define pll pair<ll, ll>
#define bitcnt(x) __builtin_popcount(x)

using ll = long long;

const int inf = (int)1e9 + 5;
const ll infl = (ll)1e18 + 5;
const int mod = 1e9 + 7;

void solve(){
	int n;
	cin >> n;
	string s = "ACL";
	rep(i, n) cout << s;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}

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

vector<int> v;
string x;
int k, temp;

int main() {
    while (cin >> x) {
        k = v.size();
        if (x=="+") {
            temp = v[k-1] + v[k-2];
            v.pop_back(); v.pop_back();
            v.push_back(temp);
        }
        else {if (x=="-") {
            temp = v[k-2] - v[k-1];
            v.pop_back(); v.pop_back();
            v.push_back(temp);
        }
        else {if (x=="*") {
            temp = v[k-1] * v[k-2];
            v.pop_back(); v.pop_back();
            v.push_back(temp);
        }
            else v.push_back(stoi(x));
        }}
    }
    cout << v[0] << endl;
}


Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;

using namespace std;
struct A
{
    int l;
    int r;
    int q;
};
struct B
{
    int a;
    int b;
    int num;
};
B bb[300005];
A aa[300005];
int a[100005], b[100005];
int f[100005];
int finds(int x)
{
    return f[x] == x?x:f[x] = finds(f[x]);
}
int cmp1(B a, B b)
{
    return a.a < b.a;
}
int cmp2(B a, B b)
{
    return a.b < b.b;
}
int cmp3(A a, A b)
{
    return a.q < b.q;
}
int main()
{
    int n;
    scanf("%d", &n);
    FOR(i,1,n)
    {
        scanf("%d%d", &bb[i].a, &bb[i].b);
        bb[i].num = i;
    }
    int ji = 0;
    sort(bb+1, bb+1+n, cmp1);
    for(int i = 1; i < n; i++)
    {
        aa[ji].l = bb[i].num;
        aa[ji].r = bb[i+1].num;
        aa[ji++].q = min(abs(bb[i].a-bb[i+1].a), abs(bb[i].b-bb[i+1].b));
    }
    sort(bb+1, bb+1+n, cmp2);
    for(int i = 1; i < n; i++)
    {
        aa[ji].l = bb[i].num;
        aa[ji].r = bb[i+1].num;
        aa[ji++].q = min(abs(bb[i].a-bb[i+1].a), abs(bb[i].b-bb[i+1].b));
    }
    sort(aa, aa+ji, cmp3);
    FOR(i,1,n)
    f[i] = i;
    ll ans = 0;
    for(int i = 0; i < ji; i++)
    {
        int x = finds(aa[i].l);
        int y = finds(aa[i].r);
        if(x != y)
        {
            f[x] = y;
            ans += aa[i].q;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 5632
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
A = []
for _ in range(N):
    A.append(list(input()))
    
B = []
for _ in range(M):
    B.append(list(input()))

for dh in range(0,N-M+1):
    for dw in range(0,N-M+1):
        ans = True
        for bh in range(0,M):
            for bw in range(0,M):
                if B[bh][bw] != A[bh+dh][bw+dw]:
                    ans = False
        if ans:
            print("Yes")
            break
    else:
      continue
    break
if ans == False:
    print("No")

Measured memory_bytes: 3064
import java.util.*;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		start = new int[totalVertex];
		t = 1;
		visit = new boolean[totalVertex];
		finish = new int[totalVertex];
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	
	private int[] start = new int[totalVertex];
	private int t;
	private boolean[] visit = new boolean[totalVertex];
	private int[] finish = new int[totalVertex];
	
	public void DFS(int i) {
	    start[i] = t++;
	    visit[i] = true;
	    for (int j = 0; j < adjList.get(i).size();j++) {
	        int v = adjList.get(i).get(j);
	        if (visit[v] == false) {
	            DFS(v);
	        }//if
	      }//for
	    finish[i] = t++;

	}//DFS
	
	public void print() {
		for (int i = 0; i < totalVertex;i++) {
			//if it has not been visited dfs
            if(visit[i] == false) {
            	DFS(i);
            }//if
        }//FOR 
        for (int i = 1; i <= totalVertex;i++) {
        	System.out.println(i + " " + start[i-1] + " " + finish[i-1]);
        }//FOR
	}//print
}//graph


public class Main {
	
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.print();
	}//main

}//class



Measured memory_bytes: 28676
def InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = int(A[i])
    return A
    
if __name__ == '__main__':
    N = int(input())
    H = InputToInt()
    M = 0
    c = 0
    for i in range(1, N):
        if H[i] <= H[i-1]:
            c += 1
        else:
            M = max(c, M)
            c = 0
    print(max(c, M))


Measured memory_bytes: 11132
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long lli;

int main(void) {
  long long int a;
  double b;
  scanf("%lld %lf", &a, &b);

  long long sum = (a * (int)(b * 100 + 0.5)) / 100; 
  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 1724
# Bellman-Ford
n, m = map(int, raw_input().split())
a, b, c = [], [], []
for i in xrange(m):
    at, bt, ct = map(int, raw_input().split())
    a.append(at - 1)
    b.append(bt - 1)
    c.append(ct)
# step1 : initialize
point = [-1e9 * m - 1] * n
point[0] = 0
# step2 : relaxation
for i in xrange(n+1):
    for j in xrange(m):
        if point[b[j]] < point[a[j]] + c[j]:
            point[b[j]] = point[a[j]] + c[j]
# step3 : check
looped = [False] * n
for i in xrange(n):
    for j in xrange(m):
        if point[b[j]] < point[a[j]] + c[j]:
            looped[b[j]] = True
        if looped[a[j]] == True:
            looped[b[j]] = True
if looped[n-1]:
    print("inf")
else:
    print(point[n-1])

    


Measured memory_bytes: 2948
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		while (h!=0||w!=0){
			StringBuilder sb1=new StringBuilder("");
			for(int n=0;n<h;n++){
				for(int m=0;m<w;m++){sb1.append("#");}
				sb1.append("\n");
			}
			System.out.println(sb1);
			h=sc.nextInt();
			w=sc.nextInt();
		}
	}
}

Measured memory_bytes: 20844
n,m,l=map(int,input().split())
a=list()
b=list()
for i in range(n):
    x=list(map(int,input().split()))
    a.append(x)
for i in range(m):
    y=list(map(int,input().split()))
    b.append(y)
for i in range(n):
    line=list()
    for j in range(l):
        sum=0
        for k in range(m):
            sum+=a[i][k]*b[k][j]
        line.append(sum)
    print(" ".join(list(map(str,line))))



Measured memory_bytes: 6252
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

int main() {
	int a, b; cin >> a >> b;
	puts(a <= 8 && b <= 8 ? "Yay!" : ":(");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  vector<int> a(5);
  int k;
  rep(i, 5) cin >> a[i];
  cin >> k;

  if (a[4] - a[0] > k) {
    cout << ":(" << endl;
  } else {
  cout << "Yay!" << endl;
  }
}


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

int main() {
	int a,b,k;
	cin>>k;
	cin>>a>>b;
	int d = a % k;
	if(d == 0) cout<<"OK"<<endl;
	else{
		d = a + (k - (a % k));
		if(d <= b) cout<<"OK"<<endl;
		else cout<<"NG"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    vector<vector<bool>> card(4,vector<bool>(14));

    for(int i = 0; i < card.size(); i++){
        for(int j = 0; j < card[i].size(); j++){
            card[i][j] = true;
        }
    }

    for(int i = 0; i < 4; i++){
        card[i][0] = false;
    }

    rep(i,n){
        string s;
        int a;
        cin >> s >> a;

        if(s == "S"){
            card[0][a] = false;
        }
        if(s == "H"){
            card[1][a] = false;
        }
        if(s == "C"){
            card[2][a] = false;
        }
        if(s == "D"){
            card[3][a] = false;
        }

    }

    for(int i =0; i < 4; i++){
        for(int j = 0; j < 14; j++){
            if(card[i][j]){
                if(i == 0){
                    cout << "S " << j << endl;
                }
                if(i == 1){
                    cout << "H " << j << endl;
                }
                if(i == 2){ 
                    cout << "C " << j << endl;

                }
                if(i == 3){
                    cout << "D " << j << endl;
                }
            }
        }
    }



}


Measured memory_bytes: 3128
N = int(input())
G1 = [int(i) for i in input().split()] 
G2 = [int(i) for i in input().split()] 
one = [0 for i in range(N)]
two = [0 for i in range(N)]
i = j = 0

for i in range(N):
    for j in range(0,i+1):
        one[i] = one[i] + G1[j]
    for k in range(i,N):
        two[i] = two[i] + G2[k]

sum = 0
for i in range(N):
    if sum < one[i] + two[i]:
        sum = one[i] + two[i]

print(sum)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        int x,h,m,s;
        Scanner sc = new Scanner(System.in);
        x=sc.nextInt();
        h=x/3600;
        m=(x-3600*h)/60;
        s=x-3600*h-60*m;
        System.out.printf("%d:%d:%d%n",h,m,s);
    }
}

Measured memory_bytes: 26352
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <queue>
#include <iostream>
#include <cmath>

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
typedef long long ll;
using namespace std;


void solve(std::string S, std::string T){
    int cnt = 0;
    REP(i , S.size())  {
        if (S[i] == T[i]) { 

        } else { 
            cnt++;
        }
    }

    cout << cnt << endl;
    return;
}

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


Measured memory_bytes: 4028
#include <stdio.h>
#include <iostream>
using namespace std;

int main()
{
	int M, D;
	cin >> M >> D;
	int d;
	int s = 0;
	for (d = 22; d <= D; d++)
	{
		if (d % 10 < 2)
			continue;
		int dd = d % 10 * (d / 10);
		if (dd > 0 & dd <= M)
		{
			s++;
		}
	}
	cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

// 20
public class Main {
    static int getMorePrime(int n) {
        if(n == 2) return n;

        ArrayList<Integer> primes = new ArrayList<Integer>();
        primes.add(2);
        int i = 2;
        while(true) {
            for(int j = 0 ; j < primes.size(); j++)
                if(i % primes.get(j) == 0) {
                    ++i;
                    j = 0;
                }
            if(i >= n) return i;
            primes.add(i);
            ++i;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        System.out.println(getMorePrime(n));
    }

}


Measured memory_bytes: 36576
import collections
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def naive(s):
	cnt = 0
	for i in range(len(s)):
		for j in range(i + 1, len(s) + 1):
			k = int(s[i:j])
			if k % 2019 == 0 and k != 0:
				#print(i, j)
				cnt += 1
	return cnt

def main(s):
	nums = [0]
	cur = 0
	p = 0.1
	for i in range(len(s)):
		p = int(p * 10) % 2019
		cur = (cur + int(s[len(s) - 1 - i]) * p) % 2019
		nums.append(cur)
	d = dict(collections.Counter(nums))
	a = [val for key, val in d.items() if val >= 2]
	return sum([comb(x, 2) for x in a])	

s = input()
print(main(s))

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

int main(){
	long n;cin >> n;
  	vector<long> a(n);
  	long ans=1;
  	for(int i=0;i<n;i++){
    	cin >> a[i];
    }
  	long mi=a[0];
	for(int i=1;i<n;i++){
    	if(a[i]<=mi)ans++;
      	mi=min(mi,a[i]);
    }
  	cout << ans;
  	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    if (a==5&&b==5&&c==7){
      System.out.println("YES");
    }
    else if (a==5&&b==7&&c==5){
      System.out.println("YES");
    }
    else if (a==7&&b==5&&c==5){
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

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

using namespace std;

int main() {
  string s;
  long long k;
  cin >> s >> k;
  for (char e : s) {
    --k;
    if (k == 0 || e != '1') {
      cout << e << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1e9 + 10;//10^9
ll MOD  = 1000000007;
int dy[] = {0,0,1,-1};
int dx[] = {1,-1,0,0};

int main(void){
    int N;
    cin >> N;
    vector<tuple<string, int, int>> SP(N);
    for(int i = 0; i < N; i++){
        string s;
        int p;
        cin >> s >> p;
        get<0>(SP[i]) = s;
        get<1>(SP[i]) = -p;
        get<2>(SP[i]) = i + 1;
    }
    sort(SP.begin(), SP.end());
    for(int i = 0; i < N; i++){
        cout << get<2>(SP[i]) << endl;
    }
    
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#define nmax_def 110000
using namespace std;
typedef long long ll;

int main() {
	int i, j;
	ll ans = 0;
	ll anstmp = 0;
	string S;
	int N;
	bool loop_skip = false;
	cin >> S;
	N = S.length();
	for (i = 0; i < N; i++)
	{
		if (!loop_skip)
		{
			if (S[i] == 'A')
				anstmp++;
			else if (i < N - 1 && S[i] == 'B' && S[i + 1] == 'C')
			{
				ans += anstmp;
				loop_skip = true;
			}
			else
				anstmp = 0;
		}
		else
			loop_skip = false;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
const int INF = 1e18, MOD = 1e9 + 7;
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
signed main() {
    INCANT;
    int n, res = 1;
    string s;
    cin>>n>>s;
    rep(i, n - 1){
        if(s[i + 1] != s[i]) res++;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include<algorithm>
#include<limits.h>
using namespace std;
int main(void){
    int n;
    scanf("%d",&n);
    int R[n];
    for(int i = 0;i < n;i++) scanf("%d",&R[i]);
    int maxv = INT_MIN,minv =INT_MAX;
    for(int i = 0;i < n;i++){
        maxv = max(maxv,R[i]-minv);
        minv = min(minv,R[i]);
    }
    printf("%d\n",maxv);
    
}



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

int modinv(long long a, long long m = 1000000007){
    for(long long i=0;i<m;i++){
        if( ((i*m+1)%a) == 0 ){
            return i;
        }
    }
    return -1;
}

int main(){
    long long n,a[200010];
    long long m = 1000000007;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    int answer = 0;
    long long jsum[200010];

    for(int j=n-1; j>=0; j--){
        if(j==n-1){
            jsum[j] = a[j];
        }else{
            jsum[j] = (jsum[j+1] + a[j])%m;
        }

    }
    
    for(int i=1; i<n; i++){
        answer = (answer + jsum[i]*a[i-1])%m;
    }

    cout << answer;
}

Measured memory_bytes: 6712
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

ll mod = 1e9 + 7;

int main(){

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

    ll x; cin >> x;

    if(x >= 30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
using pl = pair<ll,ll>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Possible\n":"Impossible\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;


int main(int argc,char* argv[])
{
    int h,w,ans=0;
    char q;
    cin>>h>>w;
    rep(i,h*w) {
        cin>>q;
        ans+=q=='#';
    }
    yn(ans==h+w-1);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll dp[n],a[n];
    for(int i=0;i<n;i++){
        dp[i]=1000000000000000000;
        cin>>a[i];
    }
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        for(ll j=max(ll(0),i-k);j<=i;j++){
            dp[i]=min(dp[i],dp[j]+abs(a[j]-a[i]));
        }
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
class Dice
  def initialize(input_str)
    @values = input_str.chomp.split(' ')
  end

  def top
    @values[0]
  end

  def move(direction)
    send('move_to_' + direction)
  end

  def move_to_E
    tmp = @values[0]
    @values[0] = @values[3]
    @values[3] = @values[5]
    @values[5] = @values[2]
    @values[2] = tmp
  end

  def move_to_W
    tmp = @values[0]
    @values[0] = @values[2]
    @values[2] = @values[5]
    @values[5] = @values[3]
    @values[3] = tmp
  end

  def move_to_N
    tmp = @values[0]
    @values[0] = @values[1]
    @values[1] = @values[5]
    @values[5] = @values[4]
    @values[4] = tmp
  end

  def move_to_S
    tmp = @values[0]
    @values[0] = @values[4]
    @values[4] = @values[5]
    @values[5] = @values[1]
    @values[1] = tmp
  end
end

dice = Dice.new(gets)
directions = gets.chomp.split('')
directions.each { |d| dice.move(d) }
puts dice.top

Measured memory_bytes: 8712
//============================================================================
// Name        : SyousuuTest.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<stdio.h>
using namespace std;

int main() {
	int a,b,d,r;
	double f;
	cin>>a>>b;
	d=a/b;
	r=a%b;
	f=(double)a/b;
	printf("%d %d %.5lf\n",d,r,f);

	return 0 ;

}



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

using int64 = long long;

const int64 MOD = 998244353LL;
const int MAX_N = 300000;

int64 fact[MAX_N + 1];

int64 powMod(int64 a, int64 b) {
    if (b == 0) return 1;
    else if (b & 1) return (a * powMod(a, b - 1)) % MOD;
    else {
        auto c = powMod(a, b / 2);
        return (c * c) % MOD;
    }
}

int64 invMod(int64 n) {
    return powMod(n, MOD - 2);
}

int64 factorialMod(int64 n) {
    // 初期化
    if (fact[n] == 0) {
        fact[0] = 1;
        for (int m = 1; m <= MAX_N; m++) {
            fact[m] = (fact[m - 1] * m) % MOD;
        }
    }
    return fact[n];
}

int64 nCkMod(int64 n, int64 k) {
    // n! / (n - k)!k!
    int64 nume = factorialMod(n),
          deno = (factorialMod(n - k) * factorialMod(k)) % MOD;
    return (nume * invMod(deno)) % MOD;
}

int main() {
    int64 N, A, B, K;

    cin >> N >> A >> B >> K;

    int64 ans = 0;
    for (int64 a = 0; a <= N; a++) {
        int64 k = (K - a * A);
        if (k < 0 or k % B != 0 or (k / B) > N) continue;

        int64 b = (k / B);
        ans = (ans + (nCkMod(N, a) * nCkMod(N, b)) % MOD) % MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main{

	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int n;
		n=scan.nextInt();
		int i,j,dice1,dice2,dice[][]=new int[n][6],f=0,swap;
		for(i=0;i<n;i++){
			for(j=0;j<6;j++){
				dice[i][j]=scan.nextInt();
			}
		}
		for(dice1=0;dice1<n-1;dice1++){
			for(dice2=dice1+1;dice2<n;dice2++){
				for(i=0;i<=6;i++){
					if(dice[dice1][0]==dice[dice2][0]&&dice[dice1][5]==dice[dice2][5]){
						for(j=0;j<4;j++){
							if(dice[dice1][1]==dice[dice2][1]&&dice[dice1][2]==dice[dice2][2]&&dice[dice1][3]==dice[dice2][3]&&dice[dice1][4]==dice[dice2][4]){
								f=1;
								break;
							}
							swap=dice[dice2][1];
							dice[dice2][1]=dice[dice2][2];
							dice[dice2][2]=dice[dice2][4];
							dice[dice2][4]=dice[dice2][3];
							dice[dice2][3]=swap;
						}
					}
					if(i%2==0){
						swap=dice[dice2][0];
						dice[dice2][0]=dice[dice2][1];
						dice[dice2][1]=dice[dice2][5];
						dice[dice2][5]=dice[dice2][4];
						dice[dice2][4]=swap;
					}

					else{
						swap=dice[dice2][0];
						dice[dice2][0]=dice[dice2][3];
						dice[dice2][3]=dice[dice2][5];
						dice[dice2][5]=dice[dice2][2];
						dice[dice2][2]=swap;
						
					}
					if(f==1){
						break;
					}
				}
				if(f==1){
					break;
				}
			}
			if(f==1){
				break;
			}
		}
		if(f>=1){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 28764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl

void Dead(){
    cout << 0 << endl;
    exit(0);
}

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int G = 0,P = 0;
    REP(i,S.size()){
        if(S[i] == 'g') G++;
        else P++;
    }
    cout << max(abs(P-G)/2,0) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define INF (1LL<<60)
typedef long long ll;
typedef vector<ll> vec;
 
vec And(vec a,vec b){
  sort(a.begin(),a.end());sort(b.begin(),b.end());
  vec res;
  int as=a.size(),bs=b.size();
  int ai=0,bi=0;
  while(ai<as||bi<bs){
    ll av=(ai==as?INF:a[ai]);
    ll bv=(bi==bs?INF:b[bi]);
    if(av<bv){
      ai++;
    }else if(av==bv){
      res.push_back(av);
      ai++;
      bi++;
    }else{
      bi++;
    }
  }
  return res;
}
 
vec Or(vec a,vec b){
  sort(a.begin(),a.end());sort(b.begin(),b.end());
  vec res;
  int as=a.size(),bs=b.size();
  int ai=0,bi=0;
  while(ai<as||bi<bs){
    ll av=(ai==as?INF:a[ai]);
    ll bv=(bi==bs?INF:b[bi]);
    if(av<bv){
      res.push_back(av);ai++;
    }else if(av==bv){
      res.push_back(av);ai++;bi++;
    }else{
      res.push_back(bv);bi++;
    }
  }
  return res;
}
 
vec Dif(vec a,vec b){
  sort(a.begin(),a.end());sort(b.begin(),b.end());
  vec res;
  int as=a.size(),bs=b.size();
  int ai=0,bi=0;
  while(ai<as||bi<bs){
    ll av=(ai==as?INF:a[ai]);
    ll bv=(bi==bs?INF:b[bi]);
    if(av<bv){
      res.push_back(av);ai++;
    }else if(av==bv){
      ai++;bi++;
    }else{
      bi++;
    }
  }
  return res;
}
 
 
vec Xor(vec a,vec b){
  return Or(Dif(a,b),Dif(b,a));
}
 
vec U;
 
vec Not(vec a){
  return Dif(U,a);
}
 
map<char,vec> mp;
 
void func(char ch,int num){
  vec v;
  ll a;
  for(int i=0;i<num;i++){
    cin>>a;
    v.push_back(a);
  }
  sort(v.begin(),v.end());
  mp[ch]=v;
  U=Or(U,v);
}
 
string s;
int pos,len;
vec solve();
 
vec getNum(){
  if(s[pos]=='c'){
    pos++;
    return Not(getNum());
  }else if(s[pos]=='('){
    pos++;
    vec res=solve();
    pos++;
    return res;
  }else{
    char ch=s[pos];
    pos++;
    return mp[ch];
  }
}
 
vec solve(){
  vec res=getNum();
  while(pos<len&&s[pos]!=')'){
    char ch=s[pos];
    pos++;
    vec num=getNum();
    if(ch=='u')res=Or(res,num);
    if(ch=='i')res=And(res,num);
    if(ch=='d')res=Dif(res,num);
    if(ch=='s')res=Xor(res,num);
  }
  return res;
}
 
int main(){
  int num;
  char ch;
  while(cin>>ch>>num){
    mp.clear();U.clear();
    func(ch,num);
    while(1){
      if(ch=='R')break;
      cin>>ch>>num;
      if(ch=='R')break;
      func(ch,num);
    }
    sort(U.begin(),U.end());
    mp['U']=U;
    pos=0;
    cin>>s;
    len=s.size();
    vec ans=solve();
    if(ans.size()==0)cout<<"NULL";
    for(int i=0;i<(int)ans.size();i++){
      if(i)cout<<' ';
      cout<<ans[i];
    }
    cout<<endl;
 
  }
  return 0;
}

Measured memory_bytes: 1248
import sys

def main():
  input = sys.stdin.readline
  S = str(input().strip())
  y, m, d = map(int, S.split('/'))
  
  if y < 2019:
    print('Heisei')
  elif m <= 4:
    print('Heisei')
  else:
    print('TBD')


if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
from collections import deque

S = input()
Q = int(input())
head = 1
d = deque([S])

for _ in range(Q):
    q = input().split()
    if q[0]=='1':
        head = head*-1
    else:
        if q[1]=='1':
            h = head*1
        else:
            h = head*-1
        
        if h==1:
            d.appendleft(q[2])
        else:
            d.append(q[2])
ans = "".join(list(d))
if head == -1:
    ans = ans[::-1]

print(ans)

Measured memory_bytes: 64600
def five_dishes(A: int, B: int, C: int, D: int, E: int)->int:
    dishes = sorted([A, B, C, D, E], key=lambda x: x % 10 if x % 10 else 10)

    def offset(d: int)->int:
        return 10 - d % 10 if d % 10 else 0
    return dishes[0] + sum(d + offset(d) for d in dishes[1:])


if __name__ == "__main__":
    inputs = [int(input()) for _ in range(5)]
    A, B, C, D, E = inputs
    ans = five_dishes(A, B, C, D, E)
    print(ans)


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

int main(int argc, char const *argv[])
{
    int a,b,c; cin >> a >> b >> c;
    if ((a <= c && c <= b) || (b <=c && c <= a))
    {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    string s;
    cin>>s;
    int n=s.size();
    int a[100010];
    for(int i=0;i<n;i++) a[i]=1;
    for(int i=0;i+2<n;i++){
        if(s[i]=='R'&&s[i+1]=='R'){
            a[i+2]+=a[i];
            a[i]=0;
        }
    }
    for(int i=n-1;i-2>=0;i--){
        if(s[i]=='L'&&s[i-1]=='L'){
            a[i-2]+=a[i];
            a[i]=0;
        }
    }
    for(int i=0;i<n;i++) cout<<a[i]<<" ";
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

        sc.close();

        int ans = 0;

        for (int i = 0; i < n; i++) {
            ans = (int) Math.pow(2, i);
            if (ans > n) {
                ans = (int) Math.pow(2, i - 1);
                break;
            }
        }

        System.out.println(ans);

    }
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int A,B;
  cin>>A>>B;
  
  if(A==B){
cout<<0<<endl;
  }
  
  else if((A+B)%2==0){
    cout<<(A+B)/2<<endl;
  }
else{
  cout<<"IMPOSSIBLE"<<endl;
}
}


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

using namespace std;

int main()
{
	int a, b, c, d, e;
	cin >> a;
	
	b = a/1000;
	c = a/100%10;
	d = a/10%10;
	e = a%10;
	
	if (b == c && c == d || c == d && d == e)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 256
input_word=""
input_text=[]
temp=[]
flg=0
text=""
#正規表現モジュール
import re 

input_word=input()

input_word="\s"+input_word+"\s"

while flg==0:
    input_line=input()
    if input_line=="END_OF_TEXT":
        flg=1
        input_line=""

    else:
        temp=input_line.split()
        input_text.extend(temp)
        temp=[]

for i in input_text:
    text=text+" "+i+" "
matchOB=re.findall(input_word,text, re.IGNORECASE)
print(len(matchOB))



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

int main(int argc, char const *argv[]) {
  int K;
  char S[110];
  scanf("%d", &K);
  scanf("%s", S);

  int len = strlen(S);
  if (len <= K) {
    printf("%s\n", S);
  } else {
    S[K] = '\0';
    printf("%s...\n", S);
  }

  return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int n,k=1e9+7,a=0,b=0;string s;
    cin>>n>>s;
    vector<int> black(n);
    vector<int> white(n);
    for(int i=0;i<n;i++){
        if(s[i]=='#') a++;
        else b++;
        black[i]=a;white[i]=b;
    }
    for(int i=0;i<n;i++) k=min(k,black[i]+white[n-1]-white[i]);
    k=min(k,b);
    cout<<k;
}

Measured memory_bytes: 2180
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int n,c1,c2,count,ans=0;
	string s;
	cin >> n >> s;
	for (int i = 1; i < n-1;i++) {
		count = 0;
		for (int j = 0; j < 26;j++) {
			c1 = 0,c2 = 0;
			for (int k = 0; k <= i;k++) {
				if (s[k]=='a'+j) {
					c1 = 1;
				}
			}
			for (int l = i + 1; l < n;l++) {
				if (s[l]=='a'+j) {
					c2 = 1;
				}
			}
			if (c1*c2>0) {
				count++;
			}
		}
		if (ans<count) {
			ans = count;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <sstream>
 
int main(void)
{
    int64_t N, Q;
    std::cin >> N >> Q;

    std::vector<std::pair<int64_t, int64_t>> branches(N-1);
    for (auto& branch : branches) {
        std::cin >> branch.first >> branch.second;
    }

    std::sort(branches.begin(), branches.end());

    std::vector<int64_t> nodes(N+1);

    for (int64_t i = 0; i < Q; ++i) {
        int64_t p, x;
        std::cin >> p >> x;
        nodes.at(p) += x;
    }

    for (auto& branch : branches) {
        auto a = branch.first;
        auto b = branch.second;
        nodes.at(b) += nodes.at(a);
    }

    for (int64_t i = 1; i < N+1; ++i) {
        std::cout << nodes.at(i) << " ";
    }
    std::cout << std::endl;

    return 0;
}

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> v(M);
	for (auto& i : v) cin >> i;
	sort(v.begin(), v.end());

	if (N >= M) {
		cout << 0 << endl;
		return 0;
	}

	vector<int> sub(M);
	for (int i = 0; i < M - 1; i++) {
		sub[i] = v[i + 1] - v[i];
	}

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

	int ans = v[M - 1] - v[0];
	for (int i = 0; i < N - 1; i++) {
		ans -= sub[M - i - 1];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
N = int(input())

dic = {}

for i in range(N):
    S = input()
    
    if (S in dic) == False:
        dic[S] = 1
    else:
        dic[S] += 1
        
keys = []
maxv = max(dic.values())
for key , value in dic.items():
    if value == maxv:
        keys.append(key)
k = keys.sort()
for i in keys:
    print(i)


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

int main()
{
    int cnt,le,small;
    string s;
    cin >> s;
    le = s.size();
    for(int i=0;i<le;i++)
    {
        if(s[i] == '0')
        {
            cnt ++;
        }
    }
    small = min(cnt, le-cnt);
    cout << small*2;


}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include<unordered_map>
#include <set>
#include<unordered_set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <math.h>

#define lli long long int
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e5 + 6;

void solve()
{
    lli h;
    cin>>h;
    lli ans = 0, x = 1;
    while(h) {
        ans += x;
        x *= 2;
        h /= 2;
    }
    cout<<ans;
    cout<<'\n';
    return ;
}

/*
*/

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

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


Measured memory_bytes: 256
/*
O(ElogV)
verify:
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=ja
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;



template<typename T >
struct edge {
  int to;
  T cost;
  edge()=default;
  edge(int to, T cost) : to(to), cost(cost) {}

};


template<class T>
vector<T> dijkstra(vector< vector<edge<T>> > &g,int s,const T inf,const T zero){
    vector<T> dist(g.size(),inf);
    using pti=pair<T,int>;
    priority_queue<pti,vector<pti>,greater<pti>> que;
    dist[s]=zero;
    que.emplace(dist[s],s);
    while(!que.empty()){
      T cost;
      int idx;
      tie(cost,idx)=que.top();
      que.pop();
      if(dist[idx]<cost) continue;
      for(auto &e:g[idx]){
        auto next_cost=cost+e.cost; //Tの足し算 順番にも注意
        if(dist[e.to]<=next_cost) continue; //Tの比較
        dist[e.to]=next_cost;
        que.emplace(dist[e.to],e.to);
      }
    }
    return dist;
}

ll l;

inline pll operator+(pll a,pll b){
    if(a.second+b.second<=l) return {a.first+b.first,a.second+b.second};
    return {a.first+b.first+1,b.second};
}

signed main(){
    int n,m;
    cin>>n>>m>>l;
    vector<vector<edge<pll>>> g(n);
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--; b--;
        if(c>l) continue;
        g[a].emplace_back(b,pll(0,c));
        g[b].emplace_back(a,pll(0,c));
    }
    vector<vector<pll>> v(n);
    for(int i=0;i<n;i++){
        v[i]=dijkstra(g,i,{INF,INF},{0,0});
    }
    int q;
    cin>>q;
    while(q--){
        int s,t;
        cin>>s>>t;
        s--; t--;
        if(v[s][t]==pll(INF,INF)) cout<<-1<<endl;
        else cout<<v[s][t].first<<endl;
    }
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
int main()
{
	int n, m;
	cin >> n >> m;
	vector<pii> v(m);
	rep(i,m){
		int a, b;
		cin >> a >> b;
		v[i] = make_pair(b, a);
	}
	sort(all(v));
	int d = v[0].first;
	int ans = 1;
	rep(i, m)
	{
		if(v[i].second >= d){
			d = v[i].first;
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <cstring>

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using PP = pair<ll, pair<ll,ll>>;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

ll n, a, t, ans;

int main() {
    cin >> n;
    t = 0;
    ans = 0;
    rep(i,n){
        cin >> a;
        ll add = t-a;
        if (add < 0) add = 0;
        t = add+a;
        ans += add;
    }
    cout << ans << endl;
    return 0;
}


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

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

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

  string s; cin >> s;
  int n = s.size();
  int N = 0, W = 0, S = 0, E = 0;
  rep(i, n) {
    if(s[i] == 'N') N++;
    else if(s[i] == 'W') W++;
    else if(s[i] == 'S') S++;
    else E++;
  }

  bool flag = true;
  if(!(N == 0 && S == 0) && N*S == 0) flag = false;
  if(!(W == 0 && E == 0) && W*E == 0) flag = false;
  cout << (flag ? "Yes" : "No") << '\n';
  return 0;
}


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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)malloc(sizeof(int)*2*n);
  int i,j;
  for(i=0;i<2*n;i++) scanf("%d",a+i);
  int max=0;
  for(i=0;i<n;i++){
    int s=0;
    for(j=0;j<=i;j++){
      s+=a[j];
    }
    for(j=i;j<n;j++){
      s+=a[n+j];
    }
    max=MAX(max,s);
  }
  printf("%d\n",max);
  return;
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
n, x, y = gets.split.map(&:to_i)
x -= 1
y -= 1

ans = [0] * (n-1)

n.times do |j|
  j.times do |i|
    d = j - i
    t = (x - i).abs + 1 + (j - y).abs
    d = t if d > t
    ans[d-1] += 1
  end
end

puts ans

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

int main()
{
	char s1[101];
	char s2[101];
	char s3[201];
		
			
	scanf("%s",s1);
	scanf("%s",s2);
		
	strcpy(s3,s1);
	strcat(s3,s1);

	if(strstr(s3,s2))
		puts("Yes");
	else
		puts("No");
		
		return 0;
}


Measured memory_bytes: 2112
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>

using namespace std;

int main()
{
  int n;

  while ( cin >> n )
    {
      cout << n * (n + 1) / 2 + 1 << endl;
    }
  
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 1;
int dp[MAXN];

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

	int n, m;
	scanf("%d%d", &n, &m);
	set<int> bad;
	for (int i = 0; i < m; i++) {
		int a;
		scanf("%d", &a);
		bad.insert(a);
	}

	dp[0] = 1;
	dp[1] = bad.count(1)? 0 : 1;
	for (int i = 2; i <= n; i++) {
		if (bad.count(i)) continue;
		dp[i] = (dp[i-1] + dp[i-2]) % MOD;
	}
	printf("%d\n", dp[n]);
}


Measured memory_bytes: 4992
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include <assert.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
#include <climits>
using namespace std;
typedef unsigned long long ull;
#define ll long long int
ll mod = 1000000007;
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;

int main() {
	ll ind = 0,y=0;
	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'W') {
			y += i - ind;
			ind++;
		}
	}
	cout << y << endl;
}




Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,k,q,A[200001];
    cin>>n>>k>>q;
    int num[200001]={0};
    rep(i,q) cin>>A[i],num[A[i]]++;
    int ans=0;
    rep(i,n){
      if(k-q+num[i+1]>0) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Solution sol = new Solution();
		sol.solve(in, out);
		out.close();
	}

	static int MAX = 1000001;

	static class Query {
		int l, r, idx;

		public Query(int l, int r, int idx) {
			this.l = l;
			this.r = r;
			this.idx = idx;
		}
	}

	static void update(int idx, int val, int bit[], int n) {
		for (; idx <= n; idx += idx & -idx)
			bit[idx] += val;
	}

	static int query(int idx, int bit[], int n) {
		int sum = 0;
		for (; idx > 0; idx -= idx & -idx)
			sum += bit[idx];
		return sum;
	}

	static void answeringQueries(int[] arr, int n, Query[] queries, int q) {

	}

	private static class Solution {
		private void solve(InputReader in, PrintWriter out) {
			int n = in.ni(), q = in.ni();
			int[] colors = in.readArray(n);
			Query[] qs = new Query[q];
			for (int i = 0; i < q; ++i)
				qs[i] = new Query(in.ni() - 1, in.ni() - 1, i);
			Arrays.sort(qs, (x, y) -> {
				if (x.r < y.r)
					return -1;
				else if (x.r == y.r)
					return 0;
				else
					return 1;
			});
			int[] bit = new int[n + 1];
			Arrays.fill(bit, 0);
			int[] last_visit = new int[MAX];
			Arrays.fill(last_visit, -1);
			int[] ans = new int[q];
			int query_counter = 0;
			for (int i = 0; i < n; i++) {
				if (last_visit[colors[i]] != -1)
					update(last_visit[colors[i]] + 1, -1, bit, n);
				last_visit[colors[i]] = i;
				update(i + 1, 1, bit, n);
				while (query_counter < q && qs[query_counter].r == i) {
					ans[qs[query_counter].idx] = query(qs[query_counter].r + 1, bit, n)
							- query(qs[query_counter].l, bit, n);
					query_counter++;
				}
			}

			for (int i = 0; i < q; i++)
				out.println(ans[i]);
		}
	}

	private static class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		private InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		private String n() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		private int ni() {
			return Integer.parseInt(n());
		}

		private int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; ++i)
				a[i] = ni();
			return a;
		}
	}
}

Measured memory_bytes: 85168