akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;



int main(){
  int n = 0;
  cin >> n;
  vector<int> data(n);
  rep(i,n) cin >> data.at(i);
  int chk = 2e5;
  int count = 0;
  rep(i,n){
    if(chk >= data.at(i)){
      chk = data.at(i);
      count += 1;
    }  
  }
  cout << count;
 
}

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

#define REP(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) REP(i,0,n)
#define FOR(i,c) for(auto& (i):(c))
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) (int)(x).size()

string J(string s) {
    string t = s.substr(1, SZ(s) - 1);
    t += s[0];
    return t;
}

string C(string s) {
    string t = "";
    t += s[SZ(s)-1];
    t += s.substr(0, SZ(s) - 1);
    return t;
}

string E(string s) {
    int n = s.size();
    string t = "";
    if(n % 2 == 0) {
        t += s.substr(n/2, n/2);
        t += s.substr(0, n/2);
    } else {
        t += s.substr(n/2+1, n/2);
        t += s[n/2];
        t += s.substr(0, n/2);
    }
    return t;
}

string P(string s) {
    FOR(c, s) {
        if(isdigit(c)) {
            if(c == '9') c = '0';
            else c++;
        }
    }
    return s;
}

string M(string s) {
    FOR(c, s) {
        if(isdigit(c)) {
            if(c == '0') c = '9';
            else c--;
        }
    }
    return s;
}

void solve(string order, string msg) {
    reverse(ALL(order));
    FOR(c, order) {
        if(c == 'C') msg = J(msg);
        if(c == 'J') msg = C(msg);
        if(c == 'E') msg = E(msg);
        if(c == 'A') reverse(ALL(msg));
        if(c == 'M') msg = P(msg);
        if(c == 'P') msg = M(msg);
    }
    cout << msg << "\n";
}

int main() {
    int n; cin>>n;
    rep(data,n) {
        string order, msg;
        cin >> order >> msg;
        solve(order, msg);
    }
    return 0;
}

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

int main()
{
    int num_problem, num_submission;

    scanf(" %d", &num_problem);
    scanf(" %d", &num_submission);

    int int_prb, int_score;
    char a_or_w;
    int score[num_problem], pena[num_problem];

    for (int j = 0; j < num_problem; j++) score[j] = pena[j] = 0; 

    for (int i = 0; i < num_submission; i++)
    {
        scanf(" %d", &int_prb);
        scanf(" %c%*c", &a_or_w);

        a_or_w == 'A' ? int_score = 1 : int_score = 0;

        if (score[int_prb - 1] == 0)
        {
            score[int_prb - 1] += int_score;
            pena[int_prb - 1] += 1 - int_score;

            // printf("%d %d\n", score[int_prb - 1], pena[int_prb - 1]);
        }
    }

    int s = 0, p = 0;

    for (int j = 0; j < num_problem; j++)
    {
        s += score[j];
        p += score[j] * pena[j];
    }

    printf("%d %d\n", s, p);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e9+7
 
 
int main() {
    int s, w;
    cin >> s >> w;
    cout << (s <= w ? "unsafe" : "safe") << endl;
    return 0;
}

Measured memory_bytes: 3652
import java.util.stream.*;
import java.io.*;
 
public class Main {
  
  static int n;
  static long[] dp, h;
 
  static long max(long a, long b, long c){
    return Math.max(Math.max(a, b), c);
  }
 
  public static void main(String[] args) throws IOException {
 
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
    String[] in;
    in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);
 
    in = br.readLine().split(" ");
    h = Stream.of(in).mapToLong(Long::parseLong).toArray();
 
    br.close();
 
    dp = new long[n+1];
    dp[2] = Math.abs(h[1] - h[0]);
    for(int i = 3; i <= n; i++){
      dp[i] = Math.min(dp[i-1] + Math.abs((h[i-1] - h[i-2])), dp[i-2] + Math.abs((h[i-1] - h[i-3])));
    }
    
    System.out.println(dp[n]);
  }
}

Measured memory_bytes: 38300
#include<iostream>

using namespace std;

int main() {
	int n;cin >> n;
	int h = n / 3600; 
	int m = (n % 3600) / 60;
	int s = (n % 3600) % 60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}

Measured memory_bytes: 1168
import math

minMod = 10
minModNum = 0
numList = []
for i in range(0, 5):
    numList.append(int(input()))
    if ((numList[i] % 10 != 0) & (numList[i] % 10 < minMod)):
        minMod = numList[i] % 10
        minModNum = i

sum = 0
for i in range(0, 5):
    if i != minModNum:
        sum += int(math.ceil(numList[i]/10)*10)
    else:
        sum += numList[i]
print(sum)


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

bool isSuccess(string &s, int from, int to) {
  bool isContinuousLock = false;
  FOR(i, from, to - 2) {
    if (s[i] == '#' && s[i] == s[i + 1]) isContinuousLock = true;
  }
  return !isContinuousLock && s[to - 1] == '.' ? true : false;
}
bool isSuccessOver(string &s, int from, int to, int overPoint,
                   int overPointTo) {
  bool isContinuousBlank = false;
  bool isContinuousLock = false;
  FOR(i, from, to - 2) {
    if (s[i] == '#' && s[i] == s[i + 1]) isContinuousLock == true;
    if (i >= overPoint - 2 && i + 2 <= overPointTo) {
      if (s[i] == '.' && s[i] == s[i + 1] && s[i] == s[i + 2])
        isContinuousBlank = true;
    }
  }
  return !isContinuousLock && isContinuousBlank && s[to - 1] == '.' ? true
                                                                    : false;
}

signed main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  string s = readString();
  if (d < c) {
    if (isSuccessOver(s, a, c, b, d) && isSuccess(s, b, d))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;

  } else {
    if (isSuccess(s, a, c) && isSuccess(s, b, d))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
long long a, b, c, k;
int main()
{
	cin >> a >> b >> c >> k;
	if (k < a) cout << k;
	else if (k < a + b)cout << a;
	else
	{
		k += -a - b;
		cout << a - k;
	}
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b, c, d;
    cin >> a >> b >> c >> d ;
    //*/
    
    /*
    vector<int> vec(4);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    */
    
    //*
    if(a + b == c + d){
        cout << "Balanced" << endl;
    } else if(a + b > c + d){
        cout << "Left" << endl;
    } else {
        cout << "Right" << endl;
    }
    //*/
    
    //cout << ( a + b ) / 2 + ( a + b ) % 2 << endl;

    return 0; 
}


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

int main()
{
    int n; cin >> n;
    vector<int> h(n+1);
    for(int i=0;i<n;i++) cin >> h[i];
    int ans = 0;
    bool st = true;
    while(st){
        int i=0;
        if(h[i] == 0){
            while(h[i] == 0 && i<n){
                i++;
            }
            if(i == n) {
                st=false;
                break;
            }
        }
        while(h[i]>0){
            h[i]--;
            i++;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <climits>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair

const int INF = INT_MAX;

// ?????????0-origin??¨??????
class Dijkstra {

    struct edge { int to, cost; };
    typedef pair<int, int> P; // <???????????¢, ????????????>

public:
    Dijkstra(int V) {
        m_V = V;
        m_G.resize(m_V);
    }

    // a -> b?????????????????¨???????????????
    void add_dir_edge(int a, int b, int cost) {
        m_G[a].push_back( edge{ b, cost } );
    }

    // a <-> b?????????????????¨???????????????
    void add_undir_edge(int a, int b, int cost) {
        add_dir_edge(a, b, cost);
        add_dir_edge(b, a, cost);
    }

    // ??????s????????????????????§????????¢????¨????????????????
    vector<int> shortest_path(int s) {
        vector<int> d(m_V, INF);
        priority_queue<P, vector<P>, greater<P> > que;
        d[s] = 0;
        que.push(P(0, s));
    
        while(!que.empty()) {
            P p = que.top();
            que.pop();

            int dist = p.first;
            int v = p.second;
            if (d[v] < dist) continue;
            REP(i, m_G[v].size()) {
                edge e = m_G[v][i];
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(P(d[e.to], e.to));
                }
            }
        }

        return d;
    }

private:
    int m_V;
    vector<vector<edge> > m_G;
};
    
int main(){
    int V, E, r;
    cin >> V >> E >> r;
    Dijkstra dij(V);

    REP(e,E) {
        int v1, v2, cost;
        cin >> v1 >> v2 >> cost;
        dij.add_dir_edge(v1, v2, cost);
    }

    auto distances = dij.shortest_path(r);
    for(auto d : distances) {
        if (d == INT_MAX) cout << "INF" << endl;
        else cout << d << endl;
    }

    return 0;
}

Measured memory_bytes: 11224
#14:29
n,cn = map(int,input().split())
event = []
for _ in range(n):
  s,t,c = map(int,input().split())
  event.append([s-1,1,c-1])
  event.append([t  ,0,c-1])
event.sort()
can = []
now = 0
chan = [0 for _ in range(cn)]
for x in event:
  u,i,c = x
  if chan[c] == 0 and i == 1:
    chan[c] += 1
    now += 1
    can.append(now)
  elif chan[c] == 1 and i == 1:
    chan[c] += 1
  elif chan[c] == 1 and i == 0:
    chan[c] -= 1
    now -= 1
  elif chan[c] == 2 and i == 0:
    chan[c] -= 1
  else:
    print(fuck)
  #print(chan,u)
print(max(can))

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

int main() {

        string s;
        cin >> s;

        s.at(5) = ' ';
        s.at(13) = ' ';

        cout << s << endl;

}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
int main(){
   int a,b;
   cin >>a >> b;
   if(a-b==2 || b-a==2){
       cout << 2  << endl;
   }
   else{
       if(a==1 || b== 1){
           cout << 3 << endl;
       }
       else{
           cout << 1 << endl;
       }
   }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var k, x int
	ans := []int{}
	fmt.Scan(&k, &x)

	ans = append(ans, x)
	for i:= 1; i<k ;i++ {
		if x + i > 200 {
			break
		}
		ans = append(ans, x + i)
	}
	for i:= -1; i > -k ; i-- {
		if x + i < -99 {
			break
		}
		ans = append(ans, x + i)
	}
	sort.Ints(ans)
	for i, v:= range ans {
		if i == 0 {
			fmt.Printf("%d", v)
		} else {
			fmt.Printf(" %d", v)
		}
	}
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A+B > C+D) {
    cout << "Left" << endl;
  }else if(A+B < C+D){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
  
  return 0;
}


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

int main()
{
     int a,b,c,ans=0,flag=0;
     scanf("%d %d %d",&a,&b,&c);
     while(1)
     {
         if((b*ans+c)%a==0)
            {printf("YES");flag=1;break;}

            ans++;
         if(ans==20)
            break;
     }
     if(flag==0)
        printf("NO");
}

Measured memory_bytes: 128
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1e9+7;
const ll MAX_N=500010;
const ll INF=1e18+10;
ll n,a,b,c,d;
map<ll,ll> memo;

ll f(ll n){
    if(n==0){return 0;}
    if(n==1){return d;}
    if(memo.count(n)){return memo[n];}

    ll l2=n/2*2;
    ll r2=(n+1)/2*2;
    ll l3=n/3*3;
    ll r3=(n+2)/3*3;
    ll l5=n/5*5;
    ll r5=(n+4)/5*5;
    ll res=INF;
    if(n<res/d){res=n*d;}
    res=min(res,llabs(l2-n)*d+f(l2/2)+a);
    res=min(res,llabs(r2-n)*d+f(r2/2)+a);
    res=min(res,llabs(l3-n)*d+f(l3/3)+b);
    res=min(res,llabs(r3-n)*d+f(r3/3)+b);
    res=min(res,llabs(l5-n)*d+f(l5/5)+c);
    res=min(res,llabs(r5-n)*d+f(r5/5)+c);
    memo[n]=res;
    return res;

}

int main(){
    ll t;
    cin>>t;
    vector<ll> ans(t);
    for(ll i=0;i<t;i++){
        memo.clear();
        cin>>n>>a>>b>>c>>d;
        ans[i]=f(n);
    }
    for(ll i=0;i<t;i++){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 4352
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
li = [a,b,c,d,e]
index = -1
def rou(n):
    if(n%10==0): return n
    return n+10-n%10

mi=(li[0]-1)%10
for i in range(5):
    if((li[i]-1)%10 <= mi):
        mi=(li[i]-1)%10
        index = i

ans = 0
for i in range(5):
    if(index == i):
        ans += li[i]
    else:
        ans += rou(li[i])
print(ans)


Measured memory_bytes: 3064
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func main(){
    
    s := nextString()
    
    g := 0
    p := 0
    w := 0
    l := 0

    for _, x := range s {
        if x == 'g' && g > p {
            p++
            w++
        } else if x == 'g' {
            g++
        } else if x == 'p' && g > p {
            p++
        } else {
            g++
            l++
        }
    }
    fmt.Println(w-l)
}

/* templates */


func Max(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Min(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
 
func Abs(a float64) float64 {
    if a < 0 {
        return -a
    }
    return a
}
 
type Pair struct {
    first, second int
}
 
type Pairs []Pair
  
func (p Pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}
 
var nextReader func() string
 
func init() {
    nextReader = NewScanner()
}
 
func NewScanner() func() string {
    r := bufio.NewScanner(os.Stdin)
    r.Buffer(make([]byte, 1024), int(1e+11))
    r.Split(bufio.ScanWords)
    return func() string {
        r.Scan()
        return r.Text()
    }
}

func nextString() string {
    return nextReader()
}
 
func nextInt64() int64 {
    v, _ := strconv.ParseInt(nextReader(), 10, 64)
    return v
}
 
func nextInt() int {
    v, _ := strconv.Atoi(nextReader())
    return v
}
 
func nextInts(n int) []int {
    r := make([]int, n)
    for i := 0; i < n; i++ {
        r[i] = nextInt()
    }
    return r
}

func nextStrings(n int) []string {
    r := make([]string, n)
    for i := 0; i < n; i++ {
        r[i] = nextString()
    }
    return r
}

func nextFloat64() float64 {
    f, _ := strconv.ParseFloat(nextReader(), 64)
    return f
}


Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
//#include<array>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
//#include<bitset>
//#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//配列,座標
/*array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
array<int, 4>dir_x2 = { 0,0,1,-1 };
array<int, 4>dir_y2 = { 1,-1,0,0 };
char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };*/

//Union Find
/*class UnionFind {
public:
	vector<int>data;
	UnionFind(int size) :data(size, -1) {};
	bool unionset(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};*/

//最大公約数,最小公倍数
/*LLI gcd(LLI x, LLI y) {
	LLI  r;
	if (x < y) {
		swap(x, y);
	}
	r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}
LLI lcm(LLI x, LLI y) {
	return x / gcd(x, y) * y;
}*/

//組み合わせ
/*long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; i--) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; i++) {
		ans = ans / i;
	}
	return ans;
}
long nHr(int n, int r) {
	n = n + r - 1;
	return nCr(n, r);
}*/

//素数判定
/*bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}*/

//桁数
/*LLI GetDigit(LLI num) {
	LLI digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}*/

//サンプル
/*const int n_max = 8;
array<array<bool, n_max>, n_max>graph;
int dfs(int v,int N,array<bool,n_max>visited) {
	int ret = 0;
	bool all_visited = true;
	for (int i = 0; i < N;i++) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}
	if (all_visited) {
		return 1;
	}
	for (int i = 0; i < N;i++) {
		if (graph[v][i] == false) {
			continue;
		}
		if (visited[i] == true) {
			continue;
		}
		visited[i] = true;
		ret += dfs(i,N,visited);
		visited[i] = false;
	}
	return ret;
}*/

//サンプル
/*vector<vector<int>>sub;
int dfs(int id) {
	if (sub[id].size() == 0) {
		return 1;
	}
	int minP = (int)1e9;
	int maxP = 0;
	for (int i : sub[id]) {
		int P = dfs(i);
		minP = min(minP, P);
		maxP = max(maxP, P);
	}
	return minP + maxP + 1;
}*/

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI N,cnt = 0;
	string S;
	cin >> N >> S;
	for (int i = 0; i < N - 2;i++) {
		if (S[i] == 'A') {
			if (S.substr(i,3) == "ABC") {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

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

    if(n % 2 == 0){
        cout << ((ld)n / 2.0) / (ld)n << endl;
    } else {
        cout << (ld)(n / 2 + 1) / (ld)n << endl;
    }
}


Measured memory_bytes: 256
//                          VIVEK UPADHYAY
//                         MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                           TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<"\n" ;
#define ok cout<<"ok\n" ;
#define dbg(x) cout<<#x<<" = "<<(x)<<"\n";
typedef long long ll;
const int MAXN = 500510;
const int MAX = 1e7 + 1 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 ;
ll mod = 500500507;
ll powr(ll a , ll b){ if(b==0) return 1LL ; ll x = powr(a,b/2) ; x = (x*x)%mod ; if(b%2) return ((a%mod)*x)%mod ; return x ;}
ll gcd(ll a , ll b){if(a==0) return b ; return gcd(b%a,a);}
void read(int *a , int N){
    for(int i = 0 ; i < N ;i ++)
        cin >> a[i] ;
}
int main () {
    
    string s ;
    cin >> s ;
    int N = (int) s.length() ;
    ll cntW = 0 , ans = 0 ;
    for(int i = N-1;i>=0;i--){
        if(s[i]=='B') ans+=cntW ;
        else cntW++ ;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
def main():
    n, m = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(n)]
    ans = n
    st = set(i for i in range(1, m+1))
    while len(st) > 1:
        dic = {v:0 for v in st}
        for i in range(n):
            for v in a[i]:
                if v in st:
                    dic[v] += 1
                    break
        tmp = max(dic.values())
        if ans > tmp:
            ans = tmp
        for key in dic.keys():
            if dic[key] == tmp:
                st.remove(key)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 10360
N,M = map(int, input().split())

A=[]
for i in range(N):
  x = [int(i) for i in input().split()]
  A = A + x[1:]

ans = 0
from collections import Counter
for k,v in Counter(A).items():
  # print(k,v)
  if v==N: ans += 1

print(ans)


Measured memory_bytes: 9460
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include <climits>
using namespace std;

int main()
{
  string S;
  string S_f, S_b;
  cin >> S;
  S_f = S.substr(0, 2);
  S_b = S.substr(2, 2);
  int I_f, I_b;
  I_f = atoi(S_f.c_str());
  I_b = atoi(S_b.c_str());

  if(I_f <= 12 && I_b <= 12 && I_f > 0 && I_b > 0){
    cout << "AMBIGUOUS" << endl;
  }else if((I_f > 12 || I_f == 0) && I_b <= 12 && I_b > 0){
    cout << "YYMM" << endl;
  }else if(I_f <= 12 && (I_b > 12 || I_b == 0) && I_f > 0){
    cout << "MMYY" << endl;
  }else{
    cout << "NA" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
int t,n,m,l,i,j,a,b,k,P[1001],T[1001],Q[2001],C[2001][2001],V[2001],d[1001][1001];
int match(s){int i=l;for(;i<l+l;i++)if(C[s][i]&&!V[i])if(V[i]=1,Q[i]<0||match(Q[i]))return Q[s]=i,Q[i]=s,1;return 0;}
main(){
  for(;scanf("%d%d%d",&n,&m,&l),l;printf("%d\n",l-t)){
	memset(C,0,sizeof(C));memset(Q,0xff,sizeof(Q));
	//memset(d,99,sizeof(d));for(i=0;i<n;i++)d[i][i]=0;
    for(i=0;i<n;i++)for(j=0;j<n;j++)d[i][j]=i==j?0:999999;
    for(i=0;i<m;i++)scanf("%d%d%d",&a,&b,&k),d[a][b]=d[b][a]=k;
	for(i=0;i<l;i++)scanf("%d%d",P+i,T+i);
	//warshall-floyd
	for(k=0;k<n;k++)for(i=0;i<n;i++)for(j=0;j<n;j++)if(d[i][j]>d[i][k]+d[k][j])d[i][j]=d[i][k]+d[k][j];
	for(i=0;i<l;i++)for(j=0;j<l;j++)if(i!=j&&d[P[i]][P[j]]<999999&&T[i]+d[P[i]][P[j]]<=T[j])C[i][l+j]=C[l+j][i]=1;
    for(t=i=0;i<l;i++)memset(&V,0,sizeof(V)),t+=match(i);
  }
  return 0;
}

Measured memory_bytes: 18560
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

struct Edge{
    int from, to, cost;
};

int fd[100005];
int sd[100005];
vector<vector<Edge>> G;

int main(){
    cin.tie(0);

    int N; cin >> N;
    int INF = 1000000;
    fill(fd+1, fd+N+1, INF);
    fill(sd+1, sd+N+1, INF);
    G = vector<vector<Edge>>(N+1);
    for (int i = 0; i < N-1; i++){
        int a, b; cin >> a >> b;
        Edge e1 = {a, b, 1};
        Edge e2 = {b, a, 1};
        G[a].push_back(e1);
        G[b].push_back(e2);
    }
    queue<int> q;
    q.push(1);
    fd[1] = 0;
    while (!q.empty()){
        int crt = q.front();
        q.pop();

        for (auto itr = G[crt].begin(); itr != G[crt].end(); itr++){
            if (fd[crt] + 1 < fd[itr->to]){
                q.push(itr->to);
                fd[itr->to] = fd[crt] + 1;
            }
        }
    }
    q.push(N);
    sd[N] = 0;
    while (!q.empty()){
        int crt = q.front();
        q.pop();

        for (auto itr = G[crt].begin(); itr != G[crt].end(); itr++){
            if (sd[crt] + 1 < sd[itr->to]){
                q.push(itr->to);
                sd[itr->to] = sd[crt] + 1;
            }
        }
    }
    int cnt = 0;
    for (int i = 1; i <= N; i++){
        if (fd[i] <= sd[i]) cnt++;
    }
    if (cnt > N-cnt) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

#define MAX_N 100100
//i番目の素数
int prime[MAX_N];
//trueなら素数
bool is_prime[MAX_N + 1];

//n以下の素数の数を返す O(n log(logn)) ~~ O(n)
int sieve(int n){
    int p = 0;
    for(int i = 0; i <= n; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= n; i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j = 2*i; j <= n; j += i) is_prime[j] = false;
        }
    }
    return p;
}

int main(){
    int nump = sieve(MAX_N);
    vector<int> like2017;
    int idx = 0;
    for(int i = 0; i < nump; i++){
        int p = prime[i];
        if(is_prime[(p+1)/2]){
            like2017.push_back(p);
        }
    }

    int Q;
    cin >> Q;
    REP(i,Q){
        int l, r;
        cin >> l >> r;
        ll ans = 0;
        ans = upper_bound(like2017.begin(), like2017.end(), r)
               - lower_bound(like2017.begin(), like2017.end(), l);
        cout << ans << endl;
    }
    return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b)
{
    return b ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(long long N, long long K, std::vector<long long> H)
{
    sort(H.begin(), H.end(), greater<long long>());
    ll atack = 0;
    int j = 0;
    for (int i = 0; i < K; i++)
    {
        j = i + 1;
    }
    for (j; j < N; j++)
    {
        atack += H[j];
    }
    cout << atack << endl;
}

int main()
{
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> H(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &H[i]);
    }
    func(N, K, std::move(H));
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD1			998244353
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//find_by_order kth largest  order_of_key <
const int tam = 100010;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int n;
	ll res = 0;
	cin>>n;
	int ar[n];
	fore(i, 0, n) cin>>ar[i];
	int pos = 0, xo = 0;
	fore(i, 0, n)
	{
		while((ar[i] & xo) > 0)
		{
			xo ^= ar[pos];
			pos++;
		}
		xo ^= ar[i];
		res += i - pos + 1;
	}
	cout<<res<<'\n';
	return 0;
}

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

Measured memory_bytes: 1024
a,b = map(int,input().split())
f = list(input())
if f[b-1]=="A":
    f[b-1]="a"
elif f[b-1]=="B":
    f[b-1]="b"
elif f[b-1]=="C":
    f[b-1]="c"
pr= ""
for i in f:
    pr += i
print(pr)

Measured memory_bytes: 3064
n = gets.chomp.to_i
count = 0
num = 1
digit = 0
while count < n do
  nums = num.to_s.split('')
  digit_num = nums.reverse[digit].to_i
  unless digit_num == 0
    puts num
    num += 10 ** digit
    count += 1
    next
  end
  sum = nums.map(&:to_i).inject(:+)
  if (sum * (10 ** digit) - num < 0)
    num += 9 * (10 ** digit)
    digit += 1
    next
  end
  puts num
  num += 10 ** digit
  count += 1
  next
end


Measured memory_bytes: 1916
#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) begin(v),end(v)
#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; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

using pll = pair<ll, ll>;

int N;
vector<ll> X, Y;
vector<char> D;

inline double func2(ll xmind, ll xmaxd, ll mn[2], ll mx[2], double t) {
	pair<double, double> res;
	res.fi = min({ (double)xmind, mn[0] + t, mn[1] - t });
	res.se = max({ (double)xmaxd, mx[0] + t, mx[1] - t });
	return res.se - res.fi;
}

vector<ll> func(vector<ll> &x, ll xmind, ll xmaxd, ll mn[2], ll mx[2], char inc, char dec) {
	// mn, mx : [0]'R', [1]'L'
	vector<ll> res;
	res.push_back(0);
	res.push_back(longINF);
	
	REP(i, N) if (D[i] == inc || D[i] == dec) {
		chmin(mn[D[i] == dec], x[i]);
		chmax(mx[D[i] == dec], x[i]);
	}
	
	if (xmind == INF) return res;
	if (mn[0] != INF) {
		if (mn[0] < xmind) res.push_back(xmind - mn[0]);
		if (mx[0] < xmaxd) res.push_back(xmaxd - mx[0]);
	}
	if (mn[1] != INF) {
		if (mx[1] > xmaxd) res.push_back(mx[1] - xmaxd);
		if (mn[1] > xmind) res.push_back(mn[1] - xmind);
	}
	return res;
}

int main() {
	cin >> N;
	X.resize(N);
	Y.resize(N);
	D.resize(N);
	REP(i, N) scanf("%lld %lld %c", &X[i], &Y[i], &D[i]);
	
	ll xmind = INF, xmaxd = -INF, ymind = INF, ymaxd = -INF;
	ll mn[2][2], mx[2][2];
	fill(mn[0], mn[2], INF);
	fill(mx[0], mx[2], -INF);
	
	REP(i, N) {
		if (D[i] != 'R' && D[i] != 'L') {
			chmin(xmind, X[i]);
			chmax(xmaxd, X[i]);
		}
		else {
			chmin(ymind, Y[i]);
			chmax(ymaxd, Y[i]);
		}
	}
	
	vector<ll> T = func(X, xmind, xmaxd, mn[0], mx[0], 'R', 'L');
	vector<ll> tmpv = func(Y, ymind, ymaxd, mn[1], mx[1], 'U', 'D');
	T.insert(T.end(), ALL(tmpv));
	sort(ALL(T));
	T.erase(unique(ALL(T)), T.end());
	
	double ans = longINF;
	REP(tt, T.size() - 1) {
		// [T[tt], T[tt + 1]]
		double l = T[tt], r = T[tt + 1];
		REP(i, 500) {
			double m1 = (r + 2*l) / 3;
			double m2 = (2*r + l) / 3;
			double f1 = func2(xmind, xmaxd, mn[0], mx[0], m1) * func2(ymind, ymaxd, mn[1], mx[1], m1);
			double f2 = func2(xmind, xmaxd, mn[0], mx[0], m2) * func2(ymind, ymaxd, mn[1], mx[1], m2);
			if (f1 > f2) l = m1;
			else r = m2;
			
			chmin(ans, f1);
		}
		
	}
	
	if (ans < 1e-10) ans = 0;
	printf("%.15lf\n", ans);
	return 0;
}



Measured memory_bytes: 1920
N, M = map(int, input().split())
a = []
issafe = [True for _ in range(N+1)]
for i in range(M):
    a.append(int(input()))
    issafe[a[i]] = False

dp = [0 for _ in range(N+1)]
dp[0] = 1
if issafe[1]:
    dp[1] = 1

for i in range(2, N+1):
    if issafe[i-1]:
        dp[i] += dp[i-1]
    if issafe[i-2]:
        dp[i] += dp[i-2]
    dp[i] %= 1000000007

print(dp[N])

Measured memory_bytes: 56480
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
typedef unsigned int uint;
typedef long long ll;

int main() {
	char N[10];
	scanf("%s", N);
	int num[4] = { N[0] - '0',N[1] - '0', N[2] - '0', N[3] - '0' };

	if      (num[0] + num[1] + num[2] + num[3] == 7)printf("%d+%d+%d+%d=7", num[0], num[1], num[2], num[3]);
	else if (num[0] + num[1] + num[2] - num[3] == 7)printf("%d+%d+%d-%d=7", num[0], num[1], num[2], num[3]);
	else if (num[0] + num[1] - num[2] + num[3] == 7)printf("%d+%d-%d+%d=7", num[0], num[1], num[2], num[3]);
	else if (num[0] - num[1] + num[2] + num[3] == 7)printf("%d-%d+%d+%d=7", num[0], num[1], num[2], num[3]);
	else if (num[0] + num[1] - num[2] - num[3] == 7)printf("%d+%d-%d-%d=7", num[0], num[1], num[2], num[3]);
	else if (num[0] - num[1] + num[2] - num[3] == 7)printf("%d-%d+%d-%d=7", num[0], num[1], num[2], num[3]);
	else if (num[0] - num[1] - num[2] + num[3] == 7)printf("%d-%d-%d+%d=7", num[0], num[1], num[2], num[3]);
	else if (num[0] - num[1] - num[2] - num[3] == 7)printf("%d-%d-%d-%d=7", num[0], num[1], num[2], num[3]);
	
}


/*          提出前の確認

・デバッグ用の関数は＜＜コメント化＞＞しているか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

template <typename X>
struct SegmentTree {
    using FX = function<X(X, X)>;
    int n;
    FX fx;
    const X ex;
    vector<X> dat;
    SegmentTree(int n_, FX fx_, X ex_) : fx(fx_), ex(ex_) {
        int x = 1;
        while (n_ > x) x *= 2;
        n = x;
        dat.resize(n * 2, ex);
    }

    X get(int i) {
        return dat[i + n - 1];
    }
    void set(int i, X x) {
        dat[i + n - 1] = x;
    }
    void build() {
        for (int i = n - 2; i >= 0; --i) {
            dat[i] = fx(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }
    void update(int i, X x) {
        i += n - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            dat[i] = fx(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }

    X query(int a, int b) {
        return query_sub(a, b, 0, 0, n);
    }
    X query_sub(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return ex;
        }
        else if (a <= l && r <= b) {
            return dat[k];
        }
        else {
            X vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            X vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return fx(vl, vr);
        }
    }
};

int main() {
    int n, q, qq, i, l, r;
    char c;
    string s;
    cin >> n >> s >> q;
    SegmentTree<int> rsq(n,
    [](int x1, int x2) -> int { return x1 | x2; },
    0 );
    for (int j = 0; j < n; ++j) {
        rsq.set(j, 1 << (s[j] - 'a'));
    }
    rsq.build();
    while (q--) {
        cin >> qq;
        if (qq == 1) {
            cin >> i >> c;
            i--;
            rsq.update(i, 1 << (c - 'a'));
        }
        else {
            cin >> l >> r;
            int t = rsq.query(l - 1, r);
            int cnt = 0;
            while (t > 0) {
                cnt += (t & 1);
                t >>= 1;
            }
            cout << cnt << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 5124
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int K = sc.nextInt();
        int[] roots = new int[N];
        int[] cnts = new int[N];
        int[] jisu = new int[N];
        int[] ans = new int[N];
        for(int i=0;i<N;i++){
            roots[i]=i;
            cnts[i] = 0;
            jisu[i]=0;
        }

        for(int i=0;i<M;i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            jisu[a]++;
            jisu[b]++;
            my_union(roots, a, b);
        }
        for(int i=0;i<N;i++){
            int root = my_find(roots, i);
            cnts[root]++;
        }
        for(int i=0;i<N;i++){
            int root = my_find(roots, i);
            ans[i] = cnts[root]-1;
            ans[i] -= jisu[i];
        }
        for(int i=0;i<K;i++){
            int c = sc.nextInt()-1;
            int d = sc.nextInt()-1;
            if(my_find(roots, c) == my_find(roots, d)){
                ans[c]--;
                ans[d]--;
            }
        }
        for(int p:ans){
            System.out.print(p + " ");
        }
    }

    private static void printarr(int[] a){
        for(int p:a){
            System.out.print(p);
        }
        System.out.println();
    }

    private static int my_find(int[] roots, int i){
        List<Integer> ch = new ArrayList<>();
        while(roots[i] != i){
            ch.add(i);
            i = roots[i];
        }
        for(Integer c:ch){
            roots[c] = i;
        }
        return i;
    }

    private static void my_union(int[] roots, int a, int b){
        int ra = my_find(roots, a);
        int rb = my_find(roots, b);
        roots[ra] = rb;
        return;
    }

}


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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll n, t;
ll x[200000];
ll ans = 0;

int main() {
    cin >> n >> t;
    rep(i,n) cin >> x[i];
    ans = t;
    rep(i,n-1) ans += min(t, x[i+1]-x[i]);
    cout << ans << endl;
}
































Measured memory_bytes: 1792
/*
	Nishant Singh
	nishant.ns19@gmail.com
*/
#include <bits/stdc++.h>
#include <functional> 
#include <iostream> 
// ******** Big Integer ********
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// #define ll1024  int1024_t
// ******** Big Integer ********
// ******** Using PBDS ********
// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ook order_of_key    //count of strictly smaller elements
// #define fbo find_by_order   //find element at an index 
// ******** Using PBDS ********
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vll vector<ll>
#define vec vector
#define setcount(x) __builtin_popcountll(x)
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define REV(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define in insert
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
#define pq priority_queue
#define ffl fflush(stdout)
#define mset multiset
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define ub upper_bound
#define lb lower_bound 
#define ln "\n"
#define Y "YES"
#define N "NO"
ll const mod=1e9 + 7;
ll const inf=2e18;
// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********
inline ll add(ll a,ll b) 
{ 
	return (a%mod + b%mod + mod)%mod; 
}
inline ll mul(ll a,ll b) 
{ 
	return (a%mod * b%mod + mod)%mod; 
}
inline ll sub(ll a,ll b) 
{ 
	return (a%mod - b%mod + mod)%mod; 
}
ll gcd(ll a,ll b)
{
	if (b == 0) 
		return a; 
	return gcd(b, a % b);  
}
ll modexp(ll x, ll n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
ll modinv(ll n)
{
	return modexp(n,mod-2);
}
// ******** GLOBAL VARIABLES ********
// ******** GLOBAL VARIABLES ********
void solve(){
	ll n,k;
	cin>>n>>k;
	ll a[n];
	ll last=1;
	REP(i,n)
	{
		cin>>a[i];
	}
	for(int i=k;i<n;i++)
	{
		if(a[i]>a[i-k])
		{
			cout<<"Yes\n";
		}
		else
		{
			cout<<"No\n";
		}
	}
}  
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll T=1;
	// cin>>T; 	
	for(int t=1;t<=T;t++)
	{
		// cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 5212
#include <bits/stdc++.h>
using namespace std;
typedef complex <double> point;
vector <point> pol;

bool eq(double a,double b){
  return (abs(a-b)<=(1e-9));
}

bool on_segment(point a,point b,point c){
  return eq(abs(b-a),abs(a-c)+abs(b-c));
}

double get_r(point a,point b,point c){
  b-=a,c-=a;
  b*=conj(c);
  return arg(b);
}

int solve(point a){
  for(int i=0;i<pol.size();i++)
    if(on_segment(pol[i],pol[(i+1)%pol.size()],a)) return 1;
 
  double sum=0;
  for(int i=0;i<pol.size();i++)
    sum+=get_r(a,pol[i],pol[(i+1)%pol.size()]);

  if(abs(sum)<=0.0001)return 0;
  return 2;
}


int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++) {
    double a,b;
    cin>>a>>b;
    pol.push_back(point(a,b));
  }

  int q;
  cin>>q;
  while(q--){
    double a,b;
    cin>>a>>b;
    cout<<solve(point(a,b))<<endl;
  }
  return 0;
}

Measured memory_bytes: 1340
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int main() {
	int n, k;

	cin >> n >> k;

	int tmp;
	int p, q;

	long long ans;

	if (k % 2 == 1) {
		tmp = n / k;
		ans = pow(tmp, 3);
		ANS(ans);
	}
	else {
		p = n / k;
		q = n % k;

		if (q < k / 2) {
			ans = pow(p, 3)*2;
			ANS(ans)
		}
		else {
			ans = pow(p, 3) + pow(p + 1, 3);
			ANS(ans)
		}
		
	}

	return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int N = Integer.parseInt(sc.next());
		if(N%10==9 || N>=90){
			out.println("Yes");
		}else{
			out.println("No");
		}
		out.flush();	
	}
}


Measured memory_bytes: 22996
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] inputA = line.split("");
        line = sc.nextLine();
        String[] inputB = line.split("");
      
      int count =0;
      for(int i=0;i<inputA.length;i++){
        if(!inputA[i].equals(inputB[i])){
          count++;
        }
      }
       System.out.println(String.valueOf(count));
    }
}

Measured memory_bytes: 66232